MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / createPickWidget_

Method createPickWidget_

source/MRViewer/MRPickPointManager.cpp:234–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234std::shared_ptr<SurfacePointWidget> PickPointManager::createPickWidget_( const std::shared_ptr<MR::VisualObject>& obj, const PickedPoint& pt )
235{
236 auto newPoint = std::make_shared<SurfacePointWidget>();
237 newPoint->setAutoHover( false );
238 newPoint->setParameters( params.surfacePointParams );
239 newPoint->setBaseColor( params.ordinaryPointColor );
240 newPoint->create( obj, pt );
241
242 newPoint->setCanMoveCallback( [this, obj = obj] ( SurfacePointWidget& pointWidget, const PickedPoint& )->bool
243 {
244 const int index = getPointIndex( obj, pointWidget );
245 if ( index < 0 )
246 {
247 assert( false );
248 return false;
249 }
250 if ( params.canMovePoint )
251 return params.canMovePoint( obj, index );
252 return true;
253 } );
254
255 newPoint->setStartMoveCallback( [this, obj = obj] ( SurfacePointWidget & pointWidget, const PickedPoint& point )
256 {
257 const int index = getPointIndex( obj, pointWidget );
258 if ( index < 0 )
259 {
260 assert( false );
261 return;
262 }
263 moveClosedPoint_ = false;
264 const auto& contour = pickedPoints_[obj];
265 if ( isClosedContour( obj ) )
266 moveClosedPoint_ = &pointWidget == contour[0].get();
267 if ( params.writeHistory )
268 {
269 SCOPED_HISTORY( "Move Point" + params.historyNameSuffix );
270 AppendHistory<MovePointHistoryAction>( *this, obj, point, index );
271 if ( moveClosedPoint_ )
272 AppendHistory<MovePointHistoryAction>( *this, obj, point, int( contour.size() ) - 1 );
273 }
274 assert( hoveredPointWidget_ == &pointWidget );
275 draggedPointWidget_ = &pointWidget;
276 if ( params.onPointMoveStart )
277 params.onPointMoveStart( obj, index );
278
279 } );
280
281 newPoint->setOnMoveCallback( [this, obj = obj] ( SurfacePointWidget & pointWidget, const PickedPoint& point )
282 {
283 if ( moveClosedPoint_ )
284 {
285 const auto& contour = pickedPoints_[obj];
286 if ( &pointWidget == contour[0].get() )
287 contour.back()->setCurrentPosition( point );
288 }
289 assert( draggedPointWidget_ == &pointWidget );
290 if ( params.onPointMove )
291 {

Callers

nothing calls this directly

Calls 11

getPickedPointPositionFunction · 0.85
setBaseColorMethod · 0.80
setCurrentPositionMethod · 0.80
setParametersMethod · 0.45
createMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
connectMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected