summaryrefslogtreecommitdiff
path: root/cad/src/dna/commands/DnaStrand/DnaStrand_GraphicsMode.py
blob: 322e52c0c112a9a52bde4b0cc3d98a9fef5b9f21 (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
# Copyright 2008-2009 Nanorex, Inc.  See LICENSE file for details.
"""
Graphics mode intended to be used while in DnaStrand_EditCommand.

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

History:
Created 2008-02-14

"""
from dna.commands.BuildDna.BuildDna_GraphicsMode import BuildDna_GraphicsMode
from graphics.drawing.drawDnaRibbons import drawDnaSingleRibbon
from utilities.constants import black


_superclass = BuildDna_GraphicsMode

class DnaStrand_GraphicsMode(BuildDna_GraphicsMode):

    _handleDrawingRequested = True
    cursor_over_when_LMB_pressed = ''

    def Draw_other(self):
        """
        Draw this DnaStrand object and its contents including handles (if any)
        @see:self._drawCursorText()
        @see:self._drawHandles()
        """
        # review: docstring may be wrong now that this method doesn't
        # draw the model [bruce 090310 comment]
        _superclass.Draw_other(self)
        if self._handleDrawingRequested:
            self._drawHandles()

    def _drawHandles(self):
        """
        Draw the handles for the command.struct
        @see: DnaStrand_ResizeHandle.hasValidParamsForDrawing ()
        @see:self._drawCursorText()
        @see:self.Draw_other()
        """
        if self.command and self.command.hasValidStructure():
            for handle in self.command.handles:
                #Check if handle's center (origin) and direction are
                #defined. (ONLY checks if those are not None)
                if handle.hasValidParamsForDrawing():
                    handle.draw()

        if self.command.grabbedHandle is not None:
            params = self.command.getDnaRibbonParams()
            if params:
                end1, end2, basesPerTurn, duplexRise, \
                    ribbon1_start_point, ribbon1_direction, ribbon1Color = params
                drawDnaSingleRibbon(self.glpane,
                               end1,
                               end2,
                               basesPerTurn,
                               duplexRise,
                               self.glpane.scale,
                               self.glpane.lineOfSight,
                               self.glpane.displayMode,
                               ribbon1_start_point = ribbon1_start_point,
                               ribbon1_direction = ribbon1_direction,
                               ribbonThickness = 4.0,
                               ribbon1Color = ribbon1Color,
                               )

            #Draw the text next to the cursor that gives info about
            #number of base pairs etc
            self._drawCursorText()