/* * Panel.hh * * Created on: 28 oct. 2013 * Author: CS */ #ifndef PANEL_HH_ #define PANEL_HH_ #include #include "Bounds.hh" #include "Font.hh" #include "Color.hh" #include "PlotCommon.hh" #include #include #include #include "plplot/plstream.h" #include "Axis.hh" #include "ColorAxis.hh" #include "TextPlot.hh" #include "CurvePlot.hh" #include "FillSerieConstant.hh" #include "FillSerieSerie.hh" #include "ParamsLegendProperties.hh" #include "TextLegendProperties.hh" #include "Layout.hh" #include "ContextFileWriter.hh" namespace plot { class Page; class DefaultPlotConfiguration; typedef std::map> Axes; typedef std::list> TextPlots; typedef std::list> CurvePlots; typedef std::list> FillSerieConstants; typedef std::list> FillSerieSeries; typedef std::list> TextLegendPropertiesList; /** * @brief A panel is a part of Page and owns a plot (and eventually * its decorator). */ class Panel { public: static const float TEXT_FACTOR; static const float LINE_SPACE_TITLE; /** * @brief Counter for panel unique id */ static int PANEL_COUNTER; /** * @brief Transform coordinate from AMDA page to Plplot page. */ static Bounds getCoordinateInPlPage(plstream* pls, const Bounds& pBounds, Page* pPage); Panel(); Panel(DefaultPlotConfiguration& defaults); Panel(Page* page); virtual ~Panel(); /** * @brief Draws panel. */ void draw(std::shared_ptr& pls); /** * @brief Write panel context */ void writeContext(std::shared_ptr& pls, ContextFileWriter& writer); /** * @brief Adds axis to panel, depends on plot type. */ void addAxis(const std::string& pAxisId, boost::shared_ptr pAxis) { _axes[pAxisId] = pAxis; } /** * @brief Gets Axis from id, new axis is created if not found. */ boost::shared_ptr getAxis(const std::string& pAxisId) { return _axes[pAxisId]; } /** * @brief Adds color axis to panel */ void addColorAxis(const std::string& pAxisId, boost::shared_ptr pColorAxis) { _colorAxis = pColorAxis; _axes[pAxisId] = pColorAxis; } /** * @brief Reset for next time interval plot */ void reset() { for (auto axe : _axes) { if (axe.second != nullptr) axe.second->reset(); } _paramsLegendProperties.reset(); for (auto legend : _textLegendPropertiesList) legend->reset(); for (auto text : _textPlots) text->reset(); for (auto curve : _curvePlots) curve->reset(); _drawn = false; } /** * @brief Gets color axis */ boost::shared_ptr getColorAxis(void) { return _colorAxis; } /** * @brief Panel unique identifier */ int _id; /** * @brief Number of points per plot */ int _resolution; /** * @brief Panel font, may be different from page font */ Font _font; /** * @brief Panel title, may be empty */ Label _title; /** * @brief Flag to know if the title must be updated during the next interval plot */ bool _updateTitleOnNextInterval; /** * @brief Panel position and size. */ Bounds _bounds; /** * @brief Background color */ Color _backgroundColor; /** * @brief Panel title Align (center, left, right) */ PlotCommon::Align _titleAlign; /** * @brief Panel title Position (top, bottom) */ PlotCommon::Position _titlePosition; /** * @brief _drawn Define if panel is already drawn (true) or not (false). */ bool _drawn; /** * @brief Page container */ Page* _page; /** * @brief List of axis. */ Axes _axes; /** * @brief List of axis. */ boost::shared_ptr _colorAxis; /** * @brief Prefered panel width and height. * @note Number set is in unit of panel character width or height. */ double _preferedWidth; double _preferedHeight; /** * @brief Space between border of panel and border of plot area. * @note Number set is in unit of panel character height. */ int _leftMargin; int _rightMargin; int _topMargin; int _bottomMargin; /** * @brief List of textplots. */ TextPlots _textPlots; /** * @brief List of curveplots. */ CurvePlots _curvePlots; /** * @brief List of FillSerieConstant. */ FillSerieConstants _fillSerieConstants; /** * @brief List of FillSerieSerie. */ FillSerieSeries _fillSerieSeries; /** * @brief Parameter legend properties */ ParamsLegendProperties _paramsLegendProperties; /** * @brief Text legend properties list */ TextLegendPropertiesList _textLegendPropertiesList; float getTitlePositionUnits (void); void drawEmptyPanel(std::shared_ptr& pls); private: void fillBackground(std::shared_ptr& pls, Bounds& pBounds) const; /** * @brief Position in units of the title character height */ float _titlePositionUnits; }; std::ostream& operator <<(std::ostream& out, Panel& panel); } /* namespace plot */ #endif /* PANEL_HH_ */