Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
BIAS::OpenGLCanvas Class Reference

OpenGL canvases with additinal event handling (JW) More...

#include <Gui/OpenGLCanvas.hh>

+ Inheritance diagram for BIAS::OpenGLCanvas:
+ Collaboration diagram for BIAS::OpenGLCanvas:

Public Member Functions

virtual void Display ()
 display call to be overridden by child classes More...
 
virtual void DisplayCalls ()
 
virtual void DisplayCameraView ()
 
virtual void DisplayCameraViewExternalParams ()
 
virtual void DisplayCameraViewInternalParams ()
 
virtual void DisplayClear (const GLbitfield &mask=CLEAR_DEFAULT_MASK)
 clears buffers and resets virtual camera to identity More...
 
void DisplayCoordCross (const float &size=1.0f, const float &linewidth=1.0f)
 
virtual void DisplayRenderMode ()
 display default shade model, polygon mode, More...
 
void DisplaySelectBuffer ()
 useful for quadbuffered stereo, e.g. shutetr glasses More...
 
float GetAspectRatio () const
 GetAspectRatio is X/Y. More...
 
unsigned long GetFrameCount () const
 
unsigned int GetHeight () const
 
virtual void GetInfoGL (std::ostream &os=std::cout)
 return GL state info More...
 
wxFrame * GetOwnerframe ()
 
float GetPixelValueDepth (const wxPoint &pos2d) const
 
BIAS::Vector3< float > GetPixelValueRGB (const wxPoint &pos2d)
 
BIAS::Vector4< float > GetPixelValueRGBA (const wxPoint &pos2d)
 
CameraViewController GetViewController () const
 
CameraViewControllerGetViewController ()
 
unsigned int GetWidth () const
 
virtual void InitMembers ()
 any constructor should call this function to initialize all data members (e.g. More...
 
virtual void InitWithContext ()
 init all things that need a context. More...
 
bool IsContextAvailable ()
 activates the current rendereing context if there is one and More...
 
virtual void OnChar (wxKeyEvent &event)
 
void OnEraseBackground (wxEraseEvent &event)
 
void OnIdle (wxIdleEvent &event)
 
void OnMotion (wxMouseEvent &event)
 
void OnMouseDown (wxMouseEvent &event)
 
void OnMouseWheel (wxMouseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 EVT handlers: ---------------------------------------—. More...
 
void OnSize (wxSizeEvent &event)
 
 OpenGLCanvas (wxFrame *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=AsciiToWx("OpenGLCanvas"), int *attribList=NULL, const wxPalette &palette=wxNullPalette)
 constructors: More...
 
 OpenGLCanvas (wxFrame *parent, wxGLContext *sharedContext=NULL, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=AsciiToWx("OpenGLCanvas"), int *attribList=0, const wxPalette &palette=wxNullPalette)
 constructor using a shared context More...
 
virtual std::ostream & PrintHelp (std::ostream &os)
 pop up keyboard layout help. More...
 
virtual void Reshape ()
 change of size and aspect ratio. More...
 
void ScreenShot (BIAS::ImageBase &dest, const bool &flipY=true, const GLenum &format=GL_RGB, const bool &force8Bit=false)
 
void ScreenShot (const std::string &filename, const bool &flipY=true, const GLenum &format=GL_RGB, const bool &force8Bit=false)
 
void ScreenShot ()
 JW automatic screenshot to file with filename based on frame, instance etc. More...
 
void SetFrameCount (const unsigned long &newVal)
 
void SetOwnerframe (wxFrame *ptr)
 
void SetStatusText (const wxString &text, const int c_field=0)
 let an OpenGL canvas use the status bar of the containing frame and cout as fallback (JW) More...
 
void ShowFPS (const int &framecounter, const float &minUpdateIntervalSec, const unsigned int &minNewFrames, const unsigned int nField)
 
shows FPS to status bar base don frame counter and last call to this function

Measures and updates only, if two conditions ar eboth met: More...

 
void ShowFPS ()
 simple interface for the above More...
 
void ShowValue (const wxPoint &pos)
 
void SwapBuffers ()
 expands parents SwapBUffers by automatic framecount increase More...
 
void ToggleFullScreen ()
 
BIAS::Vector3< float > Unproject (const wxPoint &pos2d, double &d)
 computes 3D coordinate from 2D+Z by "unprojection" JW More...
 
virtual void UpdateTime ()
 sets the internal time param, by default based on realtime wall clock More...
 
virtual ~OpenGLCanvas ()
 destructor More...
 

Static Public Member Functions

static void DisplaySampleScene ()
 display soem very simple Gl calls to draw something at all More...
 
static bool GetVSync ()
 
static void SetVSync (const bool &trueForOn)
 vertical sync control on or off (VSYNC) JW More...
 
static void StereoI_CaptureStereoImage (const int &format, const int &quality)
 
static float StereoI_GetConvergence ()
 
static void StereoI_GetInfo (std::ostream &os=std::cout)
 query status information on current NVStereo rendering state JW More...
 
static float StereoI_GetSeparation ()
 
static int StereoI_GetStereoState ()
 wrappers for StereoI interface More...
 
static int StereoI_Init ()
 interace to NVidias consumer Stereo NVStereo driver API. More...
 
static float StereoI_SetConvergence (const float &val)
 
static float StereoI_SetSeparation (const float &val)
 
static int StereoI_SetStereoState (const int &val)
 
static bool ToggleIP (bool &value)
 helper toggling a bool value in place More...
 
static bool ToggleVSync ()
 try to toggle VSync setting. More...
 

Static Public Attributes

static bool animationUpdateEnabled = OPENGLCANVASBASE_DEFAULT_animationUpdateEnabled
 
static bool idleRepaintEnabled = OPENGLCANVAS_DEFAULT_idleRepaintEnabled
 
static bool realtimeAnimation = OPENGLCANVAS_DEFAULT_realtimeAnimation
 
static double time = 0.0
 

Protected Attributes

GLenum _polygonmodeGL
 
unsigned long framecount_
 
bool InitWithContextDone_
 
unsigned int instance_
 
BIAS::DrawTextGLp_font
 
wxFrame * p_ownerframe
 
CameraViewControllerp_viewCtrl_
 
BIAS::RenderModeGL rendermode
 

Static Protected Attributes

static unsigned int instancesTotalNo_ = 0
 

Detailed Description

OpenGL canvases with additinal event handling (JW)

In addition to OpenGLCanvasbase "automatioc" event handling is integrated, e.g. -Display value under mouse in status bar, -internal storage of camera view, -navigation through mouse and keys And it is optionally adding -automatic repaint by Onidle function (like in glut) -automatic update of time for animations.

Author
Jan Woetzel

Definition at line 68 of file OpenGLCanvas.hh.

Constructor & Destructor Documentation

OpenGLCanvas::~OpenGLCanvas ( )
virtual

destructor

Definition at line 46 of file OpenGLCanvas.cpp.

OpenGLCanvas::OpenGLCanvas ( wxFrame *  parent,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = AsciiToWx("OpenGLCanvas"),
int *  attribList = NULL,
const wxPalette &  palette = wxNullPalette 
)

constructors:

Definition at line 52 of file OpenGLCanvas.cpp.

References InitMembers().

OpenGLCanvas::OpenGLCanvas ( wxFrame *  parent,
wxGLContext *  sharedContext = NULL,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = AsciiToWx("OpenGLCanvas"),
int *  attribList = 0,
const wxPalette &  palette = wxNullPalette 
)

constructor using a shared context

Definition at line 70 of file OpenGLCanvas.cpp.

References InitMembers().

Member Function Documentation

void OpenGLCanvas::Display ( )
virtual

display call to be overridden by child classes

Reimplemented from BIAS::OpenGLCanvasBase.

Definition at line 102 of file OpenGLCanvas.cpp.

References BIAS::OpenGLCanvasBase::Display(), and idleRepaintEnabled.

Referenced by OnIdle(), OnMotion(), OnMouseWheel(), Reshape(), and BIAS::ImageCanvasGLBase::Set().

void OpenGLCanvasBase::DisplayCalls ( )
virtualinherited

begin your fancy GL calls

<<< end of your GL calls

Reimplemented in BIAS::ImageCanvasGLBase, and BIAS::SimpleGLCanvas.

Definition at line 340 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::DisplayClear(), and BIAS::OpenGLCanvasBase::DisplaySampleScene().

Referenced by BIAS::OpenGLCanvasBase::Display().

void OpenGLCanvas::DisplayCameraView ( )
virtual
void OpenGLCanvas::DisplayCameraViewExternalParams ( )
virtual
void OpenGLCanvas::DisplayCameraViewInternalParams ( )
virtual
void OpenGLCanvasBase::DisplayClear ( const GLbitfield &  mask = CLEAR_DEFAULT_MASK)
virtualinherited

clears buffers and resets virtual camera to identity

Definition at line 407 of file OpenGLCanvasBase.cpp.

References BIAS::GeometryGL::DisplayClear().

Referenced by BIAS::OpenGLCanvasBase::DisplayCalls().

void OpenGLCanvasBase::DisplayCoordCross ( const float &  size = 1.0f,
const float &  linewidth = 1.0f 
)
inherited
void OpenGLCanvasBase::DisplayRenderMode ( )
virtualinherited

display default shade model, polygon mode,

Definition at line 414 of file OpenGLCanvasBase.cpp.

References BIAS::GeometryGL::DisplayRenderMode(), and BIAS::OpenGLCanvasBase::rendermode.

Referenced by BIAS::OpenGLCanvasBase::Display().

void OpenGLCanvasBase::DisplaySampleScene ( )
staticinherited

display soem very simple Gl calls to draw something at all

Definition at line 421 of file OpenGLCanvasBase.cpp.

References BIAS::GeometryGL::DisplaySceneExampleSimple().

Referenced by BIAS::OpenGLCanvasBase::DisplayCalls().

void OpenGLCanvasBase::DisplaySelectBuffer ( )
inherited
float OpenGLCanvasBase::GetAspectRatio ( ) const
inherited

GetAspectRatio is X/Y.

Returns
aspect 'X/Y' = ratio of width being 'bigger' than reference height

Definition at line 474 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::GetHeight(), and BIAS::OpenGLCanvasBase::GetWidth().

Referenced by Reshape().

unsigned long BIAS::OpenGLCanvasBase::GetFrameCount ( ) const
inlineinherited

Definition at line 301 of file OpenGLCanvasBase.hh.

unsigned int OpenGLCanvasBase::GetHeight ( ) const
inherited
void OpenGLCanvas::GetInfoGL ( std::ostream &  os = std::cout)
virtual

return GL state info

Reimplemented from BIAS::OpenGLCanvasBase.

Definition at line 224 of file OpenGLCanvas.cpp.

References BIAS::OpenGLCanvasBase::GetInfoGL(), GetViewController(), and BIAS::CameraViewController::Print().

wxFrame * OpenGLCanvasBase::GetOwnerframe ( )
inherited

Definition at line 258 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::p_ownerframe.

float OpenGLCanvasBase::GetPixelValueDepth ( const wxPoint &  pos2d) const
inherited
BIAS::Vector3< float > OpenGLCanvasBase::GetPixelValueRGB ( const wxPoint &  pos2d)
inherited
BIAS::Vector4< float > OpenGLCanvasBase::GetPixelValueRGBA ( const wxPoint &  pos2d)
inherited
CameraViewController OpenGLCanvas::GetViewController ( ) const
CameraViewController & OpenGLCanvas::GetViewController ( )

Definition at line 248 of file OpenGLCanvas.cpp.

References p_viewCtrl_.

bool OpenGLCanvasBase::GetVSync ( )
staticinherited
@return true if vertical sync is enable, 

false for free running mode JW

Definition at line 1153 of file OpenGLCanvasBase.cpp.

References BIAS::SettingsGL::GetVSyncInterval().

Referenced by BIAS::OpenGLCanvasBase::InitWithContext(), BIAS::OpenGLCanvasBase::OnChar(), and BIAS::OpenGLCanvasBase::ToggleVSync().

unsigned int OpenGLCanvasBase::GetWidth ( ) const
inherited
void OpenGLCanvas::InitMembers ( )
virtual

any constructor should call this function to initialize all data members (e.g.

pointers to NULL)

Reimplemented from BIAS::OpenGLCanvasBase.

Reimplemented in BIAS::ImageCanvasGLBase.

Definition at line 89 of file OpenGLCanvas.cpp.

References _polygonmodeGL, BIAS::OpenGLCanvasBase::InitMembers(), and p_viewCtrl_.

Referenced by BIAS::ImageCanvasGLBase::InitMembers(), and OpenGLCanvas().

void OpenGLCanvasBase::InitWithContext ( )
virtualinherited
bool OpenGLCanvasBase::IsContextAvailable ( )
inherited

activates the current rendereing context if there is one and

Returns
true if gl rendering context is available, false if there is none available (yet).

Definition at line 224 of file OpenGLCanvasBase.cpp.

Referenced by BIAS::OpenGLCanvasBase::Display(), BIAS::OpenGLCanvasBase::GetPixelValueRGB(), BIAS::OpenGLCanvasBase::GetPixelValueRGBA(), and BIAS::OpenGLCanvasBase::InitWithContext().

void OpenGLCanvasBase::OnChar ( wxKeyEvent &  event)
virtualinherited
void OpenGLCanvasBase::OnEraseBackground ( wxEraseEvent &  event)
inherited

Definition at line 1138 of file OpenGLCanvasBase.cpp.

void OpenGLCanvas::OnIdle ( wxIdleEvent &  event)
void OpenGLCanvas::OnMotion ( wxMouseEvent &  event)
void OpenGLCanvas::OnMouseDown ( wxMouseEvent &  event)
void OpenGLCanvas::OnMouseWheel ( wxMouseEvent &  event)
void OpenGLCanvasBase::OnPaint ( wxPaintEvent &  event)
inherited

EVT handlers: ---------------------------------------—.

Definition at line 920 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::Display().

void OpenGLCanvasBase::OnSize ( wxSizeEvent &  event)
inherited

Definition at line 929 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::Reshape().

std::ostream & OpenGLCanvasBase::PrintHelp ( std::ostream &  os)
virtualinherited

pop up keyboard layout help.

Must be virtual to let child class add their bindings

Definition at line 935 of file OpenGLCanvasBase.cpp.

Referenced by BIAS::OpenGLCanvasBase::OnChar().

void OpenGLCanvas::Reshape ( )
virtual
void OpenGLCanvasBase::ScreenShot ( BIAS::ImageBase dest,
const bool &  flipY = true,
const GLenum &  format = GL_RGB,
const bool &  force8Bit = false 
)
inherited
void OpenGLCanvasBase::ScreenShot ( const std::string &  filename,
const bool &  flipY = true,
const GLenum &  format = GL_RGB,
const bool &  force8Bit = false 
)
inherited
void OpenGLCanvasBase::ScreenShot ( )
inherited

JW automatic screenshot to file with filename based on frame, instance etc.

JW

Definition at line 687 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::framecount_, BIAS::OpenGLCanvasBase::instance_, and BIAS::FileHandling::LeadingZeroString().

Referenced by BIAS::OpenGLCanvasBase::OnChar(), and BIAS::OpenGLCanvasBase::ScreenShot().

void BIAS::OpenGLCanvasBase::SetFrameCount ( const unsigned long &  newVal)
inlineinherited

Definition at line 302 of file OpenGLCanvasBase.hh.

void OpenGLCanvasBase::SetOwnerframe ( wxFrame *  ptr)
inherited

Definition at line 264 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::p_ownerframe.

void OpenGLCanvasBase::SetStatusText ( const wxString &  text,
const int  c_field = 0 
)
inherited

let an OpenGL canvas use the status bar of the containing frame and cout as fallback (JW)

Definition at line 747 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::p_ownerframe.

Referenced by BIAS::OpenGLCanvasBase::OnChar(), BIAS::OpenGLCanvasBase::ShowFPS(), and BIAS::OpenGLCanvasBase::ShowValue().

void OpenGLCanvasBase::SetVSync ( const bool &  trueForOn)
staticinherited

vertical sync control on or off (VSYNC) JW

Definition at line 1144 of file OpenGLCanvasBase.cpp.

References BIAS::SettingsGL::SetVSyncInterval().

Referenced by BIAS::OpenGLCanvasBase::InitWithContext(), and BIAS::OpenGLCanvasBase::ToggleVSync().

void OpenGLCanvasBase::ShowFPS ( const int &  framecounter,
const float &  minUpdateIntervalSec,
const unsigned int &  minNewFrames,
const unsigned int  nField 
)
inherited

shows FPS to status bar base don frame counter and last call to this function

Measures and updates only, if two conditions ar eboth met:

  1. at least minUpdateIntervalSec seconds have passed since prvious update
  2. at least minNewFrames were drawn since a previous update Shouls handle multiplem, shared contextst correctly (jw). JW

Definition at line 826 of file OpenGLCanvasBase.cpp.

References BIAS::AsciiToWx(), and BIAS::OpenGLCanvasBase::SetStatusText().

void OpenGLCanvasBase::ShowFPS ( )
inherited

simple interface for the above

Definition at line 906 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::framecount_.

Referenced by OnIdle().

void OpenGLCanvasBase::ShowValue ( const wxPoint &  pos)
inherited
void OpenGLCanvasBase::StereoI_CaptureStereoImage ( const int &  format,
const int &  quality 
)
staticinherited

Definition at line 1303 of file OpenGLCanvasBase.cpp.

float OpenGLCanvasBase::StereoI_GetConvergence ( )
staticinherited

Definition at line 1287 of file OpenGLCanvasBase.cpp.

void OpenGLCanvasBase::StereoI_GetInfo ( std::ostream &  os = std::cout)
staticinherited

query status information on current NVStereo rendering state JW

Definition at line 1222 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::StereoI_Init().

Referenced by BIAS::OpenGLCanvasBase::GetInfoGL(), BIAS::OpenGLCanvasBase::OnChar(), and BIAS::OpenGLCanvasBase::StereoI_Init().

float OpenGLCanvasBase::StereoI_GetSeparation ( )
staticinherited

Definition at line 1271 of file OpenGLCanvasBase.cpp.

int OpenGLCanvasBase::StereoI_GetStereoState ( )
staticinherited

wrappers for StereoI interface

Definition at line 1255 of file OpenGLCanvasBase.cpp.

int OpenGLCanvasBase::StereoI_Init ( )
staticinherited

interace to NVidias consumer Stereo NVStereo driver API.

to enable/disbale stereo and control convergence and separation for stereo rendering

Returns
0 on success, negative on error.
Author
Jan Woetzel

Definition at line 1181 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::StereoI_GetInfo().

Referenced by BIAS::OpenGLCanvasBase::StereoI_GetInfo().

float OpenGLCanvasBase::StereoI_SetConvergence ( const float &  val)
staticinherited

Definition at line 1295 of file OpenGLCanvasBase.cpp.

float OpenGLCanvasBase::StereoI_SetSeparation ( const float &  val)
staticinherited

Definition at line 1279 of file OpenGLCanvasBase.cpp.

int OpenGLCanvasBase::StereoI_SetStereoState ( const int &  val)
staticinherited

Definition at line 1263 of file OpenGLCanvasBase.cpp.

void OpenGLCanvasBase::SwapBuffers ( )
inherited

expands parents SwapBUffers by automatic framecount increase

Definition at line 288 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::framecount_.

Referenced by BIAS::OpenGLCanvasBase::Display().

void OpenGLCanvasBase::ToggleFullScreen ( )
inherited
bool OpenGLCanvasBase::ToggleIP ( bool &  value)
staticinherited

helper toggling a bool value in place

Returns
new value JW

Definition at line 1173 of file OpenGLCanvasBase.cpp.

bool OpenGLCanvasBase::ToggleVSync ( )
staticinherited

try to toggle VSync setting.

Returns
true if toggling worked, false if status persisted.

Definition at line 1159 of file OpenGLCanvasBase.cpp.

References BIAS::OpenGLCanvasBase::GetVSync(), and BIAS::OpenGLCanvasBase::SetVSync().

Referenced by BIAS::OpenGLCanvasBase::OnChar().

BIAS::Vector3< float > OpenGLCanvasBase::Unproject ( const wxPoint &  pos2d,
double &  d 
)
inherited

computes 3D coordinate from 2D+Z by "unprojection" JW

Definition at line 536 of file OpenGLCanvasBase.cpp.

Referenced by BIAS::OpenGLCanvasBase::ShowValue().

void OpenGLCanvas::UpdateTime ( )
virtual

sets the internal time param, by default based on realtime wall clock

Reimplemented from BIAS::OpenGLCanvasBase.

Definition at line 207 of file OpenGLCanvas.cpp.

References BIAS::OpenGLCanvasBase::animationUpdateEnabled, realtimeAnimation, BIAS::OpenGLCanvasBase::time, and BIAS::OpenGLCanvasBase::UpdateTime().

Referenced by OnIdle().

Member Data Documentation

GLenum BIAS::OpenGLCanvas::_polygonmodeGL
protected

Definition at line 143 of file OpenGLCanvas.hh.

Referenced by InitMembers().

bool OpenGLCanvasBase::animationUpdateEnabled = OPENGLCANVASBASE_DEFAULT_animationUpdateEnabled
staticinherited
unsigned long BIAS::OpenGLCanvasBase::framecount_
protectedinherited
bool OpenGLCanvas::idleRepaintEnabled = OPENGLCANVAS_DEFAULT_idleRepaintEnabled
static

Definition at line 128 of file OpenGLCanvas.hh.

Referenced by Display(), OnIdle(), OnMotion(), and OnMouseWheel().

bool BIAS::OpenGLCanvasBase::InitWithContextDone_
protectedinherited
unsigned int BIAS::OpenGLCanvasBase::instance_
protectedinherited
unsigned int OpenGLCanvasBase::instancesTotalNo_ = 0
staticprotectedinherited

Definition at line 368 of file OpenGLCanvasBase.hh.

Referenced by BIAS::OpenGLCanvasBase::InitMembers().

BIAS::DrawTextGL* BIAS::OpenGLCanvasBase::p_font
protectedinherited
wxFrame* BIAS::OpenGLCanvasBase::p_ownerframe
protectedinherited
CameraViewController* BIAS::OpenGLCanvas::p_viewCtrl_
protected

Definition at line 139 of file OpenGLCanvas.hh.

Referenced by GetViewController(), and InitMembers().

bool OpenGLCanvas::realtimeAnimation = OPENGLCANVAS_DEFAULT_realtimeAnimation
static

Definition at line 130 of file OpenGLCanvas.hh.

Referenced by UpdateTime().

BIAS::RenderModeGL BIAS::OpenGLCanvasBase::rendermode
protectedinherited
double OpenGLCanvasBase::time = 0.0
staticinherited

Definition at line 352 of file OpenGLCanvasBase.hh.

Referenced by UpdateTime().


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