summaryrefslogtreecommitdiff
path: root/cad/src/commands/BuildAtoms/BondTool_GraphicsMode.py
blob: d68a7b25cf518018e24b09ab646172d98ee8a606 (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
from commands.BuildAtoms.BuildAtoms_GraphicsMode import BuildAtoms_GraphicsMode
##from commands.SelectAtoms.SelectAtoms_GraphicsMode import SelectAtoms_GraphicsMode
from model.bond_constants import V_SINGLE
from utilities.prefs_constants import buildModeHighlightingEnabled_prefs_key
import foundation.env as env

_superclass =  BuildAtoms_GraphicsMode
class BondTool_GraphicsMode(BuildAtoms_GraphicsMode):
    """
    """
    def Enter_GraphicsMode(self):
        _superclass.Enter_GraphicsMode(self)
        self.setBond(self.command.getBondType(), True)

    def bondLeftUp(self, b, event):
        # was bondClicked(). mark 060220.
        #[WARNING: docstring appears to be out of date -- bruce 060702]
        """
        Bond <b> was clicked, so select or unselect its atoms or delete bond <b>
        based on the current modkey.
        - If no modkey is pressed, clear the selection and pick <b>\'s two atoms.
        - If Shift is pressed, pick <b>\'s two atoms, adding them to the
          current selection.
        - If Ctrl is pressed,  unpick <b>\'s two atoms, removing them from the
          current selection.
        - If Shift+Control (Delete) is pressed, delete bond <b>.
        <event> is a LMB release event.
        """

        if self.o.modkeys is None:
            self.bond_change_type(b, allow_remake_bondpoints = True)
            self.o.gl_update()
            return

        _superclass.bondLeftUp(self, b, event)

        if self.o.modkeys is None:
            if self.command.isBondsToolActive():
            #Following fixes bug 2425 (implements single click bond deletion
            #in Build Atoms. -- ninad 20070626
                if self.command.isDeleteBondsToolActive():
                    self.bondDelete(event)
                    #@ self.o.gl_update() # Not necessary since win_update()
                                          # is called in bondDelete().
                                          # Mark 2007-10-19
                    return
                self.bond_change_type(b, allow_remake_bondpoints = True)
                self.o.gl_update()
                return
        _superclass.bondLeftUp(self, b, event)

    pass


class DeleteBondTool_GraphicsMode(BuildAtoms_GraphicsMode):


    def bondLeftUp(self, b, event):
        if self.o.modkeys is None:
            self.bondDelete(event)
            #@ self.o.gl_update() # Not necessary since win_update()
            # is called in bondDelete().
            # Mark 2007-10-19
            return

        _superclass.bondLeftUp(self, b, event)