MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / executeForObjects

Method executeForObjects

src/core/objects/boolean_tool.cpp:345–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345bool BooleanTool::executeForObjects(const PathObject* subject, const PathObjects& in_objects, PathObjects& out_objects, CombinedUndoStep& undo_step)
346{
347 if (!executeForObjects(subject, in_objects, out_objects))
348 {
349 Q_ASSERT(out_objects.size() == 0);
350 return false; // in release build
351 }
352
353 // Add original objects to undo step, and remove them from map.
354 QScopedPointer<AddObjectsUndoStep> add_step(new AddObjectsUndoStep(map));
355 for (PathObject* object : in_objects)
356 {
357 if (op != Difference || object == subject)
358 {
359 add_step->addObject(object, object);
360 }
361 }
362 // Keep as separate loop to get the correct index in the previous loop
363 for (PathObject* object : in_objects)
364 {
365 if (op != Difference || object == subject)
366 {
367 map->removeObjectFromSelection(object, false);
368 map->getCurrentPart()->releaseObject(object);
369 object->setMap(map); // necessary so objects are saved correctly
370 }
371 }
372
373 // Add resulting objects to map, and create delete step for them
374 QScopedPointer<DeleteObjectsUndoStep> delete_step(new DeleteObjectsUndoStep(map));
375 MapPart* part = map->getCurrentPart();
376 for (PathObject* object : out_objects)
377 {
378 map->addObject(object);
379 map->addObjectToSelection(object, false);
380 }
381 // Keep as separate loop to get the correct index in the previous loop
382 for (PathObject* object : out_objects)
383 {
384 delete_step->addObject(part->findObjectIndex(object));
385 }
386
387 undo_step.push(add_step.take());
388 undo_step.push(delete_step.take());
389 return true;
390}
391
392bool BooleanTool::executeForObjects(const PathObject* subject, const PathObjects& in_objects, PathObjects& out_objects) const
393{

Callers 3

operator()Method · 0.80
cutHoleMethod · 0.80
processMethod · 0.80

Calls 11

pathObjectToPolygonsFunction · 0.85
polyTreeToPathObjectsFunction · 0.85
getCurrentPartMethod · 0.80
addObjectToSelectionMethod · 0.80
findObjectIndexMethod · 0.80
sizeMethod · 0.45
addObjectMethod · 0.45
releaseObjectMethod · 0.45
setMapMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected