SHAPER 9.16.0
Model_AttributeSelection.h
1// Copyright (C) 2014-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#ifndef Model_AttributeSelection_H_
21#define Model_AttributeSelection_H_
22
23#include "Model.h"
24#include "Model_AttributeReference.h"
25#include <ModelAPI_AttributeSelection.h>
26#include <Selector_NameGenerator.h>
27#include <TDF_LabelMap.hxx>
28#include <TopoDS_Shape.hxx>
29#include <TopTools_ListOfShape.hxx>
30
32class Model_Document;
33
40{
43 ObjectPtr myTmpContext;
45 std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
47 CenterType myTmpCenterType;
50
52 std::shared_ptr<Model_Document> myRestoreDocument;
54 bool myIsGeometricalSelection;
55
56public:
63 MODEL_EXPORT virtual bool setValue(
64 const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
65 const bool theTemporarily = false);
66
69 MODEL_EXPORT virtual void setValueCenter(
70 const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
71 const CenterType theCenterType,
72 const bool theTemporarily = false);
73
75 MODEL_EXPORT virtual void selectValue(
76 const std::shared_ptr<ModelAPI_AttributeSelection>& theSource);
77
79 virtual void removeTemporaryValues();
80
82 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> value();
83
85 MODEL_EXPORT virtual ResultPtr context();
86
88 MODEL_EXPORT virtual FeaturePtr contextFeature();
90 MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> contextObject();
91
93 MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
94
97 MODEL_EXPORT virtual bool update();
98
101 MODEL_EXPORT virtual std::wstring namingName(const std::wstring& theDefaultValue = L"");
102
104 MODEL_EXPORT virtual void setId(int theID);
105
107 MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
108 const std::wstring& theSubShapeName);
109
111 MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
112 const std::shared_ptr<GeomAPI_Pnt>& thePoint,
113 const bool theIsIgnoreGroups = false);
115 MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
116 const std::wstring& theContextName, const int theIndex);
117
119 MODEL_EXPORT virtual bool isInitialized();
120
122 MODEL_EXPORT virtual bool isInvalid();
123
127 MODEL_EXPORT virtual void updateInHistory(bool& theRemove) override;
128
129 // Implementation of the name generator method from the Selector package
130 // This method returns the context name by the label of the sub-selected shape
131 MODEL_EXPORT virtual std::wstring contextName(const TDF_Label theSelectionLab) override;
132
135 MODEL_EXPORT virtual bool restoreContext(std::wstring theName,
136 TDF_Label& theContext, TDF_Label& theValue) override;
137
139 MODEL_EXPORT virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2)
140 const override;
141
143 MODEL_EXPORT virtual std::wstring contextName(const ResultPtr& theContext) const;
144
146 MODEL_EXPORT virtual void combineGeometrical();
147
149 MODEL_EXPORT virtual void reset();
150
151protected:
153 MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel);
154
159 std::shared_ptr<GeomAPI_Shape> internalValue(CenterType& theType);
160
162 virtual void selectBody(
163 const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape);
164
170 virtual bool selectPart(
171 const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
172 const bool theUpdate = false);
173
176 TDF_Label selectionLabel();
177
179 MODEL_EXPORT virtual void setID(const std::string theID);
180
183
185 void split(ResultPtr theContext, TopoDS_Shape theNewShape, TopAbs_ShapeEnum theType);
186
188 bool searchNewContext(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape theContShape,
189 ResultPtr theContext, TopoDS_Shape theValShape, TDF_Label theAccessLabel,
190 std::list<ResultPtr>& theResults, TopTools_ListOfShape& theValShapes);
191
193 ResultPtr newestContext(
194 const ResultPtr theCurrent, const std::shared_ptr<GeomAPI_Shape> theValue);
195
198 void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape,
199 TopTools_ListOfShape& theShapes);
200
202 virtual bool isGeometricalSelection() const {
203 return myIsGeometricalSelection;
204 };
205
208 TDF_Label baseDocumentLab();
209
212 void concealedFeature(
213 const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy,
214 std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature,
215 const bool theCheckWholeFeature = false);
216
217 friend class Model_Data;
218 friend class Model_AttributeSelectionList;
219};
220
221#endif
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
CenterType
Type of the center of the circular of elliptic edge.
Definition: ModelAPI_AttributeSelection.h:38
Attribute that contains reference to feature (located in the same document).
Definition: Model_AttributeReference.h:35
Attribute that contains list of references to the sub-shapes with possibility to manage them.
Definition: Model_AttributeSelectionList.h:38
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: Model_AttributeSelection.h:40
Model_AttributeSelection(TDF_Label &theLabel)
Objects are created for features automatically.
Definition: Model_AttributeSelection.cpp:455
virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2) const override
Returns true if the first result is newer than the second one in the tree of features.
Definition: Model_AttributeSelection.cpp:2028
virtual void removeTemporaryValues()
Reset temporary stored values.
Definition: Model_AttributeSelection.cpp:258
virtual bool update()
Updates the selection due to the changes in the referenced objects.
Definition: Model_AttributeSelection.cpp:570
virtual FeaturePtr contextFeature()
Returns the context of the selection if the whole feature was selected.
Definition: Model_AttributeSelection.cpp:513
virtual void selectSubShape(const std::string &theType, const std::wstring &theSubShapeName)
Selects (i.e. creates Naming data structure) of sub-shape specified by textual name.
Definition: Model_AttributeSelection.cpp:864
TDF_Label selectionLabel()
Returns the label where TNaming_Selection results are stored Note: there must be no attributes stored...
Definition: Model_AttributeSelection.cpp:763
void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape, TopTools_ListOfShape &theShapes)
computes theShapes list - shapes that were generated/modified/deleted the theValShape during creation...
Definition: Model_AttributeSelection.cpp:1185
virtual bool isInvalid()
Returns true if recompute of selection become impossible.
Definition: Model_AttributeSelection.cpp:420
TDF_Label baseDocumentLab()
Returns the module document label if this selection attribute is not in this document.
Definition: Model_AttributeSelection.cpp:2215
virtual void reset()
Resets attribute to default state.
Definition: Model_AttributeSelection.cpp:2224
virtual void updateInHistory(bool &theRemove) override
Updates the arguments of selection if something was affected by creation or reorder of features upper...
Definition: Model_AttributeSelection.cpp:1617
virtual bool isInitialized()
Returns true if attribute was initialized by some value.
Definition: Model_AttributeSelection.cpp:425
virtual bool isGeometricalSelection() const
Returns true if is geometrical selection.
Definition: Model_AttributeSelection.h:202
virtual ResultPtr context()
Returns the context of the selection (the whole shape owner)
Definition: Model_AttributeSelection.cpp:478
bool searchNewContext(std::shared_ptr< Model_Document > theDoc, const TopoDS_Shape theContShape, ResultPtr theContext, TopoDS_Shape theValShape, TDF_Label theAccessLabel, std::list< ResultPtr > &theResults, TopTools_ListOfShape &theValShapes)
When group position is updated, searches the new context and new values.
Definition: Model_AttributeSelection.cpp:1420
virtual void combineGeometrical()
Makes the current local selection becomes all sub-shapes with same base geometry.
Definition: Model_AttributeSelection.cpp:2173
virtual bool restoreContext(std::wstring theName, TDF_Label &theContext, TDF_Label &theValue) override
This method restores by the context and value name the context label and sub-label where the value is...
Definition: Model_AttributeSelection.cpp:1931
virtual void setID(const std::string theID)
Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting.
Definition: Model_AttributeSelection.cpp:464
virtual void selectBody(const ResultPtr &theContext, const std::shared_ptr< GeomAPI_Shape > &theSubShape)
Performs the selection for the body result (TNaming selection)
Definition: Model_AttributeSelection.cpp:683
std::shared_ptr< GeomAPI_Shape > internalValue(CenterType &theType)
Returns the selected subshape, internal method that works without knowledge about special selection o...
Definition: Model_AttributeSelection.cpp:315
void setParent(Model_AttributeSelectionList *theParent)
Sets the parent attribute.
Definition: Model_AttributeSelection.cpp:1879
virtual bool selectPart(const ResultPtr &theContext, const std::shared_ptr< GeomAPI_Shape > &theSubShape, const bool theUpdate=false)
Performs the selection for the part result (selection by name of body result inside of part)
Definition: Model_AttributeSelection.cpp:725
virtual std::shared_ptr< GeomAPI_Shape > value()
Returns the selected subshape.
Definition: Model_AttributeSelection.cpp:306
virtual std::wstring contextName(const TDF_Label theSelectionLab) override
This method returns the context name by the label of the sub-selected shape.
Definition: Model_AttributeSelection.cpp:1884
void concealedFeature(const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy, std::list< FeaturePtr > &theConcealers, const ResultPtr theResultOfFeature, const bool theCheckWholeFeature=false)
Returns features that conceals theFeature and located in history before theStop theResultOfFeature if...
Definition: Model_AttributeSelection.cpp:1354
virtual bool setValue(const ObjectPtr &theContext, const std::shared_ptr< GeomAPI_Shape > &theSubShape, const bool theTemporarily=false)
Defines the result and its selected sub-shape.
Definition: Model_AttributeSelection.cpp:107
void split(ResultPtr theContext, TopoDS_Shape theNewShape, TopAbs_ShapeEnum theType)
Splits theNewShape into sub-shapes of theType type (for the list parent of this attribute)
Definition: Model_AttributeSelection.cpp:544
virtual std::shared_ptr< ModelAPI_Object > contextObject()
Returns the context of the selection : result or feature.
Definition: Model_AttributeSelection.cpp:519
virtual void setId(int theID)
Defines the sub-shape by Id.
Definition: Model_AttributeSelection.cpp:1130
virtual void setObject(const std::shared_ptr< ModelAPI_Object > &theObject)
Sets the feature object.
Definition: Model_AttributeSelection.cpp:527
ResultPtr newestContext(const ResultPtr theCurrent, const std::shared_ptr< GeomAPI_Shape > theValue)
Searches for the newest context, modification of the current, that contains theValue.
Definition: Model_AttributeSelection.cpp:2042
virtual void setValueCenter(const ObjectPtr &theContext, const std::shared_ptr< GeomAPI_Edge > &theEdge, const CenterType theCenterType, const bool theTemporarily=false)
Same as SetValue, but it takes an edge (on circular or elliptic curve) and stores the vertex of the c...
Definition: Model_AttributeSelection.cpp:210
virtual std::wstring namingName(const std::wstring &theDefaultValue=L"")
Returns a textual string of the selection.
Definition: Model_AttributeSelection.cpp:782
virtual void selectValue(const std::shared_ptr< ModelAPI_AttributeSelection > &theSource)
Makes this selection attribute selects the same as in theSource selection.
Definition: Model_AttributeSelection.cpp:243
General object of the application that allows to get/set attributes from the document and compute res...
Definition: Model_Data.h:62
Document for internal data structure of any object storage.
Definition: Model_Document.h:45
An interface for generation of the naming name basing on the current selection and document informati...
Definition: Selector_NameGenerator.h:34