<commit_before>"""
MultiVolumeVisualizationMix

:Authors:
	<NAME>
"""
from MultiVolumeVisualization import MultiVolumeVisualization
from MultiVolumeVisualization import CreateFunctionFromProperties
from MultiVolumeVisualization import CreateEmptyFunctions
from core.decorators import overrides
from PySide.QtGui import QWidget
from PySide.QtGui import QLabel
from PySide.QtGui import QGridLayout
from PySide.QtGui import QSlider
from PySide.QtGui import QComboBox
from PySide.QtCore import Qt
from vtk import vtkVolumeProperty


class MultiVolumeVisualizationMix(MultiVolumeVisualization):
	"""
	MultiVolumeVisualizationMix is a visualization that
	just mixes the two given volume properties together.
	"""
	def __init__(self):
		super(MultiVolumeVisualizationMix, self).__init__()

		self.fixedOpacity = 1.0
		self.movingOpacity = 1.0
		self.blendType = 0  # Default blend type
		self.fixedVisualization = None
		self.movingVisualization = None
		self.mapper = None

	@overrides(MultiVolumeVisualization)
	def setImageData(self, fixedImageData, movingImageData):
		self.fixedImageData = fixedImageData
		self.movingImageData = movingImageData

	@overrides(MultiVolumeVisualization)
	def setFixedVisualization(self, visualization):
		self.fixedVisualization = visualization
		self.fixedVolProp = self._createVolPropFromVis(self.fixedVisualization, self.fixedOpacity)

	@overrides(MultiVolumeVisualization)
	def setMovingVisualization(self, visualization):
		self.movingVisualization = visualization
		self.movingVolProp = self._createVolPropFromVis(self.movingVisualization, self.movingOpacity)

	@overrides(MultiVolumeVisualization)
	def getParameterWidget(self):
		self.labelFixedOpacity = QLabel("Opacity fixed data")
		self.labelMovingOpacity = QLabel("Opacity moving data")

		self.sliderFixedOpacity = QSlider(Qt.Horizontal)
		self.sliderFixedOpacity.setValue(pow(self.fixedOpacity, 1.0/3.0) * 100.0)

		self.sliderMovingOpacity = QSlider(Qt.Horizontal)
		self.sliderMovingOpacity.setValue(pow(self.movingOpacity, 1.0/3.0) * 100.0)

		self.blendTypeComboBox = QComboBox()
		self.blendTypeComboBox.addItem("Default additive blend")
		self.blendTypeComboBox.addItem("Difference blend")
		self.blendTypeComboBox.currentIndexChanged.connect(self.valueChanged)

		# Be sure to connect after the values are set...
		self.sliderFixedOpacity.valueChanged.connect(self.valueChanged)
		self.sliderMovingOpacity.valueChanged.connect(self.valueChanged)

		layout = QGridLayout()
		layout.setAlignment(Qt.AlignTop)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.labelFixedOpacity, 0, 0)
		layout.addWidget(self.sliderFixedOpacity, 0, 1)
		layout.addWidget(self.labelMovingOpacity, 1, 0)
		layout.addWidget(self.sliderMovingOpacity, 1, 1)
		layout.addWidget(QLabel("Blend type"), 2, 0)
		layout.addWidget(self.blendTypeComboBox, 2, 1)

		widget = QWidget()
		widget.setLayout(layout)
		return widget

	@overrides(MultiVolumeVisualization)
	def valueChanged(self, value):
		"""
		This method is called when the value of one of the sliders / fields is
		adjusted. Argument value is unused. It is just there so that it can be
		connected to the signals of the interface elements.

		:type value: int
		"""
		self.fixedOpacity = self._applyOpacityFunction(float(self.sliderFixedOpacity.value()) / 100.0)
		self.movingOpacity = self._applyOpacityFunction(float(self.sliderMovingOpacity.value()) / 100.0)
		self.blendType = self.blendTypeComboBox.currentIndex()
		self.updateTransferFunctions()

	@overrides(MultiVolumeVisualization)
	def updateTransferFunctions(self):
		self.fixedVolProp = self._createVolPropFromVis(self.fixedVisualization, self.fixedOpacity)
		self.movingVolProp = self._createVolPropFromVis(self.movingVisualization, self.movingOpacity)

		if self.mapper:
			self.mapper.SetBlendType(self.blendType)

		self.updatedTransferFunction.emit()
<commit_msg>Improve layout of multi volume visualization parameters<commit_after>"""
MultiVolumeVisualizationMix

:Authors:
	<NAME>
"""
from MultiVolumeVisualization import MultiVolumeVisualization
from MultiVolumeVisualization import CreateFunctionFromProperties
from MultiVolumeVisualization import CreateEmptyFunctions
from core.decorators import overrides
from PySide.QtGui import QGroupBox
from PySide.QtGui import QWidget
from PySide.QtGui import QLabel
from PySide.QtGui import QGridLayout
from PySide.QtGui import QSlider
from PySide.QtGui import QComboBox
from PySide.QtCore import Qt
from vtk import vtkVolumeProperty


class MultiVolumeVisualizationMix(MultiVolumeVisualization):
	"""
	MultiVolumeVisualizationMix is a visualization that
	just mixes the two given volume properties together.
	"""
	def __init__(self):
		super(MultiVolumeVisualizationMix, self).__init__()

		self.fixedOpacity = 1.0
		self.movingOpacity = 1.0
		self.blendType = 0  # Default blend type
		self.fixedVisualization = None
		self.movingVisualization = None
		self.mapper = None

	@overrides(MultiVolumeVisualization)
	def setImageData(self, fixedImageData, movingImageData):
		self.fixedImageData = fixedImageData
		self.movingImageData = movingImageData

	@overrides(MultiVolumeVisualization)
	def setFixedVisualization(self, visualization):
		self.fixedVisualization = visualization
		self.fixedVolProp = self._createVolPropFromVis(self.fixedVisualization, self.fixedOpacity)

	@overrides(MultiVolumeVisualization)
	def setMovingVisualization(self, visualization):
		self.movingVisualization = visualization
		self.movingVolProp = self._createVolPropFromVis(self.movingVisualization, self.movingOpacity)

	@overrides(MultiVolumeVisualization)
	def getParameterWidget(self):
		self.labelFixedOpacity = QLabel("Fixed:")
		self.labelMovingOpacity = QLabel("Moving:")

		self.sliderFixedOpacity = QSlider(Qt.Horizontal)
		self.sliderFixedOpacity.setValue(pow(self.fixedOpacity, 1.0/3.0) * 100.0)

		self.sliderMovingOpacity = QSlider(Qt.Horizontal)
		self.sliderMovingOpacity.setValue(pow(self.movingOpacity, 1.0/3.0) * 100.0)

		self.blendTypeComboBox = QComboBox()
		self.blendTypeComboBox.addItem("Default additive blend")
		self.blendTypeComboBox.addItem("Difference blend")
		self.blendTypeComboBox.currentIndexChanged.connect(self.valueChanged)

		# Be sure to connect after the values are set...
		self.sliderFixedOpacity.valueChanged.connect(self.valueChanged)
		self.sliderMovingOpacity.valueChanged.connect(self.valueChanged)

		groupLayout = QGridLayout()
		groupLayout.setAlignment(Qt.AlignTop)
		groupLayout.addWidget(self.labelFixedOpacity, 0, 0)
		groupLayout.addWidget(self.sliderFixedOpacity, 0, 1)
		groupLayout.addWidget(self.labelMovingOpacity, 1, 0)
		groupLayout.addWidget(self.sliderMovingOpacity, 1, 1)

		groupBox = QGroupBox()
		groupBox.setTitle("Opacity:")
		groupBox.setLayout(groupLayout)

		layout = QGridLayout()
		layout.setAlignment(Qt.AlignTop)
		layout.addWidget(groupBox)

		widget = QWidget()
		widget.setLayout(layout)
		return widget

	@overrides(MultiVolumeVisualization)
	def valueChanged(self, value):
		"""
		This method is called when the value of one of the sliders / fields is
		adjusted. Argument value is unused. It is just there so that it can be
		connected to the signals of the interface elements.

		:type value: int
		"""
		self.fixedOpacity = self._applyOpacityFunction(float(self.sliderFixedOpacity.value()) / 100.0)
		self.movingOpacity = self._applyOpacityFunction(float(self.sliderMovingOpacity.value()) / 100.0)
		self.blendType = self.blendTypeComboBox.currentIndex()
		self.updateTransferFunctions()

	@overrides(MultiVolumeVisualization)
	def updateTransferFunctions(self):
		self.fixedVolProp = self._createVolPropFromVis(self.fixedVisualization, self.fixedOpacity)
		self.movingVolProp = self._createVolPropFromVis(self.movingVisualization, self.movingOpacity)

		if self.mapper:
			self.mapper.SetBlendType(self.blendType)

		self.updatedTransferFunction.emit()

{'fraction_non_alphanumeric': 0.08602969166349449, 'fraction_numerical': 0.010404770968151249, 'mean_word_length': 6.1394927536231885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2973225', 'n_tokens_mistral': 2605, 'n_tokens_neox': 2357, 'n_words': 493}