NDEVR
API Documentation
QtGraphicsWindow.h
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: QTGraphicsWindow
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/WindowInstance.h>
35#include <NDEVR/QTModelManager.h>
36#include <NDEVR/WindowContainer.h>
37#include <QWidget>
38#include <QWindow>
39class QVulkanInstance;
40struct VkSurfaceKHR_T;
41#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
42#include <QVulkanWindow>
43 typedef QVulkanWindow GraphicsWindowBase;
44#else
45 typedef QWindow GraphicsWindowBase;
46#endif
47namespace NDEVR
48{
49 class Renderer;
50 class BasicThread;
58 class NDEVR_GRAPHICS_API QTGraphicsWindow : public QWindow, public WindowInstance
59 {
60 Q_OBJECT
61 friend class QTGraphicsWidget;
62 friend class RenderThread;
63 public:
64 //explicit QTGraphicsWindow(QWindow* parent, UUID camera, Log* log, QTModelManager* manager, Qt::WindowFlags flags);
69 explicit QTGraphicsWindow(const DynamicPointer<GraphicsDevice>& device, QWindow* parent, Qt::WindowFlags flags);
72
74 virtual void initialize();
80 void exposeEvent(QExposeEvent* e) override;
83 void setAnimating(bool animating);
86 virtual bool visible() const override;
89 virtual void setModelManager(QTModelManager* manager);
92 void resizeEvent(QResizeEvent *resize_event) override;
97 void updateSize();
100 virtual bool shouldExit() const override;
103 QImage getImage() const;
105 virtual void makeCurrent() {}
108 void pause(const TimeSpan& span);
112 public slots:
115 void contextMenu(const QPoint &pos);
120 void setSize(const Vector<2, uint04>& size) final override;
124 void onSelectionChanged(Buffer<UUID> selection, bool selected);
128 void onFocusChanged(UUID focus, bool focussed);
133 void setOverrideMaterial(UUID material);
136 signals:
142 void requestContextMenu(const QPoint &pos);
149 void mouseInScreenSignal(bool mouse_in_screen);
150 protected:
151 void graphicsUpdate();
152 bool event(QEvent *event) override;
153 Renderer* getRenderer();
154 void createMouseListener();
155 //void exposeEvent(QExposeEvent *event) override;
156 protected:
158#if NDEVR_SUPPORTS_THREADING
159 //Thread* m_render_thread;
160#endif
161 QTimer* m_touch_context_timer = nullptr;
163 QTimer* m_fps_timer = nullptr;
166 QBackingStore* m_backing_store = nullptr;
172 bool m_instance_valid = false;
173 bool m_touch_alternate = false;
176 Q_DISABLE_COPY(QTGraphicsWindow)
177 };
178 class GlobalGraphicsWidgetEventFilter;
183 class NDEVR_GRAPHICS_API QTGraphicsWidget : public WindowContainer
184 {
185 Q_OBJECT
186 public:
190 QTGraphicsWidget(QTGraphicsWindow* window, QWidget* parent = nullptr);
196 bool eventCallback(QEvent* event);
201 bool eventFilter(QObject* watched, QEvent* e) override;
203 void updateSize() override;
215 signals:
218 void mouseInScreenSignal(bool mouse_in_screen);
219 protected:
222 RGBColor m_background_color = Constant<RGBColor>::Invalid;
223#if !NDEVR_SPECIAL_GRAPHICS_WINDOW
224 GlobalGraphicsWidgetEventFilter* m_filter;
225#endif
226 };
227
228}
229
Simple version of ResourceListener which allows for a simple function callback that will be executed ...
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Options that are used for performing an update on a Graphics Engine call.
RGBColor m_background_color
Cached background color.
QTGraphicsWidget(QTGraphicsWindow *window, QWidget *parent=nullptr)
Constructs the widget wrapper around a graphics window.
QTGraphicsWindow * m_window
The contained graphics window.
void setModelManager(QTModelManager *manager)
Sets the model manager for the contained window.
bool eventCallback(QEvent *event)
Handles events forwarded from the widget.
void updateBackgroundColor()
Updates the widget background from the camera settings.
void mouseInScreenSignal(bool mouse_in_screen)
Emitted when the mouse enters or leaves the widget.
virtual ~QTGraphicsWidget()
Destructor.
QTimer * m_check_visibility_timer
Timer for checking visibility changes.
bool eventFilter(QObject *watched, QEvent *e) override
Event filter for forwarding events to the graphics window.
QTGraphicsWindow * graphicsWindow()
Returns the contained graphics window.
void setCamera(const DynamicPointer< Camera > &camera)
Sets the camera for the contained graphics window.
void updateSize() override
Updates the widget and window size.
A Window used to render 3D graphics.
QBackingStore * m_backing_store
Fallback backing store for the window.
void onFocusChanged(UUID focus, bool focussed)
Handles a focus change.
QImage getImage() const
Returns the last rendered frame as a QImage.
bool m_initiation_failure
Whether initialization failed.
QRect m_last_render_size
The size used for the last render.
void requestContextMenu(const QPoint &pos)
Emitted to request a context menu display.
void mouseInScreenSignal(bool mouse_in_screen)
Emitted when the mouse enters or leaves the window.
void contextMenu(const QPoint &pos)
Shows a context menu at the given position.
void updateFallbackStore()
Updates the fallback backing store for the window.
void onSelectionChanged(Buffer< UUID > selection, bool selected)
Handles a selection change.
QPointF m_touch_begin_point
Starting point of a touch gesture.
void setOverrideMaterial(UUID material)
Sets a material override for the renderer.
void onClearAll()
Handles a clear-all event from the scene.
virtual void initialize()
Initializes the graphics context and renderer.
bool m_is_size_valid
Whether the current window size is valid.
virtual void setModelManager(QTModelManager *manager)
Sets the model manager for this window.
~QTGraphicsWindow()
Destructor.
QTModelManager * m_manager
The model manager.
void setAnimating(bool animating)
Sets whether the window continuously animates.
virtual bool visible() const override
Checks whether the window is visible.
const DynamicPointer< GraphicsDevice > & device() const
Returns the graphics device.
QTimer * m_touch_context_timer
Timer for long-press touch context menu.
bool m_animating
Whether continuous animation is active.
virtual bool shouldExit() const override
Checks whether the window should exit.
void resizeEvent(QResizeEvent *resize_event) override
Handles window resize events.
bool m_instance_valid
Whether the graphics instance is valid.
bool m_touch_alternate
Alternate touch mode flag.
QTimer * m_fps_timer
Timer driving FPS-limited rendering.
QTGraphicsWindow(const DynamicPointer< GraphicsDevice > &device, QWindow *parent, Qt::WindowFlags flags)
Constructs the graphics window.
void renderShowing()
Emitted when the render window is first shown.
void setCamera(const DynamicPointer< Camera > &camera) override
Sets the camera for rendering.
QTResourceListener * m_mouse_manager_listener
Listener for mouse manager changes.
void finishFrame(GraphicsUpdateArguments &args) override
Called after a frame is finished for post-processing.
bool m_is_init
Whether the window has been initialized.
void pause(const TimeSpan &span)
Pauses rendering for a duration.
bool m_has_valid_khr
Whether a valid Vulkan surface (KHR) exists.
DynamicPointer< GraphicsDevice > m_device
The graphics device.
void exposeEvent(QExposeEvent *e) override
Handles expose events to trigger rendering.
Renderer * m_render
The renderer for this window.
void onSelectedSignal(Buffer< UUID > selected)
Emitted when objects are selected.
void renderSlot()
Slot that triggers a render pass.
void setSize(const Vector< 2, uint04 > &size) final override
Sets the viewport size.
void updateSize()
Updates the internal size from the window geometry.
virtual void makeCurrent()
Makes this window's graphics context current (no-op by default).
void hideContextMenuSignal()
Emitted to hide the context menu.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
Definition QTTools.h:493
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
An object that renders a specific Camera object, typically run on a different thread than the main UI...
Definition Renderer.h:53
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
bool event(QEvent *event) override
Handles show/hide events and forwards all events to the optional event forwarder.
WindowContainer(QWidget *parent=nullptr)
Constructs a WindowContainer with an optional parent.
virtual ConstPointer< Camera > camera() const
Returns a const pointer to the current camera.
WindowInstance()
Default constructor.
The primary namespace for the NDEVR SDK.