diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 48740c253d80..0a7fcf49ead0 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -452,6 +452,7 @@ bool DrawProjGroup::canDelete(const char* viewProjType) const App::DocumentObject* DrawProjGroup::addProjection(const char* viewProjType) { + // Base::Console().Message("DPG::addProjection(%s)\n", viewProjType ? viewProjType : "null"); DrawProjGroupItem* view(nullptr); std::pair vecs; @@ -499,10 +500,6 @@ App::DocumentObject* DrawProjGroup::addProjection(const char* viewProjType) true);//Front should stay locked. view->LockPosition.purgeTouched(); } - // addView(view); //from DrawViewCollection - // if (view != getAnchor()) { //anchor is done elsewhere - // view->recomputeFeature(); - // } } } return view; diff --git a/src/Mod/TechDraw/Gui/QGSPage.cpp b/src/Mod/TechDraw/Gui/QGSPage.cpp index d85de20d9c67..cb27d018dedc 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.cpp +++ b/src/Mod/TechDraw/Gui/QGSPage.cpp @@ -95,6 +95,7 @@ using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; +using DU = DrawUtil; QGSPage::QGSPage(ViewProviderPage* vpPage, QWidget* parent) : QGraphicsScene(parent), pageTemplate(nullptr), m_vpPage(nullptr) @@ -254,13 +255,21 @@ int QGSPage::addQView(QGIView* view) TechDraw::DrawView *viewObj = view->getViewObject(); // Preserve the desired position, as addToGroup() adjusts the child view's position QPointF viewPos(Rez::guiX(viewObj->X.getValue()), -Rez::guiX(viewObj->Y.getValue())); - // Find if it belongs to a parent QGIView *parent = findParent(view); if (parent) { + auto parentDocObj = parent->getViewObject(); + auto parentDPG = dynamic_cast(parentDocObj); + if (parentDPG) { + // move the DPGI to the center of the DPG. the DPGI must be placed in the + // correct position on the page before adding it to the DPG or it will be + // placed at scene(0,0). + QPointF posRef(0., 0.); + QPointF mapPos = view->mapToItem(parent, posRef); + view->moveBy(-mapPos.x(), -mapPos.y()); + } parent->addToGroup(view); } - view->setPos(viewPos); auto viewProvider = dynamic_cast(QGIView::getViewProvider(view->getViewObject())); @@ -389,7 +398,7 @@ bool QGSPage::attachView(App::DocumentObject* obj) QGIView* QGSPage::addViewPart(TechDraw::DrawViewPart* partFeat) { - // Base::Console().Message("QGSP::addViewPart(%s)\n", part->getNameInDocument()); + // Base::Console().Message("QGSP::addViewPart(%s)\n", partFeat->Label.getValue()); auto viewPart(new QGIViewPart); viewPart->setViewPartFeature(partFeat); @@ -410,6 +419,7 @@ QGIView* QGSPage::addViewSection(DrawViewSection* sectionFeat) QGIView* QGSPage::addProjectionGroup(TechDraw::DrawProjGroup* projGroupFeat) { + // Base::Console().Message("QGSP::addprojectionGroup(%s)\n", projGroupFeat->Label.getValue()); auto qview(new QGIProjGroup); qview->setViewFeature(projGroupFeat); diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index fd53bf7a485e..0916dfc9f563 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -181,7 +181,7 @@ void TaskProjGroup::viewToggled(bool toggle) // Obtain name of checkbox QString viewName = sender()->objectName(); int index = viewName.mid(7).toInt(); - const char *viewNameCStr = viewChkIndexToCStr(index).c_str(); + const char *viewNameCStr = viewChkIndexToCStr(index); if ( toggle && !multiView->hasProjection( viewNameCStr ) ) { Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.addProjection('%s')", @@ -198,6 +198,7 @@ void TaskProjGroup::viewToggled(bool toggle) double scale = multiView->getScale(); setFractionalScale(scale); } + multiView->recomputeFeature(); } wc.restoreCursor(); } @@ -247,6 +248,8 @@ void TaskProjGroup::projectionTypeChanged(QString qText) ui->chkView7->setToolTip(getToolTipForBox(7)); ui->chkView8->setToolTip(getToolTipForBox(8)); ui->chkView9->setToolTip(getToolTipForBox(9)); + + multiView->recomputeFeature(); } void TaskProjGroup::scaleTypeChanged(int index) @@ -428,7 +431,7 @@ void TaskProjGroup::changeEvent(QEvent *event) } } -std::string TaskProjGroup::viewChkIndexToCStr(int index) +const char * TaskProjGroup::viewChkIndexToCStr(int index) { // Third Angle: FTL T FTRight // L F Right Rear @@ -439,20 +442,20 @@ std::string TaskProjGroup::viewChkIndexToCStr(int index) // FTRight T FTL assert (multiView); - std::string boxName; + bool thirdAngle = multiView->usedProjectionType().isValue("Third Angle"); switch(index) { - case 0: {boxName = Base::Tools::toStdString(getToolTipForBox(0)); break;} - case 1: {boxName = Base::Tools::toStdString(getToolTipForBox(1)); break;} - case 2: {boxName = Base::Tools::toStdString(getToolTipForBox(2)); break;} - case 4: {boxName = Base::Tools::toStdString(getToolTipForBox(3)); break;} - case 5: {boxName = Base::Tools::toStdString(getToolTipForBox(4)); break;} - case 6: {boxName = Base::Tools::toStdString(getToolTipForBox(5)); break;} - case 7: {boxName = Base::Tools::toStdString(getToolTipForBox(6)); break;} - case 8: {boxName = Base::Tools::toStdString(getToolTipForBox(7)); break;} - case 9: {boxName = Base::Tools::toStdString(getToolTipForBox(8)); break;} - default: boxName = ""; + case 0: return (thirdAngle ? "FrontTopLeft" : "FrontBottomRight"); + case 1: return (thirdAngle ? "Top" : "Bottom"); + case 2: return (thirdAngle ? "FrontTopRight" : "FrontBottomLeft"); + case 3: return (thirdAngle ? "Left" : "Right"); + case 4: return (thirdAngle ? "Front" : "Front"); + case 5: return (thirdAngle ? "Right" : "Left"); + case 6: return (thirdAngle ? "Rear" : "Rear"); + case 7: return (thirdAngle ? "FrontBottomLeft" : "FrontTopRight"); + case 8: return (thirdAngle ? "Bottom" : "Top"); + case 9: return (thirdAngle ? "FrontBottomRight" : "FrontTopLeft"); + default: return nullptr; } - return boxName; } QString TaskProjGroup::getToolTipForBox(int boxNumber) @@ -477,6 +480,7 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections) { if (!multiView) return; + // There must be a better way to construct this list... QCheckBox * viewCheckboxes[] = { ui->chkView0, ui->chkView1, @@ -496,7 +500,7 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections) connect(box, &QCheckBox::toggled, this, &TaskProjGroup::viewToggled); } - const char *viewStr = viewChkIndexToCStr(i).c_str(); + const char *viewStr = viewChkIndexToCStr(i); if (viewStr && multiView->hasProjection(viewStr)) { box->setCheckState(Qt::Checked); if (!multiView->canDelete(viewStr)) { diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index 32e526841c39..9e1dbfa3e36f 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -104,7 +104,7 @@ protected Q_SLOTS: bool blockUpdate; /// Translate a view checkbox index into represented view string, depending on projection type - std::string viewChkIndexToCStr(int index); + const char * viewChkIndexToCStr(int index); QString getToolTipForBox(int boxNumber); QPushButton* m_btnOK;