Exemple #1
0
def delayDisplay(message, autoCloseMsec=1000):
    """Display an information message in a popup window for a short time.
  If autoCloseMsec>0 then the window is closed after waiting for autoCloseMsec milliseconds
  If autoCloseMsec=0 then the window is not closed until the user clicks on it.
  """
    import qt, slicer
    import logging
    logging.info(message)
    messagePopup = qt.QDialog()
    layout = qt.QVBoxLayout()
    messagePopup.setLayout(layout)
    label = qt.QLabel(message, messagePopup)
    layout.addWidget(label)
    if autoCloseMsec > 0:
        qt.QTimer.singleShot(autoCloseMsec, messagePopup.close)
    else:
        okButton = qt.QPushButton("OK")
        layout.addWidget(okButton)
        okButton.connect('clicked()', messagePopup.close)
    messagePopup.exec_()
Exemple #2
0
    def __init__(self, parent=None, showVolumesFrame=True):
        VTKObservationMixin.__init__(self)
        self.shortcuts = []
        self.toolsBox = None

        # set attributes from ctor parameters
        self.showVolumesFrame = showVolumesFrame

        self.editUtil = EditUtil()  # Kept for backward compatibility

        if not parent:
            self.parent = slicer.qMRMLWidget()
            self.parent.setLayout(qt.QVBoxLayout())
            self.parent.setMRMLScene(slicer.mrmlScene)
            self.layout = self.parent.layout()
        else:
            self.parent = parent
            self.layout = parent.layout()

        ScriptedLoadableModuleWidget.__init__(self, parent)
  def __init__(self, parent = None):
    if not parent:
      self.parent = qt.QWidget()
      self.parent.setLayout(qt.QVBoxLayout())

    else:
      self.parent = parent

    self.layout = self.parent.layout()

    if not parent:
      self.setup()
      self.parent.show()

    self.extensionProject = None
    self.extensionDescription = None
    self.extensionLocation = None

    self.templateManager = None
    self.setupTemplates()
    def __init__(self, parent=None):

        self.labelMapNode = None

        self.goalSegmentation = None

        self.inputNode1 = None
        self.inputNode2 = None
        self.inputNode3 = None
        self.outputNode = None
        self.goalButtonTexts = ["Jagged", "Intermediate", "Smooth", "Custom"]
        self.goalButtonDefault = 2
        self.goalButtonUserDefined = 3
        self.precomputedErosionRadii = [1, 3,
                                        5]  #->> TODO do actual computation
        self.precomputedHoleFillIterations = [
            2, 4, 6
        ]  #->> TODO do actual computation

        self.erosionRadius = 0
        self.holeFillIterations = 0

        self.CLINode = None

        self.editorEffects = [
            "DefaultTool", "EraseLabel", "Paint", "Threshold"
        ]
        self.editorWidget = None

        self.labelMapNodeSelector = None
        self.voidLabelSpinBox = None
        ##    self.labelsColorNode = None

        if not parent:
            self.parent = qt.QFrame()
            self.parent.setLayout(qt.QVBoxLayout())
            self.layout = self.parent.layout()
            self.parent.show()
        else:
            self.parent = parent
            self.layout = parent.layout()
    def __init__(self, parent, node):
        BaseNodeWidget.__init__(self, parent, node)

        mainsplitter = qt.QSplitter(qt.QSplitter.Vertical, self)
        orderslistview = OrderSupervisorList(mainsplitter, node)
        tabssplitter = qt.QSplitter(qt.QSplitter.Horizontal, mainsplitter)

        ordertabs = qt.QTabWidget(tabssplitter)
        ordertab = OrderTab(ordertabs, {})
        ordertabs.insertTab(ordertab, "Order")

        reporttab = ReportTab(ordertabs, [])
        ordertabs.insertTab(reporttab, "Report")

        messagestab = MessagesTab(ordertabs, {})
        ordertabs.insertTab(messagestab, "Messages")

        contracttabs = qt.QTabWidget(tabssplitter)
        contracttab = ContractTab(contracttabs, {})
        contracttabs.insertTab(contracttab, "Contract")

        layout = qt.QVBoxLayout(self)
        layout.addWidget(mainsplitter)

        for widget in (
                ordertabs,
                tabssplitter,
                contracttabs,
        ):
            widget.setMargin(0)

        for widget in (ordertab, contracttab, messagestab, reporttab):
            self.connect(orderslistview, util.sigSelectChanged,
                         widget.displayOrderItem)
            self.connect(orderslistview, util.sigOrdersUpdated,
                         widget.displayOrderItem)

        firstitem = orderslistview.firstChild()
        if firstitem:
            orderslistview.setSelected(firstitem, True)
        link.connect(orderslistview)
Exemple #6
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # This module is often used in developer mode, therefore
        # collapse reload & test section by default.
        if hasattr(self, "reloadCollapsibleButton"):
            self.reloadCollapsibleButton.collapsed = True

        self.logic = SelfTestsLogic(slicer.selfTests)

        globals()['selfTests'] = self

        #
        # test list
        #

        self.testList = ctk.ctkCollapsibleButton(self.parent)
        self.testList.setLayout(qt.QVBoxLayout())
        self.testList.setText("Self Tests")
        self.layout.addWidget(self.testList)
        self.testList.collapsed = False

        self.runAll = qt.QPushButton("Run All")
        self.testList.layout().addWidget(self.runAll)
        self.runAll.connect('clicked()', self.onRunAll)

        self.testButtons = {}
        self.testMapper = qt.QSignalMapper()
        self.testMapper.connect('mapped(const QString&)', self.onRun)
        testKeys = slicer.selfTests.keys()
        testKeys.sort()
        for test in testKeys:
            self.testButtons[test] = qt.QPushButton(test)
            self.testButtons[test].setToolTip(slicer.selfTests[test].__doc__)
            self.testList.layout().addWidget(self.testButtons[test])
            self.testMapper.setMapping(self.testButtons[test], test)
            self.testButtons[test].connect('clicked()', self.testMapper,
                                           'map()')

        # Add spacer to layout
        self.layout.addStretch(1)
Exemple #7
0
    def __init__(self,
                 parent=None,
                 width=400,
                 height=400,
                 showWidget=False,
                 scale=False):
        super(LayerReveal, self).__init__()
        self.width = width
        self.height = height
        self.showWidget = showWidget
        self.scale = scale
        self.renderer = None

        # utility Qt instances for use in methods
        self.gray = qt.QColor()
        self.gray.setRedF(0.5)
        self.gray.setGreenF(0.5)
        self.gray.setBlueF(0.5)
        # a painter to use for various jobs
        self.painter = qt.QPainter()

        # make a qwidget display
        if self.showWidget:
            self.frame = qt.QFrame(parent)
            mw = slicer.util.mainWindow()
            self.frame.setGeometry(mw.x, mw.y, self.width, self.height)
            self.frameLayout = qt.QVBoxLayout(self.frame)
            self.label = qt.QLabel()
            self.frameLayout.addWidget(self.label)
            self.frame.show()

        # make an image actor in the slice view
        self.vtkImage = vtk.vtkImageData()

        self.mrmlUtils = slicer.qMRMLUtils()
        self.imageMapper = vtk.vtkImageMapper()
        self.imageMapper.SetColorLevel(128)
        self.imageMapper.SetColorWindow(255)
        self.imageMapper.SetInputData(self.vtkImage)
        self.actor2D = vtk.vtkActor2D()
        self.actor2D.SetMapper(self.imageMapper)
Exemple #8
0
    def setup(self):
        super(SliceTrackerManualSegmentationPlugin, self).setup()

        self.surfaceCutGroupBox = qt.QWidget()
        self.surfaceCutGroupBox.setLayout(qt.QVBoxLayout())
        self.surfaceCutToLabelWidget = SurfaceCutToLabelWidget(
            self.surfaceCutGroupBox)
        self.surfaceCutToLabelWidget.setup()
        self.surfaceCutToLabelWidget.selectorsGroupBoxVisible = False
        self.surfaceCutToLabelWidget.colorGroupBoxVisible = False

        if str(self.getSetting('DeveloperMode',
                               'Developer')).lower() == 'true':
            self.surfaceCutToLabelWidget.reloadCollapsibleButton.hide()

        self.segmentationGroupBox = qt.QGroupBox("SurfaceCut Segmentation")
        self.segmentationGroupBoxLayout = qt.QGridLayout()
        self.segmentationGroupBox.setLayout(self.segmentationGroupBoxLayout)
        self.segmentationGroupBoxLayout.addWidget(self.surfaceCutGroupBox, 0,
                                                  0)
        self.layout().addWidget(self.segmentationGroupBox)
Exemple #9
0
    def __init__(self, *args, **kwargs):
        qt.QWidget.__init__(self, *args)

        self.setCaption("Hardware Repository browser")
        
        tb = qt.QHBox(self)
        self.cmdRefresh = qt.QToolButton(tb)
        self.cmdRefresh.setIconSet(qt.QIconSet(Icons.load("reload")))
        qt.QToolTip.add(self.cmdRefresh, "refresh HWR objects tree")
        self.cmdClose = qt.QToolButton(tb)
        self.cmdClose.setIconSet(qt.QIconSet(Icons.load("button_cancel")))
        qt.QToolTip.add(self.cmdClose, "close HWR browser")
        HorizontalSpacer(tb)
        tb.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)

        qt.QObject.connect(self.cmdRefresh, qt.SIGNAL("clicked()"), self.refresh)
        qt.QObject.connect(self.cmdClose, qt.SIGNAL("clicked()"), self.close)

        qt.QVBoxLayout(self)
        self.layout().addWidget(tb)
        self.add_hwr_browser()
Exemple #10
0
    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 __init__(self, parent):
    self.vLayout = qt.QVBoxLayout(parent)
    self.formLayout = qt.QFormLayout()

    self.componentName = qt.QLineEdit()
    self.formLayout.addRow("Name:", self.componentName)

    self.componentType = qt.QComboBox()
    self.formLayout.addRow("Type:", self.componentType)

    self.destination = ctk.ctkPathLineEdit()
    self.destination.filters = ctk.ctkPathLineEdit.Dirs
    self.formLayout.addRow("Destination:", self.destination)

    self.vLayout.addLayout(self.formLayout)
    self.vLayout.addStretch(1)

    self.buttonBox = qt.QDialogButtonBox()
    self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok |
                                      qt.QDialogButtonBox.Cancel)
    self.vLayout.addWidget(self.buttonBox)
    def confirmationPopup(self, message, autoCloseMsec=1000):
        """Display an information message in a popup window for a short time.
        If autoCloseMsec>0 then the window is closed after waiting for autoCloseMsec milliseconds
        If autoCloseMsec=0 then the window is not closed until the user clicks on it.
        """
        messagePopup = qt.QDialog()
        layout = qt.QVBoxLayout()
        messagePopup.setLayout(layout)
        label = qt.QLabel(message, messagePopup)
        layout.addWidget(label)

        okButton = qt.QPushButton("Submit")
        layout.addWidget(okButton)
        okButton.connect('clicked()', self.onAgreeButton)
        okButton.connect('clicked()', messagePopup.close)

        stopButton = qt.QPushButton("Stop")
        layout.addWidget(stopButton)
        stopButton.connect('clicked()', messagePopup.close)

        messagePopup.exec_()
    def buildMiscPage(self, config, frame):
        """ buildMiscPage(...) -> construct widgets for the misc settings

        """
        colortickers = config.readBoolEntry(keys.colorTickers,
                                            defaults.colorTickers)

        label = i18n('Use colors when painting tickers list')
        color_check = qt.QCheckBox(label, frame)
        color_check.setChecked(colortickers)

        layout = qt.QVBoxLayout(frame, gridMargin, gridSpace)
        layout.addStretch(1)
        layout.addWidget(color_check)
        layout.addStretch(10)

        self.setConfigWidget(
            frame, (keys.colorTickers, color_check, defaults.colorTickers,
                    color_check.isChecked, color_check.setChecked))

        self.connectChanged((color_check, util.sigStateChanged))
Exemple #14
0
    def __init__(self, *args, **kwargs):
        if kwargs.get('noBorder', False):
            _args = [None, "", qt.Qt.WStyle_Customize | qt.Qt.WStyle_Splash]
            for i in range(len(args)):
                _args[i] = args[i]
            qt.QScrollView.__init__(self, *_args)
        else:
            qt.QScrollView.__init__(self, *args)

        self.additionalWindows = {}
        self.__putBackColors = None
        self.executionMode = kwargs.get('executionMode', False)
        self.previewItems = {}
        self.currentWindow = None

        self.setCaption("GUI preview")
        self.setResizePolicy(qt.QScrollView.AutoOneFit)

        self.centralWidget = qt.QWidget(self.viewport())
        self.addChild(self.centralWidget)
        qt.QVBoxLayout(self.centralWidget)
Exemple #15
0
 def __init__(self, parent = None):
   """If parent widget is not specified: a top-level widget is created automatically;
   the application has to delete this widget (by calling widget.parent.deleteLater() to avoid memory leaks.
   """
   # Get module name by stripping 'Widget' from the class name
   self.moduleName = self.__class__.__name__
   if self.moduleName.endswith('Widget'):
     self.moduleName = self.moduleName[:-6]
   self.developerMode = slicer.util.settingsValue('Developer/DeveloperMode', False, converter=slicer.util.toBool)
   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()
   if not parent:
     self.setup()
     self.parent.show()
   slicer.app.moduleManager().connect(
     'moduleAboutToBeUnloaded(QString)', self._onModuleAboutToBeUnloaded)
