From nelson at crynwr.com Fri Jun 2 22:33:42 2006 From: nelson at crynwr.com (Russ Nelson) Date: Fri, 2 Jun 2006 16:33:42 -0400 Subject: [PythonCAD] dimensions don't show up? Message-ID: <17536.41126.197118.911138@desk.crynwr.com> Hi. Why is the numeric dimension label not showing up? I start at a 'New' document, draw two points, and put a dimension between them, and I see no number. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Sat Jun 3 00:15:35 2006 From: ahaas at airmail.net (Art Haas) Date: Fri, 2 Jun 2006 17:15:35 -0500 Subject: [PythonCAD] dimensions don't show up? In-Reply-To: <17536.41126.197118.911138@desk.crynwr.com> References: <17536.41126.197118.911138@desk.crynwr.com> Message-ID: <20060602221535.GE28237@artsapartment.org> On Fri, Jun 02, 2006 at 04:33:42PM -0400, Russ Nelson wrote: > Hi. Why is the numeric dimension label not showing up? I start at a > 'New' document, draw two points, and put a dimension between them, and > I see no number. Hi. I just tried what you describe, and the dimension displayed a value. It could be that the text size is small and you aren't seeing it. The default text size is '1.0' units, so the size will probably need adjusting depending on what you've drawn. You can do that by going to the ... 'Modify' -> 'Change' -> 'Dimension' -> 'Primary Dim String' -> 'Size' ... menu, change the size, and then click on the dimension or draw a box around it. Does that work? Art Haas -- 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 From nelson at crynwr.com Sat Jun 3 07:47:33 2006 From: nelson at crynwr.com (Russ Nelson) Date: Sat, 3 Jun 2006 01:47:33 -0400 Subject: [PythonCAD] dimensions don't show up? In-Reply-To: <20060602221535.GE28237@artsapartment.org> References: <17536.41126.197118.911138@desk.crynwr.com> <20060602221535.GE28237@artsapartment.org> Message-ID: <17537.8821.699753.816373@desk.crynwr.com> Art Haas writes: > 'Modify' -> 'Change' -> 'Dimension' -> 'Primary Dim String' -> 'Size' Ahhhhh, yes, that fixes it. But I just discovered a few bugs. First one is that File->New is not undoable. Why shouldn't it be? That's a better paradigm than to ask "Are you sure?" Because nearly always the person will be SURE they're sure, and five seconds later change their confidence vanishes. Second bug is related to line drawing. Draw -> Basic -> Segment Click on two points to form a line segment. Click on a new point (just one, leaving a rubberbanding line). Click Edit -> Undo. Leaves a line drawn on the screen. Third bug (probably related to the second): Draw -> Basic -> Point Click twice to create two points. Draw -> Basic -> Segment Click on each of those two points to create a line segment between them. Click on a new point (just one, leaving a rubberbanding line). Edit -> Undo Rubberbanding stops erasing. When you do the second click, the screen is redrawn. First bug is pretty serious because it can result in loss of data. Second and Third bugs are merely drawing artifacts. Maybe don't need fixing. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Sat Jun 3 18:58:08 2006 From: ahaas at airmail.net (Art Haas) Date: Sat, 3 Jun 2006 11:58:08 -0500 Subject: [PythonCAD] dimensions don't show up? In-Reply-To: <17537.8821.699753.816373@desk.crynwr.com> References: <17536.41126.197118.911138@desk.crynwr.com> <20060602221535.GE28237@artsapartment.org> <17537.8821.699753.816373@desk.crynwr.com> Message-ID: <20060603165807.GA18694@artsapartment.org> On Sat, Jun 03, 2006 at 01:47:33AM -0400, Russ Nelson wrote: > Art Haas writes: > > 'Modify' -> 'Change' -> 'Dimension' -> 'Primary Dim String' -> 'Size' > > Ahhhhh, yes, that fixes it. Good. > But I just discovered a few bugs. First one is that File->New is not > undoable. Why shouldn't it be? That's a better paradigm than to ask > "Are you sure?" Because nearly always the person will be SURE they're > sure, and five seconds later change their confidence vanishes. Doing a 'File->New' from the menu opens up a new window, so it shouldn't do anything to the existsing drawing(s) you already have opened. When you did this the new window may have been placed over the existing window so you thought your drawing was erased. If this menu operation does _not_ open a new window then there is a bug requiring fixing. > Second bug is related to line drawing. > > Draw -> Basic -> Segment > Click on two points to form a line segment. > Click on a new point (just one, leaving a rubberbanding line). > Click Edit -> Undo. > Leaves a line drawn on the screen. I don't get the line left on the screen, but I do get a problem where the graphic context drawing mode is changed and any mouse movement in the drawing area results in line drawings. Hitting 'Esc' restores things correctly so that work can continue. > Third bug (probably related to the second): > > Draw -> Basic -> Point > Click twice to create two points. > Draw -> Basic -> Segment > Click on each of those two points to create a line segment between > them. > Click on a new point (just one, leaving a rubberbanding line). > Edit -> Undo > Rubberbanding stops erasing. > When you do the second click, the screen is redrawn. I see this behavior as well. The 'rubberbanding stops erasing' is the change in the graphics context problem similar to that in the other drawing bug report. I also see that the completed segment is removed when 'Undo' is clicked; this happens because the undo process is performed on the last completed action in the drawing, which was adding the segment. While drawing a segment the location of the first point is saved but no point is actually added to the drawing until the second segment point is either entered in the command entry box at the bottom of the screen or the mouse is clicked. Handling undo operations in the middle of creating some entity will require some thought as to how, or even if, it can be done. > First bug is pretty serious because it can result in loss of data. > Second and Third bugs are merely drawing artifacts. Maybe don't need > fixing. Thanks for the reports. I'll try and figure out how to fix the problems you found with the calling undo in the middle of segment creation. Please check that you do get a new window when calling 'File'->'New', as I think that is what happened. Art Haas -- 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 From ahaas at airmail.net Sat Jun 3 19:28:39 2006 From: ahaas at airmail.net (Art Haas) Date: Sat, 3 Jun 2006 12:28:39 -0500 Subject: [PythonCAD] dimensions don't show up? In-Reply-To: <20060603165807.GA18694@artsapartment.org> References: <17536.41126.197118.911138@desk.crynwr.com> <20060602221535.GE28237@artsapartment.org> <17537.8821.699753.816373@desk.crynwr.com> <20060603165807.GA18694@artsapartment.org> Message-ID: <20060603172839.GB18694@artsapartment.org> On Sat, Jun 03, 2006 at 11:58:08AM -0500, Art Haas wrote: > [ ... snip ... ]> > I see this behavior as well. The 'rubberbanding stops erasing' is the > change in the graphics context problem similar to that in the other > drawing bug report. I also see that the completed segment is removed > when 'Undo' is clicked; this happens because the undo process is > performed on the last completed action in the drawing, which was adding > the segment. While drawing a segment the location of the first point is > saved but no point is actually added to the drawing until the second > segment point is either entered in the command entry box at the bottom > of the screen or the mouse is clicked. > > Handling undo operations in the middle of creating some entity will > require some thought as to how, or even if, it can be done. Here's a quick thought - disable the 'Undo' and 'Redo' menus while in the middle of creating some entity. Comments? Art -- 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 From nelson at crynwr.com Sat Jun 3 20:17:08 2006 From: nelson at crynwr.com (Russ Nelson) Date: Sat, 3 Jun 2006 14:17:08 -0400 Subject: [PythonCAD] dimensions don't show up? In-Reply-To: <20060603165807.GA18694@artsapartment.org> References: <17536.41126.197118.911138@desk.crynwr.com> <20060602221535.GE28237@artsapartment.org> <17537.8821.699753.816373@desk.crynwr.com> <20060603165807.GA18694@artsapartment.org> Message-ID: <17537.53796.530639.384121@desk.crynwr.com> Art Haas writes: > Doing a 'File->New' from the menu opens up a new window, It does; I didn't notice that until after I sent the email. > Handling undo operations in the middle of creating some entity will > require some thought as to how, or even if, it can be done. Art Haas writes: > Here's a quick thought - disable the 'Undo' and 'Redo' menus while in > the middle of creating some entity. Comments? That might confuse people. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Sat Jun 3 22:58:33 2006 From: ahaas at airmail.net (Art Haas) Date: Sat, 3 Jun 2006 15:58:33 -0500 Subject: [PythonCAD] Start of Native Language Support in PythonCAD Message-ID: <20060603205833.GD18694@artsapartment.org> Hi. A goal for the next release is to make PythonCAD work using translations to a user's native language. Achieving this goal requires the use of the 'gettext' module in Python, then enclosing the translatable strings in the program within the special _() function. I've started making these changes today, and the first bits of code are at the repo. The 'gtkpycad.py' file imports the gettext module, and I've gone through the files under the PythonCAD/Interface/Gtk directory and changed all the setPrompt() calls as needed. There are still many more strings that must be enclosed within _(), so numerous more changes still need to be made. The various menus and window titles need changing still, for example. I'll be tackling them in the coming days. The current changes are available at the repo; get them with 'svn update'. People that are willing to start making the translations will need to read up on the 'gettext' module and then start sending me the '.mo' files. We'll tackle installation issues once these files start appearing. If anyone has worked on providing translations for other programs, I'd appreciate a message or two on avoid common pitfalls and how to make it easy for translators to contribute. Art Haas -- 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 From nelson at crynwr.com Mon Jun 5 17:55:03 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 5 Jun 2006 11:55:03 -0400 Subject: [PythonCAD] rotating objects? Message-ID: <17540.21463.271232.442683@desk.crynwr.com> Is there a way to rotate objects? Is there a way to set the dimensions of objects? I need to draw a bunch of fixed-size holes for switches, but they need to be at varying rotations. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Mon Jun 5 18:11:08 2006 From: ahaas at airmail.net (Art Haas) Date: Mon, 5 Jun 2006 11:11:08 -0500 Subject: [PythonCAD] rotating objects? In-Reply-To: <17540.21463.271232.442683@desk.crynwr.com> References: <17540.21463.271232.442683@desk.crynwr.com> Message-ID: <20060605161108.GD28229@artsapartment.org> On Mon, Jun 05, 2006 at 11:55:03AM -0400, Russ Nelson wrote: > Is there a way to rotate objects? > Is there a way to set the dimensions of objects? > > I need to draw a bunch of fixed-size holes for switches, but they need > to be at varying rotations. You'll probably have to use construction lines to do what you want for drawing rotated angles, and use construction circles to draw the holes. You go to 'Draw' -> 'Con. Lines' -> 'Angled' to draw the angled construction lines, and you can enter the angle you want after you define the point by either clicking in the drawing area or entering it in the entry box. For construction circles, go 'Draw' -> 'Con. Circs.' -> 'Center Pt.', define the center point by clicking or entering it, then enter the radius in the entry box. PythonCAD currently doesn't have a 'Rotate' function, but that sounds like a feature that would be good to implement. Art Haas -- 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 From nelson at crynwr.com Mon Jun 5 18:52:55 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 5 Jun 2006 12:52:55 -0400 Subject: [PythonCAD] rotating objects? In-Reply-To: <20060605161108.GD28229@artsapartment.org> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> Message-ID: <17540.24935.17674.603337@desk.crynwr.com> Art Haas writes: > On Mon, Jun 05, 2006 at 11:55:03AM -0400, Russ Nelson wrote: > > Is there a way to rotate objects? > > Is there a way to set the dimensions of objects? > > > > I need to draw a bunch of fixed-size holes for switches, but they need > > to be at varying rotations. > > You'll probably have to use construction lines to do what you want for > drawing rotated angles, and use construction circles to draw the holes. Sorry, I didn't explain myself well. The switches are rectangular, and need holes which are 11mm x 13.55mm. I need to be able to get those dimensions correct. Then I need to be able to place them at different angles and positions. How do I type in 11mm x 13.55mm? > You go to 'Draw' -> 'Con. Lines' -> 'Angled' to draw the angled > construction lines, What problem do construction lines solve for me? > PythonCAD currently doesn't have a 'Rotate' function, but that sounds > like a feature that would be good to implement. I'd just write a program which modifies the XML, but XML is a four-letter word. Have you considered using a file format with less useless gunk? Does PythonCAD have the concept of an object? If I save a file with objects selected, do they remain selectd when I reload the file? -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Mon Jun 5 19:42:18 2006 From: ahaas at airmail.net (Art Haas) Date: Mon, 5 Jun 2006 12:42:18 -0500 Subject: [PythonCAD] rotating objects? In-Reply-To: <17540.24935.17674.603337@desk.crynwr.com> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> <17540.24935.17674.603337@desk.crynwr.com> Message-ID: <20060605174218.GE28229@artsapartment.org> On Mon, Jun 05, 2006 at 12:52:55PM -0400, Russ Nelson wrote: > Art Haas writes: > > On Mon, Jun 05, 2006 at 11:55:03AM -0400, Russ Nelson wrote: > > > Is there a way to rotate objects? > > > Is there a way to set the dimensions of objects? > > > > > > I need to draw a bunch of fixed-size holes for switches, but they need > > > to be at varying rotations. > > > > You'll probably have to use construction lines to do what you want for > > drawing rotated angles, and use construction circles to draw the holes. > > Sorry, I didn't explain myself well. The switches are rectangular, > and need holes which are 11mm x 13.55mm. I need to be able to get > those dimensions correct. Then I need to be able to place them at > different angles and positions. How do I type in 11mm x 13.55mm? You'll need to use construction lines. For example, create a vertical construction line with 'Draw'->'Con. Lines'->'Vertical', then create a parallel line offset by 11mm with 'Draw'->'Con. Lines'->'Pararllel'. You then enter '11' in the entry box, click on the construction line, and then click either side of the construction line to determine where to place the parallel line. Use a similar procedure for creating horizontal lines 13.55mm across. You then go to 'Draw'->'Segment' and draw segments on the box defined by the construction lines. > > You go to 'Draw' -> 'Con. Lines' -> 'Angled' to draw the angled > > construction lines, > > What problem do construction lines solve for me? The use of construction lines is how PythonCAD is designed to create drawings. Way back when I took drafting classes we did drawings using construction lines, and my job out of college I used a CAD package called ME-10 which was also built around the idea of using construction lines to define precise distances. I also used AutoCAD many years ago, and it didn't offer construction lines or I was unaware of how to create them. This was around AutoCAD 9 or 10, and I always had difficulty in using AutoCAD. When I switched to ME-10 I felt it was much easier to use, so PythonCAD went the same way. It would be nice to offer some of the AutoCAD drawing features like drawing a segment of a given length at a given angle - I think this is specfied like 'length at angle' at the prompt. They probably have other means of adding entities that would be useful as well, but I haven't used AutoCAD in years now so I don't know what the latest version offers. > > PythonCAD currently doesn't have a 'Rotate' function, but that sounds > > like a feature that would be good to implement. > > I'd just write a program which modifies the XML, but XML is a > four-letter word. Have you considered using a file format with less > useless gunk? No, I haven't. Python offered an XML parsing module making the format easy to deal with, and when I started this project it fit the bill. I've been happy so far with the choice, but if something better comes along I would consider changing. > Does PythonCAD have the concept of an object? If I save a file with > objects selected, do they remain selectd when I reload the file? No, selected entities are not stored in the file. Art Haas -- 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 From ahaas at airmail.net Mon Jun 5 23:26:59 2006 From: ahaas at airmail.net (Art Haas) Date: Mon, 5 Jun 2006 16:26:59 -0500 Subject: [PythonCAD] Start of Native Language Support in PythonCAD In-Reply-To: <20060603205833.GD18694@artsapartment.org> References: <20060603205833.GD18694@artsapartment.org> Message-ID: <20060605212659.GF28229@artsapartment.org> On Sat, Jun 03, 2006 at 03:58:33PM -0500, Art Haas wrote: > Hi. > > A goal for the next release is to make PythonCAD work using translations > to a user's native language. Achieving this goal requires the use of > the 'gettext' module in Python, then enclosing the translatable strings > in the program within the special _() function. I've started making > these changes today, and the first bits of code are at the repo. The > 'gtkpycad.py' file imports the gettext module, and I've gone through > the files under the PythonCAD/Interface/Gtk directory and changed all > the setPrompt() calls as needed. There are still many more strings that > must be enclosed within _(), so numerous more changes still need to > be made. The various menus and window titles need changing still, for > example. I'll be tackling them in the coming days. The current changes > are available at the repo; get them with 'svn update'. Following up on the post above, I've added the magic _() function in many more calls in the interface code, so the menu items, dialog boxes, and other GTK interface pieces can be translated as well. I've not tried to adjust any of the message raised during exceptions, and I suspect that eventually they'll be translated as well, but it would be nice to get the first efforts for translation to concentrate on the normal interface components. Art Haas -- 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 From nelson at crynwr.com Tue Jun 6 00:23:55 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 5 Jun 2006 18:23:55 -0400 Subject: [PythonCAD] rotating objects? In-Reply-To: <20060605174218.GE28229@artsapartment.org> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> <17540.24935.17674.603337@desk.crynwr.com> <20060605174218.GE28229@artsapartment.org> Message-ID: <17540.44795.50226.394523@desk.crynwr.com> Art Haas writes: > to place the parallel line. Use a similar procedure for creating > horizontal lines 13.55mm across. You then go to 'Draw'->'Segment' and > draw segments on the box defined by the construction lines. Hrm. Okay, I can make four angled construction lines, however there are only three intersections. How do I define a point to snap to at the fourth intersection? Slowly .... I'm figuring out how to use this program. It begs for a tutorial. If I have something selected, and then choose Modify/Delete, shouldn't that delete the selected things? Shouldn't the scroll wheel zoom in and out on the thing you're pointing at? If I select four points and the four segments connecting them, and then Edit/Copy, shouldn't Edit/Paste insert four points and segments? I'm only getting one point inserted. > The use of construction lines is how PythonCAD is designed to create > drawings. Indeed! They're practically a requirement. > No, I haven't. Python offered an XML parsing module making the format > easy to deal with, and when I started this project it fit the bill. Maybe better for me to add the features I want within PythonCAD .... like rotate. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 03:34:05 2006 From: nelson at crynwr.com (Russ Nelson) Date: 6 Jun 2006 01:34:05 -0000 Subject: [PythonCAD] a simplifying patch? Message-ID: <20060606013405.6828.qmail@desk.crynwr.com> Is it appropriate to send patches to the list? This one's fairly short, so I'll take the chance. This code is much simpler to read and understand. diff -ur orig/PythonCAD/Interface/Gtk/gtkmenus.py ./PythonCAD/Interface/Gtk/gtkmenus.py --- orig/PythonCAD/Interface/Gtk/gtkmenus.py 2006-05-11 16:50:23.000000000 -0400 +++ ./PythonCAD/Interface/Gtk/gtkmenus.py 2006-06-05 21:05:48.000000000 -0400 @@ -350,66 +350,34 @@ #------------------------------------------------------------ def _select_all_cb(menuitem, gtkimage): + _selects = [('SelectAllPoints', 'point'), + ('SelectAllSegments','segment'), + ('SelectAllCircles','circle'), + ('SelectAllArcs','arc'), + ('SelectAllLeaders','leader'), + ('SelectAllPolylines','polyline'), + ('SelectAllChamfers','chamfer'), + ('SelectAllFillets','fillet'), + ('SelectAllHCLines','hcline'), + ('SelectAllVCLines','vcline'), + ('SelectAllACLines','acline'), + ('SelectAllCLines','cline'), + ('SelectAllCCircles','ccircle'), + ('SelectAllTextBlocks','textblock'), + ('SelectAllLDims','linear_dimension'), + ('SelectAllHDims','horizontal_dimension'), + ('SelectAllVDims','vertical_dimension'), + ('SelectAllRDims','radial_dimension'), + ('SelectAllADims','angular_dimension'), + ] + _group = gtkimage.getGroup('Edit') if _group is not None: _layer = gtkimage.getActiveLayer() - _act = _group.get_action('SelectAllPoints') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('point') > 0) - _act = _group.get_action('SelectAllSegments') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('segment') > 0) - _act = _group.get_action('SelectAllCircles') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('circle') > 0) - _act = _group.get_action('SelectAllArcs') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('arc') > 0) - _act = _group.get_action('SelectAllLeaders') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('leader') > 0) - _act = _group.get_action('SelectAllPolylines') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('polyline') > 0) - _act = _group.get_action('SelectAllChamfers') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('chamfer') > 0) - _act = _group.get_action('SelectAllFillets') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('fillet') > 0) - _act = _group.get_action('SelectAllHCLines') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('hcline') > 0) - _act = _group.get_action('SelectAllVCLines') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('vcline') > 0) - _act = _group.get_action('SelectAllACLines') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('acline') > 0) - _act = _group.get_action('SelectAllCLines') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('cline') > 0) - _act = _group.get_action('SelectAllCCircles') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('ccircle') > 0) - _act = _group.get_action('SelectAllTextBlocks') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('textblock') > 0) - _act = _group.get_action('SelectAllLDims') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('linear_dimension') > 0) - _act = _group.get_action('SelectAllHDims') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('horizontal_dimension') > 0) - _act = _group.get_action('SelectAllVDims') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('vertical_dimension') > 0) - _act = _group.get_action('SelectAllRDims') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('radial_dimension') > 0) - _act = _group.get_action('SelectAllADims') - if _act is not None: - _act.set_property('sensitive', _layer.getEntityCount('angular_dimension') > 0) + for action, entity in _selects: + _act = _group.get_action(action) + if _act is not None: + _act.set_property('sensitive', _layer.getEntityCount(entity) > 0) #------------------------------------------------------------ def edit_undo_cb(menuitem, gtkimage): -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 04:11:20 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 5 Jun 2006 22:11:20 -0400 Subject: [PythonCAD] in the interest of not multiplying entities Message-ID: <17540.58440.705301.463097@desk.crynwr.com> I'm noticing that code in gtkmenus.py which looks like this: #------------------------------------------------------------ def select_all_circles_cb(menuitem, gtkimage): _active_layer = gtkimage.getActiveLayer() for _circle in _active_layer.getLayerEntities("circle"): gtkimage.selectObject(_circle) and is later used like this: _act.connect('activate', select_all_circles_cb, gtkimage) could actually look like this: #------------------------------------------------------------ def select_all_entities_cb(menuitem, gn): gtkimage, name = gn _active_layer = gtkimage.getActiveLayer() for _point in _active_layer.getLayerEntities(name): gtkimage.selectObject(_point) and be called like this: _act.connect('activate', select_all_entities_cb, (gtkimage,"circle")) Of course, that changce, once made, begs to be integrated with the patch I sent earlier, so that there's one structure that looks like this: select_all_menu = [ ('SelectAllPoints', 'point', '_Points'), ('SelectAllSegments','segment', '_Segments'), ('SelectAllCircles','circle', '_Circles'), ('SelectAllArcs','arc', '_Arcs'), ('SelectAllLeaders','leader', '_Leaders'), ('SelectAllPolylines','polyline', '_Polylines'), ('SelectAllChamfers','chamfer', '_Cha_mfers'), ('SelectAllFillets','fillet', '_Fillets'), (None,None,None), ('SelectAllHCLines','hcline', '_HCLines'), .... ] and a loop like this: for gtkimage, objname, menuitem in select_all_menu: if gtkimage is None: _item = gtk.SeparatorMenuItem() _item.show() _menu.append(_item) else: _act = gtk.Action(gtkimage, menuitem, None, None) _act.connect('activate', select_all_thingies_cb, (gtkimage,objname)) _act.set_accel_group(_accel) actiongroup.add_action(_act) _menu.append(_act.create_menu_item()) Happy to bang out a patch if it's to your liking. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 08:10:53 2006 From: nelson at crynwr.com (Russ Nelson) Date: 6 Jun 2006 06:10:53 -0000 Subject: [PythonCAD] _width, _height? Message-ID: <20060606061053.13292.qmail@desk.crynwr.com> In Interface/Gtk/gtkedit.py/select_motion_notify, _width and _height are set but not used. Other than that, it's the same code as in gtkmirror.py/select_motion_notify, which is the same code as in gtkmodify.py/select_motion_notify. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 08:17:10 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 6 Jun 2006 02:17:10 -0400 Subject: [PythonCAD] _got_line? Message-ID: <17541.7654.758801.841281@desk.crynwr.com> In Interface/Gtk/gtkmirror.py/get_mirror_line_cb, a variable called "_got_line" is being set, but is never being used. Should that line be removed? -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Tue Jun 6 16:19:45 2006 From: ahaas at airmail.net (Art Haas) Date: Tue, 6 Jun 2006 09:19:45 -0500 Subject: [PythonCAD] rotating objects? In-Reply-To: <17540.44795.50226.394523@desk.crynwr.com> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> <17540.24935.17674.603337@desk.crynwr.com> <20060605174218.GE28229@artsapartment.org> <17540.44795.50226.394523@desk.crynwr.com> Message-ID: <20060606141945.GB3424@artsapartment.org> On Mon, Jun 05, 2006 at 06:23:55PM -0400, Russ Nelson wrote: > Art Haas writes: > > to place the parallel line. Use a similar procedure for creating > > horizontal lines 13.55mm across. You then go to 'Draw'->'Segment' and > > draw segments on the box defined by the construction lines. > > Hrm. Okay, I can make four angled construction lines, however there > are only three intersections. How do I define a point to snap to at > the fourth intersection? > > Slowly .... I'm figuring out how to use this program. It begs for a > tutorial. I agree 110%. The project needs documenting as well, more than the various doc strings I've placed within the code. This is an area that I could use help on, as I've not been good at writing the type of documentation users and/or programmers need. > If I have something selected, and then choose Modify/Delete, shouldn't > that delete the selected things? Yes it should, and I've committed the following changes to the program so that any selected entities are deleted when you 'Modify'->'Delete'. If you're pulling from the public repo then an 'svn update' will get you the contents of the patch below. > Shouldn't the scroll wheel zoom in and out on the thing you're > pointing at? Ideally yes, but I haven't written the code to tie the zoom operations into a scroll event. I suspect this is not too hard to do, but it may be more complicated. I also want to add code to make the image view change when you press the arrow keys, and possibly the PageUp and PageDown keys as well. > If I select four points and the four segments connecting them, and > then Edit/Copy, shouldn't Edit/Paste insert four points and segments? > I'm only getting one point inserted. The copy/paste routines are old, and need reworking. A problem I've always had was in handling the Paste operation is in determining just where to put any copied entities. If I draw a segment, select it, then copy it, when I try to paste it do I put an endpoint or the middle of the segment at the location where the mouse was clicked? There needs to be some sort of reference point used in these operations. > > The use of construction lines is how PythonCAD is designed to create > > drawings. > > Indeed! They're practically a requirement. > > > No, I haven't. Python offered an XML parsing module making the format > > easy to deal with, and when I started this project it fit the bill. > > Maybe better for me to add the features I want within PythonCAD > .... like rotate. Adding a Rotate operation would be great. Art Haas Index: PythonCAD/Interface/Gtk/gtkmodify.py =================================================================== --- PythonCAD/Interface/Gtk/gtkmodify.py (revision 2363) +++ PythonCAD/Interface/Gtk/gtkmodify.py (revision 2364) @@ -361,9 +361,19 @@ _gc.set_function(gtk.gdk.INVERT) return True -def delete_mode_init(tool): +def delete_mode_init(gtkimage, tool): tool.setHandler("button_press", delete_button_press_cb) tool.setHandler("initialize", delete_mode_init) + if gtkimage.hasSelection(): + gtkimage.startAction() + try: + for _obj in gtkimage.getSelectedObjects(): + _layer = _obj.getParent() + if _layer is not None: + _layer.delObject(_obj) + finally: + gtkimage.endAction() + gtkimage.redraw() # # stretch operations Index: PythonCAD/Interface/Gtk/gtkmenus.py =================================================================== --- PythonCAD/Interface/Gtk/gtkmenus.py (revision 2363) +++ PythonCAD/Interface/Gtk/gtkmenus.py (revision 2364) @@ -816,7 +816,7 @@ _tool = tools.DeleteTool() gtkimage.setTool(_tool) gtkimage.setPrompt(_('Click on the items you want to delete.')) - gtkmodify.delete_mode_init(_tool) + gtkmodify.delete_mode_init(gtkimage, _tool) def change_style_cb(menuitem, gtkimage): _st = gtkmodify.change_style_dialog(gtkimage) -- 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 From ahaas at airmail.net Tue Jun 6 16:30:43 2006 From: ahaas at airmail.net (Art Haas) Date: Tue, 6 Jun 2006 09:30:43 -0500 Subject: [PythonCAD] _got_line? In-Reply-To: <17541.7654.758801.841281@desk.crynwr.com> References: <17541.7654.758801.841281@desk.crynwr.com> Message-ID: <20060606143043.GC3424@artsapartment.org> On Tue, Jun 06, 2006 at 02:17:10AM -0400, Russ Nelson wrote: > In Interface/Gtk/gtkmirror.py/get_mirror_line_cb, a variable called > "_got_line" is being set, but is never being used. Should that line > be removed? No, but it needs to be moved and set if a construction is selected. I've commited the following change to fix this problem you found. For those using subversion an 'svn update' will get you this fix. Thanks! Art Haas Index: PythonCAD/Interface/Gtk/gtkmirror.py =================================================================== --- PythonCAD/Interface/Gtk/gtkmirror.py (revision 2364) +++ PythonCAD/Interface/Gtk/gtkmirror.py (revision 2365) @@ -109,19 +109,21 @@ _x, _y = gtkimage.getCurrentPoint() _tol = gtkimage.getTolerance() _objdict = gtkimage.mapPoint(_x, _y, _tol) + _got_line = False if len(_objdict): _active_layer = gtkimage.getActiveLayer() - _got_line = False if _active_layer in _objdict: for _obj, _pt in _objdict[_active_layer]: if isinstance(_obj, (HCLine, VCLine, ACLine, CLine)): tool.setMirrorLine(_obj) + _got_line = True 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.')) + if _got_line: + 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 From ahaas at airmail.net Tue Jun 6 16:38:22 2006 From: ahaas at airmail.net (Art Haas) Date: Tue, 6 Jun 2006 09:38:22 -0500 Subject: [PythonCAD] _width, _height? In-Reply-To: <20060606061053.13292.qmail@desk.crynwr.com> References: <20060606061053.13292.qmail@desk.crynwr.com> Message-ID: <20060606143822.GD3424@artsapartment.org> On Tue, Jun 06, 2006 at 06:10:53AM -0000, Russ Nelson wrote: > In Interface/Gtk/gtkedit.py/select_motion_notify, _width and _height > are set but not used. > > Other than that, it's the same code as in gtkmirror.py/select_motion_notify, > which is the same code as in gtkmodify.py/select_motion_notify. > The variables are gone now. Thanks. Art Haas -- 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 From nelson at crynwr.com Tue Jun 6 18:05:26 2006 From: nelson at crynwr.com (Russ Nelson) Date: 6 Jun 2006 16:05:26 -0000 Subject: [PythonCAD] bug in mirror selection Message-ID: <20060606160526.31528.qmail@desk.crynwr.com> o Modify/Mirror o Click on a construction line o It says "Click on the objects to mirror" o Click on an object Mirrored. o It says "Click on the mirroring construction line" Perhaps it should say "Click on the object to mirror"? Maybe, since it allows a rubberband select, it should say "Click on the object to mirror or select a box"? -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 18:17:09 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 6 Jun 2006 12:17:09 -0400 Subject: [PythonCAD] Tutorial 1 Message-ID: <17541.43653.594086.154124@desk.crynwr.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythoncad/attachments/20060606/0056e4ad/attachment.html From ahaas at airmail.net Tue Jun 6 19:25:00 2006 From: ahaas at airmail.net (Art Haas) Date: Tue, 6 Jun 2006 12:25:00 -0500 Subject: [PythonCAD] bug in mirror selection In-Reply-To: <20060606160526.31528.qmail@desk.crynwr.com> References: <20060606160526.31528.qmail@desk.crynwr.com> Message-ID: <20060606172500.GE3424@artsapartment.org> On Tue, Jun 06, 2006 at 04:05:26PM -0000, Russ Nelson wrote: > o Modify/Mirror > o Click on a construction line > o It says "Click on the objects to mirror" > o Click on an object Mirrored. > o It says "Click on the mirroring construction line" > > Perhaps it should say "Click on the object to mirror"? > Maybe, since it allows a rubberband select, it should say > "Click on the object to mirror or select a box"? I've tweaked this code slightly after reading your mail. I changed the prompt after the mirror line is selected, and if the first mouse click doesn't land on an object then the prompt changes again to indicate the selection is done via boxing the objects. Also, if the box selection doesn't find any objects the mirroring tool is reset to the state just after the mirroring line is selected. These changes are at the public repo - just 'svn update' and you'll have them. Art Haas -- 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 From nelson at crynwr.com Tue Jun 6 22:11:33 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 6 Jun 2006 16:11:33 -0400 Subject: [PythonCAD] bug in mirror selection In-Reply-To: <20060606172500.GE3424@artsapartment.org> References: <20060606160526.31528.qmail@desk.crynwr.com> <20060606172500.GE3424@artsapartment.org> Message-ID: <17541.57717.990454.66878@desk.crynwr.com> Art Haas writes: > I've tweaked this code slightly after reading your mail. I changed > the prompt after the mirror line is selected, and if the first mouse > click doesn't land on an object then the prompt changes again to > indicate the selection is done via boxing the objects. Hrm. I've gotten the impression that a point is considered selected if you click anywhere within its yellow box. I did that, and yet it then asked me to "Enclose objects to mirror with a box". -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 6 23:17:03 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 6 Jun 2006 17:17:03 -0400 Subject: [PythonCAD] Postscript as final output? Message-ID: <17541.61647.351837.492267@desk.crynwr.com> I'm trying (as I said before) to design a set of holes for switches, and I want to use the printed output as a template for cutting holes. I'll print the output on sticky-back paper, stick it to the panel, and cut right from the printout. Not clear to me what "size" paper I should select to get a 11mm x 13.55mm box printed so it's actually that size on the paper. In Postscript terms that would be 72 points / inch * 1 inch / 25.4mm. Any hints? -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Wed Jun 7 17:31:53 2006 From: nelson at crynwr.com (Russ Nelson) Date: Wed, 7 Jun 2006 11:31:53 -0400 Subject: [PythonCAD] components? Message-ID: <17542.61801.932332.846295@desk.crynwr.com> Is there a way to create components in PythonCAD? There are two ways components might work: held together as a set of objects, or inserted into a drawing as unaggregated objects. The latter is already implementable using cut and paste. Load up a component's drawing in a File/New window, select the entire thing, Edit/Copy, go back to the first drawing, and paste. The trouble with smashing components is that if you need to change the component, you need to go back and change it everywhere it was used. The trouble with keeping component objects together is that you need to treat it like a single object, with its own transformation matrix (translation / mirroring / rotation). Ugh. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Wed Jun 7 18:19:32 2006 From: ahaas at airmail.net (Art Haas) Date: Wed, 7 Jun 2006 11:19:32 -0500 Subject: [PythonCAD] components? In-Reply-To: <17542.61801.932332.846295@desk.crynwr.com> References: <17542.61801.932332.846295@desk.crynwr.com> Message-ID: <20060607161932.GI3424@artsapartment.org> On Wed, Jun 07, 2006 at 11:31:53AM -0400, Russ Nelson wrote: > Is there a way to create components in PythonCAD? There are two ways > components might work: held together as a set of objects, or inserted > into a drawing as unaggregated objects. The latter is already > implementable using cut and paste. Load up a component's drawing in a > File/New window, select the entire thing, Edit/Copy, go back to the > first drawing, and paste. > > The trouble with smashing components is that if you need to change the > component, you need to go back and change it everywhere it was used. > > The trouble with keeping component objects together is that you need > to treat it like a single object, with its own transformation matrix > (translation / mirroring / rotation). Ugh. Currently there is nothing in PythonCAD for making components. The closest entity I can envision is the long-stalled Hatch entity, as it will be defined as a list of boundary entities defining the exterior and any possible interior edges. I haven't worked on implementing hatching in a while as my last attempts ended without any measurable progress. Grrrr ... Art Haas -- 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 From nelson at crynwr.com Thu Jun 8 22:23:46 2006 From: nelson at crynwr.com (Russ Nelson) Date: Thu, 8 Jun 2006 16:23:46 -0400 Subject: [PythonCAD] state table? Message-ID: <17544.34642.429659.254222@desk.crynwr.com> I've been looking at the way various components get specified, and there seems to be a fair amount of overlap. And yet the callback system of gtk doesn't lend itself well to subroutines. I wonder if it might be a great simplification to have a state table? Instead of changing the callback handlers, they would stay the same, and do different things depending on the current state. So, for example, an angled construction line takes: State Pointer Entry Action Next State 21 a click a pair of points Save Point 22 22 rubberband an angle Save Angle 23 23 Add ACLine at Point, Angle This needs more fleshing out with details, but I think you can see that it would eliminate a lot of code, and allow new commands to be added without needing to reinvent rubber-banding every time. Should I continue the design, or is this a bad idea? I don't know how this design change would affect the Cocoa interface, if at all. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Thu Jun 8 23:26:23 2006 From: nelson at crynwr.com (Russ Nelson) Date: Thu, 8 Jun 2006 17:26:23 -0400 Subject: [PythonCAD] state table details Message-ID: <17544.38399.808597.353714@desk.crynwr.com> I'm trying to avoid working on what I *should* be working on, so I banged out some details of the proposed state table. The callbacks look at the current state's 'input' value to see what they should do. The motion notify will rubberband from the previously saved point (and Radius and Angle) if requested. The click handler will record the point for the action. The SavePoint action pushes the point onto an array of points. The Add* action takes the various saved values and Adds the approporiate object. All of this, of course, is so that I don't have to reinvent the "get a point" and "get an angle" code for Rotate. statetable = { # Draw/Basic/Point 21:{ 'input':'point', 'action':AddPoint, 'next': 21 }, # Draw/Basic/Point 31:{ 'input':'point', 'action':SavePoint, 'next': 32}, 32:{ 'input':'rubberline', 'action':AddSegment, 'next': 31}, # Draw/Basic/Rectangle 41:{ 'input':'point', 'action':SavePoint, 'next':42}, 42:{ 'input':'rubberrect', 'action':AddRectangle, 'next': 41}, # Draw/Basic/Circle 51:{ 'input':'point', 'action':SavePoint, 'next':52}, 52:{ 'input':'rubbercircle', 'action':AddCircle, 'next': 51}, # Draw/Basic/Circle2Pt 61:{ 'input':'point', 'action':SavePoint, 'next':62}, 62:{ 'input':'rubberdish, 'action':AddCircle2P, 'next': 61}, # Draw/Basic/Arc 71:{ 'input':'point', 'action':SavePoint, 'next':72}, 72:{ 'input':'rubbercircle', 'action':SaveRadius, 'next':73, 'nextenter':74}, 73:{ 'input':'rubberarc', 'action':AddArc, 'next':71}, 74:{ 'input':'angle', 'action':SaveAngle, 'next':75}, 75:{ 'input':'angle', 'action':AddArc, 'next':71}, # # Draw/Leader 151:{ 'input':'point', 'action':SavePoint, 'next': 152}, 152:{ 'input':'rubberline', 'action':SavePoint, 'next': 153}, 153:{ 'input':'rubberline', 'action':AddLeader, 'next': 151}, # Draw/Polyline 161:{ 'input':'point', 'action':SavePoint, 'next': 162}, 162:{ 'input':'rubberline', 'action':SavePoint, 'next': 162,'nextshift':163}, 163:{ 'input':'rubberline', 'action':AddLeader, 'next': 161}, # ..... } -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Fri Jun 9 00:27:12 2006 From: nelson at crynwr.com (Russ Nelson) Date: Thu, 8 Jun 2006 18:27:12 -0400 Subject: [PythonCAD] intersecting construction lines? Message-ID: <17544.42048.159038.118145@desk.crynwr.com> Hi. How do I put a point at the intersection of two construction lines? I mean, apart from zooming WAY in, and eyeballing the intersection? Sorry to ask a dumb question, the answer for which I could probably get by grovelling through the source code. Sometimes ya wanna hack, and other times you just want to get work done. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Fri Jun 9 01:08:43 2006 From: ahaas at airmail.net (Art Haas) Date: Thu, 8 Jun 2006 18:08:43 -0500 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <17544.42048.159038.118145@desk.crynwr.com> References: <17544.42048.159038.118145@desk.crynwr.com> Message-ID: <20060608230843.GA25457@artsapartment.org> On Thu, Jun 08, 2006 at 06:27:12PM -0400, Russ Nelson wrote: > Hi. How do I put a point at the intersection of two construction > lines? I mean, apart from zooming WAY in, and eyeballing the > intersection? You shouldn't have to zoom in, just click on the intersection. The program will try to find an intersection near where you click if one exists. If you click too far away (about 5 pixels or so) then the program is likely to either choose a point on one of the construction lines if it is near enough or a coordinate not on an entity if not. It's a bug if you click on the intersection (within the tolerance) but you don't get the intersection coordinates as your point coordinate. > Sorry to ask a dumb question, the answer for which I could probably > get by grovelling through the source code. Sometimes ya wanna hack, > and other times you just want to get work done. Not a dumb question at all. Art Haas -- 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 From nelson at crynwr.com Fri Jun 9 02:26:07 2006 From: nelson at crynwr.com (Russ Nelson) Date: Thu, 8 Jun 2006 20:26:07 -0400 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <20060608230843.GA25457@artsapartment.org> References: <17544.42048.159038.118145@desk.crynwr.com> <20060608230843.GA25457@artsapartment.org> Message-ID: <17544.49183.543064.304725@desk.crynwr.com> Art Haas writes: > You shouldn't have to zoom in, just click on the intersection. The > program will try to find an intersection near where you click if one > exists. If you click too far away (about 5 pixels or so) then the > program is likely to either choose a point on one of the construction > lines if it is near enough or a coordinate not on an entity if not. > > It's a bug if you click on the intersection (within the tolerance) > but you don't get the intersection coordinates as your point coordinate. Maybe I'm doing it the wrong way, but I'm not seeing this behavior. If I set two points on the diagonal, then drop two horizontal and two vertical construction lines on each of them, I can't set a point on either intersection. Or, rather, if I do, it's through dumb luck. The program definitely snaps to the closest construction line within the tolerance, but NOT to the intersection. This happens with both DS1-R32 and revision 2385. I tried drawing segments along both construction lines, and I get the same effect. The intersection of two lines doesn't get a snap. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Fri Jun 9 02:56:13 2006 From: ahaas at airmail.net (Art Haas) Date: Thu, 8 Jun 2006 19:56:13 -0500 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <17544.49183.543064.304725@desk.crynwr.com> References: <17544.42048.159038.118145@desk.crynwr.com> <20060608230843.GA25457@artsapartment.org> <17544.49183.543064.304725@desk.crynwr.com> Message-ID: <20060609005613.GB25457@artsapartment.org> On Thu, Jun 08, 2006 at 08:26:07PM -0400, Russ Nelson wrote: > Art Haas writes: > > You shouldn't have to zoom in, just click on the intersection. The > > program will try to find an intersection near where you click if one > > exists. If you click too far away (about 5 pixels or so) then the > > program is likely to either choose a point on one of the construction > > lines if it is near enough or a coordinate not on an entity if not. > > > > It's a bug if you click on the intersection (within the tolerance) > > but you don't get the intersection coordinates as your point coordinate. > > Maybe I'm doing it the wrong way, but I'm not seeing this behavior. > If I set two points on the diagonal, then drop two horizontal and two > vertical construction lines on each of them, I can't set a point on > either intersection. Or, rather, if I do, it's through dumb luck. > The program definitely snaps to the closest construction line within > the tolerance, but NOT to the intersection. > > This happens with both DS1-R32 and revision 2385. > > I tried drawing segments along both construction lines, and I get the > same effect. The intersection of two lines doesn't get a snap. I'm not sure what you mean when you write 'set two points on the diagonal'. Regardless, I'll do some drawing and see if I can duplicate the problem. Art Haas -- 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 From nelson at crynwr.com Fri Jun 9 04:52:39 2006 From: nelson at crynwr.com (Russ Nelson) Date: Thu, 8 Jun 2006 22:52:39 -0400 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <20060609005613.GB25457@artsapartment.org> References: <17544.42048.159038.118145@desk.crynwr.com> <20060608230843.GA25457@artsapartment.org> <17544.49183.543064.304725@desk.crynwr.com> <20060609005613.GB25457@artsapartment.org> Message-ID: <17544.57975.587779.342281@desk.crynwr.com> Art Haas writes: > I'm not sure what you mean when you write 'set two points on the > diagonal'. Regardless, I'll do some drawing and see if I can duplicate > the problem. The O's are points, the crosses are intersections without a point, and the lines are either construction lines or segments; same effect. _____ /A point drawn near this | | / \intersection doesn't snap. | |/ ------O--------------+----- | | | | | | | | | | ------+--------------O----- | | | | -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Sat Jun 10 20:02:00 2006 From: nelson at crynwr.com (Russ Nelson) Date: Sat, 10 Jun 2006 14:02:00 -0400 Subject: [PythonCAD] rotating objects? In-Reply-To: <20060606141945.GB3424@artsapartment.org> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> <17540.24935.17674.603337@desk.crynwr.com> <20060605174218.GE28229@artsapartment.org> <17540.44795.50226.394523@desk.crynwr.com> <20060606141945.GB3424@artsapartment.org> Message-ID: <17547.2328.235717.961025@desk.crynwr.com> Art Haas writes: > Adding a Rotate operation would be great. Still working on that. I'm noticing that there isn't much error reporting. For example, if you Modify/Mirror something, and then don't click on a construction line, it doesn't tell you that. Is that a feature or a bug? -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Sat Jun 10 20:11:24 2006 From: ahaas at airmail.net (Art Haas) Date: Sat, 10 Jun 2006 13:11:24 -0500 Subject: [PythonCAD] rotating objects? In-Reply-To: <17547.2328.235717.961025@desk.crynwr.com> References: <17540.21463.271232.442683@desk.crynwr.com> <20060605161108.GD28229@artsapartment.org> <17540.24935.17674.603337@desk.crynwr.com> <20060605174218.GE28229@artsapartment.org> <17540.44795.50226.394523@desk.crynwr.com> <20060606141945.GB3424@artsapartment.org> <17547.2328.235717.961025@desk.crynwr.com> Message-ID: <20060610181124.GE25457@artsapartment.org> On Sat, Jun 10, 2006 at 02:02:00PM -0400, Russ Nelson wrote: > Art Haas writes: > > Adding a Rotate operation would be great. > > Still working on that. I'm noticing that there isn't much error > reporting. For example, if you Modify/Mirror something, and then > don't click on a construction line, it doesn't tell you that. Is that > a feature or a bug? The prompt doesn't change to indicate you can select the entities to mirror, but your point about not notifying the user that invalid entity was chosen is true. I don't think this is a bug, but it is hard to call it a feature also. Art Haas -- 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 From ahaas at airmail.net Sun Jun 11 02:56:30 2006 From: ahaas at airmail.net (Art Haas) Date: Sat, 10 Jun 2006 19:56:30 -0500 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <17544.57975.587779.342281@desk.crynwr.com> References: <17544.42048.159038.118145@desk.crynwr.com> <20060608230843.GA25457@artsapartment.org> <17544.49183.543064.304725@desk.crynwr.com> <20060609005613.GB25457@artsapartment.org> <17544.57975.587779.342281@desk.crynwr.com> Message-ID: <20060611005630.GA21340@artsapartment.org> On Thu, Jun 08, 2006 at 10:52:39PM -0400, Russ Nelson wrote: > Art Haas writes: > > I'm not sure what you mean when you write 'set two points on the > > diagonal'. Regardless, I'll do some drawing and see if I can duplicate > > the problem. > > The O's are points, the crosses are intersections without a point, and > the lines are either construction lines or segments; same effect. > > _____ /A point drawn near this > | | / \intersection doesn't snap. > | |/ > ------O--------------+----- > | | > | | > | | > | | > | | > ------+--------------O----- > | | > | | Hi. I've looked into this, and I found a couple of problems. The code that under scrutiny the Image::getClosestPoint() method. First, I fixed a boneheaded typo on line 767 by replacing the '-' with the correct '<'. Fixing that goof the next change involves switching the tests for mapped points and intersection points. In the case above, the mapped point is selected because the mapped point ends up being closer to the mouse-click point even though there is an intersection point to use. I've changed things so that an intersection point will always be chosen over a mapped point. The patch below contains the changes listed above, and I've also sent the changes to the public repo so people using Subversion can get the fix with 'svn update'. Art Index: PythonCAD/Generic/image.py =================================================================== --- PythonCAD/Generic/image.py (revision 2385) +++ PythonCAD/Generic/image.py (revision 2386) @@ -724,7 +724,6 @@ if _sep is None or _sqlen < _sep: _sep = _sqlen _cp = _pt - _layers.extend(_layer.getSublayers()) if _cp is not None: return None, (_cp.x, _cp.y) @@ -760,16 +759,23 @@ for _tobj, _mp in _objlist: for _ix, _iy in intersections.find_intersections(_tobj, _obj): if ((abs(_ix - _x) < _t) and - (abs(_iy - _y) - _t)): + (abs(_iy - _y) < _t)): _sqlen = pow((_x - _ix), 2) + pow((_y - _iy), 2) _intlist.append((_sqlen, (_ix, _iy))) _objlist.append((_obj, _pt)) _layers.extend(_layer.getSublayers()) # + # use the nearest intersection point if one is available + # + _rx = _ry = None + if len(_intlist): + _intlist.sort() + _rx, _ry = _intlist[0][1] + # # look for the closest intersection or mapped point # - _rx = _ry = _smin = None - if len(_objlist): + if _rx is None and len(_objlist): + _smin = None for _obj, _pt in _objlist: _px, _py = _pt _sqlen = pow((_x - _px), 2) + pow((_y - _py), 2) @@ -777,13 +783,7 @@ _smin = _sqlen _rx = _px _ry = _py - if len(_intlist): - _intlist.sort() - _ismin = _intlist[0][0] - if _smin is None or _ismin < _smin: - _smin = _ismin - _rx, _ry = _intlist[0][1] - if _smin is None: + if _rx is None: _rx = _x _ry = _y return None, (_rx, _ry) -- 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 From nelson at crynwr.com Sun Jun 11 05:50:51 2006 From: nelson at crynwr.com (Russ Nelson) Date: Sat, 10 Jun 2006 23:50:51 -0400 Subject: [PythonCAD] intersecting construction lines? In-Reply-To: <20060611005630.GA21340@artsapartment.org> References: <17544.42048.159038.118145@desk.crynwr.com> <20060608230843.GA25457@artsapartment.org> <17544.49183.543064.304725@desk.crynwr.com> <20060609005613.GB25457@artsapartment.org> <17544.57975.587779.342281@desk.crynwr.com> <20060611005630.GA21340@artsapartment.org> Message-ID: <17547.37659.973982.923302@desk.crynwr.com> Art Haas writes: > The patch below contains the changes listed above, and I've > also sent the changes to the public repo so people using > Subversion can get the fix with 'svn update'. Woo hoo! Well done. Now I have to remember what I was doing when I ran across this. :-) -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Mon Jun 12 22:57:31 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 12 Jun 2006 16:57:31 -0400 Subject: [PythonCAD] zooming with mouse wheel Message-ID: <17549.54587.246536.536774@desk.crynwr.com> This patch allows you to zoom in and out using the mouse wheel. I think it has three problems: 1) the scroll increment is too large for a wheel. 2) it's a little hackish to be calling a menu item (but I wanted the patch to be short). 3) The scrolling should also pan at the same time so that the object you're pointing at remains underneath the pointer. Anyway, if people try this patch and think this is useful, I'll keep working on it. Any suggestions beyond the three above? Index: PythonCAD/Interface/Gtk/gtkimage.py =================================================================== --- PythonCAD/Interface/Gtk/gtkimage.py (revision 2387) +++ PythonCAD/Interface/Gtk/gtkimage.py (working copy) @@ -107,6 +107,14 @@ return _entry.event(event) return False +def window_scroll_event(widget, event, gtkimage): + from PythonCAD.Interface.Gtk.gtkmenus import zoom_in_cb + from PythonCAD.Interface.Gtk.gtkmenus import zoom_out_cb + if event.direction == gtk.gdk.SCROLL_UP: + zoom_in_cb(widget, gtkimage) + elif event.direction == gtk.gdk.SCROLL_DOWN: + zoom_out_cb(widget, gtkimage) + def window_general_event(widget, event, gtkimage): _type = event.type debug_print("window_general_event: Event type: %d" % _type) @@ -316,6 +324,7 @@ self.__window.connect("destroy", close_image, self) self.__window.connect("event", window_general_event, self) self.__window.connect("key_press_event", window_key_press_event, self) + self.__window.connect("scroll_event", window_scroll_event, self) _width = min(1024, int(0.8 * float(gtk.gdk.screen_width()))) _height = min(768, int(0.8 * float(gtk.gdk.screen_height()))) self.__window.set_default_size(_width, _height) -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Mon Jun 12 23:12:18 2006 From: nelson at crynwr.com (Russ Nelson) Date: Mon, 12 Jun 2006 17:12:18 -0400 Subject: [PythonCAD] menu creation via tables? Message-ID: <17549.55474.104201.598165@desk.crynwr.com> Should menus be created via tables? I suggest this because it will reduce the amount of code that people need to read. The menu creation code is very structured. The reason not to do it is because some day a menu entry (e.g. a "Recent Files" menu) may need to be computed rather than static. I also think (and this is just my opinion) it would be simpler to add menu entries if they came from a table. But, I may be wrong. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Tue Jun 13 02:11:40 2006 From: ahaas at airmail.net (Art Haas) Date: Mon, 12 Jun 2006 19:11:40 -0500 Subject: [PythonCAD] menu creation via tables? In-Reply-To: <17549.55474.104201.598165@desk.crynwr.com> References: <17549.55474.104201.598165@desk.crynwr.com> Message-ID: <20060613001139.GB21340@artsapartment.org> On Mon, Jun 12, 2006 at 05:12:18PM -0400, Russ Nelson wrote: > Should menus be created via tables? I suggest this because it will > reduce the amount of code that people need to read. The menu creation > code is very structured. The reason not to do it is because some day > a menu entry (e.g. a "Recent Files" menu) may need to be computed > rather than static. > > I also think (and this is just my opinion) it would be simpler to add > menu entries if they came from a table. But, I may be wrong. The menus in PythonCAD used to be defined in a file called 'Generic/menus.py'. This file contained various lists which were pulled into 'gtkmenus.py' and used to build the menus. While this approach worked, it was becoming difficult to handle as more menus were added, and the switch to using the gtk.Action/gtk.ActionGroup approach made me scrap the 'menus.py' file. Much of the menu code is quite repetative, I agree, so there probably are ways to simplify the code similar to the patch you sent in for building the various selection menus. Art -- 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 From ahaas at airmail.net Wed Jun 14 22:35:20 2006 From: ahaas at airmail.net (Art Haas) Date: Wed, 14 Jun 2006 15:35:20 -0500 Subject: [PythonCAD] zooming with mouse wheel In-Reply-To: <17549.54587.246536.536774@desk.crynwr.com> References: <17549.54587.246536.536774@desk.crynwr.com> Message-ID: <20060614203519.GE9905@artsapartment.org> On Mon, Jun 12, 2006 at 04:57:31PM -0400, Russ Nelson wrote: > This patch allows you to zoom in and out using the mouse wheel. I > think it has three problems: > 1) the scroll increment is too large for a wheel. > 2) it's a little hackish to be calling a menu item (but I wanted the > patch to be short). > 3) The scrolling should also pan at the same time so that the object > you're pointing at remains underneath the pointer. > > Anyway, if people try this patch and think this is useful, I'll keep > working on it. Any suggestions beyond the three above? I like the idea of the patch, but the problems you mention above make me not want to apply it. As you wrote, the scroll increment is too large, and calling the 'zoom_in' and 'zoom_out' functions are a bit hackish. I'd suggest changing window_scroll_event() handler by replacing the zoom_foo() calls by calculating a slightly larger or smaller viewing area and using the gtkimage.setView() method to redraw the screen. For example, the untested code below changes the units-per-pixel scaling by 1% and recalculates the view with the centerpoint of the current view remaining the same. Like I said, the code is untested so it probably needs some tweaking. A potential enhancement is to test if a certain key is pressed while the scroll event happens and increasing or descreasing the scale change by a larger amount, say 5%. def window_scroll_event(widget, event, gtkimage): _xmin, _ymin, _xmax, _ymax = gtkimage.getView() _scale = gtkimage.getUnitsPerPixel() _w, _h = gtkimage.getSize() # window size in pixels _xm = (_xmax - _xmin)/2.0 # x-midpoint _ym = (_ymax - _ymin)/2.0 # y-midpoint if event.direction == gtk.gdk.SCROLL_UP: # zoom in _scale = 0.99 * _scale elif event.direction == gtk.gdk.SCROLL_DOWN: # zoom out _scale = 1.01 * _scale else: return TRUE _dx = (_scale * _w)/2.0 _dy = (_scale * _h)/2.0 gtkimage.setView((_xm - _dx), (_ym - _dy), (_xm + _dx), (_ym + _dy)) return TRUE > [ ... snip patch ... ] If you try the code above, does it work? If not, can you make it work? Art Haas -- 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 From ahaas at airmail.net Tue Jun 20 19:52:58 2006 From: ahaas at airmail.net (Art Haas) Date: Tue, 20 Jun 2006 12:52:58 -0500 Subject: [PythonCAD] Status regarding next PythonCAD release Message-ID: <20060620175258.GL2820@artsapartment.org> Hi. I've not made much progress over the last week or more with my plans of replacing the GTKImage class with the code in 'gtkshell.py', I'm sorry to say. I hurt myself playing tennis at the end of May, and the injury has affected my ability to type for long periods. I experience a strange tingling sensation in my right thumb and pain in my right wrist and forearm. In addition to my woes, my fiance just had surgery so I've been tending to her needs as well. The net result of these events is the next release will probably appear in early to mid July. My typing issues will hopefully disappear shortly, allowing me to work on the computer without discomfort. I've also been again examining code in the Gimp to better understand how the Gimp developers handle using GTK+. Art -- 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 From nelson at crynwr.com Tue Jun 27 16:39:42 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 27 Jun 2006 10:39:42 -0400 Subject: [PythonCAD] printing bug? Message-ID: <17569.17198.664857.750587@desk.crynwr.com> When you print something with dimensions, it appears as if the text of the dimensions is being printed twice: once as a TextBlock, and again as a DimString. -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From nelson at crynwr.com Tue Jun 27 17:08:44 2006 From: nelson at crynwr.com (Russ Nelson) Date: Tue, 27 Jun 2006 11:08:44 -0400 Subject: [PythonCAD] patch for exact printing Message-ID: <17569.18940.62533.720522@desk.crynwr.com> I plan to create some parts by printing to sticky paper, sticking the paper directly to the raw material, and then cutting the part out. Thus, I need "Exact" scale printing, so that something drawn 10cm x 10cm gets printed at 10cm x 10cm regardless of the size of the paper. Units are taking into account, so that a 1" x 1" square is drawn at that size also. Note that most printers can't do edge-to-edge printing, so you probably shouldn't draw your part at 0,0. The exact printing area is printer-dependent, so count on leaving a margin. Index: PythonCAD/Generic/printing.py =================================================================== --- PythonCAD/Generic/printing.py (revision 2387) +++ PythonCAD/Generic/printing.py (working copy) @@ -73,6 +73,7 @@ # some sizes taken from 'gs_statd.ps' Ghostscript file # __papersizes = { + 'exact' : (0, 0), 'letter' : (612, 792), 'legal' : (612, 1008), 'tabloid' : (792, 1224), @@ -205,10 +206,16 @@ raise ValueError, "Unexpected unit: %s" % _units self.__factor = _fac # print "factor: %g" % _fac - _xs = _fac * ((_xmax - _xmin)/float(_w)) - _ys = _fac * ((_ymax - _ymin)/float(_h)) - # print "xs: %g; ys: %g" % (_xs, _ys) - _s = 1.0/max(_xs, _ys) + + if _w == 0 and _h == 0: + _ymin = 0 + _xmin = 0 + _s = 1 + else: + _xs = _fac * ((_xmax - _xmin)/float(_w)) + _ys = _fac * ((_ymax - _ymin)/float(_h)) + # print "xs: %g; ys: %g" % (_xs, _ys) + _s = 1.0/max(_xs, _ys) self.__scale = _s # print "scale: %g" % self.__scale self.__matrix = ((_s * _fac), -- --my blog is at http://blog.russnelson.com | When immigration is Crynwr sells support for free software | PGPok | outlawed, only criminals 521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime. From ahaas at airmail.net Wed Jun 28 19:30:31 2006 From: ahaas at airmail.net (Art Haas) Date: Wed, 28 Jun 2006 12:30:31 -0500 Subject: [PythonCAD] patch for exact printing In-Reply-To: <17569.18940.62533.720522@desk.crynwr.com> References: <17569.18940.62533.720522@desk.crynwr.com> Message-ID: <20060628173031.GE5388@artsapartment.org> On Tue, Jun 27, 2006 at 11:08:44AM -0400, Russ Nelson wrote: > I plan to create some parts by printing to sticky paper, sticking the > paper directly to the raw material, and then cutting the part out. > Thus, I need "Exact" scale printing, so that something drawn 10cm x > 10cm gets printed at 10cm x 10cm regardless of the size of the paper. > Units are taking into account, so that a 1" x 1" square is drawn at > that size also. > > Note that most printers can't do edge-to-edge printing, so you > probably shouldn't draw your part at 0,0. The exact printing area is > printer-dependent, so count on leaving a margin. > [ ... snip ... ] I've applied the patch. Thanks! I don't know just how much usage printing in PythonCAD has received, so problems like you've faced are likely to affect other users. When the GTK+-2.10 release appears with printing support built in, I will try to utilize the new routines when possible, and I'm hoping that printing abilitiies will improve. I'll still keep the PostScript printing code around for people not using the new release, which will be the majority of users for a good while. Art Haas -- 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 From ahaas at airmail.net Fri Jun 30 01:48:05 2006 From: ahaas at airmail.net (Art Haas) Date: Thu, 29 Jun 2006 18:48:05 -0500 Subject: [PythonCAD] Big changes available at public repo Message-ID: <20060629234805.GB14644@artsapartment.org> Hi. There's new stuff available for those of you using Subversion; a simple 'svn update' and you'll get the goodies. As for what these changes themselves, they are essentially a re-writing of the GTKImage class and the required followups. I'd written before about replacing GTKImage with code in the 'gtkshell.py' file with the goals being greatly simplified entity drawing, the removal of many/most/all of the various redraw() calls sprinkled around the code, and complete the separation of the interface and core code by relying on the messaging system for exchanging information. This work, however, had stalled to an extent. While at a doctor visit last week, I decided to take as much of the code from ImageView/ImageWindow and bring it back into the GTKImage class and work the issues out there. A few painkillers and some typing later, the GTKImage class was shortly transformed into a class utilizing the messaging system for responding to the core Image adding, modifying, and removing entities. The drawing routines from the ImageView class which were designed to draw entities based on those messages were brought into the GTKImage class, and various fixes later they were working, allowing me to remove the redraw() calls throughout much of the code. Previously, when an entity was added to an Image, the entire Image was redrawn. As the number of entities increased, the redraw operations took longer and longer. The new code now only draws the new entity if it is visible, not the entire lot again. People using slower machines with less powerful graphics cards should notice the speedup. The second big change was to change the base class of the GTKImage class. Previously it was the Image class defined in the 'PythonCAD/Generic/image.py' file. Now the base class is simply the Python 'object' class. This change completes the separation of the interface and the core code from an object hierarchy. Making this change, however, required lots of changes to the various files in the 'PythonCAD/Interface/Gtk' directory. I think I've managed to make all the needed changes, but it wouldn't be surprising if a few more edits are needed to complete things. The end result of all the changes is that the interface now relies on the messaging system completely for notification of entity addition, modification, and removal. These changes also greatly improve the responsiveness of drawing operations, benefitting everyone but especially people on older hardware. I'll be tweaking things over the next few days as I clean up some of the changes plus fix the errors that still quietly lurk in the code. For people wanting to try out the new code, please let me know when (not if) you find a glitch or two. The problems are usually simple to fix, as I've had to make several quick fixes after the initial big batch of changes were checked in. Art Haas -- 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 From ahaas at airmail.net Fri Jun 30 16:45:54 2006 From: ahaas at airmail.net (Art Haas) Date: Fri, 30 Jun 2006 09:45:54 -0500 Subject: [PythonCAD] Big changes available at public repo In-Reply-To: <20060629234805.GB14644@artsapartment.org> References: <20060629234805.GB14644@artsapartment.org> Message-ID: <20060630144554.GH14644@artsapartment.org> On Thu, Jun 29, 2006 at 06:48:05PM -0500, Art Haas wrote: > Hi. > > There's new stuff available for those of you using Subversion; a simple > 'svn update' and you'll get the goodies. > > [ ... snip ... ] > > For people wanting to try out the new code, please let me know when (not > if) you find a glitch or two. The problems are usually simple to fix, > as I've had to make several quick fixes after the initial big batch of > changes were checked in. Hi. I've added a couple of more fixes to the code, and sent my changes up to the public repo. A problem displaying saved drawings has been fixed, as well as an error which would would cause lots of error messages about 'NoneType' arguments has been corrected as well. Please do an 'svn update' to get these corrections. Art -- 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 From ahaas at airmail.net Fri Jun 30 21:30:26 2006 From: ahaas at airmail.net (Art Haas) Date: Fri, 30 Jun 2006 14:30:26 -0500 Subject: [PythonCAD] Big changes available at public repo In-Reply-To: <20060630144554.GH14644@artsapartment.org> References: <20060629234805.GB14644@artsapartment.org> <20060630144554.GH14644@artsapartment.org> Message-ID: <20060630193026.GA6775@artsapartment.org> On Fri, Jun 30, 2006 at 09:45:54AM -0500, Art Haas wrote: > On Thu, Jun 29, 2006 at 06:48:05PM -0500, Art Haas wrote: > > Hi. > > > > There's new stuff available for those of you using Subversion; a simple > > 'svn update' and you'll get the goodies. > > > > [ ... snip ... ] > > > > For people wanting to try out the new code, please let me know when (not > > if) you find a glitch or two. The problems are usually simple to fix, > > as I've had to make several quick fixes after the initial big batch of > > changes were checked in. > > Hi. > > I've added a couple of more fixes to the code, and sent my changes up > to the public repo. A problem displaying saved drawings has been fixed, > as well as an error which would would cause lots of error messages > about 'NoneType' arguments has been corrected as well. Please do > an 'svn update' to get these corrections. Hi. Another batch of fixes is available at the public repo awaiting your typing of 'svn update'. Switching active layers will again cause the display to update correctly, and a few other small fixes are included as well. Art -- 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