/* * Page.hh * * Created on: 28 oct. 2013 * Author: CS */ #ifndef PAGE_HH_ #define PAGE_HH_ #include "Panel.hh" #include "Font.hh" #include "PlotCommon.hh" #include "LayoutProperties.hh" #include "ContextFileWriter.hh" #include #include #include #include #include "plplot/plstream.h" namespace plot { class Page { public: static const PLINT A4_X_LENGTH_IN_MM; static const PLINT A4_Y_LENGTH_IN_MM; static const PLINT LETTER_X_LENGTH_IN_MM; static const PLINT LETTER_Y_LENGTH_IN_MM; static const PLFLT A4_X_LENGTH_IN_INCHES; static const PLFLT A4_Y_LENGTH_IN_INCHES; static const PLFLT LETTER_X_LENGTH_IN_INCHES; static const PLFLT LETTER_Y_LENGTH_IN_INCHES; static const PLINT A4_X_LENGTH_IN_PT; static const PLINT A4_Y_LENGTH_IN_PT; static const PLINT LETTER_X_LENGTH_IN_PT; static const PLINT LETTER_Y_LENGTH_IN_PT; Page(); Page(DefaultPlotConfiguration& defaults); Page(const Page& page); virtual ~Page(); /** * @brief Get page size in millimeter. * @return Return a tuple which contain page size in x coordinate and then page size in y coordinate. */ std::tuple getSizeInMm(); /** * @brief Get page size in current coordinate (point or pixel) according to device. * @return Return a tuple which contain page size in x coordinate and then page size in y coordinate. */ std::tuple getSize(); void setFont(std::string pname, int psize) { _font = Font(pname, psize); } void setDimension(const std::string& pdimension); void setOrientation(const std::string& porientation); void setMode(const std::string& pmode); const Font& getFont() const { return _font; } void setFont(const Font& font) { _font = font; } Label* getTitle() { return &_title; } const Label* getTitle() const { return &_title; } void setTitleText(const char* titleText) { _title._text = titleText; } Font getTitleFont() { Font titleFont(_title.getFont()); if (titleFont.getName() == "") titleFont.setName(_font.getName()); if (titleFont.getSize() == 0) titleFont.setSize(_font.getSize()); return titleFont; } void getDrawableBoundsInPlPage(Bounds& pBounds); void draw(std::shared_ptr& pls, bool newFile, const char *plotFilePrefix); void writeContext(ContextFileWriter& writer); /*void addPanel(boost::shared_ptr panel){ _panels.push_back(panel); }*/ public: //std::vector> _panels; /** * Page format : png, ps etc. */ std::string _format; /** * Page horizontal margin */ float _xMargin; /** * Page vertical margin */ float _yMargin; /** * Page horizontal loaded margin */ float _xLoadedMargin; /** * Page vertical loaded margin */ float _yLoadedMargin; /** * Page orientation : landscape, portrait */ PlotCommon::Orientation _orientation; /** * Page mode : color, greyscale */ PlotCommon::Mode _mode; /** * Page dimension : a4, letter */ PlotCommon::Dimension _dimension; /** * Page align : left, center, right */ PlotCommon::Align _titleAlign; /** * Page position : top, bottom */ PlotCommon::Position _titlePosition; int _dpi; LayoutProperties _layoutProperties; /** * Page file name */ std::string _fileName; /** * @brief The name of the file data * */ std::string fileDataName; /** * Default TimePlot and XYPLot width and height (used by vertical layout) * Default TimePlot and XYPlot margins (used to fix plot area size) */ double _defaultTimePlotWidth; double _defaultTimePlotHeight; double _defaultTimePlotLeftMargin; double _defaultTimePlotRightMargin; double _defaultTimePlotTopMargin; double _defaultTimePlotBottomMargin; double _defaultXYPlotWidth; double _defaultXYPlotHeight; double _defaultXYPlotLeftMargin; double _defaultXYPlotRightMargin; double _defaultXYPlotTopMargin; double _defaultXYPlotBottomMargin; /** * Superpose draw of all intervals in the same page */ bool _superposeMode; void calculateRelativeXMargin(PlotCommon::Orientation& orientation, PlotCommon::Dimension& dimension, float xMarginInMm); void calculateRelativeYMargin(PlotCommon::Orientation& orientation, PlotCommon::Dimension& dimension, float yMarginInMm); private: /** * Page font */ Font _font; /** * Page title */ Label _title; void initPageParameters(std::shared_ptr& pls); void drawCopyright(std::shared_ptr& pls); void drawTitle(std::shared_ptr& pls); }; std::ostream& operator <<(std::ostream& out, Page& page); std::ostream& operator <<(std::ostream& out, PlotCommon::Dimension& dimension); std::ostream& operator <<(std::ostream& out, PlotCommon::Orientation& orientation); std::ostream& operator <<(std::ostream& out, PlotCommon::Mode& mode); const std::string getPlSide(PlotCommon::Position& position); PLFLT getPlPos(PlotCommon::Align& align); PLFLT getPlJust(PlotCommon::Align& align); PLFLT getPlColor(PlotCommon::Mode& mode); const std::string getPlDev(const std::string& format); PLINT getPlDevXLength(const std::string& format, PlotCommon::Dimension& dimension, int dpi); PLINT getPlDevYLength(const std::string& format, PlotCommon::Dimension& dimension, int dpi); Color changeColor(std::shared_ptr& pls, Color& color, PlotCommon::Mode mode, int cmap = 0); void restoreColor(std::shared_ptr& pls, Color& color, PlotCommon::Mode mode, int cmap = 0); void getDefaultColor(PlotCommon::Mode mode, int& cursor, Color& color); } /* namespace plot */ #endif /* PAGE_HH_ */