Exemple #16
0
 def __init__(self,*args) :
     BlissWidget.__init__(self,*args)
     self.__pid = -1
     self.__cmd = None
     self.__userHost = None
     self.__stringFont = None
     self.__startIdle = qt.QTimer(self)
     qt.QObject.connect(self.__startIdle,qt.SIGNAL('timeout()'),self.__idleRun)
     
     self.__container = qttools.QtXEmbedContainer(self)
     qt.QObject.connect(self.__container, qt.SIGNAL('clientClosed()'), self.run)
     layout = qt.QVBoxLayout(self)
     layout.addWidget(self.__container)
     self.__container.setSizePolicy(qt.QSizePolicy.Expanding,qt.QSizePolicy.Expanding)
     self.__container.setSizeIncrement(1,12)
     qt.QObject.connect(qt.qApp,qt.SIGNAL('aboutToQuit()'),self.__killTerm)
     
                    ####### PROPERTY #######
     self.addProperty("command", "string", "")
     self.addProperty("users@host","string","")
     self.addProperty('font','string','')
  def setupOptionsFrame(self):

    operationLayout = qt.QVBoxLayout()

    self.insideSurfaceOptionRadioButton = qt.QRadioButton("inside surface")
    self.medialSurfaceOptionRadioButton = qt.QRadioButton("medial surface")
    self.outsideSurfaceOptionRadioButton = qt.QRadioButton("outside surface")
    operationLayout.addWidget(self.insideSurfaceOptionRadioButton)
    operationLayout.addWidget(self.medialSurfaceOptionRadioButton)
    operationLayout.addWidget(self.outsideSurfaceOptionRadioButton)
    self.insideSurfaceOptionRadioButton.setChecked(True)

    self.scriptedEffect.addLabeledOptionsWidget("Use current segment as:", operationLayout)

    self.shellThicknessMmSpinBox = slicer.qMRMLSpinBox()
    self.shellThicknessMmSpinBox.setMRMLScene(slicer.mrmlScene)
    self.shellThicknessMmSpinBox.setToolTip("Thickness of the hollow shell.")
    self.shellThicknessMmSpinBox.quantity = "length"
    self.shellThicknessMmSpinBox.minimum = 0.0
    self.shellThicknessMmSpinBox.value = 3.0
    self.shellThicknessMmSpinBox.singleStep = 1.0

    self.kernelSizePixel = qt.QLabel()
    self.kernelSizePixel.setToolTip("Thickness in pixels. Computed from the segment's spacing and the specified margin size.")

    shellThicknessFrame = qt.QHBoxLayout()
    shellThicknessFrame.addWidget(self.shellThicknessMmSpinBox)
    shellThicknessFrame.addWidget(self.kernelSizePixel)
    self.shellThicknessMmLabel = self.scriptedEffect.addLabeledOptionsWidget("Shell thickness:", shellThicknessFrame)

    self.applyButton = qt.QPushButton("Apply")
    self.applyButton.objectName = self.__class__.__name__ + 'Apply'
    self.applyButton.setToolTip("Makes the segment hollow by replacing it with a thick shell at the segment boundary.")
    self.scriptedEffect.addOptionsWidget(self.applyButton)

    self.applyButton.connect('clicked()', self.onApply)
    self.shellThicknessMmSpinBox.connect("valueChanged(double)", self.updateMRMLFromGUI)
    self.insideSurfaceOptionRadioButton.connect("toggled(bool)", self.insideSurfaceModeToggled)
    self.medialSurfaceOptionRadioButton.connect("toggled(bool)", self.medialSurfaceModeToggled)
    self.outsideSurfaceOptionRadioButton.connect("toggled(bool)", self.outsideSurfaceModeToggled)
Exemple #18
0
    def dialogBoxFunction(self):
        self.deleteAllMsgBox = qt.QDialog(slicer.util.mainWindow())
        # self.deleteAllMsgBox.setWindowTitle("Delete All Fiducials?")
        self.deleteAllMsgBox.setFixedSize(200, 100)
        self.deleteAllMsgBox.show()
        self.deleteAllMsgBox.setLayout(qt.QVBoxLayout())

        messageLabel = qt.QLabel("Delete All Fiducials?")
        font = qt.QFont()
        font.setPointSize(10)
        messageLabel.setFont(font)
        self.deleteAllMsgBox.layout().addWidget(messageLabel, 0, 4)

        yesNoBox = qt.QFrame()
        yesNoBox.setLayout(qt.QHBoxLayout())
        self.deleteAllMsgBox.layout().addWidget(yesNoBox, 0, 4)

        #
        # OK button
        #
        okButton = qt.QPushButton()
        okButton.setText("YES")
        okButton.enabled = True
        okIcon = qt.QIcon(":/Icons/AnnotationOkDone.png")
        okButton.setIcon(okIcon)
        yesNoBox.layout().addWidget(okButton)

        #
        # NO button
        #
        noButton = qt.QPushButton()
        noButton.setText("NO")
        noButton.enabled = True
        noIcon = qt.QIcon(":/Icons/AnnotationCancel.png")
        noButton.setIcon(noIcon)
        yesNoBox.layout().addWidget(noButton)

        # Connections
        okButton.connect("clicked()", self.onDeleteAllButton)
        noButton.connect("clicked()", self.deleteAllMsgBox.hide)
Exemple #19
0
  def __init__(self, parent):
    vBoxLayout = qt.QVBoxLayout(parent)
    # Add generic settings
    genericGroupBox = ctk.ctkCollapsibleGroupBox()
    genericGroupBox.title = "Generic DICOM settings"
    genericGroupBoxFormLayout = qt.QFormLayout(genericGroupBox)

    directoryButton = ctk.ctkDirectoryButton()
    genericGroupBoxFormLayout.addRow("Database location:", directoryButton)
    parent.registerProperty(slicer.dicomDatabaseDirectorySettingsKey, directoryButton,
                      "directory", str(qt.SIGNAL("directoryChanged(QString)")),
                      "DICOM general settings", ctk.ctkSettingsPanel.OptionRequireRestart)
    # Restart is forced because no mechanism is implemented that would reopen the DICOM database after
    # folder location is changed. It is easier to restart the application than implementing an update
    # mechanism.

    loadReferencesComboBox = ctk.ctkComboBox()
    loadReferencesComboBox.toolTip = "Determines whether referenced DICOM series are " \
      "offered when loading DICOM, or the automatic behavior if interaction is disabled. " \
      "Interactive selection of referenced series is the default selection"
    loadReferencesComboBox.addItem("Ask user", qt.QMessageBox.InvalidRole)
    loadReferencesComboBox.addItem("Always", qt.QMessageBox.Yes)
    loadReferencesComboBox.addItem("Never", qt.QMessageBox.No)
    loadReferencesComboBox.currentIndex = 0
    genericGroupBoxFormLayout.addRow("Load referenced series:", loadReferencesComboBox)
    parent.registerProperty(
      "DICOM/automaticallyLoadReferences", loadReferencesComboBox,
      "currentUserDataAsString", str(qt.SIGNAL("currentIndexChanged(int)")))

    vBoxLayout.addWidget(genericGroupBox)

    # Add settings panel for the plugins
    plugins = slicer.modules.dicomPlugins
    for pluginName in plugins.keys():
      if hasattr(plugins[pluginName], 'settingsPanelEntry'):
        pluginGroupBox = ctk.ctkCollapsibleGroupBox()
        pluginGroupBox.title = pluginName
        vBoxLayout.addWidget(pluginGroupBox)
        plugins[pluginName].settingsPanelEntry(parent, pluginGroupBox)
    vBoxLayout.addStretch(1)
  def openCreateNewImageClassWindow(self):
    self.createNewImageClassWidget = qt.QDialog()
    self.createNewImageClassWidget.setModal(True)
    self.createNewImageClassFrame = qt.QFrame(self.createNewImageClassWidget)
    self.createNewImageClassFrame.setFrameStyle(0x0006)
    self.createNewImageClassWidget.setWindowTitle('Create New Model')
    self.createNewImageClassPopupGeometry = qt.QRect()
    mainWindow = slicer.util.mainWindow()
    if mainWindow:
      mainWindowGeometry = mainWindow.geometry
      self.windowWidth = mainWindow.width * 0.35
      self.windowHeight = mainWindow.height * 0.35
      self.createNewImageClassPopupGeometry.setWidth(self.windowWidth)
      self.createNewImageClassPopupGeometry.setHeight(self.windowHeight)
      self.popupPositioned = False
      self.createNewImageClassWidget.setGeometry(self.createNewImageClassPopupGeometry)
      self.createNewImageClassFrame.setGeometry(self.createNewImageClassPopupGeometry)
      self.createNewImageClassWidget.move(mainWindow.width / 2.0 - self.windowWidth,
                                     mainWindow.height / 2 - self.windowHeight)
    self.createNewImageClassLayout = qt.QVBoxLayout()
    self.createNewImageClassLayout.setContentsMargins(12, 4, 4, 4)
    self.createNewImageClassLayout.setSpacing(4)

    self.createNewImageClassButtonLayout = qt.QFormLayout()
    self.createNewImageClassButtonLayout.setContentsMargins(12, 4, 4, 4)
    self.createNewImageClassButtonLayout.setSpacing(4)

    self.imageClassNameLineEdit = qt.QLineEdit("Image Class Name")
    self.createNewImageClassButtonLayout.addRow(self.imageClassNameLineEdit)

    self.createNewImageClassButton = qt.QPushButton("Add Image Class")
    self.createNewImageClassButtonLayout.addRow(self.createNewImageClassButton)

    self.imageErrorLabel = qt.QLabel("")
    self.createNewImageClassButtonLayout.addRow(self.imageErrorLabel)

    self.createNewImageClassButton.connect('clicked(bool)', self.onNewImageClassAdded)

    self.createNewImageClassLayout.addLayout(self.createNewImageClassButtonLayout)
    self.createNewImageClassFrame.setLayout(self.createNewImageClassLayout)
