GVectors::Segment Class Reference

Class representing a segment. More...

#include <segment.h>

List of all members.

Public Member Functions

 Segment ()
 Constructor.
 Segment (const Coordinates &f, const Coordinates &t)
 Constructor.
 Segment (const Coordinates &f, const Coordinates &t, const Color &c)
 Constructor.
virtual ~Segment ()
 Destructor.
 Segment (const Segment &s)
 Copy constructor.
void set_from (const Coordinates &c)
 Set the start point.
void set_to (const Coordinates &c)
 Set the end point.
void set (const Coordinates &f, const Coordinates &t)
 Set the start and end point.
void set_pol (const Coordinates &f, double length, double angle, Angle_Type at=ANG_RAD)
 Defines the Segment in terms of start point, length, and angle.
void set_color (const Color &c)
 Set the color.
void color (const Color &c)
 Set the color.
void get_from (Coordinates &f) const
 Get the start point.
Coordinates get_from () const
 Get the start point.
void get_to (Coordinates &t) const
 Get the end point.
Coordinates get_to () const
 Get the end point.
void get (Coordinates &f, Coordinates &t) const
 Get the end and start point.
Color get_color () const
 Get the color of the segment.
Color color () const
 Get the color of the segment.
double length () const
 Get the length of the segment.
double angle (Angle_Type at=ANG_RAD) const
 Get the angle of the segment.
void move_to (const Coordinates &c)
 Move the segment to a new start point.
void move_by (const Coordinates &c)
 Move the segment.
void draw (Drawer &d) const
 Draw the segment.
const Segmentoperator= (const Segment &s)
 Assignment operator.

Private Attributes

Color s_color
 The color of the segment.
Coordinates from
 The start point.
Coordinates to
 The end point.
double initial_length
 The length of the segment.
double initial_angle
 The angle of the segment.


Detailed Description

This class represents a segment (line). The coordinate system the segment lives in has the following layout:
     y

    /\
     |        * (x1/y1)
     |       /
     |      /
     |     /
     |    * (x0/y0)
     |
     |
     |
-----+-----------------> x
(0/0)|             
      

The class does not provide any methods for drawing the segment. For that, it relies on Drawer.


Constructor & Destructor Documentation

Segment::Segment (  ) 

Constructor.

Segment::Segment ( const Coordinates f,
const Coordinates t 
)

Sets start and end point.

Parameters:
f Start point.
t End point.

Segment::Segment ( const Coordinates f,
const Coordinates t,
const Color c 
)

Sets start and end point, and color.

Parameters:
f Start point.
t End point.
c Color.

Segment::~Segment (  )  [virtual]

Destructor. Does nothing. Just for completeness.

Segment::Segment ( const Segment s  ) 

Copy constructor.

Parameters:
s A const reference to a Segment object.


Member Function Documentation

void Segment::set_from ( const Coordinates c  ) 

Sets the starting point.

Parameters:
c A const reference to a Coordinates object.

void Segment::set_to ( const Coordinates c  ) 

Sets the end point.

Parameters:
c A const reference to a Cooridnates object.

void Segment::set ( const Coordinates f,
const Coordinates t 
)

Sets the start and end point.

Parameters:
f A const reference to a Coordinates object as the start point.
t A const reference to a Coordinates object as the end point.

void Segment::set_pol ( const Coordinates f,
double  length,
double  angle,
Angle_Type  at = ANG_RAD 
)

Draws a Segment from f with the specified length under the the specified angle.

Parameters:
f A const reference to a Coordinates object as the start point.
length Length of the Segment.
angle Angle of the segment with respect to the x-axis.
at Unit of angle. See Angle_Type.

void GVectors::Segment::set_color ( const Color c  )  [inline]

Sets the color of the segment.

Parameters:
c A const reference to a Color object.

void GVectors::Segment::color ( const Color c  )  [inline]

Sets the color of the segment.

Parameters:
c A const reference to a Color object.

void Segment::get_from ( Coordinates f  )  const

Gets the start point of the segment.

Parameters:
f A reference to a Coordinates object receiving the x and y values of the start point.

Coordinates Segment::get_from (  )  const

Gets the start point of the segment.

Returns:
A Coordinates object holding the x and y values of the start point.

void Segment::get_to ( Coordinates t  )  const

Gets the end point of the segment.

Parameters:
t A reference to a Coordinates object receiving the x and y values of the end point.

Coordinates Segment::get_to (  )  const

Gets the end point of the segment.

Returns:
A Coordinates object holding the x and y values of the end point.

void Segment::get ( Coordinates f,
Coordinates t 
) const

Gets the start and end point of the segment.

Parameters:
f A reference to a Coordinates object receiving the x and y values of the start point.
t A reference to a Coordinates object receiving the x and y values of the end point.

Color GVectors::Segment::get_color (  )  const [inline]

Gets the color of the segment.

Returns:
A Color object holding the RGB color.

Color GVectors::Segment::color (  )  const [inline]

Gets the color of the segment.

Returns:
A Color object holding the RGB color.

double Segment::length (  )  const

Computes the length of the segment.

Returns:
The length of the segment.

double Segment::angle ( Angle_Type  at = ANG_RAD  )  const

Computes the angle of the segment with respect to the x-axis.

Parameters:
at The unit of the angle returned.
Returns:
The angle meassured in at units.

void Segment::move_to ( const Coordinates c  ) 

Moves the segment to a new start point.

Parameters:
c A const reference to a Coordinates serving as the new start point.

void Segment::move_by ( const Coordinates c  ) 

Moves the segment by c units in x and y direction.

Parameters:
c A const reference to a Coordinates object holding the units to move the segment.

void Segment::draw ( Drawer d  )  const

Draws the segment using the Drawer provided.

Parameters:
d A reference to the Drawer to be used to draw the segment.

const Segment & Segment::operator= ( const Segment s  ) 

Assignment operator.

Parameters:
s A const reference to the Segment object assigned to this.
Returns:
A const reference to this.


Member Data Documentation

Color GVectors::Segment::s_color [private]

The color of the segment.

Coordinates GVectors::Segment::from [private]

The starting point of the segment.

Coordinates GVectors::Segment::to [private]

The end point of the segment.

double GVectors::Segment::initial_length [private]

Holds the length of the segment.

double GVectors::Segment::initial_angle [private]

The angle of the segment in relation to the x-axis.


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 19:37:30 2007 for libgvectors by  doxygen 1.4.7