|
Krita Source Code Documentation
|
#include <KoSnapGuide.h>
Inheritance diagram for KoSnapGuide:Public Types | |
| typedef QSharedPointer< KoSnapStrategy > | KoSnapStrategySP |
| typedef QList< KoSnapStrategySP > | StrategiesList |
| enum | Strategy { OrthogonalSnapping = 1 , NodeSnapping = 2 , ExtensionSnapping = 4 , IntersectionSnapping = 8 , GridSnapping = 0x10 , BoundingBoxSnapping = 0x20 , GuideLineSnapping = 0x40 , DocumentBoundsSnapping = 0x80 , DocumentCenterSnapping = 0x100 , CustomSnapping = 0x200 , PixelSnapping = 0x400 } |
| the different possible snap Strategies More... | |
Public Member Functions | |
| bool | addCustomSnapStrategy (KoSnapStrategy *customStrategy) |
| KoShape * | additionalEditedShape () const |
| returns the extra shapes to use | |
| QRectF | boundingRect () |
| returns the bounding rect of the guide | |
| KoCanvasBase * | canvas () const |
| returns the canvas the snap guide is working on | |
| KoSnapGuide::Strategies | enabledSnapStrategies () const |
| returns the enabled snap strategies | |
| void | enableSnapping (bool on) |
| enables the snapping guides | |
| void | enableSnapStrategies (Strategies strategies) |
| enables the strategies used for snapping | |
| void | enableSnapStrategy (Strategy type, bool value) |
| QList< KoPathPoint * > | ignoredPathPoints () const |
| Returns list of ignored points. | |
| QList< KoShape * > | ignoredShapes () const |
| Returns list of ignored shapes. | |
| bool | isSnapping () const |
| returns if snapping is enabled | |
| bool | isStrategyEnabled (Strategy type) const |
| KoSnapGuide (KoCanvasBase *canvas) | |
| Creates the snap guide to work on the given canvas. | |
| void | overrideSnapStrategy (Strategy type, KoSnapStrategy *strategy) |
| void | paint (QPainter &painter, const KoViewConverter &converter) |
| paints the guide | |
| Private (KoCanvasBase *parentCanvas) | |
| void | reset () |
| Resets the snap guide. | |
| void | setAdditionalEditedShape (KoShape *shape) |
| Adds an additional shape to snap to (useful when creating a path) | |
| void | setIgnoredPathPoints (const QList< KoPathPoint * > &ignoredPoints) |
| Sets a list of path points to ignore. | |
| void | setIgnoredShapes (const QList< KoShape * > &ignoredShapes) |
| Sets list of ignored shapes. | |
| void | setSnapDistance (int distance) |
| sets the snap distances in pixels | |
| QPointF | snap (const QPointF &mousePosition, const QPointF &dragOffset, Qt::KeyboardModifiers modifiers) |
| QPointF | snap (const QPointF &mousePosition, Qt::KeyboardModifiers modifiers) |
| snaps the mouse position, returns if mouse was snapped | |
| int | snapDistance () const |
| returns the snap distance in pixels | |
| virtual | ~KoSnapGuide () |
| ~Private () | |
Public Attributes | |
| bool | active |
| KoShape * | additionalEditedShape |
| KoCanvasBase * | canvas |
| KoSnapStrategySP | currentStrategy |
| QList< KoPathPoint * > | ignoredPoints |
| QList< KoShape * > | ignoredShapes |
| int | snapDistance |
| StrategiesList | strategies |
| KoSnapGuide::Strategies | usedStrategies |
Private Attributes | |
| const QScopedPointer< Private > | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
Additional Inherited Members | |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
This class is the place where all the snapping (i.e. snap to grid) is handled.
What this class does is snapping a given position (i.e. mouse position) to various snapping targets like grid, boundbox etc. The snap guide does not know anything about the specific snapping target. This is handled by the different snapping strategies which are derived from KoSnapStrategy. Snapping strategies can be enabled/disabled by passing a mask of corresponding snapping ids to KoSnapGuide::enableSnapStrategies. There can be one or more snapping strategies enabled at the same time. The best result (with the nearest distance to the original position) is then returned to the caller of KoSnapGuide::snap.
The snap guide is part of the KoCanvasBase class and thus can be accessed by any tool or application via the canvas pointer. For letting the user manage which snap strategies to enable, there is a snap guide config widget in guiutils.
Definition at line 23 of file KoSnapGuide.cpp.
Definition at line 41 of file KoSnapGuide.cpp.
Definition at line 42 of file KoSnapGuide.cpp.
the different possible snap Strategies
Definition at line 48 of file KoSnapGuide.h.
|
inline |
Definition at line 33 of file KoSnapGuide.cpp.
|
explicit |
Creates the snap guide to work on the given canvas.
Definition at line 53 of file KoSnapGuide.cpp.
References d, and toQShared().
|
virtual |
Definition at line 64 of file KoSnapGuide.cpp.
| bool KoSnapGuide::addCustomSnapStrategy | ( | KoSnapStrategy * | customStrategy | ) |
Adds a custom snap strategy
The snap guide take ownership of the strategy. All custom strategies are destroyed when calling reset().
Definition at line 102 of file KoSnapGuide.cpp.
References CustomSnapping, d, toQShared(), and KoSnapStrategy::type().
| KoShape * KoSnapGuide::additionalEditedShape | ( | ) | const |
returns the extra shapes to use
| QRectF KoSnapGuide::boundingRect | ( | ) |
returns the bounding rect of the guide
Definition at line 199 of file KoSnapGuide.cpp.
References d.
| KoCanvasBase * KoSnapGuide::canvas | ( | ) | const |
returns the canvas the snap guide is working on
| KoSnapGuide::Strategies KoSnapGuide::enabledSnapStrategies | ( | ) | const |
| void KoSnapGuide::enableSnapping | ( | bool | on | ) |
| void KoSnapGuide::enableSnapStrategies | ( | Strategies | strategies | ) |
enables the strategies used for snapping
Definition at line 92 of file KoSnapGuide.cpp.
References d, and strategies.
Definition at line 78 of file KoSnapGuide.cpp.
| QList< KoPathPoint * > KoSnapGuide::ignoredPathPoints | ( | ) | const |
| bool KoSnapGuide::isSnapping | ( | ) | const |
| bool KoSnapGuide::isStrategyEnabled | ( | Strategy | type | ) | const |
Definition at line 87 of file KoSnapGuide.cpp.
References d.
| void KoSnapGuide::overrideSnapStrategy | ( | Strategy | type, |
| KoSnapStrategy * | strategy ) |
Overrides the first entry of a strategy type with a strategy strategy. Note that basically strategy->type() may not be equal to type and that is ok. strategy may also be null.
Definition at line 111 of file KoSnapGuide.cpp.
References d, and toQShared().
| void KoSnapGuide::paint | ( | QPainter & | painter, |
| const KoViewConverter & | converter ) |
paints the guide
Definition at line 211 of file KoSnapGuide.cpp.
References d.
|
inline |
Definition at line 26 of file KoSnapGuide.cpp.
| void KoSnapGuide::reset | ( | ) |
Resets the snap guide.
Definition at line 260 of file KoSnapGuide.cpp.
References CustomSnapping, and d.
Adds an additional shape to snap to (useful when creating a path)
Definition at line 68 of file KoSnapGuide.cpp.
References d.
| void KoSnapGuide::setIgnoredPathPoints | ( | const QList< KoPathPoint * > & | ignoredPoints | ) |
Sets a list of path points to ignore.
Definition at line 240 of file KoSnapGuide.cpp.
References d, and ignoredPoints.
Sets list of ignored shapes.
Definition at line 250 of file KoSnapGuide.cpp.
References d, and ignoredShapes.
| void KoSnapGuide::setSnapDistance | ( | int | distance | ) |
sets the snap distances in pixels
Definition at line 141 of file KoSnapGuide.cpp.
References d, and distance().
| QPointF KoSnapGuide::snap | ( | const QPointF & | mousePosition, |
| const QPointF & | dragOffset, | ||
| Qt::KeyboardModifiers | modifiers ) |
Definition at line 151 of file KoSnapGuide.cpp.
References snap().
| QPointF KoSnapGuide::snap | ( | const QPointF & | mousePosition, |
| Qt::KeyboardModifiers | modifiers ) |
snaps the mouse position, returns if mouse was snapped
Definition at line 158 of file KoSnapGuide.cpp.
References CustomSnapping, d, distance(), GridSnapping, KoSnapStrategy::squareDistance(), and KoSnapStrategy::ToLine.
| int KoSnapGuide::snapDistance | ( | ) | const |
returns the snap distance in pixels
| bool KoSnapGuide::active |
Definition at line 47 of file KoSnapGuide.cpp.
| KoShape * KoSnapGuide::additionalEditedShape |
Definition at line 39 of file KoSnapGuide.cpp.
| KoCanvasBase * KoSnapGuide::canvas |
Definition at line 38 of file KoSnapGuide.cpp.
| KoSnapStrategySP KoSnapGuide::currentStrategy |
Definition at line 44 of file KoSnapGuide.cpp.
|
private |
Definition at line 142 of file KoSnapGuide.h.
| QList<KoPathPoint*> KoSnapGuide::ignoredPoints |
Definition at line 49 of file KoSnapGuide.cpp.
Definition at line 50 of file KoSnapGuide.cpp.
| int KoSnapGuide::snapDistance |
Definition at line 48 of file KoSnapGuide.cpp.
| StrategiesList KoSnapGuide::strategies |
Definition at line 43 of file KoSnapGuide.cpp.
| KoSnapGuide::Strategies KoSnapGuide::usedStrategies |
Definition at line 46 of file KoSnapGuide.cpp.