AppPartGui.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU Library General Public License as       *
00005  *   published by the Free Software Foundation; either version 2 of the    *
00006  *   License, or (at your option) any later version.                       *
00007  *   for detail see the LICENCE text file.                                 *
00008  *   Jürgen Riegel 2002                                                    *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 
00013 #include "PreCompiled.h"
00014 #ifndef _PreComp_
00015 # include <Standard_math.hxx>
00016 #endif
00017 
00018 #include <Base/Console.h>
00019 #include <Base/Interpreter.h>
00020 
00021 #include <Gui/Application.h>
00022 #include <Gui/BitmapFactory.h>
00023 #include <Gui/WidgetFactory.h>
00024 
00025 #include <Mod/Part/App/PropertyTopoShape.h>
00026 
00027 #include "SoBrepShape.h"
00028 #include "SoFCShapeObject.h"
00029 #include "ViewProvider.h"
00030 #include "ViewProviderExt.h"
00031 #include "ViewProviderPython.h"
00032 #include "ViewProviderBox.h"
00033 #include "ViewProviderCurveNet.h"
00034 #include "ViewProviderImport.h"
00035 #include "ViewProviderExtrusion.h"
00036 #include "ViewProvider2DObject.h"
00037 #include "ViewProviderMirror.h"
00038 #include "ViewProviderBoolean.h"
00039 
00040 #include "DlgSettingsGeneral.h"
00041 #include "DlgSettings3DViewPartImp.h"
00042 #include "Workbench.h"
00043 
00044 #include <Gui/Language/Translator.h>
00045 #include "qrc_Part.cpp"
00046 
00047 #include "Resources/icons/PartFeature.xpm"
00048 #include "Resources/icons/PartFeatureImport.xpm"
00049 
00050 // use a different name to CreateCommand()
00051 void CreatePartCommands(void);
00052 void CreateSimplePartCommands(void);
00053 void CreateParamPartCommands(void);
00054 
00055 void loadPartResource()
00056 {
00057     // add resources and reloads the translators
00058     Q_INIT_RESOURCE(Part);
00059     Gui::Translator::instance()->refresh();
00060 }
00061 
00062 /* registration table  */
00063 static struct PyMethodDef PartGui_methods[] = {
00064     {NULL, NULL}                   /* end of table marker */
00065 };
00066 
00067 extern "C" {
00068 void PartGuiExport initPartGui()
00069 {
00070     if (!Gui::Application::Instance) {
00071         PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
00072         return;
00073     }
00074 
00075     // load needed modules
00076     try {
00077         Base::Interpreter().runString("import Part");
00078     }
00079     catch(const Base::Exception& e) {
00080         PyErr_SetString(PyExc_ImportError, e.what());
00081         return;
00082     }
00083 
00084     (void) Py_InitModule("PartGui", PartGui_methods);   /* mod name, table ptr */
00085     Base::Console().Log("Loading GUI of Part module... done\n");
00086 
00087     PartGui::SoBrepFaceSet              ::initClass();
00088     PartGui::SoBrepEdgeSet              ::initClass();
00089     PartGui::SoBrepPointSet             ::initClass();
00090     PartGui::SoFCControlPoints          ::initClass();
00091     PartGui::ViewProviderPartBase       ::init();
00092     PartGui::ViewProviderPartExt        ::init();
00093     PartGui::ViewProviderPart           ::init();
00094     PartGui::ViewProviderEllipsoid      ::init();
00095     PartGui::ViewProviderPython         ::init();
00096     PartGui::ViewProviderBox            ::init();
00097     PartGui::ViewProviderImport         ::init();
00098     PartGui::ViewProviderCurveNet       ::init();
00099     PartGui::ViewProviderExtrusion      ::init();
00100     PartGui::ViewProvider2DObject       ::init();
00101     PartGui::ViewProvider2DObjectPython ::init();
00102     PartGui::ViewProviderMirror         ::init();
00103     PartGui::ViewProviderFillet         ::init();
00104     PartGui::ViewProviderChamfer        ::init();
00105     PartGui::ViewProviderCustom         ::init();
00106     PartGui::ViewProviderCustomPython   ::init();
00107     PartGui::ViewProviderBoolean        ::init();
00108     PartGui::ViewProviderMultiFuse      ::init();
00109     PartGui::ViewProviderMultiCommon    ::init();
00110 
00111     PartGui::Workbench                  ::init();
00112 
00113     // instantiating the commands
00114     CreatePartCommands();
00115     CreateSimplePartCommands();
00116     CreateParamPartCommands();
00117 
00118     // register preferences pages
00119     (void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>      ( QT_TRANSLATE_NOOP("QObject","Part design") );
00120     (void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>   ( QT_TRANSLATE_NOOP("QObject","Part design") );
00121     Gui::ViewProviderBuilder::add(
00122         Part::PropertyPartShape::getClassTypeId(),
00123         PartGui::ViewProviderPart::getClassTypeId());
00124 
00125     // add resources and reloads the translators
00126     loadPartResource();
00127 
00128     // register bitmaps
00129     Gui::BitmapFactoryInst& rclBmpFactory = Gui::BitmapFactory();
00130     rclBmpFactory.addXPM("PartFeature",(const char**) PartFeature_xpm);
00131     rclBmpFactory.addXPM("PartFeatureImport",(const char**) PartFeatureImport_xpm);
00132 }
00133 } // extern "C"

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