def __init__(self, parent = None, name = "task_toolbox"): qt.QWidget.__init__(self, parent, name) # Data atributes self.shape_history = None self.tree_brick = None self.previous_page_index = 0 #Layout self.v_layout = qt.QVBoxLayout(self) self.v_layout.setSpacing(10) self.method_group_box = qt.QVGroupBox("Collection method", self) font = self.method_group_box.font() font.setPointSize(12) self.method_group_box.setFont(font) self.tool_box = qt.QToolBox(self.method_group_box , "tool_box") self.tool_box.setFixedWidth(475) font = self.tool_box.font() font.setPointSize(10) self.tool_box.setFont(font) self.discrete_page = CreateDiscreteWidget(self.tool_box, "Discrete",) self.discrete_page.setBackgroundMode(qt.QWidget.PaletteBackground) self.char_page = CreateCharWidget(self.tool_box, "Characterise") self.char_page.setBackgroundMode(qt.QWidget.PaletteBackground) self.helical_page = CreateHelicalWidget(self.tool_box, "helical_page") self.helical_page.setBackgroundMode(qt.QWidget.PaletteBackground) self.energy_scan_page = CreateEnergyScanWidget(self.tool_box, "energy_scan") self.xrf_scan_page = CreateXRFScanWidget(self.tool_box, "xrf_scan") self.workflow_page = CreateWorkflowWidget(self.tool_box, 'workflow') self.tool_box.addItem(self.discrete_page, "Standard Collection") self.tool_box.addItem(self.char_page, "Characterisation") self.tool_box.addItem(self.helical_page, "Helical Collection") self.tool_box.addItem(self.energy_scan_page, "Energy Scan") self.tool_box.addItem(self.xrf_scan_page, "XRF Scan") self.tool_box.addItem(self.workflow_page, "Advanced") self.add_pixmap = Icons.load("add_row.png") self.create_task_button = qt.QPushButton(" Add to queue", self) self.create_task_button.setIconSet(qt.QIconSet(self.add_pixmap)) msg = "Add the collection method to the selected sample" qt.QToolTip.add(self.create_task_button, msg) self.v_layout.addWidget(self.method_group_box) self.button_hlayout = qt.QHBoxLayout(None) self.spacer = qt.QSpacerItem(1, 20, qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum) self.button_hlayout.addItem(self.spacer) self.button_hlayout.addWidget(self.create_task_button) self.method_group_box.layout().setSpacing(10) self.method_group_box.layout().addLayout(self.button_hlayout) qt.QObject.connect(self.create_task_button, qt.SIGNAL("clicked()"), self.create_task_button_click) qt.QObject.connect(self.tool_box, qt.SIGNAL("currentChanged( int )"), self.current_page_changed)
def __init__(self, *args, **kwargs): qt.QWidget.__init__(self, *args) self.setCaption("Toolbox") self.bricksTab = {} self.bricks = {} topPanel = qt.QFrame(self) self.cmdRefresh = qt.QToolButton(topPanel) self.cmdRefresh.setIconSet(qt.QIconSet(Icons.load("reload"))) qt.QToolTip.add(self.cmdRefresh, "refresh bricks list") qt.QHBoxLayout(topPanel) topPanel.layout().addWidget(qt.QLabel("Available bricks", topPanel), 0, qt.Qt.AlignLeft) topPanel.layout().addWidget(self.cmdRefresh, 0, qt.Qt.AlignRight) qt.QObject.connect(self.cmdRefresh, qt.SIGNAL("clicked()"), self.refresh) self.bricksToolbox = qt.QToolBox(self) qt.QVBoxLayout(self, 5, 5) self.layout().addWidget(topPanel) self.layout().addWidget(self.bricksToolbox)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... self.pbucLogic = PointerBasedUSCalibrationLogic() # Have reference to an instance of the logic # # Tracked ultrasound playback toolbox # self.playToolBox = qt.QToolBox() self.layout.addWidget( self.playToolBox ) # # Real-time playback # self.realTimeFrame = qt.QFrame( self.playToolBox ) self.realTimeLayout = qt.QVBoxLayout( self.realTimeFrame ) self.connectorNodeSelector = slicer.qMRMLNodeComboBox() self.connectorNodeSelector.nodeTypes = [ "vtkMRMLIGTLConnectorNode" ] self.connectorNodeSelector.addEnabled = False self.connectorNodeSelector.removeEnabled = False self.connectorNodeSelector.noneEnabled = False self.connectorNodeSelector.showHidden = False self.connectorNodeSelector.showChildNodeTypes = False self.connectorNodeSelector.setMRMLScene( slicer.mrmlScene ) self.connectorNodeSelector.setToolTip( "Select the connector node for playback." ) self.realTimeLayout.addWidget( self.connectorNodeSelector ) self.freezeButton = qt.QPushButton( "Freeze" ) self.freezeButton.setToolTip( "Freeze the connection." ) self.realTimeLayout.addWidget( self.freezeButton ) # # Recorded sequence playback # self.sequenceFrame = qt.QFrame( self.playToolBox ) self.sequenceLayout = qt.QVBoxLayout( self.sequenceFrame ) self.sequenceBrowserNodeSelector = slicer.qMRMLNodeComboBox() self.sequenceBrowserNodeSelector.nodeTypes = [ "vtkMRMLSequenceBrowserNode" ] self.sequenceBrowserNodeSelector.addEnabled = False self.sequenceBrowserNodeSelector.removeEnabled = False self.sequenceBrowserNodeSelector.noneEnabled = False self.sequenceBrowserNodeSelector.showHidden = False self.sequenceBrowserNodeSelector.showChildNodeTypes = False self.sequenceBrowserNodeSelector.setMRMLScene( slicer.mrmlScene ) self.sequenceBrowserNodeSelector.setToolTip( "Select the sequence browser node for playback." ) self.sequenceLayout.addWidget( self.sequenceBrowserNodeSelector ) self.sequenceBrowserPlayWidget = slicer.qMRMLSequenceBrowserPlayWidget() # TODO: Somehow disable the recording button without changing sequences' recording states self.sequenceBrowserPlayWidget.setMRMLSequenceBrowserNode( self.sequenceBrowserNodeSelector.currentNode() ) self.sequenceLayout.addWidget( self.sequenceBrowserPlayWidget ) self.sequenceBrowserSeekWidget = slicer.qMRMLSequenceBrowserSeekWidget() self.sequenceBrowserSeekWidget.setMRMLSequenceBrowserNode( self.sequenceBrowserNodeSelector.currentNode() ) self.sequenceLayout.addWidget( self.sequenceBrowserSeekWidget ) # Add the playback modes to the tool box self.playToolBox.addItem( self.realTimeFrame, "Real-time" ) self.playToolBox.addItem( self.sequenceFrame, "Sequence" ) # # Points group box # self.pointGroupBox = qt.QGroupBox() self.pointGroupBox.setTitle( "Points" ) self.layout.addWidget( self.pointGroupBox ) # Layout within the group box self.pointGroupBoxLayout = qt.QHBoxLayout( self.pointGroupBox ) # Mark point self.markPointButton = qt.QPushButton( "Mark Point" ) self.markPointButton.setIcon( qt.QIcon( ":/Icons/MarkupsMouseModePlace.png" ) ) self.markPointButton.setToolTip( "Start placing a point on the ultrasound image." ) self.pointGroupBoxLayout.addWidget( self.markPointButton ) # Undo self.undoPointsButton = qt.QPushButton( "" ) self.undoPointsButton.setIcon( qt.QIcon( ":/Icons/Small/SlicerUndo.png" ) ) self.undoPointsButton.setSizePolicy( qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed ) self.undoPointsButton.setToolTip( "Remove the most recently placed point." ) self.pointGroupBoxLayout.addWidget( self.undoPointsButton ) # Reset self.resetPointsButton = qt.QPushButton( "" ) self.resetPointsButton.setIcon( qt.QApplication.style().standardIcon( qt.QStyle.SP_DialogResetButton ) ) self.resetPointsButton.setSizePolicy( qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed ) self.resetPointsButton.setToolTip( "Clear all points." ) self.pointGroupBoxLayout.addWidget( self.resetPointsButton ) # # Result label # self.calibrationResultLabel = qt.QLabel() self.calibrationResultLabel.setText( "No calibration parameters selected." ) self.calibrationResultLabel.setToolTip( "Output from the calibration." ) self.layout.addWidget( self.calibrationResultLabel ) # # Advanced area # self.advancedCollapsibleButton = ctk.ctkCollapsibleButton() self.advancedCollapsibleButton.setText( "Advanced" ) self.advancedCollapsibleButton.collapsed = True self.layout.addWidget( self.advancedCollapsibleButton ) # Layout within the collapsible button self.advancedLayout = qt.QFormLayout( self.advancedCollapsibleButton ) # Mark point self.applyButton = qt.QPushButton( "Apply" ) self.applyButton.setToolTip( "Apply the ImageToProbe transform to the ultrasound image." ) self.advancedLayout.addWidget( self.applyButton ) # # Results area # self.resultsCollapsibleButton = ctk.ctkCollapsibleButton() self.resultsCollapsibleButton.setText( "Results" ) self.resultsCollapsibleButton.collapsed = True self.advancedLayout.addWidget( self.resultsCollapsibleButton ) # Layout within the collapsible button self.resultsLayout = qt.QFormLayout( self.resultsCollapsibleButton ) # Results table self.resultsTable = qt.QTableWidget( self.resultsCollapsibleButton ) self.resultsTable.setColumnCount( self.RESULTS_NUM_INDICES ) self.resultsTable.setHorizontalHeaderLabels( [ "Image Points", "Probe Points", "Error", "Delete" ] ) self.resultsTable.horizontalHeader().setResizeMode( qt.QHeaderView.Stretch ) self.resultsTable.horizontalHeader().setResizeMode( self.RESULTS_DELETE_INDEX, qt.QHeaderView.Fixed ) self.resultsLayout.addRow( self.resultsTable ) # # Parameters area # self.parametersCollapsibleButton = ctk.ctkCollapsibleButton() self.parametersCollapsibleButton.setText( "Parameters" ) self.parametersCollapsibleButton.collapsed = True self.advancedLayout.addWidget( self.parametersCollapsibleButton ) # Layout within the collapsible button self.parametersLayout = qt.QVBoxLayout( self.parametersCollapsibleButton ) # Parameters node self.frwNodeSelector = slicer.qMRMLNodeComboBox() self.frwNodeSelector.nodeTypes = [ "vtkMRMLFiducialRegistrationWizardNode" ] self.frwNodeSelector.addEnabled = True self.frwNodeSelector.removeEnabled = True self.frwNodeSelector.noneEnabled = False self.frwNodeSelector.showHidden = False self.frwNodeSelector.showChildNodeTypes = False self.frwNodeSelector.baseName = "UltrasoundCalibration" self.frwNodeSelector.setMRMLScene( slicer.mrmlScene ) self.frwNodeSelector.setToolTip( "Select the ultrasound calibration parameters node." ) self.parametersLayout.addWidget( self.frwNodeSelector ) # # Input group box # self.inputGroupBox = qt.QGroupBox( self.parametersCollapsibleButton ) self.inputGroupBox.setTitle( "Input" ) self.parametersLayout.addWidget( self.inputGroupBox ) # Layout within the group box self.inputGroupBoxLayout = qt.QFormLayout( self.inputGroupBox ) # US image selector self.usImageNodeSelector = slicer.qMRMLNodeComboBox() self.usImageNodeSelector.nodeTypes = [ "vtkMRMLVolumeNode" ] self.usImageNodeSelector.addEnabled = False self.usImageNodeSelector.removeEnabled = False self.usImageNodeSelector.noneEnabled = True self.usImageNodeSelector.showHidden = False self.usImageNodeSelector.showChildNodeTypes = True self.usImageNodeSelector.setMRMLScene( slicer.mrmlScene ) self.usImageNodeSelector.setToolTip( "Select the ultrasound image node." ) self.inputGroupBoxLayout.addRow( "Ultrasound image ", self.usImageNodeSelector ) # StylusTipToProbe selector self.stylusTipToProbeNodeSelector = slicer.qMRMLNodeComboBox() self.stylusTipToProbeNodeSelector.nodeTypes = [ "vtkMRMLLinearTransformNode" ] self.stylusTipToProbeNodeSelector.addEnabled = False self.stylusTipToProbeNodeSelector.removeEnabled = False self.stylusTipToProbeNodeSelector.noneEnabled = True self.stylusTipToProbeNodeSelector.showHidden = False self.stylusTipToProbeNodeSelector.showChildNodeTypes = True self.stylusTipToProbeNodeSelector.setMRMLScene( slicer.mrmlScene ) self.stylusTipToProbeNodeSelector.setToolTip( "Select the StylusTipToProbe node (parent transforms will be applied)." ) self.inputGroupBoxLayout.addRow( "StylusTipToProbe ", self.stylusTipToProbeNodeSelector ) # # Output group box # self.outputGroupBox = qt.QGroupBox( self.parametersCollapsibleButton ) self.outputGroupBox.setTitle( "Output" ) self.parametersLayout.addWidget( self.outputGroupBox ) # Layout within the group box self.outputGroupBoxLayout = qt.QFormLayout( self.outputGroupBox ) # ImageToProbe selector self.imageToProbeNodeSelector = slicer.qMRMLNodeComboBox() self.imageToProbeNodeSelector.nodeTypes = [ "vtkMRMLLinearTransformNode" ] self.imageToProbeNodeSelector.addEnabled = True self.imageToProbeNodeSelector.removeEnabled = False self.imageToProbeNodeSelector.noneEnabled = True self.imageToProbeNodeSelector.renameEnabled = True self.imageToProbeNodeSelector.showHidden = False self.imageToProbeNodeSelector.showChildNodeTypes = True self.imageToProbeNodeSelector.setMRMLScene( slicer.mrmlScene ) self.imageToProbeNodeSelector.setToolTip( "Select the ImageToProbe output node (stores the result of the calibration)." ) self.outputGroupBoxLayout.addRow( "ImageToProbe ", self.imageToProbeNodeSelector ) # # Set up connections # self.freezeButton.connect( "clicked(bool)", self.onFreezeButtonClicked ) self.sequenceBrowserNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onSequenceBrowserNodeChanged ) self.frwNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onCalibrationNodeChanged ) self.usImageNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onUSImageNodeChanged ) self.stylusTipToProbeNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onStylusTipToProbeNodeChanged ) self.markPointButton.connect( "clicked(bool)", self.onMarkPointButtonClicked ) self.undoPointsButton.connect( "clicked(bool)", self.onUndoPointsButtonClicked ) self.resetPointsButton.connect( "clicked(bool)", self.onResetPointsButtonClicked ) self.imageToProbeNodeSelector.connect( "currentNodeChanged(vtkMRMLNode*)", self.onImageToProbeNodeChanged ) self.applyButton.connect( "clicked(bool)", self.onApplyOutputTransformToImageClicked ) # # Create a parameters node by default # defaultFRWNode = slicer.vtkMRMLFiducialRegistrationWizardNode() defaultFRWNode.SetName( "UltrasoundCalibration" ) defaultFRWNode.SetScene( slicer.mrmlScene ) slicer.mrmlScene.AddNode( defaultFRWNode ) self.frwNodeSelector.setCurrentNodeID( defaultFRWNode.GetID() ) # Add vertical spacer self.layout.addStretch(1)