Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Glitch Class Reference

Inherits the MainWindow QMainWindow class to provide functionality. More...

#include <glitch.h>

List of all members.

Public Member Functions

 Glitch (QString filename=QString::null)
 ~Glitch ()

Private Slots

virtual void cmdTableCurrentChanged (int row, int)
virtual void insertCommand ()
virtual void removeCommand ()
virtual void moveCmdUp ()
virtual void moveCmdDown ()
virtual void cmdListTabChanged (QWidget *w)
virtual void varTableCurrentChanged (int row, int)
virtual void cmdInstanceUpdated (CmdInstance *instance)
virtual void fileNew ()
virtual void fileOpen ()
virtual void fileSave ()
virtual void fileSaveAs ()
virtual void fileProperties ()
virtual void worldViewResetCamera ()
virtual void worldViewDrawAxes (bool enable)
virtual void worldViewDrawGrid (bool enable)
virtual void worldViewDrawFrustum (bool enable)
virtual void worldViewDoubleBuffer (bool enable)
virtual void worldViewDisplayZBuffer (bool enable)
virtual void worldViewOrthoProjection (bool enable)
virtual void worldViewPerspectiveProjection (bool enable)
virtual void worldViewSetForegroundColour ()
virtual void worldViewSetBackgroundColour ()
virtual void screenViewKeepAspectRatio (bool enable)
virtual void optionsRestoreOpenGLContexts ()
virtual void optionsAutoGLClear (bool enable)
virtual void optionsAutoGLFlush (bool enable)
virtual void optionsAutoGLEnd (bool enable)
virtual void optionsFilterCmdLists (bool enable)
virtual void optionsFullScreen (bool enable)
virtual void optionsSaveOptionsOnExit (bool enable)
virtual void optionsRestoreDefaults ()
virtual void helpAbout ()
virtual void stepDisplay (bool enable)
virtual void stepperReset ()
virtual void stepperPrev ()
virtual void stepperNext ()
virtual void matrixSelectionClicked (int id)
virtual void closeEvent (QCloseEvent *e)
virtual void varInstanceCreated (CmdInstance *instance, VarInstance *varInst)
virtual void varInstanceDestroyedCleanup (QObject *obj)
virtual void updateSceneDependents ()

Private Member Functions

void constructCmdTrees ()
void appendTree (QPtrList< CmdTreeNode > *to, QPtrList< CmdTreeNode > *trees, const QString &name)
void loadOptionSettings ()
void saveOptionSettings ()
bool openProject (const QString &filename)
bool saveCurrentProject (const QString &filename)
void moveCommand (int tabIndex, int fromPos, int toPos)
void updateStepperWidgets ()
void updateMatrixValues (bool clearValuesInstead=false)
void updateCmdInstanceVars (CmdInstance *instance)
bool makeVarNameUnique (VarInstance *varInst)
QString doubleToStr (double n) const

Private Attributes

GLProjectproject
bool unsavedChangesExist
QPtrList< SuperTabletabTables
QColor varSelectedColour
QColor cmdSelectedColour
QColor cmdStepPosColour
int matrixSelection
uint currInitRow
uint currDispRow
uint currVarRow
QMap< CmdInstance *, VarCmdInfovarCmdInfoMap
QMap< VarInstance *, CmdInstance * > varToCmdInstMap
QPtrList< VarInstanceorderedVarList
QMap< QString, VarInstance * > uniqueVarNames
QPtrList< CmdTreeNode > * allCmdTrees
QPtrList< CmdTreeNode > * initTrees
QPtrList< CmdTreeNode > * dispTrees
CmdSelectormyCmdSelector
bool filterCmdLists
bool saveOptionsOnExit
bool inStepperMode
int stepperPos
int oldStepperPos
GLScreenViewerscreenView
GLWorldViewerworldView
GLScenescene


Detailed Description

Inherits the MainWindow QMainWindow class to provide functionality.

This class is in control of the entire application.

Note: There are a few QtMac (Q_OS_MACX) specific sections in this class, such as in Glitch::Glitch() and Glitch::tweekMacMenus().


Constructor & Destructor Documentation

Glitch::Glitch QString  filename = QString::null  ) 
 

Default constructor.

If filename is not empty, then Glitch will attempt to open it as the initial project.

Glitch::~Glitch  ) 
 

