Salome HOME
[GPUSPHGUI] fix errors relating to eCustomControl + offset
[modules/smesh.git] / src / SMESH_I / SMESH_Hypothesis_i.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 //  File   : SMESH_Hypothesis_i.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //
28 #ifndef _SMESH_HYPOTHESIS_I_HXX_
29 #define _SMESH_HYPOTHESIS_I_HXX_
30
31 #include "SMESH.hxx"
32
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
35
36 #include "SMESH_Hypothesis.hxx"
37 #include "SALOME_GenericObj_i.hh"
38
39 #include "SMESH_Gen.hxx"
40
41 #include <map>
42 #include <string>
43
44 class TCollection_AsciiString;
45
46 // ======================================================
47 // Generic hypothesis
48 // ======================================================
49 class SMESH_I_EXPORT SMESH_Hypothesis_i:
50   public virtual POA_SMESH::SMESH_Hypothesis,
51   public virtual SALOME::GenericObj_i
52 {
53 public:
54   // Constructor : placed in protected section to prohibit creation of generic class instance
55   SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA );
56
57 public:
58   // Destructor
59   virtual ~SMESH_Hypothesis_i();
60
61   // Get type name of hypothesis
62   virtual char* GetName();
63
64   // Get plugin library name of hypothesis
65   virtual char* GetLibName();
66
67   // Set plugin library name of hypothesis
68   void SetLibName( const char* theLibName );
69
70   // Get unique id of hypothesis
71   virtual CORBA::Long GetId();
72
73   // Return true if a hypothesis has parameters
74   virtual CORBA::Boolean HasParameters();
75
76   // Set the variable parameter (a variable name or a parameter value); \a method is a name
77   // of method setting this parameter.
78   // This method must be called by the hypothesis creator just before calling hyp->method()
79   virtual void SetVarParameter (const char* parameter, const char* method);
80
81   // Return the variable parameter used at Hypothesis Creation by the name of method
82   // setting this parameter. The returned variable name is used at Hypothesis Edition.
83   virtual char* GetVarParameter (const char* methodName);
84
85   // Store a hypothesis wrapping this not published one. This hyp, which has
86   // no own parameters but is published, is used to store variables defining parameters
87   // of this hypothesis. This method is to be called before setting parameters
88   // of this hypothesis.
89   virtual void SetHolderHypothesis(const SMESH::SMESH_Hypothesis_ptr hyp);
90
91   //Return true if hypothesis was published in study
92   bool IsPublished();
93
94   // Get implementation
95   ::SMESH_Hypothesis* GetImpl();
96   
97   // Persistence
98   virtual char* SaveTo();
99   virtual void  LoadFrom( const char* theStream );
100   virtual void  UpdateAsMeshesRestored(); // for hyps needing full data restored
101
102  protected:
103
104   // base hypothesis implementation
105   ::SMESH_Hypothesis*         myBaseImpl;
106
107   // a published hypothesis wrapping this not published one
108   SMESH::SMESH_Hypothesis_var myHolder;
109
110   // variable parameters
111   std::map< std::string, std::string > myMethod2VarParams;
112
113  public:
114   // Methods for backward compatibility of notebook variables
115   
116   // restore myMethod2VarParams by parameters stored in an old study
117   virtual void setOldParameters (const char* theParameters);
118
119   // method used to convert variable parameters stored in an old study
120   // into myMethod2VarParams. It should return a method name for an index of
121   // variable parameters. Index is countered from zero
122   virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const { return ""; }
123
124   // method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
125   virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const { return -1; }
126 };
127
128 // ======================================================
129 // Generic hypothesis creator
130 // ======================================================
131 class SMESH_I_EXPORT GenericHypothesisCreator_i
132 {
133 public:
134   // Create a hypothesis
135   virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
136                                      int                     theStudyId,
137                                      ::SMESH_Gen*            theGenImpl) = 0;
138   virtual ~GenericHypothesisCreator_i() {}
139
140   // return the name of IDL module
141   virtual std::string GetModuleName() = 0;
142   virtual bool IsApplicable( const TopoDS_Shape &S, bool toCheckAll ) {return true;}
143 };
144
145 //=============================================================================
146 //
147 // Specific Hypothesis Creators are generated with a template which inherits a
148 // generic hypothesis creator. Each creator returns an hypothesis of the type
149 // given in the template. 
150 //
151 //=============================================================================
152 template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
153 {
154 public:
155   virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
156                                       int                     theStudyId,
157                                       ::SMESH_Gen*            theGenImpl)
158   {
159     return new T (thePOA, theStudyId, theGenImpl);
160   };
161 };
162
163 #endif