MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPdf.h
Go to the documentation of this file.
1#pragma once
2
3#include "config.h"
4#ifndef MRIOEXTRAS_NO_PDF
5#include "exports.h"
6#include "MRMesh/MRMeshFwd.h"
7#include "MRMesh/MRVector2.h"
8#include "MRMesh/MRBox.h"
9#include "MRMesh/MRColor.h"
10
11#include <filesystem>
12#include <vector>
13
14namespace MR
15{
16
21{
22 float titleSize = 18.f;
23 float textSize = 14.f;
33 std::string defaultFontName = "Helvetica";
37 std::string tableFontName = "Courier";
38};
39
43class Pdf
44{
45public:
47 MRIOEXTRAS_API Pdf( const std::filesystem::path& documentPath, const PdfParameters& params = PdfParameters() );
48 MRIOEXTRAS_API Pdf( Pdf&& other ) noexcept;
49 MRIOEXTRAS_API Pdf& operator=( Pdf other ) noexcept; // Sic, passing by value.
51 MRIOEXTRAS_API ~Pdf();
52
61 MRIOEXTRAS_API void addText( const std::string& text, bool isTitle = false );
62
69 MRIOEXTRAS_API void addTable( const std::vector<std::pair<std::string, float>>& table );
70
72 {
74 std::string rangeMin;
75 std::string rangeMax;
76 std::string percent;
77 };
78 MRIOEXTRAS_API void addPaletteStatsTable( const std::vector<PaletteRowStats>& paletteStats );
79
82 {
86 Vector2f size;
88 std::string caption;
91 };
97 MRIOEXTRAS_API void addImageFromFile( const std::filesystem::path& imagePath, const ImageParams& params );
98
100 MRIOEXTRAS_API void newPage();
101
103 MRIOEXTRAS_API void close();
104
105 void setCursorPosX( float posX ) { cursorX_ = posX; }
106 void setCursorPosY( float posY ) { cursorY_ = posY; }
107 float getCursorPosX() const { return cursorX_; }
108 float getCursorPosY() const { return cursorY_; }
109
110 MRIOEXTRAS_API Vector2f getPageSize() const;
111 MRIOEXTRAS_API Box2f getPageWorkArea() const;
112
114 MRIOEXTRAS_API operator bool() const;
115
116private:
117 struct TextParams;
118 // common method for adding different types of text
119 void addText_( const std::string& text, const TextParams& params );
120
121 struct State;
122 std::unique_ptr<State> state_;
123
124 std::filesystem::path filename_;
125
126 PdfParameters params_;
127
128 float cursorX_ = 0;
129 float cursorY_ = 0;
130
131 bool checkDocument() const;
132 void moveCursorToNewLine();
133};
134
135}
136#endif
Definition MRPdf.h:44
float getCursorPosY() const
Definition MRPdf.h:108
MRIOEXTRAS_API Pdf & operator=(Pdf other) noexcept
float getCursorPosX() const
Definition MRPdf.h:107
MRIOEXTRAS_API void addText(const std::string &text, bool isTitle=false)
void setCursorPosX(float posX)
Definition MRPdf.h:105
MRIOEXTRAS_API void addImageFromFile(const std::filesystem::path &imagePath, const ImageParams &params)
Add image from file in current cursor position. If image bigger than page size, autoscale image to pa...
MRIOEXTRAS_API void newPage()
Add new pageand move cursor on it.
MRIOEXTRAS_API void addPaletteStatsTable(const std::vector< PaletteRowStats > &paletteStats)
MRIOEXTRAS_API Box2f getPageWorkArea() const
MRIOEXTRAS_API Pdf(const std::filesystem::path &documentPath, const PdfParameters &params=PdfParameters())
Ctor.
MRIOEXTRAS_API void addTable(const std::vector< std::pair< std::string, float > > &table)
void setCursorPosY(float posY)
Definition MRPdf.h:106
MRIOEXTRAS_API void close()
Save and close document. After this impossible add anything in document.
MRIOEXTRAS_API Vector2f getPageSize() const
MRIOEXTRAS_API ~Pdf()
Dtor. Automatically do close.
MRIOEXTRAS_API Pdf(Pdf &&other) noexcept
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh/MRColor.h:9
Parameters of document style.
Definition MRPdf.h:21
std::string tableFontName
Definition MRPdf.h:37
float titleSize
Definition MRPdf.h:22
float textSize
Definition MRPdf.h:23
std::string defaultFontName
Font name list of available fonts: Courier (-Bold, -Oblique, -BoldOblique) Helvetica (-Bold,...
Definition MRPdf.h:33
Parameters to adding image from file.
Definition MRPdf.h:82
std::string caption
caption if not empty - add caption under marks (if exist) or image.
Definition MRPdf.h:88
Vector2f size
Definition MRPdf.h:86
bool uniformScaleFromWidth
set height to keep same scale as width scale
Definition MRPdf.h:90
Definition MRPdf.h:72
std::string rangeMin
Definition MRPdf.h:74
std::string rangeMax
Definition MRPdf.h:75
Color color
Definition MRPdf.h:73
std::string percent
Definition MRPdf.h:76