コード例 #1
0
    def __init__(self):
        super(TransferFunctionWidget, self).__init__()

        self.nodes = []
        self.lines = []
        self.histogram = Histogram()
        self.histogram.enabled = False

        # Create a histogram widget for the background of the transfer function editor
        self.histogramWidget = HistogramWidget()
        self.histogramWidget.setHistogram(self.histogram)
        self.histogramWidget.setAxeMode(bottom=HistogramWidget.AxeClear,
                                        left=HistogramWidget.AxeLog)
        self.histogramWidget.update()
        self.histogramWidget._histogramItem.delegate = self
        Style.styleWidgetForTab(self.histogramWidget)

        # Invisible item that catches mouse events on top of the histogram
        self.transferfunctionItem = TransferFunctionItem()
        self.transferfunctionItem.setZValue(250)
        self.transferfunctionItem.delegate = self
        self.histogramWidget.addItem(self.transferfunctionItem)

        # Create a widget for editing the selected node of the transfer function
        self.nodeItemWidget = NodeItemWidget()
        self.nodeItemWidget.setEnabled(False)
        self.nodeItemWidget.nodeUpdated.connect(self.updateNode)
        self.nodeItemWidget.removePoint.connect(self.removePoint)

        layout = QGridLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.histogramWidget, 0, 0)
        layout.addWidget(self.nodeItemWidget, 1, 0)
        self.setLayout(layout)
コード例 #2
0
	def __init__(self):
		super(TransferFunctionWidget, self).__init__()

		self.nodes = []
		self.lines = []
		self.histogram = Histogram()
		self.histogram.enabled = False

		# Create a histogram widget for the background of the transfer function editor
		self.histogramWidget = HistogramWidget()
		self.histogramWidget.setHistogram(self.histogram)
		self.histogramWidget.setAxeMode(bottom=HistogramWidget.AxeClear, left=HistogramWidget.AxeLog)
		self.histogramWidget.update()
		self.histogramWidget._histogramItem.delegate = self
		Style.styleWidgetForTab(self.histogramWidget)

		# Invisible item that catches mouse events on top of the histogram
		self.transferfunctionItem = TransferFunctionItem()
		self.transferfunctionItem.setZValue(250)
		self.transferfunctionItem.delegate = self
		self.histogramWidget.addItem(self.transferfunctionItem)

		# Create a widget for editing the selected node of the transfer function
		self.nodeItemWidget = NodeItemWidget()
		self.nodeItemWidget.setEnabled(False)
		self.nodeItemWidget.nodeUpdated.connect(self.updateNode)
		self.nodeItemWidget.removePoint.connect(self.removePoint)

		layout = QGridLayout()
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.histogramWidget, 0, 0)
		layout.addWidget(self.nodeItemWidget, 1, 0)
		self.setLayout(layout)
コード例 #3
0
	def __init__(self):
		super(PointsWidget, self).__init__()

		self.landmarkWidgets = []
		self.activeIndex = 0

		self.scrollArea = QScrollArea(self)
		self.scrollArea.setFrameShape(QFrame.NoFrame)
		self.scrollArea.setAutoFillBackground(False)
		self.scrollArea.setAttribute(Qt.WA_TranslucentBackground)
		self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		self.scrollArea.setWidgetResizable(True)

		landmarkLocationsLayout = QGridLayout()
		landmarkLocationsLayout.setSpacing(0)
		landmarkLocationsLayout.setContentsMargins(0, 0, 0, 0)
		landmarkLocationsLayout.setAlignment(Qt.AlignTop)

		self.landmarkLocationsWidget = QWidget()
		Style.styleWidgetForTab(self.landmarkLocationsWidget)
		self.landmarkLocationsWidget.setLayout(landmarkLocationsLayout)
		self.scrollArea.setWidget(self.landmarkLocationsWidget)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.scrollArea)
		self.setLayout(layout)
