def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_PartVisualizationPanelBase.__init__(self) self.setupUi(self) Visualization2DPanel.__init__(self) TransformManager.__init__(self, self.emitDataChangedTransform) # list of associated keys from same type self.__keys = [] #default setting self.floatInRangeShininess_2.setRange([0,40.0]) self.floatInRangeShininess_2.setValue(16.0) self.floatInRangeTrans.setRange([0,1.0]) self.floatInRangeTrans.setValue(1.0) self.__floatParams = '' self.__intParams = '' self.__boolParams = '' self.__vec2Params = '' self.__vec3Params = '' self.__vec4Params = '' self.__mat2Params = '' self.__mat3Params = '' self.__mat4Params = '' self.__r = 200 self.__g = 200 self.__b = 200 self.__ambient = [180,180,180] self.__specular = [255,255,130] self.color = NO_COLOR self.colorCreator = None self.vectorVariableNames = [] self.scalarVariableNames = [] self.__baseVariable = 'Select a Variable' self.variablesSet = False self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) # for multi selection self.oldPanelParams = {} self.oldPanelRealParams = {} self.__rectangleManager = RectangleManager( self, self.emitCutChanged, self.emitCutChanged, None, CUTTINGSURFACE ) fillShaderList(self.shaderList) PartVisualizationPanelConnector(self)
def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_GenericVisualizerPanelBase.__init__(self) self.setupUi(self) # current object key self.__key = -1 self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface)) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabClipPlane)) self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) self.visibilityCheckBox.setVisible(covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox", False)) self.vrpPushButtonAdjustPreview.hide() # manager handling the starting rectangle self.__rectangleManager = RectangleManager( self, self.emitTraceParametersApply, self.emitRadioBttnsTracerApply, self.emitRectangleChange ) # keys of 2D objects in combobox self.__key2UsePart = {} self.__UsePart2key = {} # current task type self.__taskType = STREAMLINE # start style of tracer to that the panel will change self.__startStyle = PLANE self.__baseVariable = None #temporary storage of this parameter part self.colorCreator = None # qt connections and settings StreamlinesPanelConnector(self)
class StreamlinesPanel(QtWidgets.QWidget,Ui_GenericVisualizerPanelBase): """For controling parameters of a streamline. """ sigVisibiliyToggled = pyqtSignal() sigEditColorMap = pyqtSignal() def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_GenericVisualizerPanelBase.__init__(self) self.setupUi(self) # current object key self.__key = -1 self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface)) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabClipPlane)) self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) self.visibilityCheckBox.setVisible(covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox", False)) self.vrpPushButtonAdjustPreview.hide() # manager handling the starting rectangle self.__rectangleManager = RectangleManager( self, self.emitTraceParametersApply, self.emitRadioBttnsTracerApply, self.emitRectangleChange ) # keys of 2D objects in combobox self.__key2UsePart = {} self.__UsePart2key = {} # current task type self.__taskType = STREAMLINE # start style of tracer to that the panel will change self.__startStyle = PLANE self.__baseVariable = None #temporary storage of this parameter part self.colorCreator = None # qt connections and settings StreamlinesPanelConnector(self) def setSelectedColormap( self, callerKey, key, name): _infoer.function = str(self.setSelectedColormap) _infoer.write("") # new colormap was selected in color manager if (self.__key == callerKey): if MainWindow.globalColorManager.setSelectedColormapKey( self.colorMapCombobox, key ): self.emitTraceParametersApply() def paramChanged( self, key ): """ params of object key changed""" _infoer.function = str(self.paramChanged) _infoer.write(""+str(key)) if self.__key==key: self.update() def update( self ): _infoer.function = str(self.update) _infoer.write("") if self.__key!=-1: self.updateForObject( self.__key ) def updateForObject( self, key ): """ called from MainWindow to update the content to the choosen object key """ _infoer.function = str(self.updateForObject) _infoer.write("") self.__key = key params = ObjectMgr().getParamsOfObject(key) self.__setStartDomainNamesList( ObjectMgr().getList2dPartsForVisItem(key) ) self.__set2ndVariable( ObjectMgr().getPossibleScalarVariablesForVisItem(key) ) self.__setParams( params ) def __getParams(self): """ convert information in the panel into the right negotiator param classes """ _infoer.function = str(self.__getParams) _infoer.write("") if self.__taskType==STREAMLINE: data = PartStreamlineVisParams() data.tubeWidth = getDoubleInLineEdit(self.TubeWidth) elif self.__taskType==MOVING_POINTS: data = PartMovingPointsVisParams() data.numSteps = getIntInLineEdit(self.NumberOfSteps) data.duration = getDoubleInLineEdit(self.DurationOfSteps) data.sphereRadius = getDoubleInLineEdit(self.RadiusOfSpheres) else: data = PartPathlinesVisParams() data.numSteps = getIntInLineEdit(self.NumberOfSteps) data.duration = getDoubleInLineEdit(self.DurationOfSteps) data.tubeWidth = getDoubleInLineEdit(self.TubeWidth) data.sphereRadius = getDoubleInLineEdit(self.RadiusOfSpheres) data.taskType = self.__taskType data.name = str(self.nameWidget.text()) data.isVisible = self.visibilityCheckBox.isChecked() data.variable = str(self.vrpLineEditVariable.text()) data.colorTableKey = self.colorCreator if self.vrpCheckBoxMapVariable.isChecked(): data.secondVariable = str(self.vrpComboBoxVariable.currentText()) if data.secondVariable!="" and data.colorTableKey!=None and data.secondVariable in data.colorTableKey and self.__baseVariable and self.__baseVariable==data.secondVariable: data.colorTableKey[data.secondVariable] = MainWindow.globalColorManager.getSelectedColormapKey( self.colorMapCombobox) else : if self.__baseVariable and self.__baseVariable==data.variable and data.colorTableKey: data.colorTableKey[data.variable] = MainWindow.globalColorManager.getSelectedColormapKey( self.colorMapCombobox) if self.__startStyle == PLANE: data.alignedRectangle = self.__rectangleManager.getParams() elif self.__startStyle == LINE: #data.line3D = self.__rectangleManager.getParams(LINE) data.alignedRectangle = self.__rectangleManager.getParams(LINE) else: data.alignedRectangle = self.__rectangleManager.getParams() data.boundingBox = self.__rectangleManager.getBoundingBox() try: data.no_startp = getIntInLineEdit(self.numberStartpoints) except ConversionError: data.no_startp = 0 try: data.len = getDoubleInLineEdit(self.lengthTraces) except ConversionError: data.len = 0.0 data.direction = self.tracingDirectionCB.currentIndex()+1 try: data.eps = getDoubleInLineEdit(self.vrpLineEditRelativeErrors) except ConversionError: data.eps = 0.0 try: data.abs = getDoubleInLineEdit(self.vrpLineEditAbsoluteErrors) except ConversionError: data.abs = 0.0 try: data.grid_tol = getDoubleInLineEdit(self.vrpLineEditGridTolerance) except ConversionError: data.grid_tol = 0.0 try: data.maxOutOfDomain = getDoubleInLineEdit(self.vrpLineEditMinimumValue_2) except ConversionError: data.maxOutOfDomain = 0.0 try: data.min_vel = getDoubleInLineEdit(self.vrpLineEditMinimumValue) except ConversionError: data.min_vel = 0.0 data.showSmoke= self.vrpCheckBoxShow.isChecked() data.showInteractor = self.checkBox5.isChecked() if self.checkBoxDomainFromList.isChecked(): if self.comboBoxDomain.currentIndex()>0 : data.use2DPartKey=self.__UsePartIdx2key[self.comboBoxDomain.currentIndex()] else : data.use2DPartKey=-1 if self.checkBoxFreeStartpoints.isChecked(): data.start_style = 3 else: data.start_style = self.__startStyle return data def __panelAccordingTaskType( self ): """ change the panel according the needs of streamlines, moving points or pathlines NOTE: changes identical for all types should be done in __init__ """ _infoer.function = str(self.__panelAccordingTaskType) _infoer.write("") #default settings self.vrpCheckBoxMapVariable.setEnabled(True) self.vrpComboBoxVariable.setEnabled(True) self.comboBoxDomain.setEnabled(False) # widgets for end point not needed self.textEndPointX.hide() self.textEndPointY.hide() self.textEndPointZ.hide() self.floatInRangeEndPointX.hide() self.floatInRangeEndPointY.hide() self.floatInRangeEndPointZ.hide() # make sure whole data is shown self.checkBoxDomainFromList.show() self.comboBoxDomain.show() self.floatInRangeWidth.show() self.floatInRangeHeight.show() self.xAxisRadioButton.show() self.yAxisRadioButton.show() self.zAxisRadioButton.show() self.textLabel4_3_3.show() self.textLabel4_3_2_3.show() self.floatInRangeRotX.show() self.floatInRangeRotY.show() self.floatInRangeRotZ.show() self.textLabelRotX.show() self.textLabelRotY.show() self.textLabelRotZ.show() self.checkBoxFreeStartpoints.show() self.vrpCheckBoxShow.show() if self.__taskType==STREAMLINE: self.vrpLabelTitle.setText(self.__tr("Edit Streamline:")) self.textNumberOfStreamlines.setText(self.__tr("Number of Streamlines:")) self.vrpGroupBoxAdjustment.setTitle(self.__tr("Streamline Adjustment")) self.textLength.show() self.lengthTraces.show() self.textDirection.show() self.tracingDirectionCB.show() self.textNumberOfSteps.hide() self.NumberOfSteps.hide() self.textRadiusOfSpheres.hide() self.RadiusOfSpheres.hide() self.textTubeWidth.show() self.TubeWidth.show() self.textDurationOfSteps.hide() self.DurationOfSteps.hide() if self.__startStyle == LINE: self.textEndPointX.show() self.textEndPointY.show() self.textEndPointZ.show() self.floatInRangeEndPointX.show() self.floatInRangeEndPointY.show() self.floatInRangeEndPointZ.show() self.checkBoxDomainFromList.hide() self.comboBoxDomain.hide() self.floatInRangeWidth.hide() self.floatInRangeHeight.hide() self.xAxisRadioButton.hide() self.yAxisRadioButton.hide() self.zAxisRadioButton.hide() self.groupOrientation.hide() self.textLabel4_3_3.hide() self.textLabel4_3_2_3.hide() self.floatInRangeRotX.hide() self.floatInRangeRotY.hide() self.floatInRangeRotZ.hide() self.textLabelRotX.hide() self.textLabelRotY.hide() self.textLabelRotZ.hide() self.checkBoxFreeStartpoints.hide() self.vrpCheckBoxShow.hide() elif self.__taskType==MOVING_POINTS or self.__taskType==PATHLINES: self.textNumberOfStreamlines.setText(self.__tr("Number of Startpoints:")) self.vrpGroupBoxAdjustment.setTitle(self.__tr("Points Adjustment")) self.textLength.hide() self.lengthTraces.hide() self.textDirection.hide() self.tracingDirectionCB.hide() self.textNumberOfSteps.show() self.NumberOfSteps.show() self.textDurationOfSteps.show() self.DurationOfSteps.show() if self.__taskType==MOVING_POINTS: self.vrpLabelTitle.setText(self.__tr("Edit Moving Points:")) self.textRadiusOfSpheres.setText(self.__tr("Radius of Spheres")) self.textRadiusOfSpheres.show() self.RadiusOfSpheres.show() self.textTubeWidth.hide() self.TubeWidth.hide() elif self.__taskType==PATHLINES: self.vrpLabelTitle.setText(self.__tr("Edit Pathlines:")) self.textRadiusOfSpheres.setText(self.__tr("Size of head object:")) self.textTubeWidth.show() self.TubeWidth.show() def __set2ndVariable( self, varlist): """ fill the combobox to choose a variable to be mapped on the trace """ _infoer.function = str(self.__set2ndVariable) _infoer.write("") self.vrpComboBoxVariable.clear() self.vrpComboBoxVariable.setEnabled( len(varlist)!=0 ) self.vrpCheckBoxMapVariable.setEnabled( len(varlist)!=0 ) for v in varlist: self.vrpComboBoxVariable.addItem(v) def __setParams( self, params ): """ set update the panel with the information in the negotiator param class """ _infoer.function = str(self.__setParams) _infoer.write("") StreamlinesPanelBlockSignals( self, True ) # int is always the key # TODO CHANGE if isinstance( params, int): self.__key = params return self.__taskType = params.taskType if params.taskType == MOVING_POINTS: self.textTubeWidth.hide() self.TubeWidth.hide() else: self.TubeWidth.show() self.textTubeWidth.show() if hasattr(params, 'start_style'): if params.start_style != FREE: self.__startStyle = params.start_style self.__panelAccordingTaskType() if hasattr(params, 'numSteps'): self.NumberOfSteps.setText(str(params.numSteps)) if hasattr(params, 'duration'): self.DurationOfSteps.setText(str(params.duration)) if hasattr(params, 'sphereRadius'): self.RadiusOfSpheres.setText(str(params.sphereRadius)) else: self.RadiusOfSpheres.setText("0.2") if hasattr(params, 'tubeWidth'): self.TubeWidth.setText(str(params.tubeWidth)) else: self.TubeWidth.setText("0.0") self.nameWidget.setText(params.name) if hasattr(params, 'isVisible' ): self.visibilityCheckBox.setChecked(params.isVisible) if hasattr(params, 'variable' ): self.vrpLineEditVariable.setText(params.variable) if params.secondVariable!=None: self.vrpCheckBoxMapVariable.setChecked(True) self.vrpComboBoxVariable.setCurrentIndex(self.vrpComboBoxVariable.findText(params.secondVariable)) currentVariable = params.secondVariable else: self.vrpCheckBoxMapVariable.setChecked(False) currentVariable = params.variable if hasattr(params, 'start_style'): if params.start_style==3: self.checkBoxFreeStartpoints.setChecked(True) else: self.checkBoxFreeStartpoints.setChecked(False) self.__baseVariable = currentVariable currentColorTableKey = None if currentVariable!=None and params.colorTableKey!=None and currentVariable in params.colorTableKey: currentColorTableKey = params.colorTableKey[currentVariable] MainWindow.globalColorManager.update( self.colorMapCombobox, currentVariable, currentColorTableKey) if hasattr(params.boundingBox, 'getXMin' ): self.__boundingBox = params.boundingBox if self.__startStyle == PLANE: self.__rectangleManager.setBoundingBox( params.boundingBox ) elif self.__startStyle == LINE: self.__rectangleManager.setBoundingBox( params.boundingBox, LINE ) else: self.__rectangleManager.setBoundingBox( params.boundingBox ) if self.__startStyle == PLANE: self.__rectangleManager.setRectangle( params.alignedRectangle ) elif self.__startStyle == LINE: #self.__rectangleManager.setLine( params.lines3D ) self.__rectangleManager.setLine( params.alignedRectangle ) else: self.__rectangleManager.setRectangle( params.alignedRectangle ) self.numberStartpoints.setText(str(params.no_startp)) self.lengthTraces.setText(str(params.len)) self.tracingDirectionCB.setCurrentIndex(params.direction-1) self.vrpLineEditRelativeErrors.setText(str(params.eps)) self.vrpLineEditAbsoluteErrors.setText(str(params.abs)) self.vrpLineEditGridTolerance.setText(str(params.grid_tol)) self.vrpLineEditMinimumValue.setText(str(params.min_vel)) self.vrpLineEditMinimumValue_2.setText(str(params.maxOutOfDomain)) self.vrpCheckBoxShow.setChecked(params.showSmoke) self.checkBox5.setChecked(params.showInteractor) self.colorCreator=params.colorTableKey if (params.use2DPartKey==None) or (self.comboBoxDomain.count() == 1): self.checkBoxDomainFromList.setChecked(False) else : self.checkBoxDomainFromList.setChecked(True) if params.use2DPartKey in self.__key2UsePartIdx: self.comboBoxDomain.setCurrentIndex( self.__key2UsePartIdx[params.use2DPartKey] ) else : self.comboBoxDomain.setCurrentIndex( 0 ) self.__setRightDomainEnabling(self.checkBoxDomainFromList.isChecked()) if hasattr(params, 'tubeWidth'): if params.secondVariable != None and params.tubeWidth <= 0.0: self.vrpCheckBoxMapVariable.setEnabled(True) self.vrpComboBoxVariable.setEnabled(True) self.TubeWidth.setEnabled(False) elif params.secondVariable == None and params.tubeWidth > 0.0: self.vrpCheckBoxMapVariable.setEnabled(False) self.vrpComboBoxVariable.setEnabled(False) self.TubeWidth.setEnabled(True) elif params.secondVariable == None and params.tubeWidth <= 0.0: self.vrpCheckBoxMapVariable.setEnabled(True) self.vrpComboBoxVariable.setEnabled(True) self.TubeWidth.setEnabled(True) else: print("ERROR: Tube width > 0 and mapping of 2nd variable not supported") # show qLabel RadiusOfSpheres only if COMPLEX_OBJECT_TYPE is BAR_MAGNET or COMPASS # and if tube width is changed self.textRadiusOfSpheres.hide() self.RadiusOfSpheres.hide() if self.__taskType==PATHLINES and self.TubeWidth.text() != "0.0": complexObjetType = covise.getCoConfigEntry('TRACERConfig.COMPLEX_OBJECT_TYPE') if (complexObjetType == 'BAR_MAGNET') or (complexObjetType == 'COMPASS'): self.textRadiusOfSpheres.show() self.RadiusOfSpheres.show() StreamlinesPanelBlockSignals( self, False ) def __setStartDomainNamesList(self, dL): """ fill combobox with 2d domain name list dL""" _infoer.function = str(self.__setStartDomainNamesList) _infoer.write("") self.__key2UsePartIdx = {} self.__UsePartIdx2key = {} self.checkBoxDomainFromList.setEnabled( len(dL)!=0 ) self.comboBoxDomain.clear() self.comboBoxDomain.blockSignals(True) self.comboBoxDomain.addItem("Please select a part") cnt=1 for keydName in dL: self.__key2UsePartIdx[keydName[0]] = cnt self.__UsePartIdx2key[cnt] = keydName[0] self.comboBoxDomain.addItem(keydName[1]) cnt=cnt+1 self.comboBoxDomain.blockSignals(False) def emitTraceParametersApply(self): _infoer.function = str(self.emitTraceParametersApply) _infoer.write("") if not self.__key==-1: Application.vrpApp.key2params[self.__key] = self.__getParams() ObjectMgr().setParams( self.__key, self.__getParams() ) theGuiMsgHandler().runObject( self.__key ) def emitRadioBttnsTracerApply(self): _infoer.function = str(self.emitRadioBttnsTracerApply) _infoer.write("") if not self.__key==-1: # send message to cover if self.xAxisRadioButton.isChecked(): theGuiMsgHandler().sendKeyWord("xAxis") if self.yAxisRadioButton.isChecked(): theGuiMsgHandler().sendKeyWord("yAxis") if self.zAxisRadioButton.isChecked(): theGuiMsgHandler().sendKeyWord("zAxis") self.emitTraceParametersApply() def emitNameChange(self, aQString=None): _infoer.function = str(self.emitNameChange) _infoer.write("") if self.__key!=-1: MainWindow.globalAccessToTreeView.setItemData(self.__key, str(self.nameWidget.text())) self.emitTraceParametersApply() def emitVisibilityToggled(self, b): _infoer.function = str(self.emitVisibilityToggled) _infoer.write("") self.sigVisibiliyToggled.emit( (b,)) self.emitRectangleChange(b) def emitCustomizeColorMap(self): _infoer.function = str(self.emitCustomizeColorMap) _infoer.write("") self.sigEditColorMap.emit( self.__key, MainWindow.globalColorManager.getSelectedColormapKey( self.colorMapCombobox) ) def emitRectangleChange(self, val=False): _infoer.function = str(self.emitRectangleChange) _infoer.write("") if not self.__key==-1: Application.vrpApp.key2params[self.__key] = self.__getParams() ObjectMgr().setParams( self.__key, self.__getParams() ) def __setRightDomainEnabling(self, isPartChoice): _infoer.function = str(self.__setRightDomainEnabling) _infoer.write("") self.comboBoxDomain.setEnabled(isPartChoice) if not self.checkBoxFreeStartpoints.isChecked(): self.groupBoxRectPositioning.setEnabled(not isPartChoice) if self.checkBoxDomainFromList.isChecked(): #quick fix show/hide tracer self.checkBox5.setChecked(False) TraceFrom2DStyle = covise.getCoConfigEntry("vr-prepare.TraceFrom2DStyle") if TraceFrom2DStyle and TraceFrom2DStyle == "TRACE_FROM_2D_SAMPLE": pass else : self.numberStartpoints.setEnabled(not isPartChoice) # change interactor checkbox self.checkBox5.setEnabled(not isPartChoice) self.vrpCheckBoxShow.setEnabled((not isPartChoice) and COMPOSED_VELOCITY!=str(self.vrpLineEditVariable.text())) if isPartChoice: self.checkBoxFreeStartpoints.setChecked(False) def setRightDomainEnablingUpdate(self, isPartChoice): _infoer.function = str(self.setRightDomainEnablingUpdate) _infoer.write("") self.__setRightDomainEnabling( isPartChoice ) self.emitTraceParametersApply() def emitFreeStartpoint(self): _infoer.function = str(self.emitFreeStartpoint) _infoer.write("") isFreeStartPoints = self.checkBoxFreeStartpoints.isChecked() self.checkBoxDomainFromList.setChecked(False) self.groupBoxRectPositioning.setEnabled(not isFreeStartPoints) self.emitTraceParametersApply() def __tr(self,s,c = None): _infoer.function = str(self.__tr) _infoer.write("") return coTranslate(s)
class PartVisualizationPanel(QtWidgets.QWidget,Ui_PartVisualizationPanelBase, Visualization2DPanel, TransformManager): sigEditColorMap = pyqtSignal() def __init__(self, parent=None): _infoer.function = str(self.__init__) _infoer.write("") QtWidgets.QWidget.__init__(self, parent) Ui_PartVisualizationPanelBase.__init__(self) self.setupUi(self) Visualization2DPanel.__init__(self) TransformManager.__init__(self, self.emitDataChangedTransform) # list of associated keys from same type self.__keys = [] #default setting self.floatInRangeShininess_2.setRange([0,40.0]) self.floatInRangeShininess_2.setValue(16.0) self.floatInRangeTrans.setRange([0,1.0]) self.floatInRangeTrans.setValue(1.0) self.__floatParams = '' self.__intParams = '' self.__boolParams = '' self.__vec2Params = '' self.__vec3Params = '' self.__vec4Params = '' self.__mat2Params = '' self.__mat3Params = '' self.__mat4Params = '' self.__r = 200 self.__g = 200 self.__b = 200 self.__ambient = [180,180,180] self.__specular = [255,255,130] self.color = NO_COLOR self.colorCreator = None self.vectorVariableNames = [] self.scalarVariableNames = [] self.__baseVariable = 'Select a Variable' self.variablesSet = False self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) # for multi selection self.oldPanelParams = {} self.oldPanelRealParams = {} self.__rectangleManager = RectangleManager( self, self.emitCutChanged, self.emitCutChanged, None, CUTTINGSURFACE ) fillShaderList(self.shaderList) PartVisualizationPanelConnector(self) def setSelectedColormap( self, callerKey, key, name ): _infoer.function = str(self.setSelectedColormap) _infoer.write("") # new colormap was selected in color manager if len(self.__keys)>0 and self.__keys[0]==callerKey: if MainWindow.globalColorManager.setSelectedColormapKey( self.vrpComboboxColorMap_2, key ): self.emitVariableChanged() def paramChanged(self, key): """ params of object key changed""" _infoer.function = str(self.paramChanged) _infoer.write("key %d" %key) #update comes from change within panel #update only for single selection if len(self.__keys) ==1 : if self.__keys[0]==key or (self.__keys[0] in Application.vrpApp.guiKey2visuKey and key==Application.vrpApp.guiKey2visuKey[self.__keys[0]]): self.update() def update(self): _infoer.function = str(self.update) _infoer.write("") if len(self.__keys)!=0 : self.updateForObject( self.__keys ) def updateForObject( self, keys ): """ called from MainWindow to update the content to the choosen object key Default params will be shown if there is more than 1 key""" _infoer.function = str(self.updateForObject) _infoer.write("") if isinstance( keys, int ) : self.__keys = [keys] elif isinstance( keys, list ) and len(keys)>0 : self.__keys = keys else : return # if a type_2d_composed_part disable the first two tabs (coloring and shader) if len(self.__keys)==1 : # enable the visualization and the transform tab self.TabWidgetGeneralAdvanced.setTabEnabled(0, True) self.TabWidgetGeneralAdvanced.setTabEnabled(1, True) self.TabWidgetGeneralAdvanced.setTabEnabled(2, True) self.TabWidgetGeneralAdvanced.setTabEnabled(3, True) if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART: self.TabWidgetGeneralAdvanced.setTabEnabled(0, False) self.TabWidgetGeneralAdvanced.setTabEnabled(1, False) # if not a type_2d_part disable the transform tab if ObjectMgr().getTypeOfObject(self.__keys[0]) != TYPE_2D_PART: self.TabWidgetGeneralAdvanced.setTabEnabled(3, False) # if not a type_2d_cutgeometry_part disable the cut tab if ObjectMgr().getTypeOfObject(self.__keys[0]) != TYPE_2D_CUTGEOMETRY_PART: self.TabWidgetGeneralAdvanced.setTabEnabled(4, False) elif len(self.__keys) > 1 : # multi selection # always show first tab self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # disable the visualization and the transform tab self.TabWidgetGeneralAdvanced.setTabEnabled(2, False) self.TabWidgetGeneralAdvanced.setTabEnabled(3, False) # set the variables of first key self.__setScalarVariables(ObjectMgr().getPossibleScalarVariablesForType(self.__keys[0])) self.__setVectorVariables(ObjectMgr().getPossibleVectorVariablesForType(self.__keys[0])) # apply params if len(self.__keys) == 1 : realparams = ObjectMgr().getRealParamsOfObject(self.__keys[0]) params = ObjectMgr().getParamsOfObject(self.__keys[0]) params.name = realparams.name #params.boundingBox = realparams.boundingBox if isinstance(params, int) or isinstance(params, Part2DRawVisParams): self.__setParams( params ) self.__setRealParams( realparams ) # update Visualization2DPanel.updateForObject(self, self.__keys[0]) elif len(self.__keys) > 1 : # multi selection: show default params self.oldPanelParams = Part2DRawVisParams() params = CopyParams(self.oldPanelParams) self.__setParams( params ) if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_PART: self.oldPanelRealParams = co2DPartMgrParams() if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART: self.oldPanelRealParams = co2DComposedPartMgrParams() if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_CUTGEOMETRY_PART: self.oldPanelRealParams = co2DCutGeometryPartMgrParams() #self.oldPanelRealParams.name = coTranslate("Multiselection") self.oldPanelRealParams.name = "Multiselection" realparams = CopyParams(self.oldPanelRealParams) self.__setRealParams( realparams ) # set ComboBoxVariable on default value self.vrpComboBoxVariable_2.setCurrentIndex(0) def __getParams(self): _infoer.function = str(self.__getParams) _infoer.write("") data = Part2DRawVisParams() #get the coloring option if self.vrpRadioButtonNoColor.isChecked(): data.color = NO_COLOR elif self.vrpRadioButtonColorRGB.isChecked(): data.color = RGB_COLOR elif self.vrpRadioButtonColorMaterial_2.isChecked(): data.color = MATERIAL elif self.vrpRadioButtonColorVariable_2.isChecked(): data.color = VARIABLE # rgb data.r = self.__r data.g = self.__g data.b = self.__b # material data.ambient = self.__ambient data.specular = self.__specular data.shininess = self.floatInRangeShininess_2.getValue() # variable coloring data.allVariables = [] for i in range(self.vrpComboBoxVariable_2.count()): data.allVariables.append(str(self.vrpComboBoxVariable_2.itemText(i))) data.variable = str(self.vrpComboBoxVariable_2.currentText()) data.colorTableKey = self.colorCreator if self.__baseVariable and self.__baseVariable==data.variable and data.colorTableKey: data.colorTableKey[data.variable] = MainWindow.globalColorManager.getSelectedColormapKey( self.vrpComboboxColorMap_2) #transparency data.transparency = self.floatInRangeTrans.getValue() data.transparencyOn = self.vrpCheckBoxTransparency.isChecked() #transform card self.TransformManagerGetParams(data) # shader data.shaderFilename = str(self.shaderList.currentItem().text()) data.isVisible = True return data def __setParams( self, params ): _infoer.function = str(self.__setParams) _infoer.write("") PartVisualizationPanelBlockSignals(self, True) self.TransformManagerBlockSignals(True) if isinstance( params, int): self.__keys[0] = params return # rgb color self.__r=params.r self.__g=params.g self.__b=params.b # material self.floatInRangeShininess_2.setValue(params.shininess) self.__ambient = params.ambient self.__specular = params.specular # transparency self.vrpCheckBoxTransparency.setChecked(params.transparencyOn) self.floatInRangeTrans.setEnabled(params.transparencyOn) self.floatInRangeTrans.setValue(params.transparency) if len(params.allVariables)>0: self.vrpComboBoxVariable_2.clear() index = 0 for var in params.allVariables: self.vrpComboBoxVariable_2.insertItem(index, var) if var == params.variable: self.vrpComboBoxVariable_2.setCurrentIndex(index) index+= 1 # colortable currentVariable = params.variable self.__baseVariable = currentVariable currentColorTableKey = None if currentVariable!=None and params.colorTableKey!=None and currentVariable in params.colorTableKey: currentColorTableKey = params.colorTableKey[currentVariable] MainWindow.globalColorManager.update( self.vrpComboboxColorMap_2, currentVariable, currentColorTableKey ) self.colorCreator=params.colorTableKey # set the radio buttons self.color = params.color if self.color == NO_COLOR: self.vrpRadioButtonNoColor.setChecked(True) self.vrpRadioButtonColorRGB.setChecked(False) self.vrpRadioButtonColorMaterial_2.setChecked(False) self.vrpRadioButtonColorVariable_2.setChecked(False) self.__changeNoColor(True) self.__changeRGB(False) self.__changeMaterial(False) self.__changeVariable(False) elif self.color == RGB_COLOR: self.vrpRadioButtonNoColor.setChecked(False) self.vrpRadioButtonColorRGB.setChecked(True) self.vrpRadioButtonColorMaterial_2.setChecked(False) self.vrpRadioButtonColorVariable_2.setChecked(False) self.__changeNoColor(False) self.__changeRGB(True) self.__changeMaterial(False) self.__changeVariable(False) elif self.color == MATERIAL: self.vrpRadioButtonNoColor.setChecked(False) self.vrpRadioButtonColorRGB.setChecked(False) self.vrpRadioButtonColorMaterial_2.setChecked(True) self.vrpRadioButtonColorVariable_2.setChecked(False) self.__changeNoColor(False) self.__changeRGB(False) self.__changeMaterial(True) self.__changeVariable(False) elif self.color == VARIABLE: self.vrpRadioButtonNoColor.setChecked(False) self.vrpRadioButtonColorRGB.setChecked(False) self.vrpRadioButtonColorMaterial_2.setChecked(False) self.vrpRadioButtonColorVariable_2.setChecked(True) self.__changeNoColor(False) self.__changeRGB(False) self.__changeMaterial(False) self.__changeVariable(True) #transform card self.TransformManagerSetParams(params) # shader selectInShaderList(self.shaderList, params.shaderFilename) self.TransformManagerBlockSignals(False) PartVisualizationPanelBlockSignals(self, False) # for multi selection if len(self.__keys)>1 : self.oldPanelParams = params # Note: RealParams is a special case for PartVisualizationPanel since we have two objects behind the panel. # realparams correlates to co2DPartMgr and params to Part2DRawVis # DON'T COPY THE REALPARAMS-MECHANISM TO OTHER PANELS. def __setRealParams( self, params ): _infoer.function = str(self.__setRealParams) _infoer.write("") PartVisualizationPanelBlockSignals(self, True) self.nameWidget.setText(params.name) if isinstance(params, co2DCutGeometryPartMgrParams): self.__rectangleManager.setRectangle( params.alignedRectangle ) # bounding box is param of part not of visualizer, so set as real param if hasattr(params, 'boundingBox') and params.boundingBox: self.__rectangleManager.setBoundingBox( params.boundingBox ) PartVisualizationPanelBlockSignals(self, False) # for multi selection if len(self.__keys)>1 : self.oldPanelRealParams = params # emitter for the qt buttons # select a new rgb color def emitColorRGB(self): _infoer.function = str(self.emitColorRGB) _infoer.write("") color = QtWidgets.QColorDialog.getColor(QtGui.QColor(self.__r,self.__g,self.__b),self) if color.isValid(): self.__r=color.red() self.__g=color.green() self.__b =color.blue() self.emitDataChanged() # select diffuse color of material def emitColorDiffuse(self): _infoer.function = str(self.emitColorDiffuse) _infoer.write("") color = QtWidgets.QColorDialog.getColor(QtGui.QColor(self.__r,self.__g,self.__b),self) if color.isValid(): self.__r=color.red() self.__g=color.green() self.__b =color.blue() self.emitDataChanged() # select ambient color of material def emitColorAmbient(self): _infoer.function = str(self.emitColorAmbient) _infoer.write("") color = QtWidgets.QColorDialog.getColor(QtGui.QColor(self.__ambient[0],self.__ambient[1],self.__ambient[2]),self) if color.isValid(): self.__ambient=(color.red(),color.green(),color.blue()) self.emitDataChanged() # select specular color of material def emitColorSpecular(self): _infoer.function = str(self.emitColorSpecular) _infoer.write("") color = QtWidgets.QColorDialog.getColor(QtGui.QColor(self.__specular[0],self.__specular[1],self.__specular[2]),self) if color.isValid(): self.__specular=(color.red(),color.green(),color.blue()) self.emitDataChanged() # change the name of the appearance (only for single selection) def emitNameChange(self, aQString=None): _infoer.function = str(self.emitNameChange) _infoer.write("") # only for single selection if len(self.__keys)==1 : #MainWindow.globalAccessToTreeView.setItemData(self.__keys[0], str(self.nameWidget.text())) # set name of type_2d_part params = ObjectMgr().getRealParamsOfObject(self.__keys[0]) params.name = str(self.nameWidget.text()) Application.vrpApp.key2params[self.__keys[0]] = params ObjectMgr().setParams(self.__keys[0], params) self.emitDataChanged() # any data of Part2DRawVis has changed(works on multi-selection) def emitDataChanged(self): _infoer.function = str(self.emitDataChanged) _infoer.write("") if len(self.__keys)>0 and not ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART: ##all key types in self.keys should be the same # mapping of the keys for the object manager childKeys = [Application.vrpApp.guiKey2visuKey[k] for k in self.__keys] params = self.__getParams() if len(self.__keys)==1 : Application.vrpApp.key2params[childKeys[0]] = params ObjectMgr().setParams( childKeys[0], params ) #theGuiMsgHandler().runObject( childKey ) # set params for multi selection if len(self.__keys)>1 : #find changed params originalParams = self.oldPanelParams realChange = ParamsDiff( originalParams, params ) # set params for remaining selected objects for i in range(0, len(self.__keys)): childKeyParams = ObjectMgr().getParamsOfObject(childKeys[i]) # find the changed param in childKey and replace it with the # intended attribut for x in realChange : childKeyParams.__dict__[x] = params.__dict__[x] # set the params Application.vrpApp.key2params[childKeys[i]] = childKeyParams ObjectMgr().setParams( childKeys[i], childKeyParams ) #theGuiMsgHandler().runObject( childKeys[i] ) #save params for multi selection self.oldPanelParams = self.__getParams() def emitDataChangedTransform(self): _infoer.function = str(self.emitDataChangedTransform) _infoer.write("") #TODO multi selection if len(self.__keys)==1 : if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_PART: childKey = Application.vrpApp.guiKey2visuKey[self.__keys[0]] params = self.__getParams() Application.vrpApp.key2params[childKey] = params ObjectMgr().setParams( childKey, params ) theGuiMsgHandler().runObject( childKey ) # select a new variable for coloring def emitVariableChanged(self): _infoer.function = str(self.emitVariableChanged) _infoer.write("") if len(self.__keys)>0 and not ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART: ##all key types in self.keys should be the same # mapping of the keys for the object manager childKeys = [] for i in range(0, len(self.__keys)): childKeys.append(Application.vrpApp.guiKey2visuKey[self.__keys[i]]) params = self.__getParams() if len(self.__keys)==1 : Application.vrpApp.key2params[childKeys[0]] = self.__getParams() ObjectMgr().setParams( childKeys[0], params ) reqId = theGuiMsgHandler().setParams( childKeys[0], params ) theGuiMsgHandler().waitforAnswer(reqId) theGuiMsgHandler().runObject( childKeys[0] ) self.__setParams( self.__getParams() )#necessary for allVariablesList # set params for multi selection if len(self.__keys)>1 : # find changed params originalParams = self.oldPanelParams realChange = ParamsDiff( originalParams, params ) # set params for remaining selected objects for i in range(0, len(self.__keys)): childKeyParams = ObjectMgr().getParamsOfObject(childKeys[i]) # find the changed param in childKey and replace it with the # intended attribut for x in realChange : childKeyParams.__dict__[x] = params.__dict__[x] # set the params Application.vrpApp.key2params[childKeys[i]] = childKeyParams ObjectMgr().setParams( childKeys[i], childKeyParams ) reqId = theGuiMsgHandler().setParams( childKeys[i], childKeyParams ) theGuiMsgHandler().waitforAnswer(reqId) theGuiMsgHandler().runObject( childKeys[i] ) #necessary for allVariablesList self.__setParams( self.__getParams() ) #save params for multi selection self.oldPanelParams = self.__getParams() # the cut data has changed def emitCutChanged(self): _infoer.function = str(self.emitCutChanged) _infoer.write("") if len(self.__keys)>0 and ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_CUTGEOMETRY_PART: params = ObjectMgr().getRealParamsOfObject(self.__keys[0]) params.alignedRectangle = self.__rectangleManager.getParams() if len(self.__keys)==1 : Application.vrpApp.key2params[self.__keys[0]] = params ObjectMgr().setParams(self.__keys[0], params ) theGuiMsgHandler().runObject(self.__keys[0]) # set params for multi selection if len(self.__keys)>1 : #find changed params originalParams = self.oldPanelRealParams realChange = ParamsDiff( originalParams, params ) # set params for remaining selected objects for i in range(0, len(self.__keys)): childKeyParams = ObjectMgr().getRealParamsOfObject(self.__keys[i]) # find the changed param in childKey and replace it with the # intended attribut for x in realChange : childKeyParams.__dict__[x] = params.__dict__[x] # set the params Application.vrpApp.key2params[self.__keys[i]] = childKeyParams ObjectMgr().setParams( self.__keys[i], childKeyParams ) theGuiMsgHandler().runObject( self.__keys[i] ) #save params for multi selection self.oldPanelRealParams = CopyParams(params) # the selected radiobutton has changed (original color/ rgb / material / variable) def emitChangedRadioGroup(self): _infoer.function = str(self.emitChangedRadioGroup) _infoer.write("") if self.vrpRadioButtonNoColor.isChecked(): self.__changeNoColor(True) self.__changeRGB(False) self.__changeMaterial(False) self.__changeVariable(False) self.emitDataChanged() if self.vrpRadioButtonColorRGB.isChecked(): self.__changeNoColor(False) self.__changeRGB(True) self.__changeMaterial(False) self.__changeVariable(False) self.emitDataChanged() elif self.vrpRadioButtonColorMaterial_2.isChecked(): self.__changeNoColor(False) self.__changeRGB(False) self.__changeMaterial(True) self.__changeVariable(False) self.emitDataChanged() elif self.vrpRadioButtonColorVariable_2.isChecked(): self.__changeNoColor(False) self.__changeRGB(False) self.__changeMaterial(False) self.__changeVariable(True) if not self.vrpComboBoxVariable_2.currentText()=="Select a variable" and not self.vrpComboBoxVariable_2.currentText()=="": self.emitVariableChanged() # transparence checkbox has changed def emitTransChecked(self): _infoer.function = str(self.emitTransChecked) _infoer.write("") if self.vrpCheckBoxTransparency.isChecked(): self.floatInRangeTrans.setEnabled(True) else: self.floatInRangeTrans.setEnabled(False) self.emitDataChanged() # colormap changes def emitCustomizeColorMap(self): _infoer.function = str(self.emitCustomizeColorMap) _infoer.write("") # only one popup is needed, so call for key[0] self.sigEditColorMap.emit(self.__keys[0], MainWindow.globalColorManager.getSelectedColormapKey( self.vrpComboboxColorMap_2 ) ) # private helper functions for class # ----------------------------------# # enables and disables different coloroptions def __changeNoColor(self, on): _infoer.function = str(self.__changeNoColor) _infoer.write("") self.color = NO_COLOR def __changeRGB(self, on): _infoer.function = str(self.__changeRGB) _infoer.write("") self.color = RGB_COLOR self.vrpPushButtonColorRGB.setEnabled(on) def __changeMaterial(self, on): _infoer.function = str(self.__changeMaterial) _infoer.write("") self.color = MATERIAL self.vrpPushButtonAmbientRGB_2.setEnabled(on) self.vrpPushButtonDiffuseRGB_2.setEnabled(on) self.vrpPushButtonSpecularRGB_2.setEnabled(on) self.textLabel4_4_3_4_2.setEnabled(on) self.floatInRangeShininess_2.setEnabled(on) def __changeVariable(self, on): _infoer.function = str(self.__changeVariable) _infoer.write("") self.color = VARIABLE self.vrpComboBoxVariable_2.setEnabled(on) self.vrpLabelVariable_2.setEnabled(on) if not self.vrpComboBoxVariable_2.currentText()=="Select a variable": self.vrpComboboxColorMap_2.setEnabled(on) self.vrpLabelColorMap_2.setEnabled(on) self.vrpPushButtonCustomizeColorMap_2.setEnabled(on) else: self.vrpComboboxColorMap_2.setEnabled(False) self.vrpLabelColorMap_2.setEnabled(False) self.vrpPushButtonCustomizeColorMap_2.setEnabled(False) # sets the list of the variables and set the combobox def __setVectorVariables(self, aNameList): _infoer.function = str(self.__setVectorVariables) _infoer.write("") self.vectorVariableNames = aNameList self.__fillVariables() def __setScalarVariables(self, aNameList): _infoer.function = str(self.__setScalarVariables) _infoer.write("") self.scalarVariableNames = aNameList self.__fillVariables() #fill the combobox with the variables def __fillVariables(self): _infoer.function = str(self.__fillVariables) _infoer.write("") self.variablesSet = True self.vrpComboBoxVariable_2.clear() self.vrpComboBoxVariable_2.addItem("Select a variable") self.varColor = {} for aName in self.vectorVariableNames: self.vrpComboBoxVariable_2.addItem(aName) for aName in self.scalarVariableNames: self.vrpComboBoxVariable_2.addItem(aName) self.__baseVariable = self.vrpComboBoxVariable_2.currentText() self.vrpComboboxColorMap_2.clear()
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) Ui_GenericVisualizerPanelBase.__init__(self) self.setupUi(self) #current object self.__key = -1 self.vrpPushButtonAdjustPreview.hide() self.floatInRangeRotX.setEnabled(False) self.floatInRangeRotY.setEnabled(True) self.floatInRangeRotZ.setEnabled(True) self.floatInRangeEndPointX.hide() self.floatInRangeEndPointY.hide() self.floatInRangeEndPointZ.hide() self.textEndPointX.hide() self.textEndPointY.hide() self.textEndPointZ.hide() self.vrpCheckBoxShow.setText(self.__tr("Show Preview")) self.vrpGroupBoxPositioning.setTitle(self.__tr("Plane Positioning")) self.checkBoxFreeStartpoints.hide() self.vrpCheckBoxMapVariable.hide() self.vrpComboBoxVariable.hide() self.textLabel4_3_3.hide() self.floatInRangeWidth.hide() self.textLabel4_3_2_3.hide() self.floatInRangeHeight.hide() self.checkBoxDomainFromList.hide() self.comboBoxDomain.hide() self.checkBoxFreeStartpoints.hide() self.groupOrientation.setTitle(self.__tr("Normal:")) # change tooltips self.textLabel4_4_3.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_3.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_3.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_3.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_2_2.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_2_2.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.xAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.xAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.yAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.yAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.zAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.zAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.textLabelRotX.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotX.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotY.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotY.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotZ.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotZ.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentStreamline)) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdvanced)) self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) self.visibilityCheckBox.setVisible(covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox", False)) # manager handling the starting rectangle self.__rectangleManager = RectangleManager( self, self.emitPlaneParametersApply, self.emitPlaneParametersApply, self.emitRectangleChange, CUTTINGSURFACE ) self.__vector = PLANE self.__baseVariable = None #temporary storage of this parameter part self.colorCreator = None #qt connections and settings CuttingSurfacePanelConnector(self)
class CuttingSurfacePanel(QtWidgets.QWidget,Ui_GenericVisualizerPanelBase): """ For controling parameters of a cutting surface """ sigVisibiliyToggled = pyqtSignal() sigEditColorMap = pyqtSignal() def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) Ui_GenericVisualizerPanelBase.__init__(self) self.setupUi(self) #current object self.__key = -1 self.vrpPushButtonAdjustPreview.hide() self.floatInRangeRotX.setEnabled(False) self.floatInRangeRotY.setEnabled(True) self.floatInRangeRotZ.setEnabled(True) self.floatInRangeEndPointX.hide() self.floatInRangeEndPointY.hide() self.floatInRangeEndPointZ.hide() self.textEndPointX.hide() self.textEndPointY.hide() self.textEndPointZ.hide() self.vrpCheckBoxShow.setText(self.__tr("Show Preview")) self.vrpGroupBoxPositioning.setTitle(self.__tr("Plane Positioning")) self.checkBoxFreeStartpoints.hide() self.vrpCheckBoxMapVariable.hide() self.vrpComboBoxVariable.hide() self.textLabel4_3_3.hide() self.floatInRangeWidth.hide() self.textLabel4_3_2_3.hide() self.floatInRangeHeight.hide() self.checkBoxDomainFromList.hide() self.comboBoxDomain.hide() self.checkBoxFreeStartpoints.hide() self.groupOrientation.setTitle(self.__tr("Normal:")) # change tooltips self.textLabel4_4_3.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_3.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_3.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_3.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_2_2.setToolTip(self.__tr("x, y, z define one point on the plane.")) self.textLabel4_4_2_2_2.setWhatsThis(self.__tr("x, y, z define one point on the plane.")) self.xAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.xAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.yAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.yAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.zAxisRadioButton.setToolTip(self.__tr("Orientation defines the normal of the plane.")) self.zAxisRadioButton.setWhatsThis(self.__tr("Orientation defines the normal of the plane.")) self.textLabelRotX.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotX.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotY.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotY.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotZ.setToolTip(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.textLabelRotZ.setWhatsThis(self.__tr("For finetuning the orientation<br> of the plane, you can add rotations around each axis.")) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentStreamline)) self.TabWidgetGeneralAdvanced.removeTab(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdvanced)) self.TabWidgetGeneralAdvanced.setCurrentIndex(0) # ignore index set by the designer (usually no one cares about the active index when editing ui-files) self.visibilityCheckBox.setVisible(covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox", False)) # manager handling the starting rectangle self.__rectangleManager = RectangleManager( self, self.emitPlaneParametersApply, self.emitPlaneParametersApply, self.emitRectangleChange, CUTTINGSURFACE ) self.__vector = PLANE self.__baseVariable = None #temporary storage of this parameter part self.colorCreator = None #qt connections and settings CuttingSurfacePanelConnector(self) def setSelectedColormap( self, callerKey, key, name): # new colormap was selected in color manager if (self.__key == callerKey): if MainWindow.globalColorManager.setSelectedColormapKey( self.colorMapCombobox, key ): self.emitPlaneParametersApply() def paramChanged( self, key ): """ params of object key changed""" if self.__key==key: self.update() def update( self ): if self.__key!=-1: self.updateForObject( self.__key ) def updateForObject( self, key ): """ called from MainWindow to update the content to the choosen object key """ self.__key = key params = ObjectMgr().getParamsOfObject(key) self.__setParams( params ) def __getParams(self): """ convert information in the panel into the right negotiator param classes """ if self.__vector==PLANE: data = PartPlaneVisParams() elif self.__vector==VECTOR: data = PartVectorVisParams() data.length = self.cuttingSurfaceLength.currentIndex()+1 data.scale = getDoubleInLineEdit(self.cuttingSurfaceScale) data.arrow_head_factor = getDoubleInLineEdit(self.cuttingSurfaceArrowHead) data.project_arrows = self.checkBoxProjectArrows.isChecked() data.vector = self.__vector data.name = str(self.nameWidget.text()) data.isVisible = self.visibilityCheckBox.isChecked() data.variable = str(self.vrpLineEditVariable.text()) data.colorTableKey = self.colorCreator if self.__baseVariable and self.__baseVariable==data.variable and data.colorTableKey: data.colorTableKey[data.variable] = MainWindow.globalColorManager.getSelectedColormapKey( self.colorMapCombobox) data.alignedRectangle = self.__rectangleManager.getParams() data.boundingBox = self.__rectangleManager.getBoundingBox() data.showSmoke= self.vrpCheckBoxShow.isChecked() data.showInteractor = self.checkBox5.isChecked() data.attachedClipPlane_index = self.ClipPlaneIndexCombo.currentIndex()-1 data.attachedClipPlane_offset = getDoubleInLineEdit(self.vrpLineEditClipPlaneOffset) data.attachedClipPlane_flip = self.ClipPlaneFlipCheckbox.isChecked() return data def __panelAccordingTaskType( self ): """ change the panel according the needs of the visualizer NOTE: changes identical for all types should be done in __init__ """ if self.__vector==PLANE: self.TabWidgetGeneralAdvanced.setTabEnabled(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface), False) text = "Edit Plane on Cutting Surface:" ColoredCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.ColoredCuttingSurfaceText") if ColoredCuttingSurfaceText: text = ColoredCuttingSurfaceText self.vrpLabelTitle.setText(self.__tr(text)) self.vrpCheckBoxShow.show() if self.__vector==VECTOR: self.vrpCheckBoxShow.hide() self.TabWidgetGeneralAdvanced.setTabEnabled(self.TabWidgetGeneralAdvanced.indexOf(self.tabAdjustmentCuttingSurface), True) text = "Edit Arrows on Cutting Surface:" ArrowsOnCuttingSurfaceText = covise.getCoConfigEntry("vr-prepare.ArrowsOnCuttingSurfaceText") if ArrowsOnCuttingSurfaceText: text = ArrowsOnCuttingSurfaceText self.vrpLabelTitle.setText(self.__tr(text)) title = "Arrows on Cutting Plane Adjustment" ArrowsOnCuttingSurfaceAdjustmentText = covise.getCoConfigEntry("vr-prepare.ArrowsOnCuttingSurfaceAdjustmentText") if ArrowsOnCuttingSurfaceAdjustmentText: title = ArrowsOnCuttingSurfaceAdjustmentText self.vrpGroupBoxAdjustment.setTitle(self.__tr(title)) def __setParams( self, params ): """ set update the panel with the information in the negotiator param class """ CuttingSurfacePanelBlockSignals( self, True ) if isinstance( params, int): self.__key = params return self.__vector = params.vector self.__panelAccordingTaskType() self.nameWidget.setText(params.name) if hasattr(params, 'isVisible' ): self.visibilityCheckBox.setChecked(params.isVisible) if hasattr(params, 'variable' ): self.vrpLineEditVariable.setText(params.variable) currentVariable = params.variable self.__baseVariable = currentVariable currentColorTableKey = None if currentVariable!=None and params.colorTableKey!=None and currentVariable in params.colorTableKey: currentColorTableKey = params.colorTableKey[currentVariable] MainWindow.globalColorManager.update( self.colorMapCombobox, currentVariable, currentColorTableKey) if hasattr(params.boundingBox, 'getXMin' ): self.__boundingBox = params.boundingBox self.__rectangleManager.setBoundingBox( params.boundingBox ) self.__rectangleManager.setRectangle( params.alignedRectangle ) if hasattr(params, 'scale'): self.cuttingSurfaceScale.setText(str(params.scale)) if hasattr(params, 'arrow_head_factor'): self.cuttingSurfaceArrowHead.setText(str(params.arrow_head_factor)) else: self.cuttingSurfaceArrowHead.setText("0.2") if hasattr(params, 'project_arrows'): self.checkBoxProjectArrows.setChecked(params.project_arrows) #set cursor to begin of field self.cuttingSurfaceScale.home(False) if hasattr(params, 'length'): self.cuttingSurfaceLength.setCurrentIndex(params.length-1) self.vrpCheckBoxShow.setChecked(params.showSmoke) self.checkBox5.setChecked(params.showInteractor) self.colorCreator=params.colorTableKey self.ClipPlaneIndexCombo.setCurrentIndex(params.attachedClipPlane_index + 1) self.vrpLineEditClipPlaneOffset.setText(str(params.attachedClipPlane_offset)) self.vrpLineEditClipPlaneOffset.setEnabled(self.ClipPlaneIndexCombo.currentIndex()>0) self.ClipPlaneFlipCheckbox.setChecked(params.attachedClipPlane_flip) self.ClipPlaneFlipCheckbox.setEnabled(self.ClipPlaneIndexCombo.currentIndex()>0) CuttingSurfacePanelBlockSignals( self, False ) def emitPlaneParametersApply(self): if not self.__key==-1: Application.vrpApp.key2params[self.__key] = self.__getParams() ObjectMgr().setParams( self.__key, self.__getParams() ) theGuiMsgHandler().runObject( self.__key ) _infoer.function = str(self.emitPlaneParametersApply) _infoer.write("") def emitNameChange(self, aQString=None): if self.__key!=-1: MainWindow.globalAccessToTreeView.setItemData(self.__key, str(self.nameWidget.text())) self.emitPlaneParametersApply() def emitVisibilityToggled(self, b): self.sigVisibiliyToggled.emit((b,)) self.emitRectangleChange(b) def emitClipPlaneChanged(self): if not self.__key==-1: self.vrpLineEditClipPlaneOffset.setEnabled(self.ClipPlaneIndexCombo.currentIndex()>0) self.ClipPlaneFlipCheckbox.setEnabled(self.ClipPlaneIndexCombo.currentIndex()>0) Application.vrpApp.key2params[self.__key] = self.__getParams() ObjectMgr().setParams( self.__key, self.__getParams() ) def emitCustomizeColorMap(self): self.sigEditColorMap.emit( self.__key, MainWindow.globalColorManager.getSelectedColormapKey( self.colorMapCombobox )) def emitRectangleChange(self, val=False): if not self.__key==-1: Application.vrpApp.key2params[self.__key] = self.__getParams() ObjectMgr().setParams( self.__key, self.__getParams() ) def __setRightDomainEnabling(self, isPartChoice): self.checkBox5.setEnabled(not isPartChoice) self.vrpCheckBoxShow.setEnabled(not isPartChoice) def setRightDomainEnablingUpdate(self, isPartChoice): self.__setRightDomainEnabling( isPartChoice ) self.emitPlaneParametersApply() def __tr(self,s,c = None): return coTranslate(s)