Selection Class Reference

This class manages the set of shapes to be drawn on screen: memory allocation, storage, access, ... The shapes are stored by coordinates.
For the moment, a selection can only hold one shape. In the various projects, this will be improved so a selection will be able to hold a list of shapes. More...

#include <selection.h>

Collaboration diagram for Selection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Selection ()
 Constructs a selection, initializing the current shape.
virtual ~Selection ()
ShapeAllocateShape (SHAPE_TYPE type)
 Allocate a new empty shape. Beware: the call to this method should be followed by a call to Init(x,y) to initialize the first point.
void HandleNewShape (Shape *s)
 Store a new shape, replacing the previous one.
ShapeGetShape ()
 Returns a pointer to the currently held shape.
void Draw (QPainter *p, int fact)
 Draws the shape.
double SumValues (Image *pData)
 Computes and returs the sum of the pixels' values in the displayed shape.
double GetSurface ()
 returns the sum of the surfaces of the shape(s) being displayed.
bool Save (std::ofstream &of)
 Saves the coordinates of the displayed shapes in the stream of.
bool Read (std::ifstream &ifs)
 Reads the coordinates of the shapes saved in the input stream and displays them on screen.

Private Attributes

Shapem_shape
 Pointer to the Shape held by the Selection.


Detailed Description

This class manages the set of shapes to be drawn on screen: memory allocation, storage, access, ... The shapes are stored by coordinates.
For the moment, a selection can only hold one shape. In the various projects, this will be improved so a selection will be able to hold a list of shapes.

Definition at line 25 of file selection.h.


Constructor & Destructor Documentation

Selection::Selection (  ) 

Constructs a selection, initializing the current shape.

Definition at line 15 of file selection.cpp.

References m_shape.

Selection::~Selection (  )  [virtual]

Definition at line 21 of file selection.cpp.


Member Function Documentation

Shape * Selection::AllocateShape ( SHAPE_TYPE  type  ) 

Allocate a new empty shape. Beware: the call to this method should be followed by a call to Init(x,y) to initialize the first point.

Parameters:
type,: type of the new shape.
Returns:
a pointer to the newly allocated shape or NULL is no shape could be allocated.

Definition at line 25 of file selection.cpp.

References RECTANGLE.

Referenced by Visu2D::GenerateShape().

Here is the caller graph for this function:

void Selection::HandleNewShape ( Shape s  ) 

Store a new shape, replacing the previous one.

Parameters:
s new shape to handle in the selection

Definition at line 40 of file selection.cpp.

References m_shape.

Referenced by Visu2D::GenerateShape().

Here is the caller graph for this function:

Shape * Selection::GetShape (  ) 

Returns a pointer to the currently held shape.

Definition at line 49 of file selection.cpp.

References m_shape.

Referenced by WStatistics::UpdateStats().

void Selection::Draw ( QPainter *  p,
int  fact 
)

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 draw) and the visualization scale (graphical representation)

Definition at line 69 of file selection.cpp.

References Shape::Draw(), and m_shape.

Referenced by Visu2D::DrawShapes().

Here is the call graph for this function:

Here is the caller graph for this function:

double Selection::SumValues ( Image pData  ) 

Computes and returs the sum of the pixels' values in the displayed shape.

Definition at line 59 of file selection.cpp.

References m_shape, and Shape::SumValues().

Referenced by WStatistics::UpdateStats().

Here is the call graph for this function:

double Selection::GetSurface (  ) 

returns the sum of the surfaces of the shape(s) being displayed.

Returns:
the sum of the surfaces of the shape(s) being displayed.

Definition at line 76 of file selection.cpp.

References Shape::GetSurface(), and m_shape.

Referenced by WStatistics::UpdateStats().

Here is the call graph for this function:

bool Selection::Save ( std::ofstream &  of  ) 

Saves the coordinates of the displayed shapes in the stream of.

Parameters:
of data stream in which to save data
Returns:
true if everything is alright

Definition at line 85 of file selection.cpp.

bool Selection::Read ( std::ifstream &  ifs  ) 

Reads the coordinates of the shapes saved in the input stream and displays them on screen.

Parameters:
ifs input stream to read from.
Returns:
true if everything went alright

Definition at line 90 of file selection.cpp.


Member Data Documentation

Pointer to the Shape held by the Selection.

Definition at line 36 of file selection.h.

Referenced by Draw(), GetShape(), GetSurface(), HandleNewShape(), Selection(), and SumValues().


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

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