Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API
[modules/shaper.git] / src / ExchangeAPI / ExchangeAPI_Import.cpp
1 // Name   : ExchangeAPI_Import.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ExchangeAPI_Import.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 ExchangeAPI_Import::ExchangeAPI_Import(
14     const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 ExchangeAPI_Import::ExchangeAPI_Import(
21     const std::shared_ptr<ModelAPI_Feature> & theFeature,
22     const std::string & theFilePath)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if (initialize())
26     setFilePath(theFilePath);
27 }
28
29 ExchangeAPI_Import::~ExchangeAPI_Import()
30 {
31
32 }
33
34 //--------------------------------------------------------------------------------------
35 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
36 {
37   fillAttribute(theFilePath, myfilePath);
38
39   execute();
40 }
41
42 //--------------------------------------------------------------------------------------
43 void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
44 {
45   FeaturePtr aBase = feature();
46   std::string aPartName = theDumper.name(aBase->document());
47
48   theDumper << aBase << " = model.addImport(" << aPartName << ", "
49             << aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()) << ")" << std::endl;
50 }
51
52 //--------------------------------------------------------------------------------------
53 ImportPtr addImport(
54     const std::shared_ptr<ModelAPI_Document> & thePart,
55     const std::string & theFilePath)
56 {
57   // TODO(spo): check that thePart is not empty
58   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Import::ID());
59   return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath));
60 }