Exemple #1
0
    def __init__(self, parent, name, values, layout_margin=0, layout_spacing=-1, modal=True):
        qt.QDialog.__init__(self, parent, name, modal)
        if layout_spacing == -1:
            layout_spacing =  self.fontMetrics().height()

        self.list_layout = qt.QVBoxLayout()
        self.listview = qt.QListView(self)
        self.listview.setSelectionMode(qt.QListView.Extended)
        self.listview.addColumn(name)
        self.listview.setColumnWidthMode(0, qt.QListView.Maximum)
        for value in values:
            view_item = qt.QListViewItem(self.listview)
            view_item.setText(0, qt.QString(value))

        self.list_layout.addWidget(self.listview)

        self.button_box = qt.QVBoxLayout()
        self.add_button = qt.QPushButton("Add", self)
        self.add_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.add_button, qt.SIGNAL('clicked()'), self.addValue)
        self.remove_button = qt.QPushButton("Remove", self)
        self.remove_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.remove_button, qt.SIGNAL('clicked()'), self.removeValue)
        self.close_button = qt.QPushButton("Close", self)
        self.close_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.close_button, qt.SIGNAL('clicked()'), self.close)
        self.button_box.addWidget(self.add_button)
        self.button_box.addWidget(self.remove_button)
        self.button_box.addStretch(2)
        self.button_box.addWidget(self.close_button)

        self.main_layout = qt.QHBoxLayout(self, layout_margin, layout_spacing, "main_layout")
        self.main_layout.addLayout(self.list_layout)
        self.main_layout.addLayout(self.button_box)
