def create(self,widgetType='window',showHeader=False,showPreview=False): """ main window is a frame with widgets from the app widget repacked into it along with slicer-specific extra widgets """ # find internals of widget for reference and repacking self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0] self.databaseNameLabel = slicer.util.findChildren(self.dicomBrowser, 'DatabaseNameLabel')[0] self.databaseDirectoryButton = slicer.util.findChildren(self.dicomBrowser, 'DirectoryButton')[0] self.tableDensityLabel = qt.QLabel('Density: ') self.tableDensityLabel.objectName = 'tablesDensityLabel' self.tableDensityComboBox = slicer.util.findChildren(self.dicomBrowser, 'tableDensityComboBox')[0] self.tableDensityComboBox.connect('currentIndexChanged(QString)', self.onTableDensityComboBox) index = self.tableDensityComboBox.findText(self.tableDensity) if (index != -1) : self.tableDensityComboBox.setCurrentIndex(index) # # create and configure the Slicer browser widget - this involves # reaching inside and manipulating the widget hierarchy # - TODO: this configurability should be exposed more natively # in the CTK code to avoid the findChildren calls # self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0] patientTable = slicer.util.findChildren(self.tables, 'patientsTable')[0] patientTableView = slicer.util.findChildren(patientTable, 'tblDicomDatabaseView')[0] patientSearchBox = slicer.util.findChildren(patientTable, 'leSearchBox')[0] studyTable = slicer.util.findChildren(self.tables, 'studiesTable')[0] studyTableView = slicer.util.findChildren(studyTable, 'tblDicomDatabaseView')[0] studySearchBox = slicer.util.findChildren(studyTable, 'leSearchBox')[0] seriesTable = slicer.util.findChildren(self.tables, 'seriesTable')[0] seriesTableView = slicer.util.findChildren(seriesTable, 'tblDicomDatabaseView')[0] seriesSearchBox = slicer.util.findChildren(seriesTable, 'leSearchBox')[0] self.tableSplitter = qt.QSplitter() self.tableSplitter.addWidget(patientTableView) self.tableSplitter.addWidget(studyTableView) self.tableSplitter.addWidget(seriesTableView) # TODO: Move to this part to CTK patientTableView.resizeColumnsToContents() studyTableView.resizeColumnsToContents() seriesTableView.resizeColumnsToContents() self.userFrame = qt.QWidget() self.preview = qt.QWidget() self.widgetType = widgetType if widgetType == 'dialog': self.window = qt.QDialog(self.dicomBrowser) elif widgetType == 'window': self.window = qt.QWidget() elif widgetType == 'popup': self.window = ctk.ctkPopupWidget(self.dicomBrowser) self.window.orientation = 1 self.window.horizontalDirection = 0 self.window.alignment = 0x82 elif widgetType == 'dock': self.dock = qt.QDockWidget(slicer.util.mainWindow()) self.dock.setFeatures( qt.QDockWidget.DockWidgetFloatable | qt.QDockWidget.DockWidgetMovable | qt.QDockWidget.DockWidgetClosable ) slicer.util.mainWindow().addDockWidget(0x15, self.dock) self.window = qt.QFrame() self.dock.setWidget(self.window) else: raise "Unknown widget type - should be dialog, window, dock or popup" self.window.objectName = 'SlicerDICOMBrowser' self.setModality(not self.browserPersistent) self.window.setWindowTitle('DICOM Browser') self.layout = qt.QVBoxLayout(self.window) # tool row at top, with commands and database self.toolFrame = qt.QWidget() self.toolFrame.setMaximumHeight(40) self.toolFrame.setContentsMargins(-5,-5,-5,-5) self.toolLayout = qt.QHBoxLayout(self.toolFrame) self.layout.addWidget(self.toolFrame) self.toolLayout.addWidget(self.toolBar) self.settingsButton = ctk.ctkExpandButton() self.toolLayout.addWidget(self.settingsButton) self.toolLayout.addWidget(self.databaseNameLabel) self.databaseNameLabel.visible = False self.toolLayout.addWidget(self.databaseDirectoryButton) self.databaseDirectoryButton.visible = False self.toolLayout.addWidget(self.tableDensityLabel) self.tableDensityLabel.visible = False self.toolLayout.addWidget(self.tableDensityComboBox) self.tableDensityComboBox.visible = False self.settingsButton.connect('toggled(bool)', self.onSettingsButton) # enable export button and make new connection self.actionExport = self.dicomBrowser.findChildren('QAction', 'ActionExport')[0] self.actionExport.enabled = 1 self.actionExport.connect('triggered()', self.onExportAction) # search row self.searchFrame = qt.QWidget() self.searchFrame.setMaximumHeight(40) self.searchLayout = qt.QHBoxLayout(self.searchFrame) self.layout.addWidget(self.searchFrame) patinetsLabel = qt.QLabel('Patients: ') self.searchLayout.addWidget(patinetsLabel) self.searchLayout.addWidget(patientSearchBox) studiesLabel = qt.QLabel('Studies: ') self.searchLayout.addWidget(studiesLabel) self.searchLayout.addWidget(studySearchBox) seriesLabel = qt.QLabel('Series: ') self.searchLayout.addWidget(seriesLabel) self.searchLayout.addWidget(seriesSearchBox) # tables goes next, spread across 1 row, 2 columns if self.horizontalTables: self.tableSplitter.setOrientation(1) else: self.tableSplitter.setOrientation(0) self.layout.addWidget(self.tableSplitter) # # preview related column # self.previewLayout = qt.QVBoxLayout() if showPreview: self.previewLayout.addWidget(self.preview) else: self.preview.hide() # # action related column (interacting with slicer) # self.loadableTableFrame = qt.QWidget() self.loadableTableFrame.setMaximumHeight(200) self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame) self.layout.addWidget(self.loadableTableFrame) self.loadableTableLayout.addWidget(self.userFrame) self.userFrame.hide() tableWidth = 350 if showHeader else 600 self.loadableTable = DICOMLoadableTable(self.userFrame,width=tableWidth) # # button row for action column # self.actionButtonsFrame = qt.QWidget() self.actionButtonsFrame.setMaximumHeight(40) self.actionButtonsFrame.objectName = 'ActionButtonsFrame' self.layout.addWidget(self.actionButtonsFrame) self.actionButtonLayout = qt.QHBoxLayout() self.actionButtonsFrame.setLayout(self.actionButtonLayout) self.loadButton = qt.QPushButton('Load') self.loadButton.enabled = True self.loadButton.toolTip = 'Load Selection to Slicer' self.actionButtonLayout.addWidget(self.loadButton) self.loadButton.connect('clicked()', self.loadCheckedLoadables) self.headerPopup = DICOMLib.DICOMHeaderPopup() self.viewMetadataButton = qt.QPushButton('Metadata') self.viewMetadataButton.objectName = 'ActionViewMetadata' self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series' self.viewMetadataButton.enabled = False self.actionButtonLayout.addWidget(self.viewMetadataButton) self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton) self.viewMetadataButton.connect('clicked()', self.headerPopup.open) self.actionButtonLayout.addStretch(1) self.examineButton = qt.QPushButton('Examine') self.actionButtonLayout.addWidget(self.examineButton) self.examineButton.enabled = False self.examineButton.connect('clicked()', self.examineForLoading) self.uncheckAllButton = qt.QPushButton('Uncheck All') self.actionButtonLayout.addWidget(self.uncheckAllButton) self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables) self.actionButtonLayout.addStretch(1) self.advancedViewButton = qt.QCheckBox('Advanced') self.advancedViewButton.objectName = 'AdvancedViewCheckBox' self.actionButtonLayout.addWidget(self.advancedViewButton) self.advancedViewButton.enabled = True self.advancedViewButton.checked = self.advancedView self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton) self.horizontalViewCheckBox = qt.QCheckBox('Horizontal') self.horizontalViewCheckBox.objectName = 'HorizontalViewCheckBox' self.horizontalViewCheckBox.checked = self.horizontalTables self.horizontalViewCheckBox.connect('clicked()', self.onHorizontalViewCheckBox) self.actionButtonLayout.addWidget(self.horizontalViewCheckBox) self.toolLayout.addStretch(1) self.browserPersistentButton = qt.QCheckBox('Browser Persistent') self.browserPersistentButton.objectName = 'BrowserPersistentCheckBox' self.browserPersistentButton.toolTip = 'When enabled, DICOM Browser remains open after loading data or switching to another module' self.browserPersistentButton.checked = self.browserPersistent self.actionButtonLayout.addWidget(self.browserPersistentButton) self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence) if self.advancedView: self.loadableTableFrame.visible = True else: self.loadableTableFrame.visible = False self.examineButton.visible = False self.uncheckAllButton.visible = False # # header related column (more details about the selected file) # if showHeader: self.headerLayout = qt.QVBoxLayout() self.layout.addLayout(self.headerLayout,selectionRow,2) self.header = DICOMHeaderWidget(self.window) self.headerLayout.addWidget(self.header.widget) # # Series selection # self.tables.connect('seriesSelectionChanged(QStringList)', self.onSeriesSelected) # # Plugin selection widget # self.pluginSelector = DICOMPluginSelector(self.window) self.loadableTableLayout.addRow(self.pluginSelector.widget,self.loadableTable.widget) 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 create(self, widgetType='window', showHeader=False, showPreview=False): """ main window is a frame with widgets from the app widget repacked into it along with slicer-specific extra widgets """ # find internals of widget for reference and repacking self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0] self.databaseNameLabel = slicer.util.findChildren( self.dicomBrowser, 'DatabaseNameLabel')[0] self.databaseDirectoryButton = slicer.util.findChildren( self.dicomBrowser, 'DirectoryButton')[0] #self.tables = self.dicomBrowser.tableManager self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0] #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0] self.userFrame = qt.QWidget() #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0] #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0] self.preview = qt.QWidget() self.widgetType = widgetType if widgetType == 'dialog': self.window = qt.QDialog(self.dicomBrowser) elif widgetType == 'window': self.window = qt.QWidget() elif widgetType == 'popup': self.window = ctk.ctkPopupWidget(self.dicomBrowser) self.window.orientation = 1 self.window.horizontalDirection = 0 self.window.alignment = 0x82 elif widgetType == 'dock': self.dock = qt.QDockWidget(slicer.util.mainWindow()) self.dock.setFeatures(qt.QDockWidget.DockWidgetFloatable | qt.QDockWidget.DockWidgetMovable | qt.QDockWidget.DockWidgetClosable) slicer.util.mainWindow().addDockWidget(0x15, self.dock) self.window = qt.QFrame() self.dock.setWidget(self.window) else: raise "Unknown widget type - should be dialog, window, dock or popup" self.window.setWindowTitle('DICOM Browser') self.layout = qt.QVBoxLayout(self.window) # tool row at top, with commands and database self.toolFrame = qt.QWidget() self.toolFrame.setMaximumHeight(40) self.toolLayout = qt.QHBoxLayout(self.toolFrame) self.layout.addWidget(self.toolFrame) self.toolLayout.addWidget(self.toolBar) self.toolLayout.addWidget(self.databaseNameLabel) self.databaseNameLabel.visible = False self.toolLayout.addWidget(self.databaseDirectoryButton) self.databaseDirectoryButton.visible = False self.settingsButton = ctk.ctkExpandButton() self.toolBar.addWidget(self.settingsButton) self.settingsButton.connect('toggled(bool)', self.onSettingsButton) # tables goes next, spread across 1 row, 2 columns self.tables.tableOrientation = self.tableOrientation self.tables.dynamicTableLayout = False self.tablesExpandableWidget = ctk.ctkExpandableWidget() self.tablesLayout = qt.QVBoxLayout(self.tablesExpandableWidget) self.tablesLayout.addWidget(self.tables) self.tablesExpandableWidget.setMinimumHeight(400) self.layout.addWidget(self.tablesExpandableWidget) # # preview related column # self.previewLayout = qt.QVBoxLayout() #self.layout.addLayout(self.previewLayout,selectionRow,0) #self.previewLayout.addWidget(self.thumbs) #self.previewLayout.addWidget(self.widthSlider) if showPreview: self.previewLayout.addWidget(self.preview) else: self.preview.hide() # # action related column (interacting with slicer) # self.loadableTableFrame = qt.QWidget() self.loadableTableLayout = qt.QFormLayout(self.loadableTableFrame) self.layout.addWidget(self.loadableTableFrame) self.loadableTableLayout.addWidget(self.userFrame) self.userFrame.hide() tableWidth = 350 if showHeader else 600 self.loadableTable = DICOMLoadableTable(self.userFrame, width=tableWidth) #self.loadableTableLayout.addWidget(self.loadableTable.widget) #self.loadableTable.widget.hide() # # button row for action column # self.actionButtonsFrame = qt.QWidget() self.actionButtonsFrame.setMaximumHeight(40) self.layout.addWidget(self.actionButtonsFrame) #self.layout.addStretch(1) self.actionButtonLayout = qt.QHBoxLayout() self.actionButtonsFrame.setLayout(self.actionButtonLayout) self.loadButton = qt.QPushButton('Load') self.loadButton.enabled = True self.loadButton.toolTip = 'Load Selection to Slicer' self.actionButtonLayout.addWidget(self.loadButton) self.loadButton.connect('clicked()', self.loadCheckedLoadables) self.headerPopup = DICOMLib.DICOMHeaderPopup() self.viewMetadataButton = qt.QPushButton('Metadata') self.viewMetadataButton.toolTip = 'Display Metadata of the Selected Series' self.viewMetadataButton.enabled = False self.actionButtonLayout.addWidget(self.viewMetadataButton) self.viewMetadataButton.connect('clicked()', self.onViewHeaderButton) self.viewMetadataButton.connect('clicked()', self.headerPopup.open) self.actionButtonLayout.addStretch(1) self.examineButton = qt.QPushButton('Examine') self.actionButtonLayout.addWidget(self.examineButton) self.examineButton.enabled = False self.examineButton.connect('clicked()', self.examineForLoading) self.uncheckAllButton = qt.QPushButton('Uncheck All') self.actionButtonLayout.addWidget(self.uncheckAllButton) self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables) self.actionButtonLayout.addStretch(1) self.closeButton = qt.QPushButton('Close') #self.actionButtonLayout.addWidget(self.closeButton) self.closeButton.connect('clicked()', self.close) self.advancedViewButton = qt.QCheckBox('Advanced') self.actionButtonLayout.addWidget(self.advancedViewButton) self.advancedViewButton.enabled = True self.advancedViewButton.checked = self.advancedViewCheckState self.advancedViewButton.connect('clicked()', self.onAdvanedViewButton) self.horizontalViewCheckBox = qt.QCheckBox('Horizontal Tables') self.horizontalViewCheckBox.visible = False self.toolLayout.addWidget(self.horizontalViewCheckBox) self.horizontalViewCheckBox.enabled = True if self.tableOrientation == 1: self.horizontalViewCheckBox.checked = True self.horizontalViewCheckBox.connect('stateChanged(int)', self.onHorizontalViewCheckBox) if self.setBrowserPersistence: self.browserPersistentButton = qt.QCheckBox('Browser Persistent') self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module' self.actionButtonLayout.addWidget(self.browserPersistentButton) self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence) if self.advancedViewCheckState == True: self.loadableTableFrame.show() self.window.adjustSize() else: self.examineButton.hide() self.uncheckAllButton.hide() self.loadableTableFrame.hide() self.window.adjustSize() # # header related column (more details about the selected file) # if showHeader: self.headerLayout = qt.QVBoxLayout() self.layout.addLayout(self.headerLayout, selectionRow, 2) self.header = DICOMHeaderWidget(self.window) self.headerLayout.addWidget(self.header.widget) # # Plugin selection widget # self.pluginSelector = DICOMPluginSelector(self.window) self.loadableTableLayout.addRow(self.pluginSelector.widget, self.loadableTable.widget) 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 create(self, widgetType='window', showHeader=False, showPreview=False): """ main window is a frame with widgets from the app widget repacked into it along with slicer-specific extra widgets """ # find internals of widget for reference and repacking self.toolBar = slicer.util.findChildren(self.dicomBrowser, 'ToolBar')[0] self.databaseNameLabel = slicer.util.findChildren( self.dicomBrowser, 'DatabaseNameLabel')[0] self.databaseDirectoryButton = slicer.util.findChildren( self.dicomBrowser, 'DirectoryButton')[0] #self.tables = self.dicomBrowser.tableManager self.tables = slicer.util.findChildren(self.dicomBrowser, 'dicomTableManager')[0] #self.userFrame = slicer.util.findChildren(self.dicomBrowser, 'UserFrame')[0] self.userFrame = qt.QWidget() #self.thumbs = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailsWidget')[0] #self.widthSlider = slicer.util.findChildren(self.dicomBrowser, 'ThumbnailWidthSlider')[0] self.preview = qt.QWidget() self.widgetType = widgetType if widgetType == 'dialog': self.window = qt.QDialog(self.dicomBrowser) elif widgetType == 'window': self.window = qt.QWidget() elif widgetType == 'popup': self.window = ctk.ctkPopupWidget(self.dicomBrowser) self.window.orientation = 1 self.window.horizontalDirection = 0 self.window.alignment = 0x82 elif widgetType == 'dock': self.dock = qt.QDockWidget(slicer.util.mainWindow()) self.dock.setFeatures(qt.QDockWidget.DockWidgetFloatable | qt.QDockWidget.DockWidgetMovable | qt.QDockWidget.DockWidgetClosable) slicer.util.mainWindow().addDockWidget(0x15, self.dock) self.window = qt.QFrame() self.dock.setWidget(self.window) else: raise "Unknown widget type - should be dialog, window, dock or popup" self.window.setWindowTitle('DICOM Details') self.layout = qt.QGridLayout() self.window.setLayout(self.layout) # overall layout - tables on top, preview and selection below toolRow = 0 tablesRow = 1 selectionRow = 2 # tool row at top, with commands and database self.toolLayout = qt.QHBoxLayout() self.layout.addLayout(self.toolLayout, toolRow, 0, 1, 2) self.toolLayout.addWidget(self.toolBar) self.toolLayout.addWidget(self.databaseNameLabel) self.toolLayout.addWidget(self.databaseDirectoryButton) # tables goes next, spread across 1 row, 2 columns qt_Horizontal = 0x1 qt_Vertical = 0x2 self.tables.tableOrientation = qt_Vertical self.layout.addWidget(self.tables, tablesRow, 0, 1, 3) # # preview related column # self.previewLayout = qt.QVBoxLayout() self.layout.addLayout(self.previewLayout, selectionRow, 0) #self.previewLayout.addWidget(self.thumbs) #self.previewLayout.addWidget(self.widthSlider) if showPreview: self.previewLayout.addWidget(self.preview) else: self.preview.hide() # # action related column (interacting with slicer) # self.actionLayout = qt.QVBoxLayout() self.layout.addLayout(self.actionLayout, selectionRow, 1, 2) self.actionLayout.addWidget(self.userFrame) tableWidth = 350 if showHeader else 700 self.loadableTable = DICOMLoadableTable(self.userFrame, width=tableWidth) self.actionLayout.addWidget(self.loadableTable.widget) # # button row for action column # self.actionButtonLayout = qt.QHBoxLayout() self.actionLayout.addLayout(self.actionButtonLayout) self.examineButton = qt.QPushButton('Examine for Loading') self.actionButtonLayout.addWidget(self.examineButton) self.examineButton.enabled = False self.examineButton.connect('clicked()', self.examineForLoading) self.uncheckAllButton = qt.QPushButton('Uncheck All') self.actionButtonLayout.addWidget(self.uncheckAllButton) self.uncheckAllButton.connect('clicked()', self.uncheckAllLoadables) self.loadButton = qt.QPushButton('Load Selection to Slicer') self.loadButton.enabled = False self.actionButtonLayout.addWidget(self.loadButton) self.loadButton.connect('clicked()', self.loadCheckedLoadables) self.headerPopup = DICOMLib.DICOMHeaderPopup() self.viewHeaderButton = qt.QPushButton('View Header') self.viewHeaderButton.enabled = False self.actionButtonLayout.addWidget(self.viewHeaderButton) self.viewHeaderButton.connect('clicked()', self.onViewHeaderButton) self.viewHeaderButton.connect('clicked()', self.headerPopup.open) self.closeButton = qt.QPushButton('Close') self.actionButtonLayout.addWidget(self.closeButton) self.closeButton.connect('clicked()', self.close) if self.setBrowserPersistence: self.browserPersistentButton = qt.QCheckBox( 'Make DICOM Browser Persistent') self.browserPersistentButton.toolTip = 'When enabled, DICOM Broswer remains open and usable after leaving DICOM module' self.actionLayout.addWidget(self.browserPersistentButton) self.browserPersistentButton.connect('stateChanged(int)', self.setBrowserPersistence) # # header related column (more details about the selected file) # if showHeader: self.headerLayout = qt.QVBoxLayout() self.layout.addLayout(self.headerLayout, selectionRow, 2) self.header = DICOMHeaderWidget(self.window) self.headerLayout.addWidget(self.header.widget) # # Plugin selection widget # self.pluginSelector = DICOMPluginSelector(self.window) self.layout.addWidget(self.pluginSelector.widget, selectionRow, 0)