-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Model_Document.h>
#include <TDataStd_AsciiString.hxx>
#include <TDF_Reference.hxx>
#include <TDF_ChildIDIterator.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <TDF_Delta.hxx>
#include <TDF_AttributeDelta.hxx>
#include <TDF_AttributeDeltaList.hxx>
return this == Model_Session::get()->moduleDocument().get();
}
+// LCOV_EXCL_START
/// Makes all modification and generation naming shapes that have old shapes corresponding to
/// shapes in a root document be equal to this root document
static void updateShapesFromRoot(const TDF_Label theThisAccess, const TDF_Label theRootAccess)
}
}
}
+// LCOV_EXCL_STOP
bool Model_Document::load(const char* theDirName, const char* theFileName, DocumentPtr theThis)
{
}
bool isError = aStatus != PCDM_RS_OK;
if (isError) {
+ // LCOV_EXCL_START
switch (aStatus) {
case PCDM_RS_UnknownDocument:
Events_InfoMessage("Model_Document", "Can not open document").send();
Events_InfoMessage("Model_Document", "Can not open document: unknown error").send();
break;
}
+ // LCOV_EXCL_STOP
}
std::shared_ptr<Model_Session> aSession =
std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
Handle(Model_Application) anApp = Model_Application::getApplication();
if (isRoot()) {
#ifdef WIN32
- CreateDirectory((LPTSTR) theDirName, NULL);
+ size_t aDirLen = strlen(theDirName);
+ std::wstring aWStr(aDirLen, L'#');
+ mbstowcs(&aWStr[0], theDirName, aDirLen);
+ CreateDirectory(aWStr.c_str(), NULL);
#else
mkdir(theDirName, 0x1ff);
#endif
}
myObjs->synchronizeBackRefs();
Events_Loop* aLoop = Events_Loop::loop();
- static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
- static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
- static const Events_ID kRedispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static const Events_ID kDeletedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED);
+ static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
+ static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ static const Events_ID kRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const Events_ID kDeletedEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
aLoop->flush(kCreatedEvent);
aLoop->flush(kUpdatedEvent);
aLoop->flush(kRedispEvent);
// update the current features status
setCurrentFeature(currentFeature(false), false);
}
-
+// this is used for creation of undo/redo1-list by GUI
+// LCOV_EXCL_START
std::list<std::string> Model_Document::undoList() const
{
std::list<std::string> aResult;
}
return aResult;
}
+// LCOV_EXCL_STOP
void Model_Document::operationId(const std::string& theId)
{
aCurrent = aSub;
}
}
+ // #2861: if the parameter is added, add it after parameters existing in the list
+ if (aCurrent.get() &&
+ (aFeature->getKind() == "Parameter" || aFeature->getKind() == "ParametersMgr")) {
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
+ for(FeaturePtr aNextFeat = myObjs->nextFeature(aCurrent, anIndex);
+ aNextFeat.get() && aNextFeat->getKind() == "Parameter";
+ aNextFeat = myObjs->nextFeature(aCurrent, anIndex))
+ aCurrent = aNextFeat;
+ }
}
aDocToAdd->myObjs->addFeature(aFeature, aCurrent);
if (!aFeature->isAction()) { // do not add action to the data model
return aFeature;
}
-
void Model_Document::refsToFeature(FeaturePtr theFeature,
std::set<std::shared_ptr<ModelAPI_Feature> >& theRefs, const bool isSendError)
{
{
myObjs->removeFeature(theFeature);
// fix for #2723: send signal that part is updated
- if (!isRoot()) {
+ if (!isRoot() && isOperation()) {
std::shared_ptr<Model_Document> aRoot =
std::dynamic_pointer_cast<Model_Document>(ModelAPI_Session::get()->moduleDocument());
std::list<ResultPtr> allParts;
return isSub(theMain, aParent);
}
-
void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
{
bool aCurrentUp = theMoved == currentFeature(false);
FeaturePtr anAfterThisSub = theAfterThis;
if (aCompositeAfter.get()) {
FeaturePtr aSub = aCompositeAfter;
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
do {
- FeaturePtr aNext = myObjs->nextFeature(aSub);
+ FeaturePtr aNext = myObjs->nextFeature(aSub, anIndex);
if (!isSub(aCompositeAfter, aNext)) {
anAfterThisSub = aSub;
break;
TDF_Label aLab = aRef->Get();
FeaturePtr aResult = myObjs->feature(aLab);
if (theVisible) { // get nearest visible (in history) going up
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
while(aResult.get() && !aResult->isInHistory()) {
- aResult = myObjs->nextFeature(aResult, true);
+ aResult = myObjs->nextFeature(aResult, anIndex, true);
}
}
return aResult;
if (theVisible && !theCurrent.get()) {
// needed to avoid disabling of PartSet initial constructions
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
FeaturePtr aNext =
- theCurrent.get() ? myObjs->nextFeature(theCurrent) : myObjs->firstFeature();
- for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent)) {
+ theCurrent.get() ? myObjs->nextFeature(theCurrent, anIndex, false) : myObjs->firstFeature();
+ for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent, anIndex, false)) {
if (aNext->isInHistory()) {
break; // next in history is not needed
} else { // next not in history is good for making current
FeaturePtr anIter = myObjs->lastFeature();
bool aWasChanged = false;
bool isCurrentParameter = theCurrent.get() && theCurrent->getKind() == "Parameter";
- for(; anIter.get(); anIter = myObjs->nextFeature(anIter, true)) {
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
+ for(; anIter.get(); anIter = myObjs->nextFeature(anIter, anIndex, true)) {
// check this before passed become enabled: the current feature is enabled!
if (anIter == theCurrent) aPassed = true;
// problems if it is true: here and in "setCurrentFeature"
FeaturePtr aCurrent = currentFeature(false);
if (aCurrent.get()) { // if not, do nothing because null is the upper
- FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true);
+ int anIndex = kUNDEFINED_FEATURE_INDEX;
+ FeaturePtr aPrev = myObjs->nextFeature(aCurrent, anIndex, true);
// make the higher level composite as current (sketch becomes disabled if line is enabled)
if (aPrev.get()) {
FeaturePtr aComp = ModelAPI_Tools::compositeOwner(aPrev);
return myObjs->feature(theResult);
}
-Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper)
-{
- return TDF_LabelMapHasher::HashCode(theLab, theUpper);
-
-}
-Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2)
-{
- return TDF_LabelMapHasher::IsEqual(theLab1, theLab2);
-}
-
FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) {
TDF_Label aCurrentLab = theLab;
while(aCurrentLab.Depth() > 3)
return ResultPtr(); // not found
}
-
void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName)
{
std::map<std::string, std::list<TDF_Label> >::iterator aFind = myNamingNames.find(theName);
Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value());
std::string aName = TCollection_AsciiString(aSubName->Get()).ToCString();
if (aName.find(theOldName) == 0) { // started from parent name
- std::string aNewSubName = theNewName + aName.substr(theNewName.size());
+ std::string aNewSubName = theNewName + aName.substr(theOldName.size());
changeNamingName(aName, aNewSubName, aSubName->Label());
aSubName->Set(aNewSubName.c_str());
}
int aNewVal = transactionID() + 1;
TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal);
}
-void Model_Document::decrementTransactionID()
-{
- int aNewVal = transactionID() - 1;
- TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal);
-}
TDF_Label Model_Document::extConstructionsLabel() const
{
return myObjs->internalFeature(theIndex);
}
-std::shared_ptr<ModelAPI_Feature> Model_Document::featureById(const int theId)
-{
- return myObjs->featureById(theId);
-}
-
void Model_Document::synchronizeTransactions()
{
Model_Document* aRoot =
return myObjs->isLater(theLater, theCurrent);
}
+// Object Browser nodes states
+// LCOV_EXCL_START
void Model_Document::storeNodesState(const std::list<bool>& theStates)
{
TDF_Label aLab = generalLabel().FindChild(TAG_NODES_STATE);
}
}
}
+// LCOV_EXCL_STOP
void Model_Document::eraseAllFeatures()
{