Destructor - deallocate memory.

Option settings will be saved it required and things such as the command trees and the project are deallocated.

Note: Qt will look after the clean-up of the screenView, worldView and myCmdSelector (the command selector pop-up widget), along with all of the other Qt widgets, as they all inherit from QObject, which has automatic de-allocation facilities.


Member Function Documentation

void Glitch::appendTree QPtrList< CmdTreeNode > *  to,
QPtrList< CmdTreeNode > *  trees,
const QString &  name
[inline, private]
 

This is a simple utility method that searches for a specific node in a command tree list (by name), and if found and if it is not NULL, it adds to the specified to list.

Assumption: This method does NOT check to see if the `to' or `trees' paremeters are NULL or not. Ensure that they are not NULL BEFORE calling this method. This was done, as this method will be called many times on the same `to' and `trees' lists.

Note: This method has a request to be inlined.

void Glitch::closeEvent QCloseEvent *  e  )  [private, virtual, slot]
 

Reimplemented, as to add the ability to question the user upon their request to exit the program, whether or not they want to save changes, discard them or simply not exit anymore.

Obviously, this only occurs if there actually are unsaved changes.

void Glitch::cmdInstanceUpdated CmdInstance instance  )  [private, virtual, slot]
 

This slot is connected to the cmdInstanceChanged and cmdParamChanged signals.

Hence, this is called when one of the command instance's parameter input widget's value is changed and when a command instance's actual command is changed.

This ensures that the required housekeeping is performed, such as updating the OpenGL scene and its dependents and any associated external variables.

void Glitch::cmdListTabChanged QWidget *  w  )  [private, virtual, slot]
 

This slot is called when current tab in cmdListTab is changed (currentChanged signal emitted), so that it can perform the required housekeeping.

It performs things such as the following:

  • Enables and disables buttons such as "Remove", "Up" and "Down".
  • Selects the appropiate command trees for the command selector.
  • Sets up the current table row instance for editing for the given tab

void Glitch::cmdTableCurrentChanged int  row,
int 
[private, virtual, slot]
 

Update the table's editor widgets accordingly to the currenly selected row.

This is called/connected to QTable's currentChanged signal for BOTH initCmdsTable and dispCmdsTable and is also called by several methods.

void Glitch::constructCmdTrees  )  [private]
 

Construct the initialization and display command trees, using the command tree list allCmdTrees. The trees are identified via macros such as "INITTREE_TITLE" ("Initialization"), which are defined by cmdtreetitles.h.

See AllCmdTrees for why the command trees headers were not directly included into this class and hence why we must work on a string basis, not a direct object basis.

QString Glitch::doubleToStr double  n  )  const [private]
 

This utility method is used to get the string representation of a number of type `double'. It ensures that any number that could be represented exactly by an integer still has a `.0' at the end of it (e.g. `4' -> `4.0').

void Glitch::fileNew  )  [private, virtual, slot]
 

Start a new project. If one is currently open, then offer the user the chance to save it.

This is called when the program is launched to start a new project.

Note: This will also tell the OpenGL render box about the command lists.

void Glitch::fileOpen  )  [private, virtual, slot]
 

Open an existing project / tutorial

void Glitch::fileProperties  )  [private, virtual, slot]
 

Display the project properties dialog (modal). This is called by the menu item "File" -> "Properties...".

void Glitch::fileSave  )  [private, virtual, slot]
 

Save the current project / tutorial

void Glitch::fileSaveAs  )  [private, virtual, slot]
 

Save the current project / tutorial to a new / different file

void Glitch::helpAbout  )  [private, virtual, slot]
 

Display the about dialog (modal).

This is called by the menu item "Help" -> "About".

void Glitch::insertCommand  )  [private, virtual, slot]
 

Insert a new command row into the current table AFTER the current selection and select it.

void Glitch::loadOptionSettings  )  [private]
 

Attempt to load the option settings, using QSettings.

From the Qt documentation, regarding QSettings:
The QSettings class provides persistent platform-independent application settings.
On Unix systems, QSettings uses text files to store settings. On Windows systems, QSettings uses the system registry. On Mac OS X, QSettings uses the Carbon preferences API.

If any of the settings are not found, then defaults will be used.

