SHAPER 9.16.0
SketchPlugin_ConstraintDistanceAlongDir.h
1// Copyright (C) 2017-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// File: SketchPlugin_ConstraintDistanceAlongDir.h
21// Created: 24 October 2017
22// Author: Artem ZHIDKOV
23
24#ifndef SketchPlugin_ConstraintDistanceAlongDir_H_
25#define SketchPlugin_ConstraintDistanceAlongDir_H_
26
27#include <SketchPlugin.h>
28#include <SketchPlugin_ConstraintDistance.h>
29
30#include <limits>
31
41{
42public:
44 inline static const std::string& LOCATION_TYPE_ID()
45 {
46 static const std::string MY_LOCATION_TYPE_ID("LocationType");
47 return MY_LOCATION_TYPE_ID;
48 }
49
51 inline static const std::string& DISTANCE_VALUE_ID()
52 {
53 static const std::string& MY_DISTANCE_VALUE("DistanceValue");
54 return MY_DISTANCE_VALUE;
55 }
56
58 inline static const std::string& NEGATIVE_TYPE_ID()
59 {
60 static const std::string MY_NEGATIVE_VALUE("NegativeValue");
61 return MY_NEGATIVE_VALUE;
62 }
63
65 SKETCHPLUGIN_EXPORT virtual void execute();
66
68 SKETCHPLUGIN_EXPORT virtual void initAttributes();
69
71 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
72
75 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
76
79 void setNumericValue(const double theValue) override;
80
82 inline double getNumericValue() override
83 {
84 return real(DISTANCE_VALUE_ID())? real(DISTANCE_VALUE_ID())->value(): std::numeric_limits<double>::lowest();
85 }
86
89
90protected:
92 virtual double calculateCurrentDistance() = 0;
93
95 virtual void updateFlyoutPoint() = 0;
96
97protected:
98 double myValue;
99 bool myValueUpdate;
100};
101
102#endif
std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)
Returns the real attribute by the identifier.
Definition: ModelAPI_Feature.h:211
Feature for creation of a new constraint which defines a distance along direction.
Definition: SketchPlugin_ConstraintDistanceAlongDir.h:41
static const std::string & LOCATION_TYPE_ID()
attribute name of dimension location type
Definition: SketchPlugin_ConstraintDistanceAlongDir.h:44
SketchPlugin_ConstraintDistanceAlongDir()
Use plugin manager for features creation.
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:44
virtual void updateFlyoutPoint()=0
Update flyout point.
virtual SKETCHPLUGIN_EXPORT void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:52
virtual SKETCHPLUGIN_EXPORT AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:86
double getNumericValue() override
Get numeric value of attribute DISTANCE_VALUE_ID()
Definition: SketchPlugin_ConstraintDistanceAlongDir.h:82
virtual SKETCHPLUGIN_EXPORT void execute()
Creates a new part document if needed.
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:75
virtual double calculateCurrentDistance()=0
Returns the current distance between the feature attributes.
static const std::string & NEGATIVE_TYPE_ID()
attribute name of the sign of distance
Definition: SketchPlugin_ConstraintDistanceAlongDir.h:58
void setNumericValue(const double theValue) override
Set numeric value to attribute DISTANCE_VALUE_ID()
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:158
static const std::string & DISTANCE_VALUE_ID()
attribute name of the distance value shown to the user
Definition: SketchPlugin_ConstraintDistanceAlongDir.h:51
virtual SKETCHPLUGIN_EXPORT void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_ConstraintDistanceAlongDir.cpp:100
Feature for creation of a new constraint which defines a distance between a point and another feature...
Definition: SketchPlugin_ConstraintDistance.h:44