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

glitch.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  File:    glitch.h
00004  Created: by Aidan Lane, November 19, 2003
00005  Updated: by Aidan Lane, February 23, 2004
00006  
00007  This file is part of Glitch
00008  Copyright (C) 2003-2004  Monash University, Clayton Campus, Australia
00009  Created by Aidan Lane, under the supervision of Jon McCormack.
00010  
00011  This program was developed to aid the students studying the CSE3313
00012  Computer Graphics course at Monash University.
00013  
00014  This software may contain portions that are copyright (C) 1993,
00015  Silicon Graphics, Inc. All Rights Reserved.
00016  
00017  Glitch is free software; you can redistribute it and/or modify
00018  it under the terms of the GNU General Public License as published by
00019  the Free Software Foundation, version 2.
00020  
00021  Glitch is distributed in the hope that it will be useful,
00022  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  GNU General Public License for more details.
00025  
00026  You should have received a copy of the GNU General Public License
00027  along with this program; if not, write to the Free Software
00028  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00029 
00030 *****************************************************************************/
00031 
00032 #ifndef __GLITCH_H__
00033 #define __GLITCH_H__
00034 
00035 
00036 #include <qwidget.h>
00037 #include <qptrlist.h>
00038 #include <qvaluelist.h>
00039 #include <qmap.h>
00040 
00041 #include "mainwindow.h"
00042 #include "glscreenviewer.h"
00043 #include "glworldviewer.h"
00044 #include "glscene.h"
00045 #include "supertable.h"
00046 #include "cmdinstance.h"
00047 #include "varinstance.h"
00048 #include "glproject.h"
00049 #include "cmdtreenode.h"
00050 
00051 
00052 #include "mainpage.h" // Doxygen Main Page
00053 
00054 
00064 class Glitch : public MainWindow
00065 {
00066     Q_OBJECT    // make QT's signal/slot system work
00067 
00068     struct VarCmdInfo {
00069         const CmdTreeNode* cmd;
00070         QPtrList<VarInstance> vars;
00071     };
00072 
00073 public:
00074     Glitch( QString filename = QString::null );
00075     ~Glitch();
00076 
00077 private slots:
00078     virtual void cmdTableCurrentChanged( int row, int );
00079     virtual void insertCommand();
00080     virtual void removeCommand();
00081     virtual void moveCmdUp();
00082     virtual void moveCmdDown();
00083 
00084     virtual void cmdListTabChanged( QWidget* w );
00085 
00086     virtual void varTableCurrentChanged( int row, int );
00087 
00088     virtual void cmdInstanceUpdated( CmdInstance* instance );
00089 
00090     virtual void fileNew();
00091     virtual void fileOpen();
00092     virtual void fileSave();
00093     virtual void fileSaveAs();
00094     virtual void fileProperties();
00095     virtual void worldViewResetCamera();
00096     virtual void worldViewDrawAxes( bool enable );
00097     virtual void worldViewDrawGrid( bool enable );
00098     virtual void worldViewDrawFrustum( bool enable );
00099     virtual void worldViewDoubleBuffer( bool enable );
00100     virtual void worldViewDisplayZBuffer( bool enable );
00101     virtual void worldViewOrthoProjection( bool enable );
00102     virtual void worldViewPerspectiveProjection( bool enable );
00103     virtual void worldViewSetForegroundColour();
00104     virtual void worldViewSetBackgroundColour();
00105     virtual void screenViewKeepAspectRatio( bool enable );
00106     virtual void optionsRestoreOpenGLContexts();
00107     virtual void optionsAutoGLClear( bool enable );
00108     virtual void optionsAutoGLFlush( bool enable );
00109     virtual void optionsAutoGLEnd( bool enable );
00110     virtual void optionsFilterCmdLists( bool enable );
00111     virtual void optionsFullScreen( bool enable );
00112     virtual void optionsSaveOptionsOnExit( bool enable );
00113     virtual void optionsRestoreDefaults();
00114     virtual void helpAbout();
00115 
00116     virtual void stepDisplay( bool enable );
00117     virtual void stepperReset();
00118     virtual void stepperPrev();
00119     virtual void stepperNext();
00120     virtual void matrixSelectionClicked( int id );
00121 
00122     virtual void closeEvent( QCloseEvent* e );
00123 
00124     virtual void varInstanceCreated( CmdInstance* instance, VarInstance* varInst );
00125     virtual void varInstanceDestroyedCleanup( QObject* obj );
00126     
00127     virtual void updateSceneDependents();
00128 
00129 private:
00130     void constructCmdTrees();
00131     inline void appendTree( QPtrList<CmdTreeNode>* to,
00132         QPtrList<CmdTreeNode>* trees, const QString& name );
00133 
00134     void loadOptionSettings();
00135     void saveOptionSettings();
00136     
00137     bool openProject( const QString& filename );
00138     bool saveCurrentProject( const QString& filename );
00139 
00140     void moveCommand( int tabIndex, int fromPos, int toPos );
00141 
00142     void updateStepperWidgets();
00143     void updateMatrixValues( bool clearValuesInstead=false );
00144 
00145     void updateCmdInstanceVars( CmdInstance* instance );
00146 
00147     bool makeVarNameUnique( VarInstance* varInst );
00148     QString doubleToStr( double n ) const;
00149 
00150     #if defined(Q_OS_MACX)
00151     void tweekMacMenus();
00152     #endif  // defined(Q_OS_MACX)
00153 
00154     GLProject* project;
00155 
00156     bool unsavedChangesExist;
00157 
00158     QPtrList<SuperTable> tabTables; // enables the simplfication of code
00159                                     // 3 values - varsTable, initCmdsTable
00160                                     //            and dispCmdsTable
00161 
00162     QColor varSelectedColour;
00163     QColor cmdSelectedColour;
00164     QColor cmdStepPosColour;
00165 
00166     int matrixSelection;    // carries the ID/index of the which radio-button
00167 
00168     uint currInitRow;
00169     uint currDispRow;
00170     uint currVarRow;
00171 
00172     /* The following variables / objects are used to MANAGE variable instances
00173      * (note that only CmdInstances can OWN them).
00174      * It may seem stupid to have so much redundancy, but they are all used,
00175      * as they enable fast-lookups throughout the program, where they will be
00176      * called upon often.
00177      * There purposes are detailed below:
00178      */
00179     // Command instance -> command info (cmd tree node & its variable instances)
00180     QMap<CmdInstance*, VarCmdInfo> varCmdInfoMap;
00181     // Fast-lookup: variable instance -> command instance owner
00182     QMap<VarInstance*, CmdInstance*> varToCmdInstMap;
00183     // Used to find the table row of a variable instance (a .find(x) is used on it)
00184     QPtrList<VarInstance> orderedVarList;
00185     // Fast-lookup: variable instance NAME -> variable instance (reverse also used)
00186     QMap<QString, VarInstance*> uniqueVarNames;
00187 
00188     // the following are used to build the command trees
00189     QPtrList<CmdTreeNode>* allCmdTrees;
00190     QPtrList<CmdTreeNode>* initTrees;
00191     QPtrList<CmdTreeNode>* dispTrees;
00192 
00193     // The command selector pop-up widget - used by the editor
00194     CmdSelector* myCmdSelector;
00195 
00196     bool filterCmdLists;
00197     bool saveOptionsOnExit;
00198 
00199     // Variables that are used to manage the display stepper
00200     bool inStepperMode;
00201     int stepperPos;
00202     int oldStepperPos;
00203 
00204     GLScreenViewer* screenView;
00205     GLWorldViewer* worldView;
00206 
00207     GLScene* scene;
00208 };
00209 
00210 
00211 #endif  // __GLITCH_H__

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2