2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef POINTCONVERTER_H
12 #define POINTCONVERTER_H
17 class PointConverter
{
21 inline Point
flipPoint(const Point
& p
) const {
23 return Point(7-p
.x
, 7-p
.y
);
29 PointConverter(int size
, bool flipped
)
31 , m_flipped(flipped
) { }
33 inline Point
toLogical(const QPoint
& real
) const { return flipPoint(Point(real
).div(m_size
)); }
34 inline QPoint
toReal(const Point
& logical
) const { return flipPoint(logical
) * m_size
; }
36 inline void flip(bool flipped
) { m_flipped
= flipped
; }
37 inline void resize(int size
) { m_size
= size
; }
41 class PointConverter
{
43 virtual ~PointConverter(){};
46 virtual bool flipped() const = 0;
47 virtual int squareSize() const = 0;
48 virtual Point
gridSize() const = 0;
50 virtual Point
flipPoint(const Point
& p
) const {
52 return gridSize()-Point(1,1)-p
;
56 virtual Point
toLogical(const QPoint
& real
) const {
57 return flipPoint(Point(real
).div( squareSize() ));
59 virtual QPoint
toReal(const Point
& logical
) const {
60 return flipPoint(logical
) * squareSize();
65 #endif // POINTCONVERTER_H