Salome HOME
e8e5cb12a6b54727f7144ac4ea5cae3f8a9a2ea9
[modules/geom.git] / src / GEOMImpl / GEOMImpl_FieldDriver.cxx
1 // Copyright (C) 2007-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 #include "GEOMImpl_FieldDriver.hxx"
21
22 #include "GEOM_Field.hxx"
23 #include "GEOM_Function.hxx"
24 #include "GEOM_IField.hxx"
25
26 //=======================================================================
27 //function : GetID
28 //purpose  :
29 //=======================================================================
30 const Standard_GUID& GEOMImpl_FieldDriver::GetID()
31 {
32   return GEOM_Field::GetFieldID();
33 }
34
35 //=======================================================================
36 //function : GEOMImpl_FieldDriver
37 //purpose  :
38 //=======================================================================
39 GEOMImpl_FieldDriver::GEOMImpl_FieldDriver()
40 {
41 }
42
43 //=======================================================================
44 //function : Execute
45 //purpose  :
46 //=======================================================================
47 Standard_Integer GEOMImpl_FieldDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
48 {
49   return 0;
50 }
51
52 //================================================================================
53 /*!
54  * \brief Returns a name of creation operation and names and values of creation parameters
55  */
56 //================================================================================
57
58 bool GEOMImpl_FieldDriver::
59 GetCreationInformation(std::string&             theOperationName,
60                        std::vector<GEOM_Param>& theParams)
61 {
62   if (Label().IsNull()) return false;
63   Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
64
65   GEOM_IField data( function );
66   Standard_Integer funType = function->GetType();
67
68   if ( funType == GEOM_Field::FUN_ADD_FIELD )
69   {
70     theOperationName = "FIELD_CREATE";
71     // geompy.CreateField(shape, name, type, dimension, componentNames)
72     Handle(GEOM_Field) f = GEOM_Field::GetField( function->GetOwnerEntry() );
73     AddParam( theParams, "Shape", data.GetShape() );
74     AddParam( theParams, "Name", f->GetName() );
75     AddParam( theParams, "Type", f->GetDataTypeString( data.GetDataType() ));
76     AddParam( theParams, "Dimension", data.GetDimension() );
77     GEOM_Param comps = AddParam( theParams, "Components", f->GetComponentsForPython() );
78   }
79   else if ( funType == GEOM_Field::FUN_ADD_STEP )
80   {
81     theOperationName = "ADD_FIELD_STEP";
82     // field.addStep(step, stamp, values)
83     AddParam( theParams, "Step", data.GetStepID() );
84     AddParam( theParams, "Stamp", data.GetStepStamp() );
85   }
86   else if ( funType == GEOM_Field::FUN_CHANGE_COMP_NAMES )
87   {
88     theOperationName = "Change component names";
89   }
90   else if ( funType == GEOM_Field::FUN_CHANGE_STEP_STAMP )
91   {
92     theOperationName = "Change stamp";
93     AddParam( theParams, "Stamp", data.GetStepStamp() );
94   }
95   else if ( funType == GEOM_Field::FUN_CHANGE_VALUE )
96   {
97     theOperationName = "FIELD_EDIT";//"Change values";
98     AddParam( theParams, "Values", "..." );
99   }
100   else
101   {
102     return false;
103   }
104   
105   return true;
106 }
107
108 IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_FieldDriver,GEOM_BaseDriver)