wxFrameworkGLCanvas

A class that provides mouse handling, camera, and selection for an OpenGL window.

Derived From

wxBaseGLCanvas

Project

GLCore

Include

FrameworkGLCanvas.h

Summary
A class that provides mouse handling, camera, and selection for an OpenGL window.
The wxFrameworkGLCanvas constructor.
The wxFrameworkGLCanvas destructor.
Turns hit tests on or off based on the hit parameter.
Returns whether an object was actually selected or simply moused over.
Returns the id of the currently selected object.
Returns the position of the current view camera.
Returns the lookat position of the current view camera.
The wxWidgets event table declaration.
Stores the current camera settings in the ConfigDatabase.
Resets the camera position and lookat back to original values.
Determines the final location for the view camera based on rotation and panning.
Rotates the view by adjusting the <mXRot> and <mYRot> variables.
Pans the view by adjusting the camera lookat position
Zooms the view by adjusting the camera position.
Does object selection checking based on the given window coordinates.
Handles object selection.
Handles the mouse moving.
Handles the mouse wheel moving.
Handles the left mouse click.
Handles the middle mouse down.
Handles the middle mouse up.
Handles the right mouse down.
Handles the right mouse up.
Handles the right mouse float click.
Handles a keystroke.
Resets the eye point to the loaded map’s default.
Whether hit tests are on or off.
Whether an actual selection has occurred or just a mouseover.
The last captured position of the mouse.
The OpenGL id of the current selection.

Protected

Summary
The wxFrameworkGLCanvas constructor.
The wxFrameworkGLCanvas destructor.
Turns hit tests on or off based on the hit parameter.
Returns whether an object was actually selected or simply moused over.
Returns the id of the currently selected object.
Returns the position of the current view camera.
Returns the lookat position of the current view camera.
The wxWidgets event table declaration.

Constructors

wxFrameworkGLCanvas

wxFrameworkGLCanvas(wxWindow *parent, 
const wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxT("wxFrameworkGLCanvas"),
wxInt32 *attrib = NULL)

The wxFrameworkGLCanvas constructor.  Adds OnResetCamera as a receiver of the eventResetCamera Event.

Parameters

parentThe parent window (must not be NULL).
idThe id for message handling.
posThe starting position.
sizeThe starting size.
styleThe window style, using wxWindow parameters.
nameThe name.
attributeStarting OpenGL implementation attributes.

Destructors

wxFrameworkGLCanvas

~wxFrameworkGLCanvas()

The wxFrameworkGLCanvas destructor.  Removes OnResetCamera as a receiver of the eventResetCamera Event.

Functions

SetHitTest

void SetHitTest(const bool hit)

Turns hit tests on or off based on the hit parameter.  Always resets the selection to -1.

Parameters

hitTurn hit tests on or off.

GotFinalHit

bool GotFinalHit() const

Returns whether an object was actually selected or simply moused over.

Returns

A bool set to true only when an object was selected with a left mouse down as opposed to a mouseover selection that just highlights the object.

GetSelection

wxInt32 GetSelection() const

Returns the id of the currently selected object.

Returns

The id of the currently selected object.

GetCameraPos

const Vector &GetCameraPos() const

Returns the position of the current view camera.

Returns

A Vector containing the view camera’s position.

GetCameraLookAt

const Vector &GetCameraLookAt() const

Returns the lookat position of the current view camera.

Returns

A Vector containing the view camera’s lookat position.

DECLARE_EVENT_TABLE

The wxWidgets event table declaration.

Private

Summary
Stores the current camera settings in the ConfigDatabase.
Resets the camera position and lookat back to original values.
Determines the final location for the view camera based on rotation and panning.
Rotates the view by adjusting the <mXRot> and <mYRot> variables.
Pans the view by adjusting the camera lookat position
Zooms the view by adjusting the camera position.
Does object selection checking based on the given window coordinates.
Handles object selection.
Handles the mouse moving.
Handles the mouse wheel moving.
Handles the left mouse click.
Handles the middle mouse down.
Handles the middle mouse up.
Handles the right mouse down.
Handles the right mouse up.
Handles the right mouse float click.
Handles a keystroke.
Resets the eye point to the loaded map’s default.
Whether hit tests are on or off.
Whether an actual selection has occurred or just a mouseover.
The last captured position of the mouse.
The OpenGL id of the current selection.

Functions

SaveCamera

void SaveCamera()

Stores the current camera settings in the ConfigDatabase.

ResetCamera

void ResetCamera()

Resets the camera position and lookat back to original values.

UpdateViewCamera

void UpdateViewCamera()

Determines the final location for the view camera based on rotation and panning.

rotate

void rotate(const float x,
const float y)

Rotates the view by adjusting the <mXRot> and <mYRot> variables.

Parameters

xThe amount of mouse movement in the x axis.
yThe amount of mouse movement in the y axis.

pan

void pan(const float x,
const float y)

Pans the view by adjusting the camera lookat position

Parameters

xThe amount of mouse movement in the x axis.
yThe amount of mouse movement in the y axis.

zoom

void zoom(const float x,
const float y)

Zooms the view by adjusting the camera position.

Parameters

xThe amount of mouse movement in the x axis.
yThe amount of mouse movement in the y axis.

Pure Virtual Functions

Select

virtual wxInt32 Select(const wxInt32 x,
const wxInt32 y) const=0

Does object selection checking based on the given window coordinates.

Parameters

xThe x coordinate of the current mouse position.
yThe y coordinate of the current mouse position.

Returns

The OpenGL id of nearest object, or -1 if none.

SelectObject

virtual void SelectObject(wxInt32 selection)=0

Handles object selection.

Parameters

idThe OpenGL ID of the selected object.

Event Message Handling

OnMouseMove

void OnMouseMove(wxMouseEvent &event)

Handles the mouse moving.  May pan, zoom, or rotate the OpenGL view.

Parameters

eventThe mouse event.

OnMouseWheel

void OnMouseWheel(wxMouseEvent &event)

Handles the mouse wheel moving.  Zooms the OpenGL view.

Parameters

eventThe mouse event.

OnLButtonDown

void OnLButtonDown(wxMouseEvent &event)

Handles the left mouse click.  Performs a hit test to see if any objects is selected.

Parameters

eventThe mouse event.

OnMButtonDown

void OnMButtonDown(wxMouseEvent &event)

Handles the middle mouse down.  Captures the mouse for panning.

Parameters

eventThe mouse event.

OnMButtonUp

void OnMButtonUp(wxMouseEvent &event)

Handles the middle mouse up.  Releases the mouse.

Parameters

eventThe mouse event.

OnRButtonDown

void OnRButtonDown(wxMouseEvent &event)

Handles the right mouse down.  Captures the mouse for rotation or zooming.

Parameters

eventThe mouse event.

OnRButtonUp

void OnRButtonUp(wxMouseEvent &event)

Handles the right mouse up.  Releases the mouse.

Parameters

eventThe mouse event.

OnRButtonDblClk

void OnRButtonDblClk(wxMouseEvent &event)

Handles the right mouse float click.  Resets the camera to its original position and look at.

Parameters

eventThe mouse event.

OnRButtonUp

Handles a keystroke.  Checks for use of arrow keys in conjunction with Ctrl and Shift to pan, zoom, or rotate the OpenGL view.

Parameters

eventThe mouse event.

Game Event Functions

OnResetCamera

void OnResetCamera(bool val)

Resets the eye point to the loaded map’s default.

Parameters

valNeeded to satisfy Event’s one parameter requirement.  Unused.

Variables

mHitTest

bool mHitTest

Whether hit tests are on or off.

mFinalHit

bool mFinalHit

Whether an actual selection has occurred or just a mouseover.

mPoint

wxPoint mPoint

The last captured position of the mouse.  We can use it to get how much it has moved between then and now.

mSelection

wxInt32 mSelection

The OpenGL id of the current selection.

wxFrameworkGLCanvas(wxWindow *parent, 
const wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxString &name = wxT("wxFrameworkGLCanvas"),
wxInt32 *attrib = NULL)
The wxFrameworkGLCanvas constructor.
void SetHitTest(const bool hit)
Turns hit tests on or off based on the hit parameter.
bool GotFinalHit() const
Returns whether an object was actually selected or simply moused over.
wxInt32 GetSelection() const
Returns the id of the currently selected object.
const Vector &GetCameraPos() const
Returns the position of the current view camera.
const Vector &GetCameraLookAt() const
Returns the lookat position of the current view camera.
void SaveCamera()
Stores the current camera settings in the ConfigDatabase.
A Singleton class that handles configuration options for the application.
void ResetCamera()
Resets the camera position and lookat back to original values.
void UpdateViewCamera()
Determines the final location for the view camera based on rotation and panning.
void rotate(const float x,
const float y)
Rotates the view by adjusting the mXRot and mYRot variables.
void pan(const float x,
const float y)
Pans the view by adjusting the camera lookat position
void zoom(const float x,
const float y)
Zooms the view by adjusting the camera position.
virtual wxInt32 Select(const wxInt32 x,
const wxInt32 y) const=0
Does object selection checking based on the given window coordinates.
virtual void SelectObject(wxInt32 selection)=0
Handles object selection.
void OnMouseMove(wxMouseEvent &event)
Handles the mouse moving.
void OnMouseWheel(wxMouseEvent &event)
Handles the mouse wheel moving.
void OnLButtonDown(wxMouseEvent &event)
Handles the left mouse click.
void OnMButtonDown(wxMouseEvent &event)
Handles the middle mouse down.
void OnMButtonUp(wxMouseEvent &event)
Handles the middle mouse up.
void OnRButtonDown(wxMouseEvent &event)
Handles the right mouse down.
void OnRButtonUp(wxMouseEvent &event)
Handles the right mouse up.
void OnRButtonDblClk(wxMouseEvent &event)
Handles the right mouse float click.
void OnResetCamera(bool val)
Resets the eye point to the loaded map’s default.
bool mHitTest
Whether hit tests are on or off.
bool mFinalHit
Whether an actual selection has occurred or just a mouseover.
wxPoint mPoint
The last captured position of the mouse.
wxInt32 mSelection
The OpenGL id of the current selection.
A class that provides basic OpenGL window management.
GLCore provides the underlying window classes and tools needed to create and use an OpenGL window with a camera, lighting, selection, mouse/keyboard handling, and IDrawObject rendering.
A generic implementation of the Observer design pattern.
A lightweight 1x3 vector class.