Main Page | Class List | File List | Class Members | File Members

Parameters Class Reference

Manages application parameters. Creates GUI controls (sliders, checkboxes) and hotkeys. More...

#include <Parameters.h>

List of all members.

Public Member Functions

void Setup (CDXUTDialog *g_HUD)
 You can set the dialog that manages input and rendering for the GUI controls.
void Setup (CDXUTDialog *g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave=OnChange, ONCHANGE_CALLBACK OnLoad=OnChange)
 You can set the dialog that manages input and rendering for the GUI controls.
bool Get (bool_t i)
 Returns value of the specified boolean parameter, e.g. Get( bShowHelp ).
float Get (number_t i)
 Returns float value of the specified numeric parameter, in range 0..1.
int GetInt (number_t i)
 Returns integer value of the specified numeric parameter, in range 0...number-of-steps.
void SetBool (bool_t ID, bool b)
void SetFloat (number_t ID, float v)
void SetInt (number_t ID, int v)
void Add (bool_t ID, char *label, char cHotKey=0, ONCHANGE_CALLBACK bchf=OnChange)
 Adds a boolean parameter represented by a GUI checkbox. Specifies hotkey and callback function.
void Add (int radiogroupID, bool_t ID, char *label, char cHotKey=0, ONCHANGE_CALLBACK bchf=OnChange)
 Adds a boolean parameter represented by a GUI radio button. Specifies hotkey and callback function.
void Add (number_t ID, char *label, int num_steps)
 Adds a numeric parameter represented by a GUI slider.
void Add (number_t ID, char *label, int num_steps, CONVERTER ff, ONCHANGE_CALLBACK chf=OnChange)
 Adds a numeric parameter represented by a GUI slider. Specifies callback functions.
void Add (number_t ID, char *label, int num_steps, char cKeyDecr, char cKeyIncr=0, CONVERTER ff=noconvert, ONCHANGE_CALLBACK chf=OnChange)
 Adds a numeric parameter represented by a GUI slider. Specifies hotkeys and callback functions.
void SetEnabled (bool_t ID, bool bEnabled)
void SetEnabled (number_t ID, bool bEnabled)
void UpdateFromHUD (int controlID)
 Updates the specified parameter from the GUI.
void SaveToFile (char *fileName)
 Writes all parameter values into the specified file.
void LoadFromFile (char *fileName)
 Loads all parameter values from the specified file.

Private Types

enum  {
  checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000,
  downID0 = 5000
}

Private Attributes

bool bparam [LAST_BOOL]
 current param value (boolean)
wchar_t bname [LAST_BOOL][CHARBUF]
 param name
int radiogroup [LAST_BOOL]
 for boolean params that are represented by a checkbox
int param [LAST_NUMBER]
 current param value (numeric)
wchar_t name [LAST_NUMBER][CHARBUF]
 param name
int numsteps [LAST_NUMBER]
 number of possible steps for param
bool rotate [LAST_NUMBER]
 stores whether the slider can rotate around
CONVERTER ffunc [LAST_NUMBER]
ONCHANGE_CALLBACK chfunc [LAST_NUMBER+3]
ONCHANGE_CALLBACK bchfunc [LAST_BOOL]
CDXUTDialog * g_HUD
bool bSilent
 to avoid an endless loop due to a change

Static Private Attributes

static const int CHARBUFFER_SIZE = 200


Detailed Description

Manages application parameters. Creates GUI controls (sliders, checkboxes) and hotkeys.

Author:
Istvan Lazanyi, TU Budapest
Date:
2006-04-26


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
checkboxID0 
sliderID0 
staticID0 
upID0 
downID0 


Member Function Documentation

void Parameters::Add number_t  ID,
char *  label,
int  num_steps,
char  cKeyDecr,
char  cKeyIncr = 0,
CONVERTER  ff = noconvert,
ONCHANGE_CALLBACK  chf = OnChange
 

Adds a numeric parameter represented by a GUI slider. Specifies hotkeys and callback functions.

Parameters:
ID id of the given numeric parameter
label label to be displayed for the slider
num_steps number of possible parameter values
cKeyDecr Hotkey to decrease parameter value. (Note: keys R, S, L are reserved.)
cKeyIncr Hotkey to increase parameter value. (Note: keys R, S, L are reserved.) If 0, the slider will only have one hotkey that circulates between values min, min+1, ..., max-1, max, min, ...
ff converter function to transform the parameter value
chf callback to an action to be performed when the parameter changes

void Parameters::Add number_t  ID,
char *  label,
int  num_steps,
CONVERTER  ff,
ONCHANGE_CALLBACK  chf = OnChange
 

Adds a numeric parameter represented by a GUI slider. Specifies callback functions.

Parameters:
ID id of the given numeric parameter
label label to be displayed for the slider
num_steps number of possible parameter values
ff converter function to transform the parameter value
chf callback to an action to be performed when the parameter changes

void Parameters::Add number_t  ID,
char *  label,
int  num_steps
 

Adds a numeric parameter represented by a GUI slider.

Parameters:
ID id of the given numeric parameter
label label to be displayed for the slider
num_steps number of possible parameter values

void Parameters::Add int  radiogroupID,
bool_t  ID,
char *  label,
char  cHotKey = 0,
ONCHANGE_CALLBACK  bchf = OnChange
 

Adds a boolean parameter represented by a GUI radio button. Specifies hotkey and callback function.

Parameters:
radiogroupID id of radio button group. Checking a radio button will clear all other radio buttons with the same radiogroupID.
ID id of the given boolean parameter
label label to be displayed for the control
cHotkey Hotkey to change parameter value. (Note: keys R, S, L are reserved.)
bchf callback to an action to be performed when the parameter changes

void Parameters::Add bool_t  ID,
char *  label,
char  cHotKey = 0,
ONCHANGE_CALLBACK  bchf = OnChange
 

Adds a boolean parameter represented by a GUI checkbox. Specifies hotkey and callback function.

Parameters:
ID id of the given boolean parameter
label label to be displayed for the control
cHotkey Hotkey to change parameter value. (Note: keys R, S, L are reserved.)
bchf callback to an action to be performed when the parameter changes

float Parameters::Get number_t  i  ) 
 

Returns float value of the specified numeric parameter, in range 0..1.

Example: Get( refractionIndex ). Converter functions (if present) are applied to the result.

bool Parameters::Get bool_t  i  ) 
 

Returns value of the specified boolean parameter, e.g. Get( bShowHelp ).

int Parameters::GetInt number_t  i  ) 
 

Returns integer value of the specified numeric parameter, in range 0...number-of-steps.

Example: Get( fIntensity ) = 0..100. Converter functions (if present) are applied to the result.

void Parameters::LoadFromFile char *  fileName  ) 
 

Loads all parameter values from the specified file.

void Parameters::SaveToFile char *  fileName  ) 
 

Writes all parameter values into the specified file.

void Parameters::SetBool bool_t  ID,
bool  b
 

void Parameters::SetEnabled number_t  ID,
bool  bEnabled
 

void Parameters::SetEnabled bool_t  ID,
bool  bEnabled
 

void Parameters::SetFloat number_t  ID,
float  v
 

void Parameters::SetInt number_t  ID,
int  v
 

void Parameters::Setup CDXUTDialog *  g_HUD,
ONCHANGE_CALLBACK  OnReset,
ONCHANGE_CALLBACK  OnSave = OnChange,
ONCHANGE_CALLBACK  OnLoad = OnChange
 

You can set the dialog that manages input and rendering for the GUI controls.

Additionally, you can specify actions (ONCHANGE_CALLBACK) to the standard buttons Reset, Save and Load.

void Parameters::Setup CDXUTDialog *  g_HUD  ) 
 

You can set the dialog that manages input and rendering for the GUI controls.

void Parameters::UpdateFromHUD int  controlID  ) 
 

Updates the specified parameter from the GUI.

Since a GUI event provides the id of the sender (see OnGUIEvent() in Main.cpp), we can update the parameter value belonging to that control.

In case of Load/Save, parameters are loaded from/saved to the file called .params. In case of Reset, parameters are loaded from the file called .params0.


Member Data Documentation

ONCHANGE_CALLBACK Parameters::bchfunc[LAST_BOOL] [private]
 

wchar_t Parameters::bname[LAST_BOOL][CHARBUF] [private]
 

param name

bool Parameters::bparam[LAST_BOOL] [private]
 

current param value (boolean)

bool Parameters::bSilent [private]
 

to avoid an endless loop due to a change

const int Parameters::CHARBUFFER_SIZE = 200 [static, private]
 

ONCHANGE_CALLBACK Parameters::chfunc[LAST_NUMBER+3] [private]
 

CONVERTER Parameters::ffunc[LAST_NUMBER] [private]
 

CDXUTDialog* Parameters::g_HUD [private]
 

wchar_t Parameters::name[LAST_NUMBER][CHARBUF] [private]
 

param name

int Parameters::numsteps[LAST_NUMBER] [private]
 

number of possible steps for param

int Parameters::param[LAST_NUMBER] [private]
 

current param value (numeric)

int Parameters::radiogroup[LAST_BOOL] [private]
 

for boolean params that are represented by a checkbox

bool Parameters::rotate[LAST_NUMBER] [private]
 

stores whether the slider can rotate around


The documentation for this class was generated from the following files:
Generated on Wed Aug 23 00:00:39 2006 for Indirect Environment Mapping by  doxygen 1.4.2