Salome HOME
IPAL52828: No Creation Info available for a GEOM object imported from XAO file
[modules/geom.git] / src / XAOPlugin / XAOPlugin_Driver.cxx
1 // Copyright (C) 2013-2015  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 <TFunction_Logbook.hxx>
36 #include <StdFail_NotDone.hxx>
37
38 //=======================================================================
39 //function : GetID
40 //purpose  :
41 //=======================================================================
42 const Standard_GUID& XAOPlugin_Driver::GetID()
43 {
44     static Standard_GUID aGUID("FF1BBB71-5D14-4df2-980B-3A668264EA16");
45     return aGUID;
46 }
47
48 //=======================================================================
49 //function : XAOPlugin_Driver
50 //purpose  :
51 //=======================================================================
52 XAOPlugin_Driver::XAOPlugin_Driver()
53 {
54 }
55
56 //=======================================================================
57 //function : ~XAOPlugin_Driver
58 //purpose  :
59 //=======================================================================
60 XAOPlugin_Driver::~XAOPlugin_Driver()
61 {
62 }
63
64 Standard_Boolean XAOPlugin_Driver::MustExecute(const TFunction_Logbook&) const
65 {
66   return Standard_True;
67 }
68
69 //=======================================================================
70 //function : Execute
71 //purpose  :
72 //=======================================================================
73 Standard_Integer XAOPlugin_Driver::Execute(TFunction_Logbook& log) const
74 {
75   if (Label().IsNull()) return 0;
76   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
77
78   XAOPlugin_IImportExport iexao(function);
79   TCollection_AsciiString xao   = iexao.GetData();
80
81   TopoDS_Shape shape;
82
83   Standard_Integer functionType = function->GetType();
84   if (functionType == EXPORT_SHAPE)
85   {
86   }
87   else if (functionType == IMPORT_SHAPE)
88   {
89   }
90   else
91   {
92     // other construction modes here
93   }
94
95   if (shape.IsNull()) return 0;
96   function->SetValue(shape);
97
98   log.SetTouched(Label());
99
100   return 1;
101 }
102
103 //=======================================================================
104 //function : GetCreationInformation
105 //purpose  : Returns a name of creation operation and names and values of
106 //           creation parameters
107 //=======================================================================
108
109 bool XAOPlugin_Driver::GetCreationInformation(std::string&             theOperationName,
110                                               std::vector<GEOM_Param>& theParams)
111 {
112   if (Label().IsNull()) return false;
113   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
114
115   theOperationName = "ImportXAO";
116   AddParam( theParams, "File name", function->GetString( GetFileNameTag() ));
117   return true;
118 }
119
120 IMPLEMENT_STANDARD_HANDLE (XAOPlugin_Driver, GEOM_BaseDriver);
121 IMPLEMENT_STANDARD_RTTIEXT(XAOPlugin_Driver, GEOM_BaseDriver);
122