From dd7bd833c68a86d546e6863a615a427781dea721 Mon Sep 17 00:00:00 2001 From: "Michael G. Hansen" Date: Tue, 19 Aug 2014 15:07:02 +0200 Subject: [PATCH] Fix bug 1643: Projections are always added to the first drawing page --- src/Mod/Drawing/Gui/Command.cpp | 19 +++++++++---------- src/Mod/Drawing/Gui/TaskOrthoViews.cpp | 5 ++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Mod/Drawing/Gui/Command.cpp b/src/Mod/Drawing/Gui/Command.cpp index 7cacf8561..f4f6d0030 100644 --- a/src/Mod/Drawing/Gui/Command.cpp +++ b/src/Mod/Drawing/Gui/Command.cpp @@ -319,23 +319,22 @@ CmdDrawingOrthoViews::CmdDrawingOrthoViews() void CmdDrawingOrthoViews::activated(int iMsg) { - std::vector shapes = getSelection().getObjectsOfType(Part::Feature::getClassTypeId()); + const std::vector shapes = getSelection().getObjectsOfType(Part::Feature::getClassTypeId()); if (shapes.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select a Part object.")); + QObject::tr("Select exactly one Part object.")); return; } - std::vector pages = getSelection().getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); + // Check that a page object exists. TaskDlgOrthoViews will then check for a selected page object + // and use that, otherwise it will use the first page in the document. + const std::vector pages = this->getDocument()->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); if (pages.empty()) { - pages = this->getDocument()->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); - if (pages.empty()){ - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No page found"), - QObject::tr("Create a page first.")); - return; - } + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No page found"), + QObject::tr("Create a page first.")); + return; } - + Gui::Control().showDialog(new TaskDlgOrthoViews()); } diff --git a/src/Mod/Drawing/Gui/TaskOrthoViews.cpp b/src/Mod/Drawing/Gui/TaskOrthoViews.cpp index 0a9fb12fb..2474d235f 100644 --- a/src/Mod/Drawing/Gui/TaskOrthoViews.cpp +++ b/src/Mod/Drawing/Gui/TaskOrthoViews.cpp @@ -858,7 +858,10 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent) const char * part = obj.front()->getNameInDocument(); App::Document * doc = App::GetApplication().getActiveDocument(); - vector pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); + vector pages = Gui::Selection().getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); + if (pages.empty()) { + pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); + } string PageName = pages.front()->getNameInDocument(); const char * page = PageName.c_str();