puzzle_c Class Reference

This class defines the puzzle. More...

#include <puzzle.h>

Collaboration diagram for puzzle_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 puzzle_c (const puzzle_c *orig)
 copy constructor this will NOT copy the labels and solutions of the problems.
 puzzle_c (gridType_c *g)
 Constructor for empty puzzle.
 puzzle_c (xmlParser_c &pars)
 load the puzzle from the XML file
void save (xmlWriter_c &xml) const
 save the puzzle into a XML node that is returned
 ~puzzle_c (void)
 Destructor.
some functions to get the current set grid type for this puzzle
const gridType_cgetGridType (void) const
gridType_cgetGridType (void)
shape handling
unsigned int addShape (voxel_c *p)
 Add the given shape to the puzzle.
unsigned int addShape (unsigned int sx, unsigned int sy, unsigned int sz)
 add an empty shape of the given size return the index of the new shape
unsigned int shapeNumber (void) const
 return how many shapes there are in the puzzle
const voxel_cgetShape (unsigned int idx) const
 get a shape
voxel_cgetShape (unsigned int idx)
 get a shape
void removeShape (unsigned int)
 remove the num-th shape.
void exchangeShape (unsigned int s1, unsigned int s2)
 exchange 2 shapes in the list of shapes.
handle puzzle colours
unsigned int addColor (unsigned char r, unsigned char g, unsigned char b)
 add a color, return the index of the new color
void removeColor (unsigned int idx)
 remove a color with given index.
void changeColor (unsigned int idx, unsigned char r, unsigned char g, unsigned char b)
 change the RGB value of one color
void getColor (unsigned int idx, unsigned char *r, unsigned char *g, unsigned char *b) const
 get the RGB value of one color
unsigned int colorNumber (void) const
 return the number of defined colors
handle problems
unsigned int addProblem (void)
 add a new empty problem return its index
unsigned int addProblem (const problem_c *prob)
 add a new problem as copy from another problem (from another puzzle).
unsigned int problemNumber (void) const
 return the number of problems within this puzzle
void removeProblem (unsigned int p)
 remove problem with the given index freeing all its ressources
void exchangeProblem (unsigned int p1, unsigned int p2)
 exchange problem at indes p1 with problem at index p2
const problem_cgetProblem (unsigned int p) const
 get the problem at index p
problem_cgetProblem (unsigned int p)
 get the problem at index p
the puzzle comment functions
void setComment (const std::string &com)
 set comment there is no limitation in size or characters.
const std::string & getComment (void) const
 get comment
bool getCommentPopup (void) const
 find out if the comment popup flas is set
void setCommentPopup (bool val)
 set or reset comment popup flag

Private Member Functions

 puzzle_c (const puzzle_c &)
void operator= (const puzzle_c &)

Private Attributes

gridType_cgt
 The gridtype of the puzzle.
std::vector< voxel_c * > shapes
 The vector with the shapes.
std::vector< problem_c * > problems
 the vector with the problems
std::vector< uint32_t > colors
 The constraint colours.
std::string comment
 some information about the puzzle no format is forced its free for the user
bool commentPopup
 bool to signify if the comment should open on load.


Detailed Description

This class defines the puzzle.

A puzzle is a collection of shapes and a set of problems associated with these shapes and finally the color used for color constraint colors


Constructor & Destructor Documentation

puzzle_c::puzzle_c ( const puzzle_c orig  ) 

copy constructor this will NOT copy the labels and solutions of the problems.

References colors, comment, commentPopup, gridType_c::getVoxel(), gt, problems, and shapes.

puzzle_c::puzzle_c ( gridType_c g  )  [inline]

Constructor for empty puzzle.

no shape, no problem and no colours ownership of the given gridtype is taken over, the memory is freed on destruction of this class

puzzle_c::puzzle_c ( xmlParser_c pars  ) 

puzzle_c::~puzzle_c ( void   ) 

Destructor.

Deletes all the shapes in the puzzle

References gt, problems, and shapes.

puzzle_c::puzzle_c ( const puzzle_c  )  [private]


Member Function Documentation

unsigned int puzzle_c::addColor ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

add a color, return the index of the new color

References bt_assert, and colors.

Referenced by doConvert().

unsigned int puzzle_c::addProblem ( const problem_c prob  ) 

add a new problem as copy from another problem (from another puzzle).

A copy of the provided problem is created

References problems.

unsigned int puzzle_c::addProblem ( void   ) 

add a new empty problem return its index

similar functions for problems

References problems.

Referenced by doConvert(), and loadPuzzlerSolver3D().

unsigned int puzzle_c::addShape ( unsigned int  sx,
unsigned int  sy,
unsigned int  sz 
)

add an empty shape of the given size return the index of the new shape

References gridType_c::getVoxel(), gt, shapes, and voxel_c::VX_EMPTY.

unsigned int puzzle_c::addShape ( voxel_c p  ) 

