libs/flake
KoSnapGuide Class Reference
This class is the place where all the snapping (i.e. More...
#include <KoSnapGuide.h>
Public Member Functions | |
| KoSnapGuide (KoCanvasBase *canvas) | |
| virtual | ~KoSnapGuide () |
| bool | addCustomSnapStrategy (KoSnapStrategy *customStrategy) |
| QRectF | boundingRect () |
| KoCanvasBase * | canvas () const |
| KoShape * | editedShape () const |
| int | enabledSnapStrategies () const |
| void | enableSnapping (bool on) |
| void | enableSnapStrategies (int strategies) |
| QList< KoPathPoint * > | ignoredPathPoints () const |
| QList< KoShape * > | ignoredShapes () const |
| bool | isSnapping () const |
| void | paint (QPainter &painter, const KoViewConverter &converter) |
| void | reset () |
| void | setEditedShape (KoShape *shape) |
| void | setIgnoredPathPoints (const QList< KoPathPoint * > &ignoredPoints) |
| void | setIgnoredShapes (const QList< KoShape * > &ignoredShapes) |
| void | setSnapDistance (int distance) |
| QPointF | snap (const QPointF &mousePosition, Qt::KeyboardModifiers modifiers) |
| int | snapDistance () const |
Detailed Description
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 stratgies to enable, there is a snap guide config widget in guiutils.
Definition at line 57 of file KoSnapGuide.h.
Constructor & Destructor Documentation
| KoSnapGuide::KoSnapGuide | ( | KoCanvasBase * | canvas | ) |
Creates the snap guide to work on the given canvas.
Definition at line 61 of file KoSnapGuide.cpp.
| KoSnapGuide::~KoSnapGuide | ( | ) | [virtual] |
Definition at line 73 of file KoSnapGuide.cpp.
Member Function Documentation
| 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 98 of file KoSnapGuide.cpp.
| QRectF KoSnapGuide::boundingRect | ( | ) |
returns the bounding rect of the guide
Definition at line 162 of file KoSnapGuide.cpp.
| KoCanvasBase * KoSnapGuide::canvas | ( | ) | const |
returns the canvas the snap guide is working on
Definition at line 194 of file KoSnapGuide.cpp.
| KoShape * KoSnapGuide::editedShape | ( | ) | const |
returns the extra shapes to use
Definition at line 83 of file KoSnapGuide.cpp.
| int KoSnapGuide::enabledSnapStrategies | ( | ) | const |
returns the enabled snap strategies
Definition at line 93 of file KoSnapGuide.cpp.
| void KoSnapGuide::enableSnapping | ( | bool | on | ) |
enables the snapping guides
Definition at line 107 of file KoSnapGuide.cpp.
| void KoSnapGuide::enableSnapStrategies | ( | int | strategies | ) |
enables the strategies used for snapping
Definition at line 88 of file KoSnapGuide.cpp.
| QList< KoPathPoint * > KoSnapGuide::ignoredPathPoints | ( | ) | const |
Returns list of ignored points.
Definition at line 204 of file KoSnapGuide.cpp.
Returns list of ignored shapes.
Definition at line 214 of file KoSnapGuide.cpp.
| bool KoSnapGuide::isSnapping | ( | ) | const |
returns if snapping is enabled
Definition at line 112 of file KoSnapGuide.cpp.
| void KoSnapGuide::paint | ( | QPainter & | painter, | |
| const KoViewConverter & | converter | |||
| ) |
paints the guide
Definition at line 174 of file KoSnapGuide.cpp.
| void KoSnapGuide::reset | ( | ) |
Resets the snap guide.
Definition at line 219 of file KoSnapGuide.cpp.
| void KoSnapGuide::setEditedShape | ( | KoShape * | shape | ) |
Adds an additional shape to snap to (useful when creating a path).
Definition at line 78 of file KoSnapGuide.cpp.
| void KoSnapGuide::setIgnoredPathPoints | ( | const QList< KoPathPoint * > & | ignoredPoints | ) |
Sets a list of path points to ignore.
Definition at line 199 of file KoSnapGuide.cpp.
Sets list of ignored shapes.
Definition at line 209 of file KoSnapGuide.cpp.
| void KoSnapGuide::setSnapDistance | ( | int | distance | ) |
sets the snap distances in pixels
Definition at line 117 of file KoSnapGuide.cpp.
snaps the mouse position, returns if mouse was snapped
Definition at line 127 of file KoSnapGuide.cpp.
| int KoSnapGuide::snapDistance | ( | ) | const |
returns the snap distance in pixels
Definition at line 122 of file KoSnapGuide.cpp.
The documentation for this class was generated from the following files:
