Shape Class Reference

Generic class to manage various types of shapes
Holds a set of pure virtual methods needing to be implemented by derived classes. More...

#include <shape.h>

Inheritance diagram for Shape:

Inheritance graph
[legend]
Collaboration diagram for Shape:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Shape ()
 Constructs an empty shape.
virtual ~Shape ()
virtual SHAPE_TYPE GetType () const =0
 Virtual method returning the type of the shape.
void Init (int x, int y)
 Initialize the shape with a given point.
virtual const std::string & GetName () const =0
 Virtual method returning the name of the shape.
int GetHeight () const
 Returns the height of the shape.
int GetWidth () const
 Returns the width of the shape.
int GetCenterX () const
 Returns the abscissa of the center.
int GetCenterY () const
 Returns the ordinate of the center.
virtual double GetSurface () const =0
 Virtual method returning the surface of the shape.
virtual double SumValues (Image *pImage)=0
 Returns the sum of all the pixels' values within the shape.
virtual void Draw (QPainter *p, int fact)=0
 Draws the shape.
virtual void ModifyEndShape (int lastMousePosition_x, int lastMousePosition_y)
 Updates the coordinates of the end of the shape with those in arguments.
virtual bool Validate ()
 Validates the shape update (polygon closing, right ordering of the rectangle coordinates,...) and tests its validity.
const BoundingBoxGetBoundingBox () const
 Returns the rectangle surrounding the shape.
void SetBoundingBox (BoundingBox &bb)
 Assigns a new BoundingBox to this shape.
virtual bool IsInside (int x, int y) const =0
 Tests if the shape contains a given point.

Protected Attributes

BoundingBox m_box
 Smallest BoundingBox containing this shape.


Detailed Description

Generic class to manage various types of shapes
Holds a set of pure virtual methods needing to be implemented by derived classes.

Definition at line 23 of file shape.h.


Constructor & Destructor Documentation

Shape::Shape (  ) 

Constructs an empty shape.

Definition at line 10 of file shape.cpp.

Shape::~Shape (  )  [virtual]

Definition at line 14 of file shape.cpp.


Member Function Documentation

virtual SHAPE_TYPE Shape::GetType (  )  const [pure virtual]

Virtual method returning the type of the shape.

Returns:
the type of the shape

Implemented in Rectangle.

Referenced by WStatistics::UpdateStats().

void Shape::Init ( int  x,
int  y 
)

Initialize the shape with a given point.

Parameters:
x : abscissa of the first point
y : ordinate of the first point

Definition at line 17 of file shape.cpp.

References m_box, and BoundingBox::SetCoord().

Referenced by Visu2D::GenerateShape().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual const std::string& Shape::GetName (  )  const [pure virtual]

Virtual method returning the name of the shape.

Returns:
the name of the shape

Implemented in Rectangle.

int Shape::GetHeight (  )  const

Returns the height of the shape.

Returns:
the height of the shape or 0 if the shape is empty.

Definition at line 38 of file shape.cpp.

References BoundingBox::GetHeight(), and m_box.

Referenced by Rectangle::GetSurface(), and WStatistics::UpdateStats().

Here is the call graph for this function:

Here is the caller graph for this function:

int Shape::GetWidth (  )  const

Returns the width of the shape.

Returns:
the width of the shape or 0 if the shape is empty.

Definition at line 43 of file shape.cpp.

References BoundingBox::GetWidth(), and m_box.

Referenced by Rectangle::GetSurface(), and WStatistics::UpdateStats().

Here is the call graph for this function:

Here is the caller graph for this function:

int Shape::GetCenterX (  )  const

Returns the abscissa of the center.

Returns:
the abscissa of the center or 0 if the shape is empty

Definition at line 48 of file shape.cpp.

References BoundingBox::GetOriginX(), BoundingBox::GetWidth(), and m_box.

Referenced by WStatistics::UpdateStats().

Here is the call graph for this function:

int Shape::GetCenterY (  )  const

Returns the ordinate of the center.

Returns:
the ordinate of the center or 0 if the shape is empty

Definition at line 53 of file shape.cpp.

References BoundingBox::GetHeight(), BoundingBox::GetOriginY(), and m_box.

Referenced by WStatistics::UpdateStats().

Here is the call graph for this function:

virtual double Shape::GetSurface (  )  const [pure virtual]

Virtual method returning the surface of the shape.

Returns:
the surface of the shape

Implemented in Rectangle.

Referenced by Selection::GetSurface(), and WStatistics::UpdateStats().

Here is the caller graph for this function:

virtual double Shape::SumValues ( Image pImage  )  [pure virtual]

Returns the sum of all the pixels' values within the shape.

Parameters:
pImage : pointer to the image data

Implemented in Rectangle.

Referenced by Selection::SumValues(), and WStatistics::UpdateStats().

Here is the caller graph for this function:

virtual void Shape::Draw ( QPainter *  p,
int  fact 
) [pure virtual]

Draws the shape.

Parameters:
p : low-level Qt object allowing to draw and/or display a pixmap in a QWidget
fact : ratio between the data scale (shapes to be drawn) and the visualization scale (graphical representation)

Implemented in Rectangle.

Referenced by Selection::Draw(), and Visu2D::DrawShapes().

Here is the caller graph for this function:

void Shape::ModifyEndShape ( int  lastMousePosition_x,
int  lastMousePosition_y 
) [virtual]

Updates the coordinates of the end of the shape with those in arguments.

Parameters:
lastMousePosition_x Abscissa of the bottom-right corner
lastMousePosition_y Ordinate of the bottom-right corner

Definition at line 22 of file shape.cpp.

References m_box, BoundingBox::SetEndX(), and BoundingBox::SetEndY().

Referenced by Visu2D::GenerateShape().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Shape::Validate (  )  [virtual]

Validates the shape update (polygon closing, right ordering of the rectangle coordinates,...) and tests its validity.

Definition at line 58 of file shape.cpp.

References BoundingBox::IsEmpty(), m_box, and BoundingBox::Validate().

Referenced by Visu2D::GenerateShape().

Here is the call graph for this function:

Here is the caller graph for this function:

const BoundingBox & Shape::GetBoundingBox (  )  const

Returns the rectangle surrounding the shape.

Definition at line 28 of file shape.cpp.

References m_box.

void Shape::SetBoundingBox ( BoundingBox bb  ) 

Assigns a new BoundingBox to this shape.

Parameters:
bb : new BoundingBox

Definition at line 33 of file shape.cpp.

References m_box.

virtual bool Shape::IsInside ( int  x,
int  y 
) const [pure virtual]

Tests if the shape contains a given point.

Parameters:
x abscissa of the point
y ordinate of the point
Returns:
true if the point falls within the shape, false otherwise

Implemented in Rectangle.


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Tue Sep 13 10:10:29 2011 for DrawQt by  doxygen 1.5.6