Logo Search packages:      
Sourcecode: palapeli version File versions  Download package

Palapeli::JigsawPattern Class Reference

#include <pattern-jigsaw.h>

Inheritance diagram for Palapeli::JigsawPattern:

Palapeli::Pattern

List of all members.


Detailed Description

For internal use only.

Definition at line 39 of file pattern-jigsaw.h.


Public Types

enum  Mode { CreatePuzzle, SimulateCreation }
 Defines operation modes for this pattern. More...

Signals

void allPiecesGenerated ()
void pieceCountAvailable (int pieceCount)
void pieceGenerated (const QImage &image, const QImage &mask, const QRectF &positionInImage, const QPointF &sceneBasePosition)
void pieceGenerated (const QImage &image, const QRectF &positionInImage, const QPointF &sceneBasePosition)
void relationGenerated (int piece1Id, int piece2Id)

Public Member Functions

 JigsawPattern (int xCount, int yCount, const QString &name, int seed)
void loadPiecePositions (const QList< QPointF > &points)
Mode mode () const
int pieceCount () const
void setMode (Mode mode)
void setSceneSizeFactor (qreal factor)
void slice (const QImage &image)

Protected Member Functions

void addPiece (const QImage &baseImage, const QImage &mask, const QRectF &positionInImage)
 Adds a piece to the puzzle scene.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload adds the possibility to pass a mask which will define a shape to be cut out from the given baseImage. This is useful because some environments seem to have problems with image composition in non-GUI threads.

void addPiece (const QImage &image, const QRectF &positionInImage)
 Adds a piece to the puzzle scene. Internally, the piece is assigned a consecutive index (0 for the first piece, 1 for the second piece, and so on) which has to be used when defining relations between the pieces.
void addRelation (int piece1Id, int piece2Id)
 Adds a neighbor relation between two pieces.
virtual void doSlice (const QImage &image)
 Provides the slicing algorithm. This function splits a given image into pieces and defines relations between them. These pieces and relations are used to build the puzzle.
void reportPieceCount (int pieceCount)
 Informs Palapeli about the number of pieces to expect. Call this from your slicing algorithm to inform Palapeli about the number of pieces to be expected. (This should, of course, be done before any pieces are added to the scene.) The Palapeli game engine will use this information to show a progress bar to the user.

Private Attributes

int m_seed
int m_shapeCount
QList< KSvgRenderer * > m_shapes
int m_xCount
int m_yCount

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

Generated by  Doxygen 1.6.0   Back to index