Mod/PartDesign/Gui/Workbench.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #ifndef _PreComp_
00027 # include <qobject.h>
00028 #endif
00029 
00030 #include "Workbench.h"
00031 #include <Gui/MenuManager.h>
00032 #include <Gui/ToolBarManager.h>
00033 #include <Gui/Control.h>
00034 
00035 using namespace PartDesignGui;
00036 
00037 #if 0 // needed for Qt's lupdate utility
00038     qApp->translate("Workbench", "Part Design");
00039     qApp->translate("Gui::TaskView::TaskWatcherCommands", "Face tools");
00040     qApp->translate("Gui::TaskView::TaskWatcherCommands", "Sketch tools");
00041     qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry");
00042 #endif
00043 
00045 TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench)
00046 
00047 Workbench::Workbench()
00048 {
00049 }
00050 
00051 Workbench::~Workbench()
00052 {
00053 }
00054 
00055 void Workbench::activated()
00056 {
00057     Gui::Workbench::activated();
00058 
00059 
00060     std::vector<Gui::TaskView::TaskWatcher*> Watcher;
00061 
00062     //Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00063     //    "FROM Robot SELECT TrajectoryObject COUNT 1"
00064     //    "FROM Robot SELECT RobotObject COUNT 1",
00065     //    RobotAndTrac,
00066     //    "Trajectory tools",
00067     //    "Robot_InsertWaypoint"
00068     //));
00069 
00070     //Watcher.push_back(new TaskWatcherRobot);
00071 
00072     const char* Face[] = {
00073         "Sketcher_NewSketch",
00074         "PartDesign_Fillet",
00075         "PartDesign_Chamfer",
00076         0};
00077     Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00078         "SELECT Part::Feature SUBELEMENT Face COUNT 1",
00079         Face,
00080         "Face tools",
00081         "Part_Box"
00082     ));
00083 
00084     const char* Sketch[] = {
00085         "Sketcher_NewSketch",
00086         "PartDesign_Pad",
00087         "PartDesign_Pocket",
00088         "PartDesign_Revolution",
00089         0};
00090     Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00091         "SELECT Sketcher::SketchObject COUNT 1",
00092         Sketch,
00093         "Sketch tools",
00094         "Part_Box"
00095     ));
00096 
00097     const char* Empty[] = {
00098         "Sketcher_NewSketch",
00099         "Part_Box",
00100         "Part_Cylinder",
00101         0};
00102    Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptyDoc(
00103          Empty,
00104         "Create Geometry",
00105         "Part_Box"
00106     ));
00107 
00108     
00109     addTaskWatcher(Watcher);
00110     Gui::Control().showTaskView();
00111 }
00112 
00113 void Workbench::deactivated()
00114 {
00115     Gui::Workbench::deactivated();
00116     removeTaskWatcher();
00117 
00118 }
00119 
00120 Gui::MenuItem* Workbench::setupMenuBar() const
00121 {
00122     Gui::MenuItem* root = StdWorkbench::setupMenuBar();
00123     Gui::MenuItem* item = root->findItem("&Windows");
00124 
00125     Gui::MenuItem* geom = new Gui::MenuItem();
00126     geom->setCommand("Sketcher geometries");
00127     *geom /*<< "Sketcher_CreatePoint"*/
00128           << "Sketcher_CreateArc"
00129           << "Sketcher_CreateCircle"
00130           << "Sketcher_CreateLine"
00131           << "Sketcher_CreatePolyline"
00132           << "Sketcher_CreateRectangle"
00133           << "Sketcher_CreateFillet"
00134           << "Sketcher_Trimming"
00135           << "Sketcher_ToggleConstruction"
00136           /*<< "Sketcher_CreateText"*/
00137           /*<< "Sketcher_CreateDraftLine"*/;
00138 
00139     Gui::MenuItem* cons = new Gui::MenuItem();
00140     cons->setCommand("Sketcher constraints");
00141     *cons << "Sketcher_ConstrainLock"
00142           << "Sketcher_ConstrainCoincident"
00143           << "Sketcher_ConstrainPointOnObject"
00144           << "Sketcher_ConstrainDistanceX"
00145           << "Sketcher_ConstrainDistanceY"
00146           << "Sketcher_ConstrainVertical"
00147           << "Sketcher_ConstrainHorizontal"
00148           << "Sketcher_ConstrainDistance"
00149           << "Sketcher_ConstrainRadius"
00150           << "Sketcher_ConstrainParallel"
00151           << "Sketcher_ConstrainPerpendicular"
00152           << "Sketcher_ConstrainAngle"
00153           << "Sketcher_ConstrainTangent"
00154           << "Sketcher_ConstrainEqual"
00155           << "Sketcher_ConstrainSymmetric"
00156           ;
00157 
00158     Gui::MenuItem* part = new Gui::MenuItem;
00159     root->insertItem(item, part);
00160     part->setCommand("&Part Design");
00161     *part << "Sketcher_NewSketch" 
00162           << "Sketcher_LeaveSketch"
00163           << "Sketcher_ViewSketch"
00164           << "Sketcher_MapSketch"
00165           << geom
00166           << cons
00167           << "Separator" 
00168           << "PartDesign_Pad" 
00169           << "PartDesign_Pocket"
00170           << "PartDesign_Revolution" 
00171           << "PartDesign_Fillet"
00172           << "PartDesign_Chamfer";
00173 
00174     return root;
00175 }
00176 
00177 Gui::ToolBarItem* Workbench::setupToolBars() const
00178 {
00179     Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
00180     Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
00181     part->setCommand("Part Design");
00182     *part << "Sketcher_NewSketch" 
00183           << "Sketcher_LeaveSketch"
00184           << "Separator" 
00185           << "PartDesign_Pad" 
00186           << "PartDesign_Pocket" 
00187           << "PartDesign_Revolution" 
00188           << "PartDesign_Fillet"
00189           << "PartDesign_Chamfer";
00190        
00191     part = new Gui::ToolBarItem(root);
00192     part->setCommand("Sketcher geometries");
00193     *part /*<< "Sketcher_CreatePoint" */
00194                   << "Sketcher_CreateArc"
00195                   << "Sketcher_CreateCircle"
00196                   << "Sketcher_CreateLine"
00197                   << "Sketcher_CreatePolyline"
00198                   << "Sketcher_CreateRectangle"
00199           << "Sketcher_CreateFillet"
00200           << "Sketcher_Trimming"
00201                   << "Sketcher_ToggleConstruction"
00202                   /*<< "Sketcher_CreateText"*/
00203                   /*<< "Sketcher_CreateDraftLine"*/;
00204 
00205     part = new Gui::ToolBarItem(root);
00206     part->setCommand("Sketcher constraints");
00207     *part << "Sketcher_ConstrainLock"
00208           << "Sketcher_ConstrainCoincident"
00209           << "Sketcher_ConstrainPointOnObject"
00210           << "Sketcher_ConstrainDistanceX"
00211           << "Sketcher_ConstrainDistanceY"
00212           << "Sketcher_ConstrainVertical"
00213           << "Sketcher_ConstrainHorizontal"
00214           << "Sketcher_ConstrainDistance"
00215           << "Sketcher_ConstrainRadius"
00216           << "Sketcher_ConstrainParallel"
00217           << "Sketcher_ConstrainPerpendicular"
00218           << "Sketcher_ConstrainAngle"
00219           << "Sketcher_ConstrainTangent"
00220           << "Sketcher_ConstrainEqual"
00221           << "Sketcher_ConstrainSymmetric"
00222           ;
00223 
00224      return root;
00225 }
00226 
00227 Gui::ToolBarItem* Workbench::setupCommandBars() const
00228 {
00229     // Part tools
00230     Gui::ToolBarItem* root = new Gui::ToolBarItem;
00231     return root;
00232 }
00233 

Generated on Wed Nov 23 19:01:11 2011 for FreeCAD by  doxygen 1.6.1