X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/513abb883f5b0d02a9458becb2802dc01479bd38..02bcd285fac7124a41292d905609220005f51087:/src/common/matrix.cpp diff --git a/src/common/matrix.cpp b/src/common/matrix.cpp index 05b6a90982..72a72517e4 100644 --- a/src/common/matrix.cpp +++ b/src/common/matrix.cpp @@ -1,17 +1,13 @@ -///////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Name: matrix.cpp // Purpose: wxTransformMatrix class // Author: Chris Breeze, Julian Smart // Modified by: Klaas Holwerda // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "matrix.h" -#endif +/////////////////////////////////////////////////////////////////////////////// // Note: this is intended to be used in wxDC at some point to replace // the current system of scaling/translation. It is not yet used. @@ -25,21 +21,22 @@ #ifndef WX_PRECOMP #include "wx/defs.h" +#include "wx/math.h" #endif -#include "wxmatrix.h" -#include +#include "wx/matrix.h" -const double pi = 3.1415926535; +static const double pi = M_PI; wxTransformMatrix::wxTransformMatrix(void) { - m_isIdentity = FALSE; + m_isIdentity = false; Identity(); } wxTransformMatrix::wxTransformMatrix(const wxTransformMatrix& mat) + : wxObject() { (*this) = mat; } @@ -74,10 +71,10 @@ void wxTransformMatrix::operator = (const wxTransformMatrix& mat) m_isIdentity = mat.m_isIdentity; } -bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) +bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const { - if (m_isIdentity==TRUE && mat.m_isIdentity==TRUE) - return TRUE; + if (m_isIdentity && mat.m_isIdentity) + return true; int i, j; for (i = 0; i < 3; i++) @@ -85,13 +82,13 @@ bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) for (j = 0; j < 3; j++) { if (m_matrix[i][j] != mat.m_matrix[i][j]) - return FALSE; + return false; } } - return TRUE; + return true; } -bool wxTransformMatrix::operator != (const wxTransformMatrix& mat) +bool wxTransformMatrix::operator != (const wxTransformMatrix& mat) const { return (! ((*this) == mat)); } @@ -147,11 +144,11 @@ bool wxTransformMatrix::Invert(void) } } m_isIdentity = IsIdentity1(); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -160,9 +157,9 @@ bool wxTransformMatrix::Identity(void) { m_matrix[0][0] = m_matrix[1][1] = m_matrix[2][2] = 1.0; m_matrix[1][0] = m_matrix[2][0] = m_matrix[0][1] = m_matrix[2][1] = m_matrix[0][2] = m_matrix[1][2] = 0.0; - m_isIdentity = TRUE; + m_isIdentity = true; - return TRUE; + return true; } // Scale by scale (isotropic scaling i.e. the same in x and y): @@ -182,7 +179,7 @@ bool wxTransformMatrix::Scale(double scale) } m_isIdentity = IsIdentity1(); - return TRUE; + return true; } @@ -296,7 +293,7 @@ bool wxTransformMatrix::Translate(double dx, double dy) m_isIdentity = IsIdentity1(); - return TRUE; + return true; } // Rotate clockwise by the given number of degrees: @@ -306,7 +303,7 @@ bool wxTransformMatrix::Translate(double dx, double dy) bool wxTransformMatrix::Rotate(double degrees) { Rotate(-degrees,0,0); - return TRUE; + return true; } // counter clockwise rotate around a point @@ -384,13 +381,13 @@ bool wxTransformMatrix::TransformPoint(double x, double y, double& tx, double& t { if (IsIdentity()) { - tx = x; ty = y; return TRUE; + tx = x; ty = y; return true; } tx = x * m_matrix[0][0] + y * m_matrix[1][0] + m_matrix[2][0]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + m_matrix[2][1]; - return TRUE; + return true; } // Transform a point from device to logical coordinates. @@ -407,18 +404,18 @@ bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, do { if (IsIdentity()) { - tx = x; ty = y; return TRUE; + tx = x; ty = y; return true; } double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2]; if (z == 0.0) { // z = 0.0000001; - return FALSE; + return false; } tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1]; - return TRUE; + return true; } wxTransformMatrix& wxTransformMatrix::operator*=(const double& t)