kig
coordinate_system.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KIG_MISC_COORDINATE_SYSTEM_H
00022 #define KIG_MISC_COORDINATE_SYSTEM_H
00023
00024 #include <qnamespace.h>
00025
00026 class KigPainter;
00027 class KigDocument;
00028 class KigWidget;
00029 class CoordinateSystem;
00030 class QValidator;
00031 class Coordinate;
00032 class QString;
00033 class QStringList;
00034
00039 class CoordinateSystemFactory
00040 {
00041 public:
00042 enum { Euclidean = 0, Polar = 1 };
00043
00044 static QStringList names();
00045 static QString setCoordinateSystemStatement( int id );
00046 static CoordinateSystem* build( int which );
00047 static CoordinateSystem* build( const char* type );
00048 };
00049
00060 class CoordinateSystem
00061
00062 {
00063 public:
00064 CoordinateSystem();
00065 virtual ~CoordinateSystem();
00066
00067 virtual QString fromScreen ( const Coordinate& pt, const KigDocument& w ) const = 0;
00074 virtual QString coordinateFormatNotice() const = 0;
00079 virtual QString coordinateFormatNoticeMarkup() const = 0;
00080 virtual Coordinate toScreen (const QString& pt, bool& ok) const = 0;
00081 virtual void drawGrid ( KigPainter& p, bool showgrid = true,
00082 bool showaxes = true ) const = 0;
00083 virtual QValidator* coordinateValidator() const = 0;
00084 virtual Coordinate snapToGrid( const Coordinate& c,
00085 const KigWidget& w ) const = 0;
00086
00087 virtual const char* type() const = 0;
00088 virtual int id() const = 0;
00089 };
00090
00091 class EuclideanCoords
00092 : public CoordinateSystem
00093 {
00094 public:
00095 EuclideanCoords();
00096 ~EuclideanCoords();
00097 QString fromScreen( const Coordinate& pt, const KigDocument& w ) const;
00098 QString coordinateFormatNotice() const;
00099 QString coordinateFormatNoticeMarkup() const;
00100 Coordinate toScreen (const QString& pt, bool& ok) const;
00101 void drawGrid ( KigPainter& p, bool showgrid = true,
00102 bool showaxes = true ) const;
00103 QValidator* coordinateValidator() const;
00104 Coordinate snapToGrid( const Coordinate& c,
00105 const KigWidget& w ) const;
00106
00107 const char* type() const;
00108 int id() const;
00109 };
00110
00111 class PolarCoords
00112 : public CoordinateSystem
00113 {
00114 void drawGridLine( KigPainter& p, const Coordinate& center,
00115 double radius ) const;
00116 public:
00117 PolarCoords();
00118 ~PolarCoords();
00119 QString fromScreen( const Coordinate& pt, const KigDocument& w ) const;
00120 QString coordinateFormatNotice() const;
00121 QString coordinateFormatNoticeMarkup() const;
00122 Coordinate toScreen (const QString& pt, bool& ok) const;
00123 void drawGrid ( KigPainter& p, bool showgrid = true,
00124 bool showaxes = true ) const;
00125 QValidator* coordinateValidator() const;
00126 Coordinate snapToGrid( const Coordinate& c,
00127 const KigWidget& w ) const;
00128
00129 const char* type() const;
00130 int id() const;
00131 };
00132
00133 #endif