00001 /*************************************************************************** 00002 * Copyright (c) 2005 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 #ifndef _PreComp_ 00026 # include <Inventor/VRMLnodes/SoVRMLParent.h> 00027 #endif 00028 00029 #include "SoFCDB.h" 00030 #include "SoFCColorBar.h" 00031 #include "SoFCColorLegend.h" 00032 #include "SoFCColorGradient.h" 00033 #include "SoFCSelection.h" 00034 #include "SoFCBackgroundGradient.h" 00035 #include "SoFCBoundingBox.h" 00036 #include "SoFCSelection.h" 00037 #include "SoFCUnifiedSelection.h" 00038 #include "SoFCSelectionAction.h" 00039 #include "SoFCInteractiveElement.h" 00040 #include "SoFCVectorizeSVGAction.h" 00041 #include "SoFCVectorizeU3DAction.h" 00042 #include "SoAxisCrossKit.h" 00043 #include "SoTextLabel.h" 00044 #include "SoNavigationDragger.h" 00045 #include "Inventor/SoDrawingGrid.h" 00046 00047 #include "propertyeditor/PropertyItem.h" 00048 #include "NavigationStyle.h" 00049 00050 using namespace Gui; 00051 using namespace Gui::Inventor; 00052 using namespace Gui::PropertyEditor; 00053 00054 static SbBool init_done = FALSE; 00055 00056 SbBool Gui::SoFCDB::isInitialized(void) 00057 { 00058 return init_done; 00059 } 00060 00061 void Gui::SoFCDB::init() 00062 { 00063 RotTransDragger ::initClass(); 00064 SoGLRenderActionElement ::initClass(); 00065 SoFCInteractiveElement ::initClass(); 00066 SoGLWidgetElement ::initClass(); 00067 SoFCColorBarBase ::initClass(); 00068 SoFCColorBar ::initClass(); 00069 SoFCColorLegend ::initClass(); 00070 SoFCColorGradient ::initClass(); 00071 SoFCBackgroundGradient ::initClass(); 00072 SoFCBoundingBox ::initClass(); 00073 SoInteraction ::init(); 00074 SoFCSelection ::initClass(); 00075 SoFCUnifiedSelection ::initClass(); 00076 SoFCSelectionAction ::initClass(); 00077 SoFCDocumentAction ::initClass(); 00078 SoGLWidgetNode ::initClass(); 00079 SoFCEnableSelectionAction ::initClass(); 00080 SoFCEnableHighlightAction ::initClass(); 00081 SoFCSelectionColorAction ::initClass(); 00082 SoFCHighlightColorAction ::initClass(); 00083 SoFCDocumentObjectAction ::initClass(); 00084 SoGLSelectAction ::initClass(); 00085 SoVisibleFaceAction ::initClass(); 00086 SoBoxSelectionRenderAction ::initClass(); 00087 SoFCVectorizeSVGAction ::initClass(); 00088 SoFCVectorizeU3DAction ::initClass(); 00089 SoHighlightElementAction ::initClass(); 00090 SoSelectionElementAction ::initClass(); 00091 SoSkipBoundingGroup ::initClass(); 00092 SoTextLabel ::initClass(); 00093 SoStringLabel ::initClass(); 00094 SoFrameLabel ::initClass(); 00095 TranslateManip ::initClass(); 00096 SoShapeScale ::initClass(); 00097 SoAxisCrossKit ::initClass(); 00098 SoDrawingGrid ::initClass(); 00099 00100 PropertyItem ::init(); 00101 PropertySeparatorItem ::init(); 00102 PropertyStringItem ::init(); 00103 PropertyFontItem ::init(); 00104 PropertyIntegerItem ::init(); 00105 PropertyIntegerConstraintItem ::init(); 00106 PropertyFloatItem ::init(); 00107 PropertyUnitItem ::init(); 00108 PropertyFloatConstraintItem ::init(); 00109 PropertyAngleItem ::init(); 00110 PropertyBoolItem ::init(); 00111 PropertyVectorItem ::init(); 00112 PropertyDoubleVectorItem ::init(); 00113 PropertyPlacementItem ::init(); 00114 PropertyEnumItem ::init(); 00115 PropertyStringListItem ::init(); 00116 PropertyColorItem ::init(); 00117 PropertyFileItem ::init(); 00118 PropertyPathItem ::init(); 00119 PropertyTransientFileItem ::init(); 00120 00121 NavigationStyle ::init(); 00122 UserNavigationStyle ::init(); 00123 InventorNavigationStyle ::init(); 00124 CADNavigationStyle ::init(); 00125 BlenderNavigationStyle ::init(); 00126 00127 qRegisterMetaType<Base::Vector3f>("Base::Vector3f"); 00128 qRegisterMetaType<Base::Vector3d>("Base::Vector3d"); 00129 init_done = TRUE; 00130 } 00131 00132 void Gui::SoFCDB::finish() 00133 { 00134 // Coin doesn't provide a mechanism to free static members of own data types. 00135 // Hence, we need to define a static method e.g. 'finish()' for all new types 00136 // to invoke the private member function 'atexit_cleanup()'. 00137 SoFCColorBarBase ::finish(); 00138 SoFCColorBar ::finish(); 00139 SoFCColorLegend ::finish(); 00140 SoFCColorGradient ::finish(); 00141 SoFCBackgroundGradient ::finish(); 00142 SoFCBoundingBox ::finish(); 00143 SoFCSelection ::finish(); 00144 SoFCSelectionAction ::finish(); 00145 SoFCDocumentAction ::finish(); 00146 SoFCDocumentObjectAction ::finish(); 00147 SoFCEnableSelectionAction ::finish(); 00148 SoFCEnableHighlightAction ::finish(); 00149 SoFCSelectionColorAction ::finish(); 00150 SoFCHighlightColorAction ::finish(); 00151 } 00152 00153 // buffer acrobatics for inventor **************************************************** 00154 static char * buffer; 00155 static size_t buffer_size = 0; 00156 static std::string cReturnString; 00157 00158 static void * 00159 buffer_realloc(void * bufptr, size_t size) 00160 { 00161 buffer = (char *)realloc(bufptr, size); 00162 buffer_size = size; 00163 return buffer; 00164 } 00165 00166 const std::string& Gui::SoFCDB::writeNodesToString(SoNode * root) 00167 { 00168 SoOutput out; 00169 buffer = (char *)malloc(1024); 00170 buffer_size = 1024; 00171 out.setBuffer(buffer, buffer_size, buffer_realloc); 00172 if (root && root->getTypeId().isDerivedFrom(SoVRMLParent::getClassTypeId())) 00173 out.setHeaderString("#VRML V2.0 utf8"); 00174 00175 SoWriteAction wa(&out); 00176 wa.apply(root); 00177 00178 cReturnString = buffer; 00179 free(buffer); 00180 return cReturnString; 00181 }