]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Events.cpp
Salome HOME
Issue #2052: Modification of parameters don't work (sketch, extrusion)
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModelAPI_Events.cpp
5  *
6  *  Created on: Dec 8, 2014
7  *      Author: sbh
8  */
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Events.h>
12
13 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
14                                                              const void* theSender)
15     : Events_MessageGroup(theID, theSender)
16 {
17
18 }
19
20 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
21 {
22
23 }
24
25 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
26                                                              const void* theSender)
27     : Events_MessageGroup(theID, theSender)
28 {
29
30 }
31
32 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
33 {
34
35 }
36
37 ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID,
38                                                            const void* theSender)
39     : Events_Message(theID, theSender)
40 {
41
42 }
43
44 ModelAPI_OrderUpdatedMessage::~ModelAPI_OrderUpdatedMessage()
45 {
46
47 }
48
49 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
50                                                            const void* theSender)
51  : Events_Message(theID, theSender)
52 {
53   myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
54 }
55
56 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
57 {
58
59 }
60
61 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
62 {
63   return myCurrentFeature;
64 }
65
66 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
67 {
68   myCurrentFeature = theFeature;
69 }
70
71 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
72 {
73   return myFeatureState.find(theKey) != myFeatureState.end();
74 }
75
76 bool ModelAPI_FeatureStateMessage::state(const  std::string& theFeatureId, bool theDefault) const
77 {
78   if(hasState(theFeatureId)) {
79     return myFeatureState.at(theFeatureId);
80   }
81   return theDefault;
82 }
83
84 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
85 {
86   myFeatureState[theFeatureId] = theValue;
87 }
88
89 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
90 {
91   std::list<std::string> result;
92   std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
93   for( ; it != myFeatureState.end(); ++it) {
94     result.push_back(it->first);
95   }
96   return result;
97 }
98
99
100 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(
101   const Events_ID theID, const void* theSender)
102 : Events_Message(theID, theSender)
103 {}
104
105 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
106 {}
107
108 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
109 {
110   return myDocument;
111 }
112
113 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
114 {
115   myDocument = theDocument;
116 }
117
118 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(
119   const Events_ID theID, const void* theSender)
120 : Events_Message(theID, theSender)
121 {}
122
123 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
124 {}
125
126 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
127 {
128   return myAttribute;
129 }
130
131 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theAttribute)
132 {
133   myAttribute = theAttribute;
134 }
135
136 ModelAPI_ParameterEvalMessage::ModelAPI_ParameterEvalMessage(
137   const Events_ID theID, const void* theSender)
138   : Events_Message(theID, theSender), myIsProcessed(false)
139 {}
140
141 ModelAPI_ParameterEvalMessage::~ModelAPI_ParameterEvalMessage()
142 {}
143
144 FeaturePtr ModelAPI_ParameterEvalMessage::parameter() const
145 {
146   return myParam;
147 }
148
149 void ModelAPI_ParameterEvalMessage::setParameter(FeaturePtr theParam)
150 {
151   myParam = theParam;
152 }
153
154 void ModelAPI_ParameterEvalMessage::setResults(
155     const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
156     const double theResult, const std::string& theError)
157 {
158   myParamsList = theParamsList;
159   myResult = theResult;
160   myError = theError;
161   myIsProcessed = true;
162 }
163
164 bool ModelAPI_ParameterEvalMessage::isProcessed()
165 {
166   return myIsProcessed;
167 }
168
169 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >&
170   ModelAPI_ParameterEvalMessage::params() const
171 {
172   return myParamsList;
173 }
174
175 const double& ModelAPI_ParameterEvalMessage::result() const
176 {
177   return myResult;
178 }
179
180 const std::string& ModelAPI_ParameterEvalMessage::error() const
181 {
182   return myError;
183 }
184
185 ModelAPI_ComputePositionsMessage::ModelAPI_ComputePositionsMessage(
186   const Events_ID theID, const void* theSender)
187   : Events_Message(theID, theSender)
188 {}
189
190 ModelAPI_ComputePositionsMessage::~ModelAPI_ComputePositionsMessage()
191 {}
192
193 const std::string& ModelAPI_ComputePositionsMessage::expression() const
194 {
195   return myExpression;
196 }
197
198 const std::string& ModelAPI_ComputePositionsMessage::parameter() const
199 {
200   return myParamName;
201 }
202
203 void ModelAPI_ComputePositionsMessage::set(
204   const std::string& theExpression, const std::string& theParameter)
205 {
206   myExpression = theExpression;
207   myParamName = theParameter;
208 }
209
210 void ModelAPI_ComputePositionsMessage::setPositions(
211   const std::list<std::pair<int, int> >& thePositions)
212 {
213   myPositions = thePositions;
214 }
215
216 const std::list<std::pair<int, int> >& ModelAPI_ComputePositionsMessage::positions() const
217 {
218   return myPositions;
219 }
220
221
222 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
223                                                              const void* theSender)
224 : Events_Message(theID, theSender)
225 {
226
227 }
228
229 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
230 {
231
232 }
233
234 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
235                                          const std::string& theOldName,
236                                          const std::string& theNewName,
237                                          const void* theSender)
238 {
239   std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage(
240     new ModelAPI_ObjectRenamedMessage(eventId(), theSender));
241   aMessage->setObject(theObject);
242   aMessage->setOldName(theOldName);
243   aMessage->setNewName(theNewName);
244   Events_Loop::loop()->send(aMessage);
245 }
246
247 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
248 {
249   return myObject;
250 }
251
252 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
253 {
254   myObject = theObject;
255 }
256
257 std::string ModelAPI_ObjectRenamedMessage::oldName() const
258 {
259   return myOldName;
260 }
261
262 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
263 {
264   myOldName = theOldName;
265 }
266
267 std::string ModelAPI_ObjectRenamedMessage::newName() const
268 {
269   return myNewName;
270 }
271
272 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
273 {
274   myNewName = theNewName;
275 }
276
277 ModelAPI_ReplaceParameterMessage::ModelAPI_ReplaceParameterMessage(const Events_ID theID,
278                                                                    const void* theSender)
279 : Events_Message(theID, theSender)
280 {
281
282 }
283
284 ModelAPI_ReplaceParameterMessage::~ModelAPI_ReplaceParameterMessage()
285 {
286
287 }
288
289 void ModelAPI_ReplaceParameterMessage::send(ObjectPtr theObject,
290                                             const void* theSender)
291 {
292   std::shared_ptr<ModelAPI_ReplaceParameterMessage> aMessage(
293       new ModelAPI_ReplaceParameterMessage(eventId(), theSender));
294   aMessage->setObject(theObject);
295   Events_Loop::loop()->send(aMessage);
296 }
297
298 ObjectPtr ModelAPI_ReplaceParameterMessage::object() const
299 {
300   return myObject;
301 }
302
303 void ModelAPI_ReplaceParameterMessage::setObject(ObjectPtr theObject)
304 {
305   myObject = theObject;
306 }
307
308
309 // =====   ModelAPI_SolverFailedMessage   =====
310 ModelAPI_SolverFailedMessage::ModelAPI_SolverFailedMessage(const Events_ID theID,
311                                                            const void* theSender)
312   : Events_Message(theID, theSender),
313     myDOF(-1)
314 {
315 }
316
317 ModelAPI_SolverFailedMessage::~ModelAPI_SolverFailedMessage()
318 {
319 }
320
321 void ModelAPI_SolverFailedMessage::setObjects(const std::set<ObjectPtr>& theObjects)
322 {
323   myObjects = theObjects;
324 }
325
326 const std::set<ObjectPtr>& ModelAPI_SolverFailedMessage::objects() const
327 {
328   return myObjects;
329 }
330