libs/flake
KoConnectionShape.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KO_CONNECTION_SHAPE_H
00023 #define KO_CONNECTION_SHAPE_H
00024
00025 #include <KoParameterShape.h>
00026
00027 #include "flake_export.h"
00028
00029 #define KOCONNECTIONSHAPEID "KoConnectionShape"
00030
00032 typedef QPair<KoShape*, int> KoConnection;
00033
00034 class FLAKE_EXPORT KoConnectionShape : public KoParameterShape
00035 {
00036 public:
00037 enum Type {
00038 Standard,
00039 Lines,
00040 Straight,
00041 Curve
00042 };
00043
00044 explicit KoConnectionShape();
00045 virtual ~KoConnectionShape();
00046
00047
00048 virtual void paint(QPainter& painter, const KoViewConverter& converter);
00049
00050
00051 virtual void saveOdf(KoShapeSavingContext & context) const;
00052
00053
00054 virtual bool loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context);
00055
00056
00057 inline QString pathShapeId() const {
00058 return KOCONNECTIONSHAPEID;
00059 }
00060
00061
00062 virtual bool hitTest(const QPointF &position) const;
00063
00073 bool setConnection1(KoShape * shape1, int connectionPointIndex);
00074
00084 bool setConnection2(KoShape * shape2, int connectionPointIndex);
00085
00087 KoConnection connection1() const;
00088
00090 KoConnection connection2() const;
00091
00093 void updateConnections();
00094
00096 Type connectionType() const;
00097
00099 void setConnectionType(Type connectionType);
00100
00101 protected:
00103 void moveHandleAction(int handleId, const QPointF & point, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
00104
00106 void updatePath(const QSizeF &size);
00107
00109 bool handleConnected(int handleId) const;
00110
00112 QPointF escapeDirection(int handleId) const;
00113
00115 bool intersects(const QPointF &p1, const QPointF &d1, const QPointF &p2, const QPointF &d2, QPointF &isect);
00116
00118 QPointF perpendicularDirection(const QPointF &p1, const QPointF &d1, const QPointF &p2);
00119
00121 virtual void shapeChanged(ChangeType type, KoShape * shape);
00122
00124 void normalPath( const qreal MinimumEscapeLength );
00125
00126 private:
00127 qreal scalarProd(const QPointF &v1, const QPointF &v2);
00128 qreal crossProd(const QPointF &v1, const QPointF &v2);
00129
00130 QList<QPointF> m_path;
00131 bool m_hasMoved;
00132
00133 struct Private;
00134 Private * const d;
00135 };
00136
00137
00138 #endif
|