1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
22 #include <ModelAPI_Events.h>
24 #include <GeomAPI_Pnt2d.h>
26 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
27 const void* theSender)
28 : Events_MessageGroup(theID, theSender)
33 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
38 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
39 const void* theSender)
40 : Events_MessageGroup(theID, theSender)
45 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
50 ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID,
51 const void* theSender)
52 : Events_Message(theID, theSender)
57 ModelAPI_OrderUpdatedMessage::~ModelAPI_OrderUpdatedMessage()
62 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
63 const void* theSender)
64 : Events_Message(theID, theSender)
66 myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
69 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
74 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
76 return myCurrentFeature;
79 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
81 myCurrentFeature = theFeature;
84 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
86 return myFeatureState.find(theKey) != myFeatureState.end();
89 bool ModelAPI_FeatureStateMessage::state(const std::string& theFeatureId, bool theDefault) const
91 if(hasState(theFeatureId)) {
92 return myFeatureState.at(theFeatureId);
97 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
99 myFeatureState[theFeatureId] = theValue;
102 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
104 std::list<std::string> result;
105 std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
106 for( ; it != myFeatureState.end(); ++it) {
107 result.push_back(it->first);
113 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(
114 const Events_ID theID, const void* theSender)
115 : Events_Message(theID, theSender)
118 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
121 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
126 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
128 myDocument = theDocument;
131 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(
132 const Events_ID theID, const void* theSender)
133 : Events_Message(theID, theSender)
136 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
139 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
144 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theAttribute)
146 myAttribute = theAttribute;
149 ModelAPI_ParameterEvalMessage::ModelAPI_ParameterEvalMessage(
150 const Events_ID theID, const void* theSender)
151 : Events_Message(theID, theSender), myIsProcessed(false)
154 ModelAPI_ParameterEvalMessage::~ModelAPI_ParameterEvalMessage()
157 FeaturePtr ModelAPI_ParameterEvalMessage::parameter() const
162 void ModelAPI_ParameterEvalMessage::setParameter(FeaturePtr theParam)
167 void ModelAPI_ParameterEvalMessage::setResults(
168 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
169 const double theResult, const std::string& theError)
171 myParamsList = theParamsList;
172 myResult = theResult;
174 myIsProcessed = true;
177 bool ModelAPI_ParameterEvalMessage::isProcessed()
179 return myIsProcessed;
182 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >&
183 ModelAPI_ParameterEvalMessage::params() const
188 const double& ModelAPI_ParameterEvalMessage::result() const
193 const std::string& ModelAPI_ParameterEvalMessage::error() const
198 ModelAPI_ComputePositionsMessage::ModelAPI_ComputePositionsMessage(
199 const Events_ID theID, const void* theSender)
200 : Events_Message(theID, theSender)
203 ModelAPI_ComputePositionsMessage::~ModelAPI_ComputePositionsMessage()
206 const std::string& ModelAPI_ComputePositionsMessage::expression() const
211 const std::string& ModelAPI_ComputePositionsMessage::parameter() const
216 void ModelAPI_ComputePositionsMessage::set(
217 const std::string& theExpression, const std::string& theParameter)
219 myExpression = theExpression;
220 myParamName = theParameter;
223 void ModelAPI_ComputePositionsMessage::setPositions(
224 const std::list<std::pair<int, int> >& thePositions)
226 myPositions = thePositions;
229 const std::list<std::pair<int, int> >& ModelAPI_ComputePositionsMessage::positions() const
235 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
236 const void* theSender)
237 : Events_Message(theID, theSender)
242 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
247 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
248 const std::string& theOldName,
249 const std::string& theNewName,
250 const void* theSender)
252 std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage(
253 new ModelAPI_ObjectRenamedMessage(eventId(), theSender));
254 aMessage->setObject(theObject);
255 aMessage->setOldName(theOldName);
256 aMessage->setNewName(theNewName);
257 Events_Loop::loop()->send(aMessage);
260 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
265 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
267 myObject = theObject;
270 std::string ModelAPI_ObjectRenamedMessage::oldName() const
275 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
277 myOldName = theOldName;
280 std::string ModelAPI_ObjectRenamedMessage::newName() const
285 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
287 myNewName = theNewName;
290 ModelAPI_ReplaceParameterMessage::ModelAPI_ReplaceParameterMessage(const Events_ID theID,
291 const void* theSender)
292 : Events_Message(theID, theSender)
297 ModelAPI_ReplaceParameterMessage::~ModelAPI_ReplaceParameterMessage()
302 void ModelAPI_ReplaceParameterMessage::send(ObjectPtr theObject,
303 const void* theSender)
305 std::shared_ptr<ModelAPI_ReplaceParameterMessage> aMessage(
306 new ModelAPI_ReplaceParameterMessage(eventId(), theSender));
307 aMessage->setObject(theObject);
308 Events_Loop::loop()->send(aMessage);
311 ObjectPtr ModelAPI_ReplaceParameterMessage::object() const
316 void ModelAPI_ReplaceParameterMessage::setObject(ObjectPtr theObject)
318 myObject = theObject;
322 // ===== ModelAPI_SolverFailedMessage =====
323 ModelAPI_SolverFailedMessage::ModelAPI_SolverFailedMessage(const Events_ID theID,
324 const void* theSender)
325 : Events_Message(theID, theSender),
330 ModelAPI_SolverFailedMessage::~ModelAPI_SolverFailedMessage()
334 void ModelAPI_SolverFailedMessage::setObjects(const std::set<ObjectPtr>& theObjects)
336 myObjects = theObjects;
339 const std::set<ObjectPtr>& ModelAPI_SolverFailedMessage::objects() const
345 // ===== ModelAPI_ObjectMovedMessage =====
346 ModelAPI_ObjectMovedMessage::ModelAPI_ObjectMovedMessage(const void* theSender)
347 : Events_Message(Events_Loop::eventByName(EVENT_OBJECT_MOVED), theSender)
351 void ModelAPI_ObjectMovedMessage::setMovedObject(const ObjectPtr& theMovedObject)
353 myMovedObject = theMovedObject;
354 myMovedAttribute = AttributePtr();
357 void ModelAPI_ObjectMovedMessage::setMovedAttribute(const AttributePtr& theMovedAttribute)
359 myMovedAttribute = theMovedAttribute;
360 myMovedObject = ObjectPtr();
363 void ModelAPI_ObjectMovedMessage::setOriginalPosition(double theX, double theY)
365 myOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
368 void ModelAPI_ObjectMovedMessage::setOriginalPosition(
369 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
371 myOriginalPosition = thePoint;
374 void ModelAPI_ObjectMovedMessage::setCurrentPosition(double theX, double theY)
376 myCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
379 void ModelAPI_ObjectMovedMessage::setCurrentPosition(
380 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
382 myCurrentPosition = thePoint;