Exemple #21
0
    def __init__(self, parent=None):
        self.nameSize = 24

        self.CrosshairNode = None
        self.CrosshairNodeObserverTag = None

        self.frame = qt.QFrame(parent)
        self.frame.setLayout(qt.QVBoxLayout())
        # Set horizontal policy to Ignored to prevent a long segment or volume name making the widget wider.
        # If the module panel made larger then the image viewers would move and the mouse pointer position
        # would change in the image, potentially pointing outside the node with the long name, resulting in the
        # module panel collapsing to the original size, causing an infinite oscillation.
        qSize = qt.QSizePolicy()
        qSize.setHorizontalPolicy(qt.QSizePolicy.Ignored)
        qSize.setVerticalPolicy(qt.QSizePolicy.Preferred)
        self.frame.setSizePolicy(qSize)

        modulePath = slicer.modules.dataprobe.path.replace("DataProbe.py", "")
        self.iconsDIR = modulePath + '/Resources/Icons'

        self.showImage = False

        # Used in _createMagnifiedPixmap()
        self.imageCrop = vtk.vtkExtractVOI()
        self.canvas = vtk.vtkImageCanvasSource2D()
        self.painter = qt.QPainter()
        self.pen = qt.QPen()

        self._createSmall()

        # Helper class to calculate and display tensor scalars
        self.calculateTensorScalars = CalculateTensorScalars()

        # Observe the crosshair node to get the current cursor position
        self.CrosshairNode = slicer.mrmlScene.GetFirstNodeByClass(
            'vtkMRMLCrosshairNode')
        if self.CrosshairNode:
            self.CrosshairNodeObserverTag = self.CrosshairNode.AddObserver(
                slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent,
                self.processEvent)
Exemple #22
0
    def __init__(self, parent=None, name=None, fl=0):
        CreateTaskBase.__init__(self, parent, name, fl, 'Energy-scan')

        # Data attributes
        self.init_models()

        #Layout
        v_layout = qt.QVBoxLayout(self, 2, 5, "main_v_layout")
        h_box = qt.QHGroupBox('Available elements', self)
        self.periodic_table = PeriodicTableBrick(h_box)
        font = self.periodic_table.font()
        font.setPointSize(8)
        self.periodic_table.setFont(font)

        h_box.setMaximumWidth(470)
        h_box.setMaximumHeight(310)

        self._data_path_gbox = qt.QVGroupBox('Data location', self,
                                             'data_path_gbox')
        self._data_path_widget = DataPathWidget(self._data_path_gbox,
                                                data_model=self._path_template,
                                                layout='vertical')

        v_layout.addWidget(h_box)
        v_layout.addWidget(self._data_path_gbox)
        v_layout.addStretch()

        self.connect(
            self._data_path_widget.data_path_widget_layout.child(
                'prefix_ledit'), qt.SIGNAL("textChanged(const QString &)"),
            self._prefix_ledit_change)

        self.connect(
            self._data_path_widget.data_path_widget_layout.child(
                'run_number_ledit'), qt.SIGNAL("textChanged(const QString &)"),
            self._run_number_ledit_change)

        self.connect(self._data_path_widget,
                     qt.PYSIGNAL("path_template_changed"),
                     self.handle_path_conflict)
Exemple #23
0
    def configure_subplots(self):
        self.adj_window = qt.QMainWindow(None, None, qt.Qt.WDestructiveClose)
        win = self.adj_window
        win.setCaption("Subplot Configuration Tool")

        toolfig = Figure(figsize=(6, 3))
        toolfig.subplots_adjust(top=0.9)
        w = int(toolfig.bbox.width)
        h = int(toolfig.bbox.height)

        canvas = self._get_canvas(toolfig)
        tool = SubplotTool(self.canvas.figure, toolfig)
        centralWidget = qt.QWidget(win)
        canvas.reparent(centralWidget, qt.QPoint(0, 0))
        win.setCentralWidget(centralWidget)

        layout = qt.QVBoxLayout(centralWidget)
        layout.addWidget(canvas, 1)

        win.resize(w, h)
        canvas.setFocus()
        win.show()
