示例#1
0
    def __init__(self, caller):
        RegionAwareMode.__init__(self, caller)

        self.dlg = DlgRegionHighlights(Globals.root, self.Update,
                                       self.GoToRegion)

        self.region = None
        self.profileIndices = None
        self.renProfiles = None
        self.caller = caller
示例#2
0
    def __init__(self,caller):
        RegionAwareMode.__init__(self,caller)

        self.dlg = DlgRegionHighlights(Globals.root,
                                       self.Update,
                                       self.GoToRegion)

        self.region = None
        self.profileIndices = None
        self.renProfiles = None
        self.caller = caller
示例#3
0
class Highlight(RegionAwareMode):
    def __init__(self, caller):
        RegionAwareMode.__init__(self, caller)

        self.dlg = DlgRegionHighlights(Globals.root, self.Update,
                                       self.GoToRegion)

        self.region = None
        self.profileIndices = None
        self.renProfiles = None
        self.caller = caller

    def Finish(self):
        RegionAwareMode.Finish(self)
        #  class specific operations
        #     - cancel the dialog
        #     - destroy special glyphs, if any
        self.dlg.cancel()
        self.ClearProfiles()
        Globals.renWin.Render()

    def UpdateObservers(self):
        """ adds functionality to that of the basic RegionAware mode
        current region needs to be deselected when changing """

        RegionAwareMode.UpdateObservers(self)

        self.ClearProfiles()
        self.dlg.ClearData()
        #print " nullifying region"
        self.region = None

    def ClearProfiles(self):

        if self.renProfiles:
            for rp in self.renProfiles:
                rp.profile.GetProperty().SetColor(1, 1, 1)
            self.renProfiles = None

    def ShowProfiles(self):
        """ highlights profiles associated with the current region """

        self.ClearProfiles()
        if self.region and self.profileIndices:
            self.renProfiles = [ self.region.rendering.profiles[p] \
                                 for p in self.profileIndices ]
            for rp in self.renProfiles:
                rp.profile.GetProperty().SetColor(
                    Globals.preferences["highlightRed"],
                    Globals.preferences["highlightGreen"],
                    Globals.preferences["highlightBlue"])
        Globals.renWin.Render()

    def GoToRegion(self, regionId):
        """ will change the slice for a certain region"""

        # search through the list of regions and see if the value exists
        allRegions = Globals.objectSet.GetAllRegions()
        region = None
        for r in allRegions:
            if r.index == regionId:
                region = r
                break
        if not region: return

        # set the view accordingly
        # to prevent dialog data from being cleared, set no update flag
        self.caller.SetOrientation(region.orientation)
        self.caller.SetSlice(region.sliceIndex)
        self.caller.scaleSlice.set(region.sliceIndex)
        print " setting region"
        #self.region = region
        #self.dlg.SetRegion(regionId)

    def SelectRegion(self, a, b):

        regionId = self.GetSelectedRegion(a, b)
        if regionId == None: return

        self.region = Globals.objectSet.visibleRegions[regionId]
        self.dlg.SetRegion(self.region.index)

    def Update(self, indices):
        """ will do the actual highlighting of the profiles"""

        # todo - should this be here?
        if self.region == None: return

        # check to see if the indices are valid
        tmpIndices = [int(i) for i in indices]
        self.profileIndices = [
            pidx for pidx in tmpIndices
            if pidx >= 0 and pidx < len(self.region.profiles)
        ]
        self.ShowProfiles()
示例#4
0
class Highlight(RegionAwareMode):

    def __init__(self,caller):
        RegionAwareMode.__init__(self,caller)

        self.dlg = DlgRegionHighlights(Globals.root,
                                       self.Update,
                                       self.GoToRegion)

        self.region = None
        self.profileIndices = None
        self.renProfiles = None
        self.caller = caller

    def Finish(self):
        RegionAwareMode.Finish(self)
        #  class specific operations
        #     - cancel the dialog
        #     - destroy special glyphs, if any
        self.dlg.cancel()
        self.ClearProfiles()
        Globals.renWin.Render()

    def UpdateObservers(self):
        """ adds functionality to that of the basic RegionAware mode
        current region needs to be deselected when changing """

        RegionAwareMode.UpdateObservers(self)

        self.ClearProfiles()
        self.dlg.ClearData()
        #print " nullifying region"
        self.region = None

            
    def ClearProfiles(self):

        if self.renProfiles:
            for rp in self.renProfiles:
                rp.profile.GetProperty().SetColor(1,1,1)
            self.renProfiles = None

    def ShowProfiles(self):
        """ highlights profiles associated with the current region """

        self.ClearProfiles()
        if self.region and self.profileIndices:
            self.renProfiles = [ self.region.rendering.profiles[p] \
                                 for p in self.profileIndices ]
            for rp in self.renProfiles:
                rp.profile.GetProperty().SetColor(
                    Globals.preferences["highlightRed"],
                    Globals.preferences["highlightGreen"],
                    Globals.preferences["highlightBlue"] )
        Globals.renWin.Render()
        
    def GoToRegion(self,regionId):
        """ will change the slice for a certain region"""

        # search through the list of regions and see if the value exists
        allRegions = Globals.objectSet.GetAllRegions()
        region = None
        for r in allRegions:
            if r.index == regionId:
                region = r
                break
        if not region: return

        # set the view accordingly
        # to prevent dialog data from being cleared, set no update flag
        self.caller.SetOrientation( region.orientation )
        self.caller.SetSlice( region.sliceIndex )
        self.caller.scaleSlice.set(region.sliceIndex)
        print " setting region"
        #self.region = region
        #self.dlg.SetRegion(regionId)


    def SelectRegion(self,a,b):

        regionId = self.GetSelectedRegion(a,b)
        if regionId == None: return

        self.region = Globals.objectSet.visibleRegions[regionId]
        self.dlg.SetRegion(self.region.index)

    def Update(self,indices):
        """ will do the actual highlighting of the profiles"""

        # todo - should this be here?
        if self.region==None: return
        
        # check to see if the indices are valid
        tmpIndices = [int(i) for i in indices]
        self.profileIndices = [ pidx for pidx in tmpIndices
                                if pidx>=0 and pidx<len(self.region.profiles) ]
        self.ShowProfiles()