Salome HOME
Merge branch 'CPPHighAPI'
[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_Tools.h>
11 //--------------------------------------------------------------------------------------
12 ExchangeAPI_Export::ExchangeAPI_Export(
13     const std::shared_ptr<ModelAPI_Feature> & theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 ExchangeAPI_Export::ExchangeAPI_Export(
20     const std::shared_ptr<ModelAPI_Feature> & theFeature,
21     const std::string & theFilePath,
22     const std::string & theFileFormat,
23     const std::list<ModelHighAPI_Selection> & theSelectionList)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if (initialize()) {
27     setFilePath(theFilePath);
28     setFileFormat(theFileFormat);
29     setSelectionList(theSelectionList);
30     execute();
31   }
32 }
33
34 ExchangeAPI_Export::~ExchangeAPI_Export()
35 {
36
37 }
38
39 //--------------------------------------------------------------------------------------
40 void ExchangeAPI_Export::setFilePath(const std::string & theFilePath)
41 {
42   fillAttribute(theFilePath, myfilePath);
43 }
44
45 void ExchangeAPI_Export::setFileFormat(const std::string & theFileFormat)
46 {
47   fillAttribute(theFileFormat, myfileFormat);
48 }
49
50 void ExchangeAPI_Export::setSelectionList(
51     const std::list<ModelHighAPI_Selection> & theSelectionList)
52 {
53   fillAttribute(theSelectionList, myselectionList);
54 }
55
56 //--------------------------------------------------------------------------------------
57 ExportPtr exportToFile(
58     const std::shared_ptr<ModelAPI_Document> & thePart,
59     const std::string & theFilePath,
60     const std::string & theFileFormat,
61     const std::list<ModelHighAPI_Selection> & theSelectionList)
62 {
63   // TODO(spo): check that thePart is not empty
64   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Export::ID());
65   return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theFileFormat, theSelectionList));
66 }