theDumper << aBase << " = model.addImport(" << aPartName << ", "
<< aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()) << ")" << std::endl;
+ // to make import have results
+ theDumper << "model.do()" << std::endl;
+
+ CompositeFeaturePtr aCompositeFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aBase);
+ if(aCompositeFeature.get()) {
+ int aNbOfSubs = aCompositeFeature->numberOfSubs();
+ for(int anIndex = 0; anIndex < aNbOfSubs; ++anIndex) {
+ std::string aSubFeatureGet = theDumper.name(aBase) + ".subFeature(" + std::to_string((long long)anIndex) + ")";
+ theDumper.dumpSubFeatureNameAndColor(aSubFeatureGet, aCompositeFeature->subFeature(anIndex));
+ }
+ }
}
//--------------------------------------------------------------------------------------
return isOk;
}
+void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFeatureGet,
+ const FeaturePtr& theSubFeature)
+{
+ name(theSubFeature, false);
+ myNames[theSubFeature] = std::pair<std::string, std::string>(theSubFeatureGet, theSubFeature->name());
+
+ // store results if they have user-defined names or colors
+ std::list<ResultPtr> aResultsWithNameOrColor;
+ const std::list<ResultPtr>& aResults = theSubFeature->results();
+ std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
+ for (; aResIt != aResults.end(); ++aResIt) {
+ std::string aResName = (*aResIt)->data()->name();
+ myNames[*aResIt] = std::pair<std::string, std::string>(aResName, aResName);
+ aResultsWithNameOrColor.push_back(*aResIt);
+ }
+
+ // store just dumped entity to stack
+ myEntitiesStack.push(LastDumpedEntity(theSubFeature, true, aResultsWithNameOrColor));
+
+ dumpEntitySetName();
+}
+
bool ModelHighAPI_Dumper::exportTo(const std::string& theFileName)
{
std::ofstream aFile;
/// Dump given feature
virtual void dumpFeature(const FeaturePtr& theFeature, const bool theForce = false) = 0;
+ /// Dump sub-feature name and color, without dumping feature creation.
+ /// Used for features which creates sub-features in their execute method.
+ /// \param theSubFeatureGet [in] method for getting sub-feature (e.g. "Feature_1.subFeature(0)")
+ /// \param theSubFeature [in] sub-feature
+ MODELHIGHAPI_EXPORT
+ void dumpSubFeatureNameAndColor(const std::string theSubFeatureGet,
+ const FeaturePtr& theSubFeature);
+
/// Return name of getter for corresponding attribute
virtual std::string attributeGetter(const FeaturePtr& theFeature,
const std::string& theAttrName) const = 0;
//--------------------------------------------------------------------------------------
#include <Events_InfoMessage.h>
+#include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
return myFeature;
}
+std::shared_ptr<ModelHighAPI_Interface> ModelHighAPI_Interface::subFeature(const int theIndex) const
+{
+ CompositeFeaturePtr aCompositeFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if(!aCompositeFeature.get()) {
+ return InterfacePtr();
+ }
+
+ FeaturePtr aSubFeature = aCompositeFeature->subFeature(theIndex);
+ if(!aSubFeature.get()) {
+ return InterfacePtr();
+ }
+
+ return InterfacePtr(new ModelHighAPI_Interface(aSubFeature));
+}
+
const std::string& ModelHighAPI_Interface::getKind() const
{
return feature()->getKind();
void ModelHighAPI_Interface::execute()
{
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- FeaturePtr aFeature = feature();
- if(aFactory->validate(aFeature)) {
- aFeature->execute();
- }
+ //SessionPtr aMgr = ModelAPI_Session::get();
+ //ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ //FeaturePtr aFeature = feature();
+ //if(aFactory->validate(aFeature)) {
+ // aFeature->execute();
+ //}
+
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
}
void ModelHighAPI_Interface::setName(const std::string& theName)
MODELHIGHAPI_EXPORT
std::shared_ptr<ModelAPI_Feature> feature() const;
+ /// If feature is composite return intefrace for sub-feature by zero-based index,
+ /// or empty pointer if feature not composite or does not have sub-feature with such index.
+ MODELHIGHAPI_EXPORT
+ std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
+
/// Shortcut for feature()->getKind()
MODELHIGHAPI_EXPORT
const std::string& getKind() const;