Exemple #2
0
    def __init__(self,
                 parent,
                 name,
                 callback,
                 layout_margin=0,
                 layout_spacing=-1,
                 modal=True):
        qt.QDialog.__init__(self, parent, name, modal)
        self.widgets = {}
        self.result = None
        self.callback = callback

        if layout_spacing == -1:
            layout_spacing = self.fontMetrics().height()

        self.main_layout = qt.QVBoxLayout(self, layout_margin, layout_spacing,
                                          "main_layout")

        self.setEdition()

        self.button_box = qt.QHBoxLayout()
        self.accept_button = qt.QPushButton("Accept", self)
        self.accept_button.setMaximumSize(qt.QSize(75, 25))
        self.connect(self.accept_button, qt.SIGNAL('clicked()'), self._accept)
        self.cancel_button = qt.QPushButton("Cancel", self)
        self.cancel_button.setMaximumSize(qt.QSize(75, 25))
        self.connect(self.cancel_button, qt.SIGNAL('clicked()'), self.cancel)
        self.button_box.addWidget(self.accept_button)
        self.button_box.addWidget(self.cancel_button)

        self.main_layout.addStretch(1)
        self.main_layout.setMargin(5)
        self.main_layout.setSpacing(6)
        self.main_layout.addLayout(self.button_box)
    def setup(self):
        self.mainFrame = qt.QFrame()
        frameLayout = qt.QGridLayout()
        self.mainFrame.setLayout(frameLayout)
        self.layout.addWidget(self.mainFrame)

        self.saveButton = ctk.ctkPushButton()
        self.saveButton.text = "Save"
        self.saveButton.toolTip = "Save the current table"
        self.saveButton.objectName = "reportSaveButton"
        self.saveButton.setIcon(qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveButton.setIconSize(qt.QSize(24, 24))
        frameLayout.addWidget(self.saveButton, 0, 0)

        self.openButton = ctk.ctkPushButton()
        self.openButton.text = "Open"
        self.openButton.toolTip = "Open all the results saved"
        self.openButton.objectName = "reportOpenButton"
        self.openButton.setIcon(qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.openButton.setIconSize(qt.QSize(24,24))
        frameLayout.addWidget(self.openButton, 0, 1)

        self.exportButton = ctk.ctkPushButton()
        self.exportButton.text = "Export"
        self.exportButton.toolTip = "Export all the saved results to a CSV file"
        self.exportButton.objectName = "reportExportButton"
        self.exportButton.setIcon(qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.exportButton.setIconSize(qt.QSize(24,24))
        frameLayout.addWidget(self.exportButton, 0, 2)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.setIcon(qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(24,24))
        self.removeButton.text = "Clean cache"
        frameLayout.addWidget(self.removeButton, 0, 3)

        self.printButton = ctk.ctkPushButton()
        self.printButton.text = "Print"
        self.printButton.toolTip = "Print report"
        self.printButton.objectName = "reportPrintButton"
        self.printButton.setIcon(qt.QIcon("{0}/print.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.printButton.setIconSize(qt.QSize(24,24))
        self.printButton.setVisible(False)  # By default, this button will be hidden
        frameLayout.addWidget(self.printButton, 0, 4)

        self.additionalComentsLabel = qt.QLabel("Additional comments:")
        self.additionalComentsLabel.setStyleSheet("margin-top: 3px")
        frameLayout.addWidget(self.additionalComentsLabel, 1, 0, 1, 2)
        self.additionalComentsTextEdit = CollapsibleMultilineText()
        frameLayout.addWidget(self.additionalComentsTextEdit, 1, 1, 1, 3)

        self.openButton.connect('clicked()', self.onShowStoredData)
        self.saveButton.connect('clicked()', self.onSave)
        self.exportButton.connect('clicked()', self.onExport)
        self.printButton.connect('clicked()', self.onPrintReport)
        self.removeButton.connect('clicked()', self.onRemoveStoredData)
Exemple #4
0
    def __init__(self, parent=None, name="log_bar_widget", fl=0):
        qt.QWidget.__init__(self, parent, name, fl)

        self.text_edit = qt.QTextEdit(self, "text_edit")
        self.text_edit.setMinimumSize(qt.QSize(0, 55))
        self.text_edit.setMaximumSize(qt.QSize(32767, 55))
        self.text_edit.setTextFormat(qt.QTextEdit.RichText)
        self.text_edit.setReadOnly(True)

        main_layout = qt.QHBoxLayout(self)
        main_layout.addWidget(self.text_edit)
    def __init__(self, parent):
        """
        Window that display the data
        :param parent: CaseReportsWidget object
        """
        super(CaseReportsWindow, self).__init__()

        self.mainLayout = qt.QVBoxLayout(self)
        self.setLayout(self.mainLayout)
        self.resize(400, 300)

        self.label = qt.QLabel("Data stored in the module: ")
        self.label.setStyleSheet("margin: 10px 0 15px 0")
        self.mainLayout.addWidget(self.label)

        self.tableView = slicer.qMRMLTableView()
        self.tableView.setColumnWidth(0, 125)
        self.tableView.setMRMLTableNode(parent.logic.tableNode)
        self.tableView.setFirstRowLocked(True)  # First row will be headers
        self.tableView.setSortingEnabled(True)

        self.tableView.setSizePolicy(qt.QSizePolicy.Expanding,
                                     qt.QSizePolicy.Expanding)
        self.mainLayout.addWidget(self.tableView)

        self.expandRowsButton = ctk.ctkPushButton()
        self.expandRowsButton.text = "Expand rows"
        self.expandRowsButton.toolTip = "Change the height of the rows to show/hide all the multiline data"
        self.expandRowsButton.setFixedWidth(150)
        self.expandRowsButton.setIcon(
            qt.QIcon("{0}/reload.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.expandRowsButton.setIconSize(qt.QSize(24, 24))
        self.mainLayout.addWidget(self.expandRowsButton)

        self.exportButton = ctk.ctkPushButton()
        self.exportButton.text = "Export"
        self.exportButton.toolTip = "Export to a CVS file"
        self.exportButton.setFixedWidth(150)
        self.exportButton.setIcon(
            qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.exportButton.setIconSize(qt.QSize(24, 24))
        self.mainLayout.addWidget(self.exportButton)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.text = "Clean"
        self.removeButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(24, 24))
        self.removeButton.setFixedWidth(150)
        self.mainLayout.addWidget(self.removeButton)

        self.expandRowsButton.connect('clicked()', parent.onExpandRows)
        self.exportButton.connect('clicked()', parent.onExport)
        self.removeButton.connect('clicked()', parent.onRemoveStoredData)
    def _setupButtons(self):
        iconSize = qt.QSize(36, 36)
        self.quickSegmentationButton = self.createButton(
            'Quick Mode',
            icon=self.quickSegmentationIcon,
            iconSize=iconSize,
            checkable=True,
            objectName="quickSegmentationButton",
            enabled=False,
            toolTip="Start quick mode segmentation")
        self.applySegmentationButton = self.createButton(
            "",
            icon=Icons.apply,
            iconSize=iconSize,
            enabled=False,
            objectName="applyButton",
            toolTip="Apply")
        self.cancelSegmentationButton = self.createButton(
            "",
            icon=Icons.cancel,
            iconSize=iconSize,
            enabled=False,
            objectName="cancelButton",
            toolTip="Cancel")
        self.undoButton = self.createButton("",
                                            icon=Icons.undo,
                                            iconSize=iconSize,
                                            enabled=False,
                                            toolTip="Undo",
                                            objectName="undoButton")
        self.redoButton = self.createButton("",
                                            icon=Icons.redo,
                                            iconSize=iconSize,
                                            enabled=False,
                                            toolTip="Redo",
                                            objectName="redoButton")

        self.segmentEditorWidgetButton = self.createButton(
            "",
            icon=Icons.settings,
            toolTip="Show Segment Editor",
            checkable=True,
            enabled=False,
            iconSize=qt.QSize(36, 36))

        self.segmentationButtons = self.createHLayout([
            self.quickSegmentationButton, self.applySegmentationButton,
            self.cancelSegmentationButton, self.undoButton, self.redoButton,
            self.segmentEditorWidgetButton
        ])
        self.layout.addWidget(self.segmentationButtons)
Exemple #7
0
  def setup(self):
    super(SliceTrackerOverviewStep, self).setup()
    iconSize = qt.QSize(24, 24)
    self.caseManagerPlugin = SliceTrackerCaseManagerPlugin()
    self.trainingPlugin = SliceTrackerTrainingPlugin()


    self.changeSeriesTypeButton = SeriesTypeToolButton()
    self.trackTargetsButton = self.createButton("", icon=self.trackIcon, iconSize=iconSize, toolTip="Track targets",
                                                enabled=False)
    self.skipIntraopSeriesButton = self.createButton("", icon=Icons.skip, iconSize=iconSize,
                                                     toolTip="Skip selected series", enabled=False)
    self.setupIntraopSeriesSelector()

    self.setupRegistrationResultsPlugin()

    self.targetTablePlugin = SliceTrackerTargetTablePlugin()
    self.addPlugin(self.targetTablePlugin)

    self.displacementChartPlugin = SliceTrackerDisplacementChartPlugin()
    self.addPlugin(self.displacementChartPlugin)

    self.displacementChartPlugin.addEventObserver(self.displacementChartPlugin.ShowEvent, self.onShowDisplacementChart)
    self.displacementChartPlugin.addEventObserver(self.displacementChartPlugin.HideEvent, self.onHideDisplacementChart)
    self.displacementChartPlugin.collapsibleButton.hide()

    self.layout().addWidget(self.caseManagerPlugin)
    self.layout().addWidget(self.trainingPlugin)
    self.layout().addWidget(self.targetTablePlugin)
    self.layout().addWidget(self.createHLayout([self.intraopSeriesSelector, self.changeSeriesTypeButton,
                                                self.trackTargetsButton, self.skipIntraopSeriesButton]))
    self.layout().addWidget(self.regResultsCollapsibleButton)
    self.layout().addWidget(self.displacementChartPlugin.collapsibleButton)
    self.layout().addStretch(1)
Exemple #8
0
def restoreSizes(configuration,
                 window,
                 display,
                 configurationSuffix="",
                 moveWindowFlag=True):
    splitters = configuration.findAllChildrenWType("splitter", window)

    if len(splitters):
        for sw in display.queryList("QSplitter"):
            try:
                splitter = splitters[sw.name()]
                sw.setSizes(
                    eval(splitter["properties"]["sizes%s" %
                                                configurationSuffix]))
            except KeyError:
                continue

    if (window["properties"]["x%s" % configurationSuffix] +
            window["properties"]["y%s" % configurationSuffix] +
            window["properties"]["w%s" % configurationSuffix] +
            window["properties"]["h%s" % configurationSuffix] > 0):
        if moveWindowFlag:
            display.move(window["properties"]["x%s" % configurationSuffix],
                         window["properties"]["y%s" % configurationSuffix])
        display.resize(
            qt.QSize(window["properties"]["w%s" % configurationSuffix],
                     window["properties"]["h%s" % configurationSuffix]))
    def open(self, username="", password=""):
        """Open the MorphoSource page and fill in or capture the url
    """
        if username != "":
            self.setLogin(username, password)

        webWidget = slicer.qSlicerWebWidget()
        slicerGeometry = slicer.util.mainWindow().geometry
        webWidget.size = qt.QSize(slicerGeometry.width(),
                                  slicerGeometry.height())
        webWidget.pos = qt.QPoint(slicerGeometry.x() + 256,
                                  slicerGeometry.y() + 128)
        webWidget.url = "https://www.morphosource.org/LoginReg/form"
        webWidget.show()

        self.webWidget = webWidget
        # TODO: need to expose loadFinished signal from QWebEngine via qSlicerWebWidget
        # so that we will know when to send this (current 2 second delay is a hack
        # that may not always work).
        onFinishLoading = lambda: self.onFinishLoading(username, password)
        connected = self.webWidget.connect('loadFinished(bool)',
                                           onFinishLoading)
        if not connected:
            qt.QTimer.singleShot(
                3000, lambda: self.onFinishLoading(username, password))

        return self.webWidget
Exemple #10
0
    def setup(self):
        self.setLayout(qt.QGridLayout())
        self.setupSliceWidget()

        iconSize = qt.QSize(36, 36)
        self.modifySegmentButton = self.createButton(
            "Modify Segmentation",
            icon=slicer.modules.segmenteditor.icon,
            iconSize=iconSize)
        self.confirmSegmentButton = self.createButton("Confirm Segmentation",
                                                      icon=Icons.apply,
                                                      iconSize=iconSize)
        self.cancelButton = self.createButton("Cancel",
                                              icon=Icons.cancel,
                                              iconSize=iconSize)

        self.setupSegmentEditor()
        self.layout().addWidget(self.segmentEditorWidget, 0, 0, 2, 1)
        self.layout().addWidget(self.sliceWidget, 0, 1)
        self.layout().addWidget(
            self.createHLayout([
                self.modifySegmentButton, self.confirmSegmentButton,
                self.cancelButton
            ]), 1, 1)
        self.setupConnections()
    def setupViewSettingGroupBox(self):
        iconSize = qt.QSize(24, 24)
        self.redOnlyLayoutButton = RedSliceLayoutButton()
        self.sideBySideLayoutButton = SideBySideLayoutButton()
        self.fourUpLayoutButton = FourUpLayoutButton()
        self.layoutButtons = [
            self.redOnlyLayoutButton, self.sideBySideLayoutButton,
            self.fourUpLayoutButton
        ]

        self.screenShotButton = ScreenShotButton()
        self.screenShotButton.caseResultDir = ""
        self.settingsButton = ModuleSettingsButton(self.moduleName)
        self.affectiveZoneIcon = self.createIcon('icon-needle.png')
        self.showAffectiveZoneButton = self.createButton(
            "",
            icon=self.affectiveZoneIcon,
            iconSize=iconSize,
            checkable=True,
            toolTip="Display the effective ablation zone")
        self.showAffectiveZoneButton.connect(
            'toggled(bool)', self.session.onShowAffectiveZoneToggled)
        viewSettingButtons = [
            self.redOnlyLayoutButton, self.fourUpLayoutButton,
            self.settingsButton, self.screenShotButton,
            self.showAffectiveZoneButton
        ]

        for step in self.session.steps:
            viewSettingButtons += step.viewSettingButtons

        self.layout.addWidget(self.createHLayout(viewSettingButtons))
        self.setupAdditionalViewSettingButtons()
        self.resetViewSettingButtons()
Exemple #12
0
    def setupTabBarNavigation(self):
        self.tabWidget = qt.QTabWidget()
        self.layout.addWidget(self.tabWidget)

        setupGroupBox = qt.QGroupBox()
        imageSelectionGroupBox = qt.QGroupBox()
        segmentationGroupBox = qt.QGroupBox()
        submissionGroupBox = qt.QGroupBox()

        self.setupGroupBoxLayout = qt.QFormLayout()
        self.imageSelectionGroupBoxLayout = qt.QFormLayout()
        self.segmentationGroupBoxLayout = qt.QGridLayout()
        self.submissionGroupBoxLayout = qt.QFormLayout()

        setupGroupBox.setLayout(self.setupGroupBoxLayout)
        imageSelectionGroupBox.setLayout(self.imageSelectionGroupBoxLayout)
        segmentationGroupBox.setLayout(self.segmentationGroupBoxLayout)
        submissionGroupBox.setLayout(self.submissionGroupBoxLayout)

        self.tabWidget.setIconSize(qt.QSize(85, 30))

        self.tabWidget.addTab(setupGroupBox, self.setupIcon, '')
        self.tabWidget.addTab(imageSelectionGroupBox, self.imageSelectionIcon,
                              '')
        self.tabWidget.addTab(segmentationGroupBox, self.segmentationIcon, '')
        self.tabWidget.addTab(submissionGroupBox, self.submissionIcon, '')
        self.tabWidget.connect('currentChanged(int)', self.onTabWidgetClicked)

        self.setTabsEnabled([1, 2, 3, 4], True)
def make():
    # create a plot with a white canvas
    demo = Qwt.QwtPlot(Qwt.QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(qt.Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = Qwt.QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(qt.QPen(qt.Qt.black, 0, qt.Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = arange(0, 10.1, 0.5, Float)
    y = sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2  # all error bars the same size
    errorOnTop = False  # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x=x,
        y=y,
        dx=dx,
        dy=dy,
        curvePen=qt.QPen(qt.Qt.black, 2),
        curveSymbol=Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, qt.QBrush(qt.Qt.red),
                                  qt.QPen(qt.Qt.black, 2), qt.QSize(9, 9)),
        errorPen=qt.QPen(qt.Qt.blue, 2),
        errorCap=10,
        errorOnTop=errorOnTop,
    )
    curve.attach(demo)
    demo.resize(400, 300)
    demo.show()
    return demo
Exemple #14
0
 def addComboBox(self, name, description, values, label_size=100):
     label = qt.QLabel(None, description, self)
     label.setMinimumSize(qt.QSize(label_size, 1))
     label.setAlignment(qt.Qt.AlignTop)
     self.widgets[name] = combo_edit = ComboBoxEditWidget(self, values)
     combo_edit.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding))
     self._addWidget(label, combo_edit)
Exemple #15
0
 def addTextBlockEdit(self, name, description, label_size=100):
     label = qt.QLabel(None, description, self)
     label.setMinimumSize(qt.QSize(label_size, 1))
     label.setAlignment(qt.Qt.AlignTop)
     self.widgets[name] = text_block_edit = TextBlockEditWidget(self, "")
     text_block_edit.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding))
     self._addWidget(label, text_block_edit)
Exemple #16
0
 def addTextEdit(self, name, description, label_size=100):
     label = qt.QLabel(None, description, self)
     label.setMinimumSize(qt.QSize(label_size, 1))
     self.widgets[name] = text_edit = TextEditWidget(self, "")
     text_edit.setSizePolicy(
         qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum))
     self._addWidget(label, text_edit)
    def setup(self):
        self.targetTablePlugin = TargetsDefinitionTable(self.session,
                                                        movingEnabled=True)
        self.addPlugin(self.targetTablePlugin)

        self.targetingGroupBox = qt.QGroupBox("Target Placement")
        self.targetingGroupBoxLayout = qt.QFormLayout()
        self.targetingGroupBox.setLayout(self.targetingGroupBoxLayout)
        self.fiducialsWidget = TargetCreationWidget(
            DEFAULT_FIDUCIAL_LIST_NAME="IntraOpTargets",
            ICON_SIZE=qt.QSize(36, 36))
        self.fiducialsWidget.addEventObserver(
            self.fiducialsWidget.StartedEvent, self.onTargetingStarted)
        self.fiducialsWidget.addEventObserver(
            self.fiducialsWidget.FinishedEvent, self.onTargetingFinished)
        self.fiducialsWidget.targetListSelector.connect(
            "currentNodeChanged(vtkMRMLNode*)", self.onFiducialListSelected)
        self.targetDistanceWidget = qt.QListWidget()
        self.targetDistanceWidget.setWindowTitle("Distances Between Targets")
        #self.showTargetDistanceIcon = self.createIcon('icon-distance.png')
        #self.showTargetDistanceButton = self.createButton("", enabled=True, icon=self.showTargetDistanceIcon, iconSize=qt.QSize(24, 24),
        #                                              toolTip="Start placing targets")
        self.targetingGroupBoxLayout.addRow(self.targetTablePlugin)
        self.targetingGroupBoxLayout.addRow(self.fiducialsWidget)
        self.targetingGroupBoxLayout.addRow(self.targetDistanceWidget)
        self.layout().addWidget(self.targetingGroupBox, 1, 0, 2, 2)
 def onSiteButtonClicked(self, site):
   webWidget = slicer.qSlicerWebWidget()
   slicerGeometry = slicer.util.mainWindow().geometry
   webWidget.size = qt.QSize(1536,1024)
   webWidget.pos = qt.QPoint(slicerGeometry.x() + 256, slicerGeometry.y() + 128)
   webWidget.url = site["url"]
   webWidget.show()
   self.webWidgets.append(webWidget)
Exemple #19
0
 def _setupTargetCreationWidget(self):
     self.targetCreationWidget = TargetCreationWidget(
         DEFAULT_FIDUCIAL_LIST_NAME="IntraopTargets",
         ICON_SIZE=qt.QSize(36, 36))
     self.targetCreationWidget.addEventObserver(self.TargetingStartedEvent,
                                                self._onTargetingStarted)
     self.targetCreationWidget.addEventObserver(self.TargetingFinishedEvent,
                                                self._onTargetingFinished)
Exemple #20
0
 def addCheckBox(self, name, description, callback=None, label_size=100):
     label = qt.QLabel(None, description, self)
     label.setMinimumSize(qt.QSize(label_size, 1))
     label.setAlignment(qt.Qt.AlignTop)
     self.widgets[name] = checkbox_edit = BooleanEditWidget(self, False)
     checkbox_edit.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding))
     if callback:
         self.connect(checkbox_edit, qt.SIGNAL("stateChanged(int)"), callback)
     self._addWidget(label, checkbox_edit)
Exemple #21
0
    def __init__(self, *args):
        qt.QMainWindow.__init__(self, *args)

        self.plot = Qwt.QwtPlot(self)
        self.plot.setTitle("A Simple Map Demonstration")
        self.plot.setCanvasBackground(qt.Qt.white)
        self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, "x")
        self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, "y")    
        self.plot.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 1.0)
        self.plot.setAxisScale(Qwt.QwtPlot.yLeft, 0.0, 1.0)
        self.setCentralWidget(self.plot)

        # Initialize map data
        self.count = self.i = 1000
        self.xs = zeros(self.count, Float)
        self.ys = zeros(self.count, Float)

        self.kappa = 0.2

        self.curve = Qwt.QwtPlotCurve("Map")
        self.curve.attach(self.plot)

        self.curve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
                                           qt.QBrush(qt.Qt.red),
                                           qt.QPen(qt.Qt.blue),
                                           qt.QSize(5, 5)))

        self.curve.setPen(qt.QPen(qt.Qt.cyan))

        toolBar = qt.QToolBar(self)

        qt.QLabel("Count:", toolBar)
        sizeCounter = Qwt.QwtCounter(toolBar)
        toolBar.addSeparator()
        sizeCounter.setRange(0, 1000000, 100)
        sizeCounter.setValue(self.count)
        sizeCounter.setNumButtons(3)
        self.connect(
            sizeCounter, qt.SIGNAL('valueChanged(double)'), self.setCount)

        qt.QLabel("Ticks (ms):", toolBar)
        tickCounter = Qwt.QwtCounter(toolBar)
        toolBar.addSeparator()
        # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz)
        self.ticks = 10
        tickCounter.setRange(0, 1000, 1)
        tickCounter.setValue(self.ticks)
        tickCounter.setNumButtons(3)
        self.connect(
            tickCounter, qt.SIGNAL('valueChanged(double)'), self.setTicks)
        self.tid = self.startTimer(self.ticks)

        self.timer_tic = None
        self.user_tic = None
        self.system_tic = None
        
        self.plot.replot()
