def buildInterface(self): vlayout = qt.QVBoxLayout(self) title = qt.QLabel("<B>Pixel Size Calibration<B>", self) title.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)) vlayout.addWidget(title) self.calibFrame = qt.QFrame(self) self.calibFrame.setFrameShape(qt.QFrame.Box) self.calibFrame.setFrameShadow(qt.QFrame.Sunken) vlayout.addWidget(self.calibFrame) vlayout1 = qt.QVBoxLayout(self.calibFrame) vlayout1.setMargin(10) self.table = qttable.QTable(0, 3, self.calibFrame) self.table.setFocusPolicy(qt.QWidget.NoFocus) self.table.setSelectionMode(qttable.QTable.NoSelection) self.table.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.table.verticalHeader().hide() self.table.setLeftMargin(0) self.table.setReadOnly(True) header = self.table.horizontalHeader() header.setLabel(0, "Zoom") header.setLabel(1, "Y Size (nm)") header.setLabel(2, "Z Size (nm)") self.table.clearSelection(True) vlayout1.addWidget(self.table) vlayout1.addSpacing(10) f1 = qt.QFrame(self.calibFrame) f1.setFrameShape(qt.QFrame.HLine) f1.setFrameShadow(qt.QFrame.Sunken) vlayout1.addWidget(f1) vlayout1.addSpacing(10) self.saveButton = qt.QPushButton("Save Current Calibration", self.calibFrame) self.connect(self.saveButton, qt.SIGNAL("clicked()"), self.saveCalibration) vlayout1.addWidget(self.saveButton) vlayout1.addSpacing(10) f1 = qt.QFrame(self.calibFrame) f1.setFrameShape(qt.QFrame.HLine) f1.setFrameShadow(qt.QFrame.Sunken) vlayout1.addWidget(f1) vlayout1.addSpacing(10) hlayout1 = qt.QHBoxLayout(vlayout1) self.relYLabel = qt.QLabel("Y Move:", self.calibFrame) hlayout1.addWidget(self.relYLabel) self.relYText = qt.QLineEdit("0.1", self.calibFrame) hlayout1.addWidget(self.relYText) hlayout2 = qt.QHBoxLayout(vlayout1) self.relZLabel = qt.QLabel("Z Move:", self.calibFrame) hlayout2.addWidget(self.relZLabel) self.relZText = qt.QLineEdit("0.1", self.calibFrame) hlayout2.addWidget(self.relZText) vlayout1.addSpacing(5) self.calibButton = qt.QPushButton("Start New Calibration", self.calibFrame) self.connect(self.calibButton, qt.SIGNAL("clicked()"), self.calibrationAction) vlayout1.addWidget(self.calibButton) vlayout1.addStretch(1)
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.observerTags = [] self.logic = SampleDataLogic(self.logMessage) numberOfColumns = 3 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) categories = slicer.modules.sampleDataSources.keys() categories.sort() if self.logic.builtInCategoryName in categories: categories.remove(self.logic.builtInCategoryName) categories.insert(0,self.logic.builtInCategoryName) for category in categories: if category == self.logic.developmentCategoryName and self.developerMode is False: continue frame = ctk.ctkCollapsibleGroupBox(self.parent) self.layout.addWidget(frame) frame.title = category frame.name = '%sCollapsibleGroupBox' % category layout = qt.QGridLayout(frame) columnIndex = 0 rowIndex = 0 for source in slicer.modules.sampleDataSources[category]: name = source.sampleDescription if not name: name = source.nodeNames[0] b = qt.QToolButton() b.setText(name) # Set thumbnail if source.thumbnailFileName: # Thumbnail provided thumbnailImage = source.thumbnailFileName else: # Look for thumbnail image with the name of any node name with .png extension thumbnailImage = None for nodeName in source.nodeNames: if not nodeName: continue thumbnailImageAttempt = os.path.join(iconPath, nodeName+'.png') if os.path.exists(thumbnailImageAttempt): thumbnailImage = thumbnailImageAttempt break if thumbnailImage and os.path.exists(thumbnailImage): b.setIcon(qt.QIcon(thumbnailImage)) b.setIconSize(iconSize) b.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon) qSize = qt.QSizePolicy() qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding) b.setSizePolicy(qSize) b.name = '%sPushButton' % name layout.addWidget(b, rowIndex, columnIndex) columnIndex += 1 if columnIndex==numberOfColumns: rowIndex += 1 columnIndex = 0 if source.customDownloader: b.connect('clicked()', source.customDownloader) else: b.connect('clicked()', lambda s=source: self.logic.downloadFromSource(s)) self.log = qt.QTextEdit() self.log.readOnly = True self.layout.addWidget(self.log) self.logMessage('<p>Status: <i>Idle</i>') # Add spacer to layout self.layout.addStretch(1)
def __init__(self, parent): VulnEditor.__init__(self, parent) self.vuln = None self.setSpacing(10) label = qt.QLabel(None, "Path: ", parent) self._path_edit = TextEditWidget(parent, "") self._path_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._path_edit) label = qt.QLabel(None, "Website: ", parent) self._website_edit = TextEditWidget(parent, "") self._website_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._website_edit) label = qt.QLabel(None, "Request: ", parent) self._request_edit = TextBlockEditWidget(parent, "") self._request_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding)) self.addWidget(label) self.addWidget(self._request_edit) label = qt.QLabel(None, "Response: ", parent) self._response_edit = TextBlockEditWidget(parent, "") self._response_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding)) self.addWidget(label) self.addWidget(self._response_edit) label = qt.QLabel(None, "Method: ", parent) self._method_edit = TextEditWidget(parent, "") self._method_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._method_edit) label = qt.QLabel(None, "Parameter Name: ", parent) self._pname_edit = TextEditWidget(parent, "") self._pname_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._pname_edit) label = qt.QLabel(None, "Parameters: ", parent) self._params_edit = TextEditWidget(parent, "") self._params_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._params_edit) label = qt.QLabel(None, "Query: ", parent) self._query_edit = TextEditWidget(parent, "") self._query_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._query_edit) label = qt.QLabel(None, "Category: ", parent) self._category_edit = TextEditWidget(parent, "") self._category_edit.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) self.addWidget(label) self.addWidget(self._category_edit)
def setupOptionsFrame(self): self.methodSelectorComboBox = qt.QComboBox() self.methodSelectorComboBox.addItem("Grow from seeds", GROWCUT) self.methodSelectorComboBox.addItem("Fill between parallel slices", MORPHOLOGICAL_SLICE_INTERPOLATION) self.methodSelectorComboBox.setToolTip( """<html>Auto-complete methods:<ul style="margin: 0"> <li><b>Fill between slices:</b> Perform complete segmentation on selected slices using any editor effect. The complete segmentation will be created by interpolating segmentations on slices that were skipped.</li> <li><b>Expand segments:</b> Create segments using any editor effect: one segment inside each each region that should belong to a separate segment. Segments will be expanded to create a complete segmentation, taking into account the master volume content. Minimum two segments are required. (see http://insight-journal.org/browse/publication/977)</li> </ul></html>""") self.scriptedEffect.addLabeledOptionsWidget( "Method:", self.methodSelectorComboBox) self.autoUpdateCheckBox = qt.QCheckBox("Auto-update") self.autoUpdateCheckBox.setToolTip( "Auto-update results preview when input segments change.") self.autoUpdateCheckBox.setChecked(True) self.autoUpdateCheckBox.setEnabled(False) self.previewButton = qt.QPushButton("Initialize") self.previewButton.objectName = self.__class__.__name__ + 'Preview' self.previewButton.setToolTip("Preview complete segmentation") # qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) # fails on some systems, therefore set the policies using separate method calls qSize = qt.QSizePolicy() qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding) self.previewButton.setSizePolicy(qSize) previewFrame = qt.QHBoxLayout() previewFrame.addWidget(self.autoUpdateCheckBox) previewFrame.addWidget(self.previewButton) self.scriptedEffect.addLabeledOptionsWidget("Preview:", previewFrame) self.previewOpacitySlider = ctk.ctkSliderWidget() self.previewOpacitySlider.setToolTip( "Adjust visibility of results preview.") self.previewOpacitySlider.minimum = 0 self.previewOpacitySlider.maximum = 1.0 self.previewOpacitySlider.value = 0.0 self.previewOpacitySlider.singleStep = 0.05 self.previewOpacitySlider.pageStep = 0.1 self.previewOpacitySlider.spinBoxVisible = False displayFrame = qt.QHBoxLayout() displayFrame.addWidget(qt.QLabel("inputs")) displayFrame.addWidget(self.previewOpacitySlider) displayFrame.addWidget(qt.QLabel("results")) self.scriptedEffect.addLabeledOptionsWidget("Display:", displayFrame) self.cancelButton = qt.QPushButton("Cancel") self.cancelButton.objectName = self.__class__.__name__ + 'Cancel' self.cancelButton.setToolTip("Clear preview and cancel auto-complete") self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip("Replace segments by previewed result") finishFrame = qt.QHBoxLayout() finishFrame.addWidget(self.cancelButton) finishFrame.addWidget(self.applyButton) self.scriptedEffect.addOptionsWidget(finishFrame) self.methodSelectorComboBox.connect("currentIndexChanged(int)", self.updateMRMLFromGUI) self.previewButton.connect('clicked()', self.onPreview) self.cancelButton.connect('clicked()', self.onCancel) self.applyButton.connect('clicked()', self.onApply) self.previewOpacitySlider.connect("valueChanged(double)", self.updateMRMLFromGUI) self.autoUpdateCheckBox.connect("stateChanged(int)", self.updateMRMLFromGUI)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # # Parameter Combobox # self.parameterSelector = slicer.qMRMLNodeComboBox() self.parameterLabel = qt.QLabel(" Parameter set: ") self.parameterSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"] self.parameterSelector.removeEnabled = False self.parameterSelector.showHidden = True self.parameterSelector.setMRMLScene(slicer.mrmlScene) self.parameterLayout = qt.QHBoxLayout() self.parameterLayout.addWidget(self.parameterLabel) self.parameterLayout.addWidget(self.parameterSelector) self.layout.addLayout(self.parameterLayout) # # Input Area # inputCollapsibleButton = ctk.ctkCollapsibleButton() inputCollapsibleButton.text = "Input" self.layout.addWidget(inputCollapsibleButton) # Layout within the dummy collapsible button inputFormLayout = qt.QFormLayout(inputCollapsibleButton) # # Input first DVH selector # self.dvh1Selector = slicer.qMRMLNodeComboBox() self.dvh1Selector.nodeTypes = ["vtkMRMLDoubleArrayNode"] self.dvh1Selector.removeEnabled = False self.dvh1Selector.setMRMLScene(slicer.mrmlScene) inputFormLayout.addRow("DVH 1: ", self.dvh1Selector) # # Input second DVH selector # self.dvh2Selector = slicer.qMRMLNodeComboBox() self.dvh2Selector.nodeTypes = ["vtkMRMLDoubleArrayNode"] self.dvh2Selector.removeEnabled = False self.dvh2Selector.setMRMLScene(slicer.mrmlScene) inputFormLayout.addRow("DVH 2: ", self.dvh2Selector) # # Input the dose volume # self.doseVolumeSelector = slicer.qMRMLNodeComboBox() self.doseVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.doseVolumeSelector.addAttribute("vtkMRMLScalarVolumeNode", "DicomRtImport.DoseVolume") self.doseVolumeSelector.removeEnabled = False self.doseVolumeSelector.setMRMLScene(slicer.mrmlScene) inputFormLayout.addRow("Dose Volume: ", self.doseVolumeSelector) # # Dose volume only check box # self.showDoseVolumeOnlyCheckbox = qt.QCheckBox("Show dose volume only") self.showDoseVolumeOnlyCheckbox.setChecked(2) inputFormLayout.addWidget(self.showDoseVolumeOnlyCheckbox) # # Volume difference criterion spin box # self.volumeDifferenceSpinbox = qt.QDoubleSpinBox() self.volumeDifferenceSpinbox.setValue(1.0) self.volumeDifferenceSpinbox.setDecimals(1) self.volumeDifferenceSpinbox.setSingleStep(0.1) inputFormLayout.addRow("Volume difference criterion: ", self.volumeDifferenceSpinbox) # # Dose to agreement criterion spin box # self.doseToAgreementSpinbox = qt.QDoubleSpinBox() self.doseToAgreementSpinbox.setValue(1.0) self.doseToAgreementSpinbox.setDecimals(1) self.doseToAgreementSpinbox.setSingleStep(0.1) inputFormLayout.addRow("Dose to agreement criterion: ", self.doseToAgreementSpinbox) # # Compute button # self.computeButton = qt.QPushButton("Compute") self.computeButtonLayout = qt.QVBoxLayout() self.computeButtonLayout.addStrut(100) self.computeButtonLayout.setAlignment(2) self.computeButtonLayout.addWidget(self.computeButton) self.computeButtonFont = qt.QFont() self.computeButtonFont.setBold(True) self.computeButton.setFont(self.computeButtonFont) inputFormLayout.addRow(self.computeButtonLayout) # # Output Area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" self.layout.addWidget(outputCollapsibleButton) # Layout within the dummy collapsible button outputFormLayout = qt.QFormLayout(outputCollapsibleButton) self.agreementAcceptanceOutput = qt.QLineEdit() self.agreementAcceptanceOutput.setReadOnly(True) outputFormLayout.addRow("Agreement acceptance %: ", self.agreementAcceptanceOutput) # # Visualize Area # visualizeCollapsibleButton = ctk.ctkCollapsibleButton() visualizeCollapsibleButton.text = "Visualize" sizePolicy = qt.QSizePolicy() sizePolicy.setHorizontalPolicy(qt.QSizePolicy.Preferred) sizePolicy.setVerticalPolicy(qt.QSizePolicy.Expanding) visualizeCollapsibleButton.setSizePolicy(sizePolicy) self.layout.addWidget(visualizeCollapsibleButton) # Layout within the dummy collapsible button visualizeLayout = qt.QVBoxLayout(visualizeCollapsibleButton) # # DVH Table # self.dvhTable = slicer.qMRMLTableView() self.dvhTable.setMRMLScene(slicer.mrmlScene) self.dvhTable.setSelectionMode(qt.QAbstractItemView.NoSelection) self.dvhTable.setSizePolicy(sizePolicy) visualizeLayout.addWidget(self.dvhTable) # Connections self.parameterSelector.connect('nodeAddedByUser(vtkMRMLNode*)', self.parameterNodeCreated) self.parameterSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.updateWidgetFromMRML) self.showDoseVolumeOnlyCheckbox.connect( 'stateChanged(int)', self.showDoseVolumesOnlyCheckboxChanged) self.dvh1Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh1SelectorChanged) self.dvh2Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh2SelectorChanged) self.doseVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.doseVolumeSelectorChanged) self.volumeDifferenceSpinbox.connect( "valueChanged(double)", self.volumeDifferenceSpinboxChanged) self.doseToAgreementSpinbox.connect("valueChanged(double)", self.doseToAgreementSpinboxChanged) self.computeButton.connect('clicked(bool)', self.onComputeButton) self.updateWidgetFromMRML()
def buildInterface(self): self.layout = qt.QHBoxLayout(self) self.titleLabel = QubLabel("<B>Title<B>", self) self.titleLabel.setAlignment(qt.Qt.AlignCenter) self.titleLabel.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)) self.layout.addWidget(self.titleLabel) """ move and configure appearence """ self.radioGroup = QubRadioGroup(QubRadioGroup.Horizontal, self) self.radioGroup.hide() self.connect(self.radioGroup, qt.PYSIGNAL("PositionClicked"), self.positionClicked) self.layout.addWidget(self.radioGroup) self.setButton = qt.QPushButton("Set", self) self.setButton.hide() self.connect(self.setButton, qt.SIGNAL("clicked()"), self.setPosition) self.setButton.setEnabled(False) self.layout.addWidget(self.setButton) """ display appearence """ self.valueLabel = qt.QLabel("no value", self) self.valueLabel.hide() self.valueLabel.setAlignment(qt.Qt.AlignCenter) self.layout.addWidget(self.valueLabel) """ incremental appearence """ self.frame = qt.QFrame(self) self.frame.hide() self.frame.setFrameShape(qt.QFrame.NoFrame) self.frame.setFrameShadow(qt.QFrame.Plain) self.layout.addWidget(self.frame) vlayout = qt.QVBoxLayout(self.frame) vlayout.setMargin(10) self.valueWidget = QubValue( self.frame, titleType=QubValue.Label, valueType=QubValue.Label, orientation=QubValue.Horizontal, ) self.valueWidget.setTitle("Current Position") vlayout.addWidget(self.valueWidget) vlayout.addSpacing(5) hlayout = qt.QHBoxLayout(vlayout) self.positionList = qt.QListBox(self.frame) hlayout.addWidget(self.positionList) hlayout.addSpacing(5) vlayout1 = qt.QVBoxLayout(hlayout) self.gotoButton = qt.QPushButton("Go", self.frame) self.connect(self.gotoButton, qt.SIGNAL("clicked()"), self.gotoPosition) vlayout1.addWidget(self.gotoButton) vlayout1.addStretch(1) self.addButton = qt.QPushButton("Add", self.frame) self.connect(self.addButton, qt.SIGNAL("clicked()"), self.addPosition) vlayout1.addWidget(self.addButton) vlayout1.addSpacing(5) self.remButton = qt.QPushButton("Delete", self.frame) self.connect(self.remButton, qt.SIGNAL("clicked()"), self.remPosition) vlayout1.addWidget(self.remButton) """ popup config """ self.configWindow = MultiplePositionConfigurator(self) self.popupMenu = qt.QPopupMenu(self.titleLabel) self.popupMenu.insertItem("Configure", self.configWindow.show)
def setupOptionsFrame(self): self.autoUpdateCheckBox = qt.QCheckBox("Auto-update") self.autoUpdateCheckBox.setToolTip( "Auto-update results preview when input segments change.") self.autoUpdateCheckBox.setChecked(True) self.autoUpdateCheckBox.setEnabled(False) self.previewButton = qt.QPushButton("Initialize") self.previewButton.objectName = self.__class__.__name__ + 'Preview' self.previewButton.setToolTip("Preview complete segmentation") # qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) # fails on some systems, therefore set the policies using separate method calls qSize = qt.QSizePolicy() qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding) self.previewButton.setSizePolicy(qSize) previewFrame = qt.QHBoxLayout() previewFrame.addWidget(self.autoUpdateCheckBox) previewFrame.addWidget(self.previewButton) self.scriptedEffect.addLabeledOptionsWidget("Preview:", previewFrame) self.previewOpacitySlider = ctk.ctkSliderWidget() self.previewOpacitySlider.setToolTip( "Adjust visibility of results preview.") self.previewOpacitySlider.minimum = 0 self.previewOpacitySlider.maximum = 1.0 self.previewOpacitySlider.value = 0.0 self.previewOpacitySlider.singleStep = 0.05 self.previewOpacitySlider.pageStep = 0.1 self.previewOpacitySlider.spinBoxVisible = False self.previewShow3DButton = qt.QPushButton("Show 3D") self.previewShow3DButton.setToolTip("Preview results in 3D.") self.previewShow3DButton.setCheckable(True) displayFrame = qt.QHBoxLayout() displayFrame.addWidget(qt.QLabel("inputs")) displayFrame.addWidget(self.previewOpacitySlider) displayFrame.addWidget(qt.QLabel("results")) displayFrame.addWidget(self.previewShow3DButton) self.scriptedEffect.addLabeledOptionsWidget("Display:", displayFrame) self.cancelButton = qt.QPushButton("Cancel") self.cancelButton.objectName = self.__class__.__name__ + 'Cancel' self.cancelButton.setToolTip("Clear preview and cancel auto-complete") self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip("Replace segments by previewed result") finishFrame = qt.QHBoxLayout() finishFrame.addWidget(self.cancelButton) finishFrame.addWidget(self.applyButton) self.scriptedEffect.addOptionsWidget(finishFrame) self.previewButton.connect('clicked()', self.onPreview) self.cancelButton.connect('clicked()', self.onCancel) self.applyButton.connect('clicked()', self.onApply) self.previewOpacitySlider.connect("valueChanged(double)", self.updateMRMLFromGUI) self.previewShow3DButton.connect("toggled(bool)", self.updateMRMLFromGUI) self.autoUpdateCheckBox.connect("stateChanged(int)", self.updateMRMLFromGUI)
def addIntEdit(self, name, description, minValue, maxValue, label_size=100): label = qt.QLabel(None, description, self) label.setMinimumSize(qt.QSize(label_size, 1)) self.widgets[name] = int_edit = IntEditWidget(self, 1, minValue, maxValue) int_edit.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum)) self._addWidget(label, int_edit)
are created; use QHBoxLayout and QVBoxLayout as layout managers for parent widgets when more discrete layout manageement is required + Use 'show()' on top level widgets to display that level's hierarchy """ import os import qt SIGNAL = qt.SIGNAL Qt = qt.Qt import oogui OOGui = oogui.OOGui _ANCHOR = qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) def _getLabeledFrame(w, label="", etchedBorder=0): """Utility function to create a labeled frame""" box = qt.QHGroupBox(w, label) box.setSizePolicy(_ANCHOR) box.setTitle(label) if not etchedBorder: box.setFrameShadow(qt.QFrame.Plain) box.setLineWidth(0) return box def _getLabeledList(w, label="", commandSlot=None): """Utility function to create an expanding listbox in labeled frame"""
def buildInterface(self): vlayout = qt.QVBoxLayout(self) """ title """ title = qt.QLabel("<B>Ccd Bpm<B>", self) title.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)) vlayout.addWidget(title) """ brick frame """ self.frame = qt.QFrame(self) self.frame.setFrameShape(qt.QFrame.Box) self.frame.setFrameShadow(qt.QFrame.Sunken) vlayout.addWidget(self.frame) vlay = qt.QVBoxLayout(self.frame) vlay.setMargin(10) """ create tab widget """ self.tabWidget = qt.QTabWidget(self.frame) vlay.addWidget(self.tabWidget) """ create tab for display values """ self.valuesTab = qt.QWidget(None) self.tabWidget.addTab(self.valuesTab, "Info") vlayout1 = qt.QVBoxLayout(self.valuesTab) vlayout1.setMargin(10) self.exposureLabel = QubValue(self.valuesTab, "Exposure (%)", False) titlesize = self.exposureLabel.titleSizeHint() self.exposureLabel.setText("1123.1234") valuesize = self.exposureLabel.valueSizeHint() self.exposureLabel.setText("") vlayout1.addWidget(self.exposureLabel) vlayout1.addSpacing(2) self.gainLabel = QubValue(self.valuesTab, "Gain (%)", False) vlayout1.addWidget(self.gainLabel) vlayout1.addSpacing(2) self.thresholdLabel = QubValue(self.valuesTab, "Threshold (%)", False) vlayout1.addWidget(self.thresholdLabel) vlayout1.addSpacing(10) self.centerxLabel = QubValue(self.valuesTab, "X center", False) vlayout1.addWidget(self.centerxLabel) vlayout1.addSpacing(2) self.centeryLabel = QubValue(self.valuesTab, "Y center", False) vlayout1.addWidget(self.centeryLabel) vlayout1.addSpacing(2) self.fwhmxLabel = QubValue(self.valuesTab, "X FWHM", False) vlayout1.addWidget(self.fwhmxLabel) vlayout1.addSpacing(2) self.fwhmyLabel = QubValue(self.valuesTab, "Y FWHM", False) vlayout1.addWidget(self.fwhmyLabel) vlayout1.addSpacing(2) self.intensityLabel = QubValue(self.valuesTab, "Intensity", False) vlayout1.addWidget(self.intensityLabel) vlayout1.addSpacing(2) self.maxpixLabel = QubValue(self.valuesTab, "Maximum", False) vlayout1.addWidget(self.maxpixLabel) vlayout1.addSpacing(10) self.widthLabel = QubValue(self.valuesTab, "Im. width", False) vlayout1.addWidget(self.widthLabel) vlayout1.addSpacing(2) self.heightLabel = QubValue(self.valuesTab, "Im. height", False) vlayout1.addWidget(self.heightLabel) vlayout1.addSpacing(2) self.startxLabel = QubValue(self.valuesTab, "ROI X start", False) vlayout1.addWidget(self.startxLabel) vlayout1.addSpacing(2) self.endxLabel = QubValue(self.valuesTab, "ROI X end", False) vlayout1.addWidget(self.endxLabel) vlayout1.addSpacing(2) self.startyLabel = QubValue(self.valuesTab, "ROI Y start", False) vlayout1.addWidget(self.startyLabel) vlayout1.addSpacing(2) self.endyLabel = QubValue(self.valuesTab, "ROI Y end", False) vlayout1.addWidget(self.endyLabel) vlayout1.addSpacing(20) """ create tab for control """ self.cameraTab = qt.QWidget(None) self.tabWidget.addTab(self.cameraTab, "Control") vlayout2 = qt.QVBoxLayout(self.cameraTab) vlayout2.setMargin(10) self.exposureText = QubValue(self.cameraTab, "Exposure (%)", True) self.connect(self.exposureText, qt.PYSIGNAL("returnPressed"), self.setExposure) vlayout2.addWidget(self.exposureText) vlayout2.addSpacing(2) self.gainText = QubValue(self.cameraTab, "Gain (%)", True) self.connect(self.gainText, qt.PYSIGNAL("returnPressed"), self.setGain) vlayout2.addWidget(self.gainText) vlayout2.addSpacing(2) self.thresholdText = QubValue(self.cameraTab, "Threshold (%)", True) self.connect(self.thresholdText, qt.PYSIGNAL("returnPressed"), self.setThreshold) vlayout2.addWidget(self.thresholdText) vlayout2.addSpacing(20) self.liveControlToggle = qt.QPushButton("Live mode", self.cameraTab) self.liveControlToggle.setToggleButton(True) self.connect(self.liveControlToggle, qt.SIGNAL("toggled(bool)"), self.setLive) vlayout2.addWidget(self.liveControlToggle) self.bpmControlToggle = qt.QPushButton("BPM on", self.cameraTab) self.bpmControlToggle.setToggleButton(True) self.connect(self.bpmControlToggle, qt.SIGNAL("toggled(bool)"), self.setBpm) vlayout2.addWidget(self.bpmControlToggle) vlayout2.addStretch(1) """ create Tab for ROI """ self.roiTab = qt.QWidget(None) self.tabWidget.addTab(self.roiTab, "ROI") vlayout3 = qt.QVBoxLayout(self.roiTab) vlayout3.setMargin(10) """ ROI toggle button """ hlayout3 = qt.QHBoxLayout(vlayout3) self.roiButton = qt.QPushButton("Select on Image", self.roiTab) self.roiButton.setToggleButton(True) self.connect(self.roiButton, qt.SIGNAL("toggled(bool)"), self.startROISelection) hlayout3.addWidget(self.roiButton) vlayout3.addSpacing(10) """ ROI values """ self.startxText = QubValue(self.roiTab, "X start", True) vlayout3.addWidget(self.startxText) vlayout3.addSpacing(2) self.endxText = QubValue(self.roiTab, "X end", True) vlayout3.addWidget(self.endxText) vlayout3.addSpacing(2) self.startyText = QubValue(self.roiTab, "Y start", True) vlayout3.addWidget(self.startyText) vlayout3.addSpacing(2) self.endyText = QubValue(self.roiTab, "Y end", True) vlayout3.addWidget(self.endyText) vlayout3.addSpacing(10) hlayout2 = qt.QHBoxLayout(vlayout3) self.resetButton = qt.QPushButton("Reset", self.roiTab) self.connect(self.resetButton, qt.SIGNAL("clicked()"), self.resetROI) hlayout2.addWidget(self.resetButton) hlayout2.addStretch(1) self.sendButton = qt.QPushButton("Send", self.roiTab) self.connect(self.sendButton, qt.SIGNAL("clicked()"), self.sendROI) hlayout2.addWidget(self.sendButton) vlayout3.addStretch(1) """ resize """ self.exposureText.setTitleMinimumSize(titlesize) self.gainText.setTitleMinimumSize(titlesize) self.thresholdText.setTitleMinimumSize(titlesize) self.exposureLabel.setTitleMinimumSize(titlesize) self.gainLabel.setTitleMinimumSize(titlesize) self.thresholdLabel.setTitleMinimumSize(titlesize) self.centerxLabel.setTitleMinimumSize(titlesize) self.centeryLabel.setTitleMinimumSize(titlesize) self.fwhmxLabel.setTitleMinimumSize(titlesize) self.fwhmyLabel.setTitleMinimumSize(titlesize) self.intensityLabel.setTitleMinimumSize(titlesize) self.maxpixLabel.setTitleMinimumSize(titlesize) self.widthLabel.setTitleMinimumSize(titlesize) self.heightLabel.setTitleMinimumSize(titlesize) self.startxLabel.setTitleMinimumSize(titlesize) self.endxLabel.setTitleMinimumSize(titlesize) self.startyLabel.setTitleMinimumSize(titlesize) self.endyLabel.setTitleMinimumSize(titlesize) self.startxText.setTitleMinimumSize(titlesize) self.endxText.setTitleMinimumSize(titlesize) self.startyText.setTitleMinimumSize(titlesize) self.endyText.setTitleMinimumSize(titlesize) self.exposureText.setValueMaximumSize(valuesize) self.gainText.setValueMaximumSize(valuesize) self.thresholdText.setValueMaximumSize(valuesize) self.exposureLabel.setValueMaximumSize(valuesize) self.gainLabel.setValueMaximumSize(valuesize) self.thresholdLabel.setValueMaximumSize(valuesize) self.centerxLabel.setValueMaximumSize(valuesize) self.centeryLabel.setValueMaximumSize(valuesize) self.fwhmxLabel.setValueMaximumSize(valuesize) self.fwhmyLabel.setValueMaximumSize(valuesize) self.intensityLabel.setValueMaximumSize(valuesize) self.maxpixLabel.setValueMaximumSize(valuesize) self.widthLabel.setValueMaximumSize(valuesize) self.heightLabel.setValueMaximumSize(valuesize) self.startxLabel.setValueMaximumSize(valuesize) self.endxLabel.setValueMaximumSize(valuesize) self.startyLabel.setValueMaximumSize(valuesize) self.endyLabel.setValueMaximumSize(valuesize) self.startxText.setValueMaximumSize(valuesize) self.endxText.setValueMaximumSize(valuesize) self.startyText.setValueMaximumSize(valuesize) self.endyText.setValueMaximumSize(valuesize)
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) extensionNameBox = qt.QHBoxLayout() self.extensionNameEdit = qt.QLineEdit() self.extensionNameEdit.setText('') extensionNameBox.addWidget(self.extensionNameEdit) self.extensionNameAllButton = qt.QPushButton() self.extensionNameAllButton.text = "all" self.extensionNameAllButton.toolTip = "Get statistics for all extensions" extensionNameBox.addWidget(self.extensionNameAllButton) self.populateExtensionNameEdit() parametersFormLayout.addRow("Extension name: ", extensionNameBox) 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.statsTableWidget = slicer.qMRMLTableView() self.statsTableWidget.setMRMLScene(slicer.mrmlScene) parametersFormLayout.addRow("Statistics:", self.statsTableWidget) policy = qt.QSizePolicy() policy.setVerticalStretch(1) policy.setHorizontalPolicy(qt.QSizePolicy.Expanding) policy.setVerticalPolicy(qt.QSizePolicy.Expanding) self.statsTableWidget.setSizePolicy(policy) self.statsTableNode = slicer.vtkMRMLTableNode() self.statsTableNode.SetName('ExtensionStats') self.statsTableNode.SetUseColumnNameAsColumnHeader(True) self.statsTableNode.SetUseFirstColumnAsRowHeader(True) slicer.mrmlScene.AddNode(self.statsTableNode) self.statsTableWidget.setMRMLTableNode(self.statsTableNode) # Copy to clipboard button self.copyToClipboardButton = qt.QPushButton("Copy table to clipboard") parametersFormLayout.addRow('', self.copyToClipboardButton) # connections self.extensionNameAllButton.connect('clicked()', self.populateExtensionNameEdit) self.applyButton.connect('clicked(bool)', self.onApplyButton) self.copyToClipboardButton.connect('clicked()', self.copyTableToClipboard)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # If DICOM module is the startup module then this widget will be shown # before startup completes, therefore we need to ensure here that # module discovery happens before proceeding. slicer.modules.DICOMInstance.performPostModuleDiscoveryTasks() # This module is often used in developer mode, therefore # collapse reload & test section by default. if hasattr(self, "reloadCollapsibleButton"): self.reloadCollapsibleButton.collapsed = True self.dragAndDropEventFilter = DICOMLoadingByDragAndDropEventFilter() globals()['d'] = self self.testingServer = None self.browserWidget = None # Load widget from .ui file (created by Qt Designer) uiWidget = slicer.util.loadUI(self.resourcePath('UI/DICOM.ui')) self.layout.addWidget(uiWidget) self.ui = slicer.util.childWidgetVariables(uiWidget) self.browserWidget = DICOMLib.SlicerDICOMBrowser() self.browserWidget.objectName = 'SlicerDICOMBrowser' slicer.modules.DICOMInstance.setBrowserWidgetInDICOMLayout( self.browserWidget) layoutManager = slicer.app.layoutManager() if layoutManager is not None: layoutManager.layoutChanged.connect(self.onLayoutChanged) viewArrangement = slicer.app.layoutManager().layoutLogic( ).GetLayoutNode().GetViewArrangement() self.ui.showBrowserButton.checked = ( viewArrangement == slicer.vtkMRMLLayoutNode.SlicerLayoutDicomBrowserView) # connect to the 'Show DICOM Browser' button self.ui.showBrowserButton.connect('clicked()', self.toggleBrowserWidget) self.ui.importButton.connect('clicked()', self.importFolder) self.ui.subjectHierarchyTree.setMRMLScene(slicer.mrmlScene) self.ui.subjectHierarchyTree.currentItemChanged.connect( self.onCurrentItemChanged) self.ui.subjectHierarchyTree.currentItemModified.connect( self.onCurrentItemModified) self.subjectHierarchyCurrentVisibility = False self.ui.subjectHierarchyTree.setColumnHidden( self.ui.subjectHierarchyTree.model().idColumn, True) # # DICOM networking # self.ui.networkingFrame.collapsed = True self.ui.queryServerButton.connect('clicked()', self.browserWidget.dicomBrowser, "openQueryDialog()") self.ui.toggleListener.connect('toggled(bool)', self.onToggleListener) settings = qt.QSettings() self.ui.runListenerAtStart.checked = settingsValue( 'DICOM/RunListenerAtStart', False, converter=toBool) self.ui.runListenerAtStart.connect('toggled(bool)', self.onRunListenerAtStart) # Testing server - not exposed (used for development) self.toggleServer = qt.QPushButton("Start Testing Server") self.ui.networkingFrame.layout().addWidget(self.toggleServer) self.toggleServer.connect('clicked()', self.onToggleServer) self.verboseServer = qt.QCheckBox("Verbose") self.ui.networkingFrame.layout().addWidget(self.verboseServer) # advanced options - not exposed to end users # developers can uncomment these lines to access testing server self.toggleServer.hide() self.verboseServer.hide() # # Browser settings # self.ui.browserSettingsFrame.collapsed = True self.updateDatabaseDirectoryFromBrowser( self.browserWidget.dicomBrowser.databaseDirectory) # Synchronize database selection between browser and this widget self.ui.directoryButton.directoryChanged.connect( self.updateDatabaseDirectoryFromWidget) self.ui.directoryButton.sizePolicy = qt.QSizePolicy( qt.QSizePolicy.Ignored, qt.QSizePolicy.Fixed) self.browserWidget.dicomBrowser.databaseDirectoryChanged.connect( self.updateDatabaseDirectoryFromBrowser) self.ui.browserAutoHideCheckBox.checked = not settingsValue( 'DICOM/BrowserPersistent', False, converter=toBool) self.ui.browserAutoHideCheckBox.stateChanged.connect( self.onBrowserAutoHideStateChanged) self.ui.repairDatabaseButton.connect('clicked()', self.browserWidget.dicomBrowser, "onRepairAction()") self.ui.clearDatabaseButton.connect('clicked()', self.onClearDatabase) # connect to the main window's dicom button mw = slicer.util.mainWindow() if mw: try: action = slicer.util.findChildren(mw, name='LoadDICOMAction')[0] action.connect('triggered()', self.onOpenBrowserWidget) except IndexError: logging.error( 'Could not connect to the main window DICOM button') self.databaseRefreshRequestTimer = qt.QTimer() self.databaseRefreshRequestTimer.setSingleShot(True) # If not receiving new file for 2 seconds then a database update is triggered. self.databaseRefreshRequestTimer.setInterval(2000) self.databaseRefreshRequestTimer.connect('timeout()', self.requestDatabaseRefresh) # # DICOM Plugins selection widget # self.ui.dicomPluginsFrame.collapsed = True self.pluginSelector = DICOMLib.DICOMPluginSelector( self.ui.dicomPluginsFrame) self.ui.dicomPluginsFrame.layout().addWidget(self.pluginSelector) self.checkBoxByPlugins = [] for pluginClass in slicer.modules.dicomPlugins: self.checkBox = self.pluginSelector.checkBoxByPlugin[pluginClass] self.checkBox.connect('stateChanged(int)', self.onPluginStateChanged) self.checkBoxByPlugins.append(self.checkBox)
def setElementSizePolicy(element): sizePolicy = qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(element.sizePolicy.hasHeightForWidth()) element.setSizePolicy(sizePolicy)
def __init__(self, parent=None, name="data_collect", selection_changed=None): qt.QWidget.__init__(self, parent, name) # Internal members self.collecting = False self.centring_method = 0 self.queue_hwobj = None self.queue_model_hwobj = None self.beamline_setup_hwobj = None self.sample_centring_result = gevent.event.AsyncResult() # HW-Object set by TreeBrick self.sample_changer_hwobj = None self.plate_manipulator_hwobj = None self.hl_motor_hwobj = None self.tree_brick = self.parent() self.sample_item_list = [] self.collect_tree_task = None self.user_stopped = False self.plate_sample_to_mount = None # Callbacks TODO:Document better self.selection_changed_cb = None self.collect_stop_cb = None #self.clear_centred_positions_cb = None self.run_cb = None # Layout self.setCaption("Data collect") self.confirm_dialog = ConfirmDialog(self, 'Confirm Dialog') self.confirm_dialog.setModal(True) self.pin_pixmap = Icons.load("sample_axis.png") self.task_pixmap = Icons.load("task.png") self.play_pixmap = Icons.load("VCRPlay.png") self.stop_pixmap = Icons.load("Stop.png") self.up_pixmap = Icons.load("Up2.png") self.down_pixmap = Icons.load("Down2.png") self.delete_pixmap = Icons.load("bin_small.png") self.ispyb_pixmap = Icons.load("SampleChanger2.png") self.caution_pixmap = Icons.load("Caution2.png") self.up_button = qt.QPushButton(self, "up_button") self.up_button.setPixmap(self.up_pixmap) self.up_button.setFixedHeight(25) self.delete_button = qt.QPushButton(self, "delete_button") self.delete_button.setPixmap(self.delete_pixmap) self.delete_button.setDisabled(True) qt.QToolTip.add(self.delete_button, "Delete highlighted queue entries") self.down_button = qt.QPushButton(self, "down_button") self.down_button.setPixmap(self.down_pixmap) self.down_button.setFixedHeight(25) self.collect_button = qt.QPushButton(self, "collect_button") self.collect_button.setText("Collect Queue") self.collect_button.setFixedWidth(125) self.collect_button.setIconSet(qt.QIconSet(self.play_pixmap)) self.collect_button.setPaletteBackgroundColor( widget_colors.LIGHT_GREEN) self.continue_button = qt.QPushButton(self, "ok_button") self.continue_button.setText('Pause') self.continue_button.setEnabled(True) self.continue_button.setFixedWidth(75) qt.QToolTip.add(self.continue_button, "Pause after current data collection") self.sample_list_view = qt.QListView(self, "sample_list_view") self.sample_list_view.setSelectionMode(qt.QListView.Extended) self.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)) self.sample_list_view.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding)) self.sample_list_view.setSorting(-1) self.sample_list_view.addColumn("", 280) self.sample_list_view.addColumn("", 130) self.sample_list_view.header().hide() self.sample_list_view.header().hide() self.sample_list_view.setFrameShape(qt.QListView.StyledPanel) self.sample_list_view.setFrameShadow(qt.QListView.Sunken) self.sample_list_view.setRootIsDecorated(1) self.sample_list_view.setSelected(self.sample_list_view.firstChild(), True) layout = qt.QVBoxLayout(self, 0, 0, 'main_layout') button_layout = qt.QHBoxLayout(None, 0, 0, 'button_layout') button_layout.addWidget(self.up_button) button_layout.addWidget(self.down_button) layout.setSpacing(10) layout.addWidget(self.sample_list_view) self.buttons_grid_layout = qt.QGridLayout(2, 5) layout.addLayout(self.buttons_grid_layout) self.buttons_grid_layout.addLayout(button_layout, 0, 0) self.buttons_grid_layout.addWidget(self.delete_button, 0, 4) self.buttons_grid_layout.addWidget(self.collect_button, 1, 0) self.buttons_grid_layout.addWidget(self.continue_button, 1, 4) self.clearWState(qt.Qt.WState_Polished) qt.QObject.connect(self.up_button, qt.SIGNAL("clicked()"), self.up_click) qt.QObject.connect(self.down_button, qt.SIGNAL("clicked()"), self.down_click) qt.QObject.connect(self.delete_button, qt.SIGNAL("clicked()"), self.delete_click) qt.QObject.connect(self.collect_button, qt.SIGNAL("clicked()"), self.collect_stop_toggle) qt.QObject.connect(self.sample_list_view, qt.SIGNAL("selectionChanged()"), self.sample_list_view_selection) qt.QObject.connect( self.sample_list_view, qt.SIGNAL( "contextMenuRequested(QListViewItem *, const QPoint& , int)"), self.show_context_menu) qt.QObject.connect( self.sample_list_view, qt.SIGNAL("itemRenamed(QListViewItem *, int , const QString& )"), self.item_renamed) qt.QObject.connect( self.sample_list_view, qt.SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"), self.item_double_click) qt.QObject.connect( self.sample_list_view, qt.SIGNAL( "mouseButtonClicked(int, QListViewItem *, const QPoint &, int)" ), self.item_click) qt.QObject.connect(self.confirm_dialog, qt.PYSIGNAL("continue_clicked"), self.collect_items) qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"), self.continue_button_click) self.sample_list_view.viewport().installEventFilter(self) self.setFixedWidth(415) self.collect_button.setDisabled(True)
def setupOptionsFrame(self): self.thresholdSliderLabel = qt.QLabel("Threshold Range:") self.thresholdSliderLabel.setToolTip( "Set the range of the background values that should be labeled.") self.scriptedEffect.addOptionsWidget(self.thresholdSliderLabel) self.thresholdSlider = ctk.ctkRangeWidget() self.thresholdSlider.spinBoxAlignment = qt.Qt.AlignTop self.thresholdSlider.singleStep = 0.01 self.scriptedEffect.addOptionsWidget(self.thresholdSlider) self.autoThresholdModeSelectorComboBox = qt.QComboBox() self.autoThresholdModeSelectorComboBox.addItem("auto->maximum", MODE_SET_LOWER_MAX) self.autoThresholdModeSelectorComboBox.addItem("minimum->auto", MODE_SET_MIN_UPPER) self.autoThresholdModeSelectorComboBox.addItem("as lower", MODE_SET_LOWER) self.autoThresholdModeSelectorComboBox.addItem("as upper", MODE_SET_UPPER) self.autoThresholdModeSelectorComboBox.setToolTip( "How to set lower and upper threshold values. Current refers to keeping the current value." ) self.autoThresholdMethodSelectorComboBox = qt.QComboBox() self.autoThresholdMethodSelectorComboBox.addItem("Otsu", METHOD_OTSU) self.autoThresholdMethodSelectorComboBox.addItem("Huang", METHOD_HUANG) self.autoThresholdMethodSelectorComboBox.addItem( "IsoData", METHOD_ISO_DATA) # Kittler-Illingworth sometimes fails with an exception, but it does not cause any major issue, # it just logs an error message and does not compute a new threshold value self.autoThresholdMethodSelectorComboBox.addItem( "Kittler-Illingworth", METHOD_KITTLER_ILLINGWORTH) # Li sometimes crashes (index out of range error in # ITK/Modules/Filtering/Thresholding/include/itkLiThresholdCalculator.hxx#L94) # We can add this method back when issue is fixed in ITK. #self.autoThresholdMethodSelectorComboBox.addItem("Li", METHOD_LI) self.autoThresholdMethodSelectorComboBox.addItem( "Maximum entropy", METHOD_MAXIMUM_ENTROPY) self.autoThresholdMethodSelectorComboBox.addItem( "Moments", METHOD_MOMENTS) self.autoThresholdMethodSelectorComboBox.addItem( "Renyi entropy", METHOD_RENYI_ENTROPY) self.autoThresholdMethodSelectorComboBox.addItem( "Shanbhag", METHOD_SHANBHAG) self.autoThresholdMethodSelectorComboBox.addItem( "Triangle", METHOD_TRIANGLE) self.autoThresholdMethodSelectorComboBox.addItem("Yen", METHOD_YEN) self.autoThresholdMethodSelectorComboBox.setToolTip( "Select method to compute threshold value automatically.") self.selectPreviousAutoThresholdButton = qt.QToolButton() self.selectPreviousAutoThresholdButton.text = "<" self.selectPreviousAutoThresholdButton.setToolTip( "Select previous thresholding method and set thresholds." + " Useful for iterating through all available methods.") self.selectNextAutoThresholdButton = qt.QToolButton() self.selectNextAutoThresholdButton.text = ">" self.selectNextAutoThresholdButton.setToolTip( "Select next thresholding method and set thresholds." + " Useful for iterating through all available methods.") self.setAutoThresholdButton = qt.QPushButton("Set") self.setAutoThresholdButton.setToolTip( "Set threshold using selected method.") # qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) # fails on some systems, therefore set the policies using separate method calls qSize = qt.QSizePolicy() qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding) self.setAutoThresholdButton.setSizePolicy(qSize) autoThresholdFrame = qt.QHBoxLayout() autoThresholdFrame.addWidget(self.autoThresholdModeSelectorComboBox) autoThresholdFrame.addWidget(self.autoThresholdMethodSelectorComboBox) autoThresholdFrame.addWidget(self.selectPreviousAutoThresholdButton) autoThresholdFrame.addWidget(self.selectNextAutoThresholdButton) autoThresholdFrame.addWidget(self.setAutoThresholdButton) self.scriptedEffect.addLabeledOptionsWidget("Automatic threshold:", autoThresholdFrame) self.useForPaintButton = qt.QPushButton("Use for masking") self.useForPaintButton.setToolTip( "Use specified intensity range for masking and switch to Paint effect." ) self.scriptedEffect.addOptionsWidget(self.useForPaintButton) self.applyButton = qt.QPushButton("Apply") self.applyButton.objectName = self.__class__.__name__ + 'Apply' self.applyButton.setToolTip( "Fill selected segment in regions that are in the specified intensity range." ) self.scriptedEffect.addOptionsWidget(self.applyButton) self.useForPaintButton.connect('clicked()', self.onUseForPaint) self.thresholdSlider.connect('valuesChanged(double,double)', self.onThresholdValuesChanged) self.autoThresholdMethodSelectorComboBox.connect( "activated(int)", self.onSelectedAutoThresholdMethod) self.autoThresholdModeSelectorComboBox.connect( "activated(int)", self.onSelectedAutoThresholdMethod) self.selectPreviousAutoThresholdButton.connect( 'clicked()', self.onSelectPreviousAutoThresholdMethod) self.selectNextAutoThresholdButton.connect( 'clicked()', self.onSelectNextAutoThresholdMethod) self.setAutoThresholdButton.connect('clicked()', self.onAutoThreshold) self.applyButton.connect('clicked()', self.onApply)
def _createSmall(self): """Make the internals of the widget to display in the Data Probe frame (lower left of slicer main window by default)""" # this method makes SliceView Annotation self.sliceAnnotations = DataProbeLib.SliceAnnotations() # goto module button self.goToModule = qt.QPushButton('->', self.frame) self.goToModule.setToolTip('Go to the DataProbe module for more information and options') self.frame.layout().addWidget(self.goToModule) self.goToModule.connect("clicked()", self.onGoToModule) # hide this for now - there's not much to see in the module itself self.goToModule.hide() # image view self.showImageBox = qt.QCheckBox('Show Zoomed Slice', self.frame) self.frame.layout().addWidget(self.showImageBox) self.showImageBox.connect("toggled(bool)", self.onShowImage) self.showImageBox.setChecked(False) self.imageLabel = qt.QLabel() # qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) # fails on some systems, therefore set the policies using separate method calls qSize = qt.QSizePolicy() qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding) qSize.setVerticalPolicy(qt.QSizePolicy.Expanding) self.imageLabel.setSizePolicy(qSize) #self.imageLabel.setScaledContents(True) self.frame.layout().addWidget(self.imageLabel) self.onShowImage(False) # top row - things about the viewer itself self.viewerFrame = qt.QFrame(self.frame) self.viewerFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.viewerFrame) self.viewerColor = qt.QLabel(self.viewerFrame) self.viewerFrame.layout().addWidget(self.viewerColor) self.viewInfo = qt.QLabel() self.viewerFrame.layout().addWidget(self.viewInfo) self.viewerFrame.layout().addStretch(1) def _setFixedFontFamily(widget, family='Monospace'): font = widget.font font.setFamily(family) widget.font = font _setFixedFontFamily(self.viewInfo) # the grid - things about the layers # this method makes labels self.layerGrid = qt.QFrame(self.frame) layout = qt.QGridLayout() self.layerGrid.setLayout(layout) self.frame.layout().addWidget(self.layerGrid) layers = ('L', 'F', 'B') self.layerNames = {} self.layerIJKs = {} self.layerValues = {} for (row, layer) in enumerate(layers): col = 0 layout.addWidget(qt.QLabel(layer), row, col) col += 1 self.layerNames[layer] = qt.QLabel() layout.addWidget(self.layerNames[layer], row, col) col += 1 self.layerIJKs[layer] = qt.QLabel() layout.addWidget(self.layerIJKs[layer], row, col) col += 1 self.layerValues[layer] = qt.QLabel() layout.addWidget(self.layerValues[layer], row, col) layout.setColumnStretch(col, 100) _setFixedFontFamily(self.layerNames[layer]) _setFixedFontFamily(self.layerIJKs[layer]) _setFixedFontFamily(self.layerValues[layer]) # information collected about the current crosshair position # from displayable managers registered to the current view self.displayableManagerInfo = qt.QLabel() self.displayableManagerInfo.indent = 6 self.displayableManagerInfo.wordWrap = True self.frame.layout().addWidget(self.displayableManagerInfo) # only show if not empty self.displayableManagerInfo.hide() # goto module button self.goToModule = qt.QPushButton('->', self.frame) self.goToModule.setToolTip('Go to the DataProbe module for more information and options') self.frame.layout().addWidget(self.goToModule) self.goToModule.connect("clicked()", self.onGoToModule) # hide this for now - there's not much to see in the module itself self.goToModule.hide()
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)