NDEVR
API Documentation
PaperView.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2020, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: PaperView
29Included in API: True
30Author(s): tyler.parke
31 *-----------------------------------------------------------------------------------------**/
32
33#pragma once
34#include "DLLInfo.h"
35#include <NDEVR/Model.h>
36#include <NDEVR/Camera.h>
37#include <NDEVR/TranslatedString.h>
38#include <NDEVR/Vector.h>
39#include <NDEVR/StringEnum.h>
40namespace NDEVR
41{
52 class NDEVR_DESIGN_API PaperView : public Model
53 {
54 public:
59 PaperView(const Model& model);
60
65 static constexpr StringView TypeName() { return "Paper_View"; }
66
72
78
84
90
99
105
111
118
124
130
136
142
148
154
160
166
172
181
182 private:
186 void init();
187
193 void setupDisplay(Model model, RGBColor color);
194
200 Vector<2, fltp04> adjustPaperSizeIn(Vector<2, fltp04> size) const;
201
207 Bounds<2, fltp04> adjustBoundsIn(Bounds<2, fltp04> size) const;
208
214 Vector<2, fltp04> adjustPaperSizeOut(Vector<2, fltp04> size) const;
215
221 Bounds<2, fltp04> adjustBoundsOut(Bounds<2, fltp04> size) const;
222
231 fltp04 yScaleFactor() const;
232 };
233
237 #define PAPERVIEW_PARAMS(X) \
238 X(e_page_size) \
239 X(e_margins) \
240 X(e_world_bounds) \
241 X(e_dots_per_meter)
242
247 NDEVR_DEFINE_STRING_STREAM(PaperViewProperty, PAPERVIEW_PARAMS)
248 template class NDEVR_DESIGN_API StringStream<PaperViewProperty>;
249
258
266 template<>
268 {
269 public:
275 template<PaperViewProperty t_property, class t_value_type>
276 static void Set(DesignInfo* object, const t_value_type& value)
277 {
278 if constexpr (t_property == PaperViewProperty::e_margins)
279 PaperView(Model(*object)).setMargins(value);
280 else if constexpr (t_property == PaperViewProperty::e_page_size)
281 PaperView(Model(*object)).setPaperSize(value);
282 else if constexpr (t_property == PaperViewProperty::e_world_bounds)
283 PaperView(Model(*object)).setWorldBounds(value);
284 else if constexpr (t_property == PaperViewProperty::e_dots_per_meter)
285 PaperView(Model(*object)).setDotsPerMeter(value);
286 }
287
293 template<PaperViewProperty t_property>
294 static decltype(auto) Get(const DesignInfo* object)
295 {
296 if constexpr (t_property == PaperViewProperty::e_margins)
297 return PaperView(Model(*object)).margins();
298 else if constexpr (t_property == PaperViewProperty::e_page_size)
299 return PaperView(Model(*object)).paperSize();
300 else if constexpr (t_property == PaperViewProperty::e_world_bounds)
301 return PaperView(Model(*object)).worldBounds();
302 else if constexpr (t_property == PaperViewProperty::e_dots_per_meter)
303 return PaperView(Model(*object)).dotsPerMeter();
304 }
305
311 template<PaperViewProperty t_property, class t_value_type>
312 static decltype(auto) Get(const DesignInfo* object)
313 {
314 return Get<t_property>(object);
315 }
316 };
317}
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Base information class for all design objects in the NDEVR property database.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
Vector< 3, fltp08 > size() const
Returns the size (extents) of the model's bounding box.
Model()
Default constructor. Creates an uninitialized Model.
Definition Model.h:365
Represents a paper/print layout view within the design, wrapping a Model with page-size,...
Definition PaperView.h:53
Vector< 2, fltp04 > innerPaperSize() const
Returns the inner (printable area) paper size, excluding margins.
PaperView(const Model &model)
Constructs a PaperView from an existing Model.
void setPaperSize(Vector< 2, fltp04 > size)
Sets the overall paper size (width and height).
static constexpr StringView TypeName()
Returns the type name identifier for this class.
Definition PaperView.h:65
void setDotsPerMeter(fltp04 weight)
Sets the resolution in dots per meter.
Vector< 2, fltp04 > paperSize() const
Returns the overall paper size.
Vector< 4, fltp04 > margins() const
Returns the page margins.
void setupViewportForCapture(const DynamicPointer< Camera > &camera)
Configures the given camera's viewport for high-resolution capture/export.
Model outerPage() const
Returns the outer page sub-model (the full paper sheet including margins).
void setupViewportForUser(const DynamicPointer< Camera > &camera)
Configures the given camera's viewport for interactive on-screen display.
Bounds< 3, fltp08 > worldBounds() const
Returns the world-space bounds associated with this paper view.
void setWorldBounds(Bounds< 3, fltp08 > bounds)
Sets the world-space bounds that this paper view encompasses.
static Vector< 4, fltp04 > DefaultMarginsFor(const Vector< 2, fltp04 > &page_size)
Computes default margins appropriate for a given page size.
static const Buffer< std::pair< TranslatedString, Vector< 2, fltp04 > > > & PaperSizes()
Returns a list of standard paper sizes with their translated display names.
Bounds< 3, fltp08 > captureBounds() const
Returns the bounding region used for capture/export rendering.
void setInnerPaperSize(Vector< 2, fltp04 > size)
Sets the inner (printable area) paper size, excluding margins.
fltp04 dotsPerMeter() const
Returns the current resolution in dots per meter.
Model innerPage() const
Returns the inner page sub-model (the printable content area).
void setMargins(Vector< 4, fltp04 > margin)
Sets the page margins.
Matrix< fltp08 > captureViewMatrix() const
Returns the view matrix used for capture rendering.
static void Set(DesignInfo *object, const t_value_type &value)
Sets a PaperViewProperty value on the given design object.
Definition PaperView.h:276
static decltype(auto) Get(const DesignInfo *object)
Gets a PaperViewProperty value from the given design object (typed overload).
Definition PaperView.h:312
static decltype(auto) Get(const DesignInfo *object)
Gets a PaperViewProperty value from the given design object.
Definition PaperView.h:294
Typed interface for getting and setting design object properties by enum.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
Definition StringView.h:58
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Maps a compile-time property enum value to its corresponding C++ storage type.