libs/flake
KoCreatePathTool.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org> 00004 * Copyright (C) 2008-2009 Jan Hambrecht <jaham@gmx.net> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 #ifndef KOCREATEPATHTOOL_H 00022 #define KOCREATEPATHTOOL_H 00023 00024 00025 #include <KoTool.h> 00026 00027 #include <QMap> 00028 00029 class KoPathShape; 00030 class KoPathPoint; 00031 00032 #define KoCreatePathTool_ID "CreatePathTool" 00033 00037 class FLAKE_EXPORT KoCreatePathTool : public KoTool 00038 { 00039 Q_OBJECT 00040 public: 00045 explicit KoCreatePathTool(KoCanvasBase * canvas); 00046 virtual ~KoCreatePathTool(); 00047 00048 void paint(QPainter &painter, const KoViewConverter &converter); 00049 00050 void mousePressEvent(KoPointerEvent *event); 00051 void mouseDoubleClickEvent(KoPointerEvent *event); 00052 void mouseMoveEvent(KoPointerEvent *event); 00053 void mouseReleaseEvent(KoPointerEvent *event); 00054 virtual void keyPressEvent(QKeyEvent *event); 00055 00056 public slots: 00057 virtual void activate(bool temporary = false); 00058 virtual void deactivate(); 00059 virtual void resourceChanged(int key, const QVariant & res); 00060 00061 protected: 00063 virtual void addPathShape(); 00065 virtual QMap<QString, QWidget *> createOptionWidgets(); 00066 00067 KoPathShape *m_shape; 00068 00069 private slots: 00070 void angleDeltaChanged(int value); 00071 00072 private: 00073 void repaintActivePoint(); 00074 00076 KoPathPoint* endPointAtPosition( const QPointF &position ); 00077 00079 bool connectPaths( KoPathShape *pathShape, KoPathPoint *pointAtStart, KoPathPoint *pointAtEnd ); 00080 00081 KoPathPoint *m_activePoint; 00082 KoPathPoint *m_firstPoint; 00083 int m_handleRadius; 00084 bool m_mouseOverFirstPoint; 00085 bool m_pointIsDragged; 00086 KoPathPoint *m_existingStartPoint; 00087 KoPathPoint *m_existingEndPoint; 00088 KoPathPoint *m_hoveredPoint; 00089 00090 class AngleSnapStrategy; 00091 AngleSnapStrategy *m_angleSnapStrategy; 00092 int m_angleSnappingDelta; 00093 }; 00094 #endif 00095