Add the given shape to the puzzle.

The space is taken over, and freed when the puzzle is destroyed Returns the index of the new shape

References bt_assert, voxel_c::getGridType(), gridType_c::getType(), gt, and shapes.

Referenced by doConvert(), and loadPuzzlerSolver3D().

void puzzle_c::changeColor ( unsigned int  idx,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

change the RGB value of one color

References bt_assert, and colors.

unsigned int puzzle_c::colorNumber ( void   )  const [inline]

return the number of defined colors

References colors.

Referenced by problem_c::allowPlacement(), problem_c::disallowPlacement(), doConvert(), and problem_c::placementAllowed().

void puzzle_c::exchangeProblem ( unsigned int  p1,
unsigned int  p2 
)

exchange problem at indes p1 with problem at index p2

References bt_assert, and problems.

void puzzle_c::exchangeShape ( unsigned int  s1,
unsigned int  s2 
)

exchange 2 shapes in the list of shapes.

this function takes care to update all the problems and solutions because they only index into the shape list and exchangin shapes requires updating tose indices

References bt_assert, problems, and shapes.

void puzzle_c::getColor ( unsigned int  idx,
unsigned char *  r,
unsigned char *  g,
unsigned char *  b 
) const

get the RGB value of one color

References bt_assert, and colors.

Referenced by doConvert(), and removeColor().

const std::string& puzzle_c::getComment ( void   )  const [inline]

get comment

References comment.

Referenced by doConvert().

bool puzzle_c::getCommentPopup ( void   )  const [inline]

find out if the comment popup flas is set

References commentPopup.

Referenced by doConvert().

gridType_c* puzzle_c::getGridType ( void   )  [inline]

References gt.

const gridType_c* puzzle_c::getGridType ( void   )  const [inline]

problem_c* puzzle_c::getProblem ( unsigned int  p  )  [inline]

get the problem at index p

References bt_assert, and problems.

const problem_c* puzzle_c::getProblem ( unsigned int  p  )  const [inline]

get the problem at index p

References bt_assert, and problems.

Referenced by doConvert(), loadPuzzlerSolver3D(), and print().

voxel_c* puzzle_c::getShape ( unsigned int  idx  )  [inline]

get a shape

References bt_assert, and shapes.

const voxel_c* puzzle_c::getShape ( unsigned int  idx  )  const [inline]

void puzzle_c::operator= ( const puzzle_c  )  [private]

unsigned int puzzle_c::problemNumber ( void   )  const [inline]

return the number of problems within this puzzle

References problems.

Referenced by doConvert(), and print().

void puzzle_c::removeColor ( unsigned int  idx  ) 

remove a color with given index.

All shapes are updated to not use that color any more, color constraints are updated for all problems to no longer use that color, its your task to make sure the now invalid solutions are removed

References bt_assert, colors, getColor(), problems, shapes, and voxel_c::VX_EMPTY.

void puzzle_c::removeProblem ( unsigned int  p  ) 

remove problem with the given index freeing all its ressources

References bt_assert, and problems.

void puzzle_c::removeShape ( unsigned int  idx  ) 

remove the num-th shape.

be careful this changes all ids and so all problems must be updated changing them, removing solutions, result shapes or pieces in problems...

References bt_assert, problems, and shapes.

void puzzle_c::save ( xmlWriter_c xml  )  const

void puzzle_c::setComment ( const std::string &  com  )  [inline]

set comment there is no limitation in size or characters.

References comment.

Referenced by doConvert().

void puzzle_c::setCommentPopup ( bool  val  )  [inline]

set or reset comment popup flag

References commentPopup.

Referenced by doConvert().

unsigned int puzzle_c::shapeNumber ( void   )  const [inline]


Member Data Documentation

std::vector<uint32_t> puzzle_c::colors [private]

The constraint colours.

there can be many colours to constrain the placement of pieces these are the actual colours used to display them the red part is in the lowest 8 bit, followed by green and blue in the highest part

Referenced by addColor(), changeColor(), colorNumber(), getColor(), puzzle_c(), removeColor(), and save().

std::string puzzle_c::comment [private]

some information about the puzzle no format is forced its free for the user

Referenced by getComment(), puzzle_c(), save(), and setComment().

bool puzzle_c::commentPopup [private]

bool to signify if the comment should open on load.

so when the gui loads a puzzle where this is true, it will always display the comment.

Referenced by getCommentPopup(), puzzle_c(), save(), and setCommentPopup().

The gridtype of the puzzle.

each puzzle has exactly one grid type, this is it normally it doesn't change, except if you convert a puzzle of one grid type into an other with a converter

Referenced by addShape(), getGridType(), puzzle_c(), save(), and ~puzzle_c().

std::vector<problem_c*> puzzle_c::problems [private]

std::vector<voxel_c*> puzzle_c::shapes [private]


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

Generated on Sun Oct 10 10:03:06 2010 for BurrTools by  doxygen 1.5.8