/*************************************************************************** * Copyright (c) 2008 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * * 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" #ifndef _PreComp_ # include #endif #include "Workbench.h" #include #include #include #include #include #include #include using namespace PartDesignGui; #if 0 // needed for Qt's lupdate utility qApp->translate("Workbench", "Part Design"); qApp->translate("Gui::TaskView::TaskWatcherCommands", "Face tools"); qApp->translate("Gui::TaskView::TaskWatcherCommands", "Sketch tools"); qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry"); #endif extern PartDesign::Body *ActivePartObject; /// @namespace PartDesignGui @class Workbench TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench) Workbench::Workbench() { } Workbench::~Workbench() { } void Workbench::activated() { Gui::Workbench::activated(); std::vector Watcher; const char* Edge[] = { "PartDesign_Fillet", "PartDesign_Chamfer", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( "SELECT Part::Feature SUBELEMENT Edge COUNT 1..", Edge, "Edge tools", "Part_Box" )); const char* Face[] = { "PartDesign_NewSketch", "PartDesign_Fillet", "PartDesign_Chamfer", // "PartDesign_Draft", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( "SELECT Part::Feature SUBELEMENT Face COUNT 1", Face, "Face tools", "Part_Box" )); const char* Faces[] = { "PartDesign_Fillet", "PartDesign_Chamfer", // "PartDesign_Draft", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( "SELECT Part::Feature SUBELEMENT Face COUNT 2..", Faces, "Face tools", "Part_Box" )); const char* Sketch[] = { "PartDesign_NewSketch", "PartDesign_Pad", "PartDesign_Pocket", "PartDesign_Revolution", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( "SELECT Sketcher::SketchObject COUNT 1", Sketch, "Sketch tools", "Part_Box" )); // const char* Transformed[] = { // "PartDesign_Mirrored", // "PartDesign_LinearPattern", // "PartDesign_PolarPattern", //// "PartDesign_Scaled", // "PartDesign_MultiTransform", // 0}; // Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( // "SELECT PartDesign::SketchBased", // Transformed, // "Transformation tools", // "PartDesign_MultiTransform" // )); const char* Empty[] = { "PartDesign_NewSketch", "Part_Box", "Part_Cylinder", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptySelection( Empty, "Create Geometry", "Part_Box" )); // set the previous used active Body if(oldActive != "") Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(App.activeDocument().%s)",oldActive.c_str()); addTaskWatcher(Watcher); Gui::Control().showTaskView(); } void Workbench::deactivated() { removeTaskWatcher(); // remember the body for later activation if(ActivePartObject) oldActive = ActivePartObject->getNameInDocument(); else oldActive = ""; // reset the active Body Gui::Command::doCommand(Gui::Command::Doc,"import PartDesignGui"); Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(None)"); Gui::Workbench::deactivated(); } Gui::MenuItem* Workbench::setupMenuBar() const { Gui::MenuItem* root = StdWorkbench::setupMenuBar(); Gui::MenuItem* item = root->findItem("&Windows"); Gui::MenuItem* geom = new Gui::MenuItem(); geom->setCommand("Sketcher geometries"); SketcherGui::addSketcherWorkbenchGeometries( *geom ); Gui::MenuItem* cons = new Gui::MenuItem(); cons->setCommand("Sketcher constraints"); SketcherGui::addSketcherWorkbenchConstraints( *cons ); Gui::MenuItem* consaccel = new Gui::MenuItem(); consaccel->setCommand("Sketcher tools"); SketcherGui::addSketcherWorkbenchTools(*consaccel); Gui::MenuItem* part = new Gui::MenuItem; root->insertItem(item, part); part->setCommand("&Part Design"); SketcherGui::addSketcherWorkbenchSketchActions( *part ); *part << "PartDesign_NewSketch" << "Sketcher_LeaveSketch" << "Sketcher_ViewSketch" << "Sketcher_MapSketch" << geom << cons << consaccel << "Separator" << "PartDesign_Pad" << "PartDesign_Pocket" << "PartDesign_Revolution" // << "PartDesign_Groove" << "PartDesign_Fillet" << "PartDesign_Chamfer"; // << "PartDesign_Draft" // << "PartDesign_Mirrored" // << "PartDesign_LinearPattern" // << "PartDesign_PolarPattern" // << "PartDesign_Scaled" // << "PartDesign_MultiTransform"; // For 0.13 a couple of python packages like numpy, matplotlib and others // are not deployed with the installer on Windows. Thus, the WizardShaft is // not deployed either hence the check for the existence of the command. if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_InvoluteGear")) { *part << "PartDesign_InvoluteGear"; } if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_WizardShaft")) { *part << "Separator" << "PartDesign_WizardShaft"; } return root; } Gui::ToolBarItem* Workbench::setupToolBars() const { Gui::ToolBarItem* root = StdWorkbench::setupToolBars(); Gui::ToolBarItem* part = new Gui::ToolBarItem(root); part->setCommand("Part Design"); // TODO: reenable features than rebasing // SketcherGui::addSketcherWorkbenchSketchActions( *part ); *part << "PartDesign_NewSketch" << "Sketcher_LeaveSketch" << "Separator" << "PartDesign_Pad" << "PartDesign_Pocket" << "PartDesign_Revolution" // << "PartDesign_Groove" << "PartDesign_Fillet" << "PartDesign_Chamfer"; // << "PartDesign_Draft" // << "PartDesign_Mirrored" // << "PartDesign_LinearPattern" // << "PartDesign_PolarPattern" // << "PartDesign_Scaled" // << "PartDesign_MultiTransform"; Gui::ToolBarItem* geom = new Gui::ToolBarItem(root); geom->setCommand("Sketcher geometries"); SketcherGui::addSketcherWorkbenchGeometries( *geom ); Gui::ToolBarItem* cons = new Gui::ToolBarItem(root); cons->setCommand("Sketcher constraints"); SketcherGui::addSketcherWorkbenchConstraints( *cons ); Gui::ToolBarItem* consaccel = new Gui::ToolBarItem(root); consaccel->setCommand("Sketcher tools"); SketcherGui::addSketcherWorkbenchTools( *consaccel ); return root; } Gui::ToolBarItem* Workbench::setupCommandBars() const { // Part tools Gui::ToolBarItem* root = new Gui::ToolBarItem; return root; }