Exemple #24
0
 def __init__(self, parent, \
              titleType=Label, valueType=Label, orientation=Horizontal):
     qt.QWidget.__init__(self, parent)
     
     self.__valueList = []
     self.__titleList = []
     
     self.orientation = orientation
     self.titleType = titleType
     self.valueType = valueType
     
     if self.orientation == QubValue.Horizontal:
         self.layout = qt.QHBoxLayout(self)
     else:
         self.layout = qt.QVBoxLayout(self)
     
     if self.titleType == QubValue.Combo:
         self.titleWidget = qt.QComboBox(self)
         self.connect(self.titleWidget, qt.SIGNAL("activated(int)"),
                      self.__activatedType)
     else:   
         self.titleWidget = qt.QLabel(self)
     self.layout.addWidget(self.titleWidget)
     
     self.layout.addSpacing(5)
     
     if self.valueType == QubValue.Combo:
         self.valueWidget = qt.QComboBox(self)
         self.connect(self.valueWidget, qt.SIGNAL("activated(int)"),
                      self.__activatedValue)
     elif self.valueType == QubValue.Text:
         self.valueWidget = qt.QLineEdit(self)
         self.connect(self.valueWidget, qt.SIGNAL("returnPressed()"),
                      self.__returnPressed)
     else:
         self.valueWidget = qt.QLabel(self)            
         self.valueWidget.setFrameShape(qt.QFrame.Box)
         self.valueWidget.setFrameShadow(qt.QFrame.Plain)
     self.layout.addWidget(self.valueWidget)
Exemple #25
0
    def __init__(self, *args):
        """Constructor
        """
        BlissWidget.__init__(self, *args)

        self.__stopIdle = _stopIdle()

        # addProperty adds a property for the brick :
        #   - 1st argument is the name of the property ;
        #   - 2d argument is the type (one of string, integer, float, file, combo) ;
        #   - 3rd argument is the default value.
        # In some cases (e.g combo), the third argument is a tuple of choices
        # and the fourth argument is the default value.
        # When a property is changed, the propertyChanged() method is called.
        self.addProperty("mnemonic", "string", "")
        self.addProperty("title", "string", "")
        self.addProperty("formatString", "formatString", "###.##")
        self.addProperty("horizontalLayout", "boolean", True)
        self.__horizontalLayout = False
        self.addProperty("dynamicProperties",
                         "",
                         PropertyBag.PropertyBag(),
                         hidden=True)

        # now we can "draw" the brick, i.e creating GUI widgets
        # and arranging them in a layout. It is the default appearance
        # for the brick (if no property is set for example)
        self.__lblTitle = qt.QLabel(self)
        self.__lblTitle.setAlignment(qt.Qt.AlignHCenter)
        self.__pads = []
        self.__plugs = []
        self.__padLayout = qt.QGridLayout(None, 1, 1)
        self.__padLayout.setSpacing(0)
        self.__padLayout.setMargin(0)

        layout = qt.QVBoxLayout(self, 0, 0)
        layout.addWidget(self.__lblTitle)
        layout.addLayout(self.__padLayout)
        self.__extPadid = re.compile(r"pad (\d+)")
Exemple #26
0
    def __init__(self, parent):
        vLayout = qt.QVBoxLayout(parent)

        self.colorPromptLabel = qt.QLabel()
        vLayout.addWidget(self.colorPromptLabel)

        self.colorSelectorFrame = qt.QFrame()
        self.colorSelectorFrame.objectName = 'ColorSelectorFrame'
        self.colorSelectorFrame.setLayout(qt.QHBoxLayout())
        vLayout.addWidget(self.colorSelectorFrame)

        self.colorSelectorLabel = qt.QLabel()
        self.colorSelectorFrame.layout().addWidget(self.colorSelectorLabel)

        self.colorSelector = slicer.qMRMLColorTableComboBox()
        self.colorSelector.nodeTypes = ["vtkMRMLColorNode"]
        self.colorSelector.hideChildNodeTypes = (
            "vtkMRMLDiffusionTensorDisplayPropertiesNode",
            "vtkMRMLProceduralColorNode", "")
        self.colorSelector.addEnabled = False
        self.colorSelector.removeEnabled = False
        self.colorSelector.noneEnabled = False
        self.colorSelector.selectNodeUponCreation = True
        self.colorSelector.showHidden = True
        self.colorSelector.showChildNodeTypes = True
        self.colorSelector.setMRMLScene(slicer.mrmlScene)
        self.colorSelector.setToolTip(
            "Pick the table of structures you wish to edit")
        vLayout.addWidget(self.colorSelector)

        self.buttonBox = qt.QDialogButtonBox()
        self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok
                                          | qt.QDialogButtonBox.Cancel)
        vLayout.addWidget(self.buttonBox)

        self.buttonBox.button(qt.QDialogButtonBox.Ok).setToolTip(
            "Use currently selected color node.")
        self.buttonBox.button(
            qt.QDialogButtonBox.Cancel).setToolTip("Cancel current operation.")
