def create(self): super(PaintEffectOptions,self).create() self.radiusFrame = qt.QFrame(self.frame) self.radiusFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.radiusFrame) self.widgets.append(self.radiusFrame) self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame) self.radiusLabel.setToolTip("Set the radius of the paint brush in millimeters") self.radiusFrame.layout().addWidget(self.radiusLabel) self.widgets.append(self.radiusLabel) self.radiusSpinBox = qt.QDoubleSpinBox(self.radiusFrame) self.radiusSpinBox.setToolTip("Set the radius of the paint brush in millimeters") self.radiusSpinBox.minimum = 0.01 self.radiusSpinBox.maximum = 100 self.radiusSpinBox.suffix = "mm" self.radiusFrame.layout().addWidget(self.radiusSpinBox) self.widgets.append(self.radiusSpinBox) self.radiusUnitsToggle = qt.QPushButton("px:") self.radiusUnitsToggle.setToolTip("Toggle radius quick set buttons between mm and label volume pixel size units") self.radiusUnitsToggle.setFixedWidth(35) self.radiusFrame.layout().addWidget(self.radiusUnitsToggle) self.radiusUnitsToggle.connect('clicked()',self.onRadiusUnitsToggle) self.radiusQuickies = {} quickies = ( (2, self.onQuickie2Clicked), (3,self.onQuickie3Clicked), (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked), (10, self.onQuickie10Clicked), (20, self.onQuickie20Clicked) ) for rad,callback in quickies: self.radiusQuickies[rad] = qt.QPushButton(str(rad)) self.radiusFrame.layout().addWidget(self.radiusQuickies[rad]) self.radiusQuickies[rad].setFixedWidth(25) self.radiusQuickies[rad].connect('clicked()', callback) self.radiusQuickies[rad].setToolTip("Set radius based on mm or label voxel size units depending on toggle value") self.radius = ctk.ctkDoubleSlider(self.frame) self.radius.minimum = 0.01 self.radius.maximum = 100 self.radius.orientation = 1 self.radius.singleStep = 0.01 self.frame.layout().addWidget(self.radius) self.widgets.append(self.radius) self.smudge = qt.QCheckBox("Smudge", self.frame) self.smudge.setToolTip("Set the label number automatically by sampling the pixel location where the brush stroke starts.") self.frame.layout().addWidget(self.smudge) self.widgets.append(self.smudge) EditorLib.HelpButton(self.frame, "Use this tool to paint with a round brush of the selected radius") self.connections.append( (self.smudge, 'clicked()', self.updateMRMLFromGUI) ) self.connections.append( (self.radius, 'valueChanged(double)', self.onRadiusValueChanged) ) self.connections.append( (self.radiusSpinBox, 'valueChanged(double)', self.onRadiusSpinBoxChanged) ) # Add vertical spacer self.frame.layout().addStretch(1)
def numericInputFrame(parent, label, tooltip, minimum, maximum, step, decimals): inputFrame = qt.QFrame(parent) inputFrame.setLayout(qt.QHBoxLayout()) inputLabel = qt.QLabel(label, inputFrame) inputLabel.setToolTip(tooltip) inputFrame.layout().addWidget(inputLabel) inputSpinBox = qt.QDoubleSpinBox(inputFrame) inputSpinBox.setToolTip(tooltip) inputSpinBox.minimum = minimum inputSpinBox.maximum = maximum inputSpinBox.singleStep = step inputSpinBox.decimals = decimals inputFrame.layout().addWidget(inputSpinBox) inputSlider = ctk.ctkDoubleSlider(inputFrame) inputSlider.minimum = minimum inputSlider.maximum = maximum inputSlider.orientation = 1 inputSlider.singleStep = step inputSlider.setToolTip(tooltip) inputFrame.layout().addWidget(inputSlider) return inputFrame, inputSlider, inputSpinBox
def create(self): super(InteractiveConnectedComponentsUsingParzenPDFsOptions, self).create() ioCollapsibleButton = ctk.ctkCollapsibleGroupBox() ioCollapsibleButton.title = "IO" ioCollapsibleButton.collapsed = 0 self.frame.layout().addWidget(ioCollapsibleButton) # Layout within the io collapsible button ioFormLayout = qt.QFormLayout(ioCollapsibleButton) self.additionalInputNodeSelectors = [] for i in range(0, 2): self.additionalInputNodeSelectors.append( self.addInputNodeSelector(i, ioFormLayout)) self.additionalInputNodeSelectors[ 0].toolTip = "Select the 1st additional input volume to be segmented" self.additionalInputNodeSelectors[ 1].toolTip = "Select the 2nd additional input volume to be segmented" # Objects objectCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() objectCollapsibleGroupBox.title = "Objects" self.frame.layout().addWidget(objectCollapsibleGroupBox) # Layout within the io collapsible button objectFormLayout = qt.QFormLayout(objectCollapsibleGroupBox) foregroundLayout = qt.QHBoxLayout() foregroundLabel = slicer.qMRMLLabelComboBox() foregroundLabel.objectName = 'Foreground label' foregroundLabel.setMRMLScene(slicer.mrmlScene) foregroundLabel.setMRMLColorNode(self.editUtil.getColorNode()) foregroundLabel.labelValueVisible = True foregroundLabel.currentColor = 1 self.foregroundLabel = foregroundLabel self.connections.append( (self.foregroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI)) foregroundWeightSpinBox = qt.QDoubleSpinBox(foregroundLabel) self.foregroundWeightSpinBox = foregroundWeightSpinBox foregroundWeightSpinBox.setRange(0.0, 1.0) foregroundWeightSpinBox.setSingleStep(0.1) foregroundWeightSpinBox.value = 1.0 foregroundPopup = ctk.ctkPopupWidget(foregroundWeightSpinBox) foregroundPopupLayout = qt.QHBoxLayout(foregroundPopup) foregroundPopupSlider = ctk.ctkDoubleSlider(foregroundPopup) self.foregroundPopupSlider = foregroundPopupSlider foregroundPopupSlider.maximum = 1.0 foregroundPopupSlider.minimum = 0.0 foregroundPopupSlider.singleStep = 0.1 foregroundPopupSlider.connect('valueChanged(double)', self.foregroundWeightSpinBox.setValue) foregroundWeightSpinBox.connect('valueChanged(double)', self.foregroundPopupSlider.setValue) self.connections.append( (self.foregroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI)) foregroundLayout.addWidget(foregroundLabel) foregroundLayout.addWidget(foregroundWeightSpinBox) foregroundPopupLayout.addWidget(foregroundPopupSlider) objectFormLayout.addRow("Foreground Label:", foregroundLayout) self.objectLabel = foregroundLabel # http://qt-project.org/doc/qt-4.7/qt.html foregroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight foregroundPopup.horizontalDirection = 0 # Qt::LeftToRight foregroundPopup.verticalDirection = 0 # Qt::TopToBottom foregroundPopup.animationEffect = 1 # Qt::ScrollEffect backgroundLayout = qt.QHBoxLayout() backgroundLabel = slicer.qMRMLLabelComboBox() backgroundLabel.objectName = 'Background label' backgroundLabel.setMRMLScene(slicer.mrmlScene) backgroundLabel.setMRMLColorNode(self.editUtil.getColorNode()) backgroundLabel.labelValueVisible = True backgroundLabel.currentColor = 2 self.backgroundLabel = backgroundLabel self.connections.append( (self.backgroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI)) backgroundWeightSpinBox = qt.QDoubleSpinBox(backgroundLabel) self.backgroundWeightSpinBox = backgroundWeightSpinBox backgroundWeightSpinBox.setRange(0.0, 1.0) backgroundWeightSpinBox.setSingleStep(0.1) backgroundWeightSpinBox.value = 1.0 backgroundPopup = ctk.ctkPopupWidget(backgroundWeightSpinBox) backgroundPopupLayout = qt.QHBoxLayout(backgroundPopup) backgroundPopupSlider = ctk.ctkDoubleSlider(backgroundPopup) self.backgroundPopupSlider = backgroundPopupSlider backgroundPopupSlider.maximum = 1.0 backgroundPopupSlider.minimum = 0.0 backgroundPopupSlider.singleStep = 0.1 backgroundPopupSlider.connect('valueChanged(double)', self.backgroundWeightSpinBox.setValue) backgroundWeightSpinBox.connect('valueChanged(double)', self.backgroundPopupSlider.setValue) self.connections.append( (self.backgroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI)) backgroundLayout.addWidget(backgroundLabel) backgroundLayout.addWidget(backgroundWeightSpinBox) backgroundPopupLayout.addWidget(backgroundPopupSlider) objectFormLayout.addRow("Background Label:", backgroundLayout) self.backgroundLabel = backgroundLabel # http://qt-project.org/doc/qt-4.7/qt.html backgroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight backgroundPopup.horizontalDirection = 0 # Qt::LeftToRight backgroundPopup.verticalDirection = 0 # Qt::TopToBottom backgroundPopup.animationEffect = 1 # Qt::ScrollEffect # Presets # Placeholder presetsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() presetsCollapsibleGroupBox.title = "Preset" self.frame.layout().addWidget(presetsCollapsibleGroupBox) presetComboBox = slicer.qSlicerPresetComboBox() # Advanced Parameters paramsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() paramsCollapsibleGroupBox.title = "Advanced Parameters" paramsCollapsibleGroupBox.collapsed = 1 self.frame.layout().addWidget(paramsCollapsibleGroupBox) # Layout within the io collapsible button paramsFormLayout = qt.QFormLayout(paramsCollapsibleGroupBox) erosionSpinBox = qt.QSpinBox() erosionSpinBox.objectName = 'erosionSpinBox' erosionSpinBox.toolTip = "Set the erosion radius." erosionSpinBox.setMinimum(0) erosionSpinBox.setValue(5) # Default paramsFormLayout.addRow("Erosion Radius:", erosionSpinBox) self.erosionSpinBox = erosionSpinBox self.connections.append( (self.erosionSpinBox, "valueChanged(int)", self.updateMRMLFromGUI)) holeFillSpinBox = qt.QSpinBox() holeFillSpinBox.objectName = 'holeFillSpinBox' holeFillSpinBox.toolTip = "Set the hole fill iterations." holeFillSpinBox.setMinimum(0) holeFillSpinBox.setValue(5) #Default paramsFormLayout.addRow("Hole Fill Iterations:", holeFillSpinBox) self.holeFillSpinBox = holeFillSpinBox self.connections.append((self.holeFillSpinBox, "valueChanged(int)", self.updateMRMLFromGUI)) # probabilitySmoothingStandardDeviation spin box probabilitySmoothingStdDevSpinBox = qt.QDoubleSpinBox() probabilitySmoothingStdDevSpinBox.objectName = 'probabilitySmoothingStdDevSpinBox' probabilitySmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to probability images prior to computing maximum likelihood of each class at each pixel." probabilitySmoothingStdDevSpinBox.setMinimum(0.0) probabilitySmoothingStdDevSpinBox.setValue(1.0) # Default probabilitySmoothingStdDevSpinBox.setSingleStep(0.5) paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", probabilitySmoothingStdDevSpinBox) self.probabilitySmoothingStdDevSpinBox = probabilitySmoothingStdDevSpinBox self.connections.append( (self.probabilitySmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI)) # histogramSmoothingStandardDeviation spin box histogramSmoothingStdDevSpinBox = qt.QDoubleSpinBox() histogramSmoothingStdDevSpinBox.objectName = 'histogramSmoothingStdDevSpinBox' histogramSmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to histograms to convert them to probability density function estimates." histogramSmoothingStdDevSpinBox.setMinimum(0.0) histogramSmoothingStdDevSpinBox.setValue(5.0) # Default histogramSmoothingStdDevSpinBox.setSingleStep(0.5) paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", histogramSmoothingStdDevSpinBox) self.histogramSmoothingStdDevSpinBox = histogramSmoothingStdDevSpinBox self.connections.append( (self.histogramSmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI)) # draft check box draftCheckBox = qt.QCheckBox() draftCheckBox.objectName = 'draftCheckBox' draftCheckBox.toolTip = "Downsamples results by a factor of 4." paramsFormLayout.addRow("Draft Mode:", draftCheckBox) self.draftCheckBox = draftCheckBox self.connections.append( (self.draftCheckBox, "stateChanged(int)", self.updateMRMLFromGUI)) # force classification check box forceClassificationCheckBox = qt.QCheckBox() forceClassificationCheckBox.objectName = 'forceClassificationCheckBox' forceClassificationCheckBox.toolTip = "Perform the classification of all voxels?" forceClassificationCheckBox.setChecked(False) paramsFormLayout.addRow("Classify all voxels: ", forceClassificationCheckBox) self.forceClassificationCheckBox = forceClassificationCheckBox self.connections.append((self.forceClassificationCheckBox, "stateChanged(int)", self.updateMRMLFromGUI)) # dilate first check box dilateFirstCheckBox = qt.QCheckBox() dilateFirstCheckBox.objectName = 'dilateFirstCheckBox' dilateFirstCheckBox.toolTip = "Dilate and then erode so as to fill-in holes?" dilateFirstCheckBox.setChecked(False) paramsFormLayout.addRow("Dilate First: ", dilateFirstCheckBox) self.dilateFirstCheckBox = dilateFirstCheckBox self.connections.append((self.dilateFirstCheckBox, "stateChanged(int)", self.updateMRMLFromGUI)) self.helpLabel = qt.QLabel( "Run the PDF Segmentation on the current label map.", self.frame) self.frame.layout().addWidget(self.helpLabel) self.apply = qt.QPushButton("Apply", self.frame) self.apply.setToolTip( "Apply to run segmentation.\nCreates a new label volume using the current volume as input" ) self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) EditorLib.HelpButton( self.frame, "Use this tool to apply segmentation using Parzen windowed PDFs.\n\n Select different label colors and paint on the foreground or background voxels using the paint effect.\nTo run segmentation correctly, you need to supply a minimum or two class labels." ) self.connections.append((self.apply, 'clicked()', self.onApply))
def create(self): super(PaintEffectOptions,self).create() labelVolume = self.editUtil.getLabelVolume() if labelVolume and labelVolume.GetImageData(): spacing = labelVolume.GetSpacing() dimensions = labelVolume.GetImageData().GetDimensions() self.minimumRadius = 0.5 * min(spacing) bounds = [a*b for a,b in zip(spacing,dimensions)] self.maximumRadius = 0.5 * max(bounds) else: self.minimumRadius = 0.01 self.maximumRadius = 100 self.radiusFrame = qt.QFrame(self.frame) self.radiusFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.radiusFrame) self.widgets.append(self.radiusFrame) self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame) self.radiusLabel.setToolTip("Set the radius of the paint brush in millimeters") self.radiusFrame.layout().addWidget(self.radiusLabel) self.widgets.append(self.radiusLabel) self.radiusSpinBox = slicer.qMRMLSpinBox(self.radiusFrame) self.radiusSpinBox.setToolTip("Set the radius of the paint brush in millimeters") self.radiusSpinBox.quantity = "length" # QFlags not wrapped in python. Equivalent to Prefix | Suffix # See qMRMLSpinBox for more details. self.radiusSpinBox.unitAwareProperties = 0x01 | 0x02 self.radiusSpinBox.minimum = self.minimumRadius self.radiusSpinBox.maximum = self.maximumRadius self.radiusSpinBox.setMRMLScene(slicer.mrmlScene) from math import log,floor decimals = floor(log(self.minimumRadius,10)) if decimals < 0: self.radiusSpinBox.decimals = -decimals + 2 self.radiusFrame.layout().addWidget(self.radiusSpinBox) self.widgets.append(self.radiusSpinBox) self.radiusUnitsToggle = qt.QPushButton("px:") self.radiusUnitsToggle.setToolTip("Toggle radius quick set buttons between mm and label volume pixel size units") self.radiusUnitsToggle.setFixedWidth(35) self.radiusFrame.layout().addWidget(self.radiusUnitsToggle) self.radiusUnitsToggle.connect('clicked()',self.onRadiusUnitsToggle) self.radiusQuickies = {} quickies = ( (2, self.onQuickie2Clicked), (3,self.onQuickie3Clicked), (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked), (10, self.onQuickie10Clicked), (20, self.onQuickie20Clicked) ) for rad,callback in quickies: self.radiusQuickies[rad] = qt.QPushButton(str(rad)) self.radiusFrame.layout().addWidget(self.radiusQuickies[rad]) self.radiusQuickies[rad].setFixedWidth(25) self.radiusQuickies[rad].connect('clicked()', callback) self.radiusQuickies[rad].setToolTip("Set radius based on mm or label voxel size units depending on toggle value") self.radius = ctk.ctkDoubleSlider(self.frame) self.radius.minimum = self.minimumRadius self.radius.maximum = self.maximumRadius self.radius.orientation = 1 self.radius.singleStep = self.minimumRadius self.frame.layout().addWidget(self.radius) self.widgets.append(self.radius) self.sphere = qt.QCheckBox("Sphere", self.frame) self.sphere.setToolTip("Use a 3D spherical brush rather than a 2D circular brush.") self.frame.layout().addWidget(self.sphere) self.widgets.append(self.sphere) self.smudge = qt.QCheckBox("Smudge", self.frame) self.smudge.setToolTip("Set the label number automatically by sampling the pixel location where the brush stroke starts.") self.frame.layout().addWidget(self.smudge) self.widgets.append(self.smudge) self.pixelMode = qt.QCheckBox("Pixel Mode", self.frame) self.pixelMode.setToolTip("Paint exactly the pixel under the cursor, ignoring the radius, threshold, and paint over.") self.frame.layout().addWidget(self.pixelMode) self.widgets.append(self.pixelMode) EditorLib.HelpButton(self.frame, "Use this tool to paint with a round brush of the selected radius") self.connections.append( (self.sphere, 'clicked()', self.updateMRMLFromGUI) ) self.connections.append( (self.smudge, 'clicked()', self.updateMRMLFromGUI) ) self.connections.append( (self.pixelMode, 'clicked()', self.updateMRMLFromGUI) ) self.connections.append( (self.radius, 'valueChanged(double)', self.onRadiusValueChanged) ) self.connections.append( (self.radiusSpinBox, 'valueChanged(double)', self.onRadiusSpinBoxChanged) ) # Add vertical spacer self.frame.layout().addStretch(1) # set the node parameters that are dependent on the input data self.parameterNode.SetParameter( "PaintEffect,radius", str(self.minimumRadius * 10) )
def createUserInterface(self): self.__layout = self.__parent.createUserInterface() ''' # Input fiducials node selector #self.inputFiducialsNodeSelector = slicer.qMRMLNodeComboBox() self.inputFiducialsNodeSelector.toolTip = "Select a fiducial to define an insertion point for a screw." self.inputFiducialsNodeSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "") self.inputFiducialsNodeSelector.addEnabled = False self.inputFiducialsNodeSelector.removeEnabled = False self.inputFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene ) self.inputFiducialsNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.fidChanged) self.__layout.addRow("Select Insertion Point:", self.inputFiducialsNodeSelector) self.fid = self.inputFiducialsNodeSelector.currentNode() self.sliceChange() ''' ''' # Input model selector self.inputScrewSelector = ctk.ctkComboBox() self.inputScrewSelector.toolTip = "Select a screw to insert." screwList = ['Select a screw','475x30', '475x35', '475x45', '550x30', '550x40', '550x45', '625x35', '625x40', '625x45', '625x50', '700x35', '700x40', '700x45', '700x50'] self.inputScrewSelector.addItems(screwList) self.connect(self.inputScrewSelector, PythonQt.QtCore.SIGNAL('activated(QString)'), self.combo_chosen) self.__layout.addRow("Choose Screw:", self.inputScrewSelector) vText = qt.QLabel("1st Instrumented Level:") iText = qt.QLabel("# to Instrument:") aText = qt.QLabel("Approach Direction:") self.vSelector = qt.QComboBox() self.vSelector.setMaximumWidth(120) self.levels = ("C1","C2","C3","C4","C5","C6","C7","T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12","L1", "L2", "L3", "L4", "L5","S1") self.vSelector.addItems(self.levels) self.iSelector = qt.QComboBox() self.iSelector.setMaximumWidth(120) self.iSelector.addItems(['1','2','3','4','5','6','7','8','9','10','11','12']) self.aSelector = qt.QComboBox() self.aSelector.setMaximumWidth(120) self.aSelector.addItems(['Posterior','Anterior','Left','Right']) blank = qt.QLabel(" ") blank.setMaximumWidth(30) #self.__layout.addWidget(vText) #self.__layout.addWidget(self.vSelector) #self.__layout.addWidget(iText) #self.__layout.addWidget(self.iSelector) self.vertebraeGridBox = qt.QGridLayout() self.vertebraeGridBox.addWidget(vText,0,0) self.vertebraeGridBox.addWidget(self.vSelector,1,0) self.vertebraeGridBox.addWidget(blank,0,1) self.vertebraeGridBox.addWidget(iText,0,2) self.vertebraeGridBox.addWidget(blank,1,1) self.vertebraeGridBox.addWidget(self.iSelector,1,2) self.vertebraeGridBox.addWidget(blank,0,3) self.vertebraeGridBox.addWidget(aText,0,4) self.vertebraeGridBox.addWidget(blank,1,3) self.vertebraeGridBox.addWidget(self.aSelector,1,4) self.__layout.addRow(self.vertebraeGridBox) ''' self.fiducial = ctk.ctkComboBox() self.fiducial.toolTip = "Select an insertion site." self.fiducial.addItems(self.fiduciallist) self.connect(self.fiducial, PythonQt.QtCore.SIGNAL('activated(QString)'), self.fiducial_chosen) #self.screwGridLayout.addWidget(self.fiducial,0,0) self.__layout.addRow("Insertion Site:", self.fiducial) self.__fiducial = '' measuredText1 = qt.QLabel(" Measured:") measuredText2 = qt.QLabel(" Measured:") lengthText = qt.QLabel("Screw Length: ") widthText = qt.QLabel("Screw Width: ") self.length = ctk.ctkComboBox() self.length.toolTip = "Select a screw to insert." screwList = ['Select a length (mm)', '475', '550', '625', '700'] self.length.addItems(screwList) self.connect(self.length, PythonQt.QtCore.SIGNAL('activated(QString)'), self.length_chosen) self.lengthMeasure = qt.QLineEdit() #self.__layout.addRow("Screw Length:", self.length) #self.__layout.addRow("Measured Pedicle Length:", self.lengthMeasure) self.__length = '' self.QHBox1 = qt.QHBoxLayout() self.QHBox1.addWidget(lengthText) self.QHBox1.addWidget(self.length) self.QHBox1.addWidget(measuredText1) self.QHBox1.addWidget(self.lengthMeasure) self.__layout.addRow(self.QHBox1) self.diameter = ctk.ctkComboBox() self.diameter.toolTip = "Select a screw to insert." screwList = ['Select a diameter (mm)', '30', '35', '45', '50'] self.diameter.addItems(screwList) self.widthMeasure = qt.QLineEdit() self.connect(self.diameter, PythonQt.QtCore.SIGNAL('activated(QString)'), self.diameter_chosen) #self.__layout.addRow("Screw Diameter:", self.diameter) #self.__layout.addRow("Measured Pedicle Width:", self.widthMeasure) self.__diameter = '' self.QHBox2 = qt.QHBoxLayout() self.QHBox2.addWidget(widthText) self.QHBox2.addWidget(self.diameter) self.QHBox2.addWidget(measuredText2) self.QHBox2.addWidget(self.widthMeasure) self.__layout.addRow(self.QHBox2) # Load Screw Button self.__loadScrewButton = qt.QPushButton("Load Screw") self.__loadScrewButton.enabled = False #self.__layout.addWidget(self.__loadScrewButton) self.__loadScrewButton.connect('clicked(bool)', self.loadScrew) # Delete Screw Button self.__delScrewButton = qt.QPushButton("Delete Screw") self.__delScrewButton.enabled = True #self.__layout.addWidget(self.__delScrewButton) self.__delScrewButton.connect('clicked(bool)', self.delScrew) self.QHBox3 = qt.QHBoxLayout() self.QHBox3.addWidget(self.__loadScrewButton) self.QHBox3.addWidget(self.__delScrewButton) self.__layout.addRow(self.QHBox3) # Input model node selector self.modelNodeSelector = slicer.qMRMLNodeComboBox() self.modelNodeSelector.toolTip = "." self.modelNodeSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.modelNodeSelector.addEnabled = False self.modelNodeSelector.removeEnabled = False self.modelNodeSelector.setMRMLScene(slicer.mrmlScene) #self.__layout.addRow("Current Screws:", self.modelNodeSelector) self.transformGrid = qt.QGridLayout() vText = qt.QLabel("Vertical Adjustment:") iText = qt.QLabel("Horizontal Adjustment:") self.transformGrid.addWidget(vText, 0, 0) self.transformGrid.addWidget(iText, 0, 2) self.b = ctk.ctkDoubleSpinBox() self.b.minimum = -45 self.b.maximum = 45 self.transformGrid.addWidget(self.b, 1, 0) # Transform Sliders self.transformSlider1 = ctk.ctkDoubleSlider() self.transformSlider1.minimum = -45 self.transformSlider1.maximum = 45 self.transformSlider1.connect('valueChanged(double)', self.transformSlider1ValueChanged) self.transformSlider1.connect('valueChanged(double)', self.b.setValue) self.transformSlider1.setMinimumHeight(120) #self.__layout.addRow("Rotate IS", self.transformSlider1) self.transformGrid.addWidget(self.transformSlider1, 1, 1) self.b.connect('valueChanged(double)', self.transformSlider1.setValue) # Transform Sliders self.transformSlider2 = ctk.ctkSliderWidget() self.transformSlider2.minimum = -45 self.transformSlider2.maximum = 45 self.transformSlider2.connect('valueChanged(double)', self.transformSlider2ValueChanged) self.transformSlider2.setMaximumWidth(200) #self.__layout.addRow("Rotate LR", self.transformSlider2) self.transformGrid.addWidget(self.transformSlider2, 1, 2) self.__layout.addRow(self.transformGrid) ''' # Transfors Sliders self.transformSlider3 = ctk.ctkSliderWidget() self.transformSlider3.minimum = 0 self.transformSlider3.maximum = 100 self.transformSlider3.connect('valueChanged(double)', self.transformSlider3ValueChanged) self.__layout.addRow("Drive Screw", self.transformSlider3) ''' # Insert Screw Button self.insertScrewButton = qt.QPushButton("Insert Screw") self.insertScrewButton.enabled = True #self.__layout.addWidget(self.__loadScrewButton) self.insertScrewButton.connect('clicked(bool)', self.insertScrew) # Backout Screw Button self.backoutScrewButton = qt.QPushButton("Backout Screw") self.backoutScrewButton.enabled = False #self.__layout.addWidget(self.__delScrewButton) self.backoutScrewButton.connect('clicked(bool)', self.backoutScrew) # Reset Screw Button self.resetScrewButton = qt.QPushButton("Reset Screw") self.resetScrewButton.enabled = True #self.__layout.addWidget(self.__delScrewButton) self.resetScrewButton.connect('clicked(bool)', self.resetScrew) self.QHBox4 = qt.QHBoxLayout() self.QHBox4.addWidget(self.insertScrewButton) self.QHBox4.addWidget(self.backoutScrewButton) self.QHBox4.addWidget(self.resetScrewButton) self.__layout.addRow(self.QHBox4) # Hide ROI Details #measurementsTable = ctk.ctkCollapsibleButton() #measurementsTable.text = "Measurements Table" #self.__layout.addWidget(measurementsTable) #measurementsTable.collapsed = True ''' self.view = qt.QTableView() self.model = qt.QStandardItemModel() self.view.setModel(self.model) item = qt.QStandardItem() item.setText("item") self.model.setItem(0,0,item) self.__layout.addWidget(self.view) ''' #self.__layout.addRow(self.screwGridLayout) # self.updateWidgetFromParameters(self.parameterNode()) qt.QTimer.singleShot(0, self.killButton) self.currentFidIndex = self.fiducial.currentIndex self.currentFidLabel = self.fiducial.currentText self.fidNode.GetNthFiducialPosition(self.currentFidIndex, self.coords) logging.debug("Coords: {0}".format(self.coords)) self.updateMeasurements() self.cameraFocus(self.coords)
def create(self): super(InteractiveConnectedComponentsUsingParzenPDFsOptions,self).create() ioCollapsibleButton = ctk.ctkCollapsibleGroupBox() ioCollapsibleButton.title = "IO" ioCollapsibleButton.collapsed = 0 self.frame.layout().addWidget(ioCollapsibleButton) # Layout within the io collapsible button ioFormLayout = qt.QFormLayout(ioCollapsibleButton) self.additionalInputNodeSelectors = [] for i in range(0,2): self.additionalInputNodeSelectors.append(self.addInputNodeSelector(i, ioFormLayout)) self.additionalInputNodeSelectors[0].toolTip = "Select the 1st additional input volume to be segmented" self.additionalInputNodeSelectors[1].toolTip = "Select the 2nd additional input volume to be segmented" # Objects objectCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() objectCollapsibleGroupBox.title = "Objects" self.frame.layout().addWidget(objectCollapsibleGroupBox) # Layout within the io collapsible button objectFormLayout = qt.QFormLayout(objectCollapsibleGroupBox) foregroundLayout = qt.QHBoxLayout() foregroundLabel = slicer.qMRMLLabelComboBox() foregroundLabel.objectName = 'Foreground label' foregroundLabel.setMRMLScene(slicer.mrmlScene) foregroundLabel.setMRMLColorNode(self.editUtil.getColorNode()) foregroundLabel.labelValueVisible = True foregroundLabel.currentColor = 1 self.foregroundLabel = foregroundLabel self.connections.append( (self.foregroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI ) ) foregroundWeightSpinBox = qt.QDoubleSpinBox(foregroundLabel) self.foregroundWeightSpinBox = foregroundWeightSpinBox foregroundWeightSpinBox.setRange(0.0, 1.0) foregroundWeightSpinBox.setSingleStep(0.1) foregroundWeightSpinBox.value = 1.0 foregroundPopup = ctk.ctkPopupWidget( foregroundWeightSpinBox ) foregroundPopupLayout = qt.QHBoxLayout( foregroundPopup ) foregroundPopupSlider = ctk.ctkDoubleSlider( foregroundPopup ) self.foregroundPopupSlider = foregroundPopupSlider foregroundPopupSlider.maximum = 1.0 foregroundPopupSlider.minimum = 0.0 foregroundPopupSlider.singleStep = 0.1 foregroundPopupSlider.connect('valueChanged(double)', self.foregroundWeightSpinBox.setValue) foregroundWeightSpinBox.connect('valueChanged(double)', self.foregroundPopupSlider.setValue) self.connections.append( (self.foregroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI ) ) foregroundLayout.addWidget( foregroundLabel ) foregroundLayout.addWidget( foregroundWeightSpinBox ) foregroundPopupLayout.addWidget( foregroundPopupSlider ) objectFormLayout.addRow("Foreground Label:", foregroundLayout ) self.objectLabel = foregroundLabel # http://qt-project.org/doc/qt-4.7/qt.html foregroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight foregroundPopup.horizontalDirection = 0 # Qt::LeftToRight foregroundPopup.verticalDirection = 0 # Qt::TopToBottom foregroundPopup.animationEffect = 1 # Qt::ScrollEffect backgroundLayout = qt.QHBoxLayout() backgroundLabel = slicer.qMRMLLabelComboBox() backgroundLabel.objectName = 'Background label' backgroundLabel.setMRMLScene(slicer.mrmlScene) backgroundLabel.setMRMLColorNode(self.editUtil.getColorNode()) backgroundLabel.labelValueVisible = True backgroundLabel.currentColor = 2 self.backgroundLabel = backgroundLabel self.connections.append( (self.backgroundLabel, 'currentColorChanged(int)', self.updateMRMLFromGUI ) ) backgroundWeightSpinBox = qt.QDoubleSpinBox(backgroundLabel) self.backgroundWeightSpinBox = backgroundWeightSpinBox backgroundWeightSpinBox.setRange(0.0, 1.0) backgroundWeightSpinBox.setSingleStep(0.1) backgroundWeightSpinBox.value = 1.0 backgroundPopup = ctk.ctkPopupWidget( backgroundWeightSpinBox ) backgroundPopupLayout = qt.QHBoxLayout( backgroundPopup ) backgroundPopupSlider = ctk.ctkDoubleSlider( backgroundPopup ) self.backgroundPopupSlider = backgroundPopupSlider backgroundPopupSlider.maximum = 1.0 backgroundPopupSlider.minimum = 0.0 backgroundPopupSlider.singleStep = 0.1 backgroundPopupSlider.connect('valueChanged(double)', self.backgroundWeightSpinBox.setValue) backgroundWeightSpinBox.connect('valueChanged(double)', self.backgroundPopupSlider.setValue) self.connections.append( (self.backgroundWeightSpinBox, 'valueChanged(double)', self.updateMRMLFromGUI ) ) backgroundLayout.addWidget( backgroundLabel ) backgroundLayout.addWidget( backgroundWeightSpinBox ) backgroundPopupLayout.addWidget( backgroundPopupSlider ) objectFormLayout.addRow("Background Label:", backgroundLayout) self.backgroundLabel = backgroundLabel # http://qt-project.org/doc/qt-4.7/qt.html backgroundPopup.alignment = 0x0082 # Qt::AlignVCenter | Qt::AlignRight backgroundPopup.horizontalDirection = 0 # Qt::LeftToRight backgroundPopup.verticalDirection = 0 # Qt::TopToBottom backgroundPopup.animationEffect = 1 # Qt::ScrollEffect # Presets # Placeholder presetsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() presetsCollapsibleGroupBox.title = "Preset" self.frame.layout().addWidget(presetsCollapsibleGroupBox) presetComboBox = slicer.qSlicerPresetComboBox() # Advanced Parameters paramsCollapsibleGroupBox = ctk.ctkCollapsibleGroupBox() paramsCollapsibleGroupBox.title = "Advanced Parameters" paramsCollapsibleGroupBox.collapsed = 1 self.frame.layout().addWidget(paramsCollapsibleGroupBox) # Layout within the io collapsible button paramsFormLayout = qt.QFormLayout(paramsCollapsibleGroupBox) erosionSpinBox = qt.QSpinBox() erosionSpinBox.objectName = 'erosionSpinBox' erosionSpinBox.toolTip = "Set the erosion radius." erosionSpinBox.setMinimum(0) erosionSpinBox.setValue(5) # Default paramsFormLayout.addRow("Erosion Radius:", erosionSpinBox) self.erosionSpinBox = erosionSpinBox self.connections.append( (self.erosionSpinBox, "valueChanged(int)", self.updateMRMLFromGUI ) ) holeFillSpinBox = qt.QSpinBox() holeFillSpinBox.objectName = 'holeFillSpinBox' holeFillSpinBox.toolTip = "Set the hole fill iterations." holeFillSpinBox.setMinimum(0) holeFillSpinBox.setValue(5) #Default paramsFormLayout.addRow("Hole Fill Iterations:", holeFillSpinBox) self.holeFillSpinBox = holeFillSpinBox self.connections.append( (self.holeFillSpinBox, "valueChanged(int)", self.updateMRMLFromGUI ) ) # probabilitySmoothingStandardDeviation spin box probabilitySmoothingStdDevSpinBox = qt.QDoubleSpinBox() probabilitySmoothingStdDevSpinBox.objectName = 'probabilitySmoothingStdDevSpinBox' probabilitySmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to probability images prior to computing maximum likelihood of each class at each pixel." probabilitySmoothingStdDevSpinBox.setMinimum(0.0) probabilitySmoothingStdDevSpinBox.setValue(1.0) # Default probabilitySmoothingStdDevSpinBox.setSingleStep(0.5) paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", probabilitySmoothingStdDevSpinBox) self.probabilitySmoothingStdDevSpinBox = probabilitySmoothingStdDevSpinBox self.connections.append( (self.probabilitySmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI ) ) # histogramSmoothingStandardDeviation spin box histogramSmoothingStdDevSpinBox = qt.QDoubleSpinBox() histogramSmoothingStdDevSpinBox.objectName = 'histogramSmoothingStdDevSpinBox' histogramSmoothingStdDevSpinBox.toolTip = "Standard deviation of blur applied to histograms to convert them to probability density function estimates." histogramSmoothingStdDevSpinBox.setMinimum(0.0) histogramSmoothingStdDevSpinBox.setValue(5.0) # Default histogramSmoothingStdDevSpinBox.setSingleStep(0.5) paramsFormLayout.addRow("Probability Smoothing Standard Deviation:", histogramSmoothingStdDevSpinBox) self.histogramSmoothingStdDevSpinBox = histogramSmoothingStdDevSpinBox self.connections.append( (self.histogramSmoothingStdDevSpinBox, "valueChanged(double)", self.updateMRMLFromGUI ) ) # draft check box draftCheckBox = qt.QCheckBox() draftCheckBox.objectName = 'draftCheckBox' draftCheckBox.toolTip = "Downsamples results by a factor of 4." paramsFormLayout.addRow("Draft Mode:", draftCheckBox) self.draftCheckBox = draftCheckBox self.connections.append( (self.draftCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) ) # force classification check box forceClassificationCheckBox = qt.QCheckBox() forceClassificationCheckBox.objectName = 'forceClassificationCheckBox' forceClassificationCheckBox.toolTip = "Perform the classification of all voxels?" forceClassificationCheckBox.setChecked(False) paramsFormLayout.addRow("Classify all voxels: ", forceClassificationCheckBox) self.forceClassificationCheckBox = forceClassificationCheckBox self.connections.append( (self.forceClassificationCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) ) # dilate first check box dilateFirstCheckBox = qt.QCheckBox() dilateFirstCheckBox.objectName = 'dilateFirstCheckBox' dilateFirstCheckBox.toolTip = "Dilate and then erode so as to fill-in holes?" dilateFirstCheckBox.setChecked(False) paramsFormLayout.addRow("Dilate First: ", dilateFirstCheckBox) self.dilateFirstCheckBox = dilateFirstCheckBox self.connections.append( (self.dilateFirstCheckBox, "stateChanged(int)", self.updateMRMLFromGUI ) ) self.helpLabel = qt.QLabel("Run the PDF Segmentation on the current label map.", self.frame) self.frame.layout().addWidget(self.helpLabel) self.apply = qt.QPushButton("Apply", self.frame) self.apply.setToolTip("Apply to run segmentation.\nCreates a new label volume using the current volume as input") self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) EditorLib.HelpButton(self.frame, "Use this tool to apply segmentation using Parzen windowed PDFs.\n\n Select different label colors and paint on the foreground or background voxels using the paint effect.\nTo run segmentation correctly, you need to supply a minimum or two class labels.") self.connections.append( (self.apply, 'clicked()', self.onApply) )
def create(self): super(PaintEffectOptions, self).create() labelVolume = self.editUtil.getLabelVolume() if labelVolume and labelVolume.GetImageData(): spacing = labelVolume.GetSpacing() dimensions = labelVolume.GetImageData().GetDimensions() self.minimumRadius = 0.5 * min(spacing) bounds = [a * b for a, b in zip(spacing, dimensions)] self.maximumRadius = 0.5 * max(bounds) else: self.minimumRadius = 0.01 self.maximumRadius = 100 self.radiusFrame = qt.QFrame(self.frame) self.radiusFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.radiusFrame) self.widgets.append(self.radiusFrame) self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame) self.radiusLabel.setToolTip( "Set the radius of the paint brush in millimeters") self.radiusFrame.layout().addWidget(self.radiusLabel) self.widgets.append(self.radiusLabel) self.radiusSpinBox = slicer.qMRMLSpinBox(self.radiusFrame) self.radiusSpinBox.objectName = 'SpinBox_Radius' self.radiusSpinBox.setToolTip( "Set the radius of the paint brush in millimeters") self.radiusSpinBox.quantity = "length" # QFlags not wrapped in python. Equivalent to Prefix | Suffix # See qMRMLSpinBox for more details. self.radiusSpinBox.unitAwareProperties = 0x01 | 0x02 self.radiusSpinBox.minimum = self.minimumRadius self.radiusSpinBox.maximum = self.maximumRadius self.radiusSpinBox.setMRMLScene(slicer.mrmlScene) from math import log, floor decimals = floor(log(self.minimumRadius, 10)) if decimals < 0: self.radiusSpinBox.decimals = -decimals + 2 self.radiusFrame.layout().addWidget(self.radiusSpinBox) self.widgets.append(self.radiusSpinBox) self.radiusUnitsToggle = qt.QPushButton("px:") self.radiusUnitsToggle.objectName = 'PushButton_RadiusUnitsToggle' self.radiusUnitsToggle.setToolTip( "Toggle radius quick set buttons between mm and label volume pixel size units" ) self.radiusUnitsToggle.setFixedWidth(35) self.radiusFrame.layout().addWidget(self.radiusUnitsToggle) self.radiusUnitsToggle.connect('clicked()', self.onRadiusUnitsToggle) self.radiusQuickies = {} quickies = ((2, self.onQuickie2Clicked), (3, self.onQuickie3Clicked), (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked), (10, self.onQuickie10Clicked), (20, self.onQuickie20Clicked)) for rad, callback in quickies: self.radiusQuickies[rad] = qt.QPushButton(str(rad)) self.radiusQuickies[ rad].objectName = 'PushButton_QuickRadius_{0}'.format(rad) self.radiusFrame.layout().addWidget(self.radiusQuickies[rad]) self.radiusQuickies[rad].setFixedWidth(25) self.radiusQuickies[rad].connect('clicked()', callback) self.radiusQuickies[rad].setToolTip( "Set radius based on mm or label voxel size units depending on toggle value" ) self.radius = ctk.ctkDoubleSlider(self.frame) self.radius.objectName = 'DoubleSlider_Radius' self.radius.minimum = self.minimumRadius self.radius.maximum = self.maximumRadius self.radius.orientation = 1 self.radius.singleStep = self.minimumRadius self.frame.layout().addWidget(self.radius) self.widgets.append(self.radius) self.sphere = qt.QCheckBox("Sphere", self.frame) self.sphere.objectName = 'CheckBox_Sphere' self.sphere.setToolTip( "Use a 3D spherical brush rather than a 2D circular brush.") self.frame.layout().addWidget(self.sphere) self.widgets.append(self.sphere) self.smudge = qt.QCheckBox("Smudge", self.frame) self.smudge.objectName = 'CheckBox_Smudge' self.smudge.setToolTip( "Set the label number automatically by sampling the pixel location where the brush stroke starts." ) self.frame.layout().addWidget(self.smudge) self.widgets.append(self.smudge) self.pixelMode = qt.QCheckBox("Pixel Mode", self.frame) self.pixelMode.objectName = 'CheckBox_PixelMode' self.pixelMode.setToolTip( "Paint exactly the pixel under the cursor, ignoring the radius, threshold, and paint over." ) self.frame.layout().addWidget(self.pixelMode) self.widgets.append(self.pixelMode) EditorLib.HelpButton( self.frame, "Use this tool to paint with a round brush of the selected radius") self.connections.append( (self.sphere, 'clicked()', self.updateMRMLFromGUI)) self.connections.append( (self.smudge, 'clicked()', self.updateMRMLFromGUI)) self.connections.append( (self.pixelMode, 'clicked()', self.updateMRMLFromGUI)) self.connections.append( (self.radius, 'valueChanged(double)', self.onRadiusValueChanged)) self.connections.append((self.radiusSpinBox, 'valueChanged(double)', self.onRadiusSpinBoxChanged)) # Add vertical spacer self.frame.layout().addStretch(1) # set the node parameters that are dependent on the input data self.parameterNode.SetParameter("PaintEffect,radius", str(self.minimumRadius * 10))
def create(self): super(PaintEffectOptions, self).create() labelVolume = self.editUtil.getLabelVolume() if labelVolume and labelVolume.GetImageData(): spacing = labelVolume.GetSpacing() dimensions = labelVolume.GetImageData().GetDimensions() self.minimumRadius = 0.5 * min(spacing) bounds = [a * b for a, b in zip(spacing, dimensions)] self.maximumRadius = 0.5 * max(bounds) else: self.minimumRadius = 0.01 self.maximumRadius = 100 self.radiusFrame = qt.QFrame(self.frame) self.radiusFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.radiusFrame) self.widgets.append(self.radiusFrame) self.radiusLabel = qt.QLabel("Radius:", self.radiusFrame) self.radiusLabel.setToolTip( "Set the radius of the paint brush in millimeters") self.radiusFrame.layout().addWidget(self.radiusLabel) self.widgets.append(self.radiusLabel) self.radiusSpinBox = qt.QDoubleSpinBox(self.radiusFrame) self.radiusSpinBox.setToolTip( "Set the radius of the paint brush in millimeters") self.radiusSpinBox.minimum = self.minimumRadius self.radiusSpinBox.maximum = self.maximumRadius self.radiusSpinBox.suffix = "mm" from math import log, floor decimals = floor(log(self.minimumRadius, 10)) if decimals < 0: self.radiusSpinBox.decimals = -decimals + 2 self.radiusFrame.layout().addWidget(self.radiusSpinBox) self.widgets.append(self.radiusSpinBox) self.radiusUnitsToggle = qt.QPushButton("px:") self.radiusUnitsToggle.setToolTip( "Toggle radius quick set buttons between mm and label volume pixel size units" ) self.radiusUnitsToggle.setFixedWidth(35) self.radiusFrame.layout().addWidget(self.radiusUnitsToggle) self.radiusUnitsToggle.connect('clicked()', self.onRadiusUnitsToggle) self.radiusQuickies = {} quickies = ((2, self.onQuickie2Clicked), (3, self.onQuickie3Clicked), (4, self.onQuickie4Clicked), (5, self.onQuickie5Clicked), (10, self.onQuickie10Clicked), (20, self.onQuickie20Clicked)) for rad, callback in quickies: self.radiusQuickies[rad] = qt.QPushButton(str(rad)) self.radiusFrame.layout().addWidget(self.radiusQuickies[rad]) self.radiusQuickies[rad].setFixedWidth(25) self.radiusQuickies[rad].connect('clicked()', callback) self.radiusQuickies[rad].setToolTip( "Set radius based on mm or label voxel size units depending on toggle value" ) self.radius = ctk.ctkDoubleSlider(self.frame) self.radius.minimum = self.minimumRadius self.radius.maximum = self.maximumRadius self.radius.orientation = 1 self.radius.singleStep = self.minimumRadius self.frame.layout().addWidget(self.radius) self.widgets.append(self.radius) self.smudge = qt.QCheckBox("Smudge", self.frame) self.smudge.setToolTip( "Set the label number automatically by sampling the pixel location where the brush stroke starts." ) self.frame.layout().addWidget(self.smudge) self.widgets.append(self.smudge) EditorLib.HelpButton( self.frame, "Use this tool to paint with a round brush of the selected radius") self.connections.append( (self.smudge, 'clicked()', self.updateMRMLFromGUI)) self.connections.append( (self.radius, 'valueChanged(double)', self.onRadiusValueChanged)) self.connections.append((self.radiusSpinBox, 'valueChanged(double)', self.onRadiusSpinBoxChanged)) # Add vertical spacer self.frame.layout().addStretch(1) # set the node parameters that are dependent on the input data self.parameterNode.SetParameter("PaintEffect,radius", str(self.minimumRadius * 10))
def createUserInterface( self ): self.__layout = self.__parent.createUserInterface() ''' # Input fiducials node selector #self.inputFiducialsNodeSelector = slicer.qMRMLNodeComboBox() self.inputFiducialsNodeSelector.toolTip = "Select a fiducial to define an insertion point for a screw." self.inputFiducialsNodeSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "") self.inputFiducialsNodeSelector.addEnabled = False self.inputFiducialsNodeSelector.removeEnabled = False self.inputFiducialsNodeSelector.setMRMLScene( slicer.mrmlScene ) self.inputFiducialsNodeSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.fidChanged) self.__layout.addRow("Select Insertion Point:", self.inputFiducialsNodeSelector) self.fid = self.inputFiducialsNodeSelector.currentNode() self.sliceChange() ''' ''' # Input model selector self.inputScrewSelector = ctk.ctkComboBox() self.inputScrewSelector.toolTip = "Select a screw to insert." screwList = ['Select a screw','475x30', '475x35', '475x45', '550x30', '550x40', '550x45', '625x35', '625x40', '625x45', '625x50', '700x35', '700x40', '700x45', '700x50'] self.inputScrewSelector.addItems(screwList) self.connect(self.inputScrewSelector, PythonQt.QtCore.SIGNAL('activated(QString)'), self.combo_chosen) self.__layout.addRow("Choose Screw:", self.inputScrewSelector) vText = qt.QLabel("1st Instrumented Level:") iText = qt.QLabel("# to Instrument:") aText = qt.QLabel("Approach Direction:") self.vSelector = qt.QComboBox() self.vSelector.setMaximumWidth(120) self.levels = ("C1","C2","C3","C4","C5","C6","C7","T1","T2","T3","T4","T5","T6","T7","T8","T9","T10","T11","T12","L1", "L2", "L3", "L4", "L5","S1") self.vSelector.addItems(self.levels) self.iSelector = qt.QComboBox() self.iSelector.setMaximumWidth(120) self.iSelector.addItems(['1','2','3','4','5','6','7','8','9','10','11','12']) self.aSelector = qt.QComboBox() self.aSelector.setMaximumWidth(120) self.aSelector.addItems(['Posterior','Anterior','Left','Right']) blank = qt.QLabel(" ") blank.setMaximumWidth(30) #self.__layout.addWidget(vText) #self.__layout.addWidget(self.vSelector) #self.__layout.addWidget(iText) #self.__layout.addWidget(self.iSelector) self.vertebraeGridBox = qt.QGridLayout() self.vertebraeGridBox.addWidget(vText,0,0) self.vertebraeGridBox.addWidget(self.vSelector,1,0) self.vertebraeGridBox.addWidget(blank,0,1) self.vertebraeGridBox.addWidget(iText,0,2) self.vertebraeGridBox.addWidget(blank,1,1) self.vertebraeGridBox.addWidget(self.iSelector,1,2) self.vertebraeGridBox.addWidget(blank,0,3) self.vertebraeGridBox.addWidget(aText,0,4) self.vertebraeGridBox.addWidget(blank,1,3) self.vertebraeGridBox.addWidget(self.aSelector,1,4) self.__layout.addRow(self.vertebraeGridBox) ''' self.fiducial = ctk.ctkComboBox() self.fiducial.toolTip = "Select an insertion site." #fiducialList = ['Select an insertion landmark', self.fiduciallist] #print self.fiduciallist #print fiducialList #self.fiducial.addItem("Select an insertion site, no really") #self.fiducial.addItem("Select an insertion site.") self.fiducial.addItems(self.fiduciallist) self.connect(self.fiducial, PythonQt.QtCore.SIGNAL('activated(QString)'), self.fiducial_chosen) #self.connect(self.fiducial, PythonQt.QtCore.SIGNAL('activated(QString)'), self.fidChanged) #self.screwGridLayout.addWidget(self.fiducial,0,0) self.__layout.addRow("Insertion Site:", self.fiducial) self.__fiducial = '' measuredText1 = qt.QLabel(" Measured:") measuredText2 = qt.QLabel(" Measured:") lengthText = qt.QLabel("Screw Length: ") widthText = qt.QLabel("Screw Width: ") self.length = ctk.ctkComboBox() self.length.toolTip = "Select a screw to insert." screwList = ['Select a length (mm)','475', '550','625','700'] self.length.addItems(screwList) self.connect(self.length, PythonQt.QtCore.SIGNAL('activated(QString)'), self.length_chosen) self.lengthMeasure = qt.QLineEdit() #self.__layout.addRow("Screw Length:", self.length) #self.__layout.addRow("Measured Pedicle Length:", self.lengthMeasure) self.__length = '' self.QHBox1 = qt.QHBoxLayout() self.QHBox1.addWidget(lengthText) self.QHBox1.addWidget(self.length) self.QHBox1.addWidget(measuredText1) self.QHBox1.addWidget(self.lengthMeasure) self.__layout.addRow(self.QHBox1) self.diameter = ctk.ctkComboBox() self.diameter.toolTip = "Select a screw to insert." screwList = ['Select a diameter (mm)','30', '35', '45', '50'] self.diameter.addItems(screwList) self.widthMeasure = qt.QLineEdit() self.connect(self.diameter, PythonQt.QtCore.SIGNAL('activated(QString)'), self.diameter_chosen) #self.__layout.addRow("Screw Diameter:", self.diameter) #self.__layout.addRow("Measured Pedicle Width:", self.widthMeasure) self.__diameter = '' self.QHBox2 = qt.QHBoxLayout() self.QHBox2.addWidget(widthText) self.QHBox2.addWidget(self.diameter) self.QHBox2.addWidget(measuredText2) self.QHBox2.addWidget(self.widthMeasure) self.__layout.addRow(self.QHBox2) # Load Screw Button self.__loadScrewButton = qt.QPushButton("Load Screw") self.__loadScrewButton.enabled = False #self.__layout.addWidget(self.__loadScrewButton) self.__loadScrewButton.connect('clicked(bool)', self.loadScrew) # Delete Screw Button self.__delScrewButton = qt.QPushButton("Delete Screw") self.__delScrewButton.enabled = True #self.__layout.addWidget(self.__delScrewButton) self.__delScrewButton.connect('clicked(bool)', self.delScrew) self.QHBox3 = qt.QHBoxLayout() self.QHBox3.addWidget(self.__loadScrewButton) self.QHBox3.addWidget(self.__delScrewButton) self.__layout.addRow(self.QHBox3) # Input model node selector self.modelNodeSelector = slicer.qMRMLNodeComboBox() self.modelNodeSelector.toolTip = "." self.modelNodeSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.modelNodeSelector.addEnabled = False self.modelNodeSelector.removeEnabled = False self.modelNodeSelector.setMRMLScene( slicer.mrmlScene ) #self.__layout.addRow("Current Screws:", self.modelNodeSelector) self.transformGrid = qt.QGridLayout() vText = qt.QLabel("Vertical Adjustment:") iText = qt.QLabel("Horizontal Adjustment:") self.transformGrid.addWidget(vText, 0,0) self.transformGrid.addWidget(iText, 0,2) self.b = ctk.ctkDoubleSpinBox() self.b.minimum = -45 self.b.maximum = 45 self.transformGrid.addWidget(self.b, 1,0) # Transform Sliders self.transformSlider1 = ctk.ctkDoubleSlider() self.transformSlider1.minimum = -45 self.transformSlider1.maximum = 45 self.transformSlider1.connect('valueChanged(double)', self.transformSlider1ValueChanged) self.transformSlider1.connect('valueChanged(double)', self.b.setValue) self.transformSlider1.setMinimumHeight(120) #self.__layout.addRow("Rotate IS", self.transformSlider1) self.transformGrid.addWidget(self.transformSlider1, 1,1) self.b.connect('valueChanged(double)', self.transformSlider1.setValue) # Transform Sliders self.transformSlider2 = ctk.ctkSliderWidget() self.transformSlider2.minimum = -45 self.transformSlider2.maximum = 45 self.transformSlider2.connect('valueChanged(double)', self.transformSlider2ValueChanged) self.transformSlider2.setMaximumWidth(200) #self.__layout.addRow("Rotate LR", self.transformSlider2) self.transformGrid.addWidget(self.transformSlider2, 1,2) self.__layout.addRow(self.transformGrid) ''' # Transfors Sliders self.transformSlider3 = ctk.ctkSliderWidget() self.transformSlider3.minimum = 0 self.transformSlider3.maximum = 100 self.transformSlider3.connect('valueChanged(double)', self.transformSlider3ValueChanged) self.__layout.addRow("Drive Screw", self.transformSlider3) ''' # Insert Screw Button self.insertScrewButton = qt.QPushButton("Insert Screw") self.insertScrewButton.enabled = True #self.__layout.addWidget(self.__loadScrewButton) self.insertScrewButton.connect('clicked(bool)', self.insertScrew) # Backout Screw Button self.backoutScrewButton = qt.QPushButton("Backout Screw") self.backoutScrewButton.enabled = False #self.__layout.addWidget(self.__delScrewButton) self.backoutScrewButton.connect('clicked(bool)', self.backoutScrew) # Reset Screw Button self.resetScrewButton = qt.QPushButton("Reset Screw") self.resetScrewButton.enabled = True #self.__layout.addWidget(self.__delScrewButton) self.resetScrewButton.connect('clicked(bool)', self.resetScrew) self.QHBox4 = qt.QHBoxLayout() self.QHBox4.addWidget(self.insertScrewButton) self.QHBox4.addWidget(self.backoutScrewButton) self.QHBox4.addWidget(self.resetScrewButton) self.__layout.addRow(self.QHBox4) # Hide ROI Details #measurementsTable = ctk.ctkCollapsibleButton() #measurementsTable.text = "Measurements Table" #self.__layout.addWidget(measurementsTable) #measurementsTable.collapsed = True ''' self.view = qt.QTableView() self.model = qt.QStandardItemModel() self.view.setModel(self.model) item = qt.QStandardItem() item.setText("item") self.model.setItem(0,0,item) self.__layout.addWidget(self.view) ''' #self.__layout.addRow(self.screwGridLayout) # self.updateWidgetFromParameters(self.parameterNode()) qt.QTimer.singleShot(0, self.killButton) self.currentFidIndex = self.fiducial.currentIndex self.currentFidLabel = self.fiducial.currentText self.fidNode.GetNthFiducialPosition(self.currentFidIndex,self.coords) print self.coords self.updateMeasurements() self.cameraFocus(self.coords)