#include <LightApp_Study.h>
#include <CAM_Application.h>
+#include <CAM_DataObject.h>
#include <SUIT_Tools.h>
#include <SUIT_ResourceMgr.h>
void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)
{
+ // Nothing to do here: we always keep the data tree in the up-to-date state
+ // The only goal of this method is to hide default behavior from LightApp_DataModel
+ return;
+}
+
+void NewGeom_DataModel::initRootObject()
+{
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
+ CAM_ModuleObject *aModelRoot = dynamic_cast<CAM_ModuleObject*>(root());
+ if(study && aModelRoot == NULL) {
+ aModelRoot = createModuleObject( study->root() );
+ aModelRoot->setDataModel( this );
+ setRoot(aModelRoot);
+ }
}
void NewGeom_DataModel::removeDirectory(const QString& theDirectoryName)
/// Returns True if the data structure is already saved
virtual bool isSaved() const;
+ /// Creates a module root object if it has not been created yet
+ /// and append it to the active study. It is necessary for correct persistent
+ /// of the model.
+ void initRootObject();
+
/// Update data object
/// \param theObj an data object
/// \param theStudy a current study
bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
{
bool isDone = LightApp_Module::activateModule(theStudy);
+ NewGeom_DataModel* aDataModel = dynamic_cast<NewGeom_DataModel*>(dataModel());
+ aDataModel->initRootObject();
+
if (isDone) {
setMenuShown(true);
setToolShown(true);
//******************************************************
CAM_DataModel* NewGeom_Module::createDataModel()
{
- NewGeom_DataModel* aDataModel = new NewGeom_DataModel(this);
-
- // Calling addComponent() for persistent functionality work in the SalomeApp_Study
- LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(application()->activeStudy() );
- aStudy->addComponent(aDataModel);
-
- return aDataModel;
+ return new NewGeom_DataModel(this);
}
QAction* NewGeom_Module::addFeature(const QString& theWBName, const ActionInfo& theInfo)