Note: Regarding boolean settings for actions: The methods to actually update the states of the* program will ONLY be called (by actions) IF the setting is different to the initial setting for the actions. Hence, for settings such as worldViewDoubleBuffer, worldViewPerspectiveProjection, screenViewKeepAspectRatio, optionsAutoGLClear, optionsAutoGLFlush and optionsAutoGLEnd that are ON by default, the actual actions have also been set to ON by default (which is in the UI file).

See Glitch::saveOptionSettings().

bool Glitch::makeVarNameUnique VarInstance varInst  )  [private]
 

Take a variable instance and make sure that its name unique, when compared to the rest of the variable instances.

If the variable's name is not unique, then new names with a number appended to end of original will be tried, in the order of 2, 3, 4, ..., UINT_MAX.

Limitation: If the user is wants to AND is able to create variables named varName0 all the way to varName[UINT_MAX], then a unique name will NOT be returned (they deserve to be able to have un-unique variable names!).

Note: If an empty string is passed (""), then "untitled" will be the base of the new name. * Returns true if a modification was made, false otherwise.

void Glitch::matrixSelectionClicked int  id  )  [private, virtual, slot]
 

Update which matrix is to be shown by Glitch::updateMatrixValues().

This is called when the user changes (via the GUI) which matrix they want to be shown.

void Glitch::moveCmdDown  )  [private, virtual, slot]
 

Move the currently selected command in the currently selected list/tab down, if possible (e.g you can't move the bottom-most command down any further).

See Glitch::moveCommand() for more details.

void Glitch::moveCmdUp  )  [private, virtual, slot]
 

Move the currently selected command in the currently selected list/tab up, if possible (e.g. you can't move the upper-most command up any further).

See Glitch::moveCommand() for more details.

void Glitch::moveCommand int  tabIndex,
int  fromPos,
int  toPos
[private]
 

Move a command instance from the fromPos to the toPos in the table in tab tabIndex.

This looks after bounds checks, selection, visibility and updating of dependents.

This method is used by Glitch::moveCmdUp() and Glitch::moveCmdDown(), as it abstracts their core functionality.

bool Glitch::openProject const QString &  filename  )  [private]
 

Attempt to open the a project from disk.

This does NOT look after save dialogs and so forth, that sould be performed by the caller, if required. This just simply does what it says, open a project.

void Glitch::optionsAutoGLClear bool  enable  )  [private, virtual, slot]
 

Toggle an automatic glClear() OpenGL call for the OpenGL viwers screenView and worldView.

This option is on by default, as most of the time, you just want to get on with teaching a specific part of OpenGL, not bombarding the user with all of OpenGL's little management necessities.

void Glitch::optionsAutoGLEnd bool  enable  )  [private, virtual, slot]
 

Toggle an automatic glEnd() OpenGL call, which is needed to keep OpenGL working in the case where glBegin is called but has not been followed through with a glEnd call.

This happens for example, when in stepper mode and you have stepped past a glBegin but not yet to its matching glEnd call.

It fixes the display and ALSO the ability to get the matrix values.

void Glitch::optionsAutoGLFlush bool  enable  )  [private, virtual, slot]
 

Toggle an automatic glFlush() OpenGL call for the OpenGL viwers screenView and worldView.

This option is on by default, as most of the time, you just want to get on with teaching a specific part of OpenGL, not bombarding the user with all of OpenGL's little management necessities.

void Glitch::optionsFilterCmdLists bool  enable  )  [private, virtual, slot]
 

Toggle the option to either filter or show all commands in the initilzation and display sections. Hence, if disabled, it would this allow the user to insert any of the commands into either of the sections.

void Glitch::optionsFullScreen bool  enable  )  [private, virtual, slot]
 

Set this mainwindow to go into fullscreen mode or not. In fullscreen mode, the title bar will be removed, the window will be maximized and any task bar / kicker / dock / etc. should be hidden.

void Glitch::optionsRestoreDefaults  )  [private, virtual, slot]
 

Call this to restore/revet the option settings back to their defaults.

The user will be prompted first, as to check if they really want to proceed.

As the fore- and background colours must also be reset, the OpenGL scene viewers are also updated.

Note: If the user wishes to proceed, then Glitch::optionsRestoreOpenGLContexts() will be called, as it seems fitting to clean everything up (I think so anyway!). The camera will be reset by this.

