moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kmplot / kmplot / diagr.h
blob92d255d932736ec1d8a9720de31ae0f9b7a48a20
1 /*
2 * KmPlot - a math. function plotter for the KDE-Desktop
4 * Copyright (C) 1998, 1999 Klaus-Dieter M�ler
5 * 2000, 2002 kd.moeller@t-online.de
6 *
7 * This file is part of the KDE Project.
8 * KmPlot is part of the KDE-EDU Project.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /** @file diagr.h
26 * @brief Contains the CDiagr class. */
28 #ifndef diagr_included
29 #define diagr_included
31 // standard includes
32 #include <math.h>
33 #include <stdio.h>
35 // Qt includes
36 #include <qpainter.h>
38 //@{
39 /// Some abbreviations for horizontal and vertical lines.
40 #define Line drawLine
41 #define Lineh(x1, y, x2) drawLine(x1, y, x2, y)
42 #define Linev(x, y1, y2) drawLine(x, y1, x, y2)
43 //@}
45 //@{
46 /// Grid styles.
47 #define GRID_NONE 0
48 #define GRID_LINES 1
49 #define GRID_CROSSES 2
50 #define GRID_POLAR 3
51 //@}
53 /** @short This class manages the core drawing of the axes and the grid. */
54 class CDiagr
56 public:
57 /// Contructor. Members are set to initial values.
58 ///@see Create()
59 CDiagr();
60 /// Nothing to do for the destructor.
61 ~CDiagr();
63 /// Sets all members to current values.
64 void Create( QPoint Ref,
65 int lx, int ly,
66 double xmin, double xmax,
67 double ymin, double ymax );
68 /// Sets the current values for the scaling factors
69 void Skal( double ex, double ey );
70 /// Draws all requested parts of the diagram (axes, labels, grid e.g.)
71 void Plot( QPainter* pDC );
72 /// Returns the rectangle around the core of the plot area.
73 QRect GetPlotArea() { return PlotArea; }
74 /// Returns the rectangle for the frame around the plot. Extra frame is bigger.
75 QRect GetFrame() { return m_frame; }
77 /** @name Transformations */
78 //@{
79 /// These functions convert real coordinates to pixel coordinates and vice versa.
80 int Transx(double);
81 int Transy(double);
82 double Transx(int);
83 double Transy(int);
84 //@}
86 /** @name Style options
87 * These members hold the current options for line widths and colors
89 //@{
90 QRgb frameColor; ///< color of the border frame
91 QRgb axesColor; ///< color of the axes
92 QRgb gridColor; ///< color of the grid
94 uint borderThickness, ///< current line width for the border frame
95 axesLineWidth, ///< current line width for the axes
96 gridLineWidth, ///< current line width for the grid
97 ticWidth, ///< current line width for the tics
98 ticLength, ///< current length of the tic lines
99 //@}
100 xclipflg, ///< clipflg is set to 1 if the plot is out of the plot aerea.
101 yclipflg; ///< clipflg is set to 1 if the plot is out of the plot aerea.
104 private:
106 /// Draw the coordinate axes.
107 void drawAxes(QPainter*);
108 /// Draw the grid.
109 void drawGrid( QPainter* );
110 /// Write labels.
111 void drawLabels(QPainter*);
112 /// Current grid style.
113 int g_mode;
115 //@{
116 /// Plot range edge.
117 double xmin, xmax, ymin, ymax;
118 //@}
119 //@{
120 /// Clip boundage.
121 double xmd, ymd;
122 //@}
123 //@{
124 /// Axes tic distance.
125 double ex, ey;
126 //@}
127 //@{
128 ///Position of the first tic.
129 double tsx, tsy;
130 //@}
131 //@{
132 /// Screen coordinates of the coordinate system origin.
133 double ox, oy;
134 //@}
135 //@{
136 /// Transformation factors.
137 /// @see Skal
138 double skx, sky;
139 //@}
141 QRect PlotArea; ///< plot area
142 QRect m_frame; ///< frame around the plot
145 #endif // diagr_included