Example #1
0
  def loadCheckedLoadables(self):
    """Invoke the load method on each plugin for the loadable
    (DICOMLoadable or qSlicerDICOMLoadable) instances that are selected"""
    if self.advancedViewButton.checkState() == 0:
      self.examineForLoading()

    self.loadableTable.updateSelectedFromCheckstate()

    # TODO: add check that disables all referenced stuff to be considered?
    # get all the references from the checked loadables
    referencedFileLists = []
    for plugin in self.loadablesByPlugin:
      for loadable in self.loadablesByPlugin[plugin]:
        if hasattr(loadable,'referencedInstanceUIDs'):
          instanceFileList = []
          for instance in loadable.referencedInstanceUIDs:
            instanceFile = slicer.dicomDatabase.fileForInstance(instance)
            if instanceFile != '':
              instanceFileList.append(instanceFile)
          if len(instanceFileList) and not self.isFileListInCheckedLoadables(instanceFileList):
            referencedFileLists.append(instanceFileList)

    # if applicable, find all loadables from the file lists
    loadEnabled = False
    if len(referencedFileLists):
      (self.referencedLoadables,loadEnabled) = self.getLoadablesFromFileLists(referencedFileLists)

    self.referencesDialog = None
    if loadEnabled:
      self.referencesDialog = qt.QDialog(self.window)
      self.referencesDialog.modal = True
      layout = qt.QFormLayout()
      layout.setSpacing(9)
      self.referencesDialog.setLayout(layout)
      windowTitle = "Referenced datasets found"
      self.referencesDialog.setWindowTitle(windowTitle)
      fm = qt.QFontMetrics(qt.QApplication.font(self.referencesDialog))
      self.referencesDialog.setMinimumWidth(fm.width(windowTitle)+50)
      label = qt.QLabel("The loaded DICOM objects contain references to other "
      "datasets you did not select for loading. Please confirm if you would "
      "like to load the following referenced datasets.")
      label.wordWrap = True
      layout.addRow(label)
      for plugin in self.referencedLoadables:
        for loadable in self.referencedLoadables[plugin]:
          if loadable.selected:
            cb = qt.QCheckBox(loadable.name, self.referencesDialog)
            cb.checked = True
            layout.addRow(cb)
      okButton = qt.QPushButton('Proceed')
      okButton.connect("clicked()",self.proceedWithReferencedLoadablesSelection)
      layout.addRow(okButton)
      self.referencesDialog.show()
      self.referencesDialog.adjustSize()
    else:
      self.proceedWithReferencedLoadablesSelection()

    return
Example #2
0
 def _setBasicProperties(self):
   self.layout().setSpacing(9)
   self.setWindowTitle(self.WINDOW_TITLE)
   fontMetrics = qt.QFontMetrics(qt.QApplication.font(self))
   try:
     self.setMinimumWidth(fontMetrics.horizontalAdvance(self.WINDOW_TITLE))
   except AttributeError:
     # Support Qt < 5.11 lacking QFontMetrics::horizontalAdvance()
     self.setMinimumWidth(fontMetrics.width(self.WINDOW_TITLE))
Example #3
0
 def _setBasicProperties(self):
   self.layout().setSpacing(9)
   self.setWindowTitle(self.WINDOW_TITLE)
   fontMetrics = qt.QFontMetrics(qt.QApplication.font(self))
   self.setMinimumWidth(fontMetrics.width(self.WINDOW_TITLE))
 def _getMinimumTextWidth(self, text):
     fm = qt.QFontMetrics(qt.QFont(text, 0))
     width = fm.width(text)
     return width
Example #5
0
 def getMinimumTextWidth(self, text):
     font = qt.QFont("", 0)
     metrics = qt.QFontMetrics(font)
     return metrics.width(text)