API Documentation
Loading...
Searching...
No Matches
Ruler.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, 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: NDEVR
28File: Ruler
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Camera.h>
35#if NDEVR_VIEWPORT
36#include <QWidget>
37class QActionGroup;
38class QAction;
39class QMenu;
40class QWidgetAction;
41namespace NDEVR
42{
43 class Button;
44 class Ruler;
45 class Toggle;
46 class QTResourceListener;
47 class DESIGN_WIDGETS_API Ruler : public QWidget
48 {
49 public:
50 static const int MARGIN = 4;
51 enum LabelMode
52 {
53 e_camera_location
54 , e_selection
55 , e_none
56 };
57
58 public:
59 Ruler(bool is_horizontal, bool is_left_or_top, QWidget* parent);
60 ~Ruler();
61 void setCamera(const DynamicPointer<Camera>& camera);
62 QSize sizeHint() const override;
63 void paintEvent(QPaintEvent *event) override;
64 void paintBackground(QPainter& g2D);
65 void paintRuler(QPainter& g2D);
66 void setLabel(const String& label, const Vector<2, fltp08>& location = Vector<2, fltp08>(0.0));
67 void setLabelMode(LabelMode mode);
68 String label() const;
69 RGBColor labelBackground();
70 void setLabelsVisible(bool visible);
71 protected:
72 void setAxis();
73 Vector<2, fltp08> labelPixelLocation() const;
74 Bounds<3, fltp08> worldBounds() const;
75 Vector<2, fltp08> worldSpan() const;
76 Vector<2, fltp08> scale() const;
77 Vector<2, fltp08> worldOffset() const;
78 Vector<2, fltp08> worldGridSpacing() const;
79 fltp08 convertPixelToModel(uint04 dim, uint04 pixel);
80 uint04 convertModelToPixel(uint04 dim, fltp08 model);
81 TranslatedString getFormattedTickText(fltp08 value, fltp08 spacing, uint01 dim);
82 protected:
83 QTResourceListener* m_camera_listener;
84 QTResourceListener* m_coordinate_listener;
85 bool m_is_horizontal;
86 String m_label_text;
87 RGBColor m_label_background;
88 LabelMode m_label_mode;
89 ConstPointer<Camera> m_camera;
90 Vector<2, uint01> m_axis;
91 Vector<2, uint01> m_label_axis;
92 Vector<2, fltp08> m_last_paint_scale;
93 Vector<2, fltp08> m_last_label_location;
94 Vector<2, fltp08> m_last_world_spacing;
95 Vector<2, fltp08> m_last_world_offset;
96 Vector<2, fltp08> m_label_location;
97 String m_last_label_text;
98 RGBColor m_last_label_background;
99 bool m_is_opaque;
100 bool m_is_left_or_top;
101 bool m_draw_minor;
102 bool m_labels_visible;
103 };
104
105 class DESIGN_WIDGETS_API CameraRulerMenu : public QObject
106 {
107 Q_OBJECT
108 public:
109 CameraRulerMenu(const DynamicPointer<Camera>& camera, Button* combo, const void* lock_ptr);
110 CameraRulerMenu(Button* combo, const void* lock_ptr);
111 void setCamera(const DynamicPointer<Camera>& camera);
112 void setLockPointer(const void* lock_ptr);
113 void setShowRuler(const TranslatedString& ruler_name, bool show_vertical, bool show_horizontal, bool show_lockable);
114 void updateFromModel();
115 protected:
116 void init();
117 signals:
118 void requestShowRuler(bool show_vertical, bool show_horizontal);
119 protected:
120 bool m_show_lockable;
121 bool m_is_locked;
122 bool m_is_shown;
123 QMenu* m_menu;
124 QWidgetAction* m_lock_act;
125 QWidgetAction* m_show_vert_act;
126 QWidgetAction* m_show_horz_act;
127 QWidgetAction* m_show_grid_act;
128 Toggle* m_vert_toggle;
129 Toggle* m_horz_toggle;
130 Toggle* m_lock_toggle;
131 Toggle* m_show_grid_toggle;
132 QActionGroup* m_view_mode_group;
133 Button* m_combo;
134 DynamicPointer<Camera> m_camera;
135 TranslatedString m_ruler_name;
136 const void* m_lock_ptr;
137 };
138}
139#endif
#define DESIGN_WIDGETS_API
Definition DLLInfo.h:74
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:115
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:176