// File: ExchangePlugin_ImportFeature.cpp
// Created: Aug 28, 2014
-// Author: Sergey BELASH
+// Authors: Sergey BELASH, Sergey POKHODENKO
#include <ExchangePlugin_ImportFeature.h>
#include <algorithm>
#include <string>
-#ifdef _DEBUG
-#include <iostream>
-#include <ostream>
-#endif
#include <Config_Common.h>
#include <Config_PropManager.h>
void ExchangePlugin_ImportFeature::initAttributes()
{
data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(ExchangePlugin_ImportFeature::GROUP_LIST_ID(), ModelAPI_AttributeRefList::typeId());
+ data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(), ModelAPI_AttributeRefList::typeId());
- ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ImportFeature::GROUP_LIST_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(
+ getKind(), ExchangePlugin_ImportFeature::FEATURES_ID());
}
/*
XAO::Geometry* aXaoGeometry = aXao.getGeometry();
// use the geometry name or the file name for the feature
- std::string aBodyName = aXaoGeometry->getName().empty()
- ? GeomAlgoAPI_Tools::File_Tools::name(theFileName)
- : aXaoGeometry->getName();
+ std::string aBodyName = aXaoGeometry->getName();
+ if (aBodyName.empty())
+ aBodyName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
data()->setName(aBodyName);
ResultBodyPtr aResultBody = createResultBody(aGeomShape);
setResult(aResultBody);
// Process groups
- AttributeRefListPtr aRefListOfGroups = reflist(ExchangePlugin_ImportFeature::GROUP_LIST_ID());
+ std::shared_ptr<ModelAPI_AttributeRefList> aRefListOfGroups =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(FEATURES_ID()));
// Remove previous groups stored in RefList
std::list<ObjectPtr> anGroupList = aRefListOfGroups->list();
std::list<ObjectPtr>::iterator anGroupIt = anGroupList.begin();
for (; anGroupIt != anGroupList.end(); ++anGroupIt) {
- std::shared_ptr<ModelAPI_Feature> aFeature =
- std::dynamic_pointer_cast<ModelAPI_Feature>(*anGroupIt);
+ std::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_Feature::feature(*anGroupIt);
if (aFeature)
document()->removeFeature(aFeature);
}
for (int aGroupIndex = 0; aGroupIndex < aXao.countGroups(); ++aGroupIndex) {
XAO::Group* aXaoGroup = aXao.getGroup(aGroupIndex);
- std::shared_ptr<ModelAPI_Feature> aGroupFeature = document()->addFeature("Group", false);
+ std::shared_ptr<ModelAPI_Feature> aGroupFeature = addFeature("Group");
// group name
if (!aXaoGroup->getName().empty())
aSelectionList->value(anElementIndex)->setId(aReferenceID);
}
-
- aRefListOfGroups->append(aGroupFeature);
-
- // hide the group in the history
- document()->setCurrentFeature(aGroupFeature, false);
- // groups features is internal part of the import
- aGroupFeature->setInHistory(aGroupFeature, false);
+//
+// aRefListOfGroups->append(aGroupFeature);
+//
+// // hide the group in the history
+// document()->setCurrentFeature(aGroupFeature, false);
+// // groups features is internal part of the import
+// aGroupFeature->setInHistory(aGroupFeature, false);
}
} catch (XAO::XAO_Exception& e) {
// File: ExchangePlugin_ImportFeature.h
// Created: Aug 28, 2014
-// Author: Sergey BELASH
+// Authors: Sergey BELASH, Sergey POKHODENKO
#ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
#define EXCHANGEPLUGIN_IMPORTFEATURE_H_
-#include <ExchangePlugin.h>
-#include <ModelAPI_Feature.h>
+#include "ExchangePlugin.h"
+
+#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Result.h>
#include <map>
*
* The list of supported formats is defined in the configuration file.
*/
-class ExchangePlugin_ImportFeature : public ModelAPI_Feature
+class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
{
public:
/// Feature kind
static const std::string MY_FILE_PATH_ID("file_path");
return MY_FILE_PATH_ID;
}
- /// attribute name of group list
- inline static const std::string& GROUP_LIST_ID()
+ /// All features (list of references)
+ inline static const std::string& FEATURES_ID()
{
- static const std::string MY_GROUP_LIST_ID("group_list");
- return MY_GROUP_LIST_ID;
+ static const std::string MY_FEATURES_ID("Features");
+ return MY_FEATURES_ID;
}
/// Default constructor
EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
/// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
+ /// Reimplemented from ModelAPI_CompositeFeature::addFeature()
+ virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
+
+ /// Reimplemented from ModelAPI_CompositeFeature::numberOfSubs()
+ virtual int numberOfSubs(bool forTree = false) const;
+
+ /// Reimplemented from ModelAPI_CompositeFeature::subFeature()
+ virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
+
+ /// Reimplemented from ModelAPI_CompositeFeature::subFeatureId()
+ virtual int subFeatureId(const int theIndex) const;
+
+ /// Reimplemented from ModelAPI_CompositeFeature::isSub()
+ virtual bool isSub(ObjectPtr theObject) const;
+
+ /// Reimplemented from ModelAPI_CompositeFeature::removeFeature()
+ virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
+
protected:
/// Performs the import of the file
EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName);