Point Dragger Mode for Editing Draft Object Vertices?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
sebjf
Posts: 14
Joined: Mon Sep 14, 2020 7:58 pm

Point Dragger Mode for Editing Draft Object Vertices?

Post by sebjf »

Hi,

I was thinking in some cases* it may be helpful to directly adjust the position of Draft Wire vertices in 3D, with something like the Transform Manipulator.

I was looking at the code for the Draft_Edit command, and it should be fairly straightforward to add this option by instantiating a SoDragPointDragger and using its callbacks (instead of the Snapper in the mouse move callback).

This would allow the alternative mode to work with all Draft Objects.

One way to implement it would be to have a toggle at the Command level, or detect a modifier key when a Target is selected. Then the alternative implementations to modify the points could be split out into two small classes. Or, two functions be defined that set up the behaviour & a single callback to clean-up when editing is finished, ready for the other one to be started for the next edit depending on the user.

In either case, if I did this and made a PR, is it something the FreeCAD project would want, or is the use case too niche to be worth messing with that Edit module?

*E.g. forplumbing and wiring where some vertices may need to be placed in free space.

Sj
chrisb
Veteran
Posts: 53786
Joined: Tue Mar 17, 2015 9:14 am

Re: Point Dragger Mode for Editing Draft Object Vertices?

Post by chrisb »

sebjf wrote: Sun Sep 19, 2021 11:02 am I was thinking in some cases* it may be helpful to directly adjust the position of Draft Wire vertices in 3D, with something like the Transform Manipulator.
I just tried Draft Line, Wire (Polyline), Circle, Rectangle (Plane) and ShapeString: They all can already be manipulated with the Transform tool.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Point Dragger Mode for Editing Draft Object Vertices?

Post by carlopav »

Hello, we modified quite a lot Draft_Edit in the last 3 years (basically me with the help of many more skilled programmers that offered super useful advices and parts of the code).

There are still a lot of things to improve (object preview, multi point editing etc...), but one of the main goal has been to separate the editing mechanism from document_objects specific code and to make it easy to support new objects providing the needed classes.

At the current point I could agree with you that it could be quite easy to implement a new mechanism to move the points (also if in my opinion this is not a priority), so feel free to implement it and ping me if you have some question on the current implementation. :)

Take into account that many objects provide a main and an alternative editing mode (self.alt_edit_mode). Basically the point is moved the same way but the effect on the object is different.

I still think that FC lacks a common direct editing mode for all workbenches. Something that every workbench could extend to its own specific objects. But that's another topic, so to me go on, have fun, and remember to keep the community up-to-date with your experiments!
follow my experiments on BIM modelling for architecture design
sebjf
Posts: 14
Joined: Mon Sep 14, 2020 7:58 pm

Re: Point Dragger Mode for Editing Draft Object Vertices?

Post by sebjf »

Hi,

Thanks a lot!

Sorry its taken so long to get back. I got distracted by the ArchWindow Part workflow.

I prototyped the dragger mode, and compared planning a wiring run using this exclusively, with using pre-placed snap targets. Below are videos showing the task with both approaches:

https://vimeo.com/638184261
https://vimeo.com/638184665

A couple of notes,
1. I haven't yet made the dragger change size with camera zoom, so the scale is fixed.
2. I use small Part Spheres as snap targets rather than Draft Points, due to a bug with the Points.

Both approaches take almost exactly the same time (9 minutes). There would be slight differences if doing this for real. For example, the backboxes would have snap points similar to the ArchEquipment parts.

On the whole, I felt using snap targets was more comfortable, and resulted in a neater drawing. The dragger mode then turned out not so important for this use case, even if it may still be useful for the odd adjustment.

The implementation was fairly straightforward and required few changes to gui_edit.py. It would still need a couple of improvements, e.g. make the dragger mode onMousePressed callback more robust, but is practically complete.

I also explored implementing this behaviour in a separate module, which is probably a better idea. Ideally I'd be able to import the maker functionality from the Draft WB to avoid re-inventing the wheel, but not sure if this is possible.

Here is a diff showing the implementation.

I have attached the file I used in the tests as well.
Note if anyone wants to open/re-create it, you'll also need:
1. A version of pivy after commit b835b8
2. Some adjustments to ArchWindow.py
Attachments
Floor.FCStd
(189.22 KiB) Downloaded 22 times
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Point Dragger Mode for Editing Draft Object Vertices?

Post by carlopav »

Hi!

The implementation looks really clean, i like the code.

However I'm not sure about if it is the right direction: the dragger seems to be not compatible with Draft Snaps, as you experienced the drawing became less precise, and 9 minuts is really a lot of time to draw such few lines... I can obtain the same drawing in 1 minute just constraining the direction of the polyline to x y z axis (pressing x y z keys) while drawing it or while editing it (this would save you from the need to place part spheres before...). What do you think?

(this is not the purpose of the topic, but, did you import the architectural model or did you draw it by yourself? I got lots of errors like this: 17:20:54<PropShape> PropertyTopoShape.cpp(416): Pending recompute for generating element map: Floor#Window005)
follow my experiments on BIM modelling for architecture design
sebjf
Posts: 14
Joined: Mon Sep 14, 2020 7:58 pm

Re: Point Dragger Mode for Editing Draft Object Vertices?

Post by sebjf »

Hi carlopav,

> did you import the architectural model or did you draw it by yourself?

I drew it myself, but to create the backbox cutouts (following the AppPart workflow) I had to modify the ArchWindow module a little.

I posted about this in the New Users forum but as I was still investigating at the time I don't think the thread was very clear and didn't get the attention of any of the Arch maintainers, so am not sure where to submit the fixes.

> The implementation looks really clean, i like the code.
> However I'm not sure about if it is the right direction:

Thank you! Though after trying it out I agree. I don't think it adds enough to warrant changes to the Draft Edit module.

(If it belongs anywhere, I'd say in a third-party WB, as a Command that say, creates a dragger for each point allowing all of them to be edited without changing the selection.)

For completeness I recorded myself creating the line using the constraints (I didn't know about these, thank you!), to compare the approaches when used by someone with the same skill level. I recorded the 10th attempt, which took six minutes. Slower than a more experienced user but 1/3 faster than the others.
(And again with the caveat that there were no snap points on the fixtures, so a real drawing would be faster.)

https://vimeo.com/640903719
Post Reply