コード例 #4
0
	def UpdateWidgetFromRenderWidget(self):
		"""
		Update the parameter widget with a widget from the render widget.
		"""
		# Add the scroll area for the parameter widget if it is not there yet
		layout = self.layout()
		if layout.indexOf(self.scrollArea) == -1:
			layout.addWidget(self.scrollArea, 1, 0, 1, 2)
			self.setLayout(layout)

		# Clear the previous parameter widget
		if self.paramWidget is not None:
			self.paramWidget.setParent(None)
			if self.renderController.visualization is not None:
				self.renderController.visualization.disconnect(SIGNAL("updatedTransferFunction"), self.transferFunctionChanged)

		# Get a new parameter widget from the render widget
		self.paramWidget = self.renderController.getParameterWidget()
		Style.styleWidgetForTab(self.paramWidget)
		self.scrollArea.setWidget(self.paramWidget)

		if self.renderController.visualization is not None:
			self.renderController.visualization.updatedTransferFunction.connect(self.transferFunctionChanged)

		self.visTypeComboBox.setCurrentIndex(self.visTypeComboBox.findText(self.renderController.visualizationType))
コード例 #5
0
	def __init__(self):
		super(RenderInfoWidget, self).__init__()

		self.scrollArea = QScrollArea()
		self.scrollArea.setFrameShape(QFrame.NoFrame)
		self.scrollArea.setAutoFillBackground(False)
		self.scrollArea.setAttribute(Qt.WA_TranslucentBackground)
		self.scrollArea.setWidgetResizable(True)

		Style.styleWidgetForTab(self)
		Style.styleWidgetForTab(self.scrollArea)
コード例 #6
0
	def __init__(self):
		super(TrackingHistogramWidget, self).__init__()
		self.nodeItem = None
		Style.styleWidgetForTab(self)
コード例 #7
0
 def __init__(self):
     super(TrackingHistogramWidget, self).__init__()
     self.nodeItem = None
     Style.styleWidgetForTab(self)
コード例 #8
0
	def setFile(self, fileName):
		"""
		Slot that reads properties of the dataset and displays them in a few widgets.
		"""
		if fileName is None:
			return

		self.fileName = fileName

		# Read info from dataset
		# TODO: read out the real world dimensions in inch or cm
		# TODO: scalar type (int, float, short, etc.)
		imageReader = DataReader()
		imageData = imageReader.GetImageData(fileName)

		directory, name = os.path.split(fileName)
		dimensions = imageData.GetDimensions()
		minimum, maximum = imageData.GetScalarRange()
		scalarType = imageData.GetScalarTypeAsString()

		bins = DataAnalyzer.histogramForData(imageData, 256)

		self.histogram = Histogram()
		self.histogram.bins = bins
		self.histogram.enabled = True

		self.histogramWidget = HistogramWidget()
		self.histogramWidget.setMinimumHeight(100)
		self.histogramWidget.setHistogram(self.histogram)
		self.histogramWidget.setAxeMode(bottom=HistogramWidget.AxeClear,
			left=HistogramWidget.AxeLog)
		Style.styleWidgetForTab(self.histogramWidget)

		nameText = name
		dimsText = "(" + str(dimensions[0]) + ", " + str(dimensions[1]) + ", " + str(dimensions[2]) + ")"
		voxsText = str(dimensions[0] * dimensions[1] * dimensions[2])
		rangText = "[" + str(minimum) + " : " + str(maximum) + "]"
		typeText = scalarType

		layout = self.layout()
		if not layout:
			# Create a new layout
			layout = QGridLayout()
			layout.setAlignment(Qt.AlignTop)

			# Create string representations
			nameLabels = []
			nameLabels.append(QLabel("File name:"))
			nameLabels.append(QLabel("Dimensions:"))
			nameLabels.append(QLabel("Voxels:"))
			nameLabels.append(QLabel("Range:"))
			nameLabels.append(QLabel("Data type:"))

			for label in nameLabels:
				label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

			# Create 'dynamic' labels
			self.labelTitle = QLabel(nameText)
			self.labelDimensions = QLabel(dimsText)
			self.labelVoxels = QLabel(voxsText)
			self.labelRange = QLabel(rangText)
			self.labelType = QLabel(typeText)

			index = 0
			for label in nameLabels:
				layout.addWidget(label, index, 0)
				index += 1

			layout.addWidget(self.labelTitle, 0, 1)
			layout.addWidget(self.labelDimensions, 1, 1)
			layout.addWidget(self.labelVoxels, 2, 1)
			layout.addWidget(self.labelRange, 3, 1)
			layout.addWidget(self.labelType, 4, 1)
			layout.addWidget(self.histogramWidget, 5, 0, 1, 2)

			widget = QWidget()
			widget.setLayout(layout)
			Style.styleWidgetForTab(widget)
			self.scrollArea.setWidget(widget)

			scrollLayout = QGridLayout()
			scrollLayout.setSpacing(0)
			scrollLayout.setContentsMargins(0, 0, 0, 0)
			scrollLayout.addWidget(self.scrollArea)
			self.setLayout(scrollLayout)
		else:
			# Just update the text for the 'dynamic' labels
			self.labelTitle.setText(nameText)
			self.labelDimensions.setText(dimsText)
			self.labelVoxels.setText(voxsText)
			self.labelRange.setText(rangText)
			self.labelType.setText(typeText)