void Glitch::optionsRestoreOpenGLContexts  )  [private, virtual, slot]
 

This is used to restore the OpenGL contexts that are used by the world and screen viewers, in the case where they are messed-up / confused, due to some truly bad sequence of some truly bad code.

To do this, the viewers are actually destroyed and recreated.

void Glitch::optionsSaveOptionsOnExit bool  enable  )  [private, virtual, slot]
 

Toggle whether or not the option settings should be remembered from this session for the next session (excluding this option, as it is ALWAYS saved).

This method is known internally as "save options on exit", as that is what it really does.

void Glitch::removeCommand  )  [private, virtual, slot]
 

Remove / delete the currently selected command row from the table.

This will perform all required clean-ups, such as destroying any related variable instances.

This will also disable the "Remove", "Up" and "Down" buttons if the current command table does not contain any entries after the removal and then finally update any command dependents (such as the OpenGL scene and its dependents).

bool Glitch::saveCurrentProject const QString &  filename  )  [private]
 

Save the current project to disk. This does NOT look after save dialogs and so forth... The project and its filename must ALREADY be defined POST: on sucess, returns true AND updates the project's filename on failure, returens false

void Glitch::saveOptionSettings  )  [private]
 

Attempt to save the option settings, using QSettings.

Please see Glitch::loadOptionSettings() for more information.

void Glitch::screenViewKeepAspectRatio bool  enable  )  [private, virtual, slot]
 

Toggle the OpenGL screen space view to keep a 1:1 aspect ratio or not.

void Glitch::stepDisplay bool  enable  )  [private, virtual, slot]
 

Set the render mode to step through the display commands one at a time. _OR_ Set the render mode to loop over the display commands continuously.

void Glitch::stepperNext  )  [private, virtual, slot]
 

When in the stepper mode, this will step forwards to the next command in the display list.

Note: you can't step forwards any further past the last command.

void Glitch::stepperPrev  )  [private, virtual, slot]
 

When in the stepper mode, this will step back to the previous command in the display list.

Note: you can't step back any further than 1 position before the first command.

void Glitch::stepperReset  )  [private, virtual, slot]
 

When in the stepper mode, this will reset the state back to the start of the display commands list.

void Glitch::updateCmdInstanceVars CmdInstance instance  )  [private]
 

This method looks after the creation, updating and deletion of the external variables from the external variables table.

It also ensures that variable instance names are kept unique.

Note: This method can and IS used for command instances that don't or longer contain variable instances. This is because it is in charge the deletion of variable listings from the variable table and also from management variables (such as varCmdInfoMap, varToCmdInstMap, uniqueVarNames and orderedVarList).

void Glitch::updateMatrixValues bool  clearValuesInstead = false  )  [private]
 

Update the values in the 4x4 matrix. The values are dependent on which matrix is to be shown, either Model View or Projection.

Note: Setting clearValuesInstead to true will set each cell to "0.0", instead of outputting the real matrix data. This (non-default) option allows the matrix element widgets to be zeroed-out when the stepped mode is disabled.

void Glitch::updateSceneDependents  )  [private, virtual, slot]
 

Update the OpenGL scene dependents, such as stepper widgets and matrix values.

void Glitch::updateStepperWidgets  )  [private]
 

Update widgets that are affected by the stepper, such as the display commands table, current matrix mode label, matrix values, etc...

Note: This CAN be and IS called even if the stepper mode is NOT active, so that if the user just switched off stepper mode, then the command row editor's background will be updated to be the selection colour.

Note: This WILL make updateGL calls, as it needs to get the latest matrix information for the current stepper position.

void Glitch::varInstanceCreated CmdInstance instance,
VarInstance varInst
[private, virtual, slot]
 

This is called by a command instance when it creates a new variable instance.

This will look after the creation / update of records that track the variables, insertion of a new row in the variables table, ensuring that the variable name is unique and connects a slot to the variable instance's destroyed() signal.

void Glitch::varInstanceDestroyedCleanup QObject *  obj  )  [private, virtual, slot]
 

This is connected to variable instances destroyed() signal.

This will look after the removal of records that track the variables, removal of variables table row that displays the variable and makes other misc. updates.

Note: The object's virtual table is already degenerated at this point, it is not safe to call any of its functions.

void Glitch::varTableCurrentChanged int  row,
int 
[private, virtual, slot]
 

