summaryrefslogtreecommitdiff
path: root/cad/src/temporary_commands/PanMode.py
blob: e9a35b7d4624e43011bf076e221b76d32ac4d704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2005-2007 Nanorex, Inc.  See LICENSE file for details.
"""
Pan mode functionality.

@author:    Mark Sims
@version:   $Id$
@copyright: 2005-2007 Nanorex, Inc.  See LICENSE file for details.
@license:   GPL
"""

from temporary_commands.TemporaryCommand import TemporaryCommand_Overdrawing

# == GraphicsMode part

class PanMode_GM( TemporaryCommand_Overdrawing.GraphicsMode_class ):
    """
    Custom GraphicsMode for use as a component of PanMode.
    """
    def leftDown(self, event):
        """
        Event handler for LMB press event.
        """
        # Setup pan operation
        farQ_junk, self.movingPoint = self.dragstart_using_GL_DEPTH( event)
        return

    def leftDrag(self, event):
        """
        Event handler for LMB drag event.
        """
        point = self.dragto( self.movingPoint, event)
        self.glpane.pov += point - self.movingPoint
        self.glpane.gl_update()
        return

    def update_cursor_for_no_MB(self): # Fixes bug 1638. Mark 3/12/2006.
        """
        Update the cursor for 'Pan' mode.
        """
        self.glpane.setCursor(self.win.PanViewCursor)

    pass

# == Command part

class PanMode(TemporaryCommand_Overdrawing): # TODO: rename to PanTool or PanCommand or TemporaryCommand_Pan or ...
    """
    Encapsulates the Pan tool functionality.
    """
    # class constants

    commandName = 'PAN'
    featurename = "Pan Tool"
    from utilities.constants import CL_VIEW_CHANGE
    command_level = CL_VIEW_CHANGE

    GraphicsMode_class = PanMode_GM

    def command_enter_misc_actions(self):
        """
        See superclass method for documentation
        """
        self.win.panToolAction.setChecked(True)

    def command_exit_misc_actions(self):
        """
        See superclass method for documentation
        """
        self.win.panToolAction.setChecked(False)