コード例 #9
0
	def setFile(self, fileName):
		"""
		Slot that reads properties of the dataset and displays them in a few widgets.
		"""
		if fileName is None:
			return

		# Read info from dataset
		# TODO: read out the real world dimensions in inch or cm
		# TODO: scalar type (int, float, short, etc.)
		imageReader = DataReader()
		imageData = imageReader.GetImageData(fileName)

		directory, name = os.path.split(fileName)
		dimensions = imageData.GetDimensions()
		minimum, maximum = imageData.GetScalarRange()

		bins = DataAnalyzer.histogramForData(imageData, 256)

		self.histogram = Histogram()
		self.histogram.bins = bins
		self.histogram.enabled = True

		self.histogramWidget = HistogramWidget()
		self.histogramWidget.setHistogram(self.histogram)
		self.histogramWidget.setAxeMode(bottom=HistogramWidget.AxeClear,
			left=HistogramWidget.AxeLog)
		Style.styleWidgetForTab(self.histogramWidget)

		nameText = name
		dimsText = "(" + str(dimensions[0]) + ", " + str(dimensions[1]) + ", " + str(dimensions[2]) + ")"
		voxsText = str(dimensions[0] * dimensions[1] * dimensions[2])
		rangText = "[" + str(minimum) + " : " + str(maximum) + "]"

		layout = self.layout()
		if not layout:
			# Create a new layout
			layout = QGridLayout()
			layout.setAlignment(Qt.AlignTop)

			# Create string representations
			nameField = QLabel("File name:")
			dimsField = QLabel("Dimensions:")
			voxsField = QLabel("Voxels:")
			rangField = QLabel("Range:")

			nameField.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
			dimsField.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
			voxsField.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
			rangField.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

			# Create 'dynamic' labels
			self.labelTitle = QLabel(nameText)
			self.labelDimensions = QLabel(dimsText)
			self.labelVoxels = QLabel(voxsText)
			self.labelRange = QLabel(rangText)

			layout.addWidget(nameField, 0, 0)
			layout.addWidget(dimsField, 1, 0)
			layout.addWidget(voxsField, 2, 0)
			layout.addWidget(rangField, 3, 0)

			layout.addWidget(self.labelTitle, 0, 1)
			layout.addWidget(self.labelDimensions, 1, 1)
			layout.addWidget(self.labelVoxels, 2, 1)
			layout.addWidget(self.labelRange, 3, 1)
			layout.addWidget(self.histogramWidget, 4, 0, 1, 2)
			self.setLayout(layout)
		else:
			# Just update the text for the 'dynamic' labels
			self.labelTitle.setText(nameText)
			self.labelDimensions.setText(dimsText)
			self.labelVoxels.setText(voxsText)
			self.labelRange.setText(rangText)
コード例 #10
0
	def __init__(self):
		super(RenderInfoWidget, self).__init__()

		Style.styleWidgetForTab(self)