Clip group - prevent auto centering

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
kemes
Posts: 63
Joined: Wed Mar 02, 2022 8:05 am

Clip group - prevent auto centering

Post by kemes »

Once adding a view to a clip group the view automatically centers it after clicking the add icon. Is there a way to prevent the auto centering? Especially with big parts (and a tight zoom) it takes a long time to frame the part again.
Attachments
clip_group_framing.gif
clip_group_framing.gif (67.75 KiB) Viewed 1357 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Clip group - prevent auto centering

Post by Roy_043 »

Would be a useful feature IMO.

Workaround:
  1. Change the position of the empty Clip object to X=0 and Y=0.
  2. Move the view so that it is positioned correctly relative to the Clip outline.
  3. Make a note of the currrent X and Y position of the view.
  4. Add the view to the Clip.
  5. Change the X and Y of the view to the previous values.
  6. Move the Clip to the correct position on the page.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Clip group - prevent auto centering

Post by wandererfan »

kemes wrote: Fri Sep 16, 2022 10:34 am Once adding a view to a clip group the view automatically centers it after clicking the add icon. Is there a way to prevent the auto centering? Especially with big parts (and a tight zoom) it takes a long time to frame the part again.
Bear with me, I'm having trouble figuring out how this would work. If the view was not placed within the clip area, you wouldn't be see it to be able to drag it. I think what you're looking for is the ability to pick a spot on the view to be place at the center of the clip area?

Changing the view's X&Y properties after it is added to the clip is often faster than dragging.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Clip group - prevent auto centering

Post by Roy_043 »

The View should not move relative to the Clip when calling TechDraw_ClipGroupAdd.

Open the attached file and run the code below to get a better idea:

Code: Select all

view = App.activeDocument().View
clip = App.activeDocument().Clip
deltaX = view.X - clip.X
deltaY = view.Y - clip.Y
clip.addView(view)
view.X = deltaX
view.Y = deltaY
Attachments
clip_test.FCStd
(17.86 KiB) Downloaded 28 times
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Clip group - prevent auto centering

Post by wandererfan »

Roy_043 wrote: Fri Sep 16, 2022 3:21 pm The View should not move relative to the Clip when calling TechDraw_ClipGroupAdd.
What happens now is that the View's X,Y is set to (0,0) within the Clip, so the center of the View appears at the center of the Clip. The position of the Clip is not considered.

Assuming I am following (never safe), we would have to determine where the Clip's center falls within the View it is positioned over, then position the View within the Clip with the appropriate offset. Doable, but not trivial.

Please make a feature request ticket so this doesn't get forgotten.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Clip group - prevent auto centering

Post by Roy_043 »

wandererfan wrote: Fri Sep 16, 2022 4:55 pm not trivial
My code suggests that it is trivial. So I am either missing something or we are at cross-purposes here.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Clip group - prevent auto centering

Post by wandererfan »

Roy_043 wrote: Fri Sep 16, 2022 6:49 pm My code suggests that it is trivial. So I am either missing something or we are at cross-purposes here.
I was thinking that there would be issues with scaling and converting between gui side coordinates and app side coordinates, but this would not be the first time I've been wrong.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Clip group - prevent auto centering

Post by wandererfan »

Roy_043 wrote: Fri Sep 16, 2022 6:49 pm My code suggests that it is trivial. So I am either missing something or we are at cross-purposes here.
Wasn't quite trivial as I had to figure out what to do if the clip isn't aligned on the view to be added. In any case, after git commit b3dfdc568a, if the clip is aligned over the view to add, the view will be inserted as in your python code. If the clip does not overlap the view to be added, the view will be centered in the clip (the old behaviour).
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Clip group - prevent auto centering

Post by Roy_043 »

Thanks. You are checking if the center of the Clip is inside the View rectangle. Have you considered checking for an overlap between the Clip and View rectangles instead (https://doc.qt.io/qt-6/qrectf.html#intersects)?
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Clip group - prevent auto centering

Post by wandererfan »

Roy_043 wrote: Sat Sep 17, 2022 3:36 pm Thanks. You are checking if the center of the Clip is inside the View rectangle. Have you considered checking for an overlap between the Clip and View rectangles instead (https://doc.qt.io/qt-6/qrectf.html#intersects)?
I'll give that a try.
Post Reply