Editor API
UnigineEditor public API
Editor::ViewportManager Class Referencefinal

Viewport manager class. This class is used to create, manage, and remove all viewports in the Editor. More...

#include <ViewportManager.h>

Static Public Member Functions

static ViewportWindowId createViewportWindow (const char *name=nullptr)
 Creates a new viewport window with the specified name. More...
 
static bool removeViewportWindow (ViewportWindowId viewport_id)
 Removes the viewport window with the specified ID. More...
 
static bool showViewportWindow (ViewportWindowId viewport_id)
 Shows the viewport window with the specified ID. More...
 
static bool hideViewportWindow (ViewportWindowId viewport_id)
 Hides the viewport window with the specified ID. More...
 
static int getNumViewportWindows ()
 Returns the total number of existing viewport windows. More...
 
static ViewportWindowId getViewportWindowId (int index)
 Returns the ID of the viewport window by its index if it exists; otherwise, nullptr. More...
 
static ViewportWindowId getLastHoveredViewportWindow ()
 Returns the ID of the last viewport window hovered by the mouse cursor. Can be used for implementation of Drag&Drop operations More...
 
static ViewportWindowId getActiveViewportWindow ()
 Returns the ID of a viewport window that is currently active. More...
 
static const char * getViewportWindowName (ViewportWindowId viewport_id)
 Returns the name of the viewport window with the specified ID if it exists; otherwise, nullptr. More...
 
static ViewportWindowId getViewportWindowId (const char *name)
 Returns the ID of the viewport window with the specified name if it exists; otherwise nullptr. More...
 
static Unigine::PlayerPtr getViewportWindowPlayer (ViewportWindowId viewport_id)
 Returns the main player (camera) whose current view is rendered to the viewport window with the specified ID if it exists; otherwise, nullptr. More...
 
static void setViewportWindowPlayer (ViewportWindowId viewport_id, const Unigine::PlayerPtr &player)
 Sets a new main player (camera) whose current view is to be rendered to the viewport window with the specified ID. More...
 
static Unigine::ViewportPtr getViewportWindowViewport (ViewportWindowId viewport_id)
 Returns the Engine Viewport instance for the viewport window with the specified ID. More...
 
static Unigine::GuiPtr getViewportWindowGui (ViewportWindowId viewport_id)
 Returns the Gui instance for the viewport window with the specified ID. You can use it to add and manage your UI elements. More...
 
static int getViewportWindowMouseX (ViewportWindowId viewport_id)
 Returns the X coordinate of the mouse position relative to the viewport window with the specified ID. While the mouse cursor is within the window the coordinate is in the [0, getViewportWindowWidth() - 1] range, otherwise the value can be negative or greater than window width (depending on the mouse cursor position relative to the window). More...
 
static int getViewportWindowMouseY (ViewportWindowId viewport_id)
 Returns the Y coordinate of the mouse position relative to the viewport window with the specified ID. While the mouse cursor is within the window the coordinate is in the [0, getViewportWindowHeight() - 1] range, otherwise the value can be negative or greater than window height (depending on the mouse cursor position relative to the window). More...
 
static Unigine::Math::ivec2 getViewportWindowMousePos (ViewportWindowId viewport_id)
 Returns the coordinates of the mouse position relative to the viewport window with the specified ID. Coordinates are returned as a two-component vector (X, Y). While the mouse cursor is within the window the coordinates are within the following ranges: X - [0, getViewportWindowWidth() - 1]; Y - [0, getViewportWindowHeight() - 1]. Otherwise the values can be negative or greater than window height and width (depending on the mouse cursor position relative to the window). More...
 
static int getViewportWindowWidth (ViewportWindowId viewport_id)
 Returns the current width (in pixels) of the viewport window with the specified ID. More...
 
static int getViewportWindowHeight (ViewportWindowId viewport_id)
 Returns the current height (in pixels) of the viewport window with the specified ID. More...
 
static Unigine::Math::ivec2 getViewportWindowSize (ViewportWindowId viewport_id)
 Returns the current size of the viewport window with the specified ID. The value is returned as a two-component vector (Width, Height). More...
 
