libs/flake

KoPathTool.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006,2008 Jan Hambrecht <jaham@gmx.net>
00003  * Copyright (C) 2006,2007 Thorsten Zachmann <zachmann@kde.org>
00004  * Copyright (C) 2007 Thomas Zander <zander@kde.org>
00005  * Copyright (C) 2007 Boudewijn Rempt <boud@valdyas.org>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef KOPATHTOOL_H
00024 #define KOPATHTOOL_H
00025 
00026 #include "KoPathShape.h"
00027 #include "KoTool.h"
00028 #include "KoPathToolSelection.h"
00029 
00030 #include "QMap"
00031 
00032 class QButtonGroup;
00033 class KoCanvasBase;
00034 class KoInteractionStrategy;
00035 class KoPathToolHandle;
00036 
00037 class KAction;
00038 
00040 class FLAKE_TEST_EXPORT KoPathTool : public KoTool
00041 {
00042     Q_OBJECT
00043 public:
00044     explicit KoPathTool(KoCanvasBase *canvas);
00045     ~KoPathTool();
00046 
00048     virtual void paint(QPainter &painter, const KoViewConverter &converter);
00049 
00051     virtual void repaintDecorations();
00052 
00054     virtual void mousePressEvent(KoPointerEvent *event);
00056     virtual void mouseMoveEvent(KoPointerEvent *event);
00058     virtual void mouseReleaseEvent(KoPointerEvent *event);
00060     virtual void keyPressEvent(QKeyEvent *event);
00062     virtual void keyReleaseEvent(QKeyEvent *event);
00064     virtual void mouseDoubleClickEvent(KoPointerEvent *event);
00066     virtual void activate(bool temporary = false);
00068     virtual void deactivate();
00069 
00071     virtual void deleteSelection();
00072 
00074     virtual KoToolSelection* selection();
00075 
00077     void repaint(const QRectF &repaintRect);
00078 
00079 signals:
00080     void typeChanged(int types);
00081     void pathChanged(KoPathShape* path); // TODO this is unused, can we remove this one?
00082 protected:
00084     virtual QMap<QString, QWidget *>  createOptionWidgets();
00085 
00086 
00087 private:
00088     void updateOptionsWidget();
00089     bool segmentAtPoint( const QPointF &point, KoPathShape* &shape, KoPathPoint* &segmentStart, qreal &pointParam );
00090 
00091 private slots:
00092     void pointTypeChanged(QAction *type);
00093     void insertPoints();
00094     void removePoints();
00095     void segmentToLine();
00096     void segmentToCurve();
00097     void convertToPath();
00098     void joinPoints();
00099     void mergePoints();
00100     void breakAtPoint();
00101     void breakAtSegment();
00102     void resourceChanged(int key, const QVariant & res);
00103     void pointSelectionChanged();
00104     void updateActions();
00105     void pointToLine();
00106     void pointToCurve();
00107 
00108 private:
00109 
00110     KoPathToolHandle * m_activeHandle;       
00111     int m_handleRadius;    
00112     uint m_grabSensitivity; 
00113 
00114     KoPathToolSelection m_pointSelection;
00115     // needed for interaction strategy
00116     QPointF m_lastPoint;
00117 
00118     // make a frind so that it can test private member/methods
00119     friend class TestPathTool;
00120 
00121     KoInteractionStrategy *m_currentStrategy; 
00122 
00123     QButtonGroup *m_pointTypeGroup;
00124 
00125     KAction *m_actionPathPointCorner;
00126     KAction *m_actionPathPointSmooth;
00127     KAction *m_actionPathPointSymmetric;
00128     KAction *m_actionCurvePoint;
00129     KAction *m_actionLinePoint;
00130     KAction *m_actionLineSegment;
00131     KAction *m_actionCurveSegment;
00132     KAction *m_actionAddPoint;
00133     KAction *m_actionRemovePoint;
00134     KAction *m_actionBreakPoint;
00135     KAction *m_actionBreakSegment;
00136     KAction *m_actionJoinSegment;
00137     KAction *m_actionMergePoints;
00138     KAction *m_actionConvertToPath;
00139     QCursor m_selectCursor;
00140     QCursor m_moveCursor;
00141 };
00142 
00143 #endif