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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# Copyright 2007-2009 Nanorex, Inc. See LICENSE file for details.
"""
@author: Ninad, Mark
@copyright: 2007-2009 Nanorex, Inc. See LICENSE file for details.
@version: $Id$
@license: GPL
TODO:
- User Preferences for different rubberband line display styles
"""
from utilities.constants import gray, black, darkred, blue, white
from graphics.drawing.drawNanotubeLadder import drawNanotubeLadder
from temporary_commands.LineMode.Line_Command import Line_Command
from temporary_commands.LineMode.Line_GraphicsMode import Line_GraphicsMode
# == GraphicsMode part
_superclass_for_GM = Line_GraphicsMode
class NanotubeLine_GM( Line_GraphicsMode ):
"""
Custom GraphicsMode for use as a component of NanotubeLineMode.
@see: L{NanotubeLineMode} for more comments.
@see: InsertNanotube_EditCommand where this is used as a GraphicsMode class.
The default command part in this file is a Default class
implementation of self.command (see class NanotubeLineMode)
"""
# The following valuse are used in drawing the 'sphere' that represent the
# first endpoint of the line. See Line_GraphicsMode.Draw_other for details.
endPoint1_sphereColor = white
endPoint1_sphereOpacity = 1.0
text = ''
def leftUp(self, event):
"""
Left up method
"""
if self.command.mouseClickLimit is None:
if len(self.command.mouseClickPoints) == 2:
self.endPoint2 = None
self.command.createStructure()
#DISABLED AS OF 2008-01-11. (Implementation changed --
#See InsertNanotube_EditCommand.createStructure for new
#implementaion)
##self.command.callback_addSegments()
self.glpane.gl_update()
return
def snapLineEndPoint(self):
"""
Snap the line to the specified constraints.
To be refactored and expanded.
@return: The new endPoint2 i.e. the moving endpoint of the rubberband
line . This value may be same as previous or snapped so that it
lies on a specified vector (if one exists)
@rtype: B{A}
"""
if self.command.callbackForSnapEnabled() == 1:
endPoint2 = _superclass_for_GM.snapLineEndPoint(self)
else:
endPoint2 = self.endPoint2
return endPoint2
def Draw_other(self):
"""
Draw the Nanotube rubberband line (a ladder representation)
"""
_superclass_for_GM.Draw_other(self)
if self.endPoint2 is not None and \
self.endPoint1 is not None:
# Draw the ladder.
drawNanotubeLadder(
self.endPoint1,
self.endPoint2,
self.command.nanotube.getRise(),
self.glpane.scale,
self.glpane.lineOfSight,
ladderWidth = self.command.nanotube.getDiameter(),
beamThickness = 4.0,
)
return
pass # end of class NanotubeLine_GM
# == Command part
class NanotubeLineMode(Line_Command): # not used as of 080111, see docstring
"""
[no longer used as of 080111, see details below]
Encapsulates the Line_Command functionality.
@see: L{Line_Command}
@see: InsertNanotube_EditCommand.getCursorText()
NOTE: [2008-01-11]
The default NanotubeLineMode (command) part is not used as of 2008-01-11
Instead, the interested commands use its GraphicsMode class.
However, its still possible to use and implement the default command
part. (The old implementation of generating Cnt using endpoints of a
line used this default command class (NanotubeLineMode). so the method in this
class such as self.createStructure does nothing .
@see: InsertNanotube_EditCommand where the GraphicsMode class of this command is
used
"""
# class constants
commandName = 'NANOTUBE_LINE_MODE'
featurename = "Nanotube Line Mode"
# (This featurename is sometimes user-visible,
# but is probably not useful. See comments in Line_Command
# for more info and how to fix. [bruce 071227])
from utilities.constants import CL_UNUSED
command_level = CL_UNUSED
GraphicsMode_class = NanotubeLine_GM
def setParams(self, params):
assert len(params) == 5
self.mouseClickLimit, \
self.cntRise, \
self.callbackMethodForCursorTextString, \
self.callbackForSnapEnabled, \
self.callback_rubberbandLineDisplay = params
def createStructure(self):
"""
Does nothing.
@see: NanotubeLineMode_GM.leftUp
@see: comment at the beginning of the class
"""
return
pass
# end
|