Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

drv.c 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.c:

Include dependency graph

Go to the source code of this file.

Project driver module.

Date:
07-Nov-2005
Author:
Luiz F. Martha
Version:
1.0
This file contains the driver function for the third assignment of course CIV 2801 - Fundamentos de Computacao Grafica Aplicada - 2005.2. See documentation on class notes.

Revisions:

  • Version 1.0 by L.F. Martha on 07-Nov-2005: Initial version.


FILE * drvOpenFile (char *mode)
 This function prompts the user for a file name and opens the file.

void drvResize (int width, int height, void *h)
 Callback function for canvas resize event (see VGL documentation).

void drvRedisplay (void *h)
 Callback function for canvas redisplay event (see VGL documentation).

void drvMouseBt (int bt, int mode, float x, float y, void *data)
 Callback function for mouse button event on canvas (see VGL documentation).

void drvMouseMv (int bt, float x, float y, void *data)
 Callback function for mouse movement event on canvas (see VGL documentation).

int drvSetHeightFac (Ihandle *val, double fac)
 Callback function for primitive height valuator event (see IUP documentation).

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.

Ihandle * Omain
 Main dialog handle.

Ihandle * Otopmsg
 Handle to top message label.

Ihandle * Oheightval
 Handle to height valuator.

int cv_height
 canvas vertical size in pixels

int cv_width
 canvas horizontal size in pixels

int doing_help = 0
 Flag for doing help.

char file_name [256]
 String that holds the current opened file name.


Function Documentation

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 286 of file drv.c.

References doing_help, drvOpenFile(), Otopmsg, prjFit(), prjInfo(), prjManipMode(), prjNavigMode(), prjOpenModel(), prjOrtho(), prjPersp(), prjProjX(), prjProjY(), prjProjZ(), prjQuit(), prjResetView(), prjZbufferSnapShot(), prjZoomMode(), and vglcanvas.

Referenced by main().

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 197 of file drv.c.

References cv_height, cv_width, doing_help, Oheightval, Otopmsg, prjGetHeightFac(), prjRaster2WorldXY(), and prjSelectPrm().

Referenced by main().

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 242 of file drv.c.

Referenced by main().

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 83 of file drv.c.

References file_name.

Referenced by drvKeyCrtl().

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 170 of file drv.c.

References doing_help, Otopmsg, prjHelp(), prjRedisplay(), and prmFirst().

Referenced by main().

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 154 of file drv.c.

References cv_height, cv_width, Odatascreen, and prjResize().

Referenced by main().

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 267 of file drv.c.

References prjSetHeightFac().

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 398 of file drv.c.

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


Variable Documentation

int cv_height [static]
 

canvas vertical size in pixels

Definition at line 59 of file drv.c.

Referenced by drvMouseBt(), and drvResize().

int cv_width [static]
 

canvas horizontal size in pixels

Definition at line 61 of file drv.c.

Referenced by drvMouseBt(), and drvResize().

int doing_help = 0
 

Flag for doing help.

Definition at line 63 of file drv.c.

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

char file_name[256] [static]
 

String that holds the current opened file name.

Definition at line 65 of file drv.c.

Referenced by drvOpenFile().

Ihandle* Oheightval [static]
 

Handle to height valuator.

Definition at line 57 of file drv.c.

Referenced by drvMouseBt(), and main().

Ihandle* Omain [static]
 

Main dialog handle.

Definition at line 53 of file drv.c.

Referenced by main().

Ihandle* Otopmsg [static]
 

Handle to top message label.

Definition at line 55 of file drv.c.

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


Generated on Tue Nov 8 10:58:02 2005 for Trab3 by doxygen1.2.18