Esempio n. 1
0
    def run(self, receiver):
        """
        Makes sure that that the whole scene is visible

        :type receiver: operations.BaseOperation.Receiver
        :param receiver: The receiver that the operation should use.
        """
        extraZoomFactor = 1.25

        if(receiver.ui.mainView.viewPort[0]/receiver.ui.mainView.viewPort[1] > 1):
            aspect = Matrix.scale(receiver.ui.mainView.viewPort[1]/receiver.ui.mainView.viewPort[0], 1)
        else:
            aspect = Matrix.scale(1, receiver.ui.mainView.viewPort[0]/receiver.ui.mainView.viewPort[1])

        tl = receiver.ui.mainView.scene_min_max.pos_min
        br = receiver.ui.mainView.scene_min_max.pos_max

        center = [-(tl[0]+br[0])/2, -(tl[1]+br[1])/2]
        scaleFactor = 2/(extraZoomFactor*max(abs(br[0]-tl[0]), abs(br[1]-tl[1])))

        view = Matrix.translate(center[0], center[1])*Matrix.scale(1, -1)*Matrix.scale(scaleFactor)*aspect

        receiver.ui.mainView.set_view_matrix(view)

        helper.CallObservers(receiver.model.SceneDescChanged)
        receiver.ui.mainView.update()
Esempio n. 2
0
    def resizeGL(self, width, height):
        view = self.get_view_matrix()
        view = view*Matrix.scale(self.viewPort[0]/width, self.viewPort[1]/height)
        self.set_view_matrix(view)

        gl.glViewport(0, 0, width, height)
        self.viewPort = [width, height]
Esempio n. 3
0
 def __init__(self, scale, pos):
     super(ResizeScene, self).__init__(Matrix.translate(-pos[0], -pos[1])*Matrix.scale(scale)*Matrix.translate(pos[0], pos[1]))
Esempio n. 4
0
 def __init__(self, vector):
     super(TranslateScene, self).__init__(Matrix.translate(vector[0], vector[1]))