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