Cute Chess  0.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
BoardScene Class Reference

A graphical surface for displaying a chessgame. More...

#include <boardscene.h>

Inheritance diagram for BoardScene:
QGraphicsScene

Public Slots

void flip ()
 
void makeMove (const Chess::Move &move)
 
void makeMove (const Chess::GenericMove &move)
 
void onGameFinished (ChessGame *game, Chess::Result result)
 
void populate ()
 
void setFenString (const QString &fenString)
 
void undoMove ()
 

Signals

void humanMove (const Chess::GenericMove &move, const Chess::Side &side)
 

Public Member Functions

Chess::Boardboard () const
 
 BoardScene (QObject *parent=nullptr)
 
void setBoard (Chess::Board *board)
 
virtual ~BoardScene ()
 

Protected Member Functions

virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 

Additional Inherited Members

- Public Types inherited from QGraphicsScene
enum  ItemIndexMethod
 
enum  SceneLayer
 

Detailed Description

A graphical surface for displaying a chessgame.

BoardScene is the top-level container for the board, the chess pieces, etc. It also manages the deletion and creation of pieces, visualising moves made in a game, emitting moves made by a human player, etc.

BoardScene is that class that connects to the players and game objects to synchronize the graphical side with the internals.

Constructor & Destructor Documentation

BoardScene::BoardScene ( QObject parent = nullptr)
explicit

Creates a new BoardScene object.

BoardScene::~BoardScene ( )
virtual

Destroys the scene and all its items.

Member Function Documentation

Chess::Board * BoardScene::board ( ) const

Returns the current internal board object.

void BoardScene::flip ( )
slot

Flips the board, with animation.

void BoardScene::humanMove ( const Chess::GenericMove move,
const Chess::Side side 
)
signal

This signal is emitted when a human player has made a move.

The move is guaranteed to be legal. The move was made by the player on side side.

void BoardScene::makeMove ( const Chess::Move move)
slot

Makes the move move in the scene.

void BoardScene::makeMove ( const Chess::GenericMove move)
slot

Makes the move move in the scene.

void BoardScene::onGameFinished ( ChessGame game,
Chess::Result  result 
)
slot

Cancels any ongoing user move and flashes result over the board.

void BoardScene::populate ( )
slot

Clears the scene, creates a new board, and populates it with chess pieces.

The scene is populated to match the current FEN string of the internal board, so the internal board must be fully initialized before calling this function.

void BoardScene::setBoard ( Chess::Board board)

Clears the scene and sets board as the internal board.

The scene takes ownership of the board, so it's usually best to give the scene its own copy of a board.

void BoardScene::setFenString ( const QString fenString)
slot

Re-populates the scene according to fenString.

void BoardScene::undoMove ( )
slot

Reverses the last move that was made in the scene.


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