rotation and style changing works

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@144 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-12-22 15:08:49 +00:00
parent 5a8febd82a
commit 274cb1117f
14 changed files with 82 additions and 52 deletions
+7 -4
View File
@@ -17,12 +17,15 @@ int constrain_angle(int angle) {
return (a / 90) * 90; // multiple of 90
}
Rotation::Rotation(int angle, const RealRect& rect, double zoom)
Rotation::Rotation(int angle, const RealRect& rect, double zoom, bool is_internal)
: angle(constrain_angle(angle))
, size(rect.size())
, origin(rect.position())
, zoom(zoom)
{
if (is_internal) {
size = trNoNeg(size);
}
// set origin
if (revX()) origin.x += size.width;
if (revY()) origin.y += size.height;
@@ -108,12 +111,12 @@ Rotater::~Rotater() {
// ----------------------------------------------------------------------------- : RotatedDC
RotatedDC::RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality)
: Rotation(angle, rect, zoom)
RotatedDC::RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality, bool is_internal)
: Rotation(angle, rect, zoom, is_internal)
, dc(dc), high_quality(high_quality)
{}
RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, bool high_quality = false)
RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, bool high_quality)
: Rotation(rotation)
, dc(dc), high_quality(high_quality&&false)
{}
+8 -4
View File
@@ -22,9 +22,11 @@
*/
class Rotation {
public:
/// Construct a rotation object with the given rectangle of external coordinates
/// and a given rotation angle and zoom factor
Rotation(int angle, const RealRect& rect, double zoom = 1.0);
/// Construct a rotation object
/** with the given rectangle of external coordinates and a given rotation angle and zoom factor.
* if is_internal then the rect gives the internal coordinates, its origin should be (0,0)
*/
Rotation(int angle, const RealRect& rect, double zoom = 1.0, bool is_internal = false);
/// Change the zoom factor
inline void setZoom(double z) { zoom = z; }
@@ -34,6 +36,8 @@ class Rotation {
inline RealSize getInternalSize() const { return trInvNoNeg(size); }
/// The intarnal rectangle (origin at (0,0))
inline RealRect getInternalRect() const { return RealRect(RealPoint(0,0), getInternalSize()); }
/// The size of the external rectangle (as passed to the constructor) == trNoNeg(getInternalSize())
inline RealSize getExternalSize() const { return size; }
/// The external rectangle (as passed to the constructor) == trNoNeg(getInternalRect())
RealRect getExternalRect() const;
@@ -120,7 +124,7 @@ class Rotater {
*/
class RotatedDC : public Rotation {
public:
RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality);
RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality, bool is_internal = false);
RotatedDC(DC& dc, const Rotation& rotation, bool high_quality);
// --------------------------------------------------- : Drawing