Esempio n. 1
0
    def __init__(self, parent, profile=None):
        QGLViewer.__init__(self, parent)
        self.__profile = None
        self.__position = 0
        self.__positionCurve = None
        self.increment = 0.01
        self._axisScaleTolerance = abs(pi / 8.)  # (radians)

        #states
        self.__oldY = None
        self.__scalingDirection = None

        #ranges
        self.__param_min = 0.0
        self.__param_max = 1.0

        # --rendering components --
        self.factor = [1., 1., 1.]  #x, y, z scene scaling factors.
        self.discretizer = Discretizer()
        self.renderer = GLRenderer(self.discretizer)
        self.renderer.renderingMode = GLRenderer.Dynamic

        # -- addons --
        self._addons = []
        self.visualSections = VisualCrossSectionsAddOn(self)
        self.grids = GridAddOn(self)
        self.userSlices = UserSlicesAddOn(self)
Esempio n. 2
0
    def __init__(self,
                 parent=None,
                 scene=None,
                 statefilename='.temp_scene.xml',
                 shareWidget=None):
        QGLViewer.__init__(self, parent, shareWidget)
        self.set_bg_white()
        # set the scene
        if scene == None:
            scene = self.defaultScene()
        self.scene = scene
        # set some parameters
        self.setAxisIsDrawn(False)  # show axis
        self.setGridIsDrawn(True)  # show grid

        orientation = Quaternion(0.475117, 0.472505, 0.524479, 0.525286)
        position = Vec(2.91287, -0.0109797, 0.659613)
        self.camera().setPosition(position)
        self.camera().setOrientation(orientation)

        self.camera().setSceneRadius(1)  # Size of vectors x,y,z
        # connection
        self.connect(self, QtCore.SIGNAL("drawNeeded()"), self.draw)
        self.orientation_initiale = self.camera().orientation()
        self.position_initiale = self.camera().position()
        # Block "*.xml" save
        self.setStateFileName("")
        # Disable Quit in clicking on 'Escape'
        # Set "show_axis" instead of "kill_application"
        self.setShortcut(0, QtCore.Qt.Key_Escape)
    def __init__(self,parent, profile=None):
        QGLViewer.__init__(self,parent)
        self.__profile  = None
        self.__position = 0
        self.__positionCurve = None
        self.increment = 0.01
        self._axisScaleTolerance = abs(pi/8.) # (radians)

        #states
        self.__oldY = None
        self.__scalingDirection = None

        #ranges
        self.__param_min = 0.0
        self.__param_max = 1.0

        # --rendering components --
        self.factor = [1., 1., 1.] #x, y, z scene scaling factors.
        self.discretizer = Discretizer()
        self.renderer    = GLRenderer(self.discretizer)
        self.renderer.renderingMode = GLRenderer.Dynamic

        # -- addons --
        self._addons        = []
        self.visualSections = VisualCrossSectionsAddOn(self)
        self.grids          = GridAddOn(self)
        self.userSlices     = UserSlicesAddOn(self)
Esempio n. 4
0
    def __init__(self, parent=None, scene=None, statefilename='.temp_scene.xml', shareWidget=None):
        QGLViewer.__init__(self, parent, shareWidget)
        self.set_bg_white()
        # set the scene
        if scene == None:
            scene = self.defaultScene()
        self.scene = scene
        # set some parameters
        self.setAxisIsDrawn(False)  # show axis
        self.setGridIsDrawn(True)  # show grid

        orientation = Quaternion(0.475117, 0.472505, 0.524479, 0.525286)
        position = Vec(2.91287, -0.0109797, 0.659613)
        self.camera().setPosition(position)
        self.camera().setOrientation(orientation)

        self.camera().setSceneRadius(1)  # Size of vectors x,y,z
        # connection
        self.connect(self, QtCore.SIGNAL("drawNeeded()"), self.draw)
        self.orientation_initiale = self.camera().orientation()
        self.position_initiale = self.camera().position()
        # Block "*.xml" save
        self.setStateFileName("")
        # Disable Quit in clicking on 'Escape'
        # Set "show_axis" instead of "kill_application"
        self.setShortcut(0, QtCore.Qt.Key_Escape)
