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

prj.cpp

Go to the documentation of this file.
00001 /*
00002 ** ---------------------------------------------------------------
00003 ** prj.cpp - Project manager class.
00004 **
00005 ** ---------------------------------------------------------------
00006 */
00007 
00033 /*
00034 ** ---------------------------------------------------------------
00035 ** Global variables and symbols
00036 */
00037 #include <stdio.h>
00038 #include <stdlib.h>
00039 #include <string.h>
00040 
00041 #include "iup.h"
00042 #include "cd.h"
00043 #include "cdiup.h"
00044 #include "cddbuf.h"
00045 #include "prj.h"
00046 #include "dsp.h"
00047 #include "zbf.h"
00048 
00049 
00050 /*
00051 ** ---------------------------------------------------------------
00052 ** Initialization of class variables: 
00053 */
00054 
00057 Ihandle* Prj::Ozbufferdialog = NULL;
00058 
00061 cdCanvas* Prj::Gzbuffercanvas = NULL;
00062 
00065 cdCanvas* Prj::Dzbuffercanvas = NULL;
00066 
00069 int Prj::canvas_width = 400;
00070 int Prj::canvas_height = 400;
00071 
00072 /*
00073 ** ---------------------------------------------------------------
00074 ** Private class functions: 
00075 */
00076 
00077 /*====================  Prj::DspZbufferCanvas  =====================*/
00078 
00079 int Prj::DspZbufferCanvas( Ihandle* cv )
00080 {
00081  if( Dzbuffercanvas )
00082  {
00083   Zbf::Init( Dzbuffercanvas );
00084   Dsp::ZbfModel( Dzbuffercanvas );
00085   cdCanvasFlush( Dzbuffercanvas );
00086  }
00087  return( IUP_DEFAULT );
00088 }
00089 
00090 /*======================  Prj::DspRotateView  ======================*/
00091 
00092 int Prj::DspRotateView( void )
00093 {
00094  if( Dzbuffercanvas )
00095  {
00096   Dsp::RotateView( );
00097   Zbf::Init( Dzbuffercanvas );
00098   Dsp::ZbfModel( Dzbuffercanvas );
00099   cdCanvasFlush( Dzbuffercanvas );
00100  }
00101  return( IUP_DEFAULT );
00102 }
00103 
00104 /*
00105 ** ---------------------------------------------------------------
00106 ** Public class functions:
00107 **
00108 */
00109 
00110 /*==========================  Prj::Init  ============================*/
00111 
00112 void Prj::Init( void )
00113 {
00114  Ihandle  *Ozbuffercanvas;   /* IUP handle of zbuffer canvas */
00115  static char size_string[32];
00116 
00117  if( Gzbuffercanvas )
00118   cdKillCanvas( Gzbuffercanvas );
00119 
00120  if( Ozbufferdialog )
00121   IupDestroy( Ozbufferdialog );
00122 
00123 /* Create a CD canvas with default sizes.
00124  * Specifies function "Prj::DspZbufferCanvas" as the redisplay callback.
00125  */
00126  IupSetFunction( "Prj::DspZbufferCanvas", (Icallback)Prj::DspZbufferCanvas );
00127  Ozbuffercanvas = IupCanvas( "Prj::DspZbufferCanvas" );
00128  sprintf( size_string, "%dx%d", canvas_width, canvas_height );
00129  IupSetAttribute( Ozbuffercanvas, IUP_RASTERSIZE, size_string );
00130  IupSetAttribute( Ozbuffercanvas, IUP_SCROLLBAR, IUP_NO );
00131 
00132 /* Create a dialog for the canvas with no resize option.
00133  * Specifies function "Prj::DspRotateView" as the idle event callback.
00134  */
00135  Ozbufferdialog = IupDialog( Ozbuffercanvas );
00136  IupSetAttribute( Ozbufferdialog, IUP_MAXBOX, IUP_NO );
00137  IupSetAttribute( Ozbufferdialog, IUP_MINBOX, IUP_NO );
00138  IupSetAttribute( Ozbufferdialog, IUP_RESIZE, IUP_NO );
00139  IupSetAttribute( Ozbufferdialog, IUP_TITLE,  "Zbuffer Canvas" );
00140  IupSetFunction( IUP_IDLE_ACTION, (Icallback)Prj::DspRotateView );
00141  IupMap( Ozbufferdialog );
00142 
00143 /* Create a CD canvas for displaying and double buffer.
00144  */
00145  Gzbuffercanvas = cdCreateCanvas( CD_IUP, Ozbuffercanvas );
00146  Dzbuffercanvas = cdCreateCanvas( CD_DBUFFER, Gzbuffercanvas );
00147 
00148 /* Setup initial display parameters.
00149  */
00150  Dsp::SetupView( Dzbuffercanvas );
00151 
00152 /* Launch dialog.
00153  */
00154  IupShow( Ozbufferdialog );
00155 }
00156 
00157 /*===========================  Prj::Quit  ===========================*/
00158 
00159 void Prj::Quit( void )
00160 {
00161  if( Dzbuffercanvas )
00162   cdKillCanvas( Dzbuffercanvas );
00163 
00164  if( Gzbuffercanvas )
00165   cdKillCanvas( Gzbuffercanvas );
00166 
00167  if( Ozbufferdialog )
00168   IupDestroy( Ozbufferdialog );
00169 }
00170 

Generated on Mon Jun 20 18:09:52 2011 for Trab8 by  doxygen 1.4.2-20050421