HOG2
Classes | Functions | Variables
Common.cpp File Reference
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <cassert>
#include "GLUtil.h"
#include "Trackball.h"
#include "Common.h"
Include dependency graph for Common.cpp:

Go to the source code of this file.

Classes

class  bmp_header
 

Functions

const char * getModifierText (tKeyboardModifier t)
 
void InstallKeyboardHandler (KeyboardCallback kf, const char *title, const char *description, tKeyboardModifier mod, unsigned char firstKey, unsigned char lastKey)
 
void GetKeyAssignments (std::vector< char > &keys)
 
void GetKeyAssignmentDescriptions (std::vector< std::string > &keys)
 
void PrintKeyboardAssignments ()
 
bool DoKeyboardCallbacks (pRecContext pContextInfo, unsigned char keyHit, tKeyboardModifier mod)
 
void InstallFrameHandler (FrameCallback glCall, unsigned long windowID, void *userdata)
 
void RemoveFrameHandler (FrameCallback glCall, unsigned long windowID, void *userdata)
 
void HandleFrame (pRecContext pContextInfo, int viewport)
 
void InstallJoystickHandler (JoystickCallback jC, void *userdata)
 
void RemoveJoystickHandler (JoystickCallback jC, void *userdata)
 
void HandleJoystickMovement (pRecContext pContextInfo, double panX, double panY)
 
void InstallCommandLineHandler (CommandLineCallback CLC, const char *arg, const char *param, const char *usage)
 
void PrintCommandLineArguments ()
 
void ProcessCommandLineArgs (int argc, char *argv[])
 
void InstallMouseClickHandler (MouseCallback mC, tMouseEventType which)
 
void InstallMouseClickHandler (MouseCallback2 mC, tMouseEventType which)
 
void RemoveMouseClickHandler (MouseCallback mC)
 
void RemoveMouseClickHandler (MouseCallback2 mC)
 
void ReinitViewports (unsigned long windowID, const Graphics::rect &r, viewportType v)
 
int AddViewport (unsigned long windowID, const Graphics::rect &r, viewportType v)
 
int AddViewport (unsigned long windowID, const Graphics::rect &initial, const Graphics::rect &fin, viewportType v)
 
void MoveViewport (unsigned long windowID, int port, const Graphics::rect &newLocation)
 
float GlobalHOGToViewportX (float x, int v)
 
float ViewportToGlobalHOGX (float x, int v)
 
float GlobalHOGToViewportY (float y, int v)
 
Graphics::point GlobalHOGToViewport (Graphics::point where, int viewport)
 
Graphics::point ViewportToGlobalHOG (Graphics::point where, int viewport)
 
Graphics::rect GlobalHOGToViewport (const Graphics::rect &loc, int port)
 
Graphics::rect ViewportToGlobalHOG (const Graphics::rect &loc, int port)
 
Graphics::point GlobalHOGToViewport (pRecContext pContextInfo, const viewport &v, Graphics::point where)
 
Graphics::point ViewportToGlobalHOG (pRecContext pContextInfo, const viewport &v, Graphics::point where)
 
bool HandleMouse (pRecContext pContextInfo, int xWindow, int yWindow, point3d where, tButtonType button, tMouseEventType mouse)
 
bool HandleMouse (pRecContext pContextInfo, point3d where, tButtonType button, tMouseEventType mouse)
 
bool HandleMouseClick (pRecContext pContextInfo, int viewport, int x, int y, point3d where, tButtonType button, tMouseEventType mouse)
 
bool HandleMouseClick (pRecContext pContextInfo, int x, int y, point3d where, tButtonType button, tMouseEventType mouse)
 
void InstallWindowHandler (WindowCallback wC)
 
void RemoveWindowHandler (WindowCallback wC)
 
void HandleWindowEvent (pRecContext pContextInfo, tWindowEventType e)
 
void initialConditions (pRecContext pContextInfo)
 
bool DoKeyboardCommand (pRecContext pContextInfo, unsigned char keyHit, bool shift, bool cntrl, bool alt)
 
void resetCamera ()
 
void resetCamera (recCamera *pCamera)
 
recVec cameraLookingAt (int port)
 
void cameraLookAt (GLfloat x, GLfloat y, GLfloat z, float cameraSpeed, int port)
 
void cameraMoveTo (GLfloat x, GLfloat y, GLfloat z, float cameraSpeed, int port)
 
void cameraOffset (GLfloat x, GLfloat y, GLfloat z, float cameraSpeed, int port)
 
void setPortCamera (pRecContext pContextInfo, int currPort)
 
void setViewport (pRecContext pContextInfo, int currPort)
 
point3d GetOGLPos (pRecContext pContextInfo, int x, int y)
 
void SetNumPorts (unsigned long windowID, int count)
 
int GetNumPorts (unsigned long windowID)
 
int GetActivePort (unsigned long windowID)
 
void SetActivePort (unsigned long windowID, int which)
 
void SaveScreenshot (unsigned long windowID, const char *filename)
 
void SetZoom (int windowID, float amount)
 
recVec GetHeading (unsigned long windowID, int which)
 
void GetHeading (unsigned long windowID, int which, GLdouble &hx, GLdouble &hy, GLdouble &hz)
 

Variables

static unsigned long gNextWindowID = 0
 
char gDefaultMap [1024] = ""
 
const recVec gOrigin (0.0, 0.0, 0.0)
 
static std::vector< commandLineCallbackData * > commandLineCallbacks
 
static std::vector< joystickCallbackData * > joystickCallbacks
 
static std::vector< mouseCallbackData * > mouseCallbacks
 
static std::vector< mouseCallbackData2 * > mouseCallbacks2
 
static std::vector< windowCallbackData * > windowCallbacks
 
static std::vector< frameCallbackData * > glDrawCallbacks
 
static keyboardCallbackDatakeyboardCallbacks [256]
 

Function Documentation

◆ AddViewport() [1/2]

int AddViewport ( unsigned long  windowID,
const Graphics::rect initial,
const Graphics::rect fin,
viewportType  v 
)

◆ AddViewport() [2/2]

int AddViewport ( unsigned long  windowID,
const Graphics::rect r,
viewportType  v 
)

◆ cameraLookAt()

void cameraLookAt ( GLfloat  x,
GLfloat  y,
GLfloat  z,
float  cameraSpeed,
int  port 
)

◆ cameraLookingAt()

recVec cameraLookingAt ( int  port)

◆ cameraMoveTo()

void cameraMoveTo ( GLfloat  x,
GLfloat  y,
GLfloat  z,
float  cameraSpeed,
int  port 
)

◆ cameraOffset()

void cameraOffset ( GLfloat  x,
GLfloat  y,
GLfloat  z,
float  cameraSpeed,
int  port 
)

◆ DoKeyboardCallbacks()

bool DoKeyboardCallbacks ( pRecContext  pContextInfo,
unsigned char  keyHit,
tKeyboardModifier  mod 
)

◆ DoKeyboardCommand()

bool DoKeyboardCommand ( pRecContext  pContextInfo,
unsigned char  keyHit,
bool  shift,
bool  cntrl,
bool  alt 
)

Definition at line 703 of file Common.cpp.

References DoKeyboardCallbacks(), kAltDown, kControlDown, kNoModifier, kShiftDown, and pContextInfo.

Referenced by keyPressed(), and RunHOGGUI().

◆ GetActivePort()

int GetActivePort ( unsigned long  windowID)

Definition at line 929 of file Common.cpp.

References recContext::currPort, GetContext(), and pContextInfo.

Referenced by MyDisplayHandler().

◆ GetHeading() [1/2]

recVec GetHeading ( unsigned long  windowID,
int  which 
)

Definition at line 1036 of file Common.cpp.

References GetHeading(), recVec::x, recVec::y, and recVec::z.

Referenced by GetHeading().

◆ GetHeading() [2/2]

void GetHeading ( unsigned long  windowID,
int  which,
GLdouble &  hx,
GLdouble &  hy,
GLdouble &  hz 
)

◆ GetKeyAssignmentDescriptions()

void GetKeyAssignmentDescriptions ( std::vector< std::string > &  keys)

Definition at line 97 of file Common.cpp.

References keyboardCallbacks, and keyboardCallbackData::next.

◆ GetKeyAssignments()

void GetKeyAssignments ( std::vector< char > &  keys)

Definition at line 84 of file Common.cpp.

References keyboardCallbacks, and keyboardCallbackData::next.

◆ getModifierText()

const char* getModifierText ( tKeyboardModifier  t)

Definition at line 60 of file Common.cpp.

References kAltDown, kAnyModifier, kControlDown, kNoModifier, and kShiftDown.

Referenced by DoKeyboardCallbacks(), and PrintKeyboardAssignments().

◆ GetNumPorts()

int GetNumPorts ( unsigned long  windowID)

Definition at line 923 of file Common.cpp.

References GetContext(), recContext::numPorts, and pContextInfo.

Referenced by MyDisplayHandler(), and MyFrameHandler().

◆ GetOGLPos()

point3d GetOGLPos ( pRecContext  pContextInfo,
int  x,
int  y 
)

◆ GlobalHOGToViewport() [1/3]

Graphics::rect GlobalHOGToViewport ( const Graphics::rect loc,
int  port 
)

◆ GlobalHOGToViewport() [2/3]

Graphics::point GlobalHOGToViewport ( Graphics::point  where,
int  viewport 
)

