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

PrmEd Class Reference

#include <prmed.h>

Collaboration diagram for PrmEd:

[legend]
List of all members.
Date:
15-May-2011
Author:
Luiz F. Martha
Version:
1.0
This file contains class for interactive creation and manipulation of primitives.

See class specification in hearder file "prmed.h".

For specification see class notes of course CIV-2802 "Sistemas Graficos para Engenharia", period 2011.1.

Revisions:

  • Version 1.0 by L.F. Martha on 15-May-2011: Initial version. Stolen from Trab3 of CIV2802-2010.1 and modified.


static void InitParams (cdCanvas *canvas, Dsp *display)
 This function initialize the values of the local paramaters of the primitive edition module.
static void ResetParams (void)
 This function resets the values of the local paramaters of the primitive edition module.
static void SetCurType (Prm::Type type)
 This function specifies the type of the new primitives to be inserted.
static void UnselectAllPrm (void)
 This function unselects all primitives and resets the local pointer to the selected primitive.
static void InsertPrm1stPt (double x, double y, double tol)
 This function and the next two functions below are used to interactively insert a new primitive in the current model.
static void EchoPrm2ndPt (double x, double y)
 This function should be called when there is an event of mouse-move during an interactive creation of a primitive.
static void InsertPrm2ndPt (double x, double y)
 This function should be called when there is an event of button-release during an interactive creation of a primitive.
static void SelectDragPrm (double x, double y, double tol)
 This function and the two functions below are used to select a primitive and to interactively manipulate its position or shape.
static void UpdateDragPrm (double x, double y)
 This function should be called when there is an event of mouse-move, while the mouse button is pressed, during an interactive manipulation of a primitive.
static void FinishDragPrm (double x, double y)
 This function should be called when there is an event of mouse button-release at the end of an interactive manipulation of a primitive.
static void DeleteSelPrm (void)
 This function deletes a currently selected primitive, eliminating it from the list of primitives.
static void MoveSelPrmToFront (void)
 This function moves a currently selected primitive to the front of the list of primitives.
static void MoveSelPrmToBack (void)
 This function moves a currently selected primitive to the front of the list of primitives.
static double GetTolerance (void)
 This function returns the current tolerance value to be used in primitive edition.
static void SetColor (long int color)
 This function sets the color of the currently selected primitive and stores the given color as the current one for the next primitives to be created.
static long int GetColor (void)
 This function returns the current color used for the next primitives to be created.
static void SetMaxHeight (double height)
 This function sets the maximum primitive height of the entire model.
static void SetHeightFac (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).
static double GetHeightFac (void)
 This function returns the value of the currently selected primitive height factor.
static void DspTmpPrmLines (void)
 This function displays in XOR mode the boundary lines of the primitive being interactively created or of the current selected primitive being manipulated.
static cdCanvas * Gdatascreen = 0L
 CD handle to data canvas.
static Dspdsp = 0L
 Current display module.
static long int curr_color = Dsp::WHITE
 Current display color.
static double coord_tol = 0.001
 Coordinate tolerance value.
static Prm::Coord first_mousept = { 0.0, 0.0 }
 First mouse position for a button-press-mouse-move-button-up event.
static int mouse_has_moved = 0
 Flag to indicate that mouse has moved since the first mouse position.
static Prm::Coord curr_mousept = { 0.0, 0.0 }
 Current mouse position for a mouse-move event.
static Prmsel_prm = 0L
 Varialble that holds a pointer to the current selected primitive.
static int sel_vert = -1
 Variable that holds an index of the current selected primitive vertex.
static int sel_side = -1
 Variable that holds an index of the current selected primitive side.
static Prm::Type prm_type = Prm::PRM_QUAD
 Current primitive type to be attributed to new primitives to be inserted.
static double max_height = 50.0
 Maximum primitive height value (used only in 3D).

Member Function Documentation

void PrmEd::DeleteSelPrm void   )  [static]
 

This function deletes a currently selected primitive, eliminating it from the list of primitives.

Nothing will happen if the current list is empty or if no primitive is currently selected. It redisplays the entire model.

Definition at line 461 of file prmed.cpp.

References Prm::ChkEmptyModel(), and sel_prm.

Referenced by Model::DeleteSelPrm().

void PrmEd::DspTmpPrmLines void   )  [static, private]
 

This function displays in XOR mode the boundary lines of the primitive being interactively created or of the current selected primitive being manipulated.

Definition at line 108 of file prmed.cpp.

References Prm::DisplayBoundary(), dsp, Gdatascreen, sel_prm, and Dsp::XorMode().

Referenced by EchoPrm2ndPt(), and UpdateDragPrm().

void PrmEd::EchoPrm2ndPt double  x,
double  y
[static]
 

