if (isModified)
aName->Set(theName.c_str());
}
- // to do not cause the update of the result on name change
- /*if (isModified) {
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
- ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
- }*/
}
void Model_Data::addAttribute(const std::string& theID, const std::string theAttrType)
bool Model_Document::load(const char* theFileName)
{
Handle(Model_Application) anApp = Model_Application::getApplication();
- if (this == Model_Session::get()->rootDocument().get()) {
+ if (this == Model_Session::get()->moduleDocument().get()) {
anApp->setLoadPath(theFileName);
}
TCollection_ExtendedString aPath(DocFileName(theFileName, myID));
bool Model_Document::save(const char* theFileName, std::list<std::string>& theResults)
{
// create a directory in the root document if it is not yet exist
- if (this == Model_Session::get()->rootDocument().get()) {
+ if (this == Model_Session::get()->moduleDocument().get()) {
#ifdef WIN32
CreateDirectory(theFileName, NULL);
#else
if (isDone) { // save also sub-documents if any
theResults.push_back(TCollection_AsciiString(aPath).ToCString());
std::set<std::string>::iterator aSubIter = mySubs.begin();
- for (; aSubIter != mySubs.end() && isDone; aSubIter++)
- isDone = subDocument(*aSubIter)->save(theFileName, theResults);
+ for (; aSubIter != mySubs.end() && isDone; aSubIter++) {
+ isDone = subDoc(*aSubIter)->save(theFileName, theResults);
+ }
}
return isDone;
}
void Model_Document::close()
{
boost::shared_ptr<ModelAPI_Session> aPM = Model_Session::get();
- if (this != aPM->rootDocument().get() && this == aPM->currentDocument().get()) {
- aPM->setCurrentDocument(aPM->rootDocument());
+ if (this != aPM->moduleDocument().get() && this == aPM->activeDocument().get()) {
+ aPM->setActiveDocument(aPM->moduleDocument());
}
// close all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->close();
+ subDoc(*aSubIter)->close();
mySubs.clear();
// close this
/* do not close because it can be undoed
// new command for all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->startOperation();
+ subDoc(*aSubIter)->startOperation();
}
void Model_Document::compactNested()
// finish for all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->finishOperation();
+ subDoc(*aSubIter)->finishOperation();
}
void Model_Document::abortOperation()
// abort for all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->abortOperation();
+ subDoc(*aSubIter)->abortOperation();
}
bool Model_Document::isOperation()
bool Model_Document::isModified()
{
// is modified if at least one operation was commited and not undoed
- return myTransactionsAfterSave > 0;
+ return myTransactionsAfterSave > 0 || isOperation();
}
bool Model_Document::canUndo()
// check other subs contains operation that can be undoed
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- if (subDocument(*aSubIter)->canUndo())
+ if (subDoc(*aSubIter)->canUndo())
return true;
return false;
}
// undo for all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->undo();
+ subDoc(*aSubIter)->undo();
}
bool Model_Document::canRedo()
// check other subs contains operation that can be redoed
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- if (subDocument(*aSubIter)->canRedo())
+ if (subDoc(*aSubIter)->canRedo())
return true;
return false;
}
// redo for all subs
std::set<std::string>::iterator aSubIter = mySubs.begin();
for (; aSubIter != mySubs.end(); aSubIter++)
- subDocument(*aSubIter)->redo();
+ subDoc(*aSubIter)->redo();
}
/// Appenad to the array of references a new referenced label
return Model_Application::getApplication()->getDocument(theDocID);
}
+boost::shared_ptr<Model_Document> Model_Document::subDoc(std::string theDocID)
+{
+ // just store sub-document identifier here to manage it later
+ if (mySubs.find(theDocID) == mySubs.end())
+ mySubs.insert(theDocID);
+ return boost::dynamic_pointer_cast<Model_Document>(
+ Model_Application::getApplication()->getDocument(theDocID));
+}
+
ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex,
const bool theHidden)
{
aNewBody = createBody(theFeature->data(), aResIndex);
} else if (anArgLab.IsAttribute(ID_PART)) {
aNewBody = createPart(theFeature->data(), aResIndex);
- } else if (!anArgLab.IsAttribute(ID_CONSTRUCTION)) {
- Events_Error::send("Unknown type of result if found in the document");
+ } else if (!anArgLab.IsAttribute(ID_CONSTRUCTION) && anArgLab.FindChild(1).HasAttribute()) {
+ Events_Error::send("Unknown type of result is found in the document");
}
if (aNewBody) {
theFeature->setResult(aNewBody, aResIndex);
//! Adds a new sub-document by the identifier, or returns existing one if it is already exist
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
+ //! Internal sub-document by ID
+ MODEL_EXPORT virtual boost::shared_ptr<Model_Document> subDoc(std::string theDocID);
+
///! Returns the id of hte document
MODEL_EXPORT virtual const std::string& id() const
{
}
}
if (aDocRef->value())
- ModelAPI_Session::get()->setCurrentDocument(aDocRef->value());
+ ModelAPI_Session::get()->setActiveDocument(aDocRef->value());
}
static Model_Session* myImpl = new Model_Session();
+// t oredirect all calls to the root document
+#define ROOT_DOC boost::dynamic_pointer_cast<Model_Document>(moduleDocument())
+
+bool Model_Session::load(const char* theFileName)
+{
+ return ROOT_DOC->load(theFileName);
+}
+
+bool Model_Session::save(const char* theFileName, std::list<std::string>& theResults)
+{
+ return ROOT_DOC->save(theFileName, theResults);
+}
+
+void Model_Session::startOperation()
+{
+ ROOT_DOC->startOperation();
+}
+
+void Model_Session::finishOperation()
+{
+ ROOT_DOC->finishOperation();
+}
+
+void Model_Session::abortOperation()
+{
+ ROOT_DOC->abortOperation();
+}
+
+bool Model_Session::isOperation()
+{
+ return ROOT_DOC->isOperation();
+}
+
+bool Model_Session::isModified()
+{
+ return ROOT_DOC->isModified();
+}
+
+bool Model_Session::canUndo()
+{
+ return ROOT_DOC->canUndo();
+}
+
+void Model_Session::undo()
+{
+ ROOT_DOC->undo();
+}
+
+bool Model_Session::canRedo()
+{
+ return ROOT_DOC->canRedo();
+}
+
+void Model_Session::redo()
+{
+ ROOT_DOC->redo();
+}
+
FeaturePtr Model_Session::createFeature(string theFeatureID)
{
if (this != myImpl)
return FeaturePtr(); // return nothing
}
-boost::shared_ptr<ModelAPI_Document> Model_Session::rootDocument()
+boost::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
{
return boost::shared_ptr<ModelAPI_Document>(
Model_Application::getApplication()->getDocument("root"));
}
-bool Model_Session::hasRootDocument()
+bool Model_Session::hasModuleDocument()
{
return Model_Application::getApplication()->hasDocument("root");
}
-boost::shared_ptr<ModelAPI_Document> Model_Session::currentDocument()
+boost::shared_ptr<ModelAPI_Document> Model_Session::activeDocument()
{
if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id()))
- myCurrentDoc = rootDocument();
+ myCurrentDoc = moduleDocument();
return myCurrentDoc;
}
-void Model_Session::setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
+void Model_Session::setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
{
myCurrentDoc = theDoc;
static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged"));
}
}
} else { // create/update/delete
- if (myCheckTransactions && !rootDocument()->isOperation())
+ if (myCheckTransactions && !isOperation())
Events_Error::send("Modification of data structure outside of the transaction");
}
}
boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
public:
+
+ //! Loads the OCAF document from the file.
+ //! \param theFileName full name of the file to load
+ //! \param theStudyID identifier of the SALOME study to associate with loaded file
+ //! \returns true if file was loaded successfully
+ MODEL_EXPORT virtual bool load(const char* theFileName);
+
+ //! Saves the OCAF document to the file.
+ //! \param theFileName full name of the file to store
+ //! \param theResults the result full file names that were stored by "save"
+ //! \returns true if file was stored successfully
+ MODEL_EXPORT virtual bool save(const char* theFileName, std::list<std::string>& theResults);
+
+ //! Starts a new operation (opens a tansaction)
+ MODEL_EXPORT virtual void startOperation();
+ //! Finishes the previously started operation (closes the transaction)
+ MODEL_EXPORT virtual void finishOperation();
+ //! Aborts the operation
+ MODEL_EXPORT virtual void abortOperation();
+ //! Returns true if operation has been started, but not yet finished or aborted
+ MODEL_EXPORT virtual bool isOperation();
+ //! Returns true if document was modified (since creation/opening)
+ MODEL_EXPORT virtual bool isModified();
+
+ //! Returns True if there are available Undos
+ MODEL_EXPORT virtual bool canUndo();
+ //! Undoes last operation
+ MODEL_EXPORT virtual void undo();
+ //! Returns True if there are available Redos
+ MODEL_EXPORT virtual bool canRedo();
+ //! Redoes last operation
+ MODEL_EXPORT virtual void redo();
+
/// Returns the root document of the application (that may contains sub-documents)
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> rootDocument();
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> moduleDocument();
/// Return true if root document has been already created
- MODEL_EXPORT virtual bool hasRootDocument();
+ MODEL_EXPORT virtual bool hasModuleDocument();
/// Returns the current document that used for current work in the application
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> currentDocument();
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> activeDocument();
/// Defines the current document that used for current work in the application
- MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
+ MODEL_EXPORT virtual void setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
/// Registers the plugin that creates features.
/// It is obligatory for each plugin to call this function on loading to be found by
class ModelAPI_Document
{
public:
- //! Loads the OCAF document from the file.
- //! \param theFileName full name of the file to load
- //! \param theStudyID identifier of the SALOME study to associate with loaded file
- //! \returns true if file was loaded successfully
- virtual bool load(const char* theFileName) = 0;
-
- //! Saves the OCAF document to the file.
- //! \param theFileName full name of the file to store
- //! \param theResults the result full file names that were stored by "save"
- //! \returns true if file was stored successfully
- virtual bool save(const char* theFileName, std::list<std::string>& theResults) = 0;
-
//! Removes document data
virtual void close() = 0;
- //! Starts a new operation (opens a tansaction)
- virtual void startOperation() = 0;
- //! Finishes the previously started operation (closes the transaction)
- virtual void finishOperation() = 0;
- //! Aborts the operation
- virtual void abortOperation() = 0;
- //! Returns true if operation has been started, but not yet finished or aborted
- virtual bool isOperation() = 0;
- //! Returns true if document was modified (since creation/opening)
- virtual bool isModified() = 0;
-
- //! Returns True if there are available Undos
- virtual bool canUndo() = 0;
- //! Undoes last operation
- virtual void undo() = 0;
- //! Returns True if there are available Redos
- virtual bool canRedo() = 0;
- //! Redoes last operation
- virtual void redo() = 0;
-
//! Adds to the document the new feature of the given feature id
//! \param creates feature and puts it in the document (if it is not action)
virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
virtual boost::shared_ptr<ModelAPI_Document>
- subDocument(std::string theDocID) = 0;
+ subDocument(std::string theDocID) = 0;
///! Returns the id of the document
virtual const std::string& id() const = 0;
boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
{
- return ModelAPI_Session::get()->currentDocument();
+ return ModelAPI_Session::get()->activeDocument();
}
ModelAPI_Feature::~ModelAPI_Feature()
#include "ModelAPI.h"
#include <string>
+#include <list>
#include <boost/shared_ptr.hpp>
class ModelAPI_Feature;
/// Returns the real implementation (the alone instance per application) of the plugin manager
static boost::shared_ptr<ModelAPI_Session> get();
+ //! Loads the OCAF document from the file.
+ //! \param theFileName full name of the file to load
+ //! \param theStudyID identifier of the SALOME study to associate with loaded file
+ //! \returns true if file was loaded successfully
+ virtual bool load(const char* theFileName) = 0;
+
+ //! Saves the OCAF document to the file.
+ //! \param theFileName full name of the file to store
+ //! \param theResults the result full file names that were stored by "save"
+ //! \returns true if file was stored successfully
+ virtual bool save(const char* theFileName, std::list<std::string>& theResults) = 0;
+
+ //! Starts a new operation (opens a tansaction)
+ virtual void startOperation() = 0;
+ //! Finishes the previously started operation (closes the transaction)
+ virtual void finishOperation() = 0;
+ //! Aborts the operation
+ virtual void abortOperation() = 0;
+ //! Returns true if operation has been started, but not yet finished or aborted
+ virtual bool isOperation() = 0;
+ //! Returns true if document was modified (since creation/opening)
+ virtual bool isModified() = 0;
+
+ //! Returns True if there are available Undos
+ virtual bool canUndo() = 0;
+ //! Undoes last operation
+ virtual void undo() = 0;
+ //! Returns True if there are available Redos
+ virtual bool canRedo() = 0;
+ //! Redoes last operation
+ virtual void redo() = 0;
+
/// Registers the plugin that creates features.
/// It is obligatory for each plugin to call this function on loading to be found by
/// the plugin manager on call of the feature)
virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
/// Returns the root document of the application (that may contains sub-documents)
- virtual boost::shared_ptr<ModelAPI_Document> rootDocument() = 0;
+ virtual boost::shared_ptr<ModelAPI_Document> moduleDocument() = 0;
/// Return true if root document has been already created
- virtual bool hasRootDocument() = 0;
+ virtual bool hasModuleDocument() = 0;
/// Returns the current document that used for current work in the application
- virtual boost::shared_ptr<ModelAPI_Document> currentDocument() = 0;
+ virtual boost::shared_ptr<ModelAPI_Document> activeDocument() = 0;
/// Defines the current document that used for current work in the application
- virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
+ virtual void setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
/// Copies the document to the new one with the given id
virtual boost::shared_ptr<ModelAPI_Document> copy(boost::shared_ptr<ModelAPI_Document> theSource,
boost::shared_ptr<ModelAPI_Document> ModuleBase_IOperation::document() const
{
- return ModelAPI_Session::get()->rootDocument();
+ return ModelAPI_Session::get()->moduleDocument();
}
void ModuleBase_IOperation::start()
{
- document()->startOperation();
+ ModelAPI_Session::get()->startOperation();
startOperation();
emit started();
stopOperation();
- document()->abortOperation();
+ ModelAPI_Session::get()->abortOperation();
emit stopped();
}
stopOperation();
- document()->finishOperation();
+ ModelAPI_Session::get()->finishOperation();
emit stopped();
afterCommitOperation();
if (aPreviewOp) {
// create a line
- boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_Session::get()->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_Session::get()->moduleDocument();
FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID());
if (aFeature) // TODO: generate an error if feature was not created
aFeature->execute();
boost::shared_ptr<ModelAPI_Document> PartSet_Tools::document()
{
- return ModelAPI_Session::get()->rootDocument();
+ return ModelAPI_Session::get()->moduleDocument();
}
void PartSet_Tools::setFeaturePoint(FeaturePtr theFeature, double theX, double theY,
data()->addAttribute(ORIGIN_REF(), ModelAPI_AttributeRefAttr::type());
boost::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
- boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
boost::shared_ptr<ModelAPI_ResultPart> aSource; // searching for source document attribute
for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
aSource = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aRoot->object(getGroup(), a));
if (aSource && aSource->data()
&& aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()
- == aPManager->currentDocument())
+ == aPManager->activeDocument())
break;
aSource.reset();
}
if (!aDocRef->value()) { // create a document if not yet created
boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
- ModelAPI_Session::get()->rootDocument();
+ ModelAPI_Session::get()->moduleDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
}
*/
boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()
{
- return ModelAPI_Session::get()->rootDocument();
+ return ModelAPI_Session::get()->moduleDocument();
}
void PartSetPlugin_Remove::execute()
{
boost::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
- boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
boost::shared_ptr<ModelAPI_Document> aCurrent;
boost::shared_ptr<PartSetPlugin_Part> a;
for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
aRoot->object(ModelAPI_ResultPart::group(), a));
if (aPart
&& aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()
- == aPManager->currentDocument()) {
+ == aPManager->activeDocument()) {
FeaturePtr aFeature = aRoot->feature(aPart);
if (aFeature) {
// do remove
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
if (aPart) {
- if (aMgr->currentDocument() == aPart->partDoc())
+ if (aMgr->activeDocument() == aPart->partDoc())
aMenu->addAction(action("DEACTIVATE_PART_CMD"));
else
aMenu->addAction(action("ACTIVATE_PART_CMD"));
aMenu->addAction(action("SHOW_ONLY_CMD"));
}
} else { // If feature is 0 the it means that selected root object (document)
- if (aMgr->currentDocument() != aMgr->rootDocument())
+ if (aMgr->activeDocument() != aMgr->moduleDocument())
aMenu->addAction(action("ACTIVATE_PART_CMD"));
}
} else if (aSelected >= 1) {
void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
// Created object event *******************
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
void XGUI_DocumentDataModel::rebuildDataTree()
{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
beginResetModel();
clearModelIndexes();
case HistoryNode:
{
int aOffset = historyOffset();
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
if (!aFeature)
int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
{
if (!theParent.isValid()) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
// Size of external models
int aVal = historyOffset();
// Plus history size
if (theIndex.internalId() == PartsFolder)
return ObjectPtr();
if (theIndex.internalId() == HistoryNode) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
int aOffset = historyOffset();
return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
}
QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
{
// Check that this feature belongs to root document
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
DocumentPtr aDoc = theObject->document();
if (aDoc == aRootDoc) {
// This feature belongs to histrory or top model
QString aRes = aEditor->text();
ObjectPtr aFeature = mySelectedData.first();
SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->rootDocument()->startOperation();
+ aMgr->startOperation();
aFeature->data()->setName(qPrintable(aRes));
- aMgr->rootDocument()->finishOperation();
+ aMgr->finishOperation();
}
}
aLabelLay->addWidget(aLbl);
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->moduleDocument();
// TODO: Find a name of the root document
myActiveDocLbl = new QLineEdit(tr("Part set"), aLabelWgt);
if (toSave) {
// TODO: Save the name of root document
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->moduleDocument();
} else {
myActiveDocLbl->setText(myActiveDocLbl->property("OldText").toString());
}
case ParamsFolder:
return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
case ParamObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
if (aObject)
return aObject->data()->name().c_str();
case ConstructFolder:
return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
case ConstructObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(),
theIndex.row());
if (aObject)
case BodiesFolder:
return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
case BodiesObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row());
if (aObject)
return aObject->data()->name().c_str();
if (!theParent.isValid())
return 3;
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
if (theParent.internalId() == ParamsFolder)
return aRootDoc->size(ModelAPI_ResultParameters::group());
case BodiesFolder:
return ObjectPtr();
case ParamObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row());
}
case ConstructObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
}
case BodiesObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
return aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row());
}
}
{
QModelIndex aIndex;
if (theObject) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
std::string aGroup = theObject->groupName();
int aNb = aRootDoc->size(aGroup);
int aRow = -1;
// return a name
switch (theIndex.internalId()) {
case MyRoot: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
if (aObject)
return boost::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid()) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
if (aRootDoc->object(ModelAPI_ResultPart::group(), myId))
return 1;
else
DocumentPtr XGUI_PartDataModel::partDocument() const
{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
return aPart->partDoc();
{
switch (theIndex.internalId()) {
case MyRoot: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
return aRootDoc->object(ModelAPI_ResultPart::group(), myId);
}
case ParamsFolder:
ResultPartPtr XGUI_PartDataModel::part() const
{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
return boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
}
}
if (!isSalomeMode()) {
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified() != myMainWindow->isModifiedState())
- myMainWindow->setModifiedState(aDoc->isModified());
+ if (aMgr->isModified() != myMainWindow->isModifiedState())
+ myMainWindow->setModifiedState(aMgr->isModified());
}
}
{
QApplication::restoreOverrideCursor();
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- aDoc->save(theName.toLatin1().constData(), theFileNames);
+ aMgr->save(theName.toLatin1().constData(), theFileNames);
QApplication::restoreOverrideCursor();
}
void XGUI_Workshop::onExit()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified()) {
+ if (aMgr->isModified()) {
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
{
//save current file before close if modified
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isModified()) {
+ if (aMgr->isModified()) {
//TODO(sbh): re-launch the app?
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"),
} else if (anAnswer == QMessageBox::Cancel) {
return;
}
- aDoc->close();
+ aMgr->moduleDocument()->close();
myCurrentDir = "";
}
return;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
- aDoc->load(myCurrentDir.toLatin1().constData());
+ aMgr->load(myCurrentDir.toLatin1().constData());
myObjectBrowser->rebuildDataTree();
displayAllResults();
updateCommandStatus();
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isOperation())
+ if (aMgr->isOperation())
operationMgr()->abortOperation();
- aDoc->undo();
+ aMgr->undo();
updateCommandStatus();
}
{
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- if (aDoc->isOperation())
+ if (aMgr->isOperation())
operationMgr()->abortOperation();
- aDoc->redo();
+ aMgr->redo();
updateCommandStatus();
}
aCommands.append(aCmd);
}
SessionPtr aMgr = ModelAPI_Session::get();
- if (aMgr->hasRootDocument()) {
+ if (aMgr->hasModuleDocument()) {
QAction* aUndoCmd;
QAction* aRedoCmd;
foreach(QAction* aCmd, aCommands)
// Enable all commands
aCmd->setEnabled(true);
}
- DocumentPtr aDoc = aMgr->rootDocument();
- aUndoCmd->setEnabled(aDoc->canUndo());
- aRedoCmd->setEnabled(aDoc->canRedo());
+ aUndoCmd->setEnabled(aMgr->canUndo());
+ aRedoCmd->setEnabled(aMgr->canRedo());
} else {
foreach(QAction* aCmd, aCommands)
{
if (aPart) {
DocumentPtr aPartDoc = aPart->partDoc();
if (aPartDoc) {
- aMgr->setCurrentDocument(aPartDoc);
+ aMgr->setActiveDocument(aPartDoc);
return;
}
}
}
- aMgr->setCurrentDocument(aMgr->rootDocument());
+ aMgr->setActiveDocument(aMgr->moduleDocument());
}
//******************************************************
void XGUI_Workshop::activateLastPart()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->moduleDocument();
std::string aGrpName = ModelAPI_ResultPart::group();
ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
// ToDo: definbe deleting method
if (aRes == QMessageBox::Yes) {
SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->rootDocument()->startOperation();
+ aMgr->startOperation();
foreach (ObjectPtr aObj, theList)
{
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
if (aPart) {
DocumentPtr aDoc = aPart->document();
- if (aDoc == aMgr->currentDocument()) {
+ if (aDoc == aMgr->activeDocument()) {
aDoc->close();
}
- //aMgr->rootDocument()->removeFeature(aPart->owner());
+ //aMgr->moduleDocument()->removeFeature(aPart->owner());
} else {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
if (aFeature)
}
}
myDisplayer->updateViewer();
- aMgr->rootDocument()->finishOperation();
+ aMgr->finishOperation();
}
}
void XGUI_Workshop::displayAllResults()
{
SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aRootDoc = aMgr->rootDocument();
+ DocumentPtr aRootDoc = aMgr->moduleDocument();
displayDocumentResults(aRootDoc);
for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);