◆ GlobalHOGToViewport() [3/3]

Graphics::point GlobalHOGToViewport ( pRecContext  pContextInfo,
const viewport v,
Graphics::point  where 
)

◆ GlobalHOGToViewportX()

float GlobalHOGToViewportX ( float  x,
int  v 
)

◆ GlobalHOGToViewportY()

float GlobalHOGToViewportY ( float  y,
int  v 
)

◆ HandleFrame()

void HandleFrame ( pRecContext  pContextInfo,
int  viewport 
)

◆ HandleJoystickMovement()

void HandleJoystickMovement ( pRecContext  pContextInfo,
double  panX,
double  panY 
)

Definition at line 198 of file Common.cpp.

References joystickCallbacks, pContextInfo, and recContext::windowID.

◆ HandleMouse() [1/2]

bool HandleMouse ( pRecContext  pContextInfo,
int  xWindow,
int  yWindow,
point3d  where,
tButtonType  button,
tMouseEventType  mouse 
)

◆ HandleMouse() [2/2]

bool HandleMouse ( pRecContext  pContextInfo,
point3d  where,
tButtonType  button,
tMouseEventType  mouse 
)

◆ HandleMouseClick() [1/2]

bool HandleMouseClick ( pRecContext  pContextInfo,
int  viewport,
int  x,
int  y,
point3d  where,
tButtonType  button,
tMouseEventType  mouse 
)

◆ HandleMouseClick() [2/2]

bool HandleMouseClick ( pRecContext  pContextInfo,
int  x,
int  y,
point3d  where,
tButtonType  button,
tMouseEventType  mouse 
)

Definition at line 619 of file Common.cpp.

References mouseCallbacks, pContextInfo, and recContext::windowID.

◆ HandleWindowEvent()

void HandleWindowEvent ( pRecContext  pContextInfo,
tWindowEventType  e 
)

Definition at line 652 of file Common.cpp.

References pContextInfo, windowCallbacks, and recContext::windowID.

Referenced by RunHOGGUI().

◆ initialConditions()

void initialConditions ( pRecContext  pContextInfo)

◆ InstallCommandLineHandler()

void InstallCommandLineHandler ( CommandLineCallback  CLC,
const char *  arg,
const char *  param,
const char *  usage 
)

Definition at line 207 of file Common.cpp.

References commandLineCallbacks.

Referenced by InstallHandlers().

◆ InstallFrameHandler()

void InstallFrameHandler ( FrameCallback  glCall,
unsigned long  windowID,
void *  userdata 
)

Definition at line 143 of file Common.cpp.

References glDrawCallbacks.

Referenced by MyWindowHandler().

◆ InstallJoystickHandler()

void InstallJoystickHandler ( JoystickCallback  jC,
void *  userdata 
)

Definition at line 179 of file Common.cpp.

References joystickCallbacks.

◆ InstallKeyboardHandler()

void InstallKeyboardHandler ( KeyboardCallback  kf,
const char *  title,
const char *  description,
tKeyboardModifier  mod,
unsigned char  firstKey,
unsigned char  lastKey 
)

Definition at line 73 of file Common.cpp.

References keyboardCallbacks.

Referenced by InstallHandlers().

◆ InstallMouseClickHandler() [1/2]

void InstallMouseClickHandler ( MouseCallback  mC,
tMouseEventType  which 
)

Definition at line 255 of file Common.cpp.

References mouseCallbacks.

Referenced by InstallHandlers().

◆ InstallMouseClickHandler() [2/2]

void InstallMouseClickHandler ( MouseCallback2  mC,
tMouseEventType  which 
)

Definition at line 260 of file Common.cpp.

References mouseCallbacks2.

◆ InstallWindowHandler()

void InstallWindowHandler ( WindowCallback  wC)

Definition at line 634 of file Common.cpp.

References windowCallbacks.

Referenced by InstallHandlers().

◆ MoveViewport()

void MoveViewport ( unsigned long  windowID,
int  port,
const Graphics::rect newLocation 
)

Definition at line 341 of file Common.cpp.

References viewport::finalBound, GetContext(), pContextInfo, and recContext::viewports.

◆ PrintCommandLineArguments()

void PrintCommandLineArguments ( )

Definition at line 213 of file Common.cpp.

References commandLineCallbacks.

Referenced by ProcessCommandLineArgs().

◆ PrintKeyboardAssignments()

void PrintKeyboardAssignments ( )

Definition at line 109 of file Common.cpp.

References getModifierText(), keyboardCallbacks, and keyboardCallbackData::next.

Referenced by DoKeyboardCallbacks().

◆ ProcessCommandLineArgs()

void ProcessCommandLineArgs ( int  argc,
char *  argv[] 
)

Definition at line 222 of file Common.cpp.

