Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlNominativeAxis.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 
22 #ifndef GLNOMINATIVEAXIS_H_
23 #define GLNOMINATIVEAXIS_H_
24 
25 #include <map>
26 
27 #include <tulip/GlAxis.h>
28 
29 namespace tlp {
30 
31 /**
32  * \brief A class to render an axis graduated with string values
33  *
34  * This class allow to draw a nominative axis (i.e. an axis graduated with string values)
35  */
36 class TLP_GL_SCOPE GlNominativeAxis : public GlAxis {
37 
38 public :
39 
40  /**
41  * GlNominativeAxis constructor. Build a nominative axis with no graduations (need to call setAxisGraduationsLabels to build them)
42  *
43  * \param axisName the name of the axis
44  * \axisBaseCoord the base coord of the axis (if the axis is horizontal, it is the the left end, if vertical it is the down end)
45  * \axisLength the length of the axis
46  * \axisOrientation the orientation of the axis, 2 possible values (HORIZONTAL_AXIS or VERTICAL_AXIS)
47  * \axisColor the color of the axis
48  */
49  GlNominativeAxis(const std::string &axisName, const Coord &axisBaseCoord, const float axisLength,
50  const AxisOrientation &axisOrientation, const Color &axisColor);
51 
52 
53  /**
54  * Method to set the axis graduations labels. A call to updateAxis has to be done after calling this method to build or update the axis graduations. The labels will be placed on the axis in the same order as the vector passed as parameter (from bottom to top if the axis is vertical, from left to right if it is horizontal).
55  *
56  * \param axisGradsLabels a vector of string containing the graduations labels
57  * \param labelsPosition the relative position of the axis graduations label. Two possible values : LEFT_OR_BELOW (if the axis is vertical, labels will be on the left of the axis, otherwise below) or RIGHT_OR_ABOVE
58  */
59  void setAxisGraduationsLabels(const std::vector<std::string> &axisGradsLabels, const LabelPosition &labelsPosition);
60 
61  /**
62  * Method to update the axis drawing. It has to be called when one (or more) of the setters method above has been used.
63  * This method redraw the whole axis and the graduations.
64  */
65  void updateAxis();
66 
67  /**
68  * Method to get the axis point coordinates associated to string value
69  *
70  * \param value the string value we want to retrieve axis point coordinates
71  */
72  Coord getAxisPointCoordForValue(std::string value);
73 
74  /**
75  * Method to get the string value associated to an axis point. Return "" if there is not.
76  *
77  * \param axisPointCoord the axis point coordinates we want to retrieve the associated string value
78  */
79  std::string getValueAtAxisPoint(const Coord &axisPointCoord);
80 
81  void translate(const Coord &c);
82 
83 
84 private :
85 
86  void buildAxisGraduations();
87 
88  std::vector<std::string> labelsOrder;
89  std::map<std::string, Coord> labelsCoord;
90  LabelPosition axisLabelsPosition;
91 
92 };
93 
94 }
95 
96 #endif /* GLNOMINATIVEAXIS_H_ */
97 ///@endcond