libs/flake

KoSnapGuide.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2008-2009 Jan Hambrecht <jaham@gmx.net>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KOSNAPGUIDE_H
00021 #define KOSNAPGUIDE_H
00022 
00023 #include "flake_export.h"
00024 
00025 #include <KoPathSegment.h>
00026 #include <QtCore/QPointF>
00027 #include <QtCore/QList>
00028 #include <QtCore/QRectF>
00029 #include <QtGui/QPainterPath>
00030 
00031 class KoSnapStrategy;
00032 class KoShape;
00033 class KoPathPoint;
00034 class KoViewConverter;
00035 class KoCanvasBase;
00036 class QPainter;
00037 class KoCanvasBase;
00038 
00057 class FLAKE_EXPORT KoSnapGuide
00058 {
00059 public:
00060 
00062     KoSnapGuide(KoCanvasBase * canvas);
00063 
00064     virtual ~KoSnapGuide();
00065 
00067     QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers);
00068 
00070     void paint(QPainter &painter, const KoViewConverter &converter);
00071 
00073     QRectF boundingRect();
00074 
00076     void setEditedShape(KoShape * shape);
00077 
00079     KoShape * editedShape() const;
00080 
00082     void enableSnapStrategies(int strategies);
00083 
00085     int enabledSnapStrategies() const;
00086 
00093     bool addCustomSnapStrategy(KoSnapStrategy * customStrategy);
00094 
00096     void enableSnapping(bool on);
00097 
00099     bool isSnapping() const;
00100 
00102     void setSnapDistance(int distance);
00103 
00105     int snapDistance() const;
00106 
00108     KoCanvasBase * canvas() const;
00109 
00111     void setIgnoredPathPoints(const QList<KoPathPoint*> &ignoredPoints);
00112 
00114     QList<KoPathPoint*> ignoredPathPoints() const;
00115 
00117     void setIgnoredShapes(const QList<KoShape*> &ignoredShapes);
00118 
00120     QList<KoShape*> ignoredShapes() const;
00121 
00123     void reset();
00124 
00125 private:
00126     class Private;
00127     Private * const d;
00128 };
00129 
00133 class KoSnapProxy
00134 {
00135 public:
00136     KoSnapProxy(KoSnapGuide * snapGuide);
00137 
00139     QList<QPointF> pointsInRect(const QRectF &rect);
00140 
00142     QList<KoShape*> shapesInRect(const QRectF &rect, bool omitEditedShape = false);
00143 
00145     QList<QPointF> pointsFromShape(KoShape * shape);
00146 
00148     QList<KoPathSegment> segmentsInRect(const QRectF &rect);
00149 
00151     QList<KoShape*> shapes(bool omitEditedShape = false);
00152 
00154     KoCanvasBase * canvas();
00155 
00156 private:
00157     KoSnapGuide * m_snapGuide;
00158 };
00159 
00160 #endif // KOSNAPGUIDE_H