API Documentation
Loading...
Searching...
No Matches
ViewToPrimitiveObjects.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/Font.h>
3#if NDEVR_VIEWPORT
4#include <NDEVR/Polygon.h>
5#include <NDEVR/UUID.h>
6#include <functional>
7namespace NDEVR
8{
9 class DesignObjectLookup;
10 class Text;
11 class Model;
12 class Geometry;
13 class Camera;
14 /**--------------------------------------------------------------------------------------------------
15 \brief Used to convert a view and a DesignObjectLookup of data into a 2D map of primitive data types
16 **/
17 class ViewToPrimitiveObjects
18 {
19 struct PrimitiveClipRegion
20 {
21 Polygon<fltp04> polygon;
22 bool operator==(const PrimitiveClipRegion& region) const
23 {
24 return region.polygon == polygon;
25 }
26 bool operator!=(const PrimitiveClipRegion& region) const
27 {
28 return region.polygon != polygon;
29 }
30 };
31 struct PrimitiveDrawObject
32 {
33 Buffer<PrimitiveClipRegion> clip_region;
34 fltp04 radius;
36 RGBColor color;
37 bool is_filled;
38 };
39 struct PrimitiveDrawPoint : public PrimitiveDrawObject
40 {
41 Vector<2, fltp04> point;
42 };
43 struct PrimitiveDrawLine : public PrimitiveDrawObject
44 {
45 LineSegment<2, fltp04> segment;
46 };
47 struct PrimitiveDrawPolygon : public PrimitiveDrawObject
48 {
49 Polygon<fltp04> polygon;
50 };
51 struct PrimitiveDrawImagePolygon : public PrimitiveDrawPolygon
52 {
53 String image_id;
54 Polygon<fltp04> image_polygon;
55 fltp04 opacity = 1.0f;
56 Matrix<fltp08> image_transform = Matrix<fltp08>(1.0);
57 };
58 struct PrimitiveDrawText : public PrimitiveDrawObject
59 {
60 String text;
61 Font font;
62 Matrix<fltp04, 3, 2> transform;
63 };
64 struct PrimitiveRenderOptions
65 {
66 Matrix<fltp08> complete_geo_transform;
67 Bounds<3, fltp04> bounds;
68 fltp04 px_scale;
69 bool draw_grid;
70 bool draw_border;
71 fltp04 dpi;
72 uint04 margins;
73 Buffer<PrimitiveDrawLine> lines;
74 Buffer<PrimitiveDrawPoint> points;
75 Buffer<PrimitiveDrawPolygon> polygons;
76 Buffer<PrimitiveDrawImagePolygon> image_polygons;
77 Buffer<PrimitiveDrawText> text;
78 Dictionary<String, Font> fonts;
79 Matrix<fltp08> camera_transform;
80 };
81 public:
82 ViewToPrimitiveObjects(const DesignObjectLookup* lookup);
83 void setDrawGrid(bool draw_grid);
84 void setTitle(const String& title, const String& subject);
85 void setMargins(uint04 margins);
86 virtual void setdpi(fltp08 dpi);
87 void setDrawBorder(bool border);
88 virtual bool execute(const Camera& camera, const Buffer<UUID>& objects_to_render, PrimitiveRenderOptions& options);
89
90 protected:
91 void sortAndDraw(PrimitiveRenderOptions& draw_options);
92 Buffer<PrimitiveClipRegion> getClipping(const PrimitiveRenderOptions& primitive_options, const Model& model);
93 #if NDEVR_TEXT_MODEL
94 void writeTextToOptions(PrimitiveRenderOptions& primitive_options, const Matrix<fltp08>& tr, Text text);
95 #endif
96 void writeGeometryToOptions(PrimitiveRenderOptions& pdf_options, const Matrix<fltp08>& tr, const Model& model, const Geometry& geo);
97 protected:
98 std::function<void(const PrimitiveDrawImagePolygon& image_id, const PrimitiveRenderOptions& pdf_options)> m_draw_image;
99 std::function<void(const Font& font, const PrimitiveRenderOptions& pdf_options)> m_add_font;
100 std::function<void(const PrimitiveDrawPoint& point, const PrimitiveRenderOptions& pdf_options)> m_draw_point;
101 std::function<void(const PrimitiveDrawLine& line, const PrimitiveRenderOptions& pdf_options)> m_draw_line;
102 std::function<void(const PrimitiveDrawPolygon& poly, const PrimitiveRenderOptions& pdf_options)> m_draw_poly;
103 std::function<void(const PrimitiveDrawImagePolygon& image_poly, const PrimitiveRenderOptions& pdf_options)> m_draw_image_poly;
104 std::function<void(const PrimitiveDrawText& text, const PrimitiveRenderOptions& pdf_options)> m_draw_text;
105
106 const DesignObjectLookup* m_lookup;
107 String m_title;
108 String m_subject;
109 uint04 m_margins;
110 bool m_draw_grid;
111 bool m_draw_border;
112 fltp08 m_dpi;
113 };
114}
115#endif
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:171
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149