Esempio n. 5
0
 def __init__(self,parent):
     QGLViewer.__init__(self,parent)
     self.scene = None
     self.discretizer = Discretizer()
     self.glrenderer = GLRenderer(self.discretizer)
     self.bboxcomputer = BBoxComputer(self.discretizer)
     self.animationMode = eStatic
     self.camera().setViewDirection(Vec(-1,0,0))
     self.camera().setUpVector(Vec(0,0,1))
Esempio n. 6
0
 def __init__(self, parent=None):
     QGLViewer.__init__(self, parent)
     self.scene = None
     self.discretizer = Discretizer()
     self.glrenderer = GLRenderer(self.discretizer)
     self.bboxcomputer = BBoxComputer(self.discretizer)
     self.animationMode = eStatic
     self.forceclear = True
     self.camera().setViewDirection(Vec(-1, 0, 0))
     self.camera().setUpVector(Vec(0, 0, 1))
Esempio n. 7
0
 def mouseReleaseEvent(self, event):
     QGLViewer.mouseReleaseEvent(self, event)
Esempio n. 8
0
 def mouseDoubleClickEvent(self, event):
     QGLViewer.mouseDoubleClickEvent(self, event)
Esempio n. 9
0
    def mouseMoveEvent(self, event):
        if self.__oldY is not None:
            pos = self.__position

            #some values that are used a bit everywhere
            newX, newY = event.x(), event.y()
            xDiff = float(newX - self.__oldX)
            yDiff = float(newY - self.__oldY)
            cartDist = sqrt(yDiff**2 + xDiff**2)

            mod = event.modifiers()
            if mod != QtCore.Qt.ControlModifier:
                delta = newY - self.__oldY
                if delta > 0:
                    pos += self.increment
                elif delta < 0:
                    pos -= self.increment
                self.__oldY = newY

                self.set_position(pos)
            elif self.__scalingDirection is None:
                if cartDist < 50:  #pixels
                    return

                #compute direction coefficient of the mouse pointer to the screen center
                if xDiff == 0.0:
                    return
                pA = atan2(yDiff, xDiff)
                tol = self._axisScaleTolerance

                #compute projected direction coefficients of axes
                camera = self.camera()
                origin = camera.getProjectedCoordinatesOf(Vec(0., 0., 0.))
                xProj = camera.getProjectedCoordinatesOf(Vec(1., 0., 0.))
                yProj = camera.getProjectedCoordinatesOf(Vec(0., 1., 0.))
                zProj = camera.getProjectedCoordinatesOf(Vec(0., 0., 1.))

                xVec = (xProj[0] - origin[0]), (xProj[1] - origin[1])
                yVec = (yProj[0] - origin[0]), (yProj[1] - origin[1])
                zVec = (zProj[0] - origin[0]), (zProj[1] - origin[1])

                #angles
                if xVec[0] == 0.0 or yVec[0] == 0.0 or zVec[0] == 0.0:
                    return

                xA = atan(xVec[1] / xVec[0])
                yA = atan(yVec[1] / yVec[0])
                zA = atan(zVec[1] / zVec[0])

                dire = min((abs(xA % pi - pA % pi), 0, pA, xVec),
                           (abs(yA % pi - pA % pi), 1, pA, yVec),
                           (abs(zA % pi - pA % pi), 2, pA, zVec))
                self.__scalingDirection = dire if (dire[0] <= tol) else None

            elif self.__scalingDirection is not None:
                angD, dire, angle, vec = self.__scalingDirection

                #cartDist is used to obtain a significant difference
                #or else computations are screwed.
                if xDiff != 0.0 and yDiff != 0 and cartDist > 5:
                    pA = atan2(yDiff, xDiff)
                    if pA < 0: pA += 2 * pi
                    if angle < 0: angle += 2 * pi
                    angleDiv = int(angle / pi * 2)
                    mouseDiv = int(pA / pi * 2)
                    positive = angleDiv == mouseDiv

                    f = self.factor[dire]
                    f = f * 1.02 if positive else f * 0.98
                    self.factor[dire] = f

                    self.__oldY = newY
                    self.__oldX = newX
                    self.update()

        else:
            QGLViewer.mouseMoveEvent(self, event)
Esempio n. 10
0
 def mouseReleaseEvent(self, event):
     self.__oldX = None
     self.__oldY = None
     self.__scalingDirection = None
     QGLViewer.mouseReleaseEvent(self, event)
Esempio n. 11
0
 def mousePressEvent(self, event):
     if event.button() == QtCore.Qt.MidButton:
         self.__oldX = event.x()
         self.__oldY = event.y()
     else:
         QGLViewer.mousePressEvent(self, event)
 def mouseReleaseEvent(self,event):
     QGLViewer.mouseReleaseEvent(self,event)
 def mouseDoubleClickEvent(self,event):
     QGLViewer.mouseDoubleClickEvent(self,event)
    def mouseMoveEvent(self, event):
        if self.__oldY is not None:
            pos = self.__position

            #some values that are used a bit everywhere
            newX, newY = event.x(), event.y()
            xDiff = float(newX-self.__oldX)
            yDiff = float(newY-self.__oldY)
            cartDist = sqrt(yDiff**2+xDiff**2)

            mod = event.modifiers()
            if mod != QtCore.Qt.ControlModifier:
                delta =  newY - self.__oldY
                if delta > 0:
                    pos += self.increment
                elif delta < 0:
                    pos -= self.increment
                self.__oldY = newY

                self.set_position(pos)
            elif self.__scalingDirection is None:
                if cartDist < 50 : #pixels
                    return

                #compute direction coefficient of the mouse pointer to the screen center
                if xDiff==0.0:
                    return
                pA = atan2(yDiff,xDiff)
                tol = self._axisScaleTolerance

                #compute projected direction coefficients of axes
                camera = self.camera()
                origin = camera.getProjectedCoordinatesOf(Vec(0.,0.,0.))
                xProj  = camera.getProjectedCoordinatesOf(Vec(1.,0.,0.))
                yProj  = camera.getProjectedCoordinatesOf(Vec(0.,1.,0.))
                zProj  = camera.getProjectedCoordinatesOf(Vec(0.,0.,1.))

                xVec = (xProj[0] - origin[0]),(xProj[1] - origin[1])
                yVec = (yProj[0] - origin[0]),(yProj[1] - origin[1])
                zVec = (zProj[0] - origin[0]),(zProj[1] - origin[1])

                #angles
                if xVec[0]==0.0 or yVec[0]==0.0 or zVec[0]==0.0:
                    return

                xA = atan(xVec[1]/xVec[0])
                yA = atan(yVec[1]/yVec[0])
                zA = atan(zVec[1]/zVec[0])

                dire = min( ( abs(xA%pi-pA%pi),0,pA,xVec),
                            ( abs(yA%pi-pA%pi),1,pA,yVec),
                            ( abs(zA%pi-pA%pi),2,pA,zVec) )
                self.__scalingDirection = dire if (dire[0] <= tol) else None

            elif self.__scalingDirection is not None:
                angD, dire, angle, vec = self.__scalingDirection

                #cartDist is used to obtain a significant difference
                #or else computations are screwed.
                if xDiff != 0.0 and yDiff != 0 and cartDist > 5 :
                    pA = atan2(yDiff,xDiff)
                    if pA < 0: pA += 2*pi
                    if angle < 0: angle +=2*pi
                    angleDiv = int(angle/pi*2)
                    mouseDiv = int(pA/pi*2)
                    positive = angleDiv == mouseDiv

                    f = self.factor[dire]
                    f = f*1.02 if positive else f*0.98
                    self.factor[dire] = f

                    self.__oldY = newY
                    self.__oldX = newX
                    self.update()

        else:
            QGLViewer.mouseMoveEvent(self, event)
 def mouseReleaseEvent(self, event):
     self.__oldX = None
     self.__oldY = None
     self.__scalingDirection = None
     QGLViewer.mouseReleaseEvent(self, event)
 def mousePressEvent(self, event):
     if event.button() == QtCore.Qt.MidButton:
         self.__oldX = event.x()
         self.__oldY = event.y()
     else:
         QGLViewer.mousePressEvent(self, event)