API Documentation
Loading...
Searching...
No Matches
WindowInstance.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: Graphics
28File: WindowInstance
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_VIEWPORT
35#include <NDEVR/KeyController.h>
36#include <NDEVR/Pointer.h>
37#include <functional>
38namespace NDEVR
39{
40 class GraphicsUpdateArguments;
41 class MouseEvent;
42 class KeyEvent;
43 class Camera;
44 class MouseController;
45 class DesignObjectLookup;
46 class NDEVR_DESIGN_API WindowInstance
47 {
48 public:
49 WindowInstance();
50 WindowInstance(UUID camera, DesignObjectLookup* lookup);
51
52 MouseController& getMouseController();
53 KeyController& getKeyController();
54 void setLookup(DesignObjectLookup* lookup) { m_lookup = lookup; }
55 virtual Vector<2, uint04> pixelSize() const { return (m_device_pixel_ratio * m_size.as<2, fltp08>()).as<2, uint04>(); };
56 virtual Vector<2, uint04> logicalSize() const { return m_size; };
57 virtual fltp08 referenceSize() { return m_reference_size; }
58 virtual fltp08 referencePixelSize() { return m_device_pixel_ratio * m_reference_size;}
59 virtual void setSize(const Vector<2, uint04>& size);
60 virtual void setReferenceSize(fltp08 size);
61 void addResizeEvent(const std::function<void(Vector<2, uint04>)>& resize_event) { m_resize_events.add(resize_event); };
62 void addMouseEvent(const std::function<void(MouseEvent)>& mouse_event) { m_mouse_events.add(mouse_event); }
63 void addKeyboardEvent(const std::function<void(KeyEvent)>& key_event) { m_key_events.add(key_event); };
64 virtual bool visible() const { return true; }
65 virtual bool shouldExit() const { return false; }
66 virtual void* getSurface() = 0;
67 virtual void updateInstance() {};
68 Time getSurfaceUpdateTime() const { return m_surface_update_time; }
69 virtual uint04 getGrabImageSize() { return 0; }
70 virtual void finishFrame(GraphicsUpdateArguments&) {};
71 virtual void setCamera(const UUID& camera);
72 virtual ConstPointer<Camera> getCamera() const;
73 virtual DynamicPointer<Camera> getCamera();
74 const void* lockptr() const { return this; }
75 void createEvent(const MouseEvent& event);
76 void createEvent(const KeyEvent& event);
77 void createResizeEvent(const Vector<2, uint04>& event);
78 void setDevicePixelRatio(const fltp08 ratio) { m_device_pixel_ratio = ratio; };
79 fltp08 devicePixelRatio() const { return m_device_pixel_ratio; }
80 const UUID& cameraID() const { return m_camera; }
81 protected:
82 Buffer<std::function<void(Vector<2, uint04>)>> m_resize_events;
83 Buffer<std::function<void(MouseEvent)>> m_mouse_events;
84 Buffer<std::function<void(KeyEvent)>> m_key_events;
85 fltp08 m_device_pixel_ratio;
86
87 Vector<2, uint04> m_size;
88 fltp08 m_reference_size;
89 Time m_surface_update_time;
90 UUID m_camera;
91 DesignObjectLookup* m_lookup;
92 };
93}
94#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
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:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181