X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Tools.h;h=730d865b9127c4c9eee76c2995c18a862cd4bc01;hb=97917d3698f5a2f7fc9596e7c755ff8f6751e373;hp=6b242532bb74ce7fdd5e443d9a42336c074f0ccc;hpb=cbde248859fb0072f6012907391ea90cfc254574;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Tools.h b/src/SketchPlugin/SketchPlugin_Tools.h index 6b242532b..730d865b9 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.h +++ b/src/SketchPlugin/SketchPlugin_Tools.h @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: SketchPlugin_Tools.h -// Created: 07 July 2015 -// Author: Sergey POKHODENKO +// Copyright (C) 2014-2019 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 +// #ifndef SKETCHPLUGIN_TOOLS_H_ #define SKETCHPLUGIN_TOOLS_H_ @@ -11,45 +24,98 @@ #include #include +#include +#include + +class SketchPlugin_Constraint; +class SketchPlugin_Feature; +class SketchPlugin_Sketch; namespace SketchPlugin_Tools { -/// Clears text expressions for all attributes of the feature +/// Clears text expressions for all attributes of the feature void clearExpressions(FeaturePtr theFeature); /// \return coincidence point /// \param[in] theStartCoin coincidence feature std::shared_ptr getCoincidencePoint(const FeaturePtr theStartCoin); +/// Find all Coincident constraints referred to the feature or its attribute +std::set findCoincidentConstraints(const FeaturePtr& theFeature); + /// Finds lines coincident at point /// \param[in] theStartCoin coincidence feature /// \param[in] theAttr attribute name /// \param[out] theList list of lines +/// \param[in] theIsAttrOnly if true includes only coincidences with attributes. void findCoincidences(const FeaturePtr theStartCoin, const std::string& theAttr, - std::set& theList); - -/// Changes the second attribute value to be multiplied or divided by the given value. -/// \param theFirstAngleAttribute the source attribute -/// \param theSecondAngleAttribute the changed attribute -/// \param theValue a value for modification -/// \param toMultiply a type of modification -void updateMultiAttribute(const AttributePtr& theFirstAngleAttribute, - const AttributePtr& theSecondAngleAttribute, - const int& theValue, - const bool toMultiply); - -/// Changes the second attribute value to be multiplied or divided by the given value. -/// \param theFirstAngleAttribute the source attribute -/// \param theSecondAngleAttribute the changed attribute -/// \param theValue a value for modification -/// \param toMultiply a type of modification -void updateMultiAttribute(const AttributePtr& theFirstAttribute, - const AttributePtr& theSecondAttribute, - const AttributePtr& theModifiedAttribute, - const int& theValue, - const bool toMultiply); + std::set& theList, + const bool theIsAttrOnly = false); + +/// Find all features the point is coincident to. +std::set findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint); + +/// Find all points the given point is coincident to. +std::set findPointsCoincidentToPoint(const AttributePoint2DPtr& thePoint); + +void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId); + +/// Create new constraint between given attributes +/// \param[in] theSketch a sketch where the constraint will be created +/// \param[in] theConstraintId a constraint identifier +/// \param[in] theFirstAttribute an attribute of further constraint +/// \param[in] theSecondAttribute an attribute of further constraint +FeaturePtr createConstraintAttrAttr(SketchPlugin_Sketch* theSketch, + const std::string& theConstraintId, + const AttributePtr& theFirstAttribute, + const AttributePtr& theSecondAttribute); + +/// Create new constraint between given attribute and object +/// \param[in] theSketch a sketch where the constraint will be created +/// \param[in] theConstraintId a constraint identifier +/// \param[in] theFirstAttribute an attribute of further constraint +/// \param[in] theSecondObject an attribute of further constraint +FeaturePtr createConstraintAttrObject(SketchPlugin_Sketch* theSketch, + const std::string& theConstraintId, + const AttributePtr& theFirstAttribute, + const ObjectPtr& theSecondObject); + +/// Create new constraint between given objects +/// \param[in] theSketch a sketch where the constraint will be created +/// \param[in] theConstraintId a constraint identifier +/// \param[in] theFirstObject an attribute of further constraint +/// \param[in] theSecondObject an attribute of further constraint +FeaturePtr createConstraintObjectObject(SketchPlugin_Sketch* theSketch, + const std::string& theConstraintId, + const ObjectPtr& theFirstObject, + const ObjectPtr& theSecondObject); + +/// Creates coincidence or tangent constraint. +/// \param[in] theFeature to get selected attribute or object +/// \param[in] theId ID of attribute where selection is. +/// \param[in] theObject object for constraint +/// \param[in] theIsCanBeTangent if true constraint can be tangent or coincidence, depending on +/// the selection in the attribute with passed ID. +void createCoincidenceOrTangency(SketchPlugin_Feature* theFeature, + const std::string& theId, + const AttributePtr theAttr, + const ObjectPtr theObject, + const bool theIsCanBeTangent); + +/// Creates passing point or tangent curve basing on the given attributes are initialized. +/// \param[in] theRefAttr prefered attribute to be converted +/// \param[in] theDefaultAttr default attribute if theRefAttr is not initialized +/// \param[out] theTangentCurve tangent curve if theRefAttr refers to an edge +/// \param[out] thePassingPoint passing point if theRefAttr does not refer to an edge +void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr& theRefAttr, + const AttributePtr& theDefaultAttr, + std::shared_ptr& theTangentCurve, + std::shared_ptr& thePassingPoint); + +/// Calculate global coordinates for flyout point of Length constraint +GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr& theConstraint); }; // namespace SketchPlugin_Tools #endif // SKETCHPLUGIN_TOOLS_H_ \ No newline at end of file