Exemple #27
0
  def __init__(self,parent, width=50,height=100):
    self.widget = qt.QWidget(parent)
    self.widget.setMinimumHeight(height)
    self.widget.setMinimumWidth(width)
    self.width = width
    self.height = height
    self.layout = qt.QVBoxLayout()
    self.widget.setLayout(self.layout)
    self.checkBoxByPlugin = {}
    settings = qt.QSettings()

    slicerPlugins = slicer.modules.dicomPlugins

    for pluginClass in slicer.modules.dicomPlugins:
      self.checkBoxByPlugin[pluginClass] = qt.QCheckBox(pluginClass)
      self.layout.addWidget(self.checkBoxByPlugin[pluginClass])

    if settings.contains('DICOM/disabledPlugins/size'):
      size = settings.beginReadArray('DICOM/disabledPlugins')
      disabledPlugins = []

      for i in xrange(size):
        settings.setArrayIndex(i)
        disabledPlugins.append(str(settings.allKeys()[0]))
      settings.endArray()

      for pluginClass in slicer.modules.dicomPlugins:
        if pluginClass in disabledPlugins:
          self.checkBoxByPlugin[pluginClass].checked = False
        else:
          # Activate plugins for the ones who are not in the disabled list
          # and also plugins installed with extensions
          self.checkBoxByPlugin[pluginClass].checked = True

    else:

      # All DICOM plugins would be enabled by default
      for pluginClass in slicer.modules.dicomPlugins:
        self.checkBoxByPlugin[pluginClass].checked = True
Exemple #28
0
    def __init__(self, columnNames, comboItems):
        layout = CustomTable.__init__(self, columnNames)

        self.settingsFormatText = ctk.ctkFittedTextBrowser()
        self.settingsFormatText.setFrameShape(qt.QFrame.NoFrame)
        self.settingsFormatText.setFrameShadow(qt.QFrame.Plain)
        self.settingsFormatText.setCollapsibleText('')

        gb = ctk.ctkCollapsibleGroupBox()
        gb.title = 'Settings Format'
        gb.collapsed = True
        gblayout = qt.QVBoxLayout(gb)
        gblayout.addWidget(self.settingsFormatText)

        layout.addWidget(gb)

        self.view.setItemDelegateForColumn(
            0,
            ComboDelegate(self.model, comboItems,
                          self.setSettingsFormatTextFromName))
        self.view.setItemDelegateForColumn(self.model.columnCount() - 1,
                                           TextEditDelegate(self.model))
Exemple #29
0
    def __init__(self, widgetClass=None):
        self.parent = qt.QFrame()
        self.parent.setLayout(qt.QVBoxLayout())

        # TODO: should have way to pop up python interactor
        self.buttons = qt.QFrame()
        self.buttons.setLayout(qt.QHBoxLayout())
        self.parent.layout().addWidget(self.buttons)
        self.addDataButton = qt.QPushButton("Add Data")
        self.buttons.layout().addWidget(self.addDataButton)
        self.addDataButton.connect("clicked()",
                                   slicer.app.ioManager().openAddDataDialog)
        self.loadSceneButton = qt.QPushButton("Load Scene")
        self.buttons.layout().addWidget(self.loadSceneButton)
        self.loadSceneButton.connect(
            "clicked()",
            slicer.app.ioManager().openLoadSceneDialog)

        if widgetClass:
            self.widget = widgetClass(self.parent)
            self.widget.setup()
        self.parent.show()
Exemple #30
0
    def setup(self):
        self.setLayout(qt.QVBoxLayout())

        self.deviceButtonGroup = qt.QButtonGroup()
        self.deviceButtonGroup.setExclusive(True)

        vBoxDeviceButtonGroup = qt.QWidget()
        vBoxDeviceButtonGroup.setLayout(qt.QGridLayout())
        numberOfColumns = 4 if len(self.registeredDeviceClasses) < 5 or len(
            self.registeredDeviceClasses) > 6 else 3
        for currentWidgetIndex, deviceClass in enumerate(
                self.registeredDeviceClasses):
            deviceWidgetButton = self.createDeviceButton(deviceClass)
            self.deviceWidgetFrames[deviceClass.ID] = DeviceImplantWidget(
                deviceClass)
            self.deviceButtonGroup.addButton(deviceWidgetButton)
            vBoxDeviceButtonGroup.layout().addWidget(
                deviceWidgetButton, int(currentWidgetIndex / numberOfColumns),
                currentWidgetIndex % numberOfColumns)

        self.deviceButtonGroup.connect('buttonClicked(QAbstractButton*)',
                                       self.onSwitchDevice)
        self.layout().addWidget(vBoxDeviceButtonGroup)