static void setEnabledRectangleSelection (bool enable)
 Sets a value indicating if rectangular selection for viewport windows is enabled. More...
 
static bool isEnabledRectangleSelection ()
 Returns a value indicating if rectangular selection for viewport windows is enabled. More...
 
static void focusOnNode (ViewportWindowId viewport_id, const Unigine::NodePtr &node)
 Sets the camera focus for the viewport window with the specified ID on the specified node. More...
 
static void focusOnNodeList (ViewportWindowId viewport_id, const Unigine::Vector< Unigine::NodePtr > &nodes)
 Sets the camera focus for the viewport window with the specified ID on the specified nodes (the viewport will be adjusted to display all the specified nodes). More...
 
static void focusOnSurface (ViewportWindowId viewport_id, const Unigine::ObjectPtr &object, int surface)
 Sets the camera focus for the viewport window with the specified ID on the specified surface of the specified object (the viewport will be adjusted to display the specified surface). More...
 
static void focusOnSurfaceList (ViewportWindowId viewport_id, const Unigine::ObjectPtr &object, const Unigine::Vector< int > &surfaces)
 Sets the camera focus for the viewport window with the specified ID on the specified surfaces of the specified object (the viewport will be adjusted to display all the specified surfaces). More...
 
static void focusOnCenter (ViewportWindowId viewport_id, const Unigine::Math::Vec3 &center, float radius)
 Sets the camera focus for the viewport window with the specified ID on an imaginary sphere with the specified center point and radius. More...
 
static void forceWireframeWarming ()
 Renders an effect of wireframe warming, a temporary wireframe fading in and out for the current selection (such effect can be seen when selecting a node or a group of nodes in the Editor). More...
 
static void placeNode (const Unigine::NodePtr &node)
 Activates placement mode for the specified node. The node is to be placed at the location within the viewport where the left mouse button is clicked. If the Esc key is pressed before clicking within the viewport the current node placement operation will be cancelled. This behavior can be observed in the Editor, when the user creates a node via the Create menu. This function will automatically create all necessary Undo Actions (for adding nodes to the world and for selecting them). More...
 
static void placeNodeList (const Unigine::Vector< Unigine::NodePtr > &nodes)
 Activates placement mode for the specified nodes. The nodes are to be placed at the location within the viewport where the left mouse button is clicked. If the Esc key is pressed before clicking within the viewport the current node placement operation will be cancelled. This behavior can be observed in the Editor, when the user creates a node via the Create menu. This function will automatically create all necessary Undo Actions (for adding nodes to the world and for selecting them). More...
 

Detailed Description

Viewport manager class. This class is used to create, manage, and remove all viewports in the Editor.

Member Function Documentation

◆ createViewportWindow()

static ViewportWindowId Editor::ViewportManager::createViewportWindow ( const char *  name = nullptr)
static

Creates a new viewport window with the specified name.

Parameters
nameTitle of the viewport window.
Returns
ID of the new created viewport.

◆ focusOnCenter()

static void Editor::ViewportManager::focusOnCenter ( ViewportWindowId  viewport_id,
const Unigine::Math::Vec3 &  center,
float  radius 
)
static

Sets the camera focus for the viewport window with the specified ID on an imaginary sphere with the specified center point and radius.

Parameters
viewport_idID of the viewport window.
centerCoordinates of the center of an imaginary sphere to be focused on.
radiusRadius of an imaginary sphere to be focused on.

◆ focusOnNode()

static void Editor::ViewportManager::focusOnNode ( ViewportWindowId  viewport_id,
const Unigine::NodePtr &  node 
)
static

Sets the camera focus for the viewport window with the specified ID on the specified node.

Parameters
viewport_idID of the viewport window.
nodeNode to be focused on.

◆ focusOnNodeList()

static void Editor::ViewportManager::focusOnNodeList ( ViewportWindowId  viewport_id,
const Unigine::Vector< Unigine::NodePtr > &  nodes 
)
static

Sets the camera focus for the viewport window with the specified ID on the specified nodes (the viewport will be adjusted to display all the specified nodes).

