ContRap-Libraries
Public Types | Public Member Functions | Protected Attributes

crp::Primitive2D Class Reference

Class Primitive2D is an interface for all geometric primitives. More...

#include <primitives.h>

Inheritance diagram for crp::Primitive2D:
crp::Circle2D crp::Container2D crp::Ellipse2D crp::Line2D crp::Point2D crp::Polygon2D crp::Ray2D crp::Rect2D crp::Text2D crp::Triangle2D

Public Types

enum  Type {
  POINT_2D, LINE_2D, RAY_2D, RECT_2D,
  CIRCLE_2D, TRIANGLE_2D, TRIPLET_2D, TEXT_2D,
  POLYGON_2D, ELLIPSE_2D, CONTAINER_2D
}
 

Enumerates the primitive types.

More...

Public Member Functions

 Primitive2D (double x=0.0, double y=0.0)
 Creates a new primitive.
virtual ~Primitive2D ()
 Destructor.
 Primitive2D (const Primitive2D &primitive)
 Copy constructor.
Primitive2Dassign (const Primitive2D &primitive)
 Assignment operator.
virtual Type get_type () const =0
 Type of the primitive.
void set_color (double r, double g, double b, double opacity=1.0)
 Sets the color of the primitive.
void set_color (const Color &color)
 Sets the color of the primitive.
void set_opacity (double opacity)
 Sets the opacity of the primitive.
double get_x () const
 Returns the x-Coordinate.
double get_y () const
 Returns the y-Coordinate.
double get_r () const
 Returns the red color.
double get_g () const
 Returns the green color.
double get_b () const
 Returns the blue color.
double get_opacity () const
 Returns the opacity.
const std::string & get_label () const
 Returns the label.
void set_label (const std::string &label)
 Sets the label.
virtual void set_position (double x, double y)
 Sets the position of the primitive.
virtual void move (double dx, double dy)
 Moves the primitive by the given offset.
void set_valid (bool valid)
 Sets the primitives valid status.
bool is_valid () const
 Returns the primitives validity status.
int get_index () const
 Returns the index of the primitive.
virtual void set_index (int index)
 Sets the index of the primitive.
double get_width () const
 Returns the width of the primitive.
virtual void set_width (double width)
 Sets the width of the primitive.
virtual Primitive2Dget_copy ()=0
 Copies the current primitive.

Protected Attributes

double x
 Coordinates.
double y
double r
 Color.
double g
double b
double opacity
double width
 Width of the lines.
std::string label
 Label.
bool valid
 Validity flag.
int index
 Index of the primitive.

Detailed Description

Class Primitive2D is an interface for all geometric primitives.


Member Enumeration Documentation

Enumerates the primitive types.

Enumerator:
POINT_2D 
LINE_2D 
RAY_2D 
RECT_2D 
CIRCLE_2D 
TRIANGLE_2D 
TRIPLET_2D 
TEXT_2D 
POLYGON_2D 
ELLIPSE_2D 
CONTAINER_2D 

Constructor & Destructor Documentation

crp::Primitive2D::Primitive2D ( double  x = 0.0,
double  y = 0.0 
) [inline]

Creates a new primitive.

Parameters:
xX-Coordinate
yY-Coordinate
virtual crp::Primitive2D::~Primitive2D ( ) [inline, virtual]

Destructor.

crp::Primitive2D::Primitive2D ( const Primitive2D primitive) [inline]

Copy constructor.

Parameters:
primitivePrimitive to copy

Member Function Documentation

Primitive2D& crp::Primitive2D::assign ( const Primitive2D primitive) [inline]

Assignment operator.

Parameters:
primitiveObject to assign
double crp::Primitive2D::get_b ( ) const [inline]

Returns the blue color.

Returns:
Blue color
virtual Primitive2D* crp::Primitive2D::get_copy ( ) [pure virtual]

Copies the current primitive.

Returns:
New copy of the current primitive

Implemented in crp::Point2D, crp::Rect2D, crp::Line2D, crp::Ray2D, crp::Circle2D, crp::Triangle2D, crp::Text2D, crp::Polygon2D, crp::Ellipse2D, and crp::Container2D.

double crp::Primitive2D::get_g ( ) const [inline]

Returns the green color.

Returns:
Red color
int crp::Primitive2D::get_index ( ) const [inline]

Returns the index of the primitive.

Returns:
Primitive index
const std::string& crp::Primitive2D::get_label ( ) const [inline]

Returns the label.

Returns:
Label of the entity
double crp::Primitive2D::get_opacity ( ) const [inline]

Returns the opacity.

The opacity value is normally between 0.0 and 1.0.

Returns:
Opacity value
double crp::Primitive2D::get_r ( ) const [inline]

Returns the red color.

Returns:
Red color
virtual Type crp::Primitive2D::get_type ( ) const [pure virtual]

Type of the primitive.

Returns:
Type of the primitive

Implemented in crp::Point2D, crp::Rect2D, crp::Line2D, crp::Ray2D, crp::Circle2D, crp::Triangle2D, crp::Text2D, crp::Polygon2D, crp::Ellipse2D, and crp::Container2D.

double crp::Primitive2D::get_width ( ) const [inline]

Returns the width of the primitive.

Returns:
Primitive width

Reimplemented in crp::Rect2D.

double crp::Primitive2D::get_x ( ) const [inline]

Returns the x-Coordinate.

Returns:
x-Coordinate
double crp::Primitive2D::get_y ( ) const [inline]

Returns the y-Coordinate.

Returns:
y-Coordinate
bool crp::Primitive2D::is_valid ( ) const [inline]

Returns the primitives validity status.

Returns:
True if the primitive is valid
virtual void crp::Primitive2D::move ( double  dx,
double  dy 
) [inline, virtual]

Moves the primitive by the given offset.

Parameters:
dxNew X-Coordinate offset
dyNew Y-Coordinate offset
void crp::Primitive2D::set_color ( const Color color) [inline]

Sets the color of the primitive.

Parameters:
colorColor of the primitive

Reimplemented in crp::Container2D.

void crp::Primitive2D::set_color ( double  r,
double  g,
double  b,
double  opacity = 1.0 
) [inline]

Sets the color of the primitive.

Parameters:
rRed amount between 0.0 and 1.0
gGreen amount between 0.0 and 1.0
bBlue amount between 0.0 and 1.0
opacityOpacity value between 0.0 and 1.0

Reimplemented in crp::Container2D.

virtual void crp::Primitive2D::set_index ( int  index) [inline, virtual]

Sets the index of the primitive.

Parameters:
indexNew index

Reimplemented in crp::Container2D.

void crp::Primitive2D::set_label ( const std::string &  label) [inline]

Sets the label.

Parameters:
labelNew label
void crp::Primitive2D::set_opacity ( double  opacity) [inline]

Sets the opacity of the primitive.

Parameters:
opacityOpacity value between 0.0 and 1.0
virtual void crp::Primitive2D::set_position ( double  x,
double  y 
) [inline, virtual]

Sets the position of the primitive.

Parameters:
xNew X-Coordinate
yNew Y-Coordinate
void crp::Primitive2D::set_valid ( bool  valid) [inline]

Sets the primitives valid status.

Parameters:
validNew validity status
virtual void crp::Primitive2D::set_width ( double  width) [inline, virtual]

Sets the width of the primitive.

Parameters:
widthNew width

Reimplemented in crp::Rect2D.


Field Documentation

double crp::Primitive2D::b [protected]

Reimplemented in crp::Ellipse2D.

double crp::Primitive2D::g [protected]
int crp::Primitive2D::index [protected]

Index of the primitive.

std::string crp::Primitive2D::label [protected]

Label.

double crp::Primitive2D::opacity [protected]
double crp::Primitive2D::r [protected]

Color.

Reimplemented in crp::Circle2D.

bool crp::Primitive2D::valid [protected]

Validity flag.

double crp::Primitive2D::width [protected]

Width of the lines.

double crp::Primitive2D::x [protected]

Coordinates.

double crp::Primitive2D::y [protected]

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