Clip group - prevent auto centering
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Clip group - prevent auto centering
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 (67.75 KiB) Viewed 1419 times
Re: Clip group - prevent auto centering
Would be a useful feature IMO.
Workaround:
Workaround:
- Change the position of the empty Clip object to X=0 and Y=0.
- Move the view so that it is positioned correctly relative to the Clip outline.
- Make a note of the currrent X and Y position of the view.
- Add the view to the Clip.
- Change the X and Y of the view to the previous values.
- Move the Clip to the correct position on the page.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Clip group - prevent auto centering
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.
Re: Clip group - prevent auto centering
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:
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 29 times
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Clip group - prevent auto centering
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.Roy_043 wrote: ↑Fri Sep 16, 2022 3:21 pm The View should not move relative to the Clip when calling TechDraw_ClipGroupAdd.
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.
Re: Clip group - prevent auto centering
My code suggests that it is trivial. So I am either missing something or we are at cross-purposes here.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Clip group - prevent auto centering
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.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Clip group - prevent auto centering
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).
Re: Clip group - prevent auto centering
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)?
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Clip group - prevent auto centering
I'll give that a try.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)?