You have to add the roi to the image so that it can be identified as
current scene.
Example:
self.imv.addItem(copyROI)
handles = copyROI.getHandles()
for index, item in enumerate(handles):
copyROI.removeHandle(item)
where imv is the ImageView
El lunes, 25 de julio de 2016, 7:22:00 (UTC-5), Cho escribió:
>
> Hi,
>
> I have a question regarding ROIs. I have an image with a ROI which is
> movable by the user. Upon clicking a "save ROI" button I wish to save the
> ROI to do some analysis with it. In principle I want to display the saved
> ROI in the image but make it fixed in position and size so that it cannot
> be altered by the user anymore. Here's how I thought how I would go about
> doing that:
>
> -> make a copy of the current movable and scalable ROI
> -> change attributes of that copy; fix size and position
> -> add copy to the plot
>
> def saveROI(self):
> copyROI = self._ROI #make copy of user-draggable ROI
> # copyROI.setProperty("movable", False) #doesn't seem to work
> copyROI.setZValue(10) # make sure ROI is drawn above image
> copyROI.translatable = False #fix position
> copyROI.removeHandle(0) #disable scaling
> self._Plot.addItem(copyROI)
>
> However, this will overwrite the user-draggable ROI (self._ ROI) and only
> display the copy. I think the ROI object must have some index so basically
> it is overwritten by the copy?
> To overcome this I could get all the relevant data from the user-ROI and
> build fixed ROI from that but it seems kinda ugly (lots of if statments to
> handle the different ROI shapes etc.). It would be much nicer to create a
> copy and just alter some attributes on the fly. Is this possible?
>
> On a side note, could someone explain to me how one uses the .setProperty
> method correctly?
>
> Thanks a lot, Chris
>
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/5190ed11-ecfa-434e-89b5-c9ff23047c19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.