def showColorBox(self): self.colorNode = EditUtil.getColorNode() if not self.colorBox: self.colorBox = ColorBox.ColorBox(parameterNode=self.parameterNode, parameter=self.parameter, colorNode=self.colorNode) self.colorBox.show(parameterNode=self.parameterNode, parameter=self.parameter, colorNode=self.colorNode)
def updateGUIFromMRML(self,caller,event): if self.parameterNode.GetParameter(self.parameter) == '': # parameter does not exist - probably initializing return label = int(self.parameterNode.GetParameter(self.parameter)) self.colorNode = EditUtil.getColorNode() if self.colorNode: self.frame.setDisabled(0) self.labelName.setText( self.colorNode.GetColorName( label ) ) lut = self.colorNode.GetLookupTable() rgb = lut.GetTableValue( label ) self.colorPatch.setStyleSheet( "background-color: rgb(%s,%s,%s)" % (rgb[0]*255, rgb[1]*255, rgb[2]*255) ) self.colorSpin.setMaximum( self.colorNode.GetNumberOfColors()-1 ) else: self.frame.setDisabled(1) try: self.colorSpin.setValue(label) except ValueError: # TODO: why does the python class still exist if the widget is destroyed? # - this only happens when reloading the module. The owner of the # instance is gone and the widgets are gone, but this instance still # has observer on the parameter node - this indicates memory leaks # that need to be fixed self.cleanup() return
def updateGUIFromMRML(self, caller, event): if self.parameterNode.GetParameter(self.parameter) == '': # parameter does not exist - probably intializing return label = int(self.parameterNode.GetParameter(self.parameter)) self.colorNode = EditUtil.getColorNode() if self.colorNode: self.frame.setDisabled(0) self.labelName.setText(self.colorNode.GetColorName(label)) lut = self.colorNode.GetLookupTable() rgb = lut.GetTableValue(label) self.colorPatch.setStyleSheet( "background-color: rgb(%s,%s,%s)" % (rgb[0] * 255, rgb[1] * 255, rgb[2] * 255)) self.colorSpin.setMaximum(self.colorNode.GetNumberOfColors() - 1) else: self.frame.setDisabled(1) try: self.colorSpin.setValue(label) except ValueError: # TODO: why does the python class still exist if the widget is destroyed? # - this only happens when reloading the module. The owner of the # instance is gone and the widgets are gone, but this instance still # has observer on the parameter node - this indicates memory leaks # that need to be fixed self.cleanup() return
def updateGUIFromMRML(self,caller,event): if self.parameterNode.GetParameter(self.parameter) == '': # parameter does not exist - probably intializing return label = int(self.parameterNode.GetParameter(self.parameter)) self.colorNode = EditUtil.getColorNode() if self.colorNode: self.frame.setDisabled(0) self.labelName.setText( self.colorNode.GetColorName( label ) ) lut = self.colorNode.GetLookupTable() rgb = lut.GetTableValue( label ) self.colorPatch.setStyleSheet( "background-color: rgb(%s,%s,%s)" % (rgb[0]*255, rgb[1]*255, rgb[2]*255) ) self.colorSpin.setMaximum( self.colorNode.GetNumberOfColors()-1 ) else: self.frame.setDisabled(1) try: self.colorSpin.setValue(label) # check to see if there's an associated terminology with this color node if self.colorNode: terminologyName = self.colorNode.GetAttribute("TerminologyName") if terminologyName: colorLogic = slicer.modules.colors.logic() if colorLogic: # enable the terminology widgets self.hideTerminology(0) region = colorLogic.GetAnatomicRegionCodeMeaning(label, terminologyName) regionModifier = colorLogic.GetAnatomicRegionModifierCodeMeaning(label, terminologyName) category = colorLogic.GetSegmentedPropertyCategoryCodeMeaning(label, terminologyName) categoryType = colorLogic.GetSegmentedPropertyTypeCodeMeaning(label, terminologyName) categoryModifier = colorLogic.GetSegmentedPropertyTypeModifierCodeMeaning(label, terminologyName) self.terminologyRegion.setText(region) self.terminologyRegionModifier.setText(regionModifier) self.terminologyCategory.setText(category) self.terminologyCategoryType.setText(categoryType) self.terminologyCategoryModifier.setText(categoryModifier) # if no region information, hide the region panel if region is "" and regionModifier is "": self.terminologyRegionFrame.setHidden(1) else: self.terminologyRegionFrame.setHidden(0) else: self.hideTerminology(1) except ValueError: # TODO: why does the python class still exist if the widget is destroyed? # - this only happens when reloading the module. The owner of the # instance is gone and the widgets are gone, but this instance still # has observer on the parameter node - this indicates memory leaks # that need to be fixed self.cleanup() return
def updateGUIFromMRML(self, caller, event): if self.parameterNode.GetParameter(self.parameter) == '': # parameter does not exist - probably intializing return label = int(self.parameterNode.GetParameter(self.parameter)) self.colorNode = EditUtil.getColorNode() if self.colorNode: self.frame.setDisabled(0) self.labelName.setText(self.colorNode.GetColorName(label)) lut = self.colorNode.GetLookupTable() rgb = lut.GetTableValue(label) self.colorPatch.setStyleSheet( "background-color: rgb(%s,%s,%s)" % (rgb[0] * 255, rgb[1] * 255, rgb[2] * 255)) self.colorSpin.setMaximum(self.colorNode.GetNumberOfColors() - 1) else: self.frame.setDisabled(1) try: self.colorSpin.setValue(label) # check to see if there's an associated terminology with this color node if self.colorNode: terminologyName = self.colorNode.GetAttribute( "TerminologyName") if terminologyName: colorLogic = slicer.modules.colors.logic() if colorLogic: # enable the terminology widgets self.hideTerminology(0) region = colorLogic.GetAnatomicRegionCodeMeaning( label, terminologyName) regionModifier = colorLogic.GetAnatomicRegionModifierCodeMeaning( label, terminologyName) category = colorLogic.GetSegmentedPropertyCategoryCodeMeaning( label, terminologyName) categoryType = colorLogic.GetSegmentedPropertyTypeCodeMeaning( label, terminologyName) categoryModifier = colorLogic.GetSegmentedPropertyTypeModifierCodeMeaning( label, terminologyName) self.terminologyRegion.setText(region) self.terminologyRegionModifier.setText(regionModifier) self.terminologyCategory.setText(category) self.terminologyCategoryType.setText(categoryType) self.terminologyCategoryModifier.setText( categoryModifier) # if no region information, hide the region panel if region is "" and regionModifier is "": self.terminologyRegionFrame.setHidden(1) else: self.terminologyRegionFrame.setHidden(0) else: self.hideTerminology(1) except ValueError: # TODO: why does the python class still exist if the widget is destroyed? # - this only happens when reloading the module. The owner of the # instance is gone and the widgets are gone, but this instance still # has observer on the parameter node - this indicates memory leaks # that need to be fixed self.cleanup() return