kiviopolylineconnector.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Peter Simonsson <psn@linux.se>,
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KIVIOKIVIOPOLYLINECONNECTOR_H
21#define KIVIOKIVIOPOLYLINECONNECTOR_H
22
23#include <tqvaluelist.h>
24
25#include <KoPoint.h>
26#include <KoRect.h>
27
28#include "kivio_1d_stencil.h"
29#include "kivio_arrowhead.h"
30#include <koffice_export.h>
31class KivioIntraStencilData;
32class KivioCustomDragData;
33class KivioPage;
34
35namespace Kivio {
36 class KIVIO_EXPORT PolyLineConnector : public Kivio1DStencil
37 {
38 public:
39 PolyLineConnector();
40 virtual ~PolyLineConnector();
41
42 virtual KivioStencil* duplicate();
43
44 virtual bool loadCustom(const TQDomElement& e);
45 virtual bool saveCustom(TQDomElement& e, TQDomDocument& doc);
46
47 virtual KivioCollisionType checkForCollision(KoPoint* p, double threshold);
48
49 virtual void paint(KivioIntraStencilData* data);
50 virtual void paintOutline(KivioIntraStencilData* data);
51 virtual void paintSelectionHandles(KivioIntraStencilData* data);
52
57 void addPoint(const KoPoint& p);
59 void removePoint(unsigned int index);
61 void removeLastPoint();
62
63 unsigned int pointCount() const { return m_points.count(); }
64
71 void movePoint(unsigned int index, double xOffset, double yOffset);
72
73 void movePointTo(unsigned int index, const KoPoint& p);
74
75 void moveLastPointTo(const KoPoint& p);
76
77 virtual void customDrag(KivioCustomDragData* data);
78 virtual void move(double xOffset, double yOffset);
79 virtual double x();
80 virtual void setX(double x);
81 virtual double y();
82 virtual void setY(double y);
83 virtual double w() { return 0; }
84 virtual double h() { return 0; }
85 virtual KoRect rect();
86 virtual bool isInRect(const KoRect& rect);
87 virtual void setCustomIDPoint(int customID, const KoPoint& point, KivioPage* page);
88 virtual KoPoint customIDPoint(int customID);
89
90
91 virtual void updateConnectorPoints(KivioConnectorPoint* cp, double /*oldX*/, double /*oldY*/);
92
93 // Arrow head properties
94 virtual void setStartAHType(int i) { m_startArrow->setType(i); }
95 virtual int startAHType() { return m_startArrow->type(); }
96
97 virtual void setStartAHWidth(double f) { m_startArrow->setWidth(f); }
98 virtual double startAHWidth() { return m_startArrow->width(); }
99
100 virtual void setStartAHLength(double f) { m_startArrow->setLength(f); }
101 virtual double startAHLength() { return m_startArrow->length(); }
102
103 virtual void setEndAHType(int i) { m_endArrow->setType(i); }
104 virtual int endAHType() { return m_endArrow->type(); }
105
106 virtual void setEndAHWidth(double f) { m_endArrow->setWidth(f); }
107 virtual double endAHWidth() { return m_endArrow->width(); }
108
109 virtual void setEndAHLength(double f) { m_endArrow->setLength(f); }
110 virtual double endAHLength() { return m_endArrow->length(); }
111
112 protected:
113 void checkForConnection(KivioConnectorPoint* cp, KivioPage* page);
114
115 bool loadArrowHeads(const TQDomElement& e);
116 TQDomElement saveArrowHeads(TQDomDocument& doc);
117
118 private:
119 KivioArrowHead* m_startArrow; // Arrow head for the first point.
120 KivioArrowHead* m_endArrow; // Arrow head for the last point.
121
122 TQValueList<KoPoint> m_points;
123 };
124}
125
126#endif