AppRobotGui.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de)              *
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 #ifndef _PreComp_
00026 # include <Python.h>
00027 #endif
00028 
00029 #include <Base/Console.h>
00030 #include <Base/Interpreter.h>
00031 #include <Gui/Application.h>
00032 #include <Gui/Language/Translator.h>
00033 #include "ViewProviderRobotObject.h"
00034 #include "ViewProviderTrajectory.h"
00035 #include "ViewProviderEdge2TracObject.h"
00036 #include "ViewProviderTrajectoryDressUp.h"
00037 #include "ViewProviderTrajectoryCompound.h"
00038 #include "Workbench.h"
00039 //#include "resources/qrc_Robot.cpp"
00040 
00041 // use a different name to CreateCommand()
00042 void CreateRobotCommands(void);
00043 void CreateRobotCommandsExport(void);
00044 void CreateRobotCommandsInsertRobots(void);
00045 void CreateRobotCommandsTrajectory(void);
00046 
00047 void loadRobotResource()
00048 {
00049     // add resources and reloads the translators
00050     Q_INIT_RESOURCE(Robot);
00051     Gui::Translator::instance()->refresh();
00052 }
00053 
00054 /* registration table  */
00055 extern struct PyMethodDef RobotGui_Import_methods[];
00056 
00057 
00058 /* Python entry */
00059 extern "C" {
00060 void RobotGuiExport initRobotGui()  
00061 {
00062      if (!Gui::Application::Instance) {
00063         PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
00064         return;
00065     }
00066     try {
00067         Base::Interpreter().runString("import PartGui");
00068         Base::Interpreter().runString("import Part");
00069         Base::Interpreter().runString("import Robot");
00070         // set some default values
00071         // default speed for trajectory is 1m/s
00072         Base::Interpreter().runString("_DefSpeed = '1 m/s'");
00073         // default Cintinuity is off
00074         Base::Interpreter().runString("_DefCont = False");
00075         // default Cintinuity is off
00076         Base::Interpreter().runString("_DefAccelaration = '1 m/s^2'");
00077         // default orientation of a waypoint if no other constraint
00078         Base::Interpreter().runString("_DefOrientation = FreeCAD.Rotation()");
00079         // default displacement while e.g. picking
00080         Base::Interpreter().runString("_DefDisplacement = FreeCAD.Vector(0,0,0)");
00081     }
00082     catch(const Base::Exception& e) {
00083         PyErr_SetString(PyExc_ImportError, e.what());
00084         return;
00085     }
00086     (void) Py_InitModule("RobotGui", RobotGui_Import_methods);   /* mod name, table ptr */
00087     Base::Console().Log("Loading GUI of Robot module... done\n");
00088 
00089     // instantiating the commands
00090     CreateRobotCommands();
00091     CreateRobotCommandsExport();
00092     CreateRobotCommandsInsertRobots();
00093     CreateRobotCommandsTrajectory();
00094 
00095     // addition objects
00096     RobotGui::Workbench                      ::init();
00097         RobotGui::ViewProviderRobotObject        ::init();
00098         RobotGui::ViewProviderTrajectory         ::init();
00099         RobotGui::ViewProviderEdge2TracObject    ::init();
00100         RobotGui::ViewProviderTrajectoryCompound ::init();
00101         RobotGui::ViewProviderTrajectoryDressUp  ::init();
00102 
00103      // add resources and reloads the translators
00104     loadRobotResource();
00105 }
00106 
00107 } // extern "C" {

Generated on Wed Nov 23 18:59:56 2011 for FreeCAD by  doxygen 1.6.1