Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeManager Class Reference

#include <KoShapeManager.h>

+ Inheritance diagram for KoShapeManager:

Classes

struct  PaintJob
 
struct  PaintJobsOrder
 
struct  ShapeInterface
 

Public Types

enum  Repaint { PaintShapeOnAdd , AddWithoutRepaint }
 enum for add() More...
 

Public Slots

void addShape (KoShape *shape, KoShapeManager::Repaint repaint=PaintShapeOnAdd)
 
void remove (KoShape *shape)
 

Signals

void contentChanged ()
 emitted when any object changed (moved/rotated etc)
 
void forwardUpdate ()
 Emitted upon update and used to update the canvas.
 
void selectionChanged ()
 emitted when the selection is changed
 
void selectionContentChanged ()
 emitted when an object in the selection is changed (moved/rotated etc)
 

Public Member Functions

void explicitlyIssueShapeChangedSignals ()
 
void forwardCompressedUpdate ()
 
 KoShapeManager (KoCanvasBase *canvas)
 
 KoShapeManager (KoCanvasBase *canvas, const QList< KoShape * > &shapes)
 
void notifyShapeChanged (KoShape *shape)
 
void paint (QPainter &painter)
 
void paintJob (QPainter &painter, const KoShapeManager::PaintJob &job)
 
void preparePaintJobs (PaintJobsOrder &jobsOrder, KoShape *excludeRoot)
 
 Private (KoShapeManager *shapeManager, KoCanvasBase *c)
 
KoSelectionselection () const
 return the selection shapes for this shapeManager
 
void setShapes (const QList< KoShape * > &shapes, Repaint repaint=PaintShapeOnAdd)
 
void setUpdatesBlocked (bool value)
 
KoShapeshapeAt (const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
 
ShapeInterfaceshapeInterface ()
 
QList< KoShape * > shapes () const
 returns the list of maintained shapes
 
QList< KoShape * > shapesAt (const QRectF &rect, bool omitHiddenShapes=true, bool containedMode=false)
 
QList< KoShape * > topLevelShapes () const
 
void unlinkFromShapesRecursively (const QList< KoShape * > &shapes)
 
void update (const QRectF &rect, const KoShape *shape=0, bool selectionHandles=false)
 
bool updatesBlocked () const
 
void updateTree ()
 
 ~KoShapeManager () override
 
 ~Private ()
 

Static Public Member Functions

static void renderSingleShape (KoShape *shape, QPainter &painter)
 renderSingleShape renders a shape on painter. This method includes all the needed steps for painting a single shape: setting transformations, clipping and masking.
 

Public Attributes

QSet< KoShape * > aggregate4update
 
KoCanvasBasecanvas
 
QRectF compressedUpdate
 
QSet< const KoShape * > compressedUpdatedShapes
 
KoShapeManagerq
 
KoSelectionselection
 
KoShapeManager::ShapeInterface shapeInterface
 
QList< KoShape * > shapes
 
QMutex shapesMutex
 
KoRTree< KoShape * > tree
 
QMutex treeMutex
 
bool updatesBlocked = false
 

Private Member Functions

KoCanvasBasecanvas ()
 
- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

The shape manager hold a list of all shape which are in scope. There is one shape manager per canvas. This makes the shape manager different from QGraphicsScene, which contains the datamodel for all graphics items: KoShapeManager only contains the subset of shapes that are shown in its canvas.

The selection in the different views can be different.

Definition at line 41 of file KoShapeManager.h.

Member Enumeration Documentation

◆ Repaint

enum for add()

Enumerator
PaintShapeOnAdd 

Causes each shapes 'update()' to be called after being added to the shapeManager.

AddWithoutRepaint 

Avoids each shapes 'update()' to be called for faster addition when its possible.

Definition at line 47 of file KoShapeManager.h.

47 {
50 };
@ AddWithoutRepaint
Avoids each shapes 'update()' to be called for faster addition when its possible.
@ PaintShapeOnAdd
Causes each shapes 'update()' to be called after being added to the shapeManager.

Constructor & Destructor Documentation

◆ KoShapeManager() [1/2]

KoShapeManager::KoShapeManager ( KoCanvasBase * canvas)
explicit

Constructor.

Definition at line 325 of file KoShapeManager.cpp.

326 : d(new Private(this, canvas))
327{
328 Q_ASSERT(d->canvas); // not optional.
329 connect(d->selection, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
330
331 // see a comment in another constructor
332 this->moveToThread(qApp->thread());
333 connect(this, SIGNAL(forwardUpdate()), this, SLOT(forwardCompressedUpdate()));
334}
void forwardCompressedUpdate()
void selectionChanged()
emitted when the selection is changed
Private *const d
KoCanvasBase * canvas
void forwardUpdate()
Emitted upon update and used to update the canvas.
KisCanvas2 * canvas

References Private::canvas, d, forwardCompressedUpdate(), forwardUpdate(), and selectionChanged().

◆ KoShapeManager() [2/2]

KoShapeManager::KoShapeManager ( KoCanvasBase * canvas,
const QList< KoShape * > & shapes )

Constructor that takes a list of shapes, convenience version.

Parameters
shapesthe shapes to start out with, see also setShapes()
canvasthe canvas this shape manager is working on.

Shape manager uses uses queued signals, therefore it should belong to the GUI thread.

Definition at line 310 of file KoShapeManager.cpp.

311 : d(new Private(this, canvas))
312{
313 Q_ASSERT(d->canvas); // not optional.
314 connect(d->selection, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
316
321 this->moveToThread(qApp->thread());
322 connect(this, SIGNAL(forwardUpdate()), this, SLOT(forwardCompressedUpdate()));
323}
QList< KoShape * > shapes
void setShapes(const QList< KoShape * > &shapes, Repaint repaint=PaintShapeOnAdd)

References Private::canvas, d, forwardCompressedUpdate(), forwardUpdate(), selectionChanged(), setShapes(), and shapes.

◆ ~KoShapeManager()

KoShapeManager::~KoShapeManager ( )
override

Definition at line 348 of file KoShapeManager.cpp.

349{
350 d->unlinkFromShapesRecursively(d->shapes);
351 d->shapes.clear();
352
353 delete d;
354}

References d.

◆ ~Private()

KoShapeManager::~Private ( )
inline

Definition at line 37 of file KoShapeManager_p.h.

37 {
38 delete selection;
39 }
KoSelection * selection

Member Function Documentation

◆ addShape

void KoShapeManager::addShape ( KoShape * shape,
KoShapeManager::Repaint repaint = PaintShapeOnAdd )
slot

Add a KoShape to be displayed and managed by this manager. This will trigger a repaint of the shape.

Parameters
shapethe shape to add
repaintif true it will trigger a repaint of the shape

Definition at line 377 of file KoShapeManager.cpp.

378{
379 {
380 QMutexLocker l1(&d->shapesMutex);
381
382 if (d->shapes.contains(shape))
383 return;
384 shape->addShapeManager(this);
385 d->shapes.append(shape);
386
387 if (shapeUsedInRenderingTree(shape)) {
388 QMutexLocker l2(&d->treeMutex);
389
390 QRectF br(shape->boundingRect());
391 d->tree.insert(br, shape);
392 }
393 }
394
395 if (repaint == PaintShapeOnAdd) {
396 shape->update();
397 }
398
399 // add the children of a KoShapeContainer
400 KoShapeContainer *container = dynamic_cast<KoShapeContainer*>(shape);
401
402 if (container) {
403 foreach (KoShape *containerShape, container->shapes()) {
404 addShape(containerShape, repaint);
405 }
406 }
407}
QList< KoShape * > shapes() const
void addShape(KoShape *shape, KoShapeManager::Repaint repaint=PaintShapeOnAdd)
void addShapeManager(KoShapeManager *manager)
Definition KoShape.cpp:120
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:299
virtual void update() const
Definition KoShape.cpp:534

References addShape(), KoShape::addShapeManager(), KoShape::boundingRect(), d, PaintShapeOnAdd, KoShapeContainer::shapes(), and KoShape::update().

◆ canvas()

KoCanvasBase * KoShapeManager::canvas ( )
private

◆ contentChanged

void KoShapeManager::contentChanged ( )
signal

emitted when any object changed (moved/rotated etc)

◆ explicitlyIssueShapeChangedSignals()

void KoShapeManager::explicitlyIssueShapeChangedSignals ( )

The update signals are usually emitted when the owned of the manager calls to preparePaintJobs() in the beginning of the rendering cycle. This way we avoid too many signals to be emitted. But some of the canvases (e.g. KisShapeSelectionCanvas) doesn't do any rendering (yet?), so the signals should be emitted explicitly.

Definition at line 753 of file KoShapeManager.cpp.

754{
755 d->updateTree();
756}

References d.

◆ forwardCompressedUpdate()

void KoShapeManager::forwardCompressedUpdate ( )

◆ forwardUpdate

void KoShapeManager::forwardUpdate ( )
signal

Emitted upon update and used to update the canvas.

◆ notifyShapeChanged()

void KoShapeManager::notifyShapeChanged ( KoShape * shape)

Update the tree for finding the shapes. This will remove the shape from the tree and will reinsert it again. The update to the tree will be postponed until it is needed so that successive calls will be merged into one.

Parameters
shapethe shape to updated its position in the tree.

Definition at line 707 of file KoShapeManager.cpp.

708{
709 {
710 QMutexLocker l(&d->treeMutex);
711
712 Q_ASSERT(shape);
713 if (d->aggregate4update.contains(shape)) {
714 return;
715 }
716
717 d->aggregate4update.insert(shape);
718 }
719
720 KoShapeContainer *container = dynamic_cast<KoShapeContainer*>(shape);
721 if (container) {
722 Q_FOREACH (KoShape *child, container->shapes())
723 notifyShapeChanged(child);
724 }
725}
void notifyShapeChanged(KoShape *shape)

References d, notifyShapeChanged(), and KoShapeContainer::shapes().

◆ paint()

void KoShapeManager::paint ( QPainter & painter)

Paint all shapes and their selection handles etc.

Parameters
painterthe painter to paint to.
forPrintif true, make sure only actual content is drawn and no decorations.
converterto convert between document and view coordinates.

Definition at line 549 of file KoShapeManager.cpp.

550{
551 d->updateTree();
552
553 QMutexLocker l1(&d->shapesMutex);
554
555 painter.setPen(Qt::NoPen); // painters by default have a black stroke, lets turn that off.
556 painter.setBrush(Qt::NoBrush);
557
558 QList<KoShape*> unsortedShapes;
559 if (painter.hasClipping()) {
560 QMutexLocker l(&d->treeMutex);
561
563 unsortedShapes = d->tree.intersects(rect);
564 } else {
565 unsortedShapes = d->shapes;
566 warnFlake << "KoShapeManager::paint Painting with a painter that has no clipping will lead to too much being painted!";
567 }
568
569 KisForest<KoShape*> renderTree;
570 buildRenderTree(unsortedShapes, renderTree);
571 renderShapes(childBegin(renderTree), childEnd(renderTree), painter);
572}
#define warnFlake
Definition FlakeDebug.h:16
ChildIterator< value_type, is_const > childBegin(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:290
ChildIterator< value_type, is_const > childEnd(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:300
QRect safeClipBoundingRect(const QPainter &painter)

References d, KisPaintingTweaks::safeClipBoundingRect(), and warnFlake.

◆ paintJob()

void KoShapeManager::paintJob ( QPainter & painter,
const KoShapeManager::PaintJob & job )

Render a job on painter. No mutable internals of the shape manager are accessed, so calling this method is safe in multithreading environment.

Parameters
paintera painter to paint on. Clip rect of the painter is expected to be setup correctly.
joba job to paint.
forPrintnot used in Krita.
See also
preparePaintJobs

Definition at line 538 of file KoShapeManager.cpp.

539{
540 painter.setPen(Qt::NoPen); // painters by default have a black stroke, lets turn that off.
541 painter.setBrush(Qt::NoBrush);
542
543 KisForest<KoShape*> renderTree;
544 buildRenderTree(job.shapes, renderTree);
545
546 renderShapes(childBegin(renderTree), childEnd(renderTree), painter);
547}
QList< KoShape * > shapes

References KoShapeManager::PaintJob::shapes.

◆ preparePaintJobs()

void KoShapeManager::preparePaintJobs ( PaintJobsOrder & jobsOrder,
KoShape * excludeRoot )

Prepare a shallow copy of all the shapes and the jobs to be rendered asynchronously later. The copies are stored in jobs, so that the user could later pass these jobs into paintJob() in a separate thread.

Parameters
jobsa list of rects that are going to be updated. docUpdateRect and viewUpdateRect should be preinitialized by the caller.
excludeRootthe root shape which should not be copied. It is basically a hack to avoid copying of KisShapeLayer, which is not copiable.
See also
paintJob()
a comment in KisShapeLayerCanvas::slotStartAsyncRepaint()

Definition at line 471 of file KoShapeManager.cpp.

473{
474 d->updateTree();
475
476 QMutexLocker l1(&d->shapesMutex);
477
478 QSet<KoShape*> rootShapesSet;
479 Q_FOREACH (KoShape *shape, d->shapes) {
480 while (shape->parent() && shape->parent() != excludeRoot) {
481 shape = shape->parent();
482 }
483
484 if (!rootShapesSet.contains(shape) && shape != excludeRoot) {
485 rootShapesSet.insert(shape);
486 }
487 }
488 const QList<KoShape*> rootShapes(rootShapesSet.begin(), rootShapesSet.end());
489 QList<KoShape*> newRootShapes;
490
491 Q_FOREACH (KoShape *srcShape, rootShapes) {
492 KIS_SAFE_ASSERT_RECOVER(srcShape->parent() == excludeRoot
493 || !srcShape->parent()) {
494 continue;
495 }
496
497 KoShape *clonedShape = srcShape->cloneShape();
498
499 KoShapeContainer *parentShape = srcShape->parent();
500
501 if (parentShape && !parentShape->transformation().isIdentity()) {
502 clonedShape->applyAbsoluteTransformation(parentShape->transformation());
503 }
504
505 newRootShapes << clonedShape;
506 }
507
508 PaintJobsOrder result;
509
510 PaintJob::SharedSafeStorage shapesStorage = std::make_shared<PaintJob::ShapesStorage>();
511 Q_FOREACH (KoShape *shape, newRootShapes) {
512 shapesStorage->emplace_back(std::unique_ptr<KoShape>(shape));
513 }
514
515 const QList<KoShape*> originalShapes = KoShape::linearizeSubtreeSorted(rootShapes);
516 const QList<KoShape*> clonedShapes = KoShape::linearizeSubtreeSorted(newRootShapes);
517 KIS_SAFE_ASSERT_RECOVER_RETURN(clonedShapes.size() == originalShapes.size());
518
519 QHash<KoShape*, KoShape*> clonedFromOriginal;
520 for (int i = 0; i < originalShapes.size(); i++) {
521 clonedFromOriginal[originalShapes[i]] = clonedShapes[i];
522 }
523
524
525 for (auto it = std::begin(jobsOrder.jobs); it != std::end(jobsOrder.jobs); ++it) {
526 QMutexLocker l(&d->treeMutex);
527 QList<KoShape*> unsortedOriginalShapes = d->tree.intersects(it->docUpdateRect);
528
529 it->allClonedShapes = shapesStorage;
530
531 Q_FOREACH (KoShape *shape, unsortedOriginalShapes) {
532 KIS_SAFE_ASSERT_RECOVER(shapeUsedInRenderingTree(shape)) { continue; }
533 it->shapes << clonedFromOriginal[shape];
534 }
535 }
536}
void applyAbsoluteTransformation(const QTransform &matrix)
Definition KoShape.cpp:353
KoShapeContainer * parent() const
Definition KoShape.cpp:862
static QList< KoShape * > linearizeSubtreeSorted(const QList< KoShape * > &shapes)
Definition KoShape.cpp:1194
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
Definition KoShape.cpp:172
QTransform transformation() const
Returns the shapes local transformation matrix.
Definition KoShape.cpp:383
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
std::shared_ptr< ShapesStorage > SharedSafeStorage

References KoShape::applyAbsoluteTransformation(), KoShape::cloneShape(), d, KoShapeManager::PaintJobsOrder::jobs, KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_RETURN, KoShape::linearizeSubtreeSorted(), KoShape::parent(), and KoShape::transformation().

◆ Private()

KoShapeManager::Private ( KoShapeManager * shapeManager,
KoCanvasBase * c )
inline

Definition at line 28 of file KoShapeManager_p.h.

29 : selection(new KoSelection(shapeManager)),
30 canvas(c),
31 tree(4, 2),
32 q(shapeManager),
33 shapeInterface(shapeManager)
34 {
35 }
KoShapeManager::ShapeInterface shapeInterface
KoRTree< KoShape * > tree
KoShapeManager * q

◆ remove

void KoShapeManager::remove ( KoShape * shape)
slot

Remove a KoShape from this manager

Parameters
shapethe shape to remove

Definition at line 409 of file KoShapeManager.cpp.

410{
411 QRectF dirtyRect;
412 {
413 QMutexLocker l1(&d->shapesMutex);
414 QMutexLocker l2(&d->treeMutex);
415
416 dirtyRect = shape->boundingRect();
417
418 shape->removeShapeManager(this);
419 d->selection->deselect(shape);
420 d->aggregate4update.remove(shape);
421 d->compressedUpdatedShapes.remove(shape);
422
423 if (shapeUsedInRenderingTree(shape)) {
424 d->tree.remove(shape);
425 }
426 d->shapes.removeAll(shape);
427 }
428
429 if (!dirtyRect.isEmpty()) {
430 d->canvas->updateCanvas(dirtyRect);
431 }
432
433 // remove the children of a KoShapeContainer
434 KoShapeContainer *container = dynamic_cast<KoShapeContainer*>(shape);
435 if (container) {
436 foreach (KoShape *containerShape, container->shapes()) {
437 remove(containerShape);
438 }
439 }
440}
void updateCanvas(const QRectF &rc) override
void remove(KoShape *shape)
void removeShapeManager(KoShapeManager *manager)
Definition KoShape.cpp:125

References KoShape::boundingRect(), Private::canvas, d, remove(), KoShape::removeShapeManager(), KoShapeContainer::shapes(), and KisCanvas2::updateCanvas().

◆ renderSingleShape()

void KoShapeManager::renderSingleShape ( KoShape * shape,
QPainter & painter )
static

renderSingleShape renders a shape on painter. This method includes all the needed steps for painting a single shape: setting transformations, clipping and masking.

Definition at line 574 of file KoShapeManager.cpp.

575{
576 KisForest<KoShape*> renderTree;
577
578 KoViewConverter converter;
579
580 auto root = renderTree.insert(childBegin(renderTree), shape);
581 populateRenderSubtree(shape, root, renderTree, &shapeIsVisible, &shapeIsVisible);
582 renderShapes(childBegin(renderTree), childEnd(renderTree), painter);
583}
child_iterator insert(child_iterator pos, X &&value)
Inserts element value into position pos. value becomes the child of the same parent as pos and is pla...
Definition KisForest.h:943

References KisForestDetail::Forest< T >::insert().

◆ selection()

KoSelection * KoShapeManager::selection ( ) const

return the selection shapes for this shapeManager

◆ selectionChanged

void KoShapeManager::selectionChanged ( )
signal

emitted when the selection is changed

◆ selectionContentChanged

void KoShapeManager::selectionContentChanged ( )
signal

emitted when an object in the selection is changed (moved/rotated etc)

◆ setShapes()

void KoShapeManager::setShapes ( const QList< KoShape * > & shapes,
Repaint repaint = PaintShapeOnAdd )

Remove all previously owned shapes and make the argument list the new shapes to be managed by this manager.

Parameters
shapesthe new shapes to manage.
repaintif true it will trigger a repaint of the shapes

Definition at line 356 of file KoShapeManager.cpp.

357{
358 {
359 QMutexLocker l1(&d->shapesMutex);
360 QMutexLocker l2(&d->treeMutex);
361
362 //clear selection
363 d->selection->deselectAll();
364 d->unlinkFromShapesRecursively(d->shapes);
365 d->compressedUpdate = QRect();
366 d->compressedUpdatedShapes.clear();
367 d->aggregate4update.clear();
368 d->tree.clear();
369 d->shapes.clear();
370 }
371
372 Q_FOREACH (KoShape *shape, shapes) {
373 addShape(shape, repaint);
374 }
375}

References addShape(), d, and shapes.

◆ setUpdatesBlocked()

void KoShapeManager::setUpdatesBlocked ( bool value)

Block all updates initiated with update() call. The incoming updates will be dropped completely.

Definition at line 698 of file KoShapeManager.cpp.

699{
700 d->updatesBlocked = value;
701}
float value(const T *src, size_t ch)

References d, and value().

◆ shapeAt()

KoShape * KoShapeManager::shapeAt ( const QPointF & position,
KoFlake::ShapeSelection selection = KoFlake::ShapeOnTop,
bool omitHiddenShapes = true )

Returns the shape located at a specific point in the document. If more than one shape is located at the specific point, the given selection type controls which of them is returned.

Parameters
positionthe position in the document coordinate system.
selectioncontrols which shape is returned when more than one shape is at the specific point
omitHiddenShapesif true, only visible shapes are considered

Definition at line 585 of file KoShapeManager.cpp.

586{
587 d->updateTree();
588
589 QMutexLocker l(&d->shapesMutex);
590
591 QList<KoShape*> sortedShapes;
592
593 {
594 QMutexLocker l(&d->treeMutex);
595 sortedShapes = d->tree.contains(position);
596 }
597
598 std::sort(sortedShapes.begin(), sortedShapes.end(), KoShape::compareShapeZIndex);
599 KoShape *firstUnselectedShape = 0;
600 for (int count = sortedShapes.count() - 1; count >= 0; count--) {
601 KoShape *shape = sortedShapes.at(count);
602 if (omitHiddenShapes && ! shape->isVisible())
603 continue;
604 if (! shape->hitTest(position))
605 continue;
606
607 switch (selection) {
609 if (shape->isSelectable())
610 return shape;
611 break;
613 if (d->selection->isSelected(shape))
614 return shape;
615 break;
617 if (! d->selection->isSelected(shape))
618 return shape;
619 break;
621 // we want an unselected shape
622 if (d->selection->isSelected(shape))
623 continue;
624 // memorize the first unselected shape
625 if (! firstUnselectedShape)
626 firstUnselectedShape = shape;
627 // check if the shape above is selected
628 if (count + 1 < sortedShapes.count() && d->selection->isSelected(sortedShapes.at(count + 1)))
629 return shape;
630 break;
631 }
632 }
633 // if we want the next unselected below a selected but there was none selected,
634 // return the first found unselected shape
635 if (selection == KoFlake::NextUnselected && firstUnselectedShape)
636 return firstUnselectedShape;
637
638 if (d->selection->hitTest(position))
639 return d->selection;
640
641 return 0; // missed everything
642}
bool isSelectable() const
Definition KoShape.cpp:837
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:393
virtual bool hitTest(const QPointF &position) const
Check if the shape is hit on position.
Definition KoShape.cpp:280
bool isVisible(bool recursive=true) const
Definition KoShape.cpp:802
@ Unselected
return the first unselected on top.
Definition KoFlake.h:72
@ Selected
return the first selected with the highest z-ordering (i.e. on top).
Definition KoFlake.h:71
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74
@ NextUnselected
return the first unselected directly under a selected shape, or the top most one if nothing is select...
Definition KoFlake.h:73

References KoShape::compareShapeZIndex(), d, KoShape::hitTest(), KoShape::isSelectable(), KoShape::isVisible(), KoFlake::NextUnselected, KoFlake::Selected, selection, KoFlake::ShapeOnTop, and KoFlake::Unselected.

◆ shapeInterface()

ShapeInterface * KoShapeManager::shapeInterface ( )

◆ shapes()

QList< KoShape * > KoShapeManager::shapes ( ) const

returns the list of maintained shapes

◆ shapesAt()

QList< KoShape * > KoShapeManager::shapesAt ( const QRectF & rect,
bool omitHiddenShapes = true,
bool containedMode = false )

Returns the shapes which intersects the specific rect in the document.

Parameters
rectthe rectangle in the document coordinate system.
omitHiddenShapesif true, only visible shapes are considered
containedModeif true use contained mode

Definition at line 644 of file KoShapeManager.cpp.

645{
646 d->updateTree();
648
649 {
650 QMutexLocker l(&d->treeMutex);
651 shapes = containedMode ? d->tree.contained(rect) : d->tree.intersects(rect);
652 }
653
654 for (int count = shapes.count() - 1; count >= 0; count--) {
655
656 KoShape *shape = shapes.at(count);
657
658 if (omitHiddenShapes && !shape->isVisible()) {
659 shapes.removeAt(count);
660 } else {
661 const QPainterPath outline = shape->absoluteTransformation().map(shape->outline());
662
663 if (!containedMode && !outline.intersects(rect) && !outline.contains(rect)) {
664 shapes.removeAt(count);
665
666 } else if (containedMode) {
667
668 QPainterPath containingPath;
669 containingPath.addRect(rect);
670
671 if (!containingPath.contains(outline)) {
672 shapes.removeAt(count);
673 }
674 }
675 }
676 }
677
678 return shapes;
679}
virtual QPainterPath outline() const
Definition KoShape.cpp:559
QTransform absoluteTransformation() const
Definition KoShape.cpp:335

References KoShape::absoluteTransformation(), d, KoShape::isVisible(), KoShape::outline(), and shapes.

◆ topLevelShapes()

QList< KoShape * > KoShapeManager::topLevelShapes ( ) const

Get a list of all shapes that don't have a parent.

Definition at line 734 of file KoShapeManager.cpp.

735{
736 QMutexLocker l(&d->shapesMutex);
737
739 // get all toplevel shapes
740 Q_FOREACH (KoShape *shape, d->shapes) {
741 if (!shape->parent() || dynamic_cast<KoShapeLayer*>(shape->parent())) {
742 shapes.append(shape);
743 }
744 }
745 return shapes;
746}

References d, KoShape::parent(), and shapes.

◆ unlinkFromShapesRecursively()

void KoShapeManager::unlinkFromShapesRecursively ( const QList< KoShape * > & shapes)

Recursively detach the shapes from this shape manager

◆ update()

void KoShapeManager::update ( const QRectF & rect,
const KoShape * shape = 0,
bool selectionHandles = false )

Request a repaint to be queued. The repaint will be restricted to the parameters rectangle, which is expected to be in points (the document coordinates system of KoShape) and it is expected to be normalized and based in the global coordinates, not any local coordinates.

This method will return immediately and only request a repaint. Successive calls will be merged into an appropriate repaint action.

Parameters
rectthe rectangle (in pt) to queue for repaint.
shapethe shape that is going to be redrawn; only needed when selectionHandles=true
selectionHandlesif true; find out if the shape is selected and repaint its selection handles at the same time.

Definition at line 681 of file KoShapeManager.cpp.

682{
683 if (d->updatesBlocked) return;
684
685 {
686 QMutexLocker l(&d->shapesMutex);
687
688 d->compressedUpdate |= rect;
689
690 if (selectionHandles) {
691 d->compressedUpdatedShapes.insert(shape);
692 }
693 }
694
695 emit(forwardUpdate());
696}

References d, and forwardUpdate().

◆ updatesBlocked()

bool KoShapeManager::updatesBlocked ( ) const

◆ updateTree()

void KoShapeManager::updateTree ( )

Update the tree when there are shapes in m_aggregate4update. This is done so not all updates to the tree are done when they are asked for but when they are needed.

Member Data Documentation

◆ aggregate4update

QSet<KoShape *> KoShapeManager::aggregate4update

Definition at line 59 of file KoShapeManager_p.h.

◆ canvas

KoCanvasBase * KoShapeManager::canvas

Definition at line 57 of file KoShapeManager_p.h.

◆ compressedUpdate

QRectF KoShapeManager::compressedUpdate

Definition at line 65 of file KoShapeManager_p.h.

◆ compressedUpdatedShapes

QSet<const KoShape*> KoShapeManager::compressedUpdatedShapes

Definition at line 66 of file KoShapeManager_p.h.

◆ d

Private* const KoShapeManager::d
private

Definition at line 277 of file KoShapeManager.h.

◆ q

KoShapeManager* KoShapeManager::q

Definition at line 60 of file KoShapeManager_p.h.

◆ selection

KoSelection * KoShapeManager::selection

Definition at line 56 of file KoShapeManager_p.h.

◆ shapeInterface

KoShapeManager::ShapeInterface * KoShapeManager::shapeInterface

Definition at line 61 of file KoShapeManager_p.h.

◆ shapes

QList< KoShape * > KoShapeManager::shapes

Definition at line 55 of file KoShapeManager_p.h.

◆ shapesMutex

QMutex KoShapeManager::shapesMutex

Definition at line 62 of file KoShapeManager_p.h.

◆ tree

KoRTree<KoShape *> KoShapeManager::tree

Definition at line 58 of file KoShapeManager_p.h.

◆ treeMutex

QMutex KoShapeManager::treeMutex

Definition at line 63 of file KoShapeManager_p.h.

◆ updatesBlocked

bool KoShapeManager::updatesBlocked = false

Definition at line 68 of file KoShapeManager_p.h.


The documentation for this class was generated from the following files: