X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Events.cpp;h=0a425d8c2eb5e67a4e558c2c9759ce6667633009;hb=dc1f458b1518baeab0479275e47fd60d50bc18b7;hp=278867e0afd7b814c2564cde0321ade8e84c8b8b;hpb=318198d7b52d6e046d85eeb838cf5a7247703786;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp index 278867e0a..0a425d8c2 100644 --- a/src/ModelAPI/ModelAPI_Events.cpp +++ b/src/ModelAPI/ModelAPI_Events.cpp @@ -1,15 +1,33 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -/* - * ModelAPI_Events.cpp - * - * Created on: Dec 8, 2014 - * Author: sbh - */ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include #include +#include + +//#define DEBUG_OBJECT_MOVED_MESSAGE +#ifdef DEBUG_OBJECT_MOVED_MESSAGE +#include +#endif + ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender) : Events_MessageGroup(theID, theSender) @@ -35,7 +53,7 @@ ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage() } ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID, - const void* theSender) + const void* theSender) : Events_Message(theID, theSender) { @@ -97,17 +115,13 @@ std::list ModelAPI_FeatureStateMessage::features() const } -ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID, - const void* theSender) +ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage( + const Events_ID theID, const void* theSender) : Events_Message(theID, theSender) -{ - -} +{} ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage() -{ - -} +{} DocumentPtr ModelAPI_DocumentCreatedMessage::document() const { @@ -119,28 +133,110 @@ void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument) myDocument = theDocument; } -ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(const Events_ID theID, - const void* theSender) +ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage( + const Events_ID theID, const void* theSender) : Events_Message(theID, theSender) +{} + +ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage() +{} + +AttributePtr ModelAPI_AttributeEvalMessage::attribute() const { + return myAttribute; +} +void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theAttribute) +{ + myAttribute = theAttribute; } -ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage() +ModelAPI_ParameterEvalMessage::ModelAPI_ParameterEvalMessage( + const Events_ID theID, const void* theSender) + : Events_Message(theID, theSender), myIsProcessed(false) +{} + +ModelAPI_ParameterEvalMessage::~ModelAPI_ParameterEvalMessage() +{} + +FeaturePtr ModelAPI_ParameterEvalMessage::parameter() const +{ + return myParam; +} + +void ModelAPI_ParameterEvalMessage::setParameter(FeaturePtr theParam) { + myParam = theParam; +} +void ModelAPI_ParameterEvalMessage::setResults( + const std::list >& theParamsList, + const double theResult, const std::string& theError) +{ + myParamsList = theParamsList; + myResult = theResult; + myError = theError; + myIsProcessed = true; } -AttributePtr ModelAPI_AttributeEvalMessage::attribute() const +bool ModelAPI_ParameterEvalMessage::isProcessed() { - return myAttribute; + return myIsProcessed; +} + +const std::list >& + ModelAPI_ParameterEvalMessage::params() const +{ + return myParamsList; +} + +const double& ModelAPI_ParameterEvalMessage::result() const +{ + return myResult; +} + +const std::string& ModelAPI_ParameterEvalMessage::error() const +{ + return myError; +} + +ModelAPI_ComputePositionsMessage::ModelAPI_ComputePositionsMessage( + const Events_ID theID, const void* theSender) + : Events_Message(theID, theSender) +{} + +ModelAPI_ComputePositionsMessage::~ModelAPI_ComputePositionsMessage() +{} + +const std::string& ModelAPI_ComputePositionsMessage::expression() const +{ + return myExpression; +} + +const std::string& ModelAPI_ComputePositionsMessage::parameter() const +{ + return myParamName; +} + +void ModelAPI_ComputePositionsMessage::set( + const std::string& theExpression, const std::string& theParameter) +{ + myExpression = theExpression; + myParamName = theParameter; } -void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theDocument) +void ModelAPI_ComputePositionsMessage::setPositions( + const std::list >& thePositions) { - myAttribute = theDocument; + myPositions = thePositions; } +const std::list >& ModelAPI_ComputePositionsMessage::positions() const +{ + return myPositions; +} + + ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID, const void* theSender) : Events_Message(theID, theSender) @@ -226,3 +322,87 @@ void ModelAPI_ReplaceParameterMessage::setObject(ObjectPtr theObject) { myObject = theObject; } + + +// ===== ModelAPI_SolverFailedMessage ===== +ModelAPI_SolverFailedMessage::ModelAPI_SolverFailedMessage(const Events_ID theID, + const void* theSender) + : Events_Message(theID, theSender), + myDOF(-1) +{ +} + +ModelAPI_SolverFailedMessage::~ModelAPI_SolverFailedMessage() +{ +} + +void ModelAPI_SolverFailedMessage::setObjects(const std::set& theObjects) +{ + myObjects = theObjects; +} + +const std::set& ModelAPI_SolverFailedMessage::objects() const +{ + return myObjects; +} + + +// ===== ModelAPI_ObjectMovedMessage ===== +ModelAPI_ObjectMovedMessage::ModelAPI_ObjectMovedMessage(const void* theSender) + : Events_Message(Events_Loop::eventByName(EVENT_OBJECT_MOVED), theSender) +{ +} + +void ModelAPI_ObjectMovedMessage::setMovedObject(const ObjectPtr& theMovedObject) +{ + myMovedObject = theMovedObject; + myMovedAttribute = AttributePtr(); +} + +void ModelAPI_ObjectMovedMessage::setMovedAttribute(const AttributePtr& theMovedAttribute) +{ + myMovedAttribute = theMovedAttribute; + myMovedObject = ObjectPtr(); +} + +void ModelAPI_ObjectMovedMessage::setOriginalPosition(double theX, double theY) +{ + myOriginalPosition = std::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); +#ifdef DEBUG_OBJECT_MOVED_MESSAGE + std::cout << "setOriginalPosition: " << myOriginalPosition->x() << ", " + << myOriginalPosition->y() << std::endl; +#endif +} + +void ModelAPI_ObjectMovedMessage::setOriginalPosition( + const std::shared_ptr& thePoint) +{ + myOriginalPosition = thePoint; +#ifdef DEBUG_OBJECT_MOVED_MESSAGE + std::cout << "setOriginalPosition: " << myOriginalPosition->x() << ", " + << myOriginalPosition->y() << std::endl; +#endif +} + +void ModelAPI_ObjectMovedMessage::setCurrentPosition(double theX, double theY) +{ + myCurrentPosition = std::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); +#ifdef DEBUG_OBJECT_MOVED_MESSAGE + std::cout << "setCurrentPosition: " << myCurrentPosition->x() << ", " << myCurrentPosition->y() + << ", myCurrentPosition - myOriginalPosition: " + << myCurrentPosition->x() - myOriginalPosition->x() << ", " + << myCurrentPosition->y() - myOriginalPosition->y() << std::endl; +#endif +} + +void ModelAPI_ObjectMovedMessage::setCurrentPosition( + const std::shared_ptr& thePoint) +{ + myCurrentPosition = thePoint; +#ifdef DEBUG_OBJECT_MOVED_MESSAGE + std::cout << "setCurrentPosition: " << myCurrentPosition->x() << ", " << myCurrentPosition->y() + << ", myCurrentPosition - myOriginalPosition: " + << myCurrentPosition->x() - myOriginalPosition->x() << ", " + << myCurrentPosition->y() - myOriginalPosition->y() << std::endl; +#endif +}