![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 00022 #ifndef GLQUANTITATIVEAXIS_H_ 00023 #define GLQUANTITATIVEAXIS_H_ 00024 00025 #include <tulip/GlAxis.h> 00026 00027 namespace tlp { 00028 00029 /** 00030 * \brief A class to render an axis graduated with numerical values for a given range 00031 * 00032 * This class allows to draw a quantitative axis (i.e. an axis axis graduated with numerical values for a given range) 00033 */ 00034 class TLP_GL_SCOPE GlQuantitativeAxis : public GlAxis { 00035 00036 public : 00037 00038 /** 00039 * GlQuantitativeAxis constructor. Create an quantitative axis without graduations (need to call setAxisParameters to build them) 00040 * 00041 * \param axisName the name of the axis 00042 * \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) 00043 * \axisLength the length of the axis 00044 * \axisOrientation the orientation of the axis, 2 possible values (HORIZONTAL_AXIS or VERTICAL_AXIS) 00045 * \axisColor the color of the axis 00046 * \addArrow If true, an arrow will be added to one end of the axis according to the axis order (ascending or descending) 00047 * \ascendingOrder If true, the min value will be at the bottom end and the max will be at the top end if the axis is vertical (min at the left and max at the right if it is horizontal). If false this positions are switched 00048 */ 00049 GlQuantitativeAxis(const std::string &axisName, const Coord &axisBaseCoord, const float axisLength, 00050 const AxisOrientation &axisOrientation, const Color &axisColor, 00051 const bool addArrow = true, const bool ascendingOrder = true); 00052 00053 /** 00054 * Method to set the quantitative axis parameters. A call to updateAxis has to be done after calling this method to build or update the axis graduations 00055 * 00056 * \param min the min value of the range the axis represents 00057 * \param max the max value of the range the axis represents 00058 * \param nbGraduations the number of graduations to build 00059 * \param axisGradsLabelsPosition 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 00060 * \param drawFirstLabel If false, the first graduation label will not be drawn (usefull when some axis have the same base coord to avoid labels overlapping) 00061 */ 00062 void setAxisParameters(const double min, const double max, const unsigned int nbGraduations, 00063 const LabelPosition &axisGradsLabelsPosition = LEFT_OR_BELOW, const bool drawFirstLabel = true); 00064 00065 00066 void setAxisParameters(const long long min, const long long max, const unsigned long long incrementStep, 00067 const LabelPosition &axisGradsLabelsPosition = LEFT_OR_BELOW, const bool drawFirstLabel = true); 00068 00069 void setAxisParameters(const int min, const int max, const unsigned int incrementStep, 00070 const LabelPosition &axisGradsLabelsPosition = LEFT_OR_BELOW, const bool drawFirstLabel = true) { 00071 setAxisParameters((long long) min, (long long) max, (unsigned long long) incrementStep, axisGradsLabelsPosition, drawFirstLabel); 00072 } 00073 00074 void setNbGraduations(const unsigned int nbGraduations) { 00075 this->nbGraduations = nbGraduations; 00076 } 00077 00078 00079 /** 00080 * Method to set a logarithmic scale on the axis. A call to updateAxis has to be done after calling this method to build or update the axis graduations 00081 * 00082 * \param logScale If true, activate the logarithmic scale on the axis 00083 * \param logBase If filled, set the logarithm base 00084 */ 00085 void setLogScale(const bool logScale, const unsigned int logBase = 10); 00086 00087 /** 00088 * Method to set the order of the values on the axis (ascending or descending). A call to updateAxis has to be done after calling this method to build or update the axis graduations 00089 */ 00090 void setAscendingOrder(const bool ascendingOrder) { 00091 this->ascendingOrder = ascendingOrder; 00092 } 00093 00094 /** 00095 * Method to update the axis drawing. It has to be called when one (or more) of the setters method above has been used. 00096 * This method redraw the whole axis and the graduations. 00097 */ 00098 void updateAxis(); 00099 00100 /** 00101 * Method to get the axis point coordinates for a given value 00102 * 00103 * \param value the value we want to retrieve axis point coordinates 00104 */ 00105 Coord getAxisPointCoordForValue(double value) const; 00106 00107 /** 00108 * Method to get the value associated to an axis point 00109 * 00110 * \param axisPointCoord the axis point coordinates we want to retrieve associated value 00111 */ 00112 double getValueForAxisPoint(const Coord &axisPointCoord); 00113 00114 /** 00115 * Method to get the order of the values on the axis (ascending or descending) 00116 */ 00117 bool hasAscendingOrder() const { 00118 return ascendingOrder; 00119 } 00120 00121 double getAxisMinValue() const { 00122 return min; 00123 } 00124 00125 double getAxisMaxValue() const { 00126 return max; 00127 } 00128 00129 private : 00130 00131 void buildAxisGraduations(); 00132 void addArrowDrawing(); 00133 00134 double min, max, scale; 00135 double minLog, maxLog; 00136 unsigned int nbGraduations; 00137 LabelPosition axisGradsLabelsPosition; 00138 bool drawFistLabel; 00139 bool ascendingOrder; 00140 bool addArrow; 00141 Coord captionCenterCoord; 00142 bool logScale; 00143 unsigned int logBase; 00144 bool integerScale; 00145 unsigned long long incrementStep; 00146 bool minMaxSet; 00147 00148 }; 00149 00150 } 00151 00152 #endif /* GLQUANTITATIVEAXIS_H_ */ 00153 ///@endcond