Exemple #22
0
 def setWindowSize(width=None, height=None, scale=None):
     if width is None:
         width = 1280
     if height is None:
         height = 1024
     if scale is not None:
         width *= scale
         height *= scale
     slicer.util.mainWindow().size = qt.QSize(width, height)
Exemple #23
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Load UI file
        moduleName = 'Home'
        scriptedModulesPath = os.path.dirname(
            slicer.util.modulePath(moduleName))
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            moduleName + '.ui')

        self.Widget = slicer.util.loadUI(path)
        self.layout.addWidget(self.Widget)

        # Setup data buttons
        numberOfColumns = 2
        iconPath = os.path.join(
            os.path.dirname(__file__).replace('\\', '/'), 'Resources', 'Icons')
        desktop = qt.QDesktopWidget()
        mainScreenSize = desktop.availableGeometry(desktop.primaryScreen)
        iconSize = qt.QSize(mainScreenSize.width() / 15,
                            mainScreenSize.height() / 10)

        buttonsLayout = self.get('DataCollapsibleGroupBox').layout()
        columnIndex = 0
        rowIndex = 0

        files = {
            'annotation_25':
            os.path.join(scriptedModulesPath, 'CellLocatorData',
                         'annotation_25.nrrd'),
            'annotation_50':
            os.path.join(scriptedModulesPath, 'CellLocatorData',
                         'annotation_50.nrrd')
        }
        for (file, filepath) in files.iteritems():
            button = qt.QToolButton()
            button.setText(file)

            # Set thumbnail
            thumbnailFileName = os.path.join(scriptedModulesPath, 'Resources',
                                             'Icons', file + '.png')
            button.setIcon(qt.QIcon(thumbnailFileName))
            button.setIconSize(iconSize)
            button.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon)
            qSize = qt.QSizePolicy()
            qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding)
            button.setSizePolicy(qSize)

            button.name = '%sPushButton' % file
            buttonsLayout.addWidget(button, rowIndex, columnIndex)
            columnIndex += 1
            if columnIndex == numberOfColumns:
                rowIndex += 1
                columnIndex = 0
            button.connect('clicked()',
                           lambda p=filepath: slicer.util.loadVolume(p))
Exemple #24
0
 def setupActionButtons(self):
   iconSize = qt.QSize(36, 36)
   self.runZFrameRegistrationButton = self.createButton("", icon=self.startIcon, iconSize=iconSize, enabled=False,
                                                        toolTip="Run ZFrame Registration")
   self.approveZFrameRegistrationButton = self.createButton("", icon=self.approveIcon, iconSize=iconSize,
                                                            enabled=False,
                                                            toolTip="Confirm registration accuracy", )
   self.retryZFrameRegistrationButton = self.createButton("", icon=self.retryIcon, iconSize=iconSize, enabled=False,
                                                          visible=self.zFrameRegistrationClass is OpenSourceZFrameRegistration,
                                                          toolTip="Reset")
Exemple #25
0
 def createDeviceButton(self, deviceClass):
     deviceWidgetButton = qt.QPushButton()
     icon = deviceClass.getIcon()
     if icon:
         deviceWidgetButton.setIcon(icon)
         deviceWidgetButton.iconSize = qt.QSize(48, 48)
     deviceWidgetButton.checkable = True
     deviceWidgetButton.name = deviceClass.ID
     deviceWidgetButton.setToolTip(deviceClass.NAME)
     return deviceWidgetButton
Exemple #26
0
 def createWebWidget():
     webWidget = slicer.qSlicerWebWidget()
     slicerGeometry = slicer.util.mainWindow().geometry
     webWidget.size = qt.QSize(slicerGeometry.width(),
                               slicerGeometry.height())
     webWidget.pos = qt.QPoint(slicerGeometry.x() + 256,
                               slicerGeometry.y() + 128)
     webWidget.url = "http://localhost:8000"
     webWidget.show()
     return webWidget
Exemple #27
0
 def __init__(self, parent, values, title="", preview_size=25):
     qt.QHBox.__init__(self, parent)
     self.title = title
     self.values = values
     self.preview_size = preview_size
     preview = self.getPreview()
     self.list_label = DetailLabel(None, preview, self)
     button = qt.QPushButton("...", self)
     button.setMaximumSize(qt.QSize(25, 25))
     self.connect(button, qt.SIGNAL('clicked()'), self.showListEditor)
Exemple #28
0
    def __init__(self, parent=None, name=None, fl=0):
        qt.QWidget.__init__(self, parent, name, fl)

        # AsyncResult to return values
        self._async_result = None

        # Layout
        qt.QVBoxLayout(self)
        main_layout = self.layout()
        main_layout.setSpacing(10)
        main_layout.setMargin(6)
        self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding)

        self.setCaption("GPhL Workflow parameters")

        # Info box
        self.info_gbox = qt.QVGroupBox("Info", self, "info_gbox")
        main_layout.addWidget(self.info_gbox)
        self.info_text = qt.QTextEdit(self.info_gbox, "info_text")
        self.info_text.setTextFormat(0)  # PlainText
        self.info_text.setFont(qt.QFont("Courier"))
        self.info_text.setReadOnly(True)

        # Special parameter box
        self.cplx_gbox = qt.QVGroupBox("Indexing solution", self, "cplx_gbox")
        main_layout.addWidget(self.cplx_gbox)
        self.cplx_widget = None

        # Parameter box
        self.parameter_gbox = qt.QVGroupBox("Parameters", self,
                                            "parameter_gbox")
        main_layout.addWidget(self.parameter_gbox)
        self.params_widget = None

        # Button bar
        button_layout = qt.QHBoxLayout(None, 0, 6, "button_layout")
        hspacer = qt.QSpacerItem(1, 20, qt.QSizePolicy.Expanding,
                                 qt.QSizePolicy.Minimum)
        button_layout.addItem(hspacer)
        self.continue_button = qt.QPushButton("Continue", self,
                                              "continue_button")
        button_layout.addWidget(self.continue_button)
        self.cancel_button = qt.QPushButton("Abort", self, "cancel_button")
        button_layout.addWidget(self.cancel_button)
        main_layout.addLayout(button_layout)

        qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"),
                           self.continue_button_click)

        qt.QObject.connect(self.cancel_button, qt.SIGNAL("clicked()"),
                           self.cancel_button_click)

        self.resize(qt.QSize(1018, 472).expandedTo(self.minimumSizeHint()))
        self.clearWState(qt.Qt.WState_Polished)
 def setupGUIAndConnections(self):
     iconSize = qt.QSize(36, 36)
     self.inputVolumeGroupBox = qt.QGroupBox()
     self.inputVolumeGroupBoxLayout = qt.QFormLayout()
     self.inputVolumeGroupBox.setLayout(self.inputVolumeGroupBoxLayout)
     self.inputVolumeGroupBox.setFlat(True)
     self.zFrameTemplateVolumeSelector = self.createComboBox(
         nodeTypes=["vtkMRMLScalarVolumeNode", ""])
     self.inputVolumeGroupBoxLayout.addRow(
         "ZFrame template volume: ", self.zFrameTemplateVolumeSelector)
     self.layout.addWidget(self.inputVolumeGroupBox)
     self.layout.addStretch()
     self.zFrameRegistrationManualIndexesGroupBox = qt.QGroupBox(
         "Use manual start/end indexes")
     self.zFrameRegistrationManualIndexesGroupBox.setCheckable(True)
     self.zFrameRegistrationManualIndexesGroupBoxLayout = qt.QGridLayout()
     self.zFrameRegistrationManualIndexesGroupBox.setLayout(
         self.zFrameRegistrationManualIndexesGroupBoxLayout)
     self.zFrameRegistrationManualIndexesGroupBox.checked = False
     self.zFrameRegistrationStartIndex = qt.QSpinBox()
     self.zFrameRegistrationEndIndex = qt.QSpinBox()
     hBox = qt.QWidget()
     hBox.setLayout(qt.QHBoxLayout())
     hBox.layout().addWidget(qt.QLabel("start"))
     hBox.layout().addWidget(self.zFrameRegistrationStartIndex)
     hBox.layout().addWidget(qt.QLabel("end"))
     hBox.layout().addWidget(self.zFrameRegistrationEndIndex)
     self.zFrameRegistrationManualIndexesGroupBoxLayout.addWidget(
         hBox, 1, 1, qt.Qt.AlignRight)
     self.runZFrameRegistrationButton = self.createButton(
         "",
         enabled=False,
         icon=Icons.apply,
         iconSize=iconSize,
         toolTip="Run ZFrame Registration")
     self.retryZFrameRegistrationButton = self.createButton(
         "",
         enabled=False,
         icon=Icons.retry,
         iconSize=iconSize,
         toolTip="Reset")
     self.layout.addWidget(self.zFrameRegistrationManualIndexesGroupBox)
     widget = qt.QWidget()
     widget.setLayout(qt.QHBoxLayout())
     widget.layout().addWidget(self.runZFrameRegistrationButton)
     widget.layout().addWidget(self.retryZFrameRegistrationButton)
     self.layout.addWidget(widget)
     self.layout.addStretch(1)
     self.zFrameTemplateVolumeSelector.connect(
         'currentNodeChanged(bool)', self.loadVolumeAndEnableEditor)
     self.retryZFrameRegistrationButton.clicked.connect(
         self.onRetryZFrameRegistrationButtonClicked)
     self.runZFrameRegistrationButton.clicked.connect(
         self.onApplyZFrameRegistrationButtonClicked)
Exemple #30
0
 def _setupNavigationButtons(self):
     iconSize = qt.QSize(36, 36)
     self.backButton = self.createButton("",
                                         icon=Icons.back,
                                         iconSize=iconSize,
                                         toolTip="Return to last step")
     self.finishStepButton = self.createButton(
         "",
         icon=Icons.start,
         iconSize=iconSize,
         toolTip="Run Registration/Finish Step")