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

drv.cpp File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "iup.h"
#include "iupkey.h"
#include "iupgl.h"
#include "iupcontrols.h"
#include "prj.h"
#include "prm.h"

Include dependency graph for drv.cpp:

Go to the source code of this file.
Date:
21-Jun-2010
Author:
Luiz F. Martha
Version:
1.1
This file contains the driver function for the fourth assignment of course CIV 2802 - Sistemas Graficos para Engenharia - 2010.1. See documentation on class notes.

Revisions:

  • Version 1.0 by L.F. Martha on 07-Nov-2005: Initial version.
  • Version 1.1 by L.F. Martha on 21-Jun-2010: Updated for IUP 3.1: Replaced IupPopup( dlg, IUP_ANYWHERE, IUP_ANYWHERE ) by IupPopup( dlg, IUP_CURRENT, IUP_CURRENT ). Replaced IupOpen( ) by upOpen( &argc, &argv ).


static FILE * drvOpenFile (char *mode)
 This function prompts the user for a file name and opens the file.
static void drvResize (int width, int height, void *h)
 Callback function for canvas resize event (see VGL documentation).
static void drvRedisplay (void *h)
 Callback function for canvas redisplay event (see VGL documentation).
static void drvMouseBt (int bt, int mode, float x, float y, void *data)
 Callback function for mouse button event on canvas (see VGL documentation).
static void drvMouseMv (int bt, float x, float y, void *data)
 Callback function for mouse movement event on canvas (see VGL documentation).
static int drvSetHeightFac (Ihandle *val, double fac)
 Callback function for primitive height valuator event (see IUP documentation).
static int drvKeyCrtl (Ihandle *dg, int key)
 Callback function for keyboard event (see IUP documentation).
int main (int argc, char *argv[])
 This is the main driver of the program.
static Ihandle * Omain
 Main dialog handle.
static Ihandle * Otopmsg
 Handle to top message label.
static Ihandle * Oheightval
 Handle to height valuator.
static int cv_height
 canvas vertical size in pixels
static int cv_width
 canvas horizontal size in pixels
int doing_help = 0
 Flag for doing help.
static char file_name [256]
 String that holds the current opened file name.


Function Documentation

static int drvKeyCrtl Ihandle *  dg,
int  key
[static]
 

Callback function for keyboard event (see IUP documentation).

This function takes an appropriate action according to the given key that was pressed by the user and passed as a parameter.

Parameters:
dg - handle to IUP main dialog object (in)
key - pressed key identifier (in)
Returns:
IUP_DEFAULT value or IUP_CLOSE value (if key is CONTROL+Q)

Definition at line 291 of file drv.cpp.

References doing_help, drvOpenFile(), Prj::Fit(), Prj::Info(), Prj::ManipMode(), Prj::NavigMode(), Prj::OpenModel(), Prj::Ortho(), Otopmsg, Prj::Persp(), Prj::ProjX(), Prj::ProjY(), Prj::ProjZ(), Prj::Quit(), Prj::ResetView(), Prj::vglcanvas, Prj::ZbufferSnapShot(), and Prj::ZoomMode().

Referenced by main().

static void drvMouseBt int  bt,
int  mode,
float  x,
float  y,
void *  data
[static]
 

Callback function for mouse button event on canvas (see VGL documentation).

Parameters:
bt - button identifier (in)
mode - mode (button pressed or released) (in)
x,y - mouse raster position (left-top origin) (in)
data - dummy data (not used) (in)

Definition at line 202 of file drv.cpp.

References cv_height, cv_width, doing_help, Prj::GetHeightFac(), Oheightval, Otopmsg, Prj::Raster2WorldXY(), and Prj::SelectPrm().

Referenced by main().

static void drvMouseMv int  bt,
float  x,
float  y,
void *  data
[static]
 

Callback function for mouse movement event on canvas (see VGL documentation).

In this implementation it does nothing.

Parameters:
bt - button identifier (in)
x,y - mouse raster position (left-top origin) (in)
data - dummy data (not used) (in)

Definition at line 247 of file drv.cpp.

Referenced by main().

static FILE* drvOpenFile char *  mode  )  [static]
 

This function prompts the user for a file name and opens the file.

Parameters:
mode - reading ("r") or writing ("w") mode (in)
Returns:
Pointer to opened file

Definition at line 88 of file drv.cpp.

References file_name.

Referenced by drvKeyCrtl().

static void drvRedisplay void *  h  )  [static]
 

Callback function for canvas redisplay event (see VGL documentation).

It redisplays the model or the help message on the canvas.

Parameters:
h - dummy handle (not used) (in)

Definition at line 175 of file drv.cpp.

References doing_help, Prm::First(), Prj::Help(), Otopmsg, and Prj::Redisplay().

Referenced by main().

static void drvResize int  width,
int  height,
void *  h
[static]
 

Callback function for canvas resize event (see VGL documentation).

It changes the visualization parameters according to the given canvas sizes.

Parameters:
width - new canvas width (in)
height - new canvas height (in)
h - dummy handle (not used) (in)

Definition at line 159 of file drv.cpp.

References cv_height, cv_width, Prj::Odatascreen, and Prj::Resize().

Referenced by main().

static int drvSetHeightFac Ihandle *  val,
double  fac
[static]
 

Callback function for primitive height valuator event (see IUP documentation).

This function sets the new value for the current selected primitive height according to the given height factor.

Parameters:
val - handle to IUP primitive height valuator (in)
fac - new valuator factor value (in)
Returns:
IUP_DEFAULT value

Definition at line 272 of file drv.cpp.

References Prj::SetHeightFac().

Referenced by main().

int main int  argc,
char *  argv[]
 

This is the main driver of the program.

The program launches an user interface window on the screen and waits for an user action.

Parameters:
argc - number of arguments (not used) (in)
argv - list of string arguments (not used) (in)
Returns:
Program status: success (0) or failure (1)

Definition at line 403 of file drv.cpp.

References drvKeyCrtl(), drvMouseBt(), drvMouseMv(), drvRedisplay(), drvResize(), drvSetHeightFac(), Prj::Init(), Prj::Odatascreen, Oheightval, Omain, Otopmsg, and Prj::vglcanvas.


Variable Documentation

int cv_height [static]
 

canvas vertical size in pixels

Definition at line 64 of file drv.cpp.

Referenced by drvMouseBt(), and drvResize().

int cv_width [static]
 

canvas horizontal size in pixels

Definition at line 66 of file drv.cpp.

Referenced by drvMouseBt(), and drvResize().

int doing_help = 0
 

Flag for doing help.

Definition at line 68 of file drv.cpp.

Referenced by drvKeyCrtl(), drvMouseBt(), and drvRedisplay().

char file_name[256] [static]
 

String that holds the current opened file name.

Definition at line 70 of file drv.cpp.

Referenced by drvOpenFile().

Ihandle* Oheightval [static]
 

Handle to height valuator.

Definition at line 62 of file drv.cpp.

Referenced by drvMouseBt(), and main().

Ihandle* Omain [static]
 

Main dialog handle.

Definition at line 58 of file drv.cpp.

Referenced by main().

Ihandle* Otopmsg [static]
 

Handle to top message label.

Definition at line 60 of file drv.cpp.

Referenced by drvKeyCrtl(), drvMouseBt(), drvRedisplay(), and main().


Generated on Mon Jun 21 12:45:13 2010 for Trab4 by  doxygen 1.4.2-20050421