summaryrefslogtreecommitdiff
path: root/cad/src/protein/commands/BuildProtein/BuildProtein_Command.py
blob: 5ea90334a23e87f5bc4a01a8ca8634044c79be0b (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
# Copyright 2008 Nanorex, Inc.  See LICENSE file for details.
"""
BuildProtein_Command.py

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

"""
from command_support.EditCommand import EditCommand
from utilities.Log  import greenmsg
from ne1_ui.toolbars.Ui_ProteinFlyout import ProteinFlyout
from protein.commands.BuildProtein.BuildProtein_PropertyManager import BuildProtein_PropertyManager
from protein.commands.BuildProtein.BuildProtein_GraphicsMode    import BuildProtein_GraphicsMode

_superclass = EditCommand
class BuildProtein_Command(EditCommand):
    """
    ModelAndSimulateProtein_EditCommand provides a convenient way to edit or create
    or simulate a Protein object
    """

    # class constants
    GraphicsMode_class = BuildProtein_GraphicsMode

    PM_class = BuildProtein_PropertyManager

    #Flyout Toolbar
    FlyoutToolbar_class = ProteinFlyout

    cmd              =  greenmsg("Build Protein: ")
    prefix           =  'ProteinGroup'   # used for gensym
    cmdname          = "Build Protein"

    commandName       = 'BUILD_PROTEIN'
    featurename       = "Build Protein"
    from utilities.constants import CL_ENVIRONMENT_PROVIDING
    command_level = CL_ENVIRONMENT_PROVIDING
    command_should_resume_prevMode = False
    command_has_its_own_PM = True
    create_name_from_prefix  =  True
    call_makeMenus_for_each_event = True

    flyoutToolbar = None
    _currentActiveTool = 'MODEL_PROTEIN'

    def command_enter_misc_actions(self):
        """
        Overrides superclass method.

        @see: baseCommand.command_enter_misc_actions()  for documentation
        """
        self.w.buildProteinAction.setChecked(True)
        return

    def command_exit_misc_actions(self): #@@@
        """
        Overrides superclass method.

        @see: baseCommand.command_exit_misc_actions()  for documentation
        """
        #self.w.buildProteinAction.setChecked(False)
        return

    def getCurrentActiveTool(self):
        return self._currentActiveTool

    def setCurrentCommandMode(self, commandName):
        """
        Sets the current active command: modeling or simulation
        """
        self._currentActiveTool = commandName
        return

    def enterModelOrSimulateCommand(self, commandName = ''):
        """
        Enter the given tools subcommand (e.g. Model or Simulate Protein command)
        """
        if not commandName:
            return

        commandSequencer = self.win.commandSequencer
        commandSequencer.userEnterCommand( commandName)
        return

    def makeMenus(self):
        """
        Create context menu for this command.
        """
        #Urmi 20080806: will implement later, once the basic system is up and
        #working
        return

    def keep_empty_group(self, group): #@@@
        """
        Returns True if the empty group should not be automatically deleted.
        otherwise returns False. The default implementation always returns
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True.
        @see: Command.keep_empty_group() which is overridden here.
        """

        bool_keep = EditCommand.keep_empty_group(self, group)

        if not bool_keep:
            if group is self.struct:
                bool_keep = True

        return bool_keep