#include <puzzle.h>
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_c * | getGridType (void) const |
gridType_c * | getGridType (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_c * | getShape (unsigned int idx) const |
get a shape | |
voxel_c * | getShape (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_c * | getProblem (unsigned int p) const |
get the problem at index p | |
problem_c * | getProblem (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_c * | gt |
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. |
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
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 | ) |
load the puzzle from the XML file
References colors, comment, commentPopup, xmlParser_c::END_TAG, xmlParser_c::exception(), xmlParser_c::getAttributeCount(), xmlParser_c::getAttributeName(), xmlParser_c::getAttributeValue(), xmlParser_c::getName(), xmlParser_c::getText(), gridType_c::getVoxel(), gt, gridType_c::GT_BRICKS, xmlParser_c::next(), xmlParser_c::nextTag(), problems, xmlParser_c::require(), shapes, xmlParser_c::skipSubTree(), xmlParser_c::START_TAG, and xmlParser_c::TEXT.
puzzle_c::~puzzle_c | ( | void | ) |
puzzle_c::puzzle_c | ( | const puzzle_c & | ) | [private] |
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 | |||
) |
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 | |||
) |
void puzzle_c::exchangeShape | ( | unsigned int | s1, | |
unsigned int | s2 | |||
) |
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] |
bool puzzle_c::getCommentPopup | ( | void | ) | const [inline] |
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] |
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] |
const voxel_c* puzzle_c::getShape | ( | unsigned int | idx | ) | const [inline] |
get a shape
References bt_assert, and shapes.
Referenced by doConvert(), voxelTablePuzzle_c::findSpace(), problem_c::getResultShape(), problem_c::getShapeShape(), loadPuzzlerSolver3D(), and print().
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 | ) |
void puzzle_c::removeShape | ( | unsigned int | idx | ) |
void puzzle_c::save | ( | xmlWriter_c & | xml | ) | const |
save the puzzle into a XML node that is returned
References xmlWriter_c::addContent(), colors, comment, commentPopup, xmlWriter_c::endTag(), gt, xmlWriter_c::newAttrib(), xmlWriter_c::newTag(), problems, gridType_c::save(), and shapes.
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] |
unsigned int puzzle_c::shapeNumber | ( | void | ) | const [inline] |
return how many shapes there are in the puzzle
References shapes.
Referenced by doConvert(), problem_c::getResultId(), problem_c::getResultShape(), problem_c::getShapeId(), problem_c::getShapeMaximum(), problem_c::getShapeMinimum(), print(), problem_c::problem_c(), problem_c::resultValid(), problem_c::setResultId(), problem_c::setShapeMaximum(), and problem_c::setShapeMinimum().
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().
gridType_c* puzzle_c::gt [private] |
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] |
the vector with the problems
Referenced by addProblem(), exchangeProblem(), exchangeShape(), getProblem(), problemNumber(), puzzle_c(), removeColor(), removeProblem(), removeShape(), save(), and ~puzzle_c().
std::vector<voxel_c*> puzzle_c::shapes [private] |
The vector with the shapes.
Referenced by addShape(), exchangeShape(), getShape(), puzzle_c(), removeColor(), removeShape(), save(), shapeNumber(), and ~puzzle_c().