15class ChangePolylineAction :
public HistoryAction
18 using Obj = ObjectLines;
23 name_{ std::move(
name ) }
27 if (
auto p = obj->polyline() )
28 clonePolyline_ = std::make_shared<Polyline3>( *p );
33 ChangePolylineAction( std::string name,
const std::shared_ptr<ObjectLines>& obj, std::shared_ptr<Polyline3> newPolyline ) :
35 name_{ std::move(
name ) }
38 clonePolyline_ = obj->updatePolyline( std::move( newPolyline ) );
41 virtual std::string
name()
const override
46 virtual void action( HistoryAction::Type )
override
51 clonePolyline_ = objLines_->updatePolyline( clonePolyline_ );
54 static void setObjectDirty(
const std::shared_ptr<ObjectLines>& obj )
57 obj->setDirtyFlags( DIRTY_ALL );
60 [[nodiscard]]
virtual size_t heapBytes()
const override
66 std::shared_ptr<ObjectLines> objLines_;
67 std::shared_ptr<Polyline3> clonePolyline_;
73class ChangePolylinePointsAction :
public HistoryAction
76 using Obj = ObjectLines;
81 name_{ std::move(
name ) }
85 if (
auto p = objLines_->polyline() )
86 clonePoints_ = p->points;
89 virtual std::string
name()
const override
94 virtual void action( HistoryAction::Type )
override
99 if (
auto p = objLines_->varPolyline() )
101 std::swap( p->points, clonePoints_ );
102 objLines_->setDirtyFlags( DIRTY_POSITION );
106 static void setObjectDirty(
const std::shared_ptr<ObjectLines>& obj )
109 obj->setDirtyFlags( DIRTY_POSITION );
112 [[nodiscard]]
virtual size_t heapBytes()
const override
114 return name_.capacity() + clonePoints_.heapBytes();
118 std::shared_ptr<ObjectLines> objLines_;
119 VertCoords clonePoints_;
125class ChangePolylineTopologyAction :
public HistoryAction
128 using Obj = ObjectLines;
133 name_{ std::move(
name ) }
137 if (
auto p = objLines_->polyline() )
138 cloneTopology_ = p->topology;
141 virtual std::string
name()
const override
146 virtual void action( HistoryAction::Type )
override
151 if (
auto p = objLines_->varPolyline() )
153 std::swap( p->topology, cloneTopology_ );
154 objLines_->setDirtyFlags( DIRTY_FACE );
158 static void setObjectDirty(
const std::shared_ptr<ObjectLines>& obj )
161 obj->setDirtyFlags( DIRTY_FACE );
164 [[nodiscard]]
virtual size_t heapBytes()
const override
166 return name_.capacity() + cloneTopology_.heapBytes();
170 std::shared_ptr<ObjectLines> objLines_;
171 PolylineTopology cloneTopology_;
179class ChangeOnePointInPolylineAction :
public HistoryAction
182 using Obj = ObjectLines;
188 name_{ std::move(
name ) }
192 if (
auto m = obj->polyline() )
193 if ( m->points.size() > pointId_ )
194 safeCoords_ = m->points[pointId_];
202 safeCoords_{ newCoords },
203 name_{ std::move(
name ) }
205 action( HistoryAction::Type::Redo );
208 virtual std::string
name()
const override
213 virtual void action( HistoryAction::Type )
override
218 if (
auto m = objPoints_->varPolyline() )
220 if ( m->points.size() > pointId_ )
222 std::swap( safeCoords_, m->points[pointId_] );
223 objPoints_->setDirtyFlags( DIRTY_POSITION );
228 static void setObjectDirty(
const std::shared_ptr<ObjectLines>& obj )
231 obj->setDirtyFlags( DIRTY_POSITION );
234 [[nodiscard]]
virtual size_t heapBytes()
const override
236 return name_.capacity();
240 std::shared_ptr<ObjectLines> objPoints_;
242 Vector3f safeCoords_;
unsafe ChangeOnePointInPolylineAction(MR._ByValue_ChangeOnePointInPolylineAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangePolylineAction(MR._ByValue_ChangePolylineAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangePolylinePointsAction(MR._ByValue_ChangePolylinePointsAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangePolylineTopologyAction(MR._ByValue_ChangePolylineTopologyAction _other)
size_t heapBytes(const BitSet &bs)
returns the amount of memory given BitSet occupies on heap
Definition MRMesh/MRBitSet.h:298
std::string name(const T &primitive)
Definition MRFeatures.h:309
Definition MRCameraOrientationPlugin.h:8