[TD]fix front view position in projection group (fix #19085)

This commit is contained in:
wandererfan
2025-01-17 19:49:30 -05:00
committed by Yorik van Havre
parent 27732fdf50
commit 44a1e8de4d
3 changed files with 39 additions and 6 deletions

View File

@@ -59,6 +59,7 @@
#include "ViewProviderPage.h"
#include "ViewProviderDrawingView.h"
#include "ViewProviderProjGroupItem.h"
#include "ViewProviderProjGroup.h"
using namespace Gui;
@@ -276,6 +277,7 @@ void TaskProjGroup::viewToggled(bool toggle)
else {
// If toggle then we remove the view object and create a proj group instead.
turnViewToProjGroup();
changed = true;
}
}
@@ -293,6 +295,10 @@ void TaskProjGroup::viewToggled(bool toggle)
}
if (changed) {
// necessary to prevent position problems
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_page->getDocument());
auto* vppg = static_cast<ViewProviderProjGroup*>(activeGui->getViewProvider(multiView));
vppg->regroupSubViews();
if (view->ScaleType.isValue("Automatic")) {
double scale = view->getScale();
setFractionalScale(scale);
@@ -312,7 +318,6 @@ void TaskProjGroup::turnViewToProjGroup()
Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.addView(App.activeDocument().%s)", view->findParentPage()->getNameInDocument(), multiViewName.c_str());
auto* viewPart = static_cast<TechDraw::DrawViewPart*>(view);
m_page->removeView(viewPart);
multiView = static_cast<TechDraw::DrawProjGroup*>(doc->getObject(multiViewName.c_str()));
multiView->Source.setValues(viewPart->Source.getValues());
@@ -322,23 +327,24 @@ void TaskProjGroup::turnViewToProjGroup()
multiView->Scale.setValue(viewPart->Scale.getValue());
multiView->ScaleType.setValue(viewPart->ScaleType.getValue());
multiView->ProjectionType.setValue(Preferences::projectionAngle());
multiView->addView(viewPart);
multiView->Anchor.setValue(viewPart);
multiView->Anchor.purgeTouched();
viewPart->X.setValue(0.0);
viewPart->Y.setValue(0.0);
viewPart->ScaleType.setValue("Custom");
viewPart->ScaleType.setStatus(App::Property::Hidden, true);
viewPart->Scale.setStatus(App::Property::Hidden, true);
viewPart->Label.setValue("Front");
multiView->addView(viewPart);
multiView->Anchor.setValue(view);
multiView->Anchor.purgeTouched();
viewPart->LockPosition.setValue(true);
viewPart->LockPosition.setStatus(App::Property::ReadOnly, true); //Front should stay locked.
viewPart->LockPosition.purgeTouched();
m_page->requestPaint();
view = multiView;
m_page->removeView(viewPart); // prevent multiple entries in tree
updateUi();
}