kivio

kivio_point.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #ifndef KIVIO_POINT_H
00020 #define KIVIO_POINT_H
00021 
00022 #include <qdom.h>
00023 
00024 class KivioPoint
00025 {
00026 public:
00027     // KivioPoint type enumerations
00028     typedef enum {
00029         kptNone=0,      // Bounds check
00030         kptNormal,      // Normal point (for polygons, etc)
00031         kptBezier,      // Bezier point (these come in groups of 4)
00032         kptArc,         // Arc point (I think these come in groups of 3... unimplemented)
00033         kptLast         // Bounds check
00034     } KivioPointType;
00035     
00036 protected:
00037     double m_x, m_y;                 // Coordinates of the point
00038     KivioPointType m_pointType;     // The point type
00039 
00040 public:
00041     KivioPoint();
00042     KivioPoint( const KivioPoint & );
00043     KivioPoint( double, double, KivioPointType pt=kptNormal );
00044     virtual ~KivioPoint();
00045     
00046     void copyInto( KivioPoint * ) const;
00047     
00048     bool loadXML( const QDomElement & );
00049     QDomElement saveXML( QDomDocument & );
00050 
00051     static KivioPoint::KivioPointType pointTypeFromString( const QString & );
00052 
00053     inline double x() const { return m_x; }
00054     inline double y() const { return m_y; }
00055     inline KivioPointType pointType() const { return m_pointType; }
00056 
00057     inline void setX( double newX ) { m_x=newX; }
00058     inline void setY( double newY ) { m_y=newY; }
00059     inline void setPointType( KivioPointType pt ) { m_pointType=pt; }
00060 
00061     inline void set( double newX, double newY, KivioPointType pt=kptNormal ) { m_x=newX; m_y=newY; m_pointType=pt; }
00062     inline void set( const KivioPoint &p, KivioPointType pt=kptNormal ) { m_x=p.x(); m_y=p.y(); m_pointType=pt; }
00063 
00064     inline void moveBy( double dx, double dy ) { m_x += dx; m_y += dy; }
00065     inline void moveBy( const KivioPoint &p ) { m_x += p.x(); m_y += p.y(); }
00066 };
00067 
00068 #endif
00069 
00070 
KDE Home | KDE Accessibility Home | Description of Access Keys