aDSTag = aFLabIter.Value()->Label().Tag();
}
if (aDSTag > aFeatureTag) { // feature is removed
- Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP);
- Model_FeatureDeletedMessage aMsg2(aThis, (*aFIter)->getGroup());
+ FeaturePtr aFeature = *aFIter;
aFIter = myFeatures.erase(aFIter);
// event: model is updated
- Events_Loop::loop()->send(aMsg1);
+ if (aFeature->isInHistory()) {
+ Model_FeatureDeletedMessage aMsg1(aThis, FEATURES_GROUP);
+ Events_Loop::loop()->send(aMsg1);
+ }
+ Model_FeatureDeletedMessage aMsg2(aThis, aFeature->getGroup());
Events_Loop::loop()->send(aMsg2);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
#include <Model.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_Document.h>
#include <TDataStd_Name.hxx>
MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();}
/// Returns to which group in the document must be added feature
- MODEL_EXPORT virtual const std::string& getGroup() {return myRef->getGroup();}
+ MODEL_EXPORT virtual const std::string& getGroup() {return FEATURES_GROUP;}
/// Returns document this feature belongs to
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <Model_Events.h>
+#include <ModelAPI_Object.h>
#include <Events_Loop.h>
if (aDoc == myDocument) { // If root objects
if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Update only Parts group
// Add a new part
- int aStart = myPartModels.size() + 1;
+ int aStart = myPartModels.size();
XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this);
aModel->setPartId(myPartModels.count());
myPartModels.append(aModel);
int aStart = myPartModels.size() - 1;
removeSubModel(aStart);
removeRow(aStart, partFolderNode());
+ if (myActivePart && (!isPartSubModel(myActivePart))) {
+ myActivePart = 0;
+ myActivePartIndex = QModelIndex();
+ myModel->setItemsColor(ACTIVE_COLOR);
+ }
} else { // Update top groups (other except parts
QModelIndex aIndex = myModel->findGroup(aGroup);
int aStart = myModel->rowCount(aIndex);
if (myActivePart)
myActivePart->setItemsColor(PASSIVE_COLOR);
myActivePart = 0;
+ myActivePartIndex = QModelIndex();
myModel->setItemsColor(ACTIVE_COLOR);
}
QModelIndex XGUI_DocumentDataModel::partIndex(const FeaturePtr& theFeature) const
{
+ FeaturePtr aFeature = theFeature;
+ if (!aFeature->data()) {
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
+ aFeature = aObject->featureRef();
+ }
int aRow = -1;
XGUI_PartModel* aModel = 0;
foreach (XGUI_PartModel* aPartModel, myPartModels) {
aRow++;
- if (aPartModel->part() == theFeature) {
+ if (aPartModel->part() == aFeature) {
aModel = aPartModel;
break;
}
Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
aLoop->registerListener(this, aFeatureUpdatedId);
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
activateModule();
if (myMainWindow) {
}
}
- // Process deletion of a part
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- if (aMgr->currentDocument() == aMgr->rootDocument())
- activatePart(FeaturePtr()); // Activate PartSet
- }
-
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.
static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);