def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") layout = QVBoxLayout() layout.setSpacing(0) self._drawer.setLayout( layout ) thresholdWidget = ThresholdingWidget(self) thresholdWidget.valueChanged.connect( self.handleThresholdGuiValuesChanged ) self._drawer.layout().addWidget( thresholdWidget ) self._drawer.layout().addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) def updateDrawerFromOperator(): minValue, maxValue = (0,255) if self.topLevelOperatorView.MinValue.ready(): minValue = self.topLevelOperatorView.MinValue.value if self.topLevelOperatorView.MaxValue.ready(): maxValue = self.topLevelOperatorView.MaxValue.value thresholdWidget.setValue(minValue, maxValue) self.topLevelOperatorView.MinValue.notifyDirty( bind(updateDrawerFromOperator) ) self.topLevelOperatorView.MaxValue.notifyDirty( bind(updateDrawerFromOperator) ) updateDrawerFromOperator()
def initAppletDrawerUi(self): with Tracer(traceLogger): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") layout = QVBoxLayout( self ) layout.setSpacing(0) self._drawer.setLayout( layout ) thresholdWidget = ThresholdingWidget(self) thresholdWidget.valueChanged.connect( self.handleThresholdGuiValuesChanged ) layout.addWidget( thresholdWidget ) def updateDrawerFromOperator(): minValue, maxValue = (0,255) if self.mainOperator.MinValue.ready(): minValue = self.mainOperator.MinValue.value if self.mainOperator.MaxValue.ready(): maxValue = self.mainOperator.MaxValue.value thresholdWidget.setValue(minValue, maxValue) self.mainOperator.MinValue.notifyDirty( bind(updateDrawerFromOperator) ) self.mainOperator.MaxValue.notifyDirty( bind(updateDrawerFromOperator) )
def initialize_range_widgets(self, datasourceIdx: int, thresholding_widget: ThresholdingWidget, autorange_checkbox): def handleRangeChanged(a, b): self.layer.set_normalize(datasourceIdx, (a, b)) normalization_range = self.layer.get_datasource_default_range(datasourceIdx) thresholding_widget.setRange(normalization_range[0], normalization_range[1]) normalization_value = self.layer.get_datasource_range(datasourceIdx) thresholding_widget.setValue(normalization_value[0], normalization_value[1]) thresholding_widget.valueChanged.connect(handleRangeChanged) def handleAutoRangeChanged(state): self.layer.set_normalize(datasourceIdx, None if state == Qt.Checked else thresholding_widget.getRange()) thresholding_widget.setEnabled(state == Qt.Unchecked) autorange_checkbox.stateChanged.connect(handleAutoRangeChanged) autorange_state = Qt.Checked if self.layer._autoMinMax[datasourceIdx] else Qt.Unchecked autorange_checkbox.setCheckState(autorange_state)
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir + "/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect(self.apply_gui_settings_to_operator) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.thresholdWidget) layout.addSpacerItem(QSpacerItem(0, 0, vPolicy=QSizePolicy.Expanding)) # Apply layout to the drawer self._drawer.setLayout(layout) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui()
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect( self.apply_gui_settings_to_operator ) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self.thresholdWidget ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) # Apply layout to the drawer self._drawer.setLayout( layout ) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui()
def createWidget(self, parent): return ThresholdingWidget(parent)
class ThresholdMaskingGui(LayerViewerGui): """ Simple example of an applet tha """ ########################################### ### AppletGuiInterface Concrete Methods ### ########################################### def appletDrawer(self): return self._drawer # (Other methods already provided by our base class) ########################################### ########################################### def __init__(self, parentApplet, topLevelOperatorView): """ """ self.topLevelOperatorView = topLevelOperatorView super(ThresholdMaskingGui, self).__init__(parentApplet, self.topLevelOperatorView) def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect( self.apply_gui_settings_to_operator ) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self.thresholdWidget ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) # Apply layout to the drawer self._drawer.setLayout( layout ) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui() def apply_operator_settings_to_gui(self): minValue, maxValue = (0,255) if self.topLevelOperatorView.MinValue.ready(): minValue = self.topLevelOperatorView.MinValue.value if self.topLevelOperatorView.MaxValue.ready(): maxValue = self.topLevelOperatorView.MaxValue.value self.thresholdWidget.setValue(minValue, maxValue) def apply_gui_settings_to_operator(self, minVal, maxVal): self.topLevelOperatorView.MinValue.setValue(minVal) self.topLevelOperatorView.MaxValue.setValue(maxVal) def setupLayers(self): """ Overridden from LayerViewerGui. Create a list of all layer objects that should be displayed. """ layers = [] # Show the thresholded data outputImageSlot = self.topLevelOperatorView.Output if outputImageSlot.ready(): outputLayer = self.createStandardLayerFromSlot( outputImageSlot ) outputLayer.name = "min <= x <= max" outputLayer.visible = True outputLayer.opacity = 0.75 layers.append(outputLayer) # Show the data invertedOutputSlot = self.topLevelOperatorView.InvertedOutput if invertedOutputSlot.ready(): invertedLayer = self.createStandardLayerFromSlot( invertedOutputSlot ) invertedLayer.name = "(x < min) U (x > max)" invertedLayer.visible = True invertedLayer.opacity = 0.25 layers.append(invertedLayer) # Show the raw input data inputImageSlot = self.topLevelOperatorView.InputImage if inputImageSlot.ready(): inputLayer = self.createStandardLayerFromSlot( inputImageSlot ) inputLayer.name = "Raw Input" inputLayer.visible = True inputLayer.opacity = 1.0 layers.append(inputLayer) return layers
class ThresholdMaskingGui(LayerViewerGui): """ Simple example of an applet tha """ ########################################### ### AppletGuiInterface Concrete Methods ### ########################################### def appletDrawer(self): return self._drawer # (Other methods already provided by our base class) ########################################### ########################################### def __init__(self, parentApplet, topLevelOperatorView): """ """ self.topLevelOperatorView = topLevelOperatorView super(ThresholdMaskingGui, self).__init__(parentApplet, self.topLevelOperatorView) def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir + "/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect(self.apply_gui_settings_to_operator) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.thresholdWidget) layout.addSpacerItem(QSpacerItem(0, 0, vPolicy=QSizePolicy.Expanding)) # Apply layout to the drawer self._drawer.setLayout(layout) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui() def apply_operator_settings_to_gui(self): minValue, maxValue = (0, 255) if self.topLevelOperatorView.MinValue.ready(): minValue = self.topLevelOperatorView.MinValue.value if self.topLevelOperatorView.MaxValue.ready(): maxValue = self.topLevelOperatorView.MaxValue.value self.thresholdWidget.setValue(minValue, maxValue) def apply_gui_settings_to_operator(self, minVal, maxVal): self.topLevelOperatorView.MinValue.setValue(minVal) self.topLevelOperatorView.MaxValue.setValue(maxVal) def setupLayers(self): """ Overridden from LayerViewerGui. Create a list of all layer objects that should be displayed. """ layers = [] # Show the thresholded data outputImageSlot = self.topLevelOperatorView.Output if outputImageSlot.ready(): outputLayer = self.createStandardLayerFromSlot(outputImageSlot) outputLayer.name = "min <= x <= max" outputLayer.visible = True outputLayer.opacity = 0.75 layers.append(outputLayer) # Show the data invertedOutputSlot = self.topLevelOperatorView.InvertedOutput if invertedOutputSlot.ready(): invertedLayer = self.createStandardLayerFromSlot(invertedOutputSlot) invertedLayer.name = "(x < min) U (x > max)" invertedLayer.visible = True invertedLayer.opacity = 0.25 layers.append(invertedLayer) # Show the raw input data inputImageSlot = self.topLevelOperatorView.InputImage if inputImageSlot.ready(): inputLayer = self.createStandardLayerFromSlot(inputImageSlot) inputLayer.name = "Raw Input" inputLayer.visible = True inputLayer.opacity = 1.0 layers.append(inputLayer) return layers