Open 3D Engine LyShine Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
ViewportInteraction Class Reference

Inherits QObject.

Classes

struct  TranslationAndScale
 

Public Types

enum class  NudgeDirection { Up , Down , Left , Right }
 
enum class  NudgeSpeed { Slow , Fast }
 
enum class  InteractionMode {
  SELECTION , MOVE , ROTATE , RESIZE ,
  ANCHOR
}
 
enum class  CoordinateSystem { LOCAL , VIEW }
 Type of coordinate system in the viewport.
 
enum class  InteractionType {
  DIRECT , TRANSFORM_GIZMO , ANCHORS , PIVOT ,
  GUIDE , NONE
}
 

Public Member Functions

 ViewportInteraction (EditorWindow *editorWindow)
 
bool GetLeftButtonIsActive ()
 
bool GetSpaceBarIsActive ()
 
void ActivateSpaceBar ()
 
void Draw (Draw2dHelper &draw2d, const QTreeWidgetItemRawPtrQList &selectedItems)
 
void MousePressEvent (QMouseEvent *ev)
 
void MouseMoveEvent (QMouseEvent *ev, const QTreeWidgetItemRawPtrQList &selectedItems)
 
void MouseReleaseEvent (QMouseEvent *ev, const QTreeWidgetItemRawPtrQList &selectedItems)
 
bool MouseWheelEvent (QWheelEvent *ev)
 
bool KeyPressEvent (QKeyEvent *ev)
 
bool KeyReleaseEvent (QKeyEvent *ev)
 
void SetMode (InteractionMode mode)
 
InteractionMode GetMode () const
 
InteractionType GetInteractionType () const
 
AZ::Entity * GetActiveElement () const
 
const AZ::EntityId & GetActiveElementId () const
 
ViewportHelpers::SelectedAnchors GetGrabbedAnchors () const
 
void SetCoordinateSystem (CoordinateSystem s)
 
CoordinateSystem GetCoordinateSystem () const
 
void InitializeToolbars ()
 
float GetCanvasToViewportScale () const
 
AZ::Vector3 GetCanvasToViewportTranslation () const
 
const TranslationAndScaleGetCanvasViewportMatrixProps ()
 
void SetCanvasViewportMatrixProps (const TranslationAndScale &canvasViewportMatrixProps)
 
void CenterCanvasInViewport (const AZ::Vector2 *newCanvasSize=nullptr)
 Centers the entirety of the canvas so that it's viewable within the viewport.
 
void DecreaseCanvasToViewportScale ()
 "Zooms out" the view of the canvas in the viewport by an incremental amount
 
void IncreaseCanvasToViewportScale ()
 "Zooms in" the view of the canvas in the viewport by an incremental amount
 
void ResetCanvasToViewportScale ()
 Assigns a scale of 1.0 to the canvas-to-viewport matrix.
 
void SetCanvasZoomPercent (float scale)
 Sets the scale of the canvas-to-viewport matrix.
 
bool ShouldScaleToFitOnViewportResize () const
 Return whether the canvas should be scaled to fit when the viewport is resized.
 
void UpdateZoomFactorLabel ()
 
void ClearInteraction (bool clearSpaceBarIsActive=true)
 Reset all transform interaction variables except the interaction mode.
 
void Nudge (NudgeDirection direction, NudgeSpeed speed)
 Move the selected elements a certain number of pixels at a time.
 
void StartObjectPickMode ()
 Start/stop object pick mode for assigning an entityId property.
 
void StopObjectPickMode ()
 

Member Enumeration Documentation

◆ InteractionMode

Mode of interaction in the viewport This is driven by a toolbar.

◆ InteractionType

Type of interaction in the viewport This is driven by hovering and the left mouse button.

Enumerator
DIRECT 

The bounding box.

TRANSFORM_GIZMO 

The base axes or circular manipulator.

PIVOT 

The dot.

Member Function Documentation

◆ CenterCanvasInViewport()

void ViewportInteraction::CenterCanvasInViewport ( const AZ::Vector2 *  newCanvasSize = nullptr)

Centers the entirety of the canvas so that it's viewable within the viewport.

The scale of the canvas-to-viewport matrix is decreased (zoomed out) for canvases that are bigger than the viewport, and increased (zoomed in) for canvases that are smaller than the viewport. This scaled view of the canvas is then use to center the canvas within the viewport.

Parameters
newCanvasSizeBecause of a one-frame delay in canvas size, if the canvas size was recently changed, and the caller knows the new canvas size, the size can be passed to this function to be immediately applied.

The documentation for this class was generated from the following file: