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 /**--------------------------------------------------------------------------------------------------
48 \brief A widget meant to be placed beside a camera view showing either directional or measurement markings
49 depending on whether or not a camera is orthographic.
50 **/
51 class DESIGN_WIDGETS_API Ruler : public QWidget
52 {
53 public:
54 static const int MARGIN = 4;
55 enum LabelMode
56 {
57 e_camera_location
58 , e_selection
59 , e_none
60 };
61
62 public:
63 Ruler(bool is_horizontal, bool is_left_or_top, QWidget* parent);
64 ~Ruler();
65 void setCamera(const DynamicPointer<Camera>& camera);
66 QSize sizeHint() const override;
67 void paintEvent(QPaintEvent *event) override;
68 void paintBackground(QPainter& g2D);
69 void paintRuler(QPainter& g2D);
70 void setLabel(const String& label, const Vector<2, fltp08>& location = Vector<2, fltp08>(0.0));
71 void setLabelMode(LabelMode mode);
72 String label() const;
73 RGBColor labelBackground();
74 void setLabelsVisible(bool visible);
75 protected:
76 void setAxis();
77 Vector<2, fltp08> labelPixelLocation() const;
78 Bounds<3, fltp08> worldBounds() const;
79 Vector<2, fltp08> worldSpan() const;
80 Vector<2, fltp08> scale() const;
81 Vector<2, fltp08> worldOffset() const;
82 Vector<2, fltp08> worldGridSpacing() const;
83 fltp08 convertPixelToModel(uint04 dim, uint04 pixel);
84 uint04 convertModelToPixel(uint04 dim, fltp08 model);
85 TranslatedString getFormattedTickText(fltp08 value, fltp08 spacing, uint01 dim);
86 protected:
87 QTResourceListener* m_camera_listener;
88 QTResourceListener* m_coordinate_listener;
89 bool m_is_horizontal;
90 String m_label_text;
91 RGBColor m_label_background;
92 LabelMode m_label_mode;
93 ConstPointer<Camera> m_camera;
94 Vector<2, uint01> m_axis;
95 Vector<2, uint01> m_label_axis;
96 Vector<2, fltp08> m_last_paint_scale;
97 Vector<2, fltp08> m_last_label_location;
98 Vector<2, fltp08> m_last_world_spacing;
99 Vector<2, fltp08> m_last_world_offset;
100 Vector<2, fltp08> m_label_location;
101 String m_last_label_text;
102 RGBColor m_last_label_background;
103 bool m_is_opaque;
104 bool m_is_left_or_top;
105 bool m_draw_minor;
106 bool m_labels_visible;
107 };
108
109 class DESIGN_WIDGETS_API CameraRulerMenu : public QObject
110 {
111 Q_OBJECT
112 public:
113 CameraRulerMenu(const DynamicPointer<Camera>& camera, Button* combo, const void* lock_ptr);
114 CameraRulerMenu(Button* combo, const void* lock_ptr);
115 void setCamera(const DynamicPointer<Camera>& camera);
116 void setLockPointer(const void* lock_ptr);
117 void setShowRuler(const TranslatedString& ruler_name, bool show_vertical, bool show_horizontal, bool show_lockable);
118 void updateFromModel();
119 protected:
120 void init();
121 signals:
122 void requestShowRuler(bool show_vertical, bool show_horizontal);
123 protected:
124 bool m_show_lockable;
125 bool m_is_locked;
126 bool m_is_shown;
127 QMenu* m_menu;
128 QWidgetAction* m_lock_act;
129 QWidgetAction* m_show_vert_act;
130 QWidgetAction* m_show_horz_act;
131 QWidgetAction* m_show_grid_act;
132 Toggle* m_vert_toggle;
133 Toggle* m_horz_toggle;
134 Toggle* m_lock_toggle;
135 Toggle* m_show_grid_toggle;
136 QActionGroup* m_view_mode_group;
137 Button* m_combo;
138 DynamicPointer<Camera> m_camera;
139 TranslatedString m_ruler_name;
140 const void* m_lock_ptr;
141 };
142}
143#endif
#define DESIGN_WIDGETS_API
Definition DLLInfo.h:56
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:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149