[PythonCAD] New patches to PythonCAD . . . .

Art Haas ahaas at airmail.net
Fri Dec 16 18:04:49 CET 2005


On Thu, Dec 15, 2005 at 10:34:00AM -0500, Stuart Brorson wrote:
> Art --
> 
> > > *  Another poster on the pythoncad list suggested making "select" the
> > > default state for the program.  That is, when the program is in idle
> > > mode you can select objects, rather than having to do "edit -> select"
> > > first.  I agree with the poster that this would make the program
> > > easier to use.  If you agree I can send along some patches for this
> > > too.
> > 
> > Let's wait a bit on this. I like the current discussion about how other
> > programs behave, and it might end up that PythonCAD will offer both
> > 'select then act' behavior as well as 'action then select'. Right now
> > I'm leaning towards this as the program could then operate in whichever
> > mode you are most comfortable.
> 
> Allowing "act then select" along with "select then act" is easy:  In
> the init methods, just look to see if any items are selected.  If there
> are, then perform the action.  If not, then ask the user to select the
> objects upon which to act.  I can implement this as soon as I sync up
> again. 

I played with changing mirroring operations to work in both 'select then
act' and 'act then select', and the changes I needed are just the small
patch below. I've been changing the code in 'mirror.py' so it would take
advantage of newer methods in various classes than what were available
when the code was originally written, plus I cleaned it up a bit and
fixed the lost ability to mirror construction circles while at it. The
mirroring interface code is easy to adjust as it is very short. As the
patch below indicates, the changes below are very small to make this
operation have 'NOUN/VERB' and 'VERB/NOUN' abilities if I borrow the
AutoCAD terminology. 

Let me get some feedback on this, as offering both modes of operation
would be immensely helpful to people used to working in one mode or
another. Changing other editing code will probably not be as simple as
this, but I'd be happy to be proven wrong.

Art

Index: PythonCAD/Interface/Gtk/gtkmirror.py
===================================================================
--- PythonCAD/Interface/Gtk/gtkmirror.py	(revision 2102)
+++ PythonCAD/Interface/Gtk/gtkmirror.py	(working copy)
@@ -116,10 +116,13 @@
         if _active_layer in _objdict:
             for _obj, _pt in _objdict[_active_layer]:
                 if isinstance(_obj, (HCLine, VCLine, ACLine, CLine)):
-                    tool.setHandler("button_press", first_button_press_cb)
                     tool.setMirrorLine(_obj)
-                    gtkimage.setPrompt("Click on the objects to mirror.")
                     break
+    if gtkimage.hasSelection():
+        mirror_objects(gtkimage, tool, gtkimage.getSelectedObjects())
+    else:
+        tool.setHandler("button_press", first_button_press_cb)
+        gtkimage.setPrompt("Click on the objects to mirror.")
     return True
 
 def mirror_mode_init(tool):

-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list