Drawing Program
Lab 02 Core Exercise HIT3172
 All Classes Functions Variables
Public Member Functions | Private Attributes | List of all members
Drawing Class Reference

#include <Drawing.h>

Public Member Functions

 Drawing ()
 ~Drawing ()
Shapeget_selected_shape ()
color get_background_color ()
void set_background_color (color)
void add_shape (Shape *)
void select_shape_at_point (point2d)
void draw ()
void delete_selected_shape ()
void move_selected_shape_up ()
void move_selected_shape_down ()

Private Attributes

std::vector< Shape * > _shapes
Shape_selected_shape
color _background_color

Detailed Description

The Drawing class holds references to all the shapes and can draw them all to the screen in order, as well as selecting, reordering and removing shapes on screen

Constructor & Destructor Documentation

Drawing::Drawing ( )

The constructor initialises the _selected_shape and _background_color data members

Drawing::~Drawing ( )

Upon destruction, memory for each shape the drawing holds is freed (ie. each shape is deleted)

Member Function Documentation

void Drawing::add_shape ( Shape shape)

Adds a Shape to the drawing

Parameters
shapethe shape to add
void Drawing::delete_selected_shape ( )

Deletes the selected shape from the drawing, freeing it's memory and removing it from _shapes

void Drawing::draw ( )

Clears the screen with the background colour, then draws each of the Shape objects with their draw method. Also highlights the selected shape.

color Drawing::get_background_color ( )

Gets the background colour

Returns
the background colour
Shape * Drawing::get_selected_shape ( )

Gets the selected shape

Returns
the selected shape
void Drawing::move_selected_shape_down ( )

Moves the selected shape down in the array, unless it is the first already

void Drawing::move_selected_shape_up ( )

Moves the selected shape up in the array, unless it is the last already

void Drawing::select_shape_at_point ( point2d  point)

Selects the shape that is at the point point by checking if each Shape::is_at the point

Parameters
pointthe point to select the shape at
void Drawing::set_background_color ( color  bg)

Sets the background colour

Parameters
bgbackground colour

Member Data Documentation

color Drawing::_background_color
private

The background colour of the drawing canvas

Shape* Drawing::_selected_shape
private

Pointer to the selected shape

std::vector<Shape *> Drawing::_shapes
private

Vector array of the shape references, creates a "has many" relationship


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