Exemplo n.º 1
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        Ui_IsoCutterPanelBase.__init__(self)
        self.setupUi(self)
        #current object key
        self.__key = -1

        #default setting of the panel
        self.vrpCheckBoxMapVariable.setEnabled(False)
        self.vrpComboBoxVariable.setEnabled(False)
        self.visibilityCheckBox.setVisible(
            covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox",
                                False))

        self.__baseVariable = None

        #temporary storage of this parameter part
        self.colorCreator = {}

        middleFloatInRangeCtrls = [self.floatInRangeIsoValue]
        self.__boundingBox = Box()
        for w, r in zip(middleFloatInRangeCtrls,
                        self.__boundingBox.getTuple()):
            w.setRange(r)
        sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(
            self.__boundingBox.getTuple())

        IsoCutterPanelConnector(self)
Exemplo n.º 2
0
    def __init__(self, parent, doApply, doApplyRadioBttn, doParamChange, typeRec=TRACER, startStyle = PLANE):
        QtCore.QObject.__init__(self)

        assert parent
        assert doApply

        #slots to be registered by parent
        self.__parent = parent
        self.__apply = doApply
        self.__applyRadioBttn = doApplyRadioBttn
        self.__paramChange = doParamChange
        self.__type = typeRec

        middleFloatInRangeCtrls = [ self.__parent.floatInRangeX, self.__parent.floatInRangeY, self.__parent.floatInRangeZ  ]
        sideFloatInRangeCtrls = []
        rotFloatInRangeCtrls = []
        endPointFloatInRangeCtrls = []

        # a streamlines panel will have these widgets so they will get connected
        if typeRec == TRACER:
            endPointFloatInRangeCtrls = [ self.__parent.floatInRangeEndPointX, self.__parent.floatInRangeEndPointY, self.__parent.floatInRangeEndPointZ  ]

        self.__boundingBox = ((-1, 1), (-1, 1), (-1, 1))
        for w, r in zip(middleFloatInRangeCtrls, self.__boundingBox):
            w.setRange(r)
        #if not typeRec == POINTPROBING:
        if startStyle == PLANE:
            sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(self.__boundingBox)
            if self.__type == TRACER:
                sideFloatInRangeCtrls = [self.__parent.floatInRangeWidth, self.__parent.floatInRangeHeight]
                for w in sideFloatInRangeCtrls:
                    w.setRange(sideRange)
            rotFloatInRangeCtrls = [ self.__parent.floatInRangeRotX, self.__parent.floatInRangeRotY, self.__parent.floatInRangeRotZ  ]
            for w in rotFloatInRangeCtrls:
                w.setRange((-180.,180.))
        elif startStyle == LINE:
            endPointFloatInRangeCtrls = [ self.__parent.floatInRangeEndPointX, self.__parent.floatInRangeEndPointY, self.__parent.floatInRangeEndPointZ  ]
            for w, r in zip(endPointFloatInRangeCtrls, self.__boundingBox):
                w.setRange(r)
            sideFloatInRangeCtrls = []
            rotFloatInRangeCtrls = []
        #else:
        #    sideFloatInRangeCtrls = []
        #    rotFloatInRangeCtrls = []

        for w in middleFloatInRangeCtrls + sideFloatInRangeCtrls + rotFloatInRangeCtrls + endPointFloatInRangeCtrls:
            w.sigSliderReleased.connect(self.__apply)
            if self.__paramChange:
                w.sigValueChanged.connect(self.__paramChange)

        #if not typeRec == POINTPROBING:
        for w in [self.__parent.xAxisRadioButton,
                self.__parent.yAxisRadioButton,
                self.__parent.zAxisRadioButton]:
            w.clicked.connect(self.__radioButtonClick)

        self.__boundingBox = Box((-1, 1), (-1, 1), (-1, 1))
Exemplo n.º 3
0
    def getPartsBoundingBox(self):
        """ get the bounding box from all originally unfiltered/untransformed/unreduced/un... import modules """

        box = Box((0, 0), (0, 0), (0, 0))
        for key in globalKeyHandler().getAllElements():
            # get bounding box of all parts
            if globalKeyHandler().getObject(key) and globalKeyHandler(
            ).getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]:
                tmpBB = globalKeyHandler().getObject(
                    key).importModule.getBoxFromGeoRWCovise()
                box = box + tmpBB
        return box
Exemplo n.º 4
0
    def executeSampleData(self, varname, bbox=None, outside=USER_DEFINED):
        if not covise.coConfigIsOn("vr-prepare.UseSamplingModules", False):
            return

        if bbox==None:
            if not (varname,outside) in self._bbox:
                self._bbox[(varname,outside)] = Box()
            box = self._bbox[(varname,outside)]
        else:
            box = bbox
        self._updateSample( varname, box, outside)                   
        sample = self._sample[(varname,outside)]

        saveExecute(sample)
Exemplo n.º 5
0
    def _initSample( self, varname, outside ):
        if not (varname,outside) in self._sample:
            self._sample[(varname,outside)] = Sample()
            theNet().add(self._sample[(varname,outside)])
            self._bbox[(varname,USER_DEFINED)] = Box()
            self._bbox[(varname,MAX_FLT)] = Box()

#            connect( Import3DModule.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') )
#            connect( Import3DModule.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') )
            connect( ParentClass3D.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') )
            connect( ParentClass3D.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') )

            sample = self._sample[(varname,outside)]
            sample.set_outside(outside)
            if not ParentClass3D.executeOct(self) and not ParentClass3D.executeData(self, varname):
                saveExecute(sample)

        # reconnect Sample
#        print "RECONNECTING 3D SAMPLE"
        theNet().disconnectAllFromModulePort(self._sample[(varname,outside)], 'GridIn')
        theNet().disconnectAllFromModulePort(self._sample[(varname,outside)], 'DataIn')
        connect( ParentClass3D.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') )
        connect( ParentClass3D.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') )
Exemplo n.º 6
0
    def __init__(self,
                 parent,
                 doApply,
                 doApplyRadioBttn,
                 doParamChange,
                 typeRec=TRACER,
                 startStyle=PLANE):
        QtCore.QObject.__init__(self)

        assert parent
        assert doApply

        #slots to be registered by parent
        self.__parent = parent
        self.__apply = doApply
        self.__applyRadioBttn = doApplyRadioBttn
        self.__paramChange = doParamChange
        self.__type = typeRec

        middleFloatInRangeCtrls = [
            self.__parent.floatInRangeX, self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ
        ]
        sideFloatInRangeCtrls = []
        rotFloatInRangeCtrls = []
        endPointFloatInRangeCtrls = []

        # a streamlines panel will have these widgets so they will get connected
        if typeRec == TRACER:
            endPointFloatInRangeCtrls = [
                self.__parent.floatInRangeEndPointX,
                self.__parent.floatInRangeEndPointY,
                self.__parent.floatInRangeEndPointZ
            ]

        self.__boundingBox = ((-1, 1), (-1, 1), (-1, 1))
        for w, r in zip(middleFloatInRangeCtrls, self.__boundingBox):
            w.setRange(r)
        #if not typeRec == POINTPROBING:
        if startStyle == PLANE:
            sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(
                self.__boundingBox)
            if self.__type == TRACER:
                sideFloatInRangeCtrls = [
                    self.__parent.floatInRangeWidth,
                    self.__parent.floatInRangeHeight
                ]
                for w in sideFloatInRangeCtrls:
                    w.setRange(sideRange)
            rotFloatInRangeCtrls = [
                self.__parent.floatInRangeRotX, self.__parent.floatInRangeRotY,
                self.__parent.floatInRangeRotZ
            ]
            for w in rotFloatInRangeCtrls:
                w.setRange((-180., 180.))
        elif startStyle == LINE:
            endPointFloatInRangeCtrls = [
                self.__parent.floatInRangeEndPointX,
                self.__parent.floatInRangeEndPointY,
                self.__parent.floatInRangeEndPointZ
            ]
            for w, r in zip(endPointFloatInRangeCtrls, self.__boundingBox):
                w.setRange(r)
            sideFloatInRangeCtrls = []
            rotFloatInRangeCtrls = []
        #else:
        #    sideFloatInRangeCtrls = []
        #    rotFloatInRangeCtrls = []

        for w in middleFloatInRangeCtrls + sideFloatInRangeCtrls + rotFloatInRangeCtrls + endPointFloatInRangeCtrls:
            w.sigSliderReleased.connect(self.__apply)
            if self.__paramChange:
                w.sigValueChanged.connect(self.__paramChange)

        #if not typeRec == POINTPROBING:
        for w in [
                self.__parent.xAxisRadioButton, self.__parent.yAxisRadioButton,
                self.__parent.zAxisRadioButton
        ]:
            w.clicked.connect(self.__radioButtonClick)

        self.__boundingBox = Box((-1, 1), (-1, 1), (-1, 1))
Exemplo n.º 7
0
class RectangleManager(QtCore.QObject):
    """
        general gui class to handle the rectangle in VRPStreamlineBase
        used by different VisItem panels
    """
    def __init__(self,
                 parent,
                 doApply,
                 doApplyRadioBttn,
                 doParamChange,
                 typeRec=TRACER,
                 startStyle=PLANE):
        QtCore.QObject.__init__(self)

        assert parent
        assert doApply

        #slots to be registered by parent
        self.__parent = parent
        self.__apply = doApply
        self.__applyRadioBttn = doApplyRadioBttn
        self.__paramChange = doParamChange
        self.__type = typeRec

        middleFloatInRangeCtrls = [
            self.__parent.floatInRangeX, self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ
        ]
        sideFloatInRangeCtrls = []
        rotFloatInRangeCtrls = []
        endPointFloatInRangeCtrls = []

        # a streamlines panel will have these widgets so they will get connected
        if typeRec == TRACER:
            endPointFloatInRangeCtrls = [
                self.__parent.floatInRangeEndPointX,
                self.__parent.floatInRangeEndPointY,
                self.__parent.floatInRangeEndPointZ
            ]

        self.__boundingBox = ((-1, 1), (-1, 1), (-1, 1))
        for w, r in zip(middleFloatInRangeCtrls, self.__boundingBox):
            w.setRange(r)
        #if not typeRec == POINTPROBING:
        if startStyle == PLANE:
            sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(
                self.__boundingBox)
            if self.__type == TRACER:
                sideFloatInRangeCtrls = [
                    self.__parent.floatInRangeWidth,
                    self.__parent.floatInRangeHeight
                ]
                for w in sideFloatInRangeCtrls:
                    w.setRange(sideRange)
            rotFloatInRangeCtrls = [
                self.__parent.floatInRangeRotX, self.__parent.floatInRangeRotY,
                self.__parent.floatInRangeRotZ
            ]
            for w in rotFloatInRangeCtrls:
                w.setRange((-180., 180.))
        elif startStyle == LINE:
            endPointFloatInRangeCtrls = [
                self.__parent.floatInRangeEndPointX,
                self.__parent.floatInRangeEndPointY,
                self.__parent.floatInRangeEndPointZ
            ]
            for w, r in zip(endPointFloatInRangeCtrls, self.__boundingBox):
                w.setRange(r)
            sideFloatInRangeCtrls = []
            rotFloatInRangeCtrls = []
        #else:
        #    sideFloatInRangeCtrls = []
        #    rotFloatInRangeCtrls = []

        for w in middleFloatInRangeCtrls + sideFloatInRangeCtrls + rotFloatInRangeCtrls + endPointFloatInRangeCtrls:
            w.sigSliderReleased.connect(self.__apply)
            if self.__paramChange:
                w.sigValueChanged.connect(self.__paramChange)

        #if not typeRec == POINTPROBING:
        for w in [
                self.__parent.xAxisRadioButton, self.__parent.yAxisRadioButton,
                self.__parent.zAxisRadioButton
        ]:
            w.clicked.connect(self.__radioButtonClick)

        self.__boundingBox = Box((-1, 1), (-1, 1), (-1, 1))

    def getParams(self, startStyle=PLANE):
        if startStyle == PLANE:
            aar = AxisAlignedRectangleIn3d()
            aar.middle = self.__getMiddle()
            if self.__parent.zAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'z'
            elif self.__parent.yAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'y'
            elif self.__parent.xAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'x'
            else:
                text = ('Invalid orthogonalAxis.  Invalid value is "%s".  '
                        'Expected one out of {"x", "y", "z"}' %
                        str(aar.orthogonalAxis))
                assert False, text
            if self.__type == TRACER:
                aar.lengthA = self.__parent.floatInRangeWidth.getValue()
                aar.lengthB = self.__parent.floatInRangeHeight.getValue()
            elif self.__type == CUTTINGSURFACE:
                aar.lengthA = 1.0
                aar.lengthB = 1.0
            aar.rotX = self.__parent.floatInRangeRotX.getValue()
            aar.rotY = self.__parent.floatInRangeRotY.getValue()
            aar.rotZ = self.__parent.floatInRangeRotZ.getValue()

            return aar
        elif startStyle == LINE:
            line = Line3D()

            line.setStartEndPoint(
                self.__parent.floatInRangeX.getValue(),
                self.__parent.floatInRangeY.getValue(),
                self.__parent.floatInRangeZ.getValue(),
                self.__parent.floatInRangeEndPointX.getValue(),
                self.__parent.floatInRangeEndPointY.getValue(),
                self.__parent.floatInRangeEndPointZ.getValue())

            return line

    def getBoundingBox(self):
        return self.__boundingBox

    def setBoundingBox(self, box, startStyle=PLANE):
        if self.__boundingBox == box:
            return
        self.__boundingBox = box
        #self.__parent.floatInRangeY.setRange(self.__boundingBox.getYMinMax())
        #self.__parent.floatInRangeZ.setRange(self.__boundingBox.getZMinMax())
        if self.__type == TRACER:
            maxSideLength = self.__boundingBox.getMaxEdgeLength()
            self.__parent.floatInRangeHeight.setRange((0.0, maxSideLength))
            self.__parent.floatInRangeWidth.setRange((0.0, maxSideLength))
        center = self.__boundingBox.getCenter()

        self.__parent.floatInRangeX.setValue(center[0])
        #print "setXRange: "+str(self.__boundingBox.getXMinMax())
        self.__parent.floatInRangeX.setRange(self.__boundingBox.getXMinMax())
        self.__parent.floatInRangeY.setValue(center[1])
        #print "setYRange: "+str(self.__boundingBox.getYMinMax())
        self.__parent.floatInRangeY.setRange(self.__boundingBox.getYMinMax())
        self.__parent.floatInRangeZ.setValue(center[2])
        #print "setZRange: "+str(self.__boundingBox.getZMinMax())
        self.__parent.floatInRangeZ.setRange(self.__boundingBox.getZMinMax())

        if startStyle == LINE:
            self.__parent.floatInRangeEndPointX.setValue(
                self.__boundingBox.getXMinMax()[0])  #center[0])
            #print "setXRange: "+str(self.__boundingBox.getXMinMax())
            self.__parent.floatInRangeEndPointX.setRange(
                self.__boundingBox.getXMinMax())
            self.__parent.floatInRangeEndPointY.setValue(
                self.__boundingBox.getYMinMax()[0])  #center[1])
            #print "setYRange: "+str(self.__boundingBox.getYMinMax())
            self.__parent.floatInRangeEndPointY.setRange(
                self.__boundingBox.getYMinMax())
            self.__parent.floatInRangeEndPointZ.setValue(
                self.__boundingBox.getZMinMax()[0])  #center[2])
            #print "setZRange: "+str(self.__boundingBox.getZMinMax())
            self.__parent.floatInRangeEndPointZ.setRange(
                self.__boundingBox.getZMinMax())

    def setRectangle(self, aar):
        controls = [
            self.__parent.floatInRangeX, self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ, self.__parent.floatInRangeRotX,
            self.__parent.floatInRangeRotY, self.__parent.floatInRangeRotZ,
            self.__parent.xAxisRadioButton, self.__parent.yAxisRadioButton,
            self.__parent.zAxisRadioButton
        ]
        for c in controls:
            c.blockSignals(True)
        self.__parent.floatInRangeX.setValue(aar.middle[0])
        self.__parent.floatInRangeY.setValue(aar.middle[1])
        self.__parent.floatInRangeZ.setValue(aar.middle[2])
        self.__parent.floatInRangeRotX.setValue(aar.rotX)
        self.__parent.floatInRangeRotY.setValue(aar.rotY)
        self.__parent.floatInRangeRotZ.setValue(aar.rotZ)
        if aar.orthogonalAxis == 'z':
            self.__parent.zAxisRadioButton.setChecked(True)
            self.__parent.xAxisRadioButton.setChecked(False)
            self.__parent.yAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'y':
            self.__parent.yAxisRadioButton.setChecked(True)
            self.__parent.xAxisRadioButton.setChecked(False)
            self.__parent.zAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'x':
            self.__parent.xAxisRadioButton.setChecked(True)
            self.__parent.zAxisRadioButton.setChecked(False)
            self.__parent.yAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'line':
            pass
        else:
            text = ('Invalid orthogonalAxis.  Invalid value is "%s"' %
                    str(aar.orthogonalAxis))
            assert False, text
        self.__setElementsEnabled()
        for c in controls:
            c.blockSignals(False)

        if self.__type == TRACER:
            controls = [
                self.__parent.floatInRangeHeight,
                self.__parent.floatInRangeWidth
            ]
            for c in controls:
                c.blockSignals(True)
            self.__parent.floatInRangeWidth.setValue(aar.lengthA)
            self.__parent.floatInRangeHeight.setValue(aar.lengthB)
            for c in controls:
                c.blockSignals(False)

    def setLine(self, line):
        controls = [
            #self.__parent.floatInRangeHeight,
            #self.__parent.floatInRangeWidth,
            #self.__parent.floatInRangeRotX,
            #self.__parent.floatInRangeRotY,
            #self.__parent.floatInRangeRotZ,
            #self.__parent.xAxisRadioButton,
            #self.__parent.yAxisRadioButton,
            #self.__parent.zAxisRadioButton,
            self.__parent.floatInRangeX,
            self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ,
            self.__parent.floatInRangeEndPointX,
            self.__parent.floatInRangeEndPointY,
            self.__parent.floatInRangeEndPointZ
        ]
        for c in controls:
            c.blockSignals(True)

        self.__parent.floatInRangeX.setValue(line.getStartPoint()[0])
        self.__parent.floatInRangeY.setValue(line.getStartPoint()[1])
        self.__parent.floatInRangeZ.setValue(line.getStartPoint()[2])

        self.__parent.floatInRangeEndPointX.setValue(line.getEndPoint()[0])
        self.__parent.floatInRangeEndPointY.setValue(line.getEndPoint()[1])
        self.__parent.floatInRangeEndPointZ.setValue(line.getEndPoint()[2])

        for c in controls:
            c.blockSignals(False)

    def __heuristicProbeMaxSideLengthFromBox(self, bb):
        return math.sqrt((bb[0][1] - bb[0][0]) * (bb[0][1] - bb[0][0]) +
                         (bb[1][1] - bb[1][0]) * (bb[1][1] - bb[1][0]) +
                         (bb[2][1] - bb[2][0]) * (bb[2][1] - bb[2][0]))

    def __getMiddle(self):
        return (self.__parent.floatInRangeX.getValue(),
                self.__parent.floatInRangeY.getValue(),
                self.__parent.floatInRangeZ.getValue())

    def __radioButtonClick(self):
        self.__parent.floatInRangeRotX.setValue(0.0)
        self.__parent.floatInRangeRotY.setValue(0.0)
        self.__parent.floatInRangeRotZ.setValue(0.0)
        self.__setElementsEnabled()
        if self.__applyRadioBttn != None:
            self.__applyRadioBttn()

    def __setElementsEnabled(self):
        if (self.__type == CUTTINGSURFACE):
            if self.__parent.xAxisRadioButton.isChecked():
                self.__parent.floatInRangeRotX.setEnabled(False)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(True)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(True)
                self.__parent.floatInRangeZ.setEnabled(True)
            elif self.__parent.yAxisRadioButton.isChecked():
                self.__parent.floatInRangeRotX.setEnabled(True)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(False)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(True)
                self.__parent.floatInRangeZ.setEnabled(True)
            else:
                self.__parent.floatInRangeRotX.setEnabled(True)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(True)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(False)
                self.__parent.floatInRangeZ.setEnabled(True)
Exemplo n.º 8
0
class RectangleManager(QtCore.QObject):
    """
        general gui class to handle the rectangle in VRPStreamlineBase
        used by different VisItem panels
    """

    def __init__(self, parent, doApply, doApplyRadioBttn, doParamChange, typeRec=TRACER, startStyle = PLANE):
        QtCore.QObject.__init__(self)

        assert parent
        assert doApply

        #slots to be registered by parent
        self.__parent = parent
        self.__apply = doApply
        self.__applyRadioBttn = doApplyRadioBttn
        self.__paramChange = doParamChange
        self.__type = typeRec

        middleFloatInRangeCtrls = [ self.__parent.floatInRangeX, self.__parent.floatInRangeY, self.__parent.floatInRangeZ  ]
        sideFloatInRangeCtrls = []
        rotFloatInRangeCtrls = []
        endPointFloatInRangeCtrls = []

        # a streamlines panel will have these widgets so they will get connected
        if typeRec == TRACER:
            endPointFloatInRangeCtrls = [ self.__parent.floatInRangeEndPointX, self.__parent.floatInRangeEndPointY, self.__parent.floatInRangeEndPointZ  ]

        self.__boundingBox = ((-1, 1), (-1, 1), (-1, 1))
        for w, r in zip(middleFloatInRangeCtrls, self.__boundingBox):
            w.setRange(r)
        #if not typeRec == POINTPROBING:
        if startStyle == PLANE:
            sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(self.__boundingBox)
            if self.__type == TRACER:
                sideFloatInRangeCtrls = [self.__parent.floatInRangeWidth, self.__parent.floatInRangeHeight]
                for w in sideFloatInRangeCtrls:
                    w.setRange(sideRange)
            rotFloatInRangeCtrls = [ self.__parent.floatInRangeRotX, self.__parent.floatInRangeRotY, self.__parent.floatInRangeRotZ  ]
            for w in rotFloatInRangeCtrls:
                w.setRange((-180.,180.))
        elif startStyle == LINE:
            endPointFloatInRangeCtrls = [ self.__parent.floatInRangeEndPointX, self.__parent.floatInRangeEndPointY, self.__parent.floatInRangeEndPointZ  ]
            for w, r in zip(endPointFloatInRangeCtrls, self.__boundingBox):
                w.setRange(r)
            sideFloatInRangeCtrls = []
            rotFloatInRangeCtrls = []
        #else:
        #    sideFloatInRangeCtrls = []
        #    rotFloatInRangeCtrls = []

        for w in middleFloatInRangeCtrls + sideFloatInRangeCtrls + rotFloatInRangeCtrls + endPointFloatInRangeCtrls:
            w.sigSliderReleased.connect(self.__apply)
            if self.__paramChange:
                w.sigValueChanged.connect(self.__paramChange)

        #if not typeRec == POINTPROBING:
        for w in [self.__parent.xAxisRadioButton,
                self.__parent.yAxisRadioButton,
                self.__parent.zAxisRadioButton]:
            w.clicked.connect(self.__radioButtonClick)

        self.__boundingBox = Box((-1, 1), (-1, 1), (-1, 1))


    def getParams(self, startStyle = PLANE):
        if startStyle == PLANE:
            aar = AxisAlignedRectangleIn3d()
            aar.middle = self.__getMiddle()
            if self.__parent.zAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'z'
            elif self.__parent.yAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'y'
            elif self.__parent.xAxisRadioButton.isChecked():
                aar.orthogonalAxis = 'x'
            else:
                text = (
                    'Invalid orthogonalAxis.  Invalid value is "%s".  '
                    'Expected one out of {"x", "y", "z"}'
                    % str(aar.orthogonalAxis))
                assert False, text
            if self.__type == TRACER:
                aar.lengthA = self.__parent.floatInRangeWidth.getValue()
                aar.lengthB = self.__parent.floatInRangeHeight.getValue()
            elif self.__type == CUTTINGSURFACE:
                aar.lengthA = 1.0
                aar.lengthB = 1.0
            aar.rotX = self.__parent.floatInRangeRotX.getValue()
            aar.rotY = self.__parent.floatInRangeRotY.getValue()
            aar.rotZ = self.__parent.floatInRangeRotZ.getValue()
            
            return aar
        elif startStyle == LINE:
            line = Line3D()

            line.setStartEndPoint(self.__parent.floatInRangeX.getValue(),
                                  self.__parent.floatInRangeY.getValue(),
                                  self.__parent.floatInRangeZ.getValue(),
                                  self.__parent.floatInRangeEndPointX.getValue(),
                                  self.__parent.floatInRangeEndPointY.getValue(),
                                  self.__parent.floatInRangeEndPointZ.getValue())

            return line

    def getBoundingBox(self):
        return self.__boundingBox

    def setBoundingBox( self, box, startStyle = PLANE):
        if self.__boundingBox == box:
            return
        self.__boundingBox = box
        #self.__parent.floatInRangeY.setRange(self.__boundingBox.getYMinMax())
        #self.__parent.floatInRangeZ.setRange(self.__boundingBox.getZMinMax())
        if self.__type==TRACER:
            maxSideLength = self.__boundingBox.getMaxEdgeLength()
            self.__parent.floatInRangeHeight.setRange((0.0, maxSideLength))
            self.__parent.floatInRangeWidth.setRange((0.0, maxSideLength))
        center = self.__boundingBox.getCenter()

        self.__parent.floatInRangeX.setValue(center[0])
        #print "setXRange: "+str(self.__boundingBox.getXMinMax())
        self.__parent.floatInRangeX.setRange(self.__boundingBox.getXMinMax())
        self.__parent.floatInRangeY.setValue(center[1])
        #print "setYRange: "+str(self.__boundingBox.getYMinMax())
        self.__parent.floatInRangeY.setRange(self.__boundingBox.getYMinMax())
        self.__parent.floatInRangeZ.setValue(center[2])
        #print "setZRange: "+str(self.__boundingBox.getZMinMax())
        self.__parent.floatInRangeZ.setRange(self.__boundingBox.getZMinMax())

        if startStyle == LINE:
            self.__parent.floatInRangeEndPointX.setValue(self.__boundingBox.getXMinMax()[0])#center[0])
            #print "setXRange: "+str(self.__boundingBox.getXMinMax())
            self.__parent.floatInRangeEndPointX.setRange(self.__boundingBox.getXMinMax())
            self.__parent.floatInRangeEndPointY.setValue(self.__boundingBox.getYMinMax()[0])#center[1])
            #print "setYRange: "+str(self.__boundingBox.getYMinMax())
            self.__parent.floatInRangeEndPointY.setRange(self.__boundingBox.getYMinMax())
            self.__parent.floatInRangeEndPointZ.setValue(self.__boundingBox.getZMinMax()[0])#center[2])
            #print "setZRange: "+str(self.__boundingBox.getZMinMax())
            self.__parent.floatInRangeEndPointZ.setRange(self.__boundingBox.getZMinMax())


    def setRectangle(self, aar):
        controls = [
            self.__parent.floatInRangeX,
            self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ,
            self.__parent.floatInRangeRotX,
            self.__parent.floatInRangeRotY,
            self.__parent.floatInRangeRotZ,
            self.__parent.xAxisRadioButton,
            self.__parent.yAxisRadioButton,
            self.__parent.zAxisRadioButton]
        for c in controls: c.blockSignals(True)
        self.__parent.floatInRangeX.setValue(aar.middle[0])
        self.__parent.floatInRangeY.setValue(aar.middle[1])
        self.__parent.floatInRangeZ.setValue(aar.middle[2])
        self.__parent.floatInRangeRotX.setValue(aar.rotX)
        self.__parent.floatInRangeRotY.setValue(aar.rotY)
        self.__parent.floatInRangeRotZ.setValue(aar.rotZ)
        if aar.orthogonalAxis == 'z':
            self.__parent.zAxisRadioButton.setChecked(True)
            self.__parent.xAxisRadioButton.setChecked(False)
            self.__parent.yAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'y':
            self.__parent.yAxisRadioButton.setChecked(True)
            self.__parent.xAxisRadioButton.setChecked(False)
            self.__parent.zAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'x':
            self.__parent.xAxisRadioButton.setChecked(True)
            self.__parent.zAxisRadioButton.setChecked(False)
            self.__parent.yAxisRadioButton.setChecked(False)
        elif aar.orthogonalAxis == 'line':
            pass
        else:
            text = ('Invalid orthogonalAxis.  Invalid value is "%s"'
                    % str(aar.orthogonalAxis))
            assert False, text
        self.__setElementsEnabled()
        for c in controls: c.blockSignals(False)

        if self.__type==TRACER:
            controls = [self.__parent.floatInRangeHeight,
                        self.__parent.floatInRangeWidth]
            for c in controls: c.blockSignals(True)
            self.__parent.floatInRangeWidth.setValue(aar.lengthA)
            self.__parent.floatInRangeHeight.setValue(aar.lengthB)
            for c in controls: c.blockSignals(False)


    def setLine(self, line):
        controls = [
            #self.__parent.floatInRangeHeight,
            #self.__parent.floatInRangeWidth,
            #self.__parent.floatInRangeRotX,
            #self.__parent.floatInRangeRotY,
            #self.__parent.floatInRangeRotZ,
            #self.__parent.xAxisRadioButton,
            #self.__parent.yAxisRadioButton,
            #self.__parent.zAxisRadioButton,
            self.__parent.floatInRangeX,
            self.__parent.floatInRangeY,
            self.__parent.floatInRangeZ,
            self.__parent.floatInRangeEndPointX,
            self.__parent.floatInRangeEndPointY,
            self.__parent.floatInRangeEndPointZ]
        for c in controls: c.blockSignals(True)

        self.__parent.floatInRangeX.setValue(line.getStartPoint()[0])
        self.__parent.floatInRangeY.setValue(line.getStartPoint()[1])
        self.__parent.floatInRangeZ.setValue(line.getStartPoint()[2])

        self.__parent.floatInRangeEndPointX.setValue(line.getEndPoint()[0])
        self.__parent.floatInRangeEndPointY.setValue(line.getEndPoint()[1])
        self.__parent.floatInRangeEndPointZ.setValue(line.getEndPoint()[2])

        for c in controls: c.blockSignals(False)


    def __heuristicProbeMaxSideLengthFromBox(self, bb):
        return math.sqrt(
            (bb[0][1] - bb[0][0]) * (bb[0][1] - bb[0][0])
            + (bb[1][1] - bb[1][0]) * (bb[1][1] - bb[1][0])
            + (bb[2][1] - bb[2][0]) * (bb[2][1] - bb[2][0]))

    def __getMiddle(self):
        return (self.__parent.floatInRangeX.getValue(),
                self.__parent.floatInRangeY.getValue(),
                self.__parent.floatInRangeZ.getValue())

    def __radioButtonClick(self):
        self.__parent.floatInRangeRotX.setValue(0.0)
        self.__parent.floatInRangeRotY.setValue(0.0)
        self.__parent.floatInRangeRotZ.setValue(0.0)
        self.__setElementsEnabled()
        if self.__applyRadioBttn != None:
            self.__applyRadioBttn()

    def __setElementsEnabled(self):
        if (self.__type == CUTTINGSURFACE):
            if self.__parent.xAxisRadioButton.isChecked():
                self.__parent.floatInRangeRotX.setEnabled(False)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(True)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(True)            
                self.__parent.floatInRangeZ.setEnabled(True)
            elif self.__parent.yAxisRadioButton.isChecked():
                self.__parent.floatInRangeRotX.setEnabled(True)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(False)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(True)
                self.__parent.floatInRangeZ.setEnabled(True)
            else:
                self.__parent.floatInRangeRotX.setEnabled(True)
                self.__parent.floatInRangeX.setEnabled(True)
                self.__parent.floatInRangeRotY.setEnabled(True)
                self.__parent.floatInRangeY.setEnabled(True)
                self.__parent.floatInRangeRotZ.setEnabled(False)
                self.__parent.floatInRangeZ.setEnabled(True)
Exemplo n.º 9
0
 def getBox(self, forceExecute=False):
     box = Box((0, 0), (0, 0), (0, 0))
     for part in self._parts:
         box = box + part.getBox(forceExecute)
     return box
Exemplo n.º 10
0
 def getBoxFromGeoRWCovise(self):
     box = Box((0, 0), (0, 0), (0, 0))
     for part in self._parts:
         box = box + part.getBoxFromGeoRWCovise()
     return box
Exemplo n.º 11
0
class IsoCutterPanel(QtWidgets.QWidget, Ui_IsoCutterPanelBase):
    """For controling parameters of a iso surface """

    sigVisibiliyToggled = pyqtSignal()
    sigEditColorMap = pyqtSignal()

    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        Ui_IsoCutterPanelBase.__init__(self)
        self.setupUi(self)
        #current object key
        self.__key = -1

        #default setting of the panel
        self.vrpCheckBoxMapVariable.setEnabled(False)
        self.vrpComboBoxVariable.setEnabled(False)
        self.visibilityCheckBox.setVisible(
            covise.coConfigIsOn("vr-prepare.AdditionalVisibilityCheckbox",
                                False))

        self.__baseVariable = None

        #temporary storage of this parameter part
        self.colorCreator = {}

        middleFloatInRangeCtrls = [self.floatInRangeIsoValue]
        self.__boundingBox = Box()
        for w, r in zip(middleFloatInRangeCtrls,
                        self.__boundingBox.getTuple()):
            w.setRange(r)
        sideRange = 0, self.__heuristicProbeMaxSideLengthFromBox(
            self.__boundingBox.getTuple())

        IsoCutterPanelConnector(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.emitValueChange()

    def paramChanged(self, key):
        ''' params of the object with 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.__set2ndVariable(
            ObjectMgr().getPossibleScalarVariablesForVisItem(key))
        self.__setParams(params)

    def __getParams(self):
        ''' convert information in the panel into the right negotiator param classes '''
        data = PartIsoCutterVisParams()

        #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.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)
        data.isovalue = self.floatInRangeIsoValue.getValue()
        data.cutoff_side = self.checkBoxCutoffSide.isChecked()
        data.isomin = self.floatInRangeIsoValue.getRange()[0]
        data.isomax = self.floatInRangeIsoValue.getRange()[1]
        data.boundingBox = self.__boundingBox
        return data

    def __panelAccordingTaskType(self):
        pass

    def __set2ndVariable(self, varlist):
        """ fill the combobox to choose a variable to be mapped on the trace """
        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):
        ''' updates the panel with the params of the negotiatior'''
        IsoCutterPanelBlockSignals(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)
        if hasattr(params, 'secondVariable') and 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

        currentVariable = params.variable  # no second variable in this visualizer right now

        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
            maxSideLength = self.__boundingBox.getMaxEdgeLength()

        self.colorCreator = params.colorTableKey

        self.floatInRangeIsoValue.setRange([params.isomin, params.isomax])
        self.floatInRangeIsoValue.setValue(params.isovalue)
        self.checkBoxCutoffSide.setChecked(params.cutoff_side)

        IsoCutterPanelBlockSignals(self, False)

    def emitNameChange(self, aQString=None):
        if self.__key != -1:
            MainWindow.globalAccessToTreeView.setItemData(
                self.__key, str(self.nameWidget.text()))
            self.emitValueChange()

    def emitVisibilityToggled(self, b):
        self.sigVisibiliyToggled.emit((b, ))
        self.emitValueChange(b)

    def emitCustomizeColorMap(self):
        self.sigEditColorMap.emit(
            self.__key,
            MainWindow.globalColorManager.getSelectedColormapKey(
                self.colorMapCombobox))

    def emitValueChange(self, val=False):
        if not self.__key == -1:
            Application.vrpApp.key2params[self.__key] = self.__getParams()
            ObjectMgr().setParams(self.__key, self.__getParams())
            theGuiMsgHandler().runObject(self.__key)

    def __heuristicProbeMaxSideLengthFromBox(self, bb):
        return math.sqrt((bb[0][1] - bb[0][0]) * (bb[0][1] - bb[0][0]) +
                         (bb[1][1] - bb[1][0]) * (bb[1][1] - bb[1][0]) +
                         (bb[2][1] - bb[2][0]) * (bb[2][1] - bb[2][0]))

    def __tr(self, s, c=None):
        return coTranslate(s)