Multiple qvectorlayers on imshow inherit eachothers transform
When I have an imshow with multiple qvectorlayers on it, any transforms I apply on the first one are propagated by the second one:
import "Quasar.UI.dll" function [] = main() image = ones(600,600) ims = imshow(image,[0,1]) lyr1 = new(qvectorlayer);lyr1.translatetransform([200,200]);lyr1.setbrushcolor("blue") lyr2 = new(qvectorlayer);lyr2.translatetransform([200,200]);lyr2.setbrushcolor("cyan") lyr1.fillellipse([-20,-20],[20,20]) lyr2.fillellipse([-10,-10],[10,10]) ims.addlayer(lyr1) ims.addlayer(lyr2) ims.update() end
results in
Only showing lyr2:
import "Quasar.UI.dll" function [] = main() image = ones(600,600) ims = imshow(image,[0,1]) lyr1 = new(qvectorlayer);lyr1.translatetransform([200,200]);lyr1.setbrushcolor("blue") lyr2 = new(qvectorlayer);lyr2.translatetransform([200,200]);lyr2.setbrushcolor("cyan") lyr1.fillellipse([-20,-20],[20,20]) lyr2.fillellipse([-10,-10],[10,10]) %ims.addlayer(lyr1) ims.addlayer(lyr2) ims.update() end
And, finally, the image I ‘wanted’:
import "Quasar.UI.dll" function [] = main() image = ones(600,600) ims = imshow(image,[0,1]) lyr1 = new(qvectorlayer);lyr1.translatetransform([200,200]);lyr1.setbrushcolor("blue") lyr2 = new(qvectorlayer);lyr2.setbrushcolor("cyan") lyr1.fillellipse([-20,-20],[20,20]) lyr2.fillellipse([-10,-10],[10,10]) ims.addlayer(lyr1) ims.addlayer(lyr2) ims.update() end
It is rather silly that the rendering of one layer is impacted by whether or not I add an additional layer – the transform should be separate for each qvectorlayer.
1 Answers
Best Answer
The best workaround I have found in my case to be an additional transform layer that is added to the imshow prior to any others, and that contains the global transform. Any local transforms used in the rendering of the other layers should be reverted when rendering on that layer is finished.