Exemple #1
0
    def __init__(self, name="OrthoViewSwitch", cam=None):
        super(orthoViewSwitch, self).__init__()

        self.setName(name)

        self.vec = coin.SoTransformVec3f()
        self.vec.vector = coin.SbVec3f(0, 0, -1)

        self.calc = coin.SoCalculator()
        self.calc.A.connectFrom(self.vec.direction)
        self.calc.expression.set1Value(0, "ta=0.00001")  # tolerance
        self.calc.expression.set1Value(1, "tA=vec3f(0,0,1)")  # XY plane normal
        self.calc.expression.set1Value(2, "tB=vec3f(0,1,0)")  # XZ plane normal
        self.calc.expression.set1Value(3, "tC=vec3f(1,0,0)")  # YZ plane normal
        self.calc.expression.set1Value(4, "oa=fabs(dot(A,tA))")  # XY value
        self.calc.expression.set1Value(5, "ob=fabs(dot(A,tB))")  # XZ value
        self.calc.expression.set1Value(6, "oc=fabs(dot(A,tC))")  # YZ value
        self.calc.expression.set1Value(7, "tb=(oa>ob)?oa:ob")
        self.calc.expression.set1Value(8, "tc=(tb>oc)?tb:oc")  # winning value
        self.calc.expression.set1Value(9, "tf=(oa==tc)&&((oa+ta)>1)?1:0")
        self.calc.expression.set1Value(10, "tg=(ob==tc)&&((ob+ta)>1)?2:0")
        self.calc.expression.set1Value(11, "th=(oc==tc)&&((oc+ta)>1)?3:0")
        self.calc.expression.set1Value(12, "od=tf+tg+th")  # switch value

        self.view_0 = gridView("not_ortho_view")
        self.addChild(self.view_0)
        self.view_z = gridView("Z_view")
        self.addChild(self.view_z)
        self.view_y = gridView("Y_view")
        self.addChild(self.view_y)
        self.view_x = gridView("X_view")
        self.addChild(self.view_x)

        if cam:
            self.connectCamera(cam)
        else:
            self.whichChild = 0
Exemple #2
0
    def __init__(self, name="ToggleSwitch", cam=None):
        super(orthoToggleSwitch, self).__init__()

        self.setName(name)

        self.vec = coin.SoTransformVec3f()
        self.vec.vector = coin.SbVec3f(0, 0, -1)

        # switch with 4 nodes
        self.calc = coin.SoCalculator()
        self.calc.A.connectFrom(self.vec.direction)
        self.calc.expression.set1Value(0, "ta=0.0001")  # tolerance
        self.calc.expression.set1Value(1, "tA=vec3f(0,0,1)")  # XY plane normal
        self.calc.expression.set1Value(2, "tB=vec3f(0,1,0)")  # XZ plane normal
        self.calc.expression.set1Value(3, "tC=vec3f(1,0,0)")  # YZ plane normal
        self.calc.expression.set1Value(4, "oa=fabs(dot(A,tA))")  # XY value
        self.calc.expression.set1Value(5, "ob=fabs(dot(A,tB))")  # XZ value
        self.calc.expression.set1Value(6, "oc=fabs(dot(A,tC))")  # YZ value
        self.calc.expression.set1Value(7, "tb=(oa>ob)?oa:ob")
        self.calc.expression.set1Value(8, "tc=(tb>oc)?tb:oc")  # winning value
        self.calc.expression.set1Value(9, "tf=(oa==tc)&&((oa+ta)>1)?1:0")
        self.calc.expression.set1Value(10, "tg=(ob==tc)&&((ob+ta)>1)?2:0")
        self.calc.expression.set1Value(11, "th=(oc==tc)&&((oc+ta)>1)?3:0")
        self.calc.expression.set1Value(12, "od=tf+tg+th")  # switch value

        # switch with 2 nodes
        self.calc2 = coin.SoCalculator()
        self.calc2.a.connectFrom(self.calc.od)
        self.calc2.expression.set1Value(0, "oa=(a>0)?1:0")  # tolerance

        self.scaleEngine = coin.SoCalculator()
        #self.scaleEngine.a.connectFrom(cam.height)
        self.scaleEngine.expression.set1Value(0, "ta=floor(log10(a/10))")
        self.scaleEngine.expression.set1Value(1, "tb=pow(10,ta+2)")
        self.scaleEngine.expression.set1Value(2, "oA=vec3f(tb,tb,tb)")
        self.scaleEngine.expression.set1Value(3, "oa=0.01*a/tb")

        self.axis_color = coin.SoCalculator()
        self.axis_color.a.connectFrom(self.calc.od)
        self.axis_color.expression.set1Value(
            0, "tA=vec3f(0.82, 0.15, 0.15)")  # red
        self.axis_color.expression.set1Value(
            1, "tB=vec3f(0.40, 0.59, 0.20)")  # green
        self.axis_color.expression.set1Value(
            2, "tC=vec3f(0.13, 0.49, 0.88)")  # blue
        self.axis_color.expression.set1Value(
            3, "tD=vec3f(0.00, 0.00, 0.00)")  # black
        self.axis_color.expression.set1Value(4, "ta=(a==1)?1:0")
        self.axis_color.expression.set1Value(5, "tb=(a==2)?1:0")
        self.axis_color.expression.set1Value(6, "tc=(a==3)?1:0")
        self.axis_color.expression.set1Value(7, "oA=tD+tB*ta+tC*tb+tB*tc")
        self.axis_color.expression.set1Value(8, "oB=tD+tA*ta+tA*tb+tC*tc")

        self.view_0 = gridView("Not_Ortho")
        self.addChild(self.view_0)
        self.view_1 = gridView("Ortho")
        self.view_1.build_points()
        self.view_1.build_axis()
        self.view_1.build_lines()
        self.addChild(self.view_1)

        if cam:
            self.connectCamera(cam)
        else:
            self.whichChild = 0
Exemple #3
0
    def __init__(self):
        super(gridNode, self).__init__()

        self.vec = coin.SoTransformVec3f()
        #self.vec.matrix.connectFrom(cam.orientation)
        self.vec.vector = coin.SbVec3f(0, 0, -1)

        self.calc = coin.SoCalculator()
        self.calc.A.connectFrom(self.vec.direction)
        self.calc.expression.set1Value(0, "ta=0.5")  # maxviz
        self.calc.expression.set1Value(1, "tb=20.0")  # factor
        self.calc.expression.set1Value(2, "tA=vec3f(1,0,0)")  # plane normal
        self.calc.expression.set1Value(3, "tc=dot(A,tA)")
        self.calc.expression.set1Value(4, "td=fabs(tc)")
        self.calc.expression.set1Value(5, "oa=1.0-ta*pow(td,tb)")
        self.calc.expression.set1Value(6, "oA=vec3f(oa,0,0)")

        self.scaleEngine = coin.SoCalculator()
        #self.scaleEngine.a.connectFrom(cam.height)
        self.scaleEngine.expression.set1Value(0, "ta=floor(log10(a/10))")
        self.scaleEngine.expression.set1Value(1, "tb=pow(10,ta)")
        self.scaleEngine.expression.set1Value(2, "oA=vec3f(tb,tb,tb)")
        self.scaleEngine.expression.set1Value(3, "oa=0.01*a/tb")

        self.calc2 = coin.SoCalculator()
        self.calc2.a.connectFrom(self.scaleEngine.oa)
        self.calc2.b.connectFrom(self.calc.oa)
        self.calc2.expression.set1Value(0, "ta=pow(a,0.3)")
        self.calc2.expression.set1Value(1, "oa=(b>ta)?b:ta")

        self.material1 = coin.SoMaterial()
        self.material2 = coin.SoMaterial()
        self.material3 = coin.SoMaterial()
        self.material4 = coin.SoMaterial()
        self.coord = coin.SoCoordinate3()
        self.coord2 = coin.SoCoordinate3()
        self.line1 = coin.SoIndexedLineSet()
        self.line2 = coin.SoIndexedLineSet()
        self.lineSet = coin.SoIndexedLineSet()
        self.lineSet2 = coin.SoIndexedLineSet()

        self.miniscale = coin.SoScale()
        self.miniscale.scaleFactor = coin.SbVec3f(0.1, 0.1, 0.1)

        self.mainscale = coin.SoScale()
        self.mainscale.scaleFactor.connectFrom(self.scaleEngine.oA)

        self.addChild(self.mainscale)
        self.addChild(self.coord)
        self.addChild(self.material1)
        self.addChild(self.line1)
        self.addChild(self.material2)
        self.addChild(self.line2)
        self.addChild(self.material3)
        self.addChild(self.lineSet)
        self.addChild(self.miniscale)
        self.addChild(self.material4)
        self.addChild(self.coord2)
        self.addChild(self.lineSet2)

        self._vector1 = coin.SbVec3f(1, 0, 0)
        self._vector2 = coin.SbVec3f(0, 1, 0)
        self.normal = self._vector1.cross(self._vector2)

        self._mainDim = 100
        self._subDim = 10
        self._maxviz = 1.0
        self._factor = 1.0

        self._numGridLines = 4
        self.material1.diffuseColor = coin.SbColor(1, 0, 0)
        self.material2.diffuseColor = coin.SbColor(0, 1, 0)
        self.material3.diffuseColor = coin.SbColor(0.5, 0.5, 0.5)
        self.material4.diffuseColor = coin.SbColor(0.5, 0.5, 0.5)
        self.material3.transparency.connectFrom(self.calc.oa)
        self.material4.transparency.connectFrom(self.calc2.oa)