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

prj.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "iup.h"
#include "cd.h"
#include "cdiup.h"
#include "prj.h"
#include "prm.h"
#include "prmio.h"
#include "dsp.h"
#include "zbf.h"

Include dependency graph for prj.c:

Include dependency graph

Go to the source code of this file.

Project manager module.

Date:
08-Nov-2005
Author:
Luiz F. Martha
Version:
1.0
This file contains project functions to visualize and manipulate polygonal primitives of a model.

See definitions of public data types and public functions in hearder file "prj.h".

See specification of primitive database in hearder file "prm.h".

See specification of primitive Input/Output functions in hearder file "prmio.h".

See specification of primitive display functions in hearder file "dsp.h".

See specification of visualization manipulation functions in file "vgl.h".

Project specification: see class notes of course CIV-2801 "Fundamentos de Computacao Grafica Aplicada", period 2005.2.

Revisions:

  • Report modifications here (including name and date).


#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
void prjResetLocalParams (void)
 This function resets the values of the local variables in this module.

void prjBuildDisplayList (void)
 This function builds a display list of the current model.

PrmprjPckPrm (double x, double y)
 This function returns a pointer to a primitive that contains the given 2D point location.

int prjDspZbufferCanvas (Ihandle *cv)
 This is a callback redisplay function of canvas for displaying zbuffer snap shot image.

void prjInit (void)
 This function does everything is necessary to initialize the modeling and visualization part of this program.

void prjQuit (void)
 This function does everything is necessary to close the modeling and visualization part of this program.

void prjResize (int width, int height)
 This function initializes the display module as a result of of a canvas resize event.

void prjRedisplay (void)
 This function clears the main canvas and redisplays the model described in the current database.

void prjInfo (void)
 This function pops up a message dialog box with information about this program.

void prjHelp (void)
 This function calls a display function to display a help list of the possible program actions and their associated keys.

int prjOpenModel (FILE *fd)
 This function resets the current database, opens a new model data file, and creates the primitive data structure.

void prjZbufferSnapShot (void)
 This function opens a dialog containing only one canvas and creates a snap shot image of the current model.

int prjRaster2WorldXY (int x, int y, double *xw, double *yw)
 Given a mouse location point in raster canvas coordinates, this function returns the corresponding point in the XY plane in world coordinates.

int prjSelectPrm (double x, double y)
void prjSetHeightFac (double fac)
 This function sets the height of the currently selected primitive according to the given factor and the maximum allowable height (which is equal to the maximum size in the XY plane).

double prjGetHeightFac (void)
 This function returns the value of the primitive height factor.

void prjResetView (void)
 This function resets the projection of the visualization.

void prjFit (void)
 This function adjusts (fits) the current model on the screen.

void prjPersp (void)
 This function sets the current projection type to perspective (conic projection).

void prjOrtho (void)
 This function sets the current projection type to orthographic.

void prjProjX (void)
 This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane X = const.

void prjProjY (void)
 This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane Y = const.

void prjProjZ (void)
 This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane Y = const.

void prjManipMode (void)
 This function sets the mouse interaction mode to model manipulation (screen based visualization control).

void prjNavigMode (void)
 This function sets the mouse interaction mode to navigation (walk-through visualization control).

void prjZoomMode (void)
 This function sets the mouse interaction mode to zoom control.

char * trab_info
 String for project information text.

double max_height = 50.0
 Current primitive height limits.

Prmsel_prm = NULL
 Holds a pointer to the current selected primitive.

int list_updated = 0
 Flag for display list status.

Ihandle * Ozbufferdialog = NULL
 IUP handle of canvas for displaying zbuffer snap shot image.

cdCanvas * Gzbuffercanvas = NULL
 CD handle of canvas for displaying zbuffer snap shot image.


Defines

#define _PRJ_C


Define Documentation

#define _PRJ_C
 

Definition at line 7 of file prj.c.

#define MAX a,
     (((a) > (b)) ? (a) : (b))
 

Definition at line 71 of file prj.c.

Referenced by prjOpenModel(), and zbfMountEdges().


Function Documentation

void prjBuildDisplayList void    [static]
 

This function builds a display list of the current model.

Definition at line 136 of file prj.c.

References dspModel(), list_updated, and prmFirst().

Referenced by prjRedisplay(), prjSelectPrm(), and prjSetHeightFac().

int prjDspZbufferCanvas Ihandle *    cv [static]
 

This is a callback redisplay function of canvas for displaying zbuffer snap shot image.

Definition at line 172 of file prj.c.

References dspZbfModel(), and Gzbuffercanvas.

Referenced by prjZbufferSnapShot().

void prjFit void   
 

This function adjusts (fits) the current model on the screen.

That is, it keeps the current camera position and orientation parameters and resets the scaling such that the entire model fits on the screen.

Definition at line 436 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

double prjGetHeightFac void   
 

This function returns the value of the primitive height factor.

This factor is a ratio between the height of the currently selected primitive and the maximum allowable height (which is equal to the maximum size in the XY plane).

Returns:
The selected primitive height factor. If no primitive is selected, a null value is returned.

Definition at line 414 of file prj.c.

References max_height, prmFirst(), and prmGetHeight().

Referenced by drvMouseBt().

void prjHelp void   
 

This function calls a display function to display a help list of the possible program actions and their associated keys.

Definition at line 236 of file prj.c.

References dspHelp().

Referenced by drvRedisplay().

void prjInfo void   
 

This function pops up a message dialog box with information about this program.

Definition at line 229 of file prj.c.

References trab_info.

Referenced by drvKeyCrtl().

void prjInit void   
 

This function does everything is necessary to initialize the modeling and visualization part of this program.

Currently it is doing nothing.

Definition at line 187 of file prj.c.

Referenced by main().

void prjManipMode void   
 

This function sets the mouse interaction mode to model manipulation (screen based visualization control).

Definition at line 499 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

void prjNavigMode void   
 

This function sets the mouse interaction mode to navigation (walk-through visualization control).

Definition at line 506 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

int prjOpenModel FILE *    fd
 

This function resets the current database, opens a new model data file, and creates the primitive data structure.

The new model is displayed on the main canvas.

Parameters:
fd  - input file descritor (in)
Returns:
If there is an error while reading the input file, the function returns a false (0) status. Otherwise, it returns a true (1) status.

Definition at line 243 of file prj.c.

References MAX, max_height, prjPersp(), prjResetLocalParams(), prmDeleteList(), prmGetGlobalBox(), prmioInterpret(), and vglcanvas.

Referenced by drvKeyCrtl().

void prjOrtho void   
 

This function sets the current projection type to orthographic.

Definition at line 457 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

Prm* prjPckPrm double    x,
double    y
[static]
 

This function returns a pointer to a primitive that contains the given 2D point location.

If no primitive contains the given point, a null pointer is returned.

Definition at line 153 of file prj.c.

References prmFirst(), prmNext(), and prmPickArea().

Referenced by prjSelectPrm().

void prjPersp void   
 

This function sets the current projection type to perspective (conic projection).

Definition at line 444 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl(), and prjOpenModel().

void prjProjX void   
 

This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane X = const.

Definition at line 466 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

void prjProjY void   
 

This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane Y = const.

Definition at line 477 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

void prjProjZ void   
 

This function sets the current projection type to orthographic (cylinder projection) and specifies the camera paramaters such that the projection plane is parallel to plane Y = const.

Definition at line 488 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

void prjQuit void   
 

This function does everything is necessary to close the modeling and visualization part of this program.

Definition at line 193 of file prj.c.

References Gzbuffercanvas, Ozbufferdialog, and prmDeleteList().

Referenced by drvKeyCrtl().

int prjRaster2WorldXY int    x,
int    y,
double *    xw,
double *    yw
 

Given a mouse location point in raster canvas coordinates, this function returns the corresponding point in the XY plane in world coordinates.

The point is found by the intersection of the pick ray with the plane z=0. A pick ray is a line between a point on the front (near) plane and a point on the back (far) plane. These two points correspond to the given point location in raster coordinates. If the ray is parallel to the z=0 plane, a false (0) status is returned.

Parameters:
fd  - input file descritor (in)
x  - x coord. of raster point on canvas (in)
y  - y coord. of raster point on canvas (in)
xw  - x coord. of point location in XY plane (out)
yw  - y coord. of point location in XY plane (out)
Returns:
If the intersection point is not between the two pick ray end points, a false (0) status is returned. Otherwise, a true (1) status is returned.

Definition at line 336 of file prj.c.

References dspGetPickRay().

Referenced by drvMouseBt().

void prjRedisplay void   
 

This function clears the main canvas and redisplays the model described in the current database.

Definition at line 213 of file prj.c.

References list_updated, Odatascreen, and prjBuildDisplayList().

Referenced by drvRedisplay().

void prjResetLocalParams void    [static]
 

This function resets the values of the local variables in this module.

Definition at line 125 of file prj.c.

References list_updated, and max_height.

Referenced by prjOpenModel().

void prjResetView void   
 

This function resets the projection of the visualization.

That is, it resets the camera parameters.

Definition at line 428 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().

void prjResize int    width,
int    height
 

This function initializes the display module as a result of of a canvas resize event.

Parameters:
width  - new canvas width in pixels (not used) (in)
height  - new canvas height in pixels (not used) (in)

Definition at line 206 of file prj.c.

References dspInit().

Referenced by drvResize().

int prjSelectPrm double    x,
double    y
 

Definition at line 362 of file prj.c.

References prjBuildDisplayList(), prjPckPrm(), prmSelect(), and prmUnselectAll().

Referenced by drvMouseBt().

void prjSetHeightFac double    fac
 

This function sets the height of the currently selected primitive according to the given factor and the maximum allowable height (which is equal to the maximum size in the XY plane).

Nothing will happen if no primitive is selected.

Parameters:
fac  - height factor (between 0 and 1) (in)

Definition at line 388 of file prj.c.

References max_height, prjBuildDisplayList(), prmFirst(), prmSetHeight(), and vglcanvas.

Referenced by drvSetHeightFac().

void prjZbufferSnapShot void   
 

This function opens a dialog containing only one canvas and creates a snap shot image of the current model.

The image is created using the z-buffer algorithm and the CD (Canvas Draw) 2D graphics system. The current visualization parameters for camera and view volume specification are adopted.

Definition at line 284 of file prj.c.

References Gzbuffercanvas, Ozbufferdialog, prjDspZbufferCanvas(), prmFirst(), and zbfInit().

Referenced by drvKeyCrtl().

void prjZoomMode void   
 

This function sets the mouse interaction mode to zoom control.

A single zoom rectangle is defined, returning the the previous interation mode.

Definition at line 513 of file prj.c.

References vglcanvas.

Referenced by drvKeyCrtl().


Variable Documentation

cdCanvas* Gzbuffercanvas = NULL [static]
 

CD handle of canvas for displaying zbuffer snap shot image.

Definition at line 112 of file prj.c.

Referenced by prjDspZbufferCanvas(), prjQuit(), and prjZbufferSnapShot().

int list_updated = 0 [static]
 

Flag for display list status.

Definition at line 104 of file prj.c.

Referenced by prjBuildDisplayList(), prjRedisplay(), and prjResetLocalParams().

double max_height = 50.0 [static]
 

Current primitive height limits.

Definition at line 95 of file prj.c.

Referenced by prjGetHeightFac(), prjOpenModel(), prjResetLocalParams(), and prjSetHeightFac().

Ihandle* Ozbufferdialog = NULL [static]
 

IUP handle of canvas for displaying zbuffer snap shot image.

Definition at line 108 of file prj.c.

Referenced by prjQuit(), and prjZbufferSnapShot().

Prm* sel_prm = NULL [static]
 

Holds a pointer to the current selected primitive.

A null value means that no primitive is selected.

Definition at line 100 of file prj.c.

char* trab_info [static]
 

Initial value:

   {
    "\n"
    "\n"
    "                   CIV-2801  -- 2005.2               \n"
    "\n"
    "      Fundamentos de Computacao Grafica Aplicada     \n"
    "\n"
    "           Departamento de Engenharia Civil          \n"
    "                        PUC-Rio                      \n"
    "\n"
    "            Trabalho No.: 3                          \n"
    "            Aluno:       \n"
    "            Data:        \n"
    "\n"
   }
String for project information text.

Definition at line 76 of file prj.c.

Referenced by prjInfo().


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