#include <glitch.h>
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 | |
| GLProject * | project |
| bool | unsavedChangesExist |
| QPtrList< SuperTable > | tabTables |
| QColor | varSelectedColour |
| QColor | cmdSelectedColour |
| QColor | cmdStepPosColour |
| int | matrixSelection |
| uint | currInitRow |
| uint | currDispRow |
| uint | currVarRow |
| QMap< CmdInstance *, VarCmdInfo > | varCmdInfoMap |
| QMap< VarInstance *, CmdInstance * > | varToCmdInstMap |
| QPtrList< VarInstance > | orderedVarList |
| QMap< QString, VarInstance * > | uniqueVarNames |
| QPtrList< CmdTreeNode > * | allCmdTrees |
| QPtrList< CmdTreeNode > * | initTrees |
| QPtrList< CmdTreeNode > * | dispTrees |
| CmdSelector * | myCmdSelector |
| bool | filterCmdLists |
| bool | saveOptionsOnExit |
| bool | inStepperMode |
| int | stepperPos |
| int | oldStepperPos |
| GLScreenViewer * | screenView |
| GLWorldViewer * | worldView |
| GLScene * | scene |
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().
|
|
Default constructor. If filename is not empty, then Glitch will attempt to open it as the initial project. |
|
|
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. |
|
||||||||||||||||
|
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. |
|
|
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. |
|
|
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. |
|
|
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:
|
|
||||||||||||
|
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. |
|
|
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. |
|
|
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'). |
|
|
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. |
|
|
Open an existing project / tutorial |
|
|
Display the project properties dialog (modal). This is called by the menu item "File" -> "Properties...". |
|
|
Save the current project / tutorial |
|
|
Save the current project / tutorial to a new / different file |
|
|
Display the about dialog (modal). This is called by the menu item "Help" -> "About". |
|
|
Insert a new command row into the current table AFTER the current selection and select it. |
|
|
Attempt to load the option settings, using QSettings.
From the Qt documentation, regarding QSettings: 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). |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
||||||||||||||||
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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). |
|
|
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 |
|
|
Attempt to save the option settings, using QSettings. Please see Glitch::loadOptionSettings() for more information. |
|
|
Toggle the OpenGL screen space view to keep a 1:1 aspect ratio or not. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
When in the stepper mode, this will reset the state back to the start of the display commands list. |
|
|
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). |
|
|
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. |
|
|
Update the OpenGL scene dependents, such as stepper widgets and matrix values. |
|
|
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. |
|
||||||||||||
|
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. |
|
|
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. |
|
||||||||||||
|
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. |
|
|
Toggle whether or not the world view OpenGL viewer should show its Z / depth buffer instead of the normal output. |
|
|
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. |
|
|
Toggle the rendering of the axes (X, Y and Z) in the world view. |
|
|
Toggle the rendering of the projection frustum in the world view. |
|
|
Toggle the rendering of the grid on the Z=0 plane in the world view. |
|
|
Toggle whether or not the world view OpenGL viewer should use an orthographic projection for its camera, or a perspective one. |
|
|
Toggle whether or not the world view OpenGL viewer should use a perspective projection for its camera, or simply an orthographic one. |
|
|
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. |
|
|
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 ); |
|
|
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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.2