Parameters
viewport_idID of the viewport window.
nodesVector containing nodes to be focused on.

◆ focusOnSurface()

static void Editor::ViewportManager::focusOnSurface ( ViewportWindowId  viewport_id,
const Unigine::ObjectPtr &  object,
int  surface 
)
static

Sets the camera focus for the viewport window with the specified ID on the specified surface of the specified object (the viewport will be adjusted to display the specified surface).

Parameters
viewport_idID of the viewport window.
objectObject to be focused on.
surfaceThe number of the surface of the specified object to be focused on.

◆ focusOnSurfaceList()

static void Editor::ViewportManager::focusOnSurfaceList ( ViewportWindowId  viewport_id,
const Unigine::ObjectPtr &  object,
const Unigine::Vector< int > &  surfaces 
)
static

Sets the camera focus for the viewport window with the specified ID on the specified surfaces of the specified object (the viewport will be adjusted to display all the specified surfaces).

Parameters
viewport_idID of the viewport window.
objectObject to be focused on.
surfacesVector containing the numbers of surfaces of the specified object to be focused on.

◆ forceWireframeWarming()

static void Editor::ViewportManager::forceWireframeWarming ( )
static

Renders an effect of wireframe warming, a temporary wireframe fading in and out for the current selection (such effect can be seen when selecting a node or a group of nodes in the Editor).

◆ getActiveViewportWindow()

static ViewportWindowId Editor::ViewportManager::getActiveViewportWindow ( )
static

Returns the ID of a viewport window that is currently active.

◆ getLastHoveredViewportWindow()

static ViewportWindowId Editor::ViewportManager::getLastHoveredViewportWindow ( )
static

Returns the ID of the last viewport window hovered by the mouse cursor. Can be used for implementation of Drag&Drop operations

◆ getNumViewportWindows()

static int Editor::ViewportManager::getNumViewportWindows ( )
static

Returns the total number of existing viewport windows.

◆ getViewportWindowGui()

static Unigine::GuiPtr Editor::ViewportManager::getViewportWindowGui ( ViewportWindowId  viewport_id)
static

Returns the Gui instance for the viewport window with the specified ID. You can use it to add and manage your UI elements.

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowHeight()

static int Editor::ViewportManager::getViewportWindowHeight ( ViewportWindowId  viewport_id)
static

Returns the current height (in pixels) of the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowId() [1/2]

static ViewportWindowId Editor::ViewportManager::getViewportWindowId ( int  index)
static

Returns the ID of the viewport window by its index if it exists; otherwise, nullptr.

Parameters
indexIndex of the viewport window in the list, from 0 to the total number of viewport windows (see the getNumViewportWindows() method).

◆ getViewportWindowId() [2/2]

static ViewportWindowId Editor::ViewportManager::getViewportWindowId ( const char *  name)
static

Returns the ID of the viewport window with the specified name if it exists; otherwise nullptr.

Parameters
nameName of the viewport window.

◆ getViewportWindowMousePos()

static Unigine::Math::ivec2 Editor::ViewportManager::getViewportWindowMousePos ( ViewportWindowId  viewport_id)
static

Returns the coordinates of the mouse position relative to the viewport window with the specified ID. Coordinates are returned as a two-component vector (X, Y). While the mouse cursor is within the window the coordinates are within the following ranges: X - [0, getViewportWindowWidth() - 1]; Y - [0, getViewportWindowHeight() - 1]. Otherwise the values can be negative or greater than window height and width (depending on the mouse cursor position relative to the window).

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowMouseX()

static int Editor::ViewportManager::getViewportWindowMouseX ( ViewportWindowId  viewport_id)
static

Returns the X coordinate of the mouse position relative to the viewport window with the specified ID. While the mouse cursor is within the window the coordinate is in the [0, getViewportWindowWidth() - 1] range, otherwise the value can be negative or greater than window width (depending on the mouse cursor position relative to the window).

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowMouseY()

static int Editor::ViewportManager::getViewportWindowMouseY ( ViewportWindowId  viewport_id)
static