Update the table's editor widgets accordingly to the currenly selected row.

It handles the change of the selected row (remove old/existing variable instance editor and create and insert a new one for the newly seleted row), and updates the current row's editor when the same row is re-selected (such as when a variable's name is changed).

This is called/connected to QTable's currentChanged signal for varTable and is also called by several methods.

void Glitch::worldViewDisplayZBuffer bool  enable  )  [private, virtual, slot]
 

Toggle whether or not the world view OpenGL viewer should show its Z / depth buffer instead of the normal output.

void Glitch::worldViewDoubleBuffer bool  enable  )  [private, virtual, slot]
 

Toggle whether or not the world view OpenGL viewer should be double buffered.

This method will only proceed if this option is toggled to a setting other than what is already currently chosen. In which case, the world viewer is actually destroyed and recreated with the new display format setting.

void Glitch::worldViewDrawAxes bool  enable  )  [private, virtual, slot]
 

Toggle the rendering of the axes (X, Y and Z) in the world view.

void Glitch::worldViewDrawFrustum bool  enable  )  [private, virtual, slot]
 

Toggle the rendering of the projection frustum in the world view.

void Glitch::worldViewDrawGrid bool  enable  )  [private, virtual, slot]
 

Toggle the rendering of the grid on the Z=0 plane in the world view.

void Glitch::worldViewOrthoProjection bool  enable  )  [private, virtual, slot]
 

Toggle whether or not the world view OpenGL viewer should use an orthographic projection for its camera, or a perspective one.

void Glitch::worldViewPerspectiveProjection bool  enable  )  [private, virtual, slot]
 

Toggle whether or not the world view OpenGL viewer should use a perspective projection for its camera, or simply an orthographic one.

void Glitch::worldViewResetCamera  )  [private, virtual, slot]
 

Reset the world viewer's camera back to its original position. This will also stop the camera from spinning if it is currently doing so.

void Glitch::worldViewSetBackgroundColour  )  [private, virtual, slot]
 

Get the user to set the world view's background colour.

The user will be presented with a colour selection dialog that is native to the user's system.

This colour will be used when the world viewer makes an internal glClearColor call.

Note: The user can override this setting in their Glitch project, for example:

 glClearColor( 0.5, 0.5, 0.5, 1.0 );
 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

void Glitch::worldViewSetForegroundColour  )  [private, virtual, slot]
 

Get the user to set the world view's foreground colour.

The user will be presented with a colour selection dialog that is native to the user's system.

This colour is used when drawing things like the grid and the X, Y and Z axes labels.


Member Data Documentation

QPtrList<CmdTreeNode>* Glitch::allCmdTrees [private]
 

QColor Glitch::cmdSelectedColour [private]
 

QColor Glitch::cmdStepPosColour [private]
 

uint Glitch::currDispRow [private]
 

uint Glitch::currInitRow [private]
 

uint Glitch::currVarRow [private]
 

QPtrList<CmdTreeNode>* Glitch::dispTrees [private]
 

bool Glitch::filterCmdLists [private]
 

QPtrList<CmdTreeNode>* Glitch::initTrees [private]
 

bool Glitch::inStepperMode [private]
 

int Glitch::matrixSelection [private]
 

CmdSelector* Glitch::myCmdSelector [private]
 

int Glitch::oldStepperPos [private]
 

QPtrList<VarInstance> Glitch::orderedVarList [private]
 

GLProject* Glitch::project [private]
 

bool Glitch::saveOptionsOnExit [private]
 

GLScene* Glitch::scene [private]
 

GLScreenViewer* Glitch::screenView [private]
 

int Glitch::stepperPos [private]
 

QPtrList<SuperTable> Glitch::tabTables [private]
 

QMap<QString, VarInstance*> Glitch::uniqueVarNames [private]
 

bool Glitch::unsavedChangesExist [private]
 

QMap<CmdInstance*, VarCmdInfo> Glitch::varCmdInfoMap [private]
 

QColor Glitch::varSelectedColour [private]
 

QMap<VarInstance*, CmdInstance*> Glitch::varToCmdInstMap [private]
 

GLWorldViewer* Glitch::worldView [private]
 


The documentation for this class was generated from the following files:
Generated on Fri Feb 27 12:01:40 2004 for Glitch by doxygen 1.3.2