diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index b918943a6a..15ef3085c8 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -294,7 +294,7 @@ CmdTechDrawView::CmdTechDrawView() : Command("TechDraw_View") sAppModule = "TechDraw"; sGroup = QT_TR_NOOP("TechDraw"); sMenuText = QT_TR_NOOP("Insert View"); - sToolTipText = QT_TR_NOOP("Insert a View"); + sToolTipText = QT_TR_NOOP("Insert a View in current page. You can select Shapes, SpreadSheets or Section Plane from Arch Workbench objects."); sWhatsThis = "TechDraw_View"; sStatusTip = sToolTipText; sPixmap = "actions/TechDraw_View"; @@ -303,23 +303,62 @@ CmdTechDrawView::CmdTechDrawView() : Command("TechDraw_View") void CmdTechDrawView::activated(int iMsg) { Q_UNUSED(iMsg); + bool viewCreated = false; + TechDraw::DrawPage* page = DrawGuiUtil::findPage(this); + if (!page) { + return; + } + std::string PageName = page->getNameInDocument(); //set projection direction from selected Face //use first object with a face selected - std::vector shapes; - std::vector xShapes; + std::vector shapes, xShapes; App::DocumentObject* partObj = nullptr; std::string faceName; - Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement;//mystery - bool single = false; //mystery - auto selection = getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(), - resolve, single); + auto selection = getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId()); for (auto& sel : selection) { bool is_linked = false; auto obj = sel.getObject(); - if (obj->isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) { + if (obj->isDerivedFrom() || obj->isDerivedFrom()) { continue; } + + if (obj->isDerivedFrom()) { + std::string SpreadName = obj->getNameInDocument(); + + openCommand(QT_TRANSLATE_NOOP("Command", "Create spreadsheet view")); + std::string FeatName = getUniqueObjectName("Sheet"); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSpreadsheet', '%s')", + FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawViewSpreadsheet', 'Sheet', '%s')", + FeatName.c_str(), FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", FeatName.c_str(), + SpreadName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), + FeatName.c_str()); + updateActive(); + commitCommand(); + viewCreated = true; + continue; + } + else if (DrawGuiUtil::isArchSection(obj)) { + std::string FeatName = getUniqueObjectName("ArchView"); + std::string SourceName = obj->getNameInDocument(); + openCommand(QT_TRANSLATE_NOOP("Command", "Create ArchView")); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewArch', '%s')", + FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawViewArch', 'ArchView', '%s')", + FeatName.c_str(), FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", FeatName.c_str(), + SourceName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), + FeatName.c_str()); + updateActive(); + commitCommand(); + viewCreated = true; + continue; + } + if (obj->isDerivedFrom(App::LinkElement::getClassTypeId()) || obj->isDerivedFrom(App::LinkGroup::getClassTypeId()) || obj->isDerivedFrom(App::Link::getClassTypeId())) { @@ -365,19 +404,15 @@ void CmdTechDrawView::activated(int iMsg) } if (shapes.empty() && xShapes.empty()) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("No Shapes, Groups or Links in this selection")); + if (!viewCreated) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), + QObject::tr("No Suitable objects in this selection")); + } return; } - TechDraw::DrawPage* page = DrawGuiUtil::findPage(this); - if (!page) { - return; - } - std::string PageName = page->getNameInDocument(); Base::Vector3d projDir; - Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Create view")); std::string FeatName = getUniqueObjectName("View"); @@ -1493,15 +1528,14 @@ void CmdTechDrawDraftView::activated(int iMsg) std::string PageName = page->getNameInDocument(); std::pair dirs = DrawGuiUtil::get3DDirAndRot(); - for (std::vector::iterator it = objects.begin(); it != objects.end(); - ++it) { - if ((*it)->isDerivedFrom(TechDraw::DrawPage::getClassTypeId()) || - (*it)->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { + for (auto* obj : objects) { + if (obj->isDerivedFrom(TechDraw::DrawPage::getClassTypeId()) || + obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { // skip over TechDraw objects as they are not valid subjects for a DraftView continue; } std::string FeatName = getUniqueObjectName("DraftView"); - std::string SourceName = (*it)->getNameInDocument(); + std::string SourceName = obj->getNameInDocument(); openCommand(QT_TRANSLATE_NOOP("Command", "Create DraftView")); doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDraft', '%s')", FeatName.c_str()); diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_View.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_View.svg index 8de5db7f71..1756706e19 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_View.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_View.svg @@ -1,146 +1,623 @@ - - - - + + + - - - - + + + + + - - - - + + + + + - - - - - + + + + - - - - + + + + - - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - - - - + + + + + + + + + + + - - - - + - + image/svg+xml - - + [agryson] Alexander Gryson http://agryson.net - + TechDraw_View 2016-01-14 https://www.freecad.org/wiki/index.php?title=Artwork @@ -161,24 +638,130 @@ - - - - - - - + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Workbench.cpp b/src/Mod/TechDraw/Gui/Workbench.cpp index 50832dd029..9da46e3014 100644 --- a/src/Mod/TechDraw/Gui/Workbench.cpp +++ b/src/Mod/TechDraw/Gui/Workbench.cpp @@ -298,8 +298,6 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *views << "TechDraw_SectionGroup"; *views << "TechDraw_DetailView"; *views << "TechDraw_DraftView"; - *views << "TechDraw_ArchView"; - *views << "TechDraw_SpreadsheetView"; *views << "TechDraw_ClipGroup"; *views << "TechDraw_ProjectShape"; @@ -405,7 +403,6 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const *views << "TechDraw_SectionGroup"; *views << "TechDraw_DetailView"; *views << "TechDraw_DraftView"; - *views << "TechDraw_SpreadsheetView"; *views << "TechDraw_ClipGroup"; *views << "TechDraw_ProjectShape";