Returns the Y coordinate of the mouse position relative to the viewport window with the specified ID. While the mouse cursor is within the window the coordinate is in the [0, getViewportWindowHeight() - 1] range, otherwise the value can be negative or greater than window height (depending on the mouse cursor position relative to the window).

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowName()

static const char* Editor::ViewportManager::getViewportWindowName ( ViewportWindowId  viewport_id)
static

Returns the name of the viewport window with the specified ID if it exists; otherwise, nullptr.

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowPlayer()

static Unigine::PlayerPtr Editor::ViewportManager::getViewportWindowPlayer ( ViewportWindowId  viewport_id)
static

Returns the main player (camera) whose current view is rendered to the viewport window with the specified ID if it exists; otherwise, nullptr.

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowSize()

static Unigine::Math::ivec2 Editor::ViewportManager::getViewportWindowSize ( ViewportWindowId  viewport_id)
static

Returns the current size of the viewport window with the specified ID. The value is returned as a two-component vector (Width, Height).

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowViewport()

static Unigine::ViewportPtr Editor::ViewportManager::getViewportWindowViewport ( ViewportWindowId  viewport_id)
static

Returns the Engine Viewport instance for the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window.

◆ getViewportWindowWidth()

static int Editor::ViewportManager::getViewportWindowWidth ( ViewportWindowId  viewport_id)
static

Returns the current width (in pixels) of the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window.

◆ hideViewportWindow()

static bool Editor::ViewportManager::hideViewportWindow ( ViewportWindowId  viewport_id)
static

Hides the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window to be hidden.
Returns
true if the viewport window with the specified ID was successfully hidden; otherwise, false.

◆ isEnabledRectangleSelection()

static bool Editor::ViewportManager::isEnabledRectangleSelection ( )
static

Returns a value indicating if rectangular selection for viewport windows is enabled.

Returns
true if rectangular selection for viewport windows is enabled; otherwise, false.

◆ placeNode()

static void Editor::ViewportManager::placeNode ( const Unigine::NodePtr &  node)
static

Activates placement mode for the specified node. The node is to be placed at the location within the viewport where the left mouse button is clicked. If the Esc key is pressed before clicking within the viewport the current node placement operation will be cancelled. This behavior can be observed in the Editor, when the user creates a node via the Create menu. This function will automatically create all necessary Undo Actions (for adding nodes to the world and for selecting them).

Parameters
nodeThe node to be placed at the point within the viewport clicked by the user.

◆ placeNodeList()

static void Editor::ViewportManager::placeNodeList ( const Unigine::Vector< Unigine::NodePtr > &  nodes)
static

Activates placement mode for the specified nodes. The nodes are to be placed at the location within the viewport where the left mouse button is clicked. If the Esc key is pressed before clicking within the viewport the current node placement operation will be cancelled. This behavior can be observed in the Editor, when the user creates a node via the Create menu. This function will automatically create all necessary Undo Actions (for adding nodes to the world and for selecting them).

Parameters
nodesVector containing nodes to be placed at the point within the viewport clicked by the user.

◆ removeViewportWindow()

static bool Editor::ViewportManager::removeViewportWindow ( ViewportWindowId  viewport_id)
static

Removes the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window to be removed.
Returns
true if the viewport window with the specified ID was successfully removed; otherwise, false.

◆ setEnabledRectangleSelection()

static void Editor::ViewportManager::setEnabledRectangleSelection ( bool  enable)
static

Sets a value indicating if rectangular selection for viewport windows is enabled.

Parameters
enabletrue to enable rectangular selection for viewport windows; false - to disable it.

◆ setViewportWindowPlayer()

static void Editor::ViewportManager::setViewportWindowPlayer ( ViewportWindowId  viewport_id,
const Unigine::PlayerPtr &  player 
)
static

Sets a new main player (camera) whose current view is to be rendered to the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window.
playerPlayer to be used as the main camera for the viewport window with the specified ID.

◆ showViewportWindow()

static bool Editor::ViewportManager::showViewportWindow ( ViewportWindowId  viewport_id)
static

Shows the viewport window with the specified ID.

Parameters
viewport_idID of the viewport window to be shown.
Returns
true if the viewport window with the specified ID was successfully shown; otherwise, false.