summaryrefslogtreecommitdiff
path: root/cad/src/dna/commands/InsertDna/InsertDna_GraphicsMode.py
blob: 40474eb80f1dd33fef017e5d07b49b4344dc4dc9 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright 2008 Nanorex, Inc.  See LICENSE file for details.
"""
InsertDna_GraphicsMode.py

Graphics mode class for creating a dna duplex by specifying two line end
points. The duplex can be created on a specified plane or parallel to screen

@author: Ninad
@copyright: 2008 Nanorex, Inc.  See LICENSE file for details.
@version:$Id$

History:
Created on 2008-06-24

TODO:
- 2008-06-24: See  DnaOrCntPropertyManager class for a detailed to do comment regarding
the tool that allows user to specify a drawing plane.
"""
from PyQt4.Qt import Qt

from dna.temporary_commands.DnaLineMode import DnaLine_GM
from graphics.drawing.drawDnaLabels import draw_dnaBaseNumberLabels

_superclass = DnaLine_GM
class InsertDna_GraphicsMode(DnaLine_GM):
    """
    Graphics mode class for creating a dna duplex by specifying two line end
    points. The duplex can be created on a specified plane or parallel to screen
    @see: Line_GraphicsMode.bareMotion()
    @see: Line_GraphicsMode.leftDown()
    @see: DnaLine_GM.leftUp()
    """

    def _drawLabels(self):
        """
        Overrides suoerclass method.
        @see: GraphicsMode._drawLabels()
        """
        _superclass._drawLabels(self)
        draw_dnaBaseNumberLabels(self.glpane)


    def update_cursor_for_no_MB(self):
        """
        Update the cursor for no mouse button pressed
        """

        _superclass.update_cursor_for_no_MB(self)

        if self.isSpecifyPlaneToolActive():
            self.o.setCursor(self.win.specifyPlaneCursor)


    def keyPressEvent(self, event):
        """
        Handles keyPressEvent. Overrides superclass method. If delete key
        is pressed while the focus is inside the PM list widget, it deletes
        that list widget item.
        @see: ListWidgetItems_PM_Mixing.listWidgetHasFocus()
        @see: InsertDna_PropertyManager.listWidgetHasFocus()
        """
        if event.key() == Qt.Key_Delete:
            if self.command.listWidgetHasFocus():
                self.command.removeListWidgetItems()
                return

        _superclass.keyPressEvent(self, event)

    def jigLeftUp(self, j, event):
        """
        Overrides superclass method See that method for more details.

        Additional things it does: If the jig is a Plane and if Specify reference
        plane tool is enabled (from the Property manager), this method updates
        the 'drawing plane' on which the dna duplex will be created.

        @see: Select_graphicsmode_MouseHelpers_preMixin.jigLeftUp()
        @see: self.self.isSpecifyPlaneToolActive()
        """
        if self.isSpecifyPlaneToolActive() and self.glpane.modkeys is None:
            if isinstance(j, self.win.assy.Plane):
                self.command.updateDrawingPlane(j)
            return

        _superclass.jigLeftUp(self, j, event)


    def isSpecifyPlaneToolActive(self):
        """
        Overrides superclass method. Delegates this job to self.command.
        @see: InsertDna_EditCommand.isSpecifyPlaneToolActive()
        @see: InsertDna_PropertyManager.isSpecifyPlaneToolActive()
        @see: self.jigLeftUp()
        """
        if self.command:
            return self.command.isSpecifyPlaneToolActive()

        return False


    def getDrawingPlane(self):
        """
        Overridden in subclasses.

        Returns the reference plane on which the line will be drawn.
        The default immplementation returns None.
        @see: InsertDna_EditCommand.useSpecifiedDrawingPlane()
        @see: Line_GraphicsMode.bareMotion()
        @see: Line_GraphicsMode.leftDown()
        """
        if self.command.useSpecifiedDrawingPlane():
            return self.plane
        else:
            return None