#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Result.h>
#include <Events_Loop.h>
void ModuleBase_Operation::startOperation()
{
if (!myIsEditing)
- setFeature(createFeature());
+ createFeature();
//emit callSlot();
//commit();
}
FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage)
{
boost::shared_ptr<ModelAPI_Document> aDoc = document();
- FeaturePtr aFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
- if (aFeature) { // TODO: generate an error if feature was not created
+ myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
+ if (myFeature) { // TODO: generate an error if feature was not created
myIsModified = true;
- aFeature->execute();
+ myFeature->execute();
// Init default values
/*QList<ModuleBase_ModelWidget*> aWidgets = getDescription()->modelWidgets();
QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
if (theFlushMessage)
flushCreated();
- return aFeature;
+ return myFeature;
}
void ModuleBase_Operation::setFeature(FeaturePtr theFeature)
setFeature(theFeature);
myIsEditing = true;
}
+
+bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
+{
+ FeaturePtr aFeature = feature();
+ if (aFeature) {
+ if (aFeature.get() == theObj.get())
+ return true;
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+ if ((*aIt).get() == theObj.get())
+ return true;
+ }
+ }
+ return false;
+}
\ No newline at end of file
/// Sets the operation feature
void setEditingFeature(FeaturePtr theFeature);
+ /// Returns True if the current operation works with the given object (feature or result)
+ virtual bool hasObject(ObjectPtr theObj) const;
+
public slots:
/// Slots which listen the mode widget activation
/// \param theWidget the model widget
/// \returns the created feature
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
-private:
+protected:
/// Sets the operation feature
void setFeature(FeaturePtr theFeature);
-private:
+protected:
FeaturePtr myFeature; /// the operation feature to be handled
};
}
FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
{
- FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
- if (aFeature)
- emit featureConstructed(aFeature, FM_Activation);
- return aFeature;
+ ModuleBase_Operation::createFeature(theFlushMessage);
+ if (myFeature)
+ emit featureConstructed(myFeature, FM_Activation);
+ return myFeature;
}
if (aPart) {
aHasPart = true;
} else {
- myDisplayer->display(*aIt, false);
- isDisplayed = true;
+ ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ if (aOperation->hasObject(*aIt)) { // Display only current operation results
+ myDisplayer->display(*aIt, false);
+ isDisplayed = true;
+ }
}
}
if (isDisplayed)