Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlNominativeAxis.h
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 GLNOMINATIVEAXIS_H_
00023 #define GLNOMINATIVEAXIS_H_
00024 
00025 #include <map>
00026 
00027 #include <tulip/GlAxis.h>
00028 
00029 namespace tlp {
00030 
00031 /**
00032  * \brief A class to render an axis graduated with string values
00033  *
00034  * This class allow to draw a nominative axis (i.e. an axis graduated with string values)
00035  */
00036 class TLP_GL_SCOPE GlNominativeAxis : public GlAxis {
00037 
00038 public :
00039 
00040   /**
00041    * GlNominativeAxis constructor. Build a nominative axis with no graduations (need to call setAxisGraduationsLabels to build them)
00042    *
00043    * \param axisName the name of the axis
00044    * \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)
00045    * \axisLength the length of the axis
00046    * \axisOrientation the orientation of the axis, 2 possible values (HORIZONTAL_AXIS or VERTICAL_AXIS)
00047    * \axisColor the color of the axis
00048    */
00049   GlNominativeAxis(const std::string &axisName, const Coord &axisBaseCoord, const float axisLength,
00050                    const AxisOrientation &axisOrientation, const Color &axisColor);
00051 
00052 
00053   /**
00054    * 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).
00055    *
00056    * \param axisGradsLabels a vector of string containing the graduations labels
00057    * \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
00058    */
00059   void setAxisGraduationsLabels(const std::vector<std::string> &axisGradsLabels, const LabelPosition &labelsPosition);
00060 
00061   /**
00062    * Method to update the axis drawing. It has to be called when one (or more) of the setters method above has been used.
00063    * This method redraw the whole axis and the graduations.
00064    */
00065   void updateAxis();
00066 
00067   /**
00068    * Method to get the axis point coordinates associated to string value
00069    *
00070    * \param value the string value we want to retrieve axis point coordinates
00071    */
00072   Coord getAxisPointCoordForValue(const std::string& value);
00073 
00074   /**
00075    * Method to get the string value associated to an axis point. Return "" if there is not.
00076    *
00077    * \param axisPointCoord the axis point coordinates we want to retrieve the associated string value
00078    */
00079   std::string getValueAtAxisPoint(const Coord &axisPointCoord);
00080 
00081   void translate(const Coord &c);
00082 
00083 
00084 private :
00085 
00086   void buildAxisGraduations();
00087 
00088   std::vector<std::string> labelsOrder;
00089   std::map<std::string, Coord> labelsCoord;
00090   LabelPosition axisLabelsPosition;
00091 
00092 };
00093 
00094 }
00095 
00096 #endif /* GLNOMINATIVEAXIS_H_ */
00097 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties