VR-Engage  2.2
Loading...
Searching...
No Matches
createNewEntityEventProcessor.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file createNewEntityEventProcessor.h
7//! \brief Defines the event processor for entity creation interactions
8//!
9//! This file contains the DtCreateNewEntityEventProcessor class which handles
10//! user interactions during entity creation and placement, including mouse
11//! and keyboard events for positioning and configuring new entities.
12
13#pragma once
14
16
17#include <vrvCore/DtChannel.h>
18
19#include <vrvCore/DtBasicEditingEventProcessor.h>
20
21#include <boost/signals2/signal.hpp>
22
23namespace makVre
24{
25//! \brief Forward declaration of the player station application class
27
28//! \brief Event processor for entity creation and placement
29//!
30//! DtCreateNewEntityEventProcessor handles user interactions during entity
31//! creation and placement operations. It processes mouse and keyboard events
32//! to allow users to position, rotate, and configure new entities being added
33//! to the simulation. This processor is typically active during the entity
34//! creation workflow in the choose role state.
35class PLAYERSTATION_DLL DtCreateNewEntityEventProcessor : public makVrv::DtBasicEditingEventProcessor
36{
37public:
38 //! \brief Constructor
39 //! \param de Reference to the display engine
40 //! \param app Reference to the player station application
41 //!
42 //! Creates a new entity creation event processor associated with the
43 //! specified display engine and player station application.
45
46 //! \brief Virtual destructor
47 //!
48 //! Ensures proper cleanup of processor resources.
50
51 //! \brief Gets the class name of this processor
52 //! \return Reference to the class name string
53 //!
54 //! Returns the name of this event processor class.
55 //! Used for identification and debugging purposes.
56 virtual const std::string& className() override;
57
58 //! \brief Enables or disables the event processor
59 //! \param enabled True to enable processing, false to disable
60 //!
61 //! Controls whether this processor is active and handling events.
62 //! When disabled, it will ignore events and pass them to the next handler
63 //! in the processing chain. This allows the processor to be temporarily
64 //! deactivated without removing it from the processing chain.
65 virtual void setEnabled(bool enabled) override;
66
67 //! \brief Signal emitted when creation is canceled
68 //! \param escPressed Boolean indicating if cancellation was via Escape key
69 //!
70 //! This signal is emitted when entity creation is canceled, either by
71 //! user action (right-click or Escape key) or programmatically.
72 //! The boolean parameter indicates whether the cancellation was triggered
73 //! by the Escape key (true) or by another method (false).
74 boost::signalslib::signal<void(bool)> signal_cancel;
75
76 //! Derived to use this class's myElementsToIgnore list.
77 virtual bool pick(makVrv::DtChannel& channel,
78 double x,
79 double y,
80 makVrv::DtIntersectorResult& result,
81 makVrv::DtIntersector::IntersectProperties props) const override;
82
83 virtual void setElementsToIgnore(const std::vector<makVrv::DtElementID>& ids);
84
85protected:
86 //! \brief Processes mouse events during entity creation
87 //! \param ev Mouse event to process
88 //! \param channel Display channel receiving the event
89 //! \return True if the event was handled, false to allow further processing
90 //!
91 //! Handles mouse events like movement, clicks, and drags during entity creation.
92 //! These events are used to position and orient the entity being placed.
93 virtual bool processMouseEvent(const makVrv::DtMouseEvent& ev, makVrv::DtChannel& channel) override;
94
95 //! \brief Processes keyboard events during entity creation
96 //! \param ev Keyboard event to process
97 //! \param channel Display channel receiving the event
98 //! \return True if the event was handled, false to allow further processing
99 //!
100 //! Handles keyboard events during entity creation, such as escape to cancel
101 //! or other keys that might modify the creation process.
102 virtual bool processKeyboardEvent(const makVrv::DtKeyEvent& ev, makVrv::DtChannel& channel) override;
103
104 //! \brief Cancels the entity creation process
105 //! \param escPressed True if cancellation was via Escape key
106 //!
107 //! Cancels the current entity creation operation, emitting the signal_cancel
108 //! signal with the escPressed parameter. This is typically called when the
109 //! user presses Escape or performs another cancellation action.
110 virtual void cancel(bool escPressed);
111
112 //! \brief Cancels the entity creation process
113 //!
114 //! Convenience method that calls cancel(false), indicating that
115 //! cancellation was not via the Escape key.
116 virtual void cancel() override;
117
118 //! \brief Manager for signal connections
119 //!
120 //! Manages connections to various signals that need to be tracked
121 //! for proper disconnection when the processor is destroyed.
122 makVrv::DtSignalConnectionManager myConnections;
123
124 //! \brief Last recorded X position of the mouse
125 //!
126 //! Used to track mouse movement for entity positioning and rotation.
128
129 //! \brief Last recorded Y position of the mouse
130 //!
131 //! Used to track mouse movement for entity positioning and rotation.
133
134 //! \brief Distance the mouse has traveled during a drag operation
135 //!
136 //! Used to detect small movements versus significant drags.
138
139 //! \brief Set of objects that were selected before entity creation began
140 //!
141 //! Stored to restore selection state if entity creation is canceled.
142 makVrv::DtSelectionManager::IdSet mySavedSelection;
143
144 //! \brief Reference to the player station application
145 //!
146 //! Provides access to application services and state during entity creation.
148
149 std::vector<makVrv::DtElementID> myElementsToIgnore;
150};
151} // namespace makVre
virtual void setEnabled(bool enabled) override
Enables or disables the event processor.
makVrv::DtSelectionManager::IdSet mySavedSelection
Set of objects that were selected before entity creation began.
Definition createNewEntityEventProcessor.h:142
virtual bool processMouseEvent(const makVrv::DtMouseEvent &ev, makVrv::DtChannel &channel) override
Processes mouse events during entity creation.
virtual void cancel(bool escPressed)
Cancels the entity creation process.
DtCreateNewEntityEventProcessor(makVrv::DtDe &de, DtPlayerStationApp &app)
Constructor.
virtual ~DtCreateNewEntityEventProcessor() override
Virtual destructor.
int myMouseDownTravel
Distance the mouse has traveled during a drag operation.
Definition createNewEntityEventProcessor.h:137
virtual bool processKeyboardEvent(const makVrv::DtKeyEvent &ev, makVrv::DtChannel &channel) override
Processes keyboard events during entity creation.
virtual const std::string & className() override
Gets the class name of this processor.
virtual void cancel() override
Cancels the entity creation process.
std::vector< makVrv::DtElementID > myElementsToIgnore
Definition createNewEntityEventProcessor.h:149
DtPlayerStationApp & myApp
Reference to the player station application.
Definition createNewEntityEventProcessor.h:147
virtual bool pick(makVrv::DtChannel &channel, double x, double y, makVrv::DtIntersectorResult &result, makVrv::DtIntersector::IntersectProperties props) const override
Derived to use this class's myElementsToIgnore list.
int myMouseLastX
Last recorded X position of the mouse.
Definition createNewEntityEventProcessor.h:127
makVrv::DtSignalConnectionManager myConnections
Manager for signal connections.
Definition createNewEntityEventProcessor.h:122
boost::signalslib::signal< void(bool)> signal_cancel
Signal emitted when creation is canceled.
Definition createNewEntityEventProcessor.h:74
virtual void setElementsToIgnore(const std::vector< makVrv::DtElementID > &ids)
int myMouseLastY
Last recorded Y position of the mouse.
Definition createNewEntityEventProcessor.h:132
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.