def __init__(self, parent, width=350, height=300): self.widget = qt.QTableWidget(parent) self.widget.setMinimumHeight(height) self.widget.setMinimumWidth(width) self.width = width self.height = height self.items = [] self.loadables = {} self.setLoadables([])
def createUserInterface(self): self.__layout = self.__parent.createUserInterface() ln = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLLayoutNode') ln.SetViewArrangement( slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalPlotView) modLabel = qt.QLabel('Select Screw at Point:') ''' self.__modelSelector = slicer.qMRMLNodeComboBox() self.__modelSelector.nodeTypes = ( ("vtkMRMLAnnotationFiducialNode"), "" ) self.__modelSelector.addEnabled = False self.__modelSelector.removeEnabled = False self.__modelSelector.setMRMLScene( slicer.mrmlScene ) self.__layout.addRow( modLabel, self.__modelSelector ) ''' # Paint Screw Button self.__selectScrewButton = qt.QPushButton("Grade Screws") self.__layout.addWidget(self.__selectScrewButton) self.__selectScrewButton.connect('clicked(bool)', self.gradeScrews) ''' #Opacity Slider self.transformSlider3 = ctk.ctkSliderWidget() self.transformSlider3.minimum = 0 self.transformSlider3.maximum = 1 self.transformSlider3.connect('valueChanged(double)', self.transformSlider3ValueChanged) self.__layout.addRow("Volume Opacity", self.transformSlider3) ''' self.fiducial = self.fiducialNode() self.fidNumber = self.fiducial.GetNumberOfFiducials() # Screw Table horizontalHeaders = [ "Screw At", "Screw\n Size", "% Screw in\n Soft Tissue\n (<130HU)", "% Screw in\n LD Bone\n (130-250HU)", "% Screw in\n HD Bone\n (>250HU)" ] self.screwTable = qt.QTableWidget(self.fidNumber, 5) self.screwTable.sortingEnabled = False self.screwTable.setEditTriggers(1) self.screwTable.setMinimumHeight( self.screwTable.verticalHeader().length()) self.screwTable.horizontalHeader().setSectionResizeMode( qt.QHeaderView.Stretch) self.screwTable.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.screwTable.itemSelectionChanged.connect(self.onTableCellClicked) self.__layout.addWidget(self.screwTable) self.screwTable.setHorizontalHeaderLabels(horizontalHeaders) self.updateWidgetFromParameters(self.parameterNode()) qt.QTimer.singleShot(0, self.killButton) self.updateTable()
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = ExtensionStatsLogic() self.logic.setStatusCallback(self.setStatusText) self.queryInProgress = False # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) self.extensionNameEdit = qt.QLineEdit() self.extensionNameEdit.setText('') parametersFormLayout.addRow("Extension name: ", self.extensionNameEdit) self.midasQueryUrlEdit = qt.QLineEdit() self.midasQueryUrlEdit.setText( 'http://slicer.kitware.com/midas3/api/json') parametersFormLayout.addRow("MIDAS json query URL: ", self.midasQueryUrlEdit) self.applyButton = qt.QPushButton("Get download statistics") self.applyButton.toolTip = "Get download statistics" parametersFormLayout.addRow(self.applyButton) self.statusText = qt.QLabel() parametersFormLayout.addRow("Status:", self.statusText) # Stats table self.statsTable = qt.QTableWidget() self.statsTable.setSelectionBehavior(qt.QAbstractItemView.SelectRows) parametersFormLayout.addRow("Statistics:", self.statsTable) self.statsTableHeader = ['Revision', 'Downloads'] policy = qt.QSizePolicy() policy.setVerticalStretch(1) policy.setHorizontalPolicy(qt.QSizePolicy.Expanding) policy.setVerticalPolicy(qt.QSizePolicy.Expanding) self.statsTable.setSizePolicy(policy) # Copy to clipboard button self.copyToClipboardButton = qt.QPushButton("Copy table to clipboard") parametersFormLayout.addRow('', self.copyToClipboardButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.copyToClipboardButton.connect('clicked()', self.copyTableToClipboard)
def setupMainSection(self): self.mainCollapsibleButton = ctk.ctkCollapsibleButton() self.mainCollapsibleButton.text = "Main" self.layout.addWidget(self.mainCollapsibleButton) mainFormFrame = qt.QFrame() mainFormLayout = qt.QFormLayout(mainFormFrame) self.showTemplateCheckBox = qt.QCheckBox() self.showTemplateCheckBox.checked = 0 self.showTemplateCheckBox.setToolTip("Show 3D model of the template") mainFormLayout.addRow("Show Template:", self.showTemplateCheckBox) self.showTrajectoriesCheckBox = qt.QCheckBox() self.showTrajectoriesCheckBox.checked = 0 self.showTrajectoriesCheckBox.setToolTip("Show 3D model of the fiducial") mainFormLayout.addRow("Show Trajectories:", self.showTrajectoriesCheckBox) self.transformSelector = self.createComboBox(nodeTypes=["vtkMRMLLinearTransformNode", ""], noneEnabled=False, selectNodeUponCreation=True, showChildNodeTypes=False) mainFormLayout.addRow("Input Transform: ", self.transformSelector) self.inputVolumeSelector = self.createComboBox(nodeTypes=["vtkMRMLScalarVolumeNode", ""], noneEnabled=False, selectNodeUponCreation=True, showChildNodeTypes=False) mainFormLayout.addRow("Input Volume: ", self.inputVolumeSelector) self.targetFiducialsSelector = self.createComboBox(nodeTypes=["vtkMRMLMarkupsFiducialNode", ""], noneEnabled=False, selectNodeUponCreation=True, showChildNodeTypes=False, addEnabled=True, removeEnabled=True, showHidden=False, toolTip="Select Markups for targets") mainFormLayout.addRow("Targets: ", self.targetFiducialsSelector) self.targetFiducialsNode = None # # Target List Table # self.table = qt.QTableWidget(1, 4) self.table.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.table.setSelectionMode(qt.QAbstractItemView.SingleSelection) # self.table.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.headers = ["Name", "Hole", "Depth (mm)", "Position (RAS)"] self.table.setHorizontalHeaderLabels(self.headers) self.table.horizontalHeader().setStretchLastSection(True) mainLayout = qt.QVBoxLayout(self.mainCollapsibleButton) mainLayout.addWidget(mainFormFrame) mainLayout.addWidget(self.table)
def setup(self): print ("setup") # Collapsible button self.sampleCollapsibleButton = ctk.ctkCollapsibleButton() self.sampleCollapsibleButton.text = "A collapsible button" self.layout.addWidget(self.sampleCollapsibleButton) self.sampleFormLayout = qt.QFormLayout(self.sampleCollapsibleButton) self.btnBeginPlacingLandmarks = qt.QPushButton("Begin Placing") self.btnBeginPlacingLandmarks.toolTip = "Placing Anatomical Landmarks" self.sampleFormLayout.addWidget(self.btnBeginPlacingLandmarks) self.btnBeginPlacingLandmarks.connect('clicked(bool)', self.beginPlacing) self.layout.addStretch(1) markup = slicer.modules.markups.logic() markup.AddNewFiducialNode() self.table = qt.QTableWidget() self.table.setRowCount(1) self.table.setColumnCount(5) self.table.horizontalHeader().setResizeMode(qt.QHeaderView.Stretch) self.table.setSizePolicy (qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.table.setMinimumWidth(400) self.table.setMinimumHeight(215) self.table.setMaximumHeight(215) horizontalHeaders = ["Landmark", "Fiducial ID", "x", "y", "z"] self.table.setHorizontalHeaderLabels(horizontalHeaders) self.table.itemSelectionChanged.connect(self.onTableCellClicked) self.sampleFormLayout.addWidget(self.table) self.deleteFid = qt.QPushButton("Delete Selected Fiducial") self.deleteFid.connect('clicked(bool)', self.deleteFiducial) #self.sampleFormLayout.addWidget(self.deleteFid) fiducialNode = slicer.mrmlScene.GetNodeByID('vtkMRMLMarkupsFiducialNode1') self.fidObserve = fiducialNode.AddObserver(vtk.vtkCommand.ModifiedEvent, self.placeFiducialAsLandmark) self.btnComputeSplines = qt.QPushButton("Compute Splines") self.btnComputeSplines.toolTip = "" self.sampleFormLayout.addWidget(self.btnComputeSplines) self.btnComputeSplines.connect('clicked(bool)', self.computeSplines) self.btnExportSplines = qt.QPushButton("Export Splines") self.btnExportSplines.toolTip = "" self.sampleFormLayout.addWidget(self.btnExportSplines) self.btnExportSplines.connect('clicked(bool)', self.exportSplines) self.initializeTable()
def __init__(self, parent, headerName, multiSelect=False, width=100): self.widget = qt.QTableWidget(parent) # self.widget.setMinimumWidth(width) self.widget.setColumnCount(12) self.widget.setHorizontalHeaderLabels([headerName]) #self.widget.horizontalHeader().setResizeMode(0, qt.QHeaderView.Stretch) #self.widget.horizontalHeader().stretchLastSection = 1 self.widget.setEditTriggers(qt.QAbstractItemView.NoEditTriggers) self.multiSelect = multiSelect if self.multiSelect == False: self.widget.setSelectionMode(qt.QAbstractItemView.SingleSelection) self.width = width self.items = [] self.strings = []
def createUserInterface( self ): self.__layout = self.__parent.createUserInterface() ln = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLLayoutNode') ln.SetViewArrangement(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalPlotView) modLabel = qt.QLabel('Choose the puncture site:') # Paint Screw Button self.__selectScrewButton = qt.QPushButton("Grade Screws") self.__layout.addWidget(self.__selectScrewButton) self.__selectScrewButton.connect('clicked(bool)', self.gradeScrews) self.fiducial = self.fiducialNode() self.fidNumber = self.fiducial.GetNumberOfFiducials()*2/3 self.screwList = slicer.modules.PedicleScrewPlannerWidget.measurementsStep.screwList self.screwNumber = len(self.screwList) logging.debug("self.screwList:{}".format(self.screwList)) # self.screwTable.setRowCount(self.screwNumber) # Screw Table horizontalHeaders = ["puncture site","Screw\n Size","Angle\n TPA/SPA","% Screw in\nSoft Tissue\n (<130HU)","% Screw in\nLD Bone\n (130-250HU)","% Screw in\nHD Bone\n (>250HU)" ] self.screwTable = qt.QTableWidget(self.screwNumber, 6) self.screwTable.sortingEnabled = False self.screwTable.setEditTriggers(1) self.screwTable.setMinimumHeight(self.screwTable.verticalHeader().length()) self.screwTable.horizontalHeader().setSectionResizeMode(qt.QHeaderView.Stretch) self.screwTable.setSizePolicy (qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.screwTable.itemSelectionChanged.connect(self.onTableCellClicked) self.__layout.addWidget(self.screwTable) self.screwTable.setHorizontalHeaderLabels(horizontalHeaders) self.updateWidgetFromParameters(self.parameterNode()) qt.QTimer.singleShot(0, self.killButton) self.updateTable()
def defineStatisticsTable(self, fieldDictionaryValue): statTable = qt.QTableWidget() numberOfRows = fieldDictionaryValue.__len__() statTable.setRowCount(numberOfRows) i = numberOfRows - 1 statTable.setMinimumHeight(numberOfRows*35) statTable.setMinimumWidth(55) statTable.setColumnCount(12) statTable.setHorizontalHeaderLabels(['Model','Min','Max','Mean','SD','Per5','Per15','Per25','Per50','Per75','Per85','Per95']) # Add Values: for key, value in fieldDictionaryValue.items(): statTable.setCellWidget(i, 0, qt.QLabel(key)) statTable.setCellWidget(i, 1, qt.QLabel(value.min)) statTable.cellWidget(i,1).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 2, qt.QLabel(value.max)) statTable.cellWidget(i,2).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 3, qt.QLabel(value.mean)) statTable.cellWidget(i,3).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 4, qt.QLabel(value.std)) statTable.cellWidget(i,4).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 5, qt.QLabel(value.percentile5)) statTable.cellWidget(i,5).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 6, qt.QLabel(value.percentile15)) statTable.cellWidget(i,6).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 7, qt.QLabel(value.percentile25)) statTable.cellWidget(i,7).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 8, qt.QLabel(value.percentile50)) statTable.cellWidget(i,8).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 9, qt.QLabel(value.percentile75)) statTable.cellWidget(i,9).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 10, qt.QLabel(value.percentile85)) statTable.cellWidget(i,10).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') statTable.setCellWidget(i, 11, qt.QLabel(value.percentile95)) statTable.cellWidget(i,11).setStyleSheet(' QLabel{ qproperty-alignment: AlignCenter;}') i -= 1 statTable.resizeColumnToContents(0) return statTable
def __init__(self, parent=None): self.chartOptions = ("System", "Random", "P90", "P95", "P99") self.tableWidget = qt.QTableWidget() self.items = [] if not parent: self.parent = slicer.qMRMLWidget() self.parent.setLayout(qt.QVBoxLayout()) self.parent.setMRMLScene(slicer.mrmlScene) else: self.parent = parent self.layout = self.parent.layout() self.logic = None self.fileDialog = None self.numberOfSimulations = 100 self.numberOfFractions = 1 self.systematicErrorRange = 0.5 self.randomErrorRange = 0.5 self.doseGrowRange = 5 self.ROIRadiusX = 10 self.ROIRadiusY = 10 self.ROIRadiusZ = 10 if not parent: self.setup() self.parent.show()
def createUserInterface(self): slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, self.onNodeAddedRemoved) slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeRemovedEvent, self.onNodeAddedRemoved) rulers = slicer.util.getNodesByClass('vtkMRMLAnnotationRulerNode') for ruler in rulers: ruler.AddObserver('ModifiedEvent', self.rulerLengthCheck) ''' rs = slicer.mrmlScene.GetNodeByID('vtkMRMLAnnotationRulerNode1') rs.AddObserver('ModifiedEvent', a) ''' self.__layout = self.__parent.createUserInterface() #slicer.app.applicationLogic().PropagateVolumeSelection() #self.fiducialSelectionButton = slicer.qSlicerMouseModeToolBar() #self.fiducialSelectionButton.connect('mrmlSceneChanged(slicer.vtkMRMLScene*)', 'setMRMLScene(slicer.vtkMRMLScene*)') #buttonDescription = qt.QLabel('Click to Add Insertion Points to Scene:') #self.__layout.addRow(buttonDescription) #self.__layout.addRow(self.fiducialSelectionButton) #self.fiducialSelectionButton.setApplicationLogic(slicer.app.applicationLogic()) #self.fiducialSelectionButton.setMRMLScene(slicer.app.mrmlScene()) self.startMeasurements = qt.QPushButton("Start Measuring") self.startMeasurements.connect('clicked(bool)', self.startMeasure) #self.__layout.addWidget(self.startMeasurements) #self.stopMeasurements = qt.QPushButton("Stop Measuring") #self.stopMeasurements.connect('clicked(bool)', self.stop) #self.__layout.addWidget(self.stopMeasurements) #self.updateTable2 = qt.QPushButton("Update Table") #self.updateTable2.connect('clicked(bool)', self.updateTable) #self.__layout.addWidget(self.updateTable2) self.adjustFiducials = qt.QPushButton("Adjust Landmarks") self.adjustFiducials.connect('clicked(bool)', self.makeFidAdjustments) self.crosshair = qt.QPushButton("Hide Crosshair") self.crosshair.connect('clicked(bool)', self.crosshairVisible) buttonLayout = qt.QHBoxLayout() buttonLayout.addWidget(self.startMeasurements) #buttonLayout.addWidget(self.stopMeasurements) #buttonLayout.addWidget(self.updateTable2) self.__layout.addRow(buttonLayout) buttonLayout2 = qt.QHBoxLayout() buttonLayout2.addWidget(self.adjustFiducials) buttonLayout2.addWidget(self.crosshair) self.__layout.addRow(buttonLayout2) self.fiducial = self.fiducialNode() self.fidNumber = self.fiducial.GetNumberOfFiducials() self.fidLabels = [] self.fidLevels = [] self.fidSides = [] self.oldPosition = 0 ''' for i in range(0,self.fidNumber): self.fidLabels.append(slicer.modules.PedicleScrewSimulatorWidget.landmarksStep.table2.item(i,0).text()) self.fidLevels.append(slicer.modules.PedicleScrewSimulatorWidget.landmarksStep.table2.cellWidget(i,1).currentText) self.fidSides.append(slicer.modules.PedicleScrewSimulatorWidget.landmarksStep.table2.cellWidget(i,2).currentText) #self.fidLabels.append(self.fiducial.GetNthFiducialLabel(i)) #position = [0,0,0] #self.fiducial.GetNthFiducialPosition(i,position) #self.fidPositions.append(position) ''' logging.debug(self.fidLabels) logging.debug(self.fidLevels) logging.debug(self.fidSides) #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") #pNode = self.parameterNode() # Angle Table horizontalHeaders = [ "Fiducial", "Level", "Side", "Pedicle\n Length", "Pedicle\n Width" ] #self.vertebra = str(pNode.GetParameter('vertebra')) #self.inst_length = str(pNode.GetParameter('inst_length')) #logging.debug(self.vertebra) #logging.debug(self.inst_length) #self.levelselection = [] #for i in range(self.levels.index(self.vertebra),self.levels.index(self.vertebra)+int(self.inst_length)): # logging.debug(self.levels[i]) # self.levelselection.append(self.levels[i]) #logging.debug(self.levelselection) self.angleTable = qt.QTableWidget(self.fidNumber, 5) self.angleTable.sortingEnabled = False self.angleTable.setEditTriggers(1) self.angleTable.setMinimumHeight( self.angleTable.verticalHeader().length()) self.angleTable.horizontalHeader().setSectionResizeMode( qt.QHeaderView.Stretch) self.angleTable.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.angleTable.itemSelectionChanged.connect(self.onTableCellClicked) self.__layout.addWidget(self.angleTable) self.angleTable.setHorizontalHeaderLabels(horizontalHeaders) self.items = [] ''' for i in range(0,self.fidNumber): #logging.debug(self.levelselection[i] + "loop") Label = qt.QTableWidgetItem(str(self.fidLabels[i])) logging.debug(Label) Level = qt.QTableWidgetItem(str(self.fidLevels[i])) logging.debug(Level) Side = qt.QTableWidgetItem(str(self.fidSides[i])) logging.debug(Side) #self.items.append(Label) self.angleTable.setItem(i, 0, Label) self.angleTable.setItem(i, 1, Level) self.angleTable.setItem(i, 2, Side) ''' reconCollapsibleButton = ctk.ctkCollapsibleButton() reconCollapsibleButton.text = "Change Slice Reconstruction" self.__layout.addWidget(reconCollapsibleButton) reconCollapsibleButton.collapsed = True # Layout reconLayout = qt.QFormLayout(reconCollapsibleButton) #label for ROI selector reconLabel = qt.QLabel('Recon Slice:') rotationLabel = qt.QLabel('Rotation Angle:') #creates combobox and populates it with all vtkMRMLAnnotationROINodes in the scene self.selector = slicer.qMRMLNodeComboBox() self.selector.nodeTypes = ['vtkMRMLSliceNode'] self.selector.toolTip = "Change Slice Reconstruction" self.selector.setMRMLScene(slicer.mrmlScene) self.selector.addEnabled = 1 #add label + combobox reconLayout.addRow(reconLabel, self.selector) #self.reconSlice = slicer.qMRMLNodeComboBox() #self.recon = slicer.modules.reformat.createNewWidgetRepresentation() # pull slice selector #self.selector = self.recon.findChild('qMRMLNodeComboBox') #self.selector.setCurrentNodeID('vtkMRMLSliceNodeRed') #self.__layout.addWidget(self.selector) self.slider = ctk.ctkSliderWidget() #self.slider = PythonQt.qMRMLWidgets.qMRMLLinearTransformSlider() #tnode = slicer.mrmlScene.GetNodeByID('vtkMRMLLinearTransformNode1') #self.slider.setMRMLTransformNode(tnode) self.slider.connect('valueChanged(double)', self.sliderValueChanged) self.slider.minimum = -100 self.slider.maximum = 100 reconLayout.addRow(rotationLabel, self.slider) ''' # pull offset & rotation sliders self.reconButton = self.recon.findChild('ctkCollapsibleButton') self.reconProperties = self.reconButton.findChildren('ctkCollapsibleGroupBox') self.reconSpecificProperty1 = self.reconProperties[2] self.reconSlider1 = self.reconSpecificProperty1.findChildren('qMRMLLinearTransformSlider') self.slider = self.reconSlider1[0] self.reconSpecificProperty2 = self.reconProperties[0] self.reconSlider2 = self.reconSpecificProperty2.findChildren('qMRMLLinearTransformSlider') self.slider2 = self.reconSlider2[0] rText = qt.QLabel("Rotate Slice:") self.__layout.addWidget(rText) self.__layout.addWidget(self.slider) #tText = qt.QLabel("Translate Slice:") #self.__layout.addWidget(tText) #self.__layout.addWidget(self.slider2) ''' # self.updateWidgetFromParameters(self.parameterNode()) qt.QTimer.singleShot(0, self.killButton) self.updateTable()
def createUserInterface( self ): markup = slicer.modules.markups.logic() markup.AddNewFiducialNode() self.__layout = self.__parent.createUserInterface() self.startMeasurements = slicer.qSlicerMarkupsPlaceWidget() self.startMeasurements.setButtonsVisible(False) self.startMeasurements.placeButton().show() self.startMeasurements.setMRMLScene(slicer.mrmlScene) self.startMeasurements.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceMultipleMarkups self.startMeasurements.connect('activeMarkupsFiducialPlaceModeChanged(bool)', self.addFiducials) #self.__layout.addWidget(self.startMeasurements) #self.stopMeasurements = qt.QPushButton("Stop Placing") #self.stopMeasurements.connect('clicked(bool)', self.stop) #self.__layout.addWidget(self.stopMeasurements) #self.updateTable2 = qt.QPushButton("Update Table") #self.updateTable2.connect('clicked(bool)', self.updateTable) #self.__layout.addWidget(self.updateTable2) buttonLayout = qt.QHBoxLayout() buttonLayout.addWidget(self.startMeasurements) #buttonLayout.addWidget(self.stopMeasurements) #buttonLayout.addWidget(self.updateTable2) self.__layout.addRow(buttonLayout) ''' # Table Output of Fiducial List (Slicer 4.3 Markups) tableDescription = qt.QLabel('List of Points Added to Scene:') self.__layout.addRow(tableDescription) self.__markupWidget = slicer.modules.markups.createNewWidgetRepresentation() slicer.modules.markups.logic().AddNewFiducialNode() self.__markupWidget.onActiveMarkupMRMLNodeChanged(0) self.table = self.__markupWidget.findChild('QTableWidget') self.table.hideColumn(0) self.table.hideColumn(1) self.table.hideColumn(2) self.table.setMinimumHeight(100) self.table.setMaximumHeight(170) self.table.setMinimumWidth(400) self.table.setMaximumWidth(447) self.table.resize(400,170) self.__layout.addWidget(self.table) ''' self.table2 = qt.QTableWidget() self.table2.setRowCount(1) self.table2.setColumnCount(3) self.table2.horizontalHeader().setSectionResizeMode(qt.QHeaderView.Stretch) self.table2.setSizePolicy (qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.table2.setMinimumWidth(400) self.table2.setMinimumHeight(215) self.table2.setMaximumHeight(215) horizontalHeaders = ["Fiducial","Level","Side"] self.table2.setHorizontalHeaderLabels(horizontalHeaders) self.table2.itemSelectionChanged.connect(self.onTableCellClicked) self.__layout.addWidget(self.table2) self.deleteFid = qt.QPushButton("Remove Selected Fiducial") self.deleteFid.connect('clicked(bool)', self.deleteFiducial) self.__layout.addWidget(self.deleteFid) # Camera Transform Sliders transCam = ctk.ctkCollapsibleButton() transCam.text = "Shift Camera Position" transCam.collapsed = True self.__layout.addWidget(transCam) #transCam.collapsed = True camLayout = qt.QFormLayout(transCam) a = PythonQt.qMRMLWidgets.qMRMLTransformSliders() a.setMRMLTransformNode(slicer.mrmlScene.GetNodeByID('vtkMRMLLinearTransformNode4')) #transWidget = slicer.modules.transforms.createNewWidgetRepresentation() #transSelector = transWidget.findChild('qMRMLNodeComboBox') #transWidgetPart = transWidget.findChild('ctkCollapsibleButton') #transformSliders = transWidgetPart.findChildren('qMRMLTransformSliders') camLayout.addRow(a) qt.QTimer.singleShot(0, self.killButton)
def __init__(self,parent): self.widget = qt.QTableWidget() self.widget.setSelectionBehavior(1) # qt.Qt.QAbstractItemView.SelectRows) self.widget.connect('itemClicked(QTableWidgetItem*)', self.onItemClicked) self.items = [] self.setHeader(None)
def createUserInterface(self): ''' ''' self.__layout = super(EMSegmentQuickStep3, self).createUserInterface() self.__top = qt.QWidget() self.__topLayout = qt.QHBoxLayout(self.__top) # the anatomical tree anatomicalTreeGroupBox = qt.QGroupBox() anatomicalTreeGroupBox.setTitle('Anatomical Tree') self.__topLayout.addWidget(anatomicalTreeGroupBox) anatomicalTreeGroupBoxLayout = qt.QFormLayout(anatomicalTreeGroupBox) self.__anatomicalTree = slicer.modulewidget.qSlicerEMSegmentAnatomicalTreeWidget( ) self.__anatomicalTree.structureNameEditable = False self.__anatomicalTree.labelColumnVisible = False self.__anatomicalTree.probabilityMapColumnVisible = False self.__anatomicalTree.classWeightColumnVisible = False self.__anatomicalTree.updateClassWeightColumnVisible = False self.__anatomicalTree.atlasWeightColumnVisible = False self.__anatomicalTree.alphaColumnVisible = False self.__anatomicalTree.displayAlphaCheckBoxVisible = False self.__anatomicalTree.setMinimumHeight(200) self.__anatomicalTree.toolTip = 'Select a structure to configure the intensity distribution.' self.__anatomicalTree.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.MinimumExpanding) self.__anatomicalTree.connect('currentTreeNodeChanged(vtkMRMLNode*)', self.onTreeSelectionChanged) anatomicalTreeGroupBoxLayout.addWidget(self.__anatomicalTree) # # overview of class weights panel # self.__overviewBox = qt.QGroupBox() self.__overviewBox.title = 'Guesses of Probability' self.__overviewBox.toolTip = 'These are your guesses of probability relations between structures. Which structure takes how much percentage of the volume?' self.__overviewBoxLayout = qt.QVBoxLayout(self.__overviewBox) self.__topLayout.addWidget(self.__overviewBox) self.__layout.addWidget(self.__top) self.__tabWidget = qt.QTabWidget() self.__layout.addWidget(self.__tabWidget) # # manualSamplingPage # manualSamplingPage = qt.QWidget() manualSamplingPageLayout = qt.QFormLayout(manualSamplingPage) self.__classLabel2 = qt.QLabel("Class: XX") manualSamplingPageLayout.addWidget(self.__classLabel2) self.__infoLabel = qt.QLabel( "left mouse Click in a slice window to pick a sample") manualSamplingPageLayout.addWidget(self.__infoLabel) self.__manualSampleTable = qt.QTableWidget() manualSamplingPageLayout.addWidget(self.__manualSampleTable) self.__tabWidget.addTab(manualSamplingPage, "Manual Sampling") self.__plotDistributionButton = qt.QPushButton() self.__plotDistributionButton.text = "Plot Distribution" self.__plotDistributionButton.toolTip = 'Click to plot the intensity distributions for all structures.' self.__layout.addRow(self.__plotDistributionButton) self.__plotDistributionButton.connect('clicked()', self.plotDistribution)
def setup(self): # Tags are used to manage event ovservers self.tagSourceNode = None self.tagDestinationNode = None #Set up area for creating curves createCurveBttn = ctk.ctkCollapsibleButton() createCurveBttn.text = "Create Curve" self.layout.addWidget(createCurveBttn) layout = qt.QFormLayout(createCurveBttn) #Selecting source points from fiducials self.SourceSelector = slicer.qMRMLNodeComboBox() self.SourceSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "") self.SourceSelector.addEnabled = True self.SourceSelector.removeEnabled = True self.SourceSelector.noneEnabled = True self.SourceSelector.renameEnabled = True self.SourceSelector.setMRMLScene(slicer.mrmlScene) self.SourceSelector.setToolTip( "Select source of points or create a new list") layout.addRow("Source points: ", self.SourceSelector) #Selecting destination for new curve self.DestinationSelector = slicer.qMRMLNodeComboBox() self.DestinationSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.DestinationSelector.addEnabled = True self.DestinationSelector.removeEnabled = True self.DestinationSelector.noneEnabled = True self.DestinationSelector.renameEnabled = True self.DestinationSelector.selectNodeUponCreation = True self.DestinationSelector.setMRMLScene(slicer.mrmlScene) self.DestinationSelector.setToolTip( "Select existing curve model or create a new one") layout.addRow("Curve model: ", self.DestinationSelector) #x, y, z inputs for new fiducial self.validator = qt.QDoubleValidator() self.AddFiducialLayout = qt.QHBoxLayout() self.AddX = qt.QLineEdit("X") self.AddX.setValidator(self.validator) self.AddY = qt.QLineEdit("Y") self.AddY.setValidator(self.validator) self.AddZ = qt.QLineEdit("Z") self.AddZ.setValidator(self.validator) self.AddFiducialLayout.addWidget(self.AddX) self.AddFiducialLayout.addWidget(self.AddY) self.AddFiducialLayout.addWidget(self.AddZ) layout.addRow("X, Y, Z coordinates for new fiducial: ", self.AddFiducialLayout) #Add fiducial button self.AddFiducialButton = qt.QPushButton("Add Fiducial") self.AddFiducialButton.toolTip = "Adds fiducial using given x, y, z coordinates" self.AddFiducialButton.enabled = True layout.addRow("", self.AddFiducialButton) #Current fiducials table self.FiducialTable = qt.QTableWidget(1, 4) self.FiducialTableHeaders = ["Name", "X (mm)", "Y (mm)", "Z (mm)"] self.FiducialTable.setHorizontalHeaderLabels(self.FiducialTableHeaders) layout.addWidget(self.FiducialTable) #Radius of curve self.RadiusSliderWidget = ctk.ctkSliderWidget() self.RadiusSliderWidget.singleStep = 0.5 self.RadiusSliderWidget.minimum = 0.5 self.RadiusSliderWidget.maximum = 20.0 self.RadiusSliderWidget.value = 3.0 self.RadiusSliderWidget.setToolTip( "Determines the thickness of the curve") layout.addRow("Thickness: ", self.RadiusSliderWidget) #Select the method of interpolation self.InterpolationLayout = qt.QHBoxLayout() self.InterpolationLinear = qt.QRadioButton("Linear") self.InterpolationLinear.setToolTip( "Straight lines from point to point") self.InterpolationSpline = qt.QRadioButton("Spline") self.InterpolationSpline.setToolTip( "Cardinal spline will create curvature between points") self.InterpolationLayout.addWidget(self.InterpolationLinear) self.InterpolationLayout.addWidget(self.InterpolationSpline) self.InterpolationGroup = qt.QButtonGroup() self.InterpolationGroup.addButton(self.InterpolationLinear) self.InterpolationGroup.addButton(self.InterpolationSpline) layout.addRow("Interpolation: ", self.InterpolationLayout) #Button for generating specified curve self.GenerateButton = qt.QPushButton("Generate/Update Curve") self.GenerateButton.toolTip = "Creates or updates curve specified" self.GenerateButton.enabled = True layout.addRow("", self.GenerateButton) #Linking buttons to methods self.InterpolationLinear.connect('clicked(bool)', self.onSelectInterpolationLinear) self.InterpolationSpline.connect('clicked(bool)', self.onSelectInterpolationSpline) self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSourceSelected) self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onDestinationSelected) self.AddX.textChanged.connect( lambda inputSelection: self.checkInputState('x')) self.AddX.textChanged.emit(self.AddX.text) self.AddY.textChanged.connect( lambda inputSelection: self.checkInputState('y')) self.AddY.textChanged.emit(self.AddY.text) self.AddZ.textChanged.connect( lambda inputSelection: self.checkInputState('z')) self.AddZ.textChanged.emit(self.AddZ.text) self.AddFiducialButton.connect('clicked(bool)', self.addFiducial) self.RadiusSliderWidget.connect("valueChanged(double)", self.onThicknessUpdated) self.GenerateButton.connect('clicked(bool)', self.generateCurve) #Default checkboxes self.InterpolationSpline.setChecked(True) self.onSelectInterpolationSpline(True) self.layout.addStretch(1)
def setup(self): # Instantiate and connect widgets ... self.RingOff = None self.RingOn = None # Tags to manage event observers self.tagSourceNode = None self.tagDestinationNode = None ##################### ## For debugging ## ## Reload and Test area reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) ## reload button ## (use this during development, but remove it when delivering ## your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "CurveMaker Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) ## ##################### # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Source points (vtkMRMLMarkupsFiducialNode) # self.SourceSelector = slicer.qMRMLNodeComboBox() self.SourceSelector.nodeTypes = (("vtkMRMLMarkupsFiducialNode"), "") self.SourceSelector.addEnabled = True self.SourceSelector.removeEnabled = False self.SourceSelector.noneEnabled = True self.SourceSelector.showHidden = False self.SourceSelector.renameEnabled = True self.SourceSelector.showChildNodeTypes = False self.SourceSelector.setMRMLScene(slicer.mrmlScene) self.SourceSelector.setToolTip( "Pick up a Markups node listing fiducials.") parametersFormLayout.addRow("Source points: ", self.SourceSelector) # # Target point (vtkMRMLMarkupsFiducialNode) # self.DestinationSelector = slicer.qMRMLNodeComboBox() self.DestinationSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.DestinationSelector.addEnabled = True self.DestinationSelector.removeEnabled = False self.DestinationSelector.noneEnabled = True self.DestinationSelector.showHidden = False self.DestinationSelector.renameEnabled = True self.DestinationSelector.selectNodeUponCreation = True self.DestinationSelector.showChildNodeTypes = False self.DestinationSelector.setMRMLScene(slicer.mrmlScene) self.DestinationSelector.setToolTip("Pick up or create a Model node.") parametersFormLayout.addRow("Curve model: ", self.DestinationSelector) # # Radius for the tube # self.RadiusSliderWidget = ctk.ctkSliderWidget() self.RadiusSliderWidget.singleStep = 1.0 self.RadiusSliderWidget.minimum = 1.0 self.RadiusSliderWidget.maximum = 50.0 self.RadiusSliderWidget.value = 5.0 self.RadiusSliderWidget.setToolTip("Set the raidus of the tube.") parametersFormLayout.addRow("Radius (mm): ", self.RadiusSliderWidget) # # Radio button to select interpolation method # self.InterpolationLayout = qt.QHBoxLayout() self.InterpolationNone = qt.QRadioButton("None") self.InterpolationCardinalSpline = qt.QRadioButton("Cardinal Spline") self.InterpolationHermiteSpline = qt.QRadioButton( "Hermite Spline (for Endoscopy)") self.InterpolationLayout.addWidget(self.InterpolationNone) self.InterpolationLayout.addWidget(self.InterpolationCardinalSpline) self.InterpolationLayout.addWidget(self.InterpolationHermiteSpline) self.InterpolationGroup = qt.QButtonGroup() self.InterpolationGroup.addButton(self.InterpolationNone) self.InterpolationGroup.addButton(self.InterpolationCardinalSpline) self.InterpolationGroup.addButton(self.InterpolationHermiteSpline) parametersFormLayout.addRow("Interpolation: ", self.InterpolationLayout) # # Interpolation Resolution # self.InterpResolutionSliderWidget = ctk.ctkSliderWidget() self.InterpResolutionSliderWidget.singleStep = 1.0 self.InterpResolutionSliderWidget.minimum = 3.0 self.InterpResolutionSliderWidget.maximum = 50.0 self.InterpResolutionSliderWidget.value = 25.0 self.InterpResolutionSliderWidget.setToolTip( "Number of interpolation points between control points. Default is 25." ) parametersFormLayout.addRow("Resolution: ", self.InterpResolutionSliderWidget) # # Radio button for ring mode # self.RingLayout = qt.QHBoxLayout() self.RingOff = qt.QRadioButton("Off") self.RingOn = qt.QRadioButton("On") self.RingLayout.addWidget(self.RingOff) self.RingLayout.addWidget(self.RingOn) self.RingGroup = qt.QButtonGroup() self.RingGroup.addButton(self.RingOff) self.RingGroup.addButton(self.RingOn) parametersFormLayout.addRow("Ring mode: ", self.RingLayout) # # Check box to start curve visualization # self.EnableAutoUpdateCheckBox = qt.QCheckBox() self.EnableAutoUpdateCheckBox.checked = 0 self.EnableAutoUpdateCheckBox.setToolTip( "If checked, the CurveMaker module keeps updating the model as the points are updated." ) parametersFormLayout.addRow("Auto update:", self.EnableAutoUpdateCheckBox) # # Button to generate a curve # self.GenerateButton = qt.QPushButton("Generate Curve") self.GenerateButton.toolTip = "Generate Curve" self.GenerateButton.enabled = True parametersFormLayout.addRow("", self.GenerateButton) # Connections self.InterpolationNone.connect('clicked(bool)', self.onSelectInterpolationNone) self.InterpolationCardinalSpline.connect( 'clicked(bool)', self.onSelectInterpolationCardinalSpline) self.InterpolationHermiteSpline.connect( 'clicked(bool)', self.onSelectInterpolationHermiteSpline) self.RingOff.connect('clicked(bool)', self.onRingOff) self.RingOn.connect('clicked(bool)', self.onRingOn) self.EnableAutoUpdateCheckBox.connect('toggled(bool)', self.onEnableAutoUpdate) self.SourceSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSourceSelected) self.DestinationSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onDestinationSelected) self.RadiusSliderWidget.connect("valueChanged(double)", self.onTubeUpdated) self.InterpResolutionSliderWidget.connect( "valueChanged(double)", self.onInterpResolutionUpdated) self.GenerateButton.connect('clicked(bool)', self.onGenerateCurve) # Set default ## default interpolation method self.InterpolationCardinalSpline.setChecked(True) self.onSelectInterpolationCardinalSpline(True) ## default ring mode self.RingOff.setChecked(True) self.onRingOff(True) # # Curve Length area # lengthCollapsibleButton = ctk.ctkCollapsibleButton() lengthCollapsibleButton.text = "Length" self.layout.addWidget(lengthCollapsibleButton) lengthFormLayout = qt.QFormLayout(lengthCollapsibleButton) lengthCollapsibleButton.collapsed = True #-- Curve length self.lengthLineEdit = qt.QLineEdit() self.lengthLineEdit.text = '--' self.lengthLineEdit.readOnly = True self.lengthLineEdit.frame = True self.lengthLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.lengthLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) lengthFormLayout.addRow("Curve Length (mm):", self.lengthLineEdit) # # Distance Area # distanceCollapsibleButton = ctk.ctkCollapsibleButton() distanceCollapsibleButton.text = "Distance" distanceCollapsibleButton.collapsed = True self.layout.addWidget(distanceCollapsibleButton) distanceFormLayout = qt.QFormLayout(distanceCollapsibleButton) #-- Point-to-curve distance # - Markups selector for input points distanceLayout = qt.QVBoxLayout() self.targetFiducialsSelector = slicer.qMRMLNodeComboBox() self.targetFiducialsSelector.nodeTypes = (( "vtkMRMLMarkupsFiducialNode"), "") self.targetFiducialsSelector.selectNodeUponCreation = True self.targetFiducialsSelector.addEnabled = True self.targetFiducialsSelector.removeEnabled = True self.targetFiducialsSelector.noneEnabled = True self.targetFiducialsSelector.showHidden = False self.targetFiducialsSelector.showChildNodeTypes = False self.targetFiducialsSelector.setMRMLScene(slicer.mrmlScene) self.targetFiducialsSelector.setToolTip("Select Markups for targets") distanceLayout.addWidget(self.targetFiducialsSelector) self.targetFiducialsNode = None self.tagDestinationDispNode = None self.targetFiducialsSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onTargetFiducialsSelected) self.fiducialsTable = qt.QTableWidget(1, 3) self.fiducialsTable.setSelectionBehavior( qt.QAbstractItemView.SelectRows) self.fiducialsTable.setSelectionMode( qt.QAbstractItemView.SingleSelection) self.fiducialsTableHeaders = ["Name", "Position (mm)", "Distance (mm)"] self.fiducialsTable.setHorizontalHeaderLabels( self.fiducialsTableHeaders) self.fiducialsTable.horizontalHeader().setStretchLastSection(True) distanceLayout.addWidget(self.fiducialsTable) self.extrapolateCheckBox = qt.QCheckBox() self.extrapolateCheckBox.checked = 0 self.extrapolateCheckBox.setToolTip( "Extrapolate the first and last segment to calculate the distance") self.extrapolateCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.extrapolateCheckBox.text = 'Extrapolate curves to measure the distances' self.showErrorVectorCheckBox = qt.QCheckBox() self.showErrorVectorCheckBox.checked = 0 self.showErrorVectorCheckBox.setToolTip( "Show error vectors, which is defined by the target point and the closest point on the curve. The vector is perpendicular to the curve, unless the closest point is one end of the curve." ) self.showErrorVectorCheckBox.connect('toggled(bool)', self.updateTargetFiducialsTable) self.showErrorVectorCheckBox.text = 'Show error vectors' distanceLayout.addWidget(self.extrapolateCheckBox) distanceLayout.addWidget(self.showErrorVectorCheckBox) distanceFormLayout.addRow("Distance from:", distanceLayout) # # Curvature Area # curvatureCollapsibleButton = ctk.ctkCollapsibleButton() curvatureCollapsibleButton.text = "Curvature" curvatureCollapsibleButton.collapsed = True self.layout.addWidget(curvatureCollapsibleButton) curvatureFormLayout = qt.QFormLayout(curvatureCollapsibleButton) #-- Curvature self.curvatureLayout = qt.QHBoxLayout() self.curvatureOff = qt.QRadioButton("Off") self.curvatureOff.connect('clicked(bool)', self.onCurvatureOff) self.curvatureOn = qt.QRadioButton("On") self.curvatureOn.connect('clicked(bool)', self.onCurvatureOn) self.curvatureLayout.addWidget(self.curvatureOff) self.curvatureLayout.addWidget(self.curvatureOn) self.curvatureGroup = qt.QButtonGroup() self.curvatureGroup.addButton(self.curvatureOff) self.curvatureGroup.addButton(self.curvatureOn) curvatureFormLayout.addRow("Curvature mode:", self.curvatureLayout) autoCurvatureRangeFormLayout = qt.QFormLayout( curvatureCollapsibleButton) self.autoCurvatureRangeLayout = qt.QHBoxLayout() self.autoCurvatureRangeOff = qt.QRadioButton("Manual") self.autoCurvatureRangeOff.connect('clicked(bool)', self.onAutoCurvatureRangeOff) self.autoCurvatureRangeOn = qt.QRadioButton("Auto") self.autoCurvatureRangeOn.connect('clicked(bool)', self.onAutoCurvatureRangeOn) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOff) self.autoCurvatureRangeLayout.addWidget(self.autoCurvatureRangeOn) self.autoCurvatureRangeGroup = qt.QButtonGroup() self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOff) self.autoCurvatureRangeGroup.addButton(self.autoCurvatureRangeOn) curvatureFormLayout.addRow("Color range:", self.autoCurvatureRangeLayout) #-- Color range self.curvatureColorRangeWidget = ctk.ctkRangeWidget() self.curvatureColorRangeWidget.setToolTip("Set color range") self.curvatureColorRangeWidget.setDecimals(3) self.curvatureColorRangeWidget.singleStep = 0.001 self.curvatureColorRangeWidget.minimumValue = 0.0 self.curvatureColorRangeWidget.maximumValue = 0.5 self.curvatureColorRangeWidget.minimum = 0.0 self.curvatureColorRangeWidget.maximum = 1.0 curvatureFormLayout.addRow("Color range: ", self.curvatureColorRangeWidget) self.curvatureColorRangeWidget.connect( 'valuesChanged(double, double)', self.onUpdateCurvatureColorRange) #-- Curvature data self.meanCurvatureLineEdit = qt.QLineEdit() self.meanCurvatureLineEdit.text = '--' self.meanCurvatureLineEdit.readOnly = True self.meanCurvatureLineEdit.frame = True self.meanCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.meanCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.meanCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Mean (mm^-1):", self.meanCurvatureLineEdit) self.minCurvatureLineEdit = qt.QLineEdit() self.minCurvatureLineEdit.text = '--' self.minCurvatureLineEdit.readOnly = True self.minCurvatureLineEdit.frame = True self.minCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.minCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.minCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Minimum (mm^-1):", self.minCurvatureLineEdit) self.maxCurvatureLineEdit = qt.QLineEdit() self.maxCurvatureLineEdit.text = '--' self.maxCurvatureLineEdit.readOnly = True self.maxCurvatureLineEdit.frame = True self.maxCurvatureLineEdit.styleSheet = "QLineEdit { background:transparent; }" self.maxCurvatureLineEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) self.maxCurvatureLineEdit.enabled = False curvatureFormLayout.addRow("Maximum (mm^-1):", self.maxCurvatureLineEdit) ## Create a scale for curvature self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("Curvature (mm^-1)") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor( renderer.GetRenderWindow().GetInteractor()) self.lookupTable = vtk.vtkLookupTable() self.lookupTable.SetRange(0.0, 100.0) self.scalarBarWidget.GetScalarBarActor().SetLookupTable( self.lookupTable) ## default curvature mode: off self.curvatureOff.setChecked(True) self.onCurvatureOff(True) self.autoCurvatureRangeOff.setChecked(True) self.onAutoCurvatureRangeOff(True) # Add vertical spacer self.layout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) self.moduleName = "AnglePlanes" self.i = 0 self.logic = AnglePlanesLogic() self.planeControlsId = 0 self.planeControlsDictionary = {} self.midPointFiducialDictionaryID = {} # self.logic.initializePlane() self.n_vector = numpy.matrix([[0], [0], [1], [1]]) self.interactionNode = slicer.mrmlScene.GetNodeByID( "vtkMRMLInteractionNodeSingleton") #Definition of the 2 planes # Collapsible button -- Scene Description self.loadCollapsibleButton = ctk.ctkCollapsibleButton() self.loadCollapsibleButton.text = "Scene" self.layout.addWidget(self.loadCollapsibleButton) # Layout within the laplace collapsible button self.loadFormLayout = qt.QFormLayout(self.loadCollapsibleButton) #--------------------------- List of Models --------------------------# treeView = slicer.qMRMLTreeView() treeView.setMRMLScene(slicer.app.mrmlScene()) treeView.setSceneModelType('Displayable') treeView.sceneModel().setHorizontalHeaderLabels(["Models"]) treeView.sortFilterProxyModel().nodeTypes = ['vtkMRMLModelNode'] header = treeView.header() header.setResizeMode(0, qt.QHeaderView.Stretch) header.setVisible(True) self.loadFormLayout.addWidget(treeView) # numNodes = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLModelNode") # for i in range (3,numNodes): # self.elements = slicer.mrmlScene.GetNthNodeByClass(i,"vtkMRMLModelNode" ) # print self.elements.GetName() # Add vertical spacer self.layout.addStretch(1) #------------------------ Compute Bounding Box ----------------------# buttonFrameBox = qt.QFrame(self.parent) buttonFrameBox.setLayout(qt.QHBoxLayout()) self.loadFormLayout.addWidget(buttonFrameBox) self.computeBox = qt.QPushButton( "Compute Bounding Box around all models") buttonFrameBox.layout().addWidget(self.computeBox) self.computeBox.connect('clicked()', self.onComputeBox) self.CollapsibleButton = ctk.ctkCollapsibleButton() self.CollapsibleButton.text = "Manage planes" self.layout.addWidget(self.CollapsibleButton) self.managePlanesFormLayout = qt.QFormLayout(self.CollapsibleButton) self.CollapsibleButton.checked = True # Add planes and manage landmark addition to each plane addNewPlaneLayout = qt.QHBoxLayout() addPlaneLabel = qt.QLabel('Add new plane') addPlaneButton = qt.QPushButton( qt.QIcon(":/Icons/MarkupsAddFiducial.png"), " ") addPlaneButton.setFixedSize(50, 25) addPlaneButton.connect('clicked()', self.addNewPlane) addPlaneButton.setEnabled(True) addNewPlaneLayout.addWidget(addPlaneLabel) addNewPlaneLayout.addWidget(addPlaneButton) self.managePlanesFormLayout.addRow(addNewPlaneLayout) # ----------------- Compute Mid Point ------------- self.midPointGroupBox = ctk.ctkCollapsibleButton() self.midPointGroupBox.setText( 'Define middle point between two landmarks') self.midPointGroupBox.collapsed = True self.parent.layout().addWidget(self.midPointGroupBox) self.landmarkComboBox1MidPoint = qt.QComboBox() self.landmarkComboBox2MidPoint = qt.QComboBox() landmark1Layout = qt.QFormLayout() landmark1Layout.addRow('Landmark A: ', self.landmarkComboBox1MidPoint) landmark1Layout.addRow('Landmark B: ', self.landmarkComboBox2MidPoint) self.defineMiddlePointButton = qt.QPushButton(' Add middle point ') # self.midPointOnSurfaceCheckBox = qt.QCheckBox('On Surface') # self.midPointOnSurfaceCheckBox.setChecked(False) exportLayout_1 = qt.QFormLayout() # exportLayout_1.addRow(self.midPointOnSurfaceCheckBox, self.defineMiddlePointButton) exportLayout_1.addRow(self.defineMiddlePointButton) self.midPointLayout = qt.QVBoxLayout() self.midPointLayout.addLayout(landmark1Layout) self.midPointLayout.addLayout(exportLayout_1) self.midPointGroupBox.setLayout(self.midPointLayout) self.defineMiddlePointButton.connect('clicked()', self.onAddMidPoint) # self.landmarkComboBox1MidPoint.connect('currentIndexChanged(int)', self.onUpdateMidPoint) # self.landmarkComboBox2MidPoint.connect('currentIndexChanged(int)', self.onUpdateMidPoint) # -------- Calculate angles between planes ------------ self.CollapsibleButtonPlane = ctk.ctkCollapsibleButton() self.CollapsibleButtonPlane.text = "Choose planes" self.layout.addWidget(self.CollapsibleButtonPlane) sampleFormLayoutPlane = qt.QFormLayout(self.CollapsibleButtonPlane) self.planeComboBox1 = qt.QComboBox() self.planeComboBox1.addItem("red") self.planeComboBox1.addItem("yellow") self.planeComboBox1.addItem("green") sampleFormLayoutPlane.addRow("Select plane 1: ", self.planeComboBox1) self.planeComboBox2 = qt.QComboBox() self.planeComboBox2.addItem("red") self.planeComboBox2.addItem("yellow") self.planeComboBox2.addItem("green") sampleFormLayoutPlane.addRow("Select plane 2: ", self.planeComboBox2) self.CollapsibleButton2 = ctk.ctkCollapsibleButton() self.CollapsibleButton2.text = "Results" self.layout.addWidget(self.CollapsibleButton2) sampleFormLayout2 = qt.QFormLayout(self.CollapsibleButton2) self.results = qt.QPushButton("Results") self.results.connect('clicked()', self.angleValue) sampleFormLayout2.addWidget(self.results) label_RL = qt.QLabel("R-L View") self.getAngle_RL = qt.QLabel("0") label_SI = qt.QLabel("S-I View") self.getAngle_SI = qt.QLabel("0") label_AP = qt.QLabel("A-P View") self.getAngle_AP = qt.QLabel("0") self.getAngle_RL_comp = qt.QLabel("0") self.getAngle_SI_comp = qt.QLabel("0") self.getAngle_AP_comp = qt.QLabel("0") tableResult = qt.QTableWidget(3, 3) tableResult.setColumnCount(3) tableResult.setHorizontalHeaderLabels( [' View ', 'Angle', 'Complementary angle']) tableResult.setColumnWidth(0, 80) tableResult.setColumnWidth(1, 80) tableResult.setColumnWidth(2, 180) tableResult.setRowCount(1) tableResult.setCellWidget(0, 0, label_RL) tableResult.setCellWidget(0, 1, self.getAngle_RL) tableResult.setCellWidget(0, 2, self.getAngle_RL_comp) tableResult.setRowCount(2) tableResult.setCellWidget(1, 0, label_SI) tableResult.setCellWidget(1, 1, self.getAngle_SI) tableResult.setCellWidget(1, 2, self.getAngle_SI_comp) tableResult.setRowCount(3) tableResult.setCellWidget(2, 0, label_AP) tableResult.setCellWidget(2, 1, self.getAngle_AP) tableResult.setCellWidget(2, 2, self.getAngle_AP_comp) # Add vertical spacer self.layout.addStretch(1) sampleFormLayout2.addWidget(tableResult) self.CollapsibleButton3 = ctk.ctkCollapsibleButton() self.CollapsibleButton3.text = "Save" self.layout.addWidget(self.CollapsibleButton3) sampleFormLayout3 = qt.QFormLayout(self.CollapsibleButton3) self.CollapsibleButton3.checked = False buttonFrame = qt.QFrame(self.parent) buttonFrame.setLayout(qt.QVBoxLayout()) sampleFormLayout3.addWidget(buttonFrame) #-------------------------------- PLANES --------------------------------# save_plane = qt.QLabel("Save the planes you create as a txt file.") buttonFrame.layout().addWidget(save_plane) save = qt.QPushButton("Save plane") buttonFrame.layout().addWidget(save) # load_plane = qt.QLabel("Load the file with the plane you saved.") # buttonFrame.layout().addWidget(load_plane) read = qt.QPushButton("Load plane") buttonFrame.layout().addWidget(read) #-------------------------------- CONNECTIONS --------------------------------# self.planeComboBox1.connect('currentIndexChanged(QString)', self.valueComboBox) self.planeComboBox2.connect('currentIndexChanged(QString)', self.valueComboBox) save.connect('clicked(bool)', self.onSavePlanes) read.connect('clicked(bool)', self.onReadPlanes) slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, self.onCloseScene) self.pointLocatorDictionary = {} numNodes = slicer.mrmlScene.GetNumberOfNodesByClass("vtkMRMLModelNode") for i in range(3, numNodes): modelnode = slicer.mrmlScene.GetNthNodeByClass( i, "vtkMRMLModelNode") self.addModelPointLocator(modelnode.GetName(), modelnode.GetPolyData()) ModelAddedClass(self)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... self.logic = NeedleGuideTemplateLogic(None) #-------------------------------------------------- # For debugging # # Reload and Test area reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) reloadCollapsibleButton.collapsed = True # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "NeedleGuideTemlpate Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # #-------------------------------------------------- #-------------------------------------------------- # # Configuration # configCollapsibleButton = ctk.ctkCollapsibleButton() configCollapsibleButton.text = "Configuration" self.layout.addWidget(configCollapsibleButton) configFormLayout = qt.QFormLayout(configCollapsibleButton) configCollapsibleButton.collapsed = True templateConfigPathLayout = qt.QHBoxLayout() self.templateConfigPathEdit = qt.QLineEdit() self.templateConfigPathEdit.text = "" self.templateConfigPathEdit.readOnly = False self.templateConfigPathEdit.frame = True self.templateConfigPathEdit.styleSheet = "QLineEdit { background:transparent; }" self.templateConfigPathEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) templateConfigPathLayout.addWidget(self.templateConfigPathEdit) self.templateConfigButton = qt.QPushButton("...") self.templateConfigButton.toolTip = "Choose a template configuration file" self.templateConfigButton.enabled = True self.templateConfigButton.connect('clicked(bool)', self.onTemplateConfigButton) templateConfigPathLayout.addWidget(self.templateConfigButton) configFormLayout.addRow("Template Config File: ", templateConfigPathLayout) fiducialConfigPathLayout = qt.QHBoxLayout() self.fiducialConfigPathEdit = qt.QLineEdit() self.fiducialConfigPathEdit.text = "" self.fiducialConfigPathEdit.readOnly = False self.fiducialConfigPathEdit.frame = True self.fiducialConfigPathEdit.styleSheet = "QLineEdit { background:transparent; }" self.fiducialConfigPathEdit.cursor = qt.QCursor(qt.Qt.IBeamCursor) fiducialConfigPathLayout.addWidget(self.fiducialConfigPathEdit) self.fiducialConfigButton = qt.QPushButton("...") self.fiducialConfigButton.toolTip = "Choose a fiducial configuration file" self.fiducialConfigButton.enabled = True self.fiducialConfigButton.connect('clicked(bool)', self.onFiducialConfigButton) fiducialConfigPathLayout.addWidget(self.fiducialConfigButton) configFormLayout.addRow("Fiducial Config File: ", fiducialConfigPathLayout) # # Main Area # mainCollapsibleButton = ctk.ctkCollapsibleButton() mainCollapsibleButton.text = "Main" self.layout.addWidget(mainCollapsibleButton) # Layout within the dummy collapsible button #mainFormLayout = qt.QFormLayout(mainCollapsibleButton) mainLayout = qt.QVBoxLayout(mainCollapsibleButton) mainFormFrame = qt.QFrame() mainFormLayout = qt.QFormLayout(mainFormFrame) mainLayout.addWidget(mainFormFrame) self.showTemplateCheckBox = qt.QCheckBox() self.showTemplateCheckBox.checked = 0 self.showTemplateCheckBox.setToolTip("Show 3D model of the template") mainFormLayout.addRow("Show Template:", self.showTemplateCheckBox) self.showTemplateCheckBox.connect('toggled(bool)', self.onShowTemplate) self.showFiducialCheckBox = qt.QCheckBox() self.showFiducialCheckBox.checked = 0 self.showFiducialCheckBox.setToolTip("Show 3D model of the fiducial") mainFormLayout.addRow("Show Fiducial:", self.showFiducialCheckBox) self.showFiducialCheckBox.connect('toggled(bool)', self.onShowFiducial) self.showTrajectoriesCheckBox = qt.QCheckBox() self.showTrajectoriesCheckBox.checked = 0 self.showTrajectoriesCheckBox.setToolTip( "Show 3D model of the fiducial") mainFormLayout.addRow("Show Trajectories:", self.showTrajectoriesCheckBox) self.showTrajectoriesCheckBox.connect('toggled(bool)', self.onShowTrajectories) # # input volume selector # self.targetFiducialsSelector = slicer.qMRMLNodeComboBox() self.targetFiducialsSelector.nodeTypes = (( "vtkMRMLMarkupsFiducialNode"), "") self.targetFiducialsSelector.selectNodeUponCreation = True self.targetFiducialsSelector.addEnabled = True self.targetFiducialsSelector.removeEnabled = True self.targetFiducialsSelector.noneEnabled = False self.targetFiducialsSelector.showHidden = False self.targetFiducialsSelector.showChildNodeTypes = False self.targetFiducialsSelector.setMRMLScene(slicer.mrmlScene) self.targetFiducialsSelector.setToolTip("Select Markups for targets") mainFormLayout.addRow("Targets: ", self.targetFiducialsSelector) self.targetFiducialsNode = None self.targetFiducialsSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onFiducialsSelected) # # Target List Table # self.table = qt.QTableWidget(1, 4) self.table.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.table.setSelectionMode(qt.QAbstractItemView.SingleSelection) #self.table.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.headers = ["Name", "Hole", "Depth (mm)", "Position (RAS)"] self.table.setHorizontalHeaderLabels(self.headers) self.table.horizontalHeader().setStretchLastSection(True) mainLayout.addWidget(self.table) self.table.connect('cellClicked(int, int)', self.onTableSelected) self.onFiducialsSelected() ## ## input volume selector ## #self.inputSelector = slicer.qMRMLNodeComboBox() #self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) #self.inputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 ) #self.inputSelector.selectNodeUponCreation = True #self.inputSelector.addEnabled = False #self.inputSelector.removeEnabled = False #self.inputSelector.noneEnabled = False #self.inputSelector.showHidden = False #self.inputSelector.showChildNodeTypes = False #self.inputSelector.setMRMLScene( slicer.mrmlScene ) #self.inputSelector.setToolTip( "Pick the input to the algorithm." ) #mainFormLayout.addRow("Input Volume: ", self.inputSelector) ## ## scale factor for screen shots ## #self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget() #self.screenshotScaleFactorSliderWidget.singleStep = 1.0 #self.screenshotScaleFactorSliderWidget.minimum = 1.0 #self.screenshotScaleFactorSliderWidget.maximum = 50.0 #self.screenshotScaleFactorSliderWidget.value = 1.0 #self.screenshotScaleFactorSliderWidget.setToolTip("Set scale factor for the screen shots.") #mainFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget) ## ## Apply Button ## #self.applyButton = qt.QPushButton("Apply") #self.applyButton.toolTip = "Run the algorithm." #self.applyButton.enabled = False #mainFormLayout.addRow(self.applyButton) # connections #self.applyButton.connect('clicked(bool)', self.onApplyButton) #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #-------------------------------------------------- # # Projection # projectionCollapsibleButton = ctk.ctkCollapsibleButton() projectionCollapsibleButton.text = "Projection" self.layout.addWidget(projectionCollapsibleButton) projectionLayout = qt.QVBoxLayout(projectionCollapsibleButton) projectionCollapsibleButton.collapsed = False self.openWindowButton = qt.QPushButton("OpenWindow") self.openWindowButton.toolTip = "Run the algorithm." self.openWindowButton.enabled = True projectionLayout.addWidget(self.openWindowButton) self.openWindowButton.connect('clicked(bool)', self.onOpenWindowButton) # Add vertical spacer self.layout.addStretch(1) self.ex = None
def createUserInterface(self): ''' ''' self.__layout = self.__parent.createUserInterface() # the anatomical tree anatomicalTreeGroupBox = qt.QGroupBox() anatomicalTreeGroupBox.setTitle('Anatomical Tree') self.__layout.addWidget(anatomicalTreeGroupBox) anatomicalTreeGroupBoxLayout = qt.QFormLayout(anatomicalTreeGroupBox) self.__anatomicalTree = PythonQt.qSlicerEMSegmentModuleWidgets.qSlicerEMSegmentAnatomicalTreeWidget( ) self.__anatomicalTree.structureNameEditable = False self.__anatomicalTree.labelColumnVisible = False self.__anatomicalTree.probabilityMapColumnVisible = False self.__anatomicalTree.classWeightColumnVisible = False self.__anatomicalTree.updateClassWeightColumnVisible = False self.__anatomicalTree.atlasWeightColumnVisible = False self.__anatomicalTree.alphaColumnVisible = False self.__anatomicalTree.displayAlphaCheckBoxVisible = False self.__anatomicalTree.setMinimumHeight(140) self.__anatomicalTree.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.MinimumExpanding) self.__anatomicalTree.connect('currentTreeNodeChanged(vtkMRMLNode*)', self.onTreeSelectionChanged) anatomicalTreeGroupBoxLayout.addWidget(self.__anatomicalTree) self.__tabWidget = qt.QTabWidget() self.__layout.addWidget(self.__tabWidget) # # intensityDistributionPage # intensityDistributionPage = qt.QWidget() intensityDistributionPageLayout = qt.QFormLayout( intensityDistributionPage) self.__classLabel = qt.QLabel("XX") intensityDistributionPageLayout.addRow("Class:", self.__classLabel) self.__specificationComboBox = qt.QComboBox() self.__specificationComboBox.addItems(Helper.GetSpecificationTypes()) #self.__specificationComboBox.model().item( 2 ).setSelectable( False ) #self.__specificationComboBox.model().item( 2 ).setEnabled( False ) intensityDistributionPageLayout.addRow("Specification:", self.__specificationComboBox) self.__specificationComboBox.connect('currentIndexChanged(int)', self.propagateToMRML) self.__meanMatrixWidget = ctk.ctkMatrixWidget() self.__meanMatrixWidget.columnCount = 1 self.__meanMatrixWidget.rowCount = 1 self.__meanMatrixWidget.decimals = 4 self.__meanMatrixWidget.minimum = 0 self.__meanMatrixWidget.maximum = 1000000 intensityDistributionPageLayout.addRow("Mean:", self.__meanMatrixWidget) self.__meanMatrixWidget.connect('matrixChanged()', self.propagateToMRML) self.__logCovarianceMatrixWidget = ctk.ctkMatrixWidget() self.__logCovarianceMatrixWidget.columnCount = 1 self.__logCovarianceMatrixWidget.rowCount = 1 self.__logCovarianceMatrixWidget.decimals = 4 self.__logCovarianceMatrixWidget.minimum = 0 self.__logCovarianceMatrixWidget.maximum = 1000000 intensityDistributionPageLayout.addRow( "Log Covariance:", self.__logCovarianceMatrixWidget) self.__logCovarianceMatrixWidget.connect('matrixChanged()', self.propagateToMRML) self.__resetDistributionButton = qt.QPushButton() self.__resetDistributionButton.text = "Reset Distribution" intensityDistributionPageLayout.addRow(self.__resetDistributionButton) self.__resetDistributionButton.connect('clicked()', self.resetDistribution) # # manualSamplingPage # manualSamplingPage = qt.QWidget() manualSamplingPageLayout = qt.QFormLayout(manualSamplingPage) self.__classLabel2 = qt.QLabel("Class: XX") manualSamplingPageLayout.addWidget(self.__classLabel2) self.__infoLabel = qt.QLabel( "left mouse Click in a slice window to pick a sample") manualSamplingPageLayout.addWidget(self.__infoLabel) self.__manualSampleTable = qt.QTableWidget() manualSamplingPageLayout.addWidget(self.__manualSampleTable) self.__tabWidget.addTab(intensityDistributionPage, "Intensity Distribution") self.__tabWidget.addTab(manualSamplingPage, "Manual Sampling") self.__plotDistributionButton = qt.QPushButton() self.__plotDistributionButton.text = "Plot Distribution" self.__layout.addRow(self.__plotDistributionButton) self.__plotDistributionButton.connect('clicked()', self.plotDistribution)
def setup(self): for cervicalVertebrae in range( 1, self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE + 1): self.verterbraeNames.append("C" + str(cervicalVertebrae)) for thoracicVertebrae in range( 1, self.CONST_NUMBER_OF_THORACIC_VERTERBRAE + 1): self.verterbraeNames.append("T" + str(thoracicVertebrae)) for lumbarVertebrae in range( 1, self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE + 1): self.verterbraeNames.append("L" + str(lumbarVertebrae)) self.superiorAnglesList = [ None ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE self.inferiorAnglesList = [ None ] * self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE * self.CONST_NUMBER_OF_THORACIC_VERTERBRAE * self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE # Instantiate and connect widgets # # Brief Explanation Text instructionsCollapsibleButton = ctk.ctkCollapsibleButton() instructionsCollapsibleButton.text = "Instructions" self.layout.addWidget(instructionsCollapsibleButton) instructionsLayout = qt.QVBoxLayout(instructionsCollapsibleButton) self.namingInstructions = ctk.ctkFittedTextBrowser() self.namingInstructions.setReadOnly(True) self.namingInstructions.setPlainText( "C - Cervical, T - Thoracic, L - Lumbar\ns - Superior, i - Inferior\nName ruler annotations like so: T1-s, T1-i, T2-s, etc." ) instructionsLayout.addWidget(self.namingInstructions) # Input Area parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Input" self.layout.addWidget(parametersCollapsibleButton) # Layout parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # Input Selector self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = (("vtkMRMLAnnotationHierarchyNode"), "") self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = True self.inputSelector.removeEnabled = True self.inputSelector.noneEnabled = False self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Pick the input to the algorithm.") parametersFormLayout.addRow("Input Rulers: ", self.inputSelector) self.projectionPlaneBox = qt.QComboBox() self.projectionPlaneBox.addItems(["Coronal", "Axial", "Sagittal"]) parametersFormLayout.addRow("Projection Plane: ", self.projectionPlaneBox) # # Output Area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" self.layout.addWidget(outputCollapsibleButton) # Layout outputVerticalLayout = qt.QGridLayout(outputCollapsibleButton) # Calculate Button self.calculateButton = qt.QPushButton("Start Calculating") outputVerticalLayout.addWidget(self.calculateButton, 0, 0, 1, 5) # Save Button self.saveButton = qt.QPushButton("Save as CSV") outputVerticalLayout.addWidget(self.saveButton, 1, 0, 1, 5) # Angle Table horizontalHeaders = [ "Vertebrae", "Superior Angles (degrees)", "Inferior Angles (degrees)" ] self.angleTable = qt.QTableWidget( self.CONST_NUMBER_OF_CERVICAL_VERTERBRAE + self.CONST_NUMBER_OF_THORACIC_VERTERBRAE + self.CONST_NUMBER_OF_LUMBAR_VERTERBRAE, 3) self.angleTable.sortingEnabled = False self.angleTable.setEditTriggers(0) self.angleTable.setMinimumHeight( self.angleTable.verticalHeader().length() + 25) self.angleTable.horizontalHeader().setResizeMode( qt.QHeaderView.Stretch) self.angleTable.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) outputVerticalLayout.addWidget(self.angleTable, 2, 0, 1, 5) self.angleTable.setHorizontalHeaderLabels(horizontalHeaders) self.labelReferences = [] self.superiorAngleReferences = [] self.inferiorAngleReferences = [] for verterbraeIndex, verterbraeName in enumerate(self.verterbraeNames): vertebraeLabel = qt.QTableWidgetItem(verterbraeName) self.labelReferences.append(vertebraeLabel) self.angleTable.setItem(verterbraeIndex, 0, vertebraeLabel) superiorAngleItem = qt.QTableWidgetItem("") self.superiorAngleReferences.append(superiorAngleItem) self.angleTable.setItem(verterbraeIndex, 1, superiorAngleItem) inferiorAngleItem = qt.QTableWidgetItem("") self.inferiorAngleReferences.append(inferiorAngleItem) self.angleTable.setItem(verterbraeIndex, 2, inferiorAngleItem) # connections self.calculateButton.connect('clicked(bool)', self.onCalculateButton) self.saveButton.connect('clicked(bool)', self.onSaveButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.layout.addStretch(1)
def __init__(self, logic, applyButton, buttonsList): super(ILSVisualizationWidget, self).__init__() self.logic = logic self.applyButton = applyButton self.fiducialButtonsList = buttonsList self.enableApplyButton = False self.widget = qt.QWidget() self.layout = qt.QFormLayout(self.widget) self.boxHolder = qt.QWidget() self.boxHolder.setLayout(qt.QVBoxLayout()) self.layout.addRow(self.boxHolder) self.groupBox = qt.QFrame() self.groupBox.setLayout(qt.QHBoxLayout()) self.fiducialsCollapsibleButton = ctk.ctkCollapsibleButton() self.fiducialsCollapsibleButton.text = "Show Fiducials" self.fiducialsCollapsibleButton.hide() self.fiducialsFormLayout = qt.QFormLayout( self.fiducialsCollapsibleButton) # Table Widget Definition self.tableWidget = qt.QTableWidget() self.tableWidget.sortingEnabled = False self.tableWidget.hide() self.tableWidget.setColumnCount(3) self.tableWidget.setColumnWidth(0, 190) self.tableWidget.setColumnWidth(1, 190) self.tableWidget.setColumnWidth(2, 190) self.tableWidget.setMaximumWidth(590) horizontalBar = self.tableWidget.horizontalScrollBar() horizontalBar.setDisabled(True) horizontalBar.hide() self.tableWidget.setHorizontalHeaderLabels([ "Left Oblique Fiducials", "Right Oblique Fiducials", "Right Horizontal Fiducials" ]) behavior = qt.QAbstractItemView() self.tableWidget.setSelectionBehavior(behavior.SelectItems) self.tableWidget.setSelectionMode(behavior.SingleSelection) self.tableWidget.setContextMenuPolicy(3) self.tableWidget.customContextMenuRequested.connect(self.onRightClick) self.groupBox.layout().addWidget(self.tableWidget) self.fiducialsFormLayout.addWidget(self.groupBox) self.boxHolder.layout().addWidget(self.fiducialsCollapsibleButton) self.pendingUpdate = False self.updatingFiducials = False self.observerTags = [] self.leftRow = 0 self.rightObliqueRow = 0 self.rightHorizontalRow = 0 self.tableItems = [] self.deletionGroupBox = qt.QFrame() self.deletionGroupBox.setLayout(qt.QHBoxLayout()) self.fiducialsFormLayout.addWidget(self.deletionGroupBox) # # Delete Selected Fiducials Button # self.deleteButton = qt.QPushButton("Delete Selected Fiducial") self.deleteButton.toolTip = "Select a fiducial from the table and push this button to delete the selected fiducial from the scene." self.deleteButton.enabled = True selectedIcon = qt.QIcon(":/Icons/MarkupsDelete.png") self.deleteButton.setIcon(selectedIcon) self.deleteButton.setFixedSize(220, 30) self.deletionGroupBox.layout().addWidget(self.deleteButton) self.deleteButton.connect('clicked(bool)', self.onDeleteOneFiducialButton) # # Delete All Fiducials Button # self.deleteAllButton = qt.QPushButton("Delete All Fiducials") self.deleteAllButton.toolTip = "Delete all fiducials in the scene." self.deleteAllButton.enabled = True allIcon = qt.QIcon(":/Icons/MarkupsDeleteAllRows.png") self.deleteAllButton.setIcon(allIcon) self.deleteAllButton.setFixedSize(220, 30) self.deletionGroupBox.layout().addWidget(self.deleteAllButton) #self.fiducialsFormLayout.addRow(self.deleteAllButton) self.deleteAllButton.connect('clicked(bool)', self.dialogBoxFunction)
def __init__(self, parent): self.widget = qt.QTableWidget(parent, width=350, height=300) self.items = [] self.setHeader(None)
def createUserInterface(self): markup = slicer.modules.markups.logic() markup.AddNewFiducialNode() self.__layout = self.__parent.createUserInterface() self.startMeasurements = slicer.qSlicerMarkupsPlaceWidget() self.startMeasurements.setButtonsVisible(False) self.startMeasurements.placeButton().show() self.startMeasurements.setMRMLScene(slicer.mrmlScene) self.startMeasurements.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceMultipleMarkups self.startMeasurements.connect( 'activeMarkupsFiducialPlaceModeChanged(bool)', self.addFiducials) # 加个调节和cross显示选择 self.adjustFiducials = qt.QPushButton("Adjust Landmarks") self.adjustFiducials.connect('clicked(bool)', self.makeFidAdjustments) self.crosshair = qt.QPushButton("Hide Crosshair") self.crosshair.connect('clicked(bool)', self.crosshairVisible) buttonLayout = qt.QHBoxLayout() buttonLayout.addWidget(self.startMeasurements) self.__layout.addRow(buttonLayout) buttonLayout2 = qt.QHBoxLayout() buttonLayout2.addWidget(self.adjustFiducials) buttonLayout2.addWidget(self.crosshair) self.__layout.addRow(buttonLayout2) self.table2 = qt.QTableWidget() self.table2.setRowCount(1) self.table2.setColumnCount(2) self.table2.horizontalHeader().setSectionResizeMode( qt.QHeaderView.Stretch) self.table2.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.Preferred) self.table2.setMinimumWidth(400) self.table2.setMinimumHeight(215) self.table2.setMaximumHeight(215) horizontalHeaders = ["Fiducial", "Level\Side\Landmarks"] self.table2.setHorizontalHeaderLabels(horizontalHeaders) self.table2.itemSelectionChanged.connect(self.onTableCellClicked) self.__layout.addWidget(self.table2) self.deleteFid = qt.QPushButton("Remove Selected Fiducial") self.deleteFid.connect('clicked(bool)', self.deleteFiducial) self.__layout.addWidget(self.deleteFid) self.oldPosition = 0 # 就是在这里加个位置选择选择 aText = qt.QLabel("Camera:") self.aSelector = qt.QComboBox() # self.aSelector.setMaximumWidth(120) self.aSelector.addItems(["Posterior", "Anterior", "Right", "Left"]) self.__layout.addRow(aText) self.__layout.addRow(self.aSelector) reconCollapsibleButton = ctk.ctkCollapsibleButton() reconCollapsibleButton.text = "Change Slice Reconstruction" self.__layout.addWidget(reconCollapsibleButton) reconCollapsibleButton.collapsed = True # Layout reconLayout = qt.QFormLayout(reconCollapsibleButton) # label for ROI selector reconLabel = qt.QLabel('Recon Slice:') rotationLabel = qt.QLabel('Rotation Angle:') # creates combobox and populates it with all vtkMRMLAnnotationROINodes # in the scene self.selector = slicer.qMRMLNodeComboBox() self.selector.nodeTypes = ['vtkMRMLSliceNode'] self.selector.toolTip = "Change Slice Reconstruction" self.selector.setMRMLScene(slicer.mrmlScene) self.selector.addEnabled = 1 # add label + combobox reconLayout.addRow(reconLabel, self.selector) self.slider = ctk.ctkSliderWidget() self.slider.connect('valueChanged(double)', self.sliderValueChanged) self.slider.minimum = -100 self.slider.maximum = 100 reconLayout.addRow(rotationLabel, self.slider) qt.QTimer.singleShot(0, self.killButton)