Salome HOME
e6fd5576424407de2b5bc3777e5679ce123cd95b
[modules/geom.git] / src / XAOPlugin / XAOPlugin_Driver.cxx
1 // Copyright (C) 2013-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // internal includes
21 #include "XAOPlugin_Driver.hxx"
22 #include "XAOPlugin_IImportExport.hxx"
23
24 // GEOM includes
25 #include "GEOMImpl_Types.hxx"
26 #include "GEOM_Function.hxx"
27
28 #include <XAO_Xao.hxx>
29 #include <XAO_Geometry.hxx>
30 #include <XAO_Group.hxx>
31 #include <XAO_XaoUtils.hxx>
32
33 // OCC includes
34 #include <Standard_Stream.hxx>
35 #include <StdFail_NotDone.hxx>
36
37 //=======================================================================
38 //function : GetID
39 //purpose  :
40 //=======================================================================
41 const Standard_GUID& XAOPlugin_Driver::GetID()
42 {
43     static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16");
44     return aGUID;
45 }
46
47 //=======================================================================
48 //function : XAOPlugin_Driver
49 //purpose  :
50 //=======================================================================
51 XAOPlugin_Driver::XAOPlugin_Driver()
52 {
53 }
54
55 //=======================================================================
56 //function : ~XAOPlugin_Driver
57 //purpose  :
58 //=======================================================================
59 XAOPlugin_Driver::~XAOPlugin_Driver()
60 {
61 }
62
63 //function : Execute
64 //purpose  :
65 //=======================================================================
66 Standard_Integer XAOPlugin_Driver::Execute(Handle(TFunction_Logbook)& log) const
67 {
68   if (Label().IsNull()) return 0;
69   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
70
71   XAOPlugin_IImportExport iexao(function);
72   TCollection_AsciiString xao   = iexao.GetData();
73
74   TopoDS_Shape shape;
75
76   Standard_Integer functionType = function->GetType();
77   if (functionType == EXPORT_SHAPE)
78   {
79   }
80   else if (functionType == IMPORT_SHAPE)
81   {
82   }
83   else
84   {
85     // other construction modes here
86   }
87
88   if (shape.IsNull()) return 0;
89   function->SetValue(shape);
90
91   log->SetTouched(Label());
92
93   return 1;
94 }
95
96 //=======================================================================
97 //function : GetCreationInformation
98 //purpose  : Returns a name of creation operation and names and values of
99 //           creation parameters
100 //=======================================================================
101
102 bool XAOPlugin_Driver::GetCreationInformation(std::string&             theOperationName,
103                                               std::vector<GEOM_Param>& theParams)
104 {
105   if (Label().IsNull()) return false;
106   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
107
108   theOperationName = "ImportXAO";
109   AddParam( theParams, "File name", function->GetString( GetFileNameTag() ));
110   return true;
111 }
112
113 IMPLEMENT_STANDARD_RTTIEXT(XAOPlugin_Driver, GEOM_BaseDriver)
114