kivio

kiviopolylineconnector.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Peter Simonsson <psn@linux.se>,
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 KIVIOKIVIOPOLYLINECONNECTOR_H
00021 #define KIVIOKIVIOPOLYLINECONNECTOR_H
00022 
00023 #include <qvaluelist.h>
00024 
00025 #include <KoPoint.h>
00026 #include <KoRect.h>
00027 
00028 #include "kivio_1d_stencil.h"
00029 #include "kivio_arrowhead.h"
00030 #include <koffice_export.h>
00031 class KivioIntraStencilData;
00032 class KivioCustomDragData;
00033 class KivioPage;
00034 
00035 namespace Kivio {
00036   class KIVIO_EXPORT PolyLineConnector : public Kivio1DStencil
00037   {
00038     public:
00039       PolyLineConnector();
00040       virtual ~PolyLineConnector();
00041       
00042       virtual KivioStencil* duplicate();
00043       
00044       virtual bool loadCustom(const QDomElement& e);
00045       virtual bool saveCustom(QDomElement& e, QDomDocument& doc);
00046       
00047       virtual KivioCollisionType checkForCollision(KoPoint* p, double threshold);
00048   
00049       virtual void paint(KivioIntraStencilData* data);
00050       virtual void paintOutline(KivioIntraStencilData* data);
00051       virtual void paintSelectionHandles(KivioIntraStencilData* data);
00052       
00057       void addPoint(const KoPoint& p);
00059       void removePoint(unsigned int index);
00061       void removeLastPoint();
00062       
00063       unsigned int pointCount() const { return m_points.count(); }
00064       
00071       void movePoint(unsigned int index, double xOffset, double yOffset);
00072       
00073       void movePointTo(unsigned int index, const KoPoint& p);
00074       
00075       void moveLastPointTo(const KoPoint& p);
00076       
00077       virtual void customDrag(KivioCustomDragData* data);
00078       virtual void move(double xOffset, double yOffset);
00079       virtual double x();
00080       virtual void setX(double x);
00081       virtual double y();
00082       virtual void setY(double y);
00083       virtual double w() { return 0; }
00084       virtual double h() { return 0; }
00085       virtual KoRect rect();
00086       virtual bool isInRect(const KoRect& rect);
00087       virtual void setCustomIDPoint(int customID, const KoPoint& point, KivioPage* page);
00088       virtual KoPoint customIDPoint(int customID);
00089 
00090 
00091       virtual void updateConnectorPoints(KivioConnectorPoint* cp, double /*oldX*/, double /*oldY*/);
00092       
00093       // Arrow head properties
00094       virtual void setStartAHType(int i) { m_startArrow->setType(i); }
00095       virtual int startAHType() { return m_startArrow->type(); }
00096       
00097       virtual void setStartAHWidth(double f) { m_startArrow->setWidth(f); }
00098       virtual double startAHWidth() { return m_startArrow->width(); }
00099       
00100       virtual void setStartAHLength(double f) { m_startArrow->setLength(f); }
00101       virtual double startAHLength() { return m_startArrow->length(); }
00102       
00103       virtual void setEndAHType(int i) { m_endArrow->setType(i); }
00104       virtual int endAHType() { return m_endArrow->type(); }
00105       
00106       virtual void setEndAHWidth(double f) { m_endArrow->setWidth(f); }
00107       virtual double endAHWidth() { return m_endArrow->width(); }
00108       
00109       virtual void setEndAHLength(double f) { m_endArrow->setLength(f); }
00110       virtual double endAHLength() { return m_endArrow->length(); }
00111     
00112     protected:
00113       void checkForConnection(KivioConnectorPoint* cp, KivioPage* page);
00114   
00115       bool loadArrowHeads(const QDomElement& e);
00116       QDomElement saveArrowHeads(QDomDocument& doc);
00117 
00118     private:
00119       KivioArrowHead* m_startArrow; // Arrow head for the first point.
00120       KivioArrowHead* m_endArrow; // Arrow head for the last point.
00121       
00122       QValueList<KoPoint> m_points;
00123   };
00124 }
00125 
00126 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys