/* * ParamsLegendProperties.hh * * Created on: 18 sep. 2014 * Author: AKKA */ #ifndef PARAMSLEGENDPROPERTIES_HH_ #define PARAMSLEGENDPROPERTIES_HH_ #define LEGEND_NB_SYMBOLS_TO_DRAW 4 #define LEGEND_TEXT_OFFSET 1.0 #define LEGEND_TEXT_SPACING 2.0 #define LEGEND_TEXT_JUSTIFICATION 0.0 #define LEGEND_OUTSIDE_OFFSET 0.005 #define LEGEND_INSIDE_OFFSET 0.005 #define LEGEND_LINE_SYM_WIDTH 0.05 #include #include #include "plplot/plstream.h" #include "Color.hh" #include "SymbolProperties.hh" #include "LineProperties.hh" #include "ParameterAxes.hh" #include "SeriesProperties.hh" namespace plot { typedef enum {POS_INSIDE, POS_OUTSIDE} ParamsLegendPosition; /* * @brief Class for properties of a legend line */ class LegendLineProperties { public: /* * @brief Constructor */ LegendLineProperties(void); /* * @brief Destructor */ virtual ~LegendLineProperties(void); /* * @brief Get symbol */ const SymbolProperties& getSymbolProperties(void) const; /* * @brief Set symbol */ void setSymbolProperties(const SymbolProperties& symbolProperties); /* * @brief Get line */ const LineProperties& getLineProperties(void) const; /* * @brief Set line */ void setLineProperties(const LineProperties& lineProperties); /* * @brief Get legend line text */ const char *getText(void) const; /* * @brief Set legend line text */ void setText(const char *text); /* * @brief Set the default color */ void setDefaultTextColor(const Color &textColor); /* * @brief Get the color to use for this legend line. */ Color getTextColor(bool autoTextColor); /* * @brief Show line */ bool isLineVisible(void); /* * @brief Show symbol */ bool isSymbolsVisible(void); private: /* * @brief Symbol properties */ SymbolProperties _symbolProperties; /* * @brief Line properties */ LineProperties _lineProperties; /* * @brief Legend line text */ std::string _text; /* * @brief Text color */ Color _textColor; }; /* * @brief Class to describe a params legend */ class ParamsLegendProperties { public: /* * @brief Enumerate to know how to represent an interval in the legend */ enum IntervalInfoType { INDEX, STARTSTOP }; /* * @brief Constructor */ ParamsLegendProperties(void); /* * @brief Destructor */ virtual ~ParamsLegendProperties(void); /* * @brief Remove all legend lines and prepare for a next plot */ void resetPlot(void); /* * @brief Add a serie to the legend */ void addSerie(SeriesProperties &serie,const char *text, Color lineColor, Color symbolColor); /* * @brief Get the associated color index from a given color */ int getColorIndex(plstream *pls, Color color); /* * @brief Set only text option (don't show line and symbol) */ void setOnlyText(bool onlyText); /* * @brief Legend is in only text mode? */ bool isOnlyText(void); /* * @brief Set legend font */ void setFont(Font font); /* * @brief Get legend font */ Font& getFont(void); /* * @brief Set default text color */ void setDefaultTextColor(const Color& color); /* * @brief Set legend border color */ void setBorderColor(const Color& color); /* * @brief Get legend border color */ Color getBorderColor(void); /* * @brief Set visibility of the border */ void setIsBorderVisible(bool boderVisible); /* * @brief Get if the border is visible */ bool isBorderVisible(void); /* * @brief Get if the legend is visible */ bool isVisible(void); /* * @brief Set visibility of the legend */ void setIsVisible(bool isVisible); /* * @brief Get legend position */ ParamsLegendPosition getPosition(void); /* * @brief Set legend position */ void setPosition(ParamsLegendPosition position); /* * @brief Get legend lines list */ const std::list& getLegendLines(void) const; /* * @brief Get associated legend color map */ const std::vector& getColorsMap(void) const; /* * @brief Estimate the width of the legend */ double getEstimateWidth(double charSize); /* * @brief Get left offset */ double getLeftOffset(void); /* * @brief Set left offset */ void setLeftOffset(double offset); /* * @brief Legend already drawn? */ bool isDrawn(void); /* * @brief Set legend already drawn propertie */ void setDrawn(bool drawn); /* * @brief Set visibility of param info */ void setParamInfoVisible(bool isVisible); /* * @brief Get visibility of param info */ bool isParamInfoVisible(void); /* * @brief Set visibility of interval info */ void setIntervalInfoVisible(bool isVisible); /* * @brief Get visibility of interval info */ bool isIntervalInfoVisible(void); /* * @brief Set the type of the interval info (interval index or start/stop time) */ void setIntervalInfoType(IntervalInfoType type); /* * @brief Get interval info type */ IntervalInfoType getIntervalInfoType(void); private: /* * @brief Legend lines */ std::list _lines; /* * @brief Legend colors */ std::vector _colors; /* * @brief show only text */ bool _isOnlyText; /* * @brief Default color */ Color _defaultTextColor; /* * @brief Border visibility */ bool _isBorderVisible; /* * @brief Border color */ Color _borderColor; /* * @brief Legend visibility */ bool _isVisible; /* * @brief Legend position */ ParamsLegendPosition _position; /* * @brief Legend font */ Font _font; /* * @brief Legend left offset */ double _leftOffset; /* * @brief Legend drawn */ bool _drawn; /* * @brief Param info visibility */ bool _isParamInfoVisible; /* * @brief Interval info visibility */ bool _isIntervalInfoVisible; /* * @brief Interval info type */ IntervalInfoType _intervalInfoType; }; } #endif /* PARAMSLEGENDPROPERTIES_HH_ */