umbrello API Documentation

linepath.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #ifndef LINEPATH_H
00013 #define LINEPATH_H
00014 #include <qobject.h>
00015 #include <qptrlist.h>
00016 #include <qpoint.h>
00017 #include <qpointarray.h>
00018 #include <qcanvas.h>
00019 #include <qpainter.h>
00020 #include "umlnamespace.h"
00021 
00022 /* how many pixels a user could click around a point */
00023 #define POINT_DELTA 5
00024 
00025 class AssociationWidget;
00026 class UMLView;
00027 
00028 // Qt forward declarations
00029 class QDataStream;
00030 class QDomDocument;
00031 class QDomElement;
00032 
00033 // typedefs
00034 typedef QPtrList<QCanvasLine> LineList;
00035 typedef QPtrListIterator<QCanvasLine> LineListIt;
00036 
00037 typedef QPtrList<QCanvasRectangle> RectList;
00038 typedef QPtrListIterator<QCanvasRectangle> RectListIt;
00039 
00040 
00045 class LinePath : public QObject {
00046     Q_OBJECT
00047 public:
00051     LinePath();
00052 
00056     ~LinePath();
00057 
00061     bool operator==( LinePath & rhs );
00062 
00066     LinePath & operator=( LinePath & rhs );
00067 
00071     enum Region {
00072         TopBottom, LeftRight
00073     };
00074 
00078     void setDockRegion( Region region );
00079 
00080     bool hasPoints ();
00081     void dumpPoints ();
00082 
00086     QPoint getPoint( int pointIndex );
00087 
00091     bool setPoint( int pointIndex, const QPoint &point );
00092 
00098     bool isPoint( int pointIndex, const QPoint &point, unsigned short delta = 0 );
00099 
00103     bool insertPoint( int pointIndex, const QPoint &point );
00104 
00109     bool removePoint( int pointIndex, const QPoint &point, unsigned short delta = 0 );
00110 
00114     bool setStartEndPoints( const QPoint &start, const QPoint &end );
00115 
00120     int count();
00121 
00127     int onLinePath( const QPoint &position );
00128 
00132     void setCanvas( QCanvas * canvas );
00133 
00137     void setAssocType( Uml::Association_Type type );
00138 
00142     void update();
00143 
00148     void setAssociation( AssociationWidget * association );
00149 
00153     AssociationWidget * getAssociation() {
00154         return m_pAssociation;
00155     }
00156 
00160     void setSelected( bool select );
00161 
00162     void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
00163 
00164     bool loadFromXMI( QDomElement & qElement );
00165 
00175     void activate();
00176 
00180     void cleanup();
00181 
00185     QPen getPen();
00186 
00190     void setLineColor( const QColor &color );
00194     void setLineWidth( uint width );
00195 
00196 protected:
00197 
00203     class Circle : public QCanvasEllipse {
00204     public:
00205         explicit Circle(QCanvas * canvas, int radius = 0);
00206         void setRadius(int radius);
00207         int getRadius() const;
00208         void setX(int x);
00209         void setY(int y);
00213         void drawShape(QPainter& p);
00214     };
00215 
00223     QCanvas * getCanvas();
00224 
00232     Uml::Association_Type getAssocType();
00233 
00241     QColor getLineColor();
00249     uint getLineWidth();
00250 
00254     void moveSelected( int pointIndex );
00255 
00259     void setupSelected();
00260 
00264     void calculateHead();
00265 
00269     void createHeadLines();
00270 
00277     void growList(LineList &list, int by);
00278 
00282     void updateHead();
00283 
00287     void setupParallelLine();
00288 
00292     void calculateParallelLine();
00293 
00298     void updateParallelLine();
00299 
00300     /********Attributes*************/
00301 
00305     AssociationWidget * m_pAssociation;
00306 
00310     LineList m_LineList;
00311 
00315     RectList m_RectList;
00316 
00320     LineList m_HeadList;
00321 
00325     LineList m_ParallelList;
00326 
00330     bool  m_bSelected;
00331 
00335     QPointArray m_PointArray;
00336 
00340     QPoint m_ArrowPointA, m_ArrowPointB, m_MidPoint, m_EgdePoint;
00341 
00345     QCanvasPolygon * m_pClearPoly;
00346 
00350     Circle * m_pCircle;
00351 
00356     QPointArray m_ParallelLines;
00357 
00361     Region m_DockRegion;
00362 
00363     bool m_bHeadCreated;
00364 
00365     bool m_bParallelLineCreated;
00366 
00367 public slots:
00368 
00374     void slotLineColorChanged( Uml::IDType viewID );
00380     void slotLineWidthChanged( Uml::IDType viewID );
00381 };
00382 
00383 #endif
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:58 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003