def scalePixmap(self,pixmap): # extract the center of the pixmap and then zoom halfWidth = self.width/2 halfHeight = self.height/2 quarterWidth = self.width/4 quarterHeight = self.height/4 centerPixmap = qt.QPixmap(halfWidth,halfHeight) centerPixmap.fill(self.gray) self.painter.begin(centerPixmap) fullRect = qt.QRect(0,0,halfWidth,halfHeight) centerRect = qt.QRect(quarterWidth, quarterHeight, halfWidth, halfHeight) self.painter.drawPixmap(fullRect, pixmap, centerRect) self.painter.end() scaledPixmap = centerPixmap.scaled(self.width, self.height) return scaledPixmap
def __init__(self, dicomBrowser, setBrowserPersistence=None): self.dicomBrowser = dicomBrowser self.setBrowserPersistence = setBrowserPersistence self.popupGeometry = qt.QRect() settings = qt.QSettings() self.advancedViewCheckState = False self.horizontalOrientation = 0x1 self.verticalOrientation = 0x2 self.tableOrientation = self.verticalOrientation if settings.contains('DICOM/detailsPopup.geometry'): self.popupGeometry = settings.value('DICOM/detailsPopup.geometry') if settings.contains('DICOM/advancedViewToggled'): self.advancedViewCheckState = True if settings.contains('DICOM/tableOrientation'): self.tableOrientation = int( settings.value('DICOM/tableOrientation')) self.create() self.popupPositioned = False self.pluginInstances = {} self.fileLists = []
def __init__(self,dicomBrowser): self.dicomBrowser = dicomBrowser self.popupGeometry = qt.QRect() settings = qt.QSettings() self.browserPersistent = False if settings.contains('DICOM/BrowserPersistent'): self.browserPersistent = settings.value('DICOM/BrowserPersistent').lower() == 'true' if settings.contains('DICOM/tableDensity'): self.tableDensity = settings.value('DICOM/tableDensity') else: self.tableDensity = 'Compact' if settings.contains('DICOM/detailsPopup.geometry'): self.popupGeometry = settings.value('DICOM/detailsPopup.geometry') if settings.contains('DICOM/advancedView'): self.advancedView = int(settings.value('DICOM/advancedView')) else: self.advancedView= 0 if settings.contains('DICOM/horizontalTables'): self.horizontalTables = int(settings.value('DICOM/horizontalTables')) else: self.horizontalTables = 0 self.create() self.popupPositioned = False self.pluginInstances = {} self.fileLists = []
def __init__(self, dicomApp, setBrowserPersistence=None): self.dicomApp = dicomApp self.setBrowserPersistence = setBrowserPersistence self.popupGeometry = qt.QRect() settings = qt.QSettings() if settings.contains('DICOM/detailsPopup.geometry'): self.popupGeometry = settings.value('DICOM/detailsPopup.geometry') self.create() self.popupPositioned = False self.pluginInstances = {}
def __init__(self): self.popupGeometry = qt.QRect() settings = qt.QSettings() if settings.contains('DICOM/headerPopup.geometry'): self.popupGeometry = settings.value('DICOM/headerPopup.geometry') self.popupPositioned = False self.window = ctk.ctkDICOMObjectListWidget() self.window.setWindowTitle('DICOM File Metadata') self.layout = qt.QGridLayout() self.window.setLayout(self.layout)
def createNewSliceWidget(self, cmd): import qt import slicer p = urlparse.urlparse(cmd) q = urlparse.parse_qs(p.query) try: ID = str(q['ID'][0].strip()) except KeyError: ID = 'vtkMRMLScalarVolumeNode2' formattedDate = "N/A" if ID not in SlicerRequestHandler.sliceWidgets: #create slice node sliceNode = slicer.vtkMRMLSliceNode() sliceNode.SetName(ID + "SliceNode") sliceNode.SetLayoutName(ID) sliceNode.SetLayoutLabel("VR") sliceNode.SetLayoutColor(1, 0, 0.93) #create slice widget slicer.mrmlScene.AddNode(sliceNode) sliceWidget = slicer.app.layoutManager().sliceWidget(ID) sliceWidget.setWindowFlags(qt.Qt.Window) #create new window with the slice widget sliceWidget.setGeometry(qt.QRect(0, 0, 400, 400)) sliceNode.SetDimensions(400, 400, 1) compNode = sliceWidget.sliceLogic().GetSliceCompositeNode() compNode.SetBackgroundVolumeID(ID) sliceWidget.show() SlicerRequestHandler.sliceWidgets[ID] = sliceWidget #sliceWidget.sliceLogic().StartSliceNodeInteraction(slicer.vtkMRMlSliceNode.ResetFieldofViewFlag) sliceWidget.sliceLogic().FitSliceToAll() #sliceNode.UpdateMatrices() #sliceWidget.sliceLogic().EndSliceNodeInteraction() #sliceWidget.hide() uids = slicer.util.getNode(ID).GetAttribute("DICOM.instanceUIDs") firstUid = uids.split(" ")[0] rawDate = slicer.dicomDatabase.instanceValue( firstUid, "0008,0020").encode("ascii") formattedDate = datetime.date(int(rawDate[0:4]), int(rawDate[4:6]), int(rawDate[6:8])).strftime('%B %d, %Y') return formattedDate
def revealPixmap(self, xy): """fill a pixmap with an image that has a reveal pattern at xy with the fg drawn over the bg""" # Get QImages for the two layers bgVTKImage = self.layerLogics['B'].GetImageData() fgVTKImage = self.layerLogics['F'].GetImageData() bgQImage = qt.QImage() fgQImage = qt.QImage() slicer.qMRMLUtils().vtkImageDataToQImage(bgVTKImage, bgQImage) slicer.qMRMLUtils().vtkImageDataToQImage(fgVTKImage, fgQImage) # get the geometry of the focal point (xy) and images # noting that vtk has the origin at the bottom left and qt has # it at the top left. yy is the flipped version of y imageWidth = bgQImage.width() imageHeight = bgQImage.height() x, y = xy yy = imageHeight - y # # make a generally transparent image, # then fill quadrants with the fg image # overlayImage = qt.QImage(imageWidth, imageHeight, qt.QImage().Format_ARGB32) overlayImage.fill(0) halfWidth = imageWidth / 2 halfHeight = imageHeight / 2 topLeft = qt.QRect(0, 0, x, yy) bottomRight = qt.QRect(x, yy, imageWidth - x - 1, imageHeight - yy - 1) self.painter.begin(overlayImage) self.painter.drawImage(topLeft, fgQImage, topLeft) self.painter.drawImage(bottomRight, fgQImage, bottomRight) self.painter.end() # draw the bg and fg on top of gray background compositePixmap = qt.QPixmap(self.width, self.height) compositePixmap.fill(self.gray) self.painter.begin(compositePixmap) self.painter.drawImage(-1 * (x - self.width / 2), -1 * (yy - self.height / 2), bgQImage) self.painter.drawImage(-1 * (x - self.width / 2), -1 * (yy - self.height / 2), overlayImage) self.painter.end() if self.scale: compositePixmap = self.scalePixmap(compositePixmap) # draw a border around the pixmap self.painter.begin(compositePixmap) self.pen = qt.QPen() self.color = qt.QColor("#FF0") self.color.setAlphaF(0.3) self.pen.setColor(self.color) self.pen.setWidth(5) self.pen.setStyle(3) # dotted line (Qt::DotLine) self.painter.setPen(self.pen) rect = qt.QRect(1, 1, self.width - 2, self.height - 2) self.painter.drawRect(rect) self.painter.end() return compositePixmap
def __init__(self): self.dataProbeUtil = DataProbeUtil.DataProbeUtil() self.dicomVolumeNode = 0 self.sliceViewNames = [] self.popupGeometry = qt.QRect() self.cornerTexts =[] # Bottom Left Corner Text self.cornerTexts.append({ '1-Label':{'text':'','category':'A'}, '2-Foreground':{'text':'','category':'A'}, '3-Background':{'text':'','category':'A'} }) # Bottom Right Corner Text # Not used - orientation figure will be draw there self.cornerTexts.append({ '1-TR':{'text':'','category':'A'}, '2-TE':{'text':'','category':'A'} }) # Top Left Corner Text self.cornerTexts.append({ '1-PatientName':{'text':'','category':'B'}, '2-PatientID':{'text':'','category':'A'}, '3-PatientInfo':{'text':'','category':'B'}, '4-Bg-StudyDate':{'text':'','category':'B'}, '5-Fg-StudyDate':{'text':'','category':'B'}, '6-Bg-StudyTime':{'text':'','category':'C'}, '7-Bg-StudyTime':{'text':'','category':'C'}, '8-Bg-SeriesDescription':{'text':'','category':'C'}, '9-Fg-SeriesDescription':{'text':'','category':'C'} }) # Top Rihgt Corner Text self.cornerTexts.append({ '1-Institution-Name':{'text':'','category':'B'}, '2-Referring-Phisycian':{'text':'','category':'B'}, '3-Manufacturer':{'text':'','category':'C'}, '4-Model':{'text':'','category':'C'}, '5-Patient-Position':{'text':'','category':'A'}, '6-TR':{'text':'','category':'A'}, '7-TE':{'text':'','category':'A'} }) self.layoutManager = slicer.app.layoutManager() self.sliceCornerAnnotations = {} self.annotationsDisplayAmount = 0 # If there is no user settings load defaults settings = qt.QSettings() if settings.contains('DataProbe/sliceViewAnnotations.topLeft'): self.topLeftAnnotationDisplay = int(settings.value( 'DataProbe/sliceViewAnnotations.topLeft')) else: self.topLeftAnnotationDisplay = 1 if settings.contains('DataProbe/sliceViewAnnotations.topRight'): self.topRightAnnotationDisplay = int(settings.value( 'DataProbe/sliceViewAnnotations.topRight')) else: self.topRightAnnotationDisplay = 1 if settings.contains('DataProbe/sliceViewAnnotations.bottomLeft'): self.bottomLeftAnnotationDisplay = int(settings.value( 'DataProbe/sliceViewAnnotations.bottomLeft')) else: self.bottomLeftAnnotationDisplay = 1 if settings.contains('DataProbe/sliceViewAnnotations.show'): self.showSliceViewAnnotations= int(settings.value( 'DataProbe/sliceViewAnnotations.show')) else: self.showSliceViewAnnotations = 1 if settings.contains('DataProbe/sliceViewAnnotations.showScalingRuler'): self.showScalingRuler= int(settings.value( 'DataProbe/sliceViewAnnotations.showScalingRuler')) else: self.showScalingRuler = 1 if settings.contains('DataProbe/sliceViewAnnotations.showColorScalarBar'): self.showColorScalarBar= int(settings.value( 'DataProbe/sliceViewAnnotations.showColorScalarBar')) else: self.showColorScalarBar = 0 if settings.contains('DataProbe/sliceViewAnnotations.fontFamily'): self.fontFamily = settings.value('DataProbe/sliceViewAnnotations.fontFamily') else: self.fontFamily = 'Times' if settings.contains('DataProbe/sliceViewAnnotations.fontSize'): self.fontSize = int(settings.value('DataProbe/sliceViewAnnotations.fontSize')) else: self.fontSize = 14 self.maximumTextLength= 35 if settings.contains('DataProbe/sliceViewAnnotations.bgDicomAnnotationsPersistence'): self.backgroundDicomAnnotationsPersistence = int(settings.value( 'DataProbe/sliceViewAnnotations.bgDicomAnnotationsPersistence')) else: self.backgroundDicomAnnotationsPersistence = 0 self.parameter = 'showSliceViewAnnotations' self.parameterNode = self.dataProbeUtil.getParameterNode() self.parameterNodeTag = self.parameterNode.AddObserver( vtk.vtkCommand.ModifiedEvent, self.updateGUIFromMRML) self.colorbarSelectedLayer = 'background' self.create() if self.showSliceViewAnnotations: self.updateSliceViewFromGUI()