moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kig / misc / coordinate_system.h
blobb69a91519f67305581a2b73be594e40ef609f089
1 /**
2 This file is part of Kig, a KDE program for Interactive Geometry...
3 Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 USA
19 **/
21 #ifndef KIG_MISC_COORDINATE_SYSTEM_H
22 #define KIG_MISC_COORDINATE_SYSTEM_H
24 #include <qnamespace.h>
26 class KigPainter;
27 class KigDocument;
28 class KigWidget;
29 class CoordinateSystem;
30 class QValidator;
31 class Coordinate;
32 class QString;
33 class QStringList;
34 class QWidget;
36 class CoordinateSystemFactory
38 public:
39 enum { Euclidean = 0, Polar = 1 };
41 static QStringList names();
42 static QString setCoordinateSystemStatement( int id );
43 static CoordinateSystem* build( int which );
44 static CoordinateSystem* build( const char* type );
47 // a CoordinateSystem is what the user sees: it is kept by KigPart to
48 // show the user a grid, and to show the coordinates of points... it
49 // allows for weird CoordinateSystem's like homogeneous or
50 // projective...
51 // internally, it does nothing, it could almost have been an ordinary
52 // Object..., mapping coordinates from and to the screen to and from
53 // the internal coordinates is done elsewhere ( KigPainter and
54 // KigWidget... )
55 class CoordinateSystem
56 : public Qt
58 public:
59 CoordinateSystem();
60 virtual ~CoordinateSystem();
62 const Coordinate getCoordFromUser( const QString& caption, const QString& label,
63 const KigDocument& doc, QWidget* parent, bool* ok = 0,
64 const Coordinate* value = 0 ) const;
66 virtual QString fromScreen ( const Coordinate& pt, const KigDocument& w ) const = 0;
67 /**
68 * This returns a notice to say in which format coordinates should
69 * be entered. This should be something like:
70 * i18n( "Enter coordinates in the following form: \"(x,y)\", where
71 * x is the x coordinate, and y is the y coordinate." );
73 virtual QString coordinateFormatNotice() const = 0;
74 virtual Coordinate toScreen (const QString& pt, bool& ok) const = 0;
75 virtual void drawGrid ( KigPainter& p, bool showgrid = true,
76 bool showaxes = true ) const = 0;
77 virtual QValidator* coordinateValidator() const = 0;
78 virtual Coordinate snapToGrid( const Coordinate& c,
79 const KigWidget& w ) const = 0;
81 virtual const char* type() const = 0;
82 virtual int id() const = 0;
85 class EuclideanCoords
86 : public CoordinateSystem
88 public:
89 EuclideanCoords();
90 ~EuclideanCoords();
91 QString fromScreen( const Coordinate& pt, const KigDocument& w ) const;
92 QString coordinateFormatNotice() const;
93 Coordinate toScreen (const QString& pt, bool& ok) const;
94 void drawGrid ( KigPainter& p, bool showgrid = true,
95 bool showaxes = true ) const;
96 QValidator* coordinateValidator() const;
97 Coordinate snapToGrid( const Coordinate& c,
98 const KigWidget& w ) const;
100 const char* type() const;
101 int id() const;
104 class PolarCoords
105 : public CoordinateSystem
107 void drawGridLine( KigPainter& p, const Coordinate& center,
108 double radius ) const;
109 public:
110 PolarCoords();
111 ~PolarCoords();
112 QString fromScreen( const Coordinate& pt, const KigDocument& w ) const;
113 QString coordinateFormatNotice() const;
114 Coordinate toScreen (const QString& pt, bool& ok) const;
115 void drawGrid ( KigPainter& p, bool showgrid = true,
116 bool showaxes = true ) const;
117 QValidator* coordinateValidator() const;
118 Coordinate snapToGrid( const Coordinate& c,
119 const KigWidget& w ) const;
121 const char* type() const;
122 int id() const;
125 #endif