GlobeEngine
Comparisoner.h
Go to the documentation of this file.
1 #ifndef GlobeEngine_Comparisoner_h
2 #define GlobeEngine_Comparisoner_h
3 
4 #include <vmmlib/vector.hpp>
5 #include <vector>
6 #include <set>
7 #include <algorithm>
8 #include <memory>
9 #include <sstream>
10 
11 #include "Planet.h"
12 #include "OrthographicMapCamera.h"
13 #include "ComparisonGrid.h"
14 
15 namespace geAstro {
16 
21  };
22 
24  {
25  std::string labelContent;
26  vmml::Vector3d labelPosition;
27 
29  labelContent = "not set";
30  labelPosition = vmml::Vector3d(-1.0, -1.0, -1.0);
31  }
32 
33  ComparisonLabelInfo(std::string _labelContent, vmml::Vector3d _labelPosition) :
34  labelContent(_labelContent), labelPosition(labelPosition)
35  {}
36  };
37 
39  {
40  double compareValueX;
41  double compareValueY;
42  vmml::Vector3d comparisonPosition;
43 
45  compareValueX = -1;
46  compareValueY = -1;
47  comparisonPosition = vmml::Vector3d(-1.0, -1.0, -1.0);
48  }
49 
50  ComparisonInfo(double _compareValueX, double _compareValueY, vmml::Vector3d _comparisonPosition) :
51  compareValueX(_compareValueX), compareValueY(_compareValueY), comparisonPosition(_comparisonPosition)
52  {}
53  };
54 
55  class Comparisoner{
56 
57  public:
58  Comparisoner();
59  ~Comparisoner();
60  void clear();
61  void createComparison();
62  void drawComparison();
63  void drawComparisonGrid();
64  void addPlanet(std::shared_ptr<Planet> _planet);
65  void addPlanet(std::vector<std::shared_ptr<Planet> > _planets);
66  void removePlanet(std::shared_ptr<Planet> _planet);
67  void togglePlanetMarking(std::shared_ptr<Planet> _planet);
68  void clearPlanets();
69  void setXProperty(ComparisonProperty _xProperty);
70  void setYProperty(ComparisonProperty _yProperty);
73  void setCamera(std::shared_ptr<ge::OrthographicMapCamera> _cam);
74 
75  void setupComparisonGrid(std::shared_ptr<ge::Shader> _shader);
76  void newNumberOfXLines(int _lines);
77  void newNumberOfYLines(int _lines);
78  void newXRangeMin(double _newMin);
79  void newXRangeMax(double _newMax);
80  void newYRangeMin(double _newMin);
81  void newYRangeMax(double _newMax);
82  const vmml::Vector2d& getPropertyValuesMin();
83  const vmml::Vector2d& getPropertyValuesMax();
84  const vmml::Vector2i& getInitialNumberOfLines();
85  const vmml::Vector2i& getCurrentNumberOfLines();
86 
87  void createLabelInfos();
88  std::vector<ComparisonLabelInfo>& getAxisLabelInfos();
89  std::vector<ComparisonLabelInfo>& getPlanetAxisLabelInfos();
90  std::vector<ComparisonLabelInfo>& getPlanetNameLabelInfos();
91  std::vector<ComparisonLabelInfo>& getMarkedPlanetAxisLabelInfos();
92  std::vector<ComparisonLabelInfo>& getMarkedPlanetNameLabelInfos();
93 
94  void resetCamera();
95 
96  private:
97  std::vector<ComparisonInfo> createComparisonInfos();
98  std::vector<ComparisonInfo> calculateComparisonPositions(std::vector<ComparisonInfo>& _infosToCompare);
99  void setComparisonPositionForPlanets(std::vector<ComparisonInfo>& _infos);
100 
101  //set containing pointers to all planets that are currently compared
102  std::set<std::shared_ptr<Planet> > planetsToCompare;
103 
104  //set containing pointers to all planets that lie in the currently selected comparison range (i.e. planets that get displayed)
105  std::set<std::shared_ptr<Planet> > planetsInRange;
106 
107  //set containing pointers to all planets that are currently marked
108  std::set<std::shared_ptr<Planet> > planetsMarked;
109 
110  //range (world coordinates) to which the comparisoner maps planet properties
111  //e.g. the smallest x-axis property value gets mapped to mapValuesMin.x(), the largest gets mapped to mapValuesMax.x()
112  vmml::Vector2d mapValuesMin;
113  vmml::Vector2d mapValuesMax;
114 
115  //range of the current comparison values
116  //e.g. propertyValuesMin.x() contains the current minimal value for the property selected for the x-axis (i.e. the one which gets mapped
117  //to mapValuesMin.x())
118  vmml::Vector2d propertyValuesMin;
119  vmml::Vector2d propertyValuesMax;
120 
121  //axis label values
122  std::vector<double> xAxisValues;
123  std::vector<double> yAxisValues;
124 
125  //holds offsets for axis labels
126  //.x() offset in x for y-axis labels, .y() offset in y for x-axis labels
127  //.z() offset in y for y-axis labels, .w() offset in x for x-axis labels
128  //all in world coordinates
129  vmml::Vector4d labelOffsets;
130 
131  ComparisonProperty xProperty;
132  ComparisonProperty yProperty;
133 
134  ComparisonGrid comparisonGrid;
135 
136  vmml::Vector2i initialNumberOfLines;
137 
138  std::shared_ptr<ge::OrthographicMapCamera> orthoCam;
139 
140  void calculateAxisValues();
141  std::string getUnitForProperty(ComparisonProperty _property);
142  vmml::Vector2d getDefaultRangeForProperty(ComparisonProperty _property);
143 
144  //labels infos
145  std::vector<ComparisonLabelInfo> axisLabelInfos;
146  std::vector<ComparisonLabelInfo> planetAxisLabelInfos;
147  std::vector<ComparisonLabelInfo> planetNameLabelInfos;
148  std::vector<ComparisonLabelInfo> markedPlanetAxisLabelInfos;
149  std::vector<ComparisonLabelInfo> markedPlanetNameLabelInfos;
150 
151  };
152 }
153 #endif
void newYRangeMin(double _newMin)
Definition: Comparisoner.cpp:189
const vmml::Vector2i & getInitialNumberOfLines()
Definition: Comparisoner.cpp:139
ComparisonProperty getXProperty()
Definition: Comparisoner.cpp:123
vmml::Vector3d labelPosition
Definition: Comparisoner.h:26
ComparisonProperty getYProperty()
Definition: Comparisoner.cpp:127
void createComparison()
Definition: Comparisoner.cpp:26
void newNumberOfXLines(int _lines)
Definition: Comparisoner.cpp:161
void newNumberOfYLines(int _lines)
Definition: Comparisoner.cpp:170
const vmml::Vector2i & getCurrentNumberOfLines()
Definition: Comparisoner.cpp:143
Definition: Comparisoner.h:20
ComparisonLabelInfo()
Definition: Comparisoner.h:28
ComparisonInfo()
Definition: Comparisoner.h:44
std::vector< ComparisonLabelInfo > & getAxisLabelInfos()
Definition: Comparisoner.cpp:702
void newXRangeMin(double _newMin)
Definition: Comparisoner.cpp:179
void newXRangeMax(double _newMax)
Definition: Comparisoner.cpp:184
void drawComparison()
Definition: Comparisoner.cpp:33
Definition: Comparisoner.h:20
void setYProperty(ComparisonProperty _yProperty)
Definition: Comparisoner.cpp:115
void setCamera(std::shared_ptr< ge::OrthographicMapCamera > _cam)
Definition: Comparisoner.cpp:147
ComparisonLabelInfo(std::string _labelContent, vmml::Vector3d _labelPosition)
Definition: Comparisoner.h:33
Definition: Comparisoner.h:55
Definition: Comparisoner.h:19
ComparisonInfo(double _compareValueX, double _compareValueY, vmml::Vector3d _comparisonPosition)
Definition: Comparisoner.h:50
void setXProperty(ComparisonProperty _xProperty)
Definition: Comparisoner.cpp:107
Definition: Comparisoner.h:20
void createLabelInfos()
Definition: Comparisoner.cpp:381
ComparisonProperty
Definition: Comparisoner.h:17
void togglePlanetMarking(std::shared_ptr< Planet > _planet)
Definition: Comparisoner.cpp:91
void setupComparisonGrid(std::shared_ptr< ge::Shader > _shader)
Definition: Comparisoner.cpp:151
void clearPlanets()
Definition: Comparisoner.cpp:103
Definition: AstroCommon.h:18
void newYRangeMax(double _newMax)
Definition: Comparisoner.cpp:194
Definition: ComparisonGrid.h:10
Definition: Comparisoner.h:20
std::vector< ComparisonLabelInfo > & getPlanetAxisLabelInfos()
Definition: Comparisoner.cpp:829
Definition: Comparisoner.h:23
std::vector< ComparisonLabelInfo > & getMarkedPlanetAxisLabelInfos()
Definition: Comparisoner.cpp:1041
void resetCamera()
Definition: Comparisoner.cpp:1231
Definition: Comparisoner.h:19
const vmml::Vector2d & getPropertyValuesMin()
Definition: Comparisoner.cpp:131
Definition: Comparisoner.h:20
void addPlanet(std::shared_ptr< Planet > _planet)
Definition: Comparisoner.cpp:46
double compareValueY
Definition: Comparisoner.h:41
void drawComparisonGrid()
Definition: Comparisoner.cpp:42
vmml::Vector3d comparisonPosition
Definition: Comparisoner.h:42
Definition: Comparisoner.h:18
Definition: Comparisoner.h:38
Definition: Comparisoner.h:19
void removePlanet(std::shared_ptr< Planet > _planet)
Definition: Comparisoner.cpp:76
Definition: Comparisoner.h:19
std::vector< ComparisonLabelInfo > & getMarkedPlanetNameLabelInfos()
Definition: Comparisoner.cpp:1045
void clear()
Definition: Comparisoner.cpp:15
Definition: Comparisoner.h:19
Definition: Comparisoner.h:19
std::vector< ComparisonLabelInfo > & getPlanetNameLabelInfos()
Definition: Comparisoner.cpp:1024
Definition: Comparisoner.h:19
~Comparisoner()
Definition: Comparisoner.cpp:11
const vmml::Vector2d & getPropertyValuesMax()
Definition: Comparisoner.cpp:135
std::string labelContent
Definition: Comparisoner.h:25
Comparisoner()
Definition: Comparisoner.cpp:7
double compareValueX
Definition: Comparisoner.h:40
Definition: Comparisoner.h:20