Skip to content

Commit

Permalink
Core: Gui: SoFCSysDragger: changes to SoFCDB to store dragger.
Browse files Browse the repository at this point in the history
  • Loading branch information
blobfish authored and wwmayer committed May 7, 2016
1 parent 56e5837 commit 381a59b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Gui/SoFCDB.cpp
Expand Up @@ -27,6 +27,7 @@
# include <Inventor/VRMLnodes/SoVRMLGroup.h>
# include <Inventor/VRMLnodes/SoVRMLParent.h>
# include <Inventor/SbString.h>
# include <Inventor/nodes/SoGroup.h>
#endif

#include <Base/FileInfo.h>
Expand All @@ -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"
Expand All @@ -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)
{
Expand Down Expand Up @@ -112,6 +115,7 @@ void Gui::SoFCDB::init()
SoDrawingGrid ::initClass();
SoAutoZoomTranslation ::initClass();
MarkerBitmaps ::initClass();
SoFCCSysDragger ::initClass();

PropertyItem ::init();
PropertySeparatorItem ::init();
Expand Down Expand Up @@ -160,6 +164,10 @@ void Gui::SoFCDB::init()
qRegisterMetaType<Base::Quantity>("Base::Quantity");
qRegisterMetaType<QList<Base::Quantity> >("Base::QuantityList");
init_done = true;

assert(!storage);
storage = new SoGroup();
storage->ref();
}

void Gui::SoFCDB::finish()
Expand All @@ -181,6 +189,9 @@ void Gui::SoFCDB::finish()
SoFCEnableHighlightAction ::finish();
SoFCSelectionColorAction ::finish();
SoFCHighlightColorAction ::finish();

storage->unref();
storage = nullptr;
}

// buffer acrobatics for inventor ****************************************************
Expand Down Expand Up @@ -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;
}
7 changes: 6 additions & 1 deletion src/Gui/SoFCDB.h
Expand Up @@ -28,9 +28,10 @@
#include <Inventor/SbBasic.h>

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
Expand All @@ -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
Expand Down

0 comments on commit 381a59b

Please sign in to comment.