From 381a59bb36342fd091ddedd0e70b28852135fdaf Mon Sep 17 00:00:00 2001 From: blobfish Date: Sun, 9 Aug 2015 11:45:38 -0400 Subject: [PATCH] Core: Gui: SoFCSysDragger: changes to SoFCDB to store dragger. --- src/Gui/SoFCDB.cpp | 17 +++++++++++++++++ src/Gui/SoFCDB.h | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 0ed3b6d0c741..f1cdd03ed77c 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -27,6 +27,7 @@ # include # include # include +# include #endif #include @@ -53,6 +54,7 @@ #include "Inventor/SoDrawingGrid.h" #include "Inventor/SoAutoZoomTranslation.h" #include "Inventor/MarkerBitmaps.h" +#include "SoFCCSysDragger.h" #include "propertyeditor/PropertyItem.h" #include "NavigationStyle.h" @@ -64,6 +66,7 @@ using namespace Gui::Inventor; using namespace Gui::PropertyEditor; static SbBool init_done = false; +static SoGroup *storage = nullptr; SbBool Gui::SoFCDB::isInitialized(void) { @@ -112,6 +115,7 @@ void Gui::SoFCDB::init() SoDrawingGrid ::initClass(); SoAutoZoomTranslation ::initClass(); MarkerBitmaps ::initClass(); + SoFCCSysDragger ::initClass(); PropertyItem ::init(); PropertySeparatorItem ::init(); @@ -160,6 +164,10 @@ void Gui::SoFCDB::init() qRegisterMetaType("Base::Quantity"); qRegisterMetaType >("Base::QuantityList"); init_done = true; + + assert(!storage); + storage = new SoGroup(); + storage->ref(); } void Gui::SoFCDB::finish() @@ -181,6 +189,9 @@ void Gui::SoFCDB::finish() SoFCEnableHighlightAction ::finish(); SoFCSelectionColorAction ::finish(); SoFCHighlightColorAction ::finish(); + + storage->unref(); + storage = nullptr; } // buffer acrobatics for inventor **************************************************** @@ -287,3 +298,9 @@ bool Gui::SoFCDB::writeToFile(SoNode* node, const char* filename, bool binary) return ret; } + +SoGroup* Gui::SoFCDB::getStorage() +{ + assert(storage); //call init first. + return storage; +} diff --git a/src/Gui/SoFCDB.h b/src/Gui/SoFCDB.h index 9e9d0a82c837..129f4e045d36 100644 --- a/src/Gui/SoFCDB.h +++ b/src/Gui/SoFCDB.h @@ -28,9 +28,10 @@ #include class SoNode; +class SoGroup; namespace Gui { /** - * The FreeCAD database class to initialioze all onw Inventor nodes. + * The FreeCAD database class to initialize all our own Inventor nodes. * @author Werner Mayer */ class GuiExport SoFCDB @@ -44,6 +45,10 @@ class GuiExport SoFCDB static bool writeToVRML(SoNode* node, const char* filename, bool binary); // Write to VRML or Inventor file static bool writeToFile(SoNode* node, const char* filename, bool binary); + /*! container for app lifetime storage. See SoFCCSysDragger for details + * on why this is needed. + */ + static SoGroup* getStorage(); }; } // namespace Gui