Salome HOME
Add ExchangeAPI, fillAttribute in ModelHighAPI_Tools, ModelHighAPI_Selection and...
[modules/shaper.git] / src / ExchangeAPI / ExchangeAPI_Export.cpp
1 // Name   : ExchangeAPI_Export.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ExchangeAPI_Export.h"
9
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 ExchangeAPI_Export::ExchangeAPI_Export(
14     const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 ExchangeAPI_Export::ExchangeAPI_Export(
21     const std::shared_ptr<ModelAPI_Feature> & theFeature,
22     const std::string & theFilePath,
23     const std::string & theFileFormat,
24     const std::list<ModelHighAPI_Selection> & theSelectionList)
25 : ModelHighAPI_Interface(theFeature)
26 {
27   if (initialize()) {
28     setFilePath(theFilePath);
29     setFileFormat(theFileFormat);
30     setSelectionList(theSelectionList);
31     execute();
32   }
33 }
34
35 ExchangeAPI_Export::~ExchangeAPI_Export()
36 {
37
38 }
39
40 //--------------------------------------------------------------------------------------
41 void ExchangeAPI_Export::setFilePath(const std::string & theFilePath)
42 {
43   fillAttribute(theFilePath, myfilePath);
44 }
45
46 void ExchangeAPI_Export::setFileFormat(const std::string & theFileFormat)
47 {
48   fillAttribute(theFileFormat, myfileFormat);
49 }
50
51 void ExchangeAPI_Export::setSelectionList(
52     const std::list<ModelHighAPI_Selection> & theSelectionList)
53 {
54   fillAttribute(theSelectionList, myselectionList);
55 }
56
57 //--------------------------------------------------------------------------------------
58 ExportPtr exportToFile(
59     const std::shared_ptr<ModelAPI_Document> & thePart,
60     const std::string & theFilePath,
61     const std::string & theFileFormat,
62     const std::list<ModelHighAPI_Selection> & theSelectionList)
63 {
64   // TODO(spo): check that thePart is not empty
65   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Export::ID());
66   return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theFileFormat, theSelectionList));
67 }