summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Smith <bruce@nanorex.com>2009-03-11 19:31:12 +0000
committerBruce Smith <bruce@nanorex.com>2009-03-11 19:31:12 +0000
commite384d2f33fe0fbe562826b2ddfc5a038f4f77bef (patch)
tree0bdc62268e7f2ab83317bf311cc63bb485c7d238
parent795c25aa6847ab245e31dfa0699e7373e156c19e (diff)
downloadnanoengineer-e384d2f33fe0fbe562826b2ddfc5a038f4f77bef.tar.gz
nanoengineer-e384d2f33fe0fbe562826b2ddfc5a038f4f77bef.zip
rename some methods for consistency
-rwxr-xr-xcad/src/command_support/GraphicsMode.py36
-rw-r--r--cad/src/command_support/GraphicsMode_API.py4
-rwxr-xr-xcad/src/commands/Move/Move_GraphicsMode.py2
-rwxr-xr-xcad/src/commands/Rotate/RotateChunks_GraphicsMode.py11
-rwxr-xr-xcad/src/commands/SelectChunks/SelectChunks_GraphicsMode.py30
-rwxr-xr-xcad/src/commands/Translate/TranslateChunks_GraphicsMode.py8
-rwxr-xr-xcad/src/graphics/drawing/ColorSortedDisplayList.py39
-rw-r--r--cad/src/graphics/widgets/GLPane_highlighting_methods.py9
-rw-r--r--cad/src/graphics/widgets/GLPane_rendering_methods.py2
9 files changed, 78 insertions, 63 deletions
diff --git a/cad/src/command_support/GraphicsMode.py b/cad/src/command_support/GraphicsMode.py
index 155aadb3f..d08cb3c79 100755
--- a/cad/src/command_support/GraphicsMode.py
+++ b/cad/src/command_support/GraphicsMode.py
@@ -318,10 +318,13 @@ class basicGraphicsMode(GraphicsMode_API):
# ==
# Note: toplevel drawing methods in the GraphicsMode API for its GLPane
- # are called Draw_* (capital D) (at least the main ones for drawing the
- # model and related things, in model coordinates -- a few older ones
- # have not been reviewed for renaming to make this a consistent division).
- # Other drawing methods use a lowercase 'd'. [bruce 090311 comment]
+ # have names starting with Draw_ (capital 'D') whenever they are intended
+ # for drawing the model, or objects in the same 3d space. They are all called
+ # within the stereo image loop, and with absolute model coordinates current.
+ #
+ # Other drawing methods in this API start with "draw" (lower-case 'd')
+ # (or perhaps something else if they are older and I missed them in my
+ # review today), and are called under other conditions. [bruce 090311]
def Draw(self): #bruce 090310-11 split this up and removed it from the GraphicsMode API
"""
@@ -610,33 +613,42 @@ class basicGraphicsMode(GraphicsMode_API):
return True # let the selobj remain
pass
- def drawHighlightedObjectUnderMouse(self, glpane, selobj, hicolor):
+ def Draw_highlighted_selobj(self, glpane, selobj, hicolor):
"""
[overrides GraphicsMode_API method]
- Subclasses should override this as needed, though most don't need to:
-
- Draw selobj in highlighted form for being the object under the mouse,
+ Draw selobj in highlighted form for being the "object under the mouse",
as appropriate to this graphics mode.
[TODO: document this properly: Use hicolor as its color
if you return sensible colors from method XXX.]
+ Subclasses should override this as needed (for example, to highlight a
+ larger object that contains selobj), though many don't need to.
+
Note: selobj is typically glpane.selobj, but don't assume this.
"""
+ #bruce 090311 renamed this from drawHighlightedObjectUnderMouse;
+ # it now starts with Draw_ since it's called inside the stereo loop
selobj.draw_in_abs_coords(glpane, hicolor)
def draw_glpane_label(self, glpane):
- ### review: rename to start with Draw_, or reserve that prefix for
- # when the same coords are in use as when calling Draw_model? [bruce 090311 Q]
"""
- #doc [see doc in the glpane method we call] [#doc coord sys when called]
+ [part of the GraphicsMode API for drawing into a GLPane]
+
+ This is called with model coordinates, but outside of stereo loops,
+ once per paintGL call, after model drawing. It is meant to allow
+ the GraphicsMode to draw a text label for the entire GLPane.
- @note: called from GLPane.paintGL shortly after graphicsMode.Draw_*()
+ The default implementation determines the text by calling
+ glpane.part.glpane_label_text() and draws it using
+ glpane.draw_glpane_label_text (which uses a standard
+ location and style for a whole-glpane label).
"""
#bruce 090219 moved this here from part.py, renamed from draw_text_label
# (after refactoring it the prior day, 090218)
# (note: caller catches exceptions, so we don't have to bother)
+ # (not named with a capital 'D' since not inside stereo loop [bruce 090311])
text = self.glpane.part.glpane_label_text()
if text:
diff --git a/cad/src/command_support/GraphicsMode_API.py b/cad/src/command_support/GraphicsMode_API.py
index 0c6dd9c4f..db82c61f3 100644
--- a/cad/src/command_support/GraphicsMode_API.py
+++ b/cad/src/command_support/GraphicsMode_API.py
@@ -104,7 +104,7 @@ class GraphicsMode_API(GraphicsMode_interface):
# but which receives a single argument which will be the GLPane.
check_target_depth_fudge_factor = 0.0001
- # affects GLPane's algorithm for finding objectUnderMouse (selobj)
+ # affects GLPane's algorithm for finding selobj (aka objectUnderMouse)
# default methods of various kinds:
@@ -158,7 +158,7 @@ class GraphicsMode_API(GraphicsMode_interface):
def draw_overlay(self): # misnamed
return
- def drawHighlightedObjectUnderMouse(self, glpane, selobj, hicolor):
+ def Draw_highlighted_selobj(self, glpane, selobj, hicolor):
"""
@see: GraphicsMode version, for docstring
"""
diff --git a/cad/src/commands/Move/Move_GraphicsMode.py b/cad/src/commands/Move/Move_GraphicsMode.py
index 7555a6d38..9aa15a5be 100755
--- a/cad/src/commands/Move/Move_GraphicsMode.py
+++ b/cad/src/commands/Move/Move_GraphicsMode.py
@@ -221,7 +221,7 @@ class Move_GraphicsMode(SelectChunks_GraphicsMode):
return
if self.o.modkeys is not None:
- #@see : comment related to this condition in _superclass.leftDrag
+ #@see: comment related to this condition in _superclass.leftDrag
self.emptySpaceLeftDown(self.LMB_press_event)
return
diff --git a/cad/src/commands/Rotate/RotateChunks_GraphicsMode.py b/cad/src/commands/Rotate/RotateChunks_GraphicsMode.py
index 9e0930712..18cda4e47 100755
--- a/cad/src/commands/Rotate/RotateChunks_GraphicsMode.py
+++ b/cad/src/commands/Rotate/RotateChunks_GraphicsMode.py
@@ -1,7 +1,7 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
-@version:$Id$
+@version: $Id$
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
History:
Ninad 2008-01-25: Split the former 'modifyMode '
@@ -153,7 +153,7 @@ class RotateChunks_GraphicsMode(Move_GraphicsMode):
@param event: The mouse left drag event.
@type event: QMouseEvent object
- @see : self.leftDrag
+ @see: self.leftDrag
"""
if self.command and self.command.propMgr and \
@@ -227,8 +227,7 @@ class RotateChunks_GraphicsMode(Move_GraphicsMode):
@param event: The mouse left drag event.
@type event: QMouseEvent instance
- @see : self.leftDragRotation
-
+ @see: self.leftDragRotation
"""
selectedMovables = self._leftDrag_movables
diff --git a/cad/src/commands/SelectChunks/SelectChunks_GraphicsMode.py b/cad/src/commands/SelectChunks/SelectChunks_GraphicsMode.py
index 9f5aa2249..6ec64adf3 100755
--- a/cad/src/commands/SelectChunks/SelectChunks_GraphicsMode.py
+++ b/cad/src/commands/SelectChunks/SelectChunks_GraphicsMode.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
SelectChunks_GraphicsMode.py
@@ -13,7 +13,7 @@ For example:
@version: $Id$
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
TODO:
@@ -655,9 +655,9 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
It calls separate method for objects that implement drag handler API
@param event: mouse left drag event
- @see : selectMode.leftDrag
- @see : SelectChunks_GraphicsMode._leftDown_preparation_for_dragging
- @see : SelectChunks_GraphicsMode.leftDragTranslation
+ @see: selectMode.leftDrag
+ @see: SelectChunks_GraphicsMode._leftDown_preparation_for_dragging
+ @see: SelectChunks_GraphicsMode.leftDragTranslation
"""
@@ -709,7 +709,7 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
leftDrag method (leftDragTranslation) .
@param event: Mouse left down event
@param objectUnderMouse: Object under the mouse during left down event.
- @see : self.leftDown()
+ @see: self.leftDown()
@see: self.getMovablesForLeftDragging()
"""
#pseudo move mode related initialization STARTS
@@ -749,7 +749,7 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
def _leftDragFreeTranslation(self, event):
"""
- @see : self.leftDrag()
+ @see: self.leftDrag()
@see: self._leftDragFreeTranslation()
@see: self._leftDragConstrainedTranslation()
"""
@@ -967,7 +967,7 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
(usually, this is just whether we drew something)
@rtype: boolean
@see: self._get_objects_to_highlight()
- @see : self.drawHighlightedObjectUnderMouse()
+ @see: self.Draw_highlighted_selobj()
"""
# Ninad 070214 wrote this in GLPane; bruce 071008 moved it into
# SelectChunks_GraphicsMode and slightly revised it (including, adding the return
@@ -1016,7 +1016,7 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
@return: dictionary of objects to be highlighted.
@rtype: dict
@see: self.drawHighlightedChunk()
- @see : self.drawHighlightedObjectUnderMouse()
+ @see: self.Draw_highlighted_selobj()
"""
#Create a dictionary of objects to be drawn highlighted.
@@ -1078,13 +1078,11 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
return objectDict
- def drawHighlightedObjectUnderMouse(self, glpane, selobj, hicolor):
+ def Draw_highlighted_selobj(self, glpane, selobj, hicolor):
"""
[overrides superclass method]
@see: self._get_objects_to_highlight()
@see: self.drawHighlightedChunk()
-
-
"""
# Ninad 070214 wrote this in GLPane; bruce 071008 moved it into
# SelectChunks_GraphicsMode and slightly revised it.
@@ -1101,10 +1099,10 @@ class SelectChunks_basicGraphicsMode(Select_basicGraphicsMode):
# The prior code was equivalent to every subclass doing that.
# - [bruce 071008]
if not skip_usual_selobj_highlighting:
- _superclass.drawHighlightedObjectUnderMouse(self,
- glpane,
- selobj,
- hicolor)
+ _superclass.Draw_highlighted_selobj(self,
+ glpane,
+ selobj,
+ hicolor)
return
def _getAtomHighlightColor(self, selobj):
diff --git a/cad/src/commands/Translate/TranslateChunks_GraphicsMode.py b/cad/src/commands/Translate/TranslateChunks_GraphicsMode.py
index b793ab1a9..24309b4e0 100755
--- a/cad/src/commands/Translate/TranslateChunks_GraphicsMode.py
+++ b/cad/src/commands/Translate/TranslateChunks_GraphicsMode.py
@@ -1,7 +1,7 @@
-# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details.
+# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details.
"""
-@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details.
-@version:$Id$
+@version: $Id$
+@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details.
History:
Ninad 2008-01-25: Split modifyMode into Commmand and GraphicsMode classes
@@ -161,7 +161,7 @@ class TranslateChunks_GraphicsMode(Move_GraphicsMode):
- or slide and rotate along the an axis
@param event: The mouse left drag event.
- @see : self.leftDrag()
+ @see: self.leftDrag()
@see: self._leftDragFreeTranslation()
@see: self._leftDragConstrainedTranslation()
"""
diff --git a/cad/src/graphics/drawing/ColorSortedDisplayList.py b/cad/src/graphics/drawing/ColorSortedDisplayList.py
index 1320eacaf..82553e23f 100755
--- a/cad/src/graphics/drawing/ColorSortedDisplayList.py
+++ b/cad/src/graphics/drawing/ColorSortedDisplayList.py
@@ -474,23 +474,28 @@ class ColorSortedDisplayList: #Russ 080225: Added.
# ==
- #### REVIEW: the methods draw_in_abs_coords and nodes_containing_selobj
- # don't make sense in this class in the long run, since it is not meant
- # to be directly used as a "selobj" or as a Node. I presume they are
- # only needed by temporary testing and debugging code, and they should be
- # removed when no longer needed. [bruce 090114 comment]
-
- # Russ 081128: Used by preDraw_glselect_dict() in standard_repaint_0(), and
- # draw_highlighted_objectUnderMouse() in _do_other_drawing_inside_stereo().
- def draw_in_abs_coords(self, glpane, color):
- self.draw(highlighted = True, highlight_color = color)
- return
-
- # Russ 081128: Used by GLPane._update_nodes_containing_selobj().
- def nodes_containing_selobj(self):
- # XXX Only TestGraphics_GraphicsMode selects CSDL's now, so no
- # XXX connection to the Model Tree.
- return []
+#### NOTE: the methods draw_in_abs_coords and nodes_containing_selobj
+# don't make sense in this class in the long run, since it is not meant
+# to be directly used as a "selobj" or as a Node. I presume they are
+# only needed by temporary testing and debugging code, and they should be
+# removed when no longer needed. [bruce 090114 comment]
+#
+# Update, bruce 090311: I'm removing them now (since we need to test the
+# claim that nothing but test code depends on them). Any testCases this
+# breaks should be rewritten to put their CSDLs inside wrapper objects
+# which provide these methods.
+#
+## # Russ 081128: Used by preDraw_glselect_dict() in standard_repaint_0(), and
+## # _draw_highlighted_selobj() in _do_other_drawing_inside_stereo().
+## def draw_in_abs_coords(self, glpane, color):
+## self.draw(highlighted = True, highlight_color = color)
+## return
+##
+## # Russ 081128: Used by GLPane._update_nodes_containing_selobj().
+## def nodes_containing_selobj(self):
+## # XXX Only TestGraphics_GraphicsMode selects CSDL's now, so no
+## # XXX connection to the Model Tree.
+## return []
# ==
diff --git a/cad/src/graphics/widgets/GLPane_highlighting_methods.py b/cad/src/graphics/widgets/GLPane_highlighting_methods.py
index f675a9ced..1be765501 100644
--- a/cad/src/graphics/widgets/GLPane_highlighting_methods.py
+++ b/cad/src/graphics/widgets/GLPane_highlighting_methods.py
@@ -412,7 +412,8 @@ class GLPane_highlighting_methods(object):
"""
return self.assy.alloc_my_glselect_name(obj)
- def draw_highlighted_objectUnderMouse(self, selobj, hicolor): #bruce 070920 split this out
+ def _draw_highlighted_selobj(self, selobj, hicolor):
+ #bruce 070920 split this out; 090311 renamed it
"""
Draw selobj in highlighted form, using its "selobj drawing interface"
(not yet a formal interface; we use several methods including draw_in_abs_coords).
@@ -492,7 +493,7 @@ class GLPane_highlighting_methods(object):
# [This should fix the Qt4 transition issue which is the subject of reminder bug 2300,
# though it can't be tested yet since it has no known effect on current code, only on future code.]
def func():
- self.graphicsMode.drawHighlightedObjectUnderMouse( self, selobj, hicolor)
+ self.graphicsMode.Draw_highlighted_selobj( self, selobj, hicolor)
# TEST someday: test having color writing disabled here -- does stencil write still happen??
# (not urgent, since we definitely need color writing here.)
return
@@ -500,7 +501,7 @@ class GLPane_highlighting_methods(object):
except:
# try/except added for GL-state safety, bruce 061218
print_compact_traceback(
- "bug: exception in %r.drawHighlightedObjectUnderMouse for %r ignored: " % \
+ "bug: exception in %r.Draw_highlighted_selobj for %r ignored: " % \
(self.graphicsMode, selobj)
)
pass
@@ -540,7 +541,7 @@ class GLPane_highlighting_methods(object):
glDisable(GL_STENCIL_TEST)
- return # from draw_highlighted_objectUnderMouse
+ return # from _draw_highlighted_selobj
def preDraw_glselect_dict(self): #bruce 050609
"""
diff --git a/cad/src/graphics/widgets/GLPane_rendering_methods.py b/cad/src/graphics/widgets/GLPane_rendering_methods.py
index 6f187fb5d..bef5d2260 100644
--- a/cad/src/graphics/widgets/GLPane_rendering_methods.py
+++ b/cad/src/graphics/widgets/GLPane_rendering_methods.py
@@ -1039,7 +1039,7 @@ class GLPane_rendering_methods(GLPane_image_methods):
# if it was (probably an important optimization).
selobj, hicolor = self._selobj_and_hicolor
if selobj is not None:
- self.draw_highlighted_objectUnderMouse(selobj, hicolor)
+ self._draw_highlighted_selobj(selobj, hicolor)
# REVIEW: is it ok that the mode had to tell us selobj and hicolor
# (and validate selobj) before drawing the model?