|
Krita Source Code Documentation
|
#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) | |
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 |
| KoCanvasBase * | canvas |
| QRectF | compressedUpdate |
| QSet< const KoShape * > | compressedUpdatedShapes |
| KoShapeManager * | q |
| KoSelection * | selection |
| QHash< KoShape *, int > | shapeIndexesBeforeUpdate |
| KoShapeManager::ShapeInterface | shapeInterface |
| QList< KoShape * > | shapes |
| QMutex | shapesMutex |
| KoRTree< KoShape * > | tree |
| QMutex | treeMutex |
| bool | updatesBlocked = false |
Private Member Functions | |
| KoCanvasBase * | canvas () |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| Private *const | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
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.
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.
|
explicit |
Constructor.
Definition at line 336 of file KoShapeManager.cpp.
References Private::canvas, connect(), d, forwardCompressedUpdate(), forwardUpdate(), and selectionChanged().
| KoShapeManager::KoShapeManager | ( | KoCanvasBase * | canvas, |
| const QList< KoShape * > & | shapes ) |
Constructor that takes a list of shapes, convenience version.
| shapes | the shapes to start out with, see also setShapes() |
| canvas | the canvas this shape manager is working on. |
Shape manager uses uses queued signals, therefore it should belong to the GUI thread.
Definition at line 321 of file KoShapeManager.cpp.
References Private::canvas, connect(), d, forwardCompressedUpdate(), forwardUpdate(), selectionChanged(), setShapes(), and shapes.
|
override |
|
inline |
Definition at line 37 of file KoShapeManager_p.h.
|
slot |
Add a KoShape to be displayed and managed by this manager. This will trigger a repaint of the shape.
| shape | the shape to add |
| repaint | if true it will trigger a repaint of the shape |
Definition at line 389 of file KoShapeManager.cpp.
References addShape(), KoShape::addShapeManager(), KoShape::boundingRect(), d, PaintShapeOnAdd, KoShapeContainer::shapes(), and KoShape::update().
|
private |
|
signal |
emitted when any object changed (moved/rotated etc)
| 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 768 of file KoShapeManager.cpp.
References d.
| void KoShapeManager::forwardCompressedUpdate | ( | ) |
|
signal |
Emitted upon update and used to update the canvas.
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.
| shape | the shape to updated its position in the tree. |
Definition at line 721 of file KoShapeManager.cpp.
References d, notifyShapeChanged(), KoShapeContainer::shapes(), and KoShape::zIndex().
| void KoShapeManager::paint | ( | QPainter & | painter | ) |
Paint all shapes and their selection handles etc.
| painter | the painter to paint to. |
| forPrint | if true, make sure only actual content is drawn and no decorations. |
| converter | to convert between document and view coordinates. |
Definition at line 561 of file KoShapeManager.cpp.
References d, KisPaintingTweaks::safeClipBoundingRect(), and warnFlake.
| 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.
| painter | a painter to paint on. Clip rect of the painter is expected to be setup correctly. |
| job | a job to paint. |
| forPrint | not used in Krita. |
Definition at line 550 of file KoShapeManager.cpp.
References KoShapeManager::PaintJob::shapes.
| 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.
| jobs | a list of rects that are going to be updated. docUpdateRect and viewUpdateRect should be preinitialized by the caller. |
| excludeRoot | the root shape which should not be copied. It is basically a hack to avoid copying of KisShapeLayer, which is not copiable. |
Definition at line 483 of file KoShapeManager.cpp.
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().
|
inline |
Definition at line 28 of file KoShapeManager_p.h.
Remove a KoShape from this manager
| shape | the shape to remove |
Definition at line 421 of file KoShapeManager.cpp.
References KoShape::boundingRect(), Private::canvas, d, remove(), KoShape::removeShapeManager(), KoShapeContainer::shapes(), and KisCanvas2::updateCanvas().
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 586 of file KoShapeManager.cpp.
References KisForestDetail::Forest< T >::insert().
| KoSelection * KoShapeManager::selection | ( | ) | const |
return the selection shapes for this shapeManager
|
signal |
emitted when the selection is changed
|
signal |
emitted when an object in the selection is changed (moved/rotated etc)
| 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.
| shapes | the new shapes to manage. |
| repaint | if true it will trigger a repaint of the shapes |
Definition at line 367 of file KoShapeManager.cpp.
References addShape(), d, and shapes.
| void KoShapeManager::setUpdatesBlocked | ( | bool | value | ) |
Block all updates initiated with update() call. The incoming updates will be dropped completely.
Definition at line 712 of file KoShapeManager.cpp.
| 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.
| position | the position in the document coordinate system. |
| selection | controls which shape is returned when more than one shape is at the specific point |
| omitHiddenShapes | if true, only visible shapes are considered |
Definition at line 597 of file KoShapeManager.cpp.
References KoShape::compareShapeZIndex(), d, KoShape::hitTest(), KoShape::isSelectable(), KoShape::isVisible(), KoFlake::NextUnselected, KoFlake::Selected, selection, KoFlake::ShapeOnTop, and KoFlake::Unselected.
| ShapeInterface * KoShapeManager::shapeInterface | ( | ) |
| QList< KoShape * > KoShapeManager::shapesAt | ( | const QRectF & | rect, |
| bool | omitHiddenShapes = true, | ||
| bool | containedMode = false ) |
Returns the shapes which intersects the specific rect in the document.
| rect | the rectangle in the document coordinate system. |
| omitHiddenShapes | if true, only visible shapes are considered |
| containedMode | if true use contained mode |
Definition at line 656 of file KoShapeManager.cpp.
References KoShape::absoluteTransformation(), d, KoShape::isVisible(), KoShape::outline(), and shapes.
Get a list of all shapes that don't have a parent.
Definition at line 749 of file KoShapeManager.cpp.
References d, KoShape::parent(), and shapes.
Recursively detach the shapes from this shape manager
| 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.
| rect | the rectangle (in pt) to queue for repaint. |
| shape | the shape that is going to be redrawn; only needed when selectionHandles=true |
| selectionHandles | if true; find out if the shape is selected and repaint its selection handles at the same time. |
Definition at line 695 of file KoShapeManager.cpp.
References d, and forwardUpdate().
| bool KoShapeManager::updatesBlocked | ( | ) | const |
| 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.
| QSet<KoShape *> KoShapeManager::aggregate4update |
Definition at line 59 of file KoShapeManager_p.h.
| KoCanvasBase * KoShapeManager::canvas |
Definition at line 57 of file KoShapeManager_p.h.
| QRectF KoShapeManager::compressedUpdate |
Definition at line 66 of file KoShapeManager_p.h.
| QSet<const KoShape*> KoShapeManager::compressedUpdatedShapes |
Definition at line 67 of file KoShapeManager_p.h.
|
private |
Definition at line 277 of file KoShapeManager.h.
| KoShapeManager* KoShapeManager::q |
Definition at line 61 of file KoShapeManager_p.h.
| KoSelection * KoShapeManager::selection |
Definition at line 56 of file KoShapeManager_p.h.
| QHash<KoShape*, int> KoShapeManager::shapeIndexesBeforeUpdate |
Definition at line 60 of file KoShapeManager_p.h.
| KoShapeManager::ShapeInterface * KoShapeManager::shapeInterface |
Definition at line 62 of file KoShapeManager_p.h.
Definition at line 55 of file KoShapeManager_p.h.
| QMutex KoShapeManager::shapesMutex |
Definition at line 63 of file KoShapeManager_p.h.
Definition at line 58 of file KoShapeManager_p.h.
| QMutex KoShapeManager::treeMutex |
Definition at line 64 of file KoShapeManager_p.h.
| bool KoShapeManager::updatesBlocked = false |
Definition at line 69 of file KoShapeManager_p.h.