-
Notifications
You must be signed in to change notification settings - Fork 1
/
board.h
66 lines (55 loc) · 2.02 KB
/
board.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef BOARD_H
#define BOARD_H
#include <QtGui/QMessageBox>
#include <QtGui/QInputDialog>
#include <cmath>
#include "abstractboard.h"
#include "sgfgame.h"
class Board : public AbstractBoard
{
Q_OBJECT
double dx, dy;
double cellsize;
QVector < QVector <QString> > tips;
QColor m_boardColor;
Point m_lineStopPoint;
protected slots:
void boardChanged();
void reloadGame();
inline void showMoveError(QString s) { QMessageBox::critical(this, tr("Error!"), s); };
protected:
bool event(QEvent *e);
void paintEvent(QPaintEvent*);
void mouseReleaseEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
void drawBoard(QPainter &p);
void drawStones(QPainter &p);
void drawTerritory(QPainter &p);
void drawMarkup(QPainter &p);
void drawMark(QPainter &p, Point pnt, Markup mark);
void drawLabels(QPainter &p);
void drawLabels(QPainter &p, QVector <Label> v);
void drawFilling(QPainter &p, QVector <QVector<qint8> > flags, qint8 flag, const QBrush& brush);
void drawLineElements(QPainter &p, const QVector<Line>& vector);
void drawMoveNames(QPainter &p);
inline QPointF stoneToPoint(Point pnt) { return QPointF(stoneXToCanvas(pnt.col), stoneYToCanvas(pnt.row)); }
inline QPointF stoneXYToPoint(int x, int y) { return QPointF(stoneXToCanvas(x), stoneYToCanvas(y)); }
inline Point canvasToPoint(QPoint p) { return Point(canvasXToStone(p.x()), canvasYToStone(p.y())); }
inline int canvasXToStone(int x) { return round((x - dx) / cellsize); }
inline int canvasYToStone(int y) { return round((y - dy) / cellsize); }
inline double stoneXToCanvas(int x) { return dx + cellsize * double(x) - 0.5; }
inline double stoneYToCanvas(int y) { return dy + cellsize * double(y) - 0.5; }
inline QRectF stoneRect(Point pnt)
{
QPointF center = stoneToPoint(pnt);
QPointF delta(cellsize/2, cellsize/2);
return QRectF(center-delta, center+delta);
}
public:
virtual QSize sizeHint();
virtual void setGame(SgfGame* game);
Board(QWidget* parent = 0, SgfGame *game = 0);
virtual ~Board();
};
#endif // BOARD_H