This function should be called when there is an event of mouse-move during an interactive creation of a primitive.

Its main objective is to display the boundary of the primitive being created. The primitive geometry is defined temporarely by the mouse location at button-press (specified through a call to function prmedInsertPrm1stPt above) an by the given mouse point location.

Parameters:
x - x coordinate of current mouse location (in)
y - y coordinate of current mouse location (in)

Definition at line 217 of file prmed.cpp.

References Prj::ABS(), curr_mousept, DspTmpPrmLines(), mouse_has_moved, sel_prm, Prm::Set2ndPt(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::EchoPrm2ndPt().

void PrmEd::FinishDragPrm double  x,
double  y
[static]
 

This function should be called when there is an event of mouse button-release at the end of an interactive manipulation of a primitive.

The translation parameters used to drag the entire primitive, or one of its vertex or side, are computed based on the given point location. The manipulated primitive is maintained selected, which means that it will appear highlighted when the model is redisplayed at the end of this function.

Parameters:
x - x coordinate of final mouse location (in)
y - y coordinate of final mouse location (in)

Definition at line 426 of file prmed.cpp.

References Prm::ChkEmptyModel(), curr_mousept, sel_prm, sel_side, sel_vert, Prm::Translate(), Prm::TranslateSide(), Prm::TranslateVertex(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::FinishDragPrm().

long int PrmEd::GetColor void   )  [static]
 

This function returns the current color used for the next primitives to be created.

The color is given by a long integer with a coded RGB color (adopted in the CD graphics system).

Definition at line 519 of file prmed.cpp.

References curr_color.

Referenced by Model::GetColor().

double PrmEd::GetHeightFac void   )  [static]
 

This function returns the value of the currently selected primitive height factor.

This factor is a ratio between the height of the selected primitive and the maximum allowable height (which is equal to the maximum size in the XY plane). If no primitive is selected, a null value is returned. The function is only used in 3D.

Returns:
Current height factor (between 0 and 1)

Definition at line 557 of file prmed.cpp.

References Prm::ChkEmptyModel(), Prm::GetHeight(), max_height, and sel_prm.

Referenced by Model::GetHeightFac().

double PrmEd::GetTolerance void   )  [static]
 

This function returns the current tolerance value to be used in primitive edition.

Definition at line 492 of file prmed.cpp.

References coord_tol.

Referenced by Circ::TranslateVertex().

void PrmEd::InitParams cdCanvas *  canvas,
Dsp display
[static]
 

This function initialize the values of the local paramaters of the primitive edition module.

It also stores the handle to the current CD data canvas and the pointer to the current display object.

Parameters:
canvas - CD handle to data canvas (in)
display - display module identifier (in)

Definition at line 125 of file prmed.cpp.

References dsp, Gdatascreen, and ResetParams().

Referenced by Model::Model().

void PrmEd::InsertPrm1stPt double  x,
double  y,
double  tol
[static]
 

This function and the next two functions below are used to interactively insert a new primitive in the current model.

The present one should be called to setup the module for the creation of a new primitive and to insert the first primitive vertex. This function should be called when there is an event of mouse button-press during an interactive creation of a primitive. The location where this event occur is the position of the first vertex of the new primitive. This function unselects all primitives and redisplays the current model. The current color, which is specified in function SetColor below, is attributed to the new primitive. A null height is set to the new primitive. The primitive is added to the front of the list of primitives. The primitive is selected, which means that it will appear highlighted when the model is redisplayed at the end of this button-press-mouse-move-button-release interaction.

Parameters:
x - x coordinate of first primitive vertex (in)
y - y coordinate of first primitive vertex (in)
tol - tolerance value to check point proximity (in)

Definition at line 172 of file prmed.cpp.

References coord_tol, curr_color, curr_mousept, first_mousept, mouse_has_moved, Prm::PRM_CIRC, Prm::PRM_QUAD, prm_type, sel_prm, Prm::Select(), Prm::Set1stPt(), Prm::SetColor(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::InsertPrm1stPt().

void PrmEd::InsertPrm2ndPt double  x,
double  y
[static]
 

This function should be called when there is an event of button-release during an interactive creation of a primitive.

Its main objective is to finish up the creating of the primitive. The primitive geometry is defined by the mouse location at button-press (specified through a call to function prmedInsertPrm1stPt above) an by the given mouse point location.

Parameters:
x - x coordinate of first primitive vertex (in)
y - y coordinate of first primitive vertex (in)

Definition at line 267 of file prmed.cpp.

References Prj::ABS(), coord_tol, first_mousept, sel_prm, Prm::Set2ndPt(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::InsertPrm2ndPt().

void PrmEd::MoveSelPrmToBack void   )  [static]
 

This function moves a currently selected primitive to the front of the list of primitives.

Nothing will happen if the current list is empty or if no primitive is currently selected. It redisplays the entire model.

Definition at line 482 of file prmed.cpp.

References Prm::ChkEmptyModel(), Prm::MoveBack(), and sel_prm.

Referenced by Model::MoveSelPrmToBack().

void PrmEd::MoveSelPrmToFront void   )  [static]
 

This function moves a currently selected primitive to the front of the list of primitives.

Nothing will happen if the current list is empty or if no primitive is currently selected. It redisplays the entire model.

Definition at line 472 of file prmed.cpp.

References Prm::ChkEmptyModel(), Prm::MoveFront(), and sel_prm.

Referenced by Model::MoveSelPrmToFront().

void PrmEd::ResetParams void   )  [static]
 

This function resets the values of the local paramaters of the primitive edition module.

Definition at line 134 of file prmed.cpp.

References coord_tol, curr_color, max_height, mouse_has_moved, Prm::PRM_QUAD, prm_type, sel_prm, sel_side, sel_vert, and Dsp::WHITE.

Referenced by InitParams(), Model::Open(), and Model::Reset().

void PrmEd::SelectDragPrm double  x,
double  y,
double  tol
[static]
 

This function and the two functions below are used to select a primitive and to interactively manipulate its position or shape.

The present one should be called when there is an event of mouse button-press. The location where this event occur is used to select the target primitive to manipulate. This location is also used to select a vertex or a side of the primitive. The selection searches a primitive starting from the front to the back of the list of primitives. Three types of primitive manipulation can occur:

  • Vertex dragging, in case one of the vertices of the selected primitive is found close to the given point location.
  • Side dragging, in case no vertex is found and one of the sides of the selected primitive is found close to the given point location.
  • Entire primitive dragging, in case no vertex or side of the selected primitive is found, or there is no selected primitive, and the given point location is inside the target primitive.

This function may be used just for selection of a primitive. This occurs when there is no mouse-move after the button-press event. In this case, the button-release mouse position is the same as the button-press mouse position. After selecting a primitive, or one of its vertex or side, the function stores the first mouse point position in a local variable so that it can be used by the two next functions. It also redisplays the entire model so that the selected primitive will appear highlighted. This function may also be used to unselect all the primitives, in case no primitive is selected at the given point location.

Parameters:
x - x coord. of location on target primitive (in)
y - y coord. of location on target primitive (in)
tol - tolerance value to check point proximity (in)

Definition at line 302 of file prmed.cpp.

References Prm::ChkEmptyModel(), coord_tol, curr_mousept, Prm::First(), first_mousept, mouse_has_moved, Prm::Next(), Prm::PickArea(), Prm::PickSide(), Prm::PickVertex(), sel_prm, sel_side, sel_vert, Prm::Select(), Prm::UnselectAll(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::SelectDragPrm().

void PrmEd::SetColor long int  color  )  [static]
 

This function sets the color of the currently selected primitive and stores the given color as the current one for the next primitives to be created.

The color is given by a long integer with a coded RGB color (adopted in the CD graphics system). If there is one primitive selected, it changes the color of this primitive and redisplays the entire model.

Parameters:
color - coded RGB color (in)

Definition at line 499 of file prmed.cpp.

References Prm::ChkEmptyModel(), curr_color, sel_prm, and Prm::SetColor().

Referenced by Model::SetColor().

void PrmEd::SetCurType Prm::Type  type  )  [static]
 

This function specifies the type of the new primitives to be inserted.

Parameters:
type - code for type of primitive to be inserted(in)

Definition at line 148 of file prmed.cpp.

References Prm::PRM_CIRC, Prm::PRM_QUAD, and prm_type.

Referenced by Model::SetPrmType().

void PrmEd::SetHeightFac double  fac  )  [static]
 

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).

It redisplays the entire model. Nothing will happen if no primitive is selected. The function is only used in 3D.

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

Definition at line 536 of file prmed.cpp.

References Prm::ChkEmptyModel(), max_height, sel_prm, and Prm::SetHeight().

Referenced by Model::SetHeightFac().

void PrmEd::SetMaxHeight double  height  )  [static]
 

This function sets the maximum primitive height of the entire model.

The function is only used in 3D.

Parameters:
height - maximum primitive height (in)

Definition at line 526 of file prmed.cpp.

References coord_tol, and max_height.

Referenced by Model::Open().

void PrmEd::UnselectAllPrm void   )  [static]
 

This function unselects all primitives and resets the local pointer to the selected primitive.

Definition at line 164 of file prmed.cpp.

References sel_prm, and Prm::UnselectAll().

Referenced by Model::UnselectAllPrm().

void PrmEd::UpdateDragPrm double  x,
double  y
[static]
 

This function should be called when there is an event of mouse-move, while the mouse button is pressed, during an interactive manipulation of a primitive.

Its main objective is to display the boundary lines representing the transformed primitive. The translation parameters used to drag the entire primitive, or one of its vertex or side, are computed based on the given point location.

Parameters:
x - x coordinate of current mouse location (in)
y - y coordinate of current mouse location (in)

Definition at line 367 of file prmed.cpp.

References Prj::ABS(), Prm::ChkEmptyModel(), curr_mousept, DspTmpPrmLines(), mouse_has_moved, sel_prm, sel_side, sel_vert, Prm::Translate(), Prm::TranslateSide(), Prm::TranslateVertex(), Prm::Coord::x, and Prm::Coord::y.

Referenced by Model::UpdateDragPrm().


Member Data Documentation

double PrmEd::coord_tol = 0.001 [static, private]
 

Coordinate tolerance value.

Definition at line 63 of file prmed.cpp.

Referenced by GetTolerance(), InsertPrm1stPt(), InsertPrm2ndPt(), ResetParams(), SelectDragPrm(), and SetMaxHeight().

long int PrmEd::curr_color = Dsp::WHITE [static, private]
 

Current display color.

Definition at line 59 of file prmed.cpp.

Referenced by GetColor(), InsertPrm1stPt(), ResetParams(), and SetColor().

Prm::Coord PrmEd::curr_mousept = { 0.0, 0.0 } [static, private]
 

Current mouse position for a mouse-move event.

Definition at line 75 of file prmed.cpp.

Referenced by EchoPrm2ndPt(), FinishDragPrm(), InsertPrm1stPt(), SelectDragPrm(), and UpdateDragPrm().

Dsp * PrmEd::dsp = 0L [static, private]
 

Current display module.

Definition at line 55 of file prmed.cpp.

Referenced by DspTmpPrmLines(), and InitParams().

Prm::Coord PrmEd::first_mousept = { 0.0, 0.0 } [static, private]
 

First mouse position for a button-press-mouse-move-button-up event.

Definition at line 67 of file prmed.cpp.

Referenced by InsertPrm1stPt(), InsertPrm2ndPt(), and SelectDragPrm().

cdCanvas * PrmEd::Gdatascreen = 0L [static, private]
 

CD handle to data canvas.

Definition at line 51 of file prmed.cpp.

Referenced by DspTmpPrmLines(), and InitParams().

double PrmEd::max_height = 50.0 [static, private]
 

Maximum primitive height value (used only in 3D).

Definition at line 99 of file prmed.cpp.

Referenced by GetHeightFac(), ResetParams(), SetHeightFac(), and SetMaxHeight().

int PrmEd::mouse_has_moved = 0 [static, private]
 

Flag to indicate that mouse has moved since the first mouse position.

Definition at line 71 of file prmed.cpp.

Referenced by EchoPrm2ndPt(), InsertPrm1stPt(), ResetParams(), SelectDragPrm(), and UpdateDragPrm().

Prm::Type PrmEd::prm_type = Prm::PRM_QUAD [static, private]
 

Current primitive type to be attributed to new primitives to be inserted.

Definition at line 95 of file prmed.cpp.

Referenced by InsertPrm1stPt(), ResetParams(), and SetCurType().

Prm * PrmEd::sel_prm = 0L [static, private]
 

Varialble that holds a pointer to the current selected primitive.

A null value means that no primitive is selected.

Definition at line 80 of file prmed.cpp.

Referenced by DeleteSelPrm(), DspTmpPrmLines(), EchoPrm2ndPt(), FinishDragPrm(), GetHeightFac(), InsertPrm1stPt(), InsertPrm2ndPt(), MoveSelPrmToBack(), MoveSelPrmToFront(), ResetParams(), SelectDragPrm(), SetColor(), SetHeightFac(), UnselectAllPrm(), and UpdateDragPrm().

int PrmEd::sel_side = -1 [static, private]
 

Variable that holds an index of the current selected primitive side.

A negative value means that no side is selected.

Definition at line 90 of file prmed.cpp.

Referenced by FinishDragPrm(), ResetParams(), SelectDragPrm(), and UpdateDragPrm().

int PrmEd::sel_vert = -1 [static, private]
 

Variable that holds an index of the current selected primitive vertex.

A negative value means that no vertex is selected.

Definition at line 85 of file prmed.cpp.

Referenced by FinishDragPrm(), ResetParams(), SelectDragPrm(), and UpdateDragPrm().


The documentation for this class was generated from the following files:
Generated on Mon May 16 23:26:12 2011 for Trab7 by  doxygen 1.4.2-20050421