-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimpleplot.cpp
More file actions
117 lines (92 loc) · 3.85 KB
/
simpleplot.cpp
File metadata and controls
117 lines (92 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Copyright 2014 Daniel McInnes
This file is part of OpenMining.
OpenMining is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenMining is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMining. If not, see <http://www.gnu.org/licenses/>.
*/
//-----------------------------------------------------------------
// simpleplot.cpp
//
// A simple example which shows how to use SurfacePlot
//-----------------------------------------------------------------
#include <math.h>
#include <iostream>
#include <qapplication.h>
#include <qwtplot3d/include/qwt3d_surfaceplot.h>
#include <qwtplot3d/include/qwt3d_function.h>
// my includes
#include "simpleplot.h"
#include "utils/Exit.h"
#include "utils/copy_mapped_value.h"
#include "utils/Rectangle.h"
#include "utils/save.h"
#include "utils/utils.h"
using namespace std;
using namespace Qwt3D;
using namespace utils;
Plot::Plot(QStringList& args, Cube& boundary, points3dgrid32_t& locations) : m_args(args)
{
uint32_t columns = 40, rows = 30;
x_int32_t grid_width = 0;
y_int32_t grid_height = 0;
float xscale = 1, yscale = 1, zscale = 1;
setTitle("https://github.com/DanielMcInnes/openmining");
copy_mapped_value(args, "-xscale", xscale);
copy_mapped_value(args, "-yscale", yscale);
copy_mapped_value(args, "-zscale", zscale);
copy_mapped_value(args, "-columns", columns);
copy_mapped_value(args, "-rows", rows);
if (columns < 1) Exit("Error! Invalid number of columns specified via '-columns'", -1);
if (rows < 1) Exit("Error! Invalid number of rows specified via '-rows'" , -1);
grid_width = boundary.longitudeRange() / columns;
grid_height = boundary.latitudeRange() / rows;
Rectangle_t grid(grid_width, grid_height);
cout << "Grid width = " << grid_width << " units of latitude." << endl;
cout << "Grid height = " << grid_height << " units of longitude." << endl;
GridMappingFunction gridMappingFunction(this, locations, grid);
gridMappingFunction.setMesh(columns+1,rows+1); // x, y. How finely we slice the x and y domains. Gridlines = columns + 1, rows + 1.
cout << "calling setDomain(" << boundary << ")" << endl;
gridMappingFunction.setDomain(boundary.m_minx, boundary.m_maxx, boundary.m_miny, boundary.m_maxy ); // xmin, xmax, ymin, ymax
gridMappingFunction.setMinZ(boundary.m_minz);
gridMappingFunction.setMaxZ(boundary.m_maxz);
cout << "calling create() " << endl;
gridMappingFunction.create();
cout << "calling setRotation() " << endl;
setRotation(30,0,15);
cout << "calling setScale(" << xscale << ", " << yscale << ", " << zscale << ")" << endl;
setScale(xscale,yscale,zscale);
cout << "calling setShift() " << endl;
setShift(0.15,0,0);
cout << "calling setZoom() " << endl;
setZoom(0.9);
for (unsigned i=0; i!=coordinates()->axes.size(); ++i)
{
coordinates()->axes[i].setMajors(7);
coordinates()->axes[i].setMinors(4);
}
coordinates()->axes[X1].setLabelString("x-axis");
coordinates()->axes[Y1].setLabelString("y-axis");
setCoordinateStyle(BOX);
updateData();
cout << "calling updateGL() " << endl;
updateGL();
}
double GridMappingFunction::operator()(double x, double y)
{
int32_t longitude = x;
int32_t latitude = y;
m_grid.setCentre(longitude, latitude);
z_int32_t elevation = 0;
m_locations.getZ(m_grid, elevation);
double retval = elevation;
//cout << FN << longitude << ", " << latitude << ": " << retval << ", " << endl;
return retval;
}