ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex)
{
if (theGroupID == ModelAPI_Feature::group()) {
- std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+ // features may be not in history but in the myObjs, so, iterate all
+ int anIndex = 0;
+ std::map<std::string, std::vector<ObjectPtr> >::iterator aFind =
+ myObjs.find(ModelAPI_Feature::group());
if (aFind != myObjs.end()) {
- int aSize = aFind->second.size();
- if (theIndex >= 0 && theIndex < aSize)
- return aFind->second[theIndex];
+ std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+ for(; aFIter != aFind->second.end(); aFIter++) {
+ if ((*aFIter)->isInHistory()) {
+ if (theIndex == anIndex)
+ return *aFIter;
+ anIndex++;
+ }
+ }
}
} else {
// iterate all features in order to find the needed result
{
int aResult = 0;
if (theGroupID == ModelAPI_Feature::group()) {
- std::map<std::string, std::vector<ObjectPtr> >::iterator aFind = myObjs.find(theGroupID);
+ // features may be not in history but in the myObjs, so, iterate all
+ std::map<std::string, std::vector<ObjectPtr> >::iterator aFind =
+ myObjs.find(ModelAPI_Feature::group());
if (aFind != myObjs.end()) {
- aResult = aFind->second.size();
+ std::vector<ObjectPtr>::iterator aFIter = aFind->second.begin();
+ for(; aFIter != aFind->second.end(); aFIter++) {
+ if ((*aFIter)->isInHistory()) {
+ aResult++;
+ }
+ }
}
} else {
// iterate all features in order to find the needed result
if (theObject) myObjects.insert(theObject);
}
-std::set<ObjectPtr> Model_ObjectUpdatedMessage::features() const
+std::set<ObjectPtr> Model_ObjectUpdatedMessage::objects() const
{
return myObjects;
}
public:
/// Returns the feature that has been updated
- virtual std::set<ObjectPtr> features() const;
+ virtual std::set<ObjectPtr> objects() const;
//! Creates a new empty group (to store it in the loop before flush)
virtual Events_MessageGroup* newEmpty();
{
const ModelAPI_ObjectUpdatedMessage* aMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
- myInitial = aMsg->features();
+ myInitial = aMsg->objects();
// collect all documents involved into the update
set<boost::shared_ptr<ModelAPI_Document> > aDocs;
set<boost::shared_ptr<ModelAPI_Object> >::iterator aFIter = myInitial.begin();
public:
/// Returns the feature that has been updated
- virtual std::set<ObjectPtr> features() const = 0;
+ virtual std::set<ObjectPtr> objects() const = 0;
//! Creates a new empty group (to store it in the loop before flush)
virtual Events_MessageGroup* newEmpty() = 0;
{
const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
- std::set<ObjectPtr > aFeatures = aUpdMsg->features();
+ std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
ObjectPtr aObject = *anIt;
{
const ModelAPI_ObjectUpdatedMessage* anUpdateMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
- std::set< ObjectPtr > aFeatures = anUpdateMsg->features();
+ std::set< ObjectPtr > aFeatures = anUpdateMsg->objects();
bool isModifiedEvt =
theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
// Created object event *******************
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const Model_ObjectUpdatedMessage*>(theMessage);
- std::set<ObjectPtr> aFeatures = aUpdMsg->features();
+ std::set<ObjectPtr> aObjects = aUpdMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
- ObjectPtr aFeature = (*aIt);
- DocumentPtr aDoc = aFeature->document();
+ for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ ObjectPtr aObject = (*aIt);
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
+ if (aFeature && (!aFeature->isInHistory()))
+ continue;
+
+ DocumentPtr aDoc = aObject->document();
if (aDoc == aRootDoc) { // If root objects
- if (aFeature->groupName().compare(ModelAPI_ResultPart::group()) == 0) { // Update only Parts group
+ if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group
// Add a new part
int aStart = myPartModels.size();
XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
myPartModels.append(aModel);
insertRow(aStart, partFolderNode());
} else { // Update top groups (other except parts
- QModelIndex aIndex = myModel->findParent(aFeature);
+ QModelIndex aIndex = myModel->findParent(aObject);
int aStart = myModel->rowCount(aIndex) - 1;
aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
insertRow(aStart, aIndex);
}
}
if (aPartModel) {
- QModelIndex aIndex = aPartModel->findParent(aFeature);
+ QModelIndex aIndex = aPartModel->findParent(aObject);
int aStart = aPartModel->rowCount(aIndex) - 1;
aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
insertRow(aStart, aIndex);
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
- return aObject->data()->docRef("PartDocument")->value();
+ return aObject->document();
}
ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
//******************************************************
void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg)
{
- std::set<ObjectPtr> aFeatures = theMsg->features();
+ std::set<ObjectPtr> aFeatures = theMsg->objects();
if (myOperationMgr->hasOperation())
{
FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
//******************************************************
void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg)
{
- std::set<ObjectPtr> aFeatures = theMsg->features();
+ std::set<ObjectPtr> aObjects = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
bool isDisplayed = false;
- for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
+ for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
if (aRes) {
isDisplayed = myDisplayer->redisplay(aRes, false);
//******************************************************
void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg)
{
- std::set<ObjectPtr> aFeatures = theMsg->features();
+ std::set<ObjectPtr> aFeatures = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
bool aHasPart = false;