示例#1
0
    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)
示例#2
0
    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)