kivio_point.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#ifndef KIVIO_POINT_H
20#define KIVIO_POINT_H
21
22#include <tqdom.h>
23
24class KivioPoint
25{
26public:
27 // KivioPoint type enumerations
28 typedef enum {
29 kptNone=0, // Bounds check
30 kptNormal, // Normal point (for polygons, etc)
31 kptBezier, // Bezier point (these come in groups of 4)
32 kptArc, // Arc point (I think these come in groups of 3... unimplemented)
33 kptLast // Bounds check
34 } KivioPointType;
35
36protected:
37 double m_x, m_y; // Coordinates of the point
38 KivioPointType m_pointType; // The point type
39
40public:
41 KivioPoint();
42 KivioPoint( const KivioPoint & );
43 KivioPoint( double, double, KivioPointType pt=kptNormal );
44 virtual ~KivioPoint();
45
46 void copyInto( KivioPoint * ) const;
47
48 bool loadXML( const TQDomElement & );
49 TQDomElement saveXML( TQDomDocument & );
50
51 static KivioPoint::KivioPointType pointTypeFromString( const TQString & );
52
53 inline double x() const { return m_x; }
54 inline double y() const { return m_y; }
55 inline KivioPointType pointType() const { return m_pointType; }
56
57 inline void setX( double newX ) { m_x=newX; }
58 inline void setY( double newY ) { m_y=newY; }
59 inline void setPointType( KivioPointType pt ) { m_pointType=pt; }
60
61 inline void set( double newX, double newY, KivioPointType pt=kptNormal ) { m_x=newX; m_y=newY; m_pointType=pt; }
62 inline void set( const KivioPoint &p, KivioPointType pt=kptNormal ) { m_x=p.x(); m_y=p.y(); m_pointType=pt; }
63
64 inline void moveBy( double dx, double dy ) { m_x += dx; m_y += dy; }
65 inline void moveBy( const KivioPoint &p ) { m_x += p.x(); m_y += p.y(); }
66};
67
68#endif
69
70