diff options
author | Bruce Smith <bruce@nanorex.com> | 2009-02-28 01:18:08 +0000 |
---|---|---|
committer | Bruce Smith <bruce@nanorex.com> | 2009-02-28 01:18:08 +0000 |
commit | 707ebe1abf46846b5ca771dbba464a54a5e56bbd (patch) | |
tree | eaa9018c16a771644fc3b65c17952a1f395b326c | |
parent | 6032d5def9b8235d2ea0de4e5bf0ecf8962cdcd4 (diff) | |
download | nanoengineer-theirix-707ebe1abf46846b5ca771dbba464a54a5e56bbd.tar.gz nanoengineer-theirix-707ebe1abf46846b5ca771dbba464a54a5e56bbd.zip |
clean up Draw_after_highlighting; pass drawing_phase in those jig select methods that shouldn't exist
-rwxr-xr-x | cad/src/analysis/ESP/ESPImage.py | 10 | ||||
-rwxr-xr-x | cad/src/command_support/GraphicsMode.py | 7 | ||||
-rw-r--r-- | cad/src/command_support/GraphicsMode_API.py | 2 | ||||
-rwxr-xr-x | cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py | 4 | ||||
-rwxr-xr-x | cad/src/commands/BuildCrystal/BuildCrystal_Command.py | 4 | ||||
-rwxr-xr-x | cad/src/commands/Extrude/extrudeMode.py | 4 | ||||
-rwxr-xr-x | cad/src/commands/Select/Select_GraphicsMode.py | 24 | ||||
-rwxr-xr-x | cad/src/exprs/testdraw.py | 3 | ||||
-rwxr-xr-x | cad/src/exprs/testmode.py | 2 | ||||
-rwxr-xr-x | cad/src/foundation/Group.py | 9 | ||||
-rwxr-xr-x | cad/src/foundation/Utility.py | 5 | ||||
-rw-r--r-- | cad/src/graphics/widgets/GLPane_drawingset_methods.py | 27 | ||||
-rw-r--r-- | cad/src/graphics/widgets/GLPane_rendering_methods.py | 38 | ||||
-rwxr-xr-x | cad/src/graphics/widgets/ThumbView.py | 6 | ||||
-rwxr-xr-x | cad/src/model/Plane.py | 19 |
15 files changed, 99 insertions, 65 deletions
diff --git a/cad/src/analysis/ESP/ESPImage.py b/cad/src/analysis/ESP/ESPImage.py index a95e4e695..236c860b5 100755 --- a/cad/src/analysis/ESP/ESPImage.py +++ b/cad/src/analysis/ESP/ESPImage.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. """ ESPImage.py - display an Electrostatic Potential Image (or any OpenGL texture) @@ -8,7 +8,7 @@ the 3d model space. @author: Huaicai, Bruce @version: $Id$ -@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details. +@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details. History: @@ -396,8 +396,7 @@ class ESPImage(RectGadget): def draw(self, glpane, dispdef): """ Does nothing. All the drawing is done after the main drawing code is - done. (i.e. in self.draw_after_highlighting(). - @see: self.draw_after_highlighting() + done. (i.e. in self.draw_after_highlighting()). """ pass @@ -410,9 +409,6 @@ class ESPImage(RectGadget): drawing code is finished drawing.) This method ensures that the ESP image jig gets selected even when you click inside the rectangular box (i.e. not just along the edges of the box). - @see: GraphicsMode.Draw_after_highlighting() - @see: Node.draw_after_highlighting() - @see: Plane.draw_after_highlighting() """ anythingDrawn = False if self.hidden: diff --git a/cad/src/command_support/GraphicsMode.py b/cad/src/command_support/GraphicsMode.py index 519c746ef..fd75926f1 100755 --- a/cad/src/command_support/GraphicsMode.py +++ b/cad/src/command_support/GraphicsMode.py @@ -493,11 +493,12 @@ class basicGraphicsMode(GraphicsMode_API): UPDATE 2008-06-20: Another example use of this method: Used for selecting a Reference Plane when user clicks inside the filled plane (i.e. not along the edges). - See new API method Node.draw_after_highlighthing + See new API method Node.draw_after_highlighting + [note capitalization and arg signature difference] which is called here. It fixes bug 2900-- Ninad ] - @see: Plane.draw_after_highlighthing() - @see: Node.draw_after_highlighitng() + @see: Plane.draw_after_highlighting() + @see: Node.draw_after_highlighting() """ return self.o.assy.part.topnode.draw_after_highlighting( self.glpane, diff --git a/cad/src/command_support/GraphicsMode_API.py b/cad/src/command_support/GraphicsMode_API.py index 2fc819038..2f88b393b 100644 --- a/cad/src/command_support/GraphicsMode_API.py +++ b/cad/src/command_support/GraphicsMode_API.py @@ -87,7 +87,7 @@ class GraphicsMode_API(object): # [bruce 081223 comment] return - def Draw_after_highlighting(self): + def Draw_after_highlighting(self, pickCheckOnly = False): return def draw_overlay(self): # misnamed diff --git a/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py b/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py index 049d9eb20..57bc9dc68 100755 --- a/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py +++ b/cad/src/commands/BuildAtoms/BuildAtoms_GraphicsMode.py @@ -361,7 +361,7 @@ class BuildAtoms_basicGraphicsMode(SelectAtoms_basicGraphicsMode): -- just a hack for Build mode's water surface. Could be used for transparent drawing in general.] """ - _superclass.Draw_after_highlighting(self, pickCheckOnly) #Draw possible other translucent objects. [huaicai 9/28/05] + res = _superclass.Draw_after_highlighting(self, pickCheckOnly) #Draw possible other translucent objects. [huaicai 9/28/05] glDepthMask(GL_FALSE) # disable writing the depth buffer, so bareMotion selobj check measures depths behind it, @@ -372,7 +372,7 @@ class BuildAtoms_basicGraphicsMode(SelectAtoms_basicGraphicsMode): # but ok then, since water was drawn last and bareMotion had no depth-buffer pixel check.) self.surface() glDepthMask(GL_TRUE) - return + return res def surface(self): """ diff --git a/cad/src/commands/BuildCrystal/BuildCrystal_Command.py b/cad/src/commands/BuildCrystal/BuildCrystal_Command.py index 980356aa4..342ae3458 100755 --- a/cad/src/commands/BuildCrystal/BuildCrystal_Command.py +++ b/cad/src/commands/BuildCrystal/BuildCrystal_Command.py @@ -1045,12 +1045,12 @@ class BuildCrystal_Command(basicMode): self.o.assy.draw(self.o) return - def Draw_after_highlighting(self): + def Draw_after_highlighting(self, pickCheckOnly = False): """ Only draw those translucent parts of the whole model when we are requested to draw the whole model """ if self.showFullModel: - basicMode.Draw_after_highlighting(self) + return basicMode.Draw_after_highlighting(self, pickCheckOnly) return def griddraw(self): diff --git a/cad/src/commands/Extrude/extrudeMode.py b/cad/src/commands/Extrude/extrudeMode.py index a2e0f005f..745ac9b8f 100755 --- a/cad/src/commands/Extrude/extrudeMode.py +++ b/cad/src/commands/Extrude/extrudeMode.py @@ -1742,13 +1742,13 @@ class extrudeMode(basicMode): return # from Draw ## Added this method to fix bug 1043 [Huaicai 10/04/05] - def Draw_after_highlighting(self): + def Draw_after_highlighting(self, pickCheckOnly = False): """ Only draw those translucent parts of the whole model when we are requested to draw the whole model """ if self.show_entire_model: - basicMode.Draw_after_highlighting(self) + return basicMode.Draw_after_highlighting(self, pickCheckOnly) return call_makeMenus_for_each_event = True #bruce 050914 enable dynamic context menus [fixes bug 971] diff --git a/cad/src/commands/Select/Select_GraphicsMode.py b/cad/src/commands/Select/Select_GraphicsMode.py index fc21778fe..f7a4db0b6 100755 --- a/cad/src/commands/Select/Select_GraphicsMode.py +++ b/cad/src/commands/Select/Select_GraphicsMode.py @@ -778,7 +778,7 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, if obj is None: # a "highlighted" jig [i think this comment is #misleading, it might really be nothing -- bruce 060726] obj = self.get_jig_under_cursor(event) # [this can be slow -- bruce comment 070322] - if 0 and env.debug(): + if env.debug(): ####### print "debug fyi: get_jig_under_cursor returns %r" % (obj,) # [bruce 060721] pass @@ -1114,8 +1114,8 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, glEnable(GL_CLIP_PLANE0) def func(): assy.draw(self.o) - self.o._call_func_that_draws_model( func) - self.Draw_after_highlighting(pickCheckOnly = True) + self.o._call_func_that_draws_model( func, drawing_phase = 'main') + self.o.call_Draw_after_highlighting(self, pickCheckOnly = True) glDisable(GL_CLIP_PLANE0) except: # BUG: this except clause looks wrong. It doesn't return, @@ -1123,7 +1123,8 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, # [bruce 080917 comment] # Restore Model view matrix, select mode to render mode - msg = "exception in mode.Draw_after_highlighting() during GL_SELECT; ignored; restoring modelview matrix: " + msg = "exception in code around mode.Draw_after_highlighting() " \ + "during GL_SELECT; ignored; restoring modelview matrix: " print_compact_traceback(msg + ": ") glPopMatrix() glRenderMode(GL_RENDER) @@ -1382,11 +1383,11 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, glMatrixMode(GL_MODELVIEW) glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE) - if self.Draw_after_highlighting(pickCheckOnly = True): + if self.o.call_Draw_after_highlighting(self, pickCheckOnly = True): # Only when we have translucent planes drawn def func(): self.o.assy.draw(self.o) - self.o._call_func_that_draws_model( func) + self.o._call_func_that_draws_model( func, drawing_phase = 'main') pass wZ = glReadPixelsf(wX, wY, 1, 1, GL_DEPTH_COMPONENT) @@ -1411,15 +1412,18 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, # BUG: both methods like this in this class are wrong when left/right # stereo is enabled. The best fix would be to remove them completely, - # since they should ever have existed at all, since general highlighting + # since they should never have existed at all, since general highlighting # code handles jigs. Unfortunately removing them is hard -- # for how to do it, see comment near the call of this method # in this file. [bruce 080917 comment] + # this method has two calls, one in this file and one in commands/Move/Move_GraphicsMode + # [bruce 090227 comment] + wX = event.pos().x() wY = self.o.height - event.pos().y() - gz = self._calibrateZ(wX, wY) # note: this redraws the entire model + gz = self._calibrateZ(wX, wY) # note: this sometimes redraws the entire model if gz >= GL_FAR_Z: # Empty space was clicked--This may not be true for translucent face [Huaicai 10/5/05] return False @@ -1446,8 +1450,8 @@ class Select_basicGraphicsMode(Select_GraphicsMode_DrawMethod_preMixin, glEnable(GL_CLIP_PLANE0) def func(): assy.draw(self.o) - self.o._call_func_that_draws_model( func) - self.Draw_after_highlighting(pickCheckOnly = True) + self.o._call_func_that_draws_model( func, drawing_phase = 'main') + self.o.call_Draw_after_highlighting(self, pickCheckOnly = True) glDisable(GL_CLIP_PLANE0) except: # Restore Model view matrix, select mode to render mode diff --git a/cad/src/exprs/testdraw.py b/cad/src/exprs/testdraw.py index 725b5a9b1..11acdac88 100755 --- a/cad/src/exprs/testdraw.py +++ b/cad/src/exprs/testdraw.py @@ -228,8 +228,7 @@ def Draw(mode, glpane, super): # called by testmode.Draw def Draw_after_highlighting(mode, pickCheckOnly, glpane, super): ## print "testdraw.Draw_after_highlighting(pickCheckOnly = %r)" % (pickCheckOnly,) # pickCheckOnly is True once when I click - super.Draw_after_highlighting(mode, pickCheckOnly) - return + return super.Draw_after_highlighting(mode, pickCheckOnly) # == diff --git a/cad/src/exprs/testmode.py b/cad/src/exprs/testmode.py index 092a7d3ff..d5f0bd5be 100755 --- a/cad/src/exprs/testmode.py +++ b/cad/src/exprs/testmode.py @@ -128,7 +128,7 @@ class testmode_GM(_superclass_GM): ## _superclass_GM.Draw_after_highlighting(self, pickCheckOnly) # let testdraw do this if if wants to import exprs.testdraw as testdraw try: - testdraw.Draw_after_highlighting(self, pickCheckOnly, self.o, _superclass_GM) + return testdraw.Draw_after_highlighting(self, pickCheckOnly, self.o, _superclass_GM) except: #e history message? print_compact_traceback("exception in testdraw.Draw_after_highlighting ignored: ") diff --git a/cad/src/foundation/Group.py b/cad/src/foundation/Group.py index 929108cfe..2dd19fcf8 100755 --- a/cad/src/foundation/Group.py +++ b/cad/src/foundation/Group.py @@ -1,11 +1,11 @@ -# Copyright 2004-2008 Nanorex, Inc. See LICENSE file for details. +# Copyright 2004-2009 Nanorex, Inc. See LICENSE file for details. """ Group.py -- Class (or superclass) for all non-leaf nodes in the internal model tree of Nodes. @author: Josh @version: $Id$ -@copyright: 2004-2008 Nanorex, Inc. See LICENSE file for details. +@copyright: 2004-2009 Nanorex, Inc. See LICENSE file for details. History: @@ -1328,7 +1328,7 @@ class Group(NodeWithAtomContents): self.draw_begin(glpane, dispdef) try: for ob in self.members: ## [:]: - ob.draw(glpane, dispdef) #see also self.draw_after_highlighting() + ob.draw(glpane, dispdef) #see also self.draw_after_highlighting # Check: Do they actually use dispdef? I know some of them # sometimes circumvent it (i.e. look directly at outermost one). # Todo: I might like to get them to honor it, and generalize @@ -1349,10 +1349,7 @@ class Group(NodeWithAtomContents): """ Things to draw after highlighting. See superclass method for more info. @see: self.draw() - @see: GraphicsMode.Draw_after_highlighting() @see: Node.draw_after_highlighting() which this overrides - @see: Plane.draw_after_highlighting() - @see: ESPImage.draw_after_highlighting() """ anythingDrawn = False diff --git a/cad/src/foundation/Utility.py b/cad/src/foundation/Utility.py index 84e949c65..282b3c482 100755 --- a/cad/src/foundation/Utility.py +++ b/cad/src/foundation/Utility.py @@ -2006,9 +2006,8 @@ class Node( StateMixin): drew something. @rtype: boolean - @see: GraphicsMode.Draw_after_highlighting() which returns this method - @see: Group.draw_after_highlighting() - @see: Plane.draw_after_highlighting() + @see: GraphicsMode.Draw_after_highlighting() which calls this method + [note difference in capitalization and arg signature] """ #Ninad 2008-06-20: This is a new API method that completely #replaces the implementation originally in method Utility._drawESPImage(). diff --git a/cad/src/graphics/widgets/GLPane_drawingset_methods.py b/cad/src/graphics/widgets/GLPane_drawingset_methods.py index e808f9925..ab022b92d 100644 --- a/cad/src/graphics/widgets/GLPane_drawingset_methods.py +++ b/cad/src/graphics/widgets/GLPane_drawingset_methods.py @@ -271,7 +271,10 @@ class GLPane_drawingset_methods(object): del self._csdl_collector_class # expose class default value return - def _call_func_that_draws_model(self, func, **kws): + def _call_func_that_draws_model(self, + func, + bare_primitives = None, + drawing_phase = None ): """ Call func() between calls of self.before_drawing_csdls(**kws) and self.after_drawing_csdls(). Return whatever func() returns @@ -281,9 +284,21 @@ class GLPane_drawingset_methods(object): func should usually be something which calls before/after_drawing_model inside it, e.g. one of the standard functions for drawing the entire model (e.g. part.draw or graphicsMode.Draw). + + @param bare_primitives: passed to before_drawing_csdls. + + @param drawing_phase: if provided, drawing_phase must be '?' + on entry; we'll set it as specified only during this call. + If not provided, we don't check it or change it + (typically, in that case, caller ought to do something + like we do itself). """ - self.before_drawing_csdls(**kws) # allowed kws: bare_primitives - # todo: just make them explicit keywords of our own. + # todo: convert some older callers to pass drawing_phase + # rather than implementing their own similar behavior. + if drawing_phase is not None: + assert self.drawing_phase == '?' + self.set_drawing_phase(drawing_phase) + self.before_drawing_csdls(bare_primitives = bare_primitives) error = True res = None try: @@ -293,9 +308,11 @@ class GLPane_drawingset_methods(object): # (note: this is sometimes what does the actual drawing # requested by func()) self.after_drawing_csdls( error) + if drawing_phase is not None: + self.set_drawing_phase('?') return res - def _call_func_that_draws_objects(self, func, part, **kws): + def _call_func_that_draws_objects(self, func, part, bare_primitives = None): """ Like _call_func_that_draws_model, but also wraps func with the part methods @@ -319,7 +336,7 @@ class GLPane_drawingset_methods(object): finally: part.after_drawing_model(error) return - self._call_func_that_draws_model( func2, **kws) + self._call_func_that_draws_model( func2, bare_primitives = bare_primitives) return _dset_caches = None # or map from cachename to persistent DrawingSetCache diff --git a/cad/src/graphics/widgets/GLPane_rendering_methods.py b/cad/src/graphics/widgets/GLPane_rendering_methods.py index 0ae4bf9de..260e38fc1 100644 --- a/cad/src/graphics/widgets/GLPane_rendering_methods.py +++ b/cad/src/graphics/widgets/GLPane_rendering_methods.py @@ -943,20 +943,44 @@ class GLPane_rendering_methods(GLPane_image_methods): # draw transparent things (e.g. Build Atoms water surface, # parts of Plane or ESPImage nodes) # [bruce 080919 bugfix: do this inside the stereo loop] + + self.call_Draw_after_highlighting(self.graphicsMode) + return + + def call_Draw_after_highlighting(self, graphicsMode, pickCheckOnly = False): + """ + Call graphicsMode.Draw_after_highlighting() in the correct way + (with appropriate drawing_phase), with exception protection, + and return whatever it returns. Pass pickCheckOnly. + + @note: calls of this should be inside a stereo loop, to be correct. + + @note: event processing or drawing code should use this method to call + graphicsMode.Draw_after_highlighting(), rather than + calling it directly. But implementations of Draw_after_highlighting + itself should call their superclass versions directly. + """ + # note: some existing calls of this are buggy since not in a stereo + # loop. They are bad in other ways too. See comment there for more info. + ### REVIEW: any need for _call_func_that_draws_model? I guess not now, - # but revise if we ever want to use csdls with objects drawn by this. - # [bruce 090219 comment] + # but revise if we ever want to use csdls with objects drawn by this, + # in any GraphicsMode. [bruce 090219 comment] + self.set_drawing_phase('main/Draw_after_highlighting') try: - self.set_drawing_phase('main/Draw_after_highlighting') - self.graphicsMode.Draw_after_highlighting() + res = self.graphicsMode.Draw_after_highlighting( pickCheckOnly) # e.g. draws water surface in Build mode [###REVIEW: ok inside stereo loop?], # or transparent parts of ESPImage or Plane (must be inside stereo loop). # Note: this is called in the main model coordinate system # (perhaps modified for current stereo image), # just like self.graphicsMode.Draw() [bruce 061208/080919 comment] - finally: - self.set_drawing_phase('?') - return + except: + res = None + msg = "bug in %r.Draw_after_highlighting ignored" % (graphicsMode,) + print_compact_traceback(msg + ": ") + pass + self.set_drawing_phase('?') + return res def validate_selobj_and_hicolor(self): #bruce 070919 split this out, slightly revised behavior, and simplified code """ diff --git a/cad/src/graphics/widgets/ThumbView.py b/cad/src/graphics/widgets/ThumbView.py index a54fa2b73..b6d061635 100755 --- a/cad/src/graphics/widgets/ThumbView.py +++ b/cad/src/graphics/widgets/ThumbView.py @@ -165,7 +165,7 @@ class ThumbView(GLPane_minimal): """ def func(): self.drawModel() - self._call_func_that_draws_model( func ) + self._call_func_that_draws_model( func, drawing_phase = 'main' ) return def drawSelected(self, obj): @@ -181,9 +181,9 @@ class ThumbView(GLPane_minimal): """ def func(): self.drawSelected(obj) - self._call_func_that_draws_model( func ) + self._call_func_that_draws_model( func, drawing_phase = 'selobj' ) ### REVIEW: should we use _call_func_that_draws_objects instead? - # This requires passing a part which contains obj, + # That requires passing a part which contains obj, # and I don't know for sure whether there is one, or how to find it # in all cases. Guess: this is desirable, but not yet essential. # [bruce 090219 comment] diff --git a/cad/src/model/Plane.py b/cad/src/model/Plane.py index 49bac1e64..3a6c307dd 100755 --- a/cad/src/model/Plane.py +++ b/cad/src/model/Plane.py @@ -1,15 +1,15 @@ -# Copyright 2007-2008 Nanorex, Inc. See LICENSE file for details. +# Copyright 2007-2009 Nanorex, Inc. See LICENSE file for details. """ @author: Ninad -@copyright: 2007-2008 Nanorex, Inc. See LICENSE file for details. -@version:$Id$ +@version: $Id$ +@copyright: 2007-2009 Nanorex, Inc. See LICENSE file for details. History: ninad 2007-05-21: Created. ninad 2007-06-03: Implemented Plane Property Manager piotr 2008-06-13: Added image reading from MMP file. -This file also used to contain DirectionArrow and ResizeHandle classes. +This file also used to contain DirectionArrow and ResizeHandle classes. Those were moved to their own module on Aug 20 and Oct 17, 2007 respt. """ @@ -350,12 +350,10 @@ class Plane(ReferenceGeometry): @type highlighted: bool @see: self.draw_after_highlighting() which draws things like filled - plane, grids etc after the main drawing code is finished. + plane, grids etc after the main drawing code is finished. """ - - #IMPORTANT NOTE: See also self.draw_after_highlighting() which draws - #some more things such as filled plane etc after the main drawing code - #is finished. It makes sure that plane get selected even when you click + #IMPORTANT NOTE: self.draw_after_highlighting makes sure that + #plane get selected even when you click #on the filled portion of it. -- Ninad 2008-06-20 glPushMatrix() @@ -404,7 +402,7 @@ class Plane(ReferenceGeometry): glPopMatrix() return - def draw_after_highlighting(self, glpane, dispdef, pickCheckOnly = False): + def draw_after_highlighting(self, glpane, dispdef, pickCheckOnly = False): """ Things to draw after highlighting. Subclasses can override this method. This API method ensures that, when user clicks on the filled @@ -421,7 +419,6 @@ class Plane(ReferenceGeometry): drew something. @rtype: boolean - @see: GraphicsMode.Draw_after_highlighting() @see: Node.draw_after_highlighting() which is overridden here """ #This implementation fixes bug 2900 |