summaryrefslogtreecommitdiff
path: root/cad/src/dna/commands/BreakStrands/BreakStrands_Command.py
blob: f4452480c3fa7dfb5e22ff558b16281b2df44b1c (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
# Copyright 2007-2008 Nanorex, Inc.  See LICENSE file for details.
"""
@author:    Ninad
@version:   $Id$
@copyright: 2007-2008 Nanorex, Inc.  See LICENSE file for details.
@license:   GPL

TODOs: [ as of 2008-01-04]
- To be revised heavily . Still a stub, needs documentation.
"""

from dna.command_support.BreakOrJoinStrands_Command import BreakOrJoinStrands_Command
from dna.commands.BreakStrands.BreakStrands_PropertyManager import BreakStrands_PropertyManager
from dna.commands.BreakStrands.BreakStrands_GraphicsMode import BreakStrands_GraphicsMode
from utilities.prefs_constants import cpkScaleFactor_prefs_key
import foundation.env as env

#debug flag for experimental code Ninad is
#working on (various break strands options)
from utilities.GlobalPreferences import DEBUG_BREAK_OPTIONS_FEATURE

_superclass = BreakOrJoinStrands_Command
class BreakStrands_Command(BreakOrJoinStrands_Command):
    """

    """

    # class constants
    commandName = 'BREAK_STRANDS'
    featurename = "Break Strands"
    GraphicsMode_class = BreakStrands_GraphicsMode

    PM_class = BreakStrands_PropertyManager


    def _get_init_gui_flyout_action_string(self):
        return 'breakStrandAction'


    def command_entered(self):
        """
        Extends superclass method.
        """
        _superclass.command_entered(self)
        self._modifyCPKScaleFactor()


    def command_will_exit(self):
        """
        Extends superclass method.
        """
        self._restoreCPKScaleFactor()
        _superclass.command_will_exit(self)

    def _modifyCPKScaleFactor(self):
        """
        Modify the global CPK scale factor prefs_key temporarily , while in
        BreakStrands command. This prefs_key will be restored while exiting this
        command
        @see: self._restoreCPKScaleFactor()
        @see: self.command_entered()
        """
        #Note 2008-11-14: This is implemented based on Mark's NFR.
        self._original_cpkScaleFactor_prefs_key = env.prefs[cpkScaleFactor_prefs_key]
        env.prefs[cpkScaleFactor_prefs_key] = 0.5

    def _restoreCPKScaleFactor(self):
        """
        @see: self._modifyCPKScaleFactor()
        @see: self.command_entered()
        @see: self.command_will_exit()
        """
        env.prefs[cpkScaleFactor_prefs_key] = self._original_cpkScaleFactor_prefs_key





    #===========================================================================
    #Methods used in experimental feature that provide various break options
    #these are not called but thhe methods do have a safety check to
    #see id DEBUG_BREAK_OPTIONS_FEATURE is set to True. -- ninad 2008-08-06


    def getStrandList(self):
        part = self.win.assy.part
        return part.get_topmost_subnodes_of_class(self.win.assy.DnaStrand)

    def isSpecifyEndAtomsToolActive(self):
        return False

    def isSpecifyStartAtomsToolActive(self):
        if not DEBUG_BREAK_OPTIONS_FEATURE:
            return False
        return True

    def getNumberOfBasesBeforeNextBreak(self):
        if not DEBUG_BREAK_OPTIONS_FEATURE:
            return 2

        if self.propMgr:
            return self.propMgr.getNumberOfBasesBeforeNextBreak()

        return 2

    def breakStrandBonds(self):
        if not DEBUG_BREAK_OPTIONS_FEATURE:
            return

        self.graphicsMode.breakStrandBonds()

    def updateBreakSites(self):
        if not DEBUG_BREAK_OPTIONS_FEATURE:
            return
        self.graphicsMode.updateBreakSites()

    #===========================================================================