amath  1.8.5
Simple command line calculator
fgrid.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 #ifndef AMATH_GRID_H
31 #define AMATH_GRID_H
32 
33 /**
34  * @file fgrid.h
35  * @brief Function grid used with graphs.
36  *
37  */
38 
39 #include "userfunction.h"
40 #include "lib/real.h"
41 
42 class Grid
43 {
44 public:
45  explicit Grid(UserFunction* function);
46  ~Grid();
47  void SetFunctionBounderies(double minX, double maxX);
48  void SetScreenBounderues(int minX, int maxX, int minY, int maxY);
49  void GetScreenCoordinates(double value, int* x, int* y) const;
50  void GetScreenCoordinates(double xval, int* x, double yval, int* y) const;
51  double GetHorizontalResolution() const;
52 
53  void GetXAxis(int* xstart, int* xend, int* ystart, int* yend) const;
54  void GetYAxis(int* xstart, int* xend, int* ystart, int* yend) const;
55 
56 private:
57  double FunctionValue(double parameter) const;
58 
61 
62  double minX;
63  double maxX;
64  double minY;
65  double maxY;
66 
67  int pad;
72 
73  int originX;
74  int originY;
75  double zoom;
76  double scaleX;
77  double scaleY;
78 };
79 
80 #endif
void SetScreenBounderues(int minX, int maxX, int minY, int maxY)
Definition: fgrid.cpp:72
void GetScreenCoordinates(double xval, int *x, double yval, int *y) const
Definition: fgrid.cpp:101
double maxY
Definition: fgrid.h:65
int originX
Definition: fgrid.h:73
Grid(UserFunction *function)
Definition: fgrid.cpp:33
Definition: fgrid.h:42
void GetXAxis(int *xstart, int *xend, int *ystart, int *yend) const
Definition: fgrid.cpp:110
double zoom
Definition: fgrid.h:75
RealNumber * parameter
Definition: fgrid.h:60
int screenMinX
Definition: fgrid.h:68
double scaleY
Definition: fgrid.h:77
void SetFunctionBounderies(double minX, double maxX)
Definition: fgrid.cpp:51
double minX
Definition: fgrid.h:62
Represent a real number with 15 significant digits.
Definition: real.h:45
int screenMinY
Definition: fgrid.h:70
double GetHorizontalResolution() const
Definition: fgrid.cpp:46
double minY
Definition: fgrid.h:64
UserFunction * function
Definition: fgrid.h:59
void GetYAxis(int *xstart, int *xend, int *ystart, int *yend) const
Definition: fgrid.cpp:118
double maxX
Definition: fgrid.h:63
void GetScreenCoordinates(double value, int *x, int *y) const
Definition: fgrid.cpp:92
int screenMaxX
Definition: fgrid.h:69
A user defined function.
Definition: userfunction.h:44
int originY
Definition: fgrid.h:74
double scaleX
Definition: fgrid.h:76
int pad
Definition: fgrid.h:67
double FunctionValue(double parameter) const
Definition: fgrid.cpp:83
int screenMaxY
Definition: fgrid.h:71
~Grid()
Definition: fgrid.cpp:41