[TD]fix front view position in projection group (fix #19085)
This commit is contained in:
committed by
Yorik van Havre
parent
d7f0ce2a97
commit
01f4e08f47
@@ -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();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#include <Mod/TechDraw/App/DrawViewSection.h>
|
||||
|
||||
#include "TaskProjGroup.h"
|
||||
#include "QGIViewPart.h"
|
||||
#include "QGSPage.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "ViewProviderProjGroup.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -216,3 +219,25 @@ TechDraw::DrawProjGroup* ViewProviderProjGroup::getObject() const
|
||||
{
|
||||
return getViewObject();
|
||||
}
|
||||
|
||||
|
||||
//! gather the (existing) graphics for our sub views into our scene group.
|
||||
void ViewProviderProjGroup::regroupSubViews()
|
||||
{
|
||||
auto vpPage = getViewProviderPage();
|
||||
if (!vpPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto scene = vpPage->getQGSPage();
|
||||
auto dpgQView = getQView();
|
||||
|
||||
auto viewsAll = getObject()->getViewsAsDPGI();
|
||||
for (auto& view : viewsAll) {
|
||||
auto viewQView = dynamic_cast<QGIViewPart *>(scene->findQViewForDocObj(view));
|
||||
if (viewQView) {
|
||||
scene->addItemToParent(viewQView, dpgQView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
bool onDelete(const std::vector<std::string> &parms) override;
|
||||
bool canDelete(App::DocumentObject* obj) const override;
|
||||
|
||||
void regroupSubViews();
|
||||
|
||||
protected:
|
||||
bool setEdit(int ModNum) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user