References commandLineCallbacks, and PrintCommandLineArguments().

Referenced by RunHOGGUI().

◆ ReinitViewports()

void ReinitViewports ( unsigned long  windowID,
const Graphics::rect r,
viewportType  v 
)

◆ RemoveFrameHandler()

void RemoveFrameHandler ( FrameCallback  glCall,
unsigned long  windowID,
void *  userdata 
)

Definition at line 148 of file Common.cpp.

References glDrawCallbacks.

Referenced by MyWindowHandler().

◆ RemoveJoystickHandler()

void RemoveJoystickHandler ( JoystickCallback  jC,
void *  userdata 
)

Definition at line 184 of file Common.cpp.

References joystickCallbacks.

◆ RemoveMouseClickHandler() [1/2]

void RemoveMouseClickHandler ( MouseCallback  mC)

Definition at line 265 of file Common.cpp.

References mouseCallbacks.

◆ RemoveMouseClickHandler() [2/2]

void RemoveMouseClickHandler ( MouseCallback2  mC)

Definition at line 278 of file Common.cpp.

References mouseCallbacks2.

◆ RemoveWindowHandler()

void RemoveWindowHandler ( WindowCallback  wC)

Definition at line 639 of file Common.cpp.

References windowCallbacks.

◆ resetCamera() [1/2]

void resetCamera ( )

◆ resetCamera() [2/2]

void resetCamera ( recCamera pCamera)

◆ SaveScreenshot()

void SaveScreenshot ( unsigned long  windowID,
const char *  filename 
)

◆ SetActivePort()

void SetActivePort ( unsigned long  windowID,
int  which 
)

Definition at line 935 of file Common.cpp.

References recContext::currPort, GetContext(), and pContextInfo.

Referenced by MyDisplayHandler().

◆ SetNumPorts()

void SetNumPorts ( unsigned long  windowID,
int  count 
)

◆ setPortCamera()

void setPortCamera ( pRecContext  pContextInfo,
int  currPort 
)

◆ setViewport()

void setViewport ( pRecContext  pContextInfo,
int  currPort 
)

◆ SetZoom()

void SetZoom ( int  windowID,
float  amount 
)

◆ ViewportToGlobalHOG() [1/3]

Graphics::rect ViewportToGlobalHOG ( const Graphics::rect loc,
int  port 
)

◆ ViewportToGlobalHOG() [2/3]

Graphics::point ViewportToGlobalHOG ( Graphics::point  where,
int  viewport 
)

◆ ViewportToGlobalHOG() [3/3]

Graphics::point ViewportToGlobalHOG ( pRecContext  pContextInfo,
const viewport v,
Graphics::point  where 
)

◆ ViewportToGlobalHOGX()

float ViewportToGlobalHOGX ( float  x,
int  v 
)

Variable Documentation

◆ commandLineCallbacks

std::vector<commandLineCallbackData *> commandLineCallbacks
static

◆ gDefaultMap

char gDefaultMap[1024] = ""

Definition at line 29 of file Common.cpp.

Referenced by CreateSimulation(), MyCLHandler(), and MyFrameHandler().

◆ glDrawCallbacks

std::vector<frameCallbackData *> glDrawCallbacks
static

Definition at line 39 of file Common.cpp.

Referenced by HandleFrame(), InstallFrameHandler(), and RemoveFrameHandler().

◆ gNextWindowID

unsigned long gNextWindowID = 0
static

Definition at line 28 of file Common.cpp.

Referenced by initialConditions().

◆ gOrigin

const recVec gOrigin(0.0, 0.0, 0.0)

◆ joystickCallbacks

std::vector<joystickCallbackData *> joystickCallbacks
static

◆ keyboardCallbacks

keyboardCallbackData* keyboardCallbacks[256]
static
Initial value:
=
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }

Definition at line 42 of file Common.cpp.

Referenced by DoKeyboardCallbacks(), GetKeyAssignmentDescriptions(), GetKeyAssignments(), InstallKeyboardHandler(), and PrintKeyboardAssignments().

◆ mouseCallbacks

std::vector<mouseCallbackData *> mouseCallbacks
static

Definition at line 36 of file Common.cpp.

Referenced by HandleMouseClick(), InstallMouseClickHandler(), and RemoveMouseClickHandler().

◆ mouseCallbacks2

std::vector<mouseCallbackData2 *> mouseCallbacks2
static

Definition at line 37 of file Common.cpp.

Referenced by HandleMouseClick(), InstallMouseClickHandler(), and RemoveMouseClickHandler().

◆ windowCallbacks

std::vector<windowCallbackData *> windowCallbacks
static

Definition at line 38 of file Common.cpp.

Referenced by HandleWindowEvent(), InstallWindowHandler(), and RemoveWindowHandler().