From fcef1cb1741e2943949662b733db2c2cdc812ca2 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 7 Sep 2022 11:03:14 -0400 Subject: [PATCH] [TD]implement view stacking --- src/Mod/TechDraw/Gui/AppTechDrawGui.cpp | 2 + src/Mod/TechDraw/Gui/CMakeLists.txt | 1 + src/Mod/TechDraw/Gui/CommandStack.cpp | 419 +++++++++++ src/Mod/TechDraw/Gui/QGIView.cpp | 16 + src/Mod/TechDraw/Gui/QGIView.h | 4 + src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 4 + .../icons/actions/TechDraw_StackBottom.svg | 699 ++++++++++++++++++ .../icons/actions/TechDraw_StackDown.svg | 699 ++++++++++++++++++ .../icons/actions/TechDraw_StackTop.svg | 698 +++++++++++++++++ .../icons/actions/TechDraw_StackUp.svg | 698 +++++++++++++++++ src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp | 3 + .../TechDraw/Gui/ViewProviderDimension.cpp | 3 + .../TechDraw/Gui/ViewProviderDrawingView.cpp | 68 ++ .../TechDraw/Gui/ViewProviderDrawingView.h | 7 + src/Mod/TechDraw/Gui/Workbench.cpp | 18 + 15 files changed, 3339 insertions(+) create mode 100644 src/Mod/TechDraw/Gui/CommandStack.cpp create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackBottom.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackDown.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackTop.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackUp.svg diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp index 360d42f95f..e6241f5a0f 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp @@ -76,6 +76,7 @@ void CreateTechDrawCommandsDecorate(); void CreateTechDrawCommandsAnnotate(); void CreateTechDrawCommandsExtensionDims(); void CreateTechDrawCommandsExtensions(); +void CreateTechDrawCommandsStack(); void loadTechDrawResource() { @@ -123,6 +124,7 @@ PyMOD_INIT_FUNC(TechDrawGui) CreateTechDrawCommandsAnnotate(); CreateTechDrawCommandsExtensionDims(); CreateTechDrawCommandsExtensions(); + CreateTechDrawCommandsStack(); TechDrawGui::Workbench::init(); TechDrawGui::MDIViewPage::init(); diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index d16c01d9df..3322504464 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -116,6 +116,7 @@ SET(TechDrawGui_SRCS CommandAnnotate.cpp CommandExtensionDims.cpp CommandExtensionPack.cpp + CommandStack.cpp Resources/TechDraw.qrc PreCompiled.cpp PreCompiled.h diff --git a/src/Mod/TechDraw/Gui/CommandStack.cpp b/src/Mod/TechDraw/Gui/CommandStack.cpp new file mode 100644 index 0000000000..4a8f436dca --- /dev/null +++ b/src/Mod/TechDraw/Gui/CommandStack.cpp @@ -0,0 +1,419 @@ +/*************************************************************************** + * Copyright (c) 2022 Wanderer Fan * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "DrawGuiUtil.h" +#include "ViewProviderDrawingView.h" + + +using namespace TechDrawGui; +using namespace TechDraw; +using namespace std; + +void execStackTop(Gui::Command* cmd); +void execStackBottom(Gui::Command* cmd); +void execStackUp(Gui::Command* cmd); +void execStackDown(Gui::Command* cmd); + + +//=========================================================================== +// TechDraw_StackGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawStackGroup) + +CmdTechDrawStackGroup::CmdTechDrawStackGroup() + : Command("TechDraw_StackGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Adjust stacking order of views"); + sToolTipText = sMenuText; + sWhatsThis = "TechDraw_StackGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawStackGroup::activated(int iMsg) +{ + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + if (dlg != nullptr) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), + QObject::tr("Close active task dialog and try again.")); + return; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: + execStackTop(this); + break; + case 1: + execStackBottom(this); + break; + case 2: + execStackUp(this); + break; + case 3: + execStackDown(this); + break; + default: + Base::Console().Message("CMD::StackGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawStackGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackTop")); + p1->setObjectName(QString::fromLatin1("TechDraw_StackTop")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_StackTop")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackBottom")); + p2->setObjectName(QString::fromLatin1("TechDraw_StackBottom")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_StackBottom")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackUp")); + p3->setObjectName(QString::fromLatin1("TechDraw_StackUp")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_StackUp")); + QAction* p4 = pcAction->addAction(QString()); + p4->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackDown")); + p4->setObjectName(QString::fromLatin1("TechDraw_StackDown")); + p4->setWhatsThis(QString::fromLatin1("TechDraw_StackDown")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawStackGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Top")); + arc1->setToolTip(QApplication::translate("TechDraw_StackTop","Move view to top of stack")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Bottom")); + arc2->setToolTip(QApplication::translate("TechDraw_StackBottom","Move view to bottom of stack")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Up")); + arc3->setToolTip(QApplication::translate("TechDraw_StackUp","Move view up one level")); + arc3->setStatusTip(arc3->toolTip()); + QAction* arc4 = a[3]; + arc4->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Down")); + arc4->setToolTip(QApplication::translate("TechDraw_StackDown","Move view down one level")); + arc4->setStatusTip(arc4->toolTip()); +} + +bool CmdTechDrawStackGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, false); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_StackTop +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawStackTop) + +CmdTechDrawStackTop::CmdTechDrawStackTop() + : Command("TechDraw_StackTop") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Move view to top of stack"); + sToolTipText = sMenuText; + sWhatsThis = "TechDraw_StackTop"; + sStatusTip = sToolTipText; + sPixmap = "actions/TechDraw_StackTop"; +} + +void CmdTechDrawStackTop::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + if (dlg != nullptr) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), + QObject::tr("Close active task dialog and try again.")); + return; + } + + execStackTop(this); +} + +bool CmdTechDrawStackTop::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, false); + return (havePage && haveView); +} + +void execStackTop(Gui::Command* cmd) +{ + TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); + if (!page) { + return; + } + + std::vector views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); + if (!views.empty()) { + for (auto& v: views) { + TechDraw::DrawView* dv = static_cast(v); + Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( + cmd->getDocument())->getViewProvider(dv); + ViewProviderDrawingView* vpdv = static_cast(vp); + if (vpdv) { + vpdv->stackTop(); + } + } + } +} + +//=========================================================================== +// TechDraw_StackBottom +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawStackBottom) + +CmdTechDrawStackBottom::CmdTechDrawStackBottom() + : Command("TechDraw_StackBottom") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Move view to bottom of stack"); + sToolTipText = sMenuText; + sWhatsThis = "TechDraw_StackBottom"; + sStatusTip = sToolTipText; + sPixmap = "actions/TechDraw_StackBottom"; +} + +void CmdTechDrawStackBottom::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + if (dlg != nullptr) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), + QObject::tr("Close active task dialog and try again.")); + return; + } + + execStackBottom(this); +} + +bool CmdTechDrawStackBottom::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, false); + return (havePage && haveView); +} + +void execStackBottom(Gui::Command* cmd) +{ + TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); + if (!page) { + return; + } + + std::vector views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); + if (!views.empty()) { + for (auto& v: views) { + TechDraw::DrawView* dv = static_cast(v); + Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( + cmd->getDocument())->getViewProvider(dv); + ViewProviderDrawingView* vpdv = static_cast(vp); + if (vpdv) { + vpdv->stackBottom(); + } + } + } +} + +//=========================================================================== +// TechDraw_StackUp +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawStackUp) + +CmdTechDrawStackUp::CmdTechDrawStackUp() + : Command("TechDraw_StackUp") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Move view up one level"); + sToolTipText = sMenuText; + sWhatsThis = "TechDraw_StackUp"; + sStatusTip = sToolTipText; + sPixmap = "actions/TechDraw_StackUp"; +} + +void CmdTechDrawStackUp::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + if (dlg != nullptr) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), + QObject::tr("Close active task dialog and try again.")); + return; + } + + execStackUp(this); +} + +bool CmdTechDrawStackUp::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, false); + return (havePage && haveView); +} + +void execStackUp(Gui::Command* cmd) +{ + TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); + if (!page) { + return; + } + + std::vector views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); + if (!views.empty()) { + for (auto& v: views) { + TechDraw::DrawView* dv = static_cast(v); + Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( + cmd->getDocument())->getViewProvider(dv); + ViewProviderDrawingView* vpdv = static_cast(vp); + if (vpdv) { + vpdv->stackUp(); + } + } + } +} + +//=========================================================================== +// TechDraw_StackDown +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawStackDown) + +CmdTechDrawStackDown::CmdTechDrawStackDown() + : Command("TechDraw_StackDown") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Move view down one level"); + sToolTipText = sMenuText; + sWhatsThis = "TechDraw_StackDown"; + sStatusTip = sToolTipText; + sPixmap = "actions/TechDraw_StackDown"; +} + +void CmdTechDrawStackDown::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + if (dlg != nullptr) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), + QObject::tr("Close active task dialog and try again.")); + return; + } + + execStackDown(this); +} + +bool CmdTechDrawStackDown::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, false); + return (havePage && haveView); +} + +void execStackDown(Gui::Command* cmd) +{ + TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); + if (!page) { + return; + } + + std::vector views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); + if (!views.empty()) { + for (auto& v: views) { + TechDraw::DrawView* dv = static_cast(v); + Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( + cmd->getDocument())->getViewProvider(dv); + ViewProviderDrawingView* vpdv = static_cast(vp); + if (vpdv) { + vpdv->stackDown(); + } + } + } +} + +void CreateTechDrawCommandsStack(void) +{ + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); + + rcCmdMgr.addCommand(new CmdTechDrawStackGroup()); + rcCmdMgr.addCommand(new CmdTechDrawStackTop()); + rcCmdMgr.addCommand(new CmdTechDrawStackBottom()); + rcCmdMgr.addCommand(new CmdTechDrawStackUp()); + rcCmdMgr.addCommand(new CmdTechDrawStackDown()); +} diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 480a2aa8c5..58f9f250a2 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -707,6 +707,22 @@ void QGIView::addArbitraryItem(QGraphicsItem* qgi) } } +void QGIView::setStack(int z) +{ + m_zOrder = z; + setZValue(z); + draw(); +} + +void QGIView::setStackFromVP() +{ + TechDraw::DrawView* feature = getViewObject(); + ViewProviderDrawingView* vpdv = static_cast + (getViewProvider(feature)); + int z = vpdv->getZ(); + setStack(z); +} + QColor QGIView::prefNormalColor() { return PreferencesGui::normalQColor(); diff --git a/src/Mod/TechDraw/Gui/QGIView.h b/src/Mod/TechDraw/Gui/QGIView.h index 7f0751a2e9..7d61e5c09e 100644 --- a/src/Mod/TechDraw/Gui/QGIView.h +++ b/src/Mod/TechDraw/Gui/QGIView.h @@ -136,6 +136,9 @@ public: QColor getSettingColor() { return m_colSetting; } void setSettingColor(QColor color) { m_colSetting = color; } + virtual void setStack(int z); + virtual void setStackFromVP(); + static Gui::ViewProvider* getViewProvider(App::DocumentObject* obj); static ViewProviderPage* getViewProviderPage(TechDraw::DrawView* dView); static QGVPage* getQGVPage(TechDraw::DrawView* dView); @@ -202,6 +205,7 @@ private: double m_lockWidth; double m_lockHeight; int m_dragState; + int m_zOrder; }; diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index d33658baa9..eaa2d3845e 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -41,6 +41,10 @@ icons/actions/TechDraw_ShareView.svg icons/actions/TechDraw_ShowAll.svg icons/actions/TechDraw_SpreadsheetView.svg + icons/actions/TechDraw_StackTop.svg + icons/actions/TechDraw_StackBottom.svg + icons/actions/TechDraw_StackUp.svg + icons/actions/TechDraw_StackDown.svg icons/actions/TechDraw_Symbol.svg icons/actions/TechDraw_Tile.svg icons/actions/TechDraw_ToggleFrame.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackBottom.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackBottom.svg new file mode 100644 index 0000000000..c1436c7516 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackBottom.svg @@ -0,0 +1,699 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [agryson] Alexander Gryson + + + http://agryson.net + + techdraw-view + 2016-01-14 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-view.svg + + + FreeCAD LGPL2+ + + + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackDown.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackDown.svg new file mode 100644 index 0000000000..5d00a41fc8 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackDown.svg @@ -0,0 +1,699 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [agryson] Alexander Gryson + + + http://agryson.net + + techdraw-view + 2016-01-14 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-view.svg + + + FreeCAD LGPL2+ + + + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackTop.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackTop.svg new file mode 100644 index 0000000000..ae5bf8aae0 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackTop.svg @@ -0,0 +1,698 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [agryson] Alexander Gryson + + + http://agryson.net + + techdraw-view + 2016-01-14 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-view.svg + + + FreeCAD LGPL2+ + + + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackUp.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackUp.svg new file mode 100644 index 0000000000..98696d7b90 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_StackUp.svg @@ -0,0 +1,698 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [agryson] Alexander Gryson + + + http://agryson.net + + techdraw-view + 2016-01-14 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-view.svg + + + FreeCAD LGPL2+ + + + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp index 1c33eedaf6..9912224bee 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp @@ -64,6 +64,9 @@ ViewProviderBalloon::ViewProviderBalloon() ADD_PROPERTY_TYPE(LineWidth, (weight), group, (App::PropertyType)(App::Prop_None), "Leader line width"); ADD_PROPERTY_TYPE(LineVisible, (true), group, (App::PropertyType)(App::Prop_None), "Balloon line visible or hidden"); ADD_PROPERTY_TYPE(Color, (PreferencesGui::dimColor()), group, App::Prop_None, "Color of the balloon"); + + //Dimensions take their stacking order from the parent View + StackOrder.setStatus(App::Property::Hidden,true); } ViewProviderBalloon::~ViewProviderBalloon() diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 60b1ce3784..6411f0d1f5 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -85,6 +85,9 @@ ViewProviderDimension::ViewProviderDimension() "Adjusts the gap between dimension point and extension line"); ADD_PROPERTY_TYPE(GapFactorASME, (Preferences::GapASME()), group, App::Prop_None, "Adjusts the gap between dimension point and extension line"); + + //Dimensions take their stacking order from the parent View + StackOrder.setStatus(App::Property::Hidden,true); } ViewProviderDimension::~ViewProviderDimension() diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp index eb2c0928a0..f234bcf3a5 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp @@ -57,6 +57,7 @@ ViewProviderDrawingView::ViewProviderDrawingView() static const char *group = "Base"; ADD_PROPERTY_TYPE(KeepLabel ,(false), group, App::Prop_None, "Keep Label on Page even if toggled off"); + ADD_PROPERTY_TYPE(StackOrder,(0),group,App::Prop_None,"Over or under lap relative to other views"); // Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we // don't use coin. @@ -104,6 +105,13 @@ void ViewProviderDrawingView::onChanged(const App::Property *prop) } } + if (prop == &StackOrder) { + QGIView* qgiv = getQView(); + if (qgiv) { + qgiv->setStack(StackOrder.getValue()); + } + } + Gui::ViewProviderDocumentObject::onChanged(prop); } @@ -315,6 +323,66 @@ void ViewProviderDrawingView::showProgressMessage(const std::string featureName, } } +void ViewProviderDrawingView::stackUp() +{ + QGIView* v = getQView(); + if (v) { + int z = StackOrder.getValue(); + z++; + StackOrder.setValue(z); + v->setStack(z); + } +} + +void ViewProviderDrawingView::stackDown() +{ + QGIView* v = getQView(); + if (v) { + int z = StackOrder.getValue(); + z--; + StackOrder.setValue(z); + v->setStack(z); + } +} + +void ViewProviderDrawingView::stackTop() +{ + Gui::Document* gDoc = getDocument(); + std::vector vps = gDoc->getViewProvidersOfType(TechDrawGui::ViewProviderDrawingView::getClassTypeId()); + int maxZ = 0; + for (auto& vp: vps) { + ViewProviderDrawingView* vpdv = static_cast(vp); + int z = vpdv->StackOrder.getValue(); + if (z > maxZ) { + maxZ = z; + } + } + StackOrder.setValue(maxZ + 1); + QGIView* v = getQView(); + if (v) { + v->setStack(maxZ + 1); + } +} + +void ViewProviderDrawingView::stackBottom() +{ + Gui::Document* gDoc = getDocument(); + std::vector vps = gDoc->getViewProvidersOfType(TechDrawGui::ViewProviderDrawingView::getClassTypeId()); + int minZ = 0; + for (auto& vp: vps) { + ViewProviderDrawingView* vpdv = static_cast(vp); + int z = vpdv->StackOrder.getValue(); + if (z < minZ) { + minZ = z; + } + } + StackOrder.setValue(minZ - 1); + QGIView* v = getQView(); + if (v) { + v->setStack(minZ - 1); + } +} + TechDraw::DrawView* ViewProviderDrawingView::getViewObject() const { return dynamic_cast(pcObject); diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h index 0f2206115c..c9c2d2f430 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h @@ -52,6 +52,7 @@ public: ~ViewProviderDrawingView() override; App::PropertyBool KeepLabel; + App::PropertyInteger StackOrder; void attach(App::DocumentObject *) override; bool useNewSelectionModel() const override {return false;} @@ -86,6 +87,12 @@ public: Connection connectGuiRepaint; Connection connectProgressMessage; + virtual void stackUp(); + virtual void stackDown(); + virtual void stackTop(); + virtual void stackBottom(); + virtual int getZ() {return StackOrder.getValue();} + private: void multiParentPaint(std::vector& pages); void singleParentPaint(const TechDraw::DrawView* dv); diff --git a/src/Mod/TechDraw/Gui/Workbench.cpp b/src/Mod/TechDraw/Gui/Workbench.cpp index 742ebf897c..f1af6f4792 100644 --- a/src/Mod/TechDraw/Gui/Workbench.cpp +++ b/src/Mod/TechDraw/Gui/Workbench.cpp @@ -153,6 +153,14 @@ Gui::MenuItem* Workbench::setupMenuBar() const *annotations << "TechDraw_RichTextAnnotation"; *annotations << "TechDraw_Balloon"; + // stacking + Gui::MenuItem* stacking = new Gui::MenuItem; + stacking->setCommand("Stacking"); + *stacking << "TechDraw_StackTop"; + *stacking << "TechDraw_StackBottom"; + *stacking << "TechDraw_StackUp"; + *stacking << "TechDraw_StackDown"; + // lines Gui::MenuItem* lines = new Gui::MenuItem; lines->setCommand("Add Lines"); @@ -192,6 +200,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const *draw << "Separator"; *draw << "TechDraw_MoveView"; *draw << "TechDraw_ShareView"; + *draw << "Separator"; + *draw << stacking; *draw << dimensions; *draw << toolattrib; *draw << toolcenter; @@ -249,6 +259,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *clips << "TechDraw_ClipGroupAdd"; *clips << "TechDraw_ClipGroupRemove"; + Gui::ToolBarItem *stacking = new Gui::ToolBarItem(root); + stacking->setCommand("TechDraw Stacking"); + *stacking << "TechDraw_StackGroup"; + Gui::ToolBarItem *dims = new Gui::ToolBarItem(root); dims->setCommand("TechDraw Dimensions"); *dims << "TechDraw_LengthDimension"; @@ -391,6 +405,10 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const *clips << "TechDraw_ClipGroupAdd"; *clips << "TechDraw_ClipGroupRemove"; + Gui::ToolBarItem *stacking = new Gui::ToolBarItem(root); + stacking->setCommand("TechDraw Stacking"); + *stacking << "TechDraw_StackGroup"; + Gui::ToolBarItem *dims = new Gui::ToolBarItem(root); dims->setCommand("TechDraw Dimensions"); *dims << "TechDraw_LengthDimension";