Small GAL refactorization, mostly correcting constness.
This commit is contained in:
parent
3106d25361
commit
f9f0b46b63
|
@ -35,9 +35,6 @@
|
||||||
|
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
|
|
||||||
///> Opacity of a single layer
|
|
||||||
const float LAYER_ALPHA = 0.8;
|
|
||||||
|
|
||||||
CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
wxEvtHandler* aPaintListener, const wxString& aName ) :
|
wxEvtHandler* aPaintListener, const wxString& aName ) :
|
||||||
wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
|
wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
|
||||||
|
@ -430,7 +427,7 @@ void CAIRO_GAL::SetLayerDepth( double aLayerDepth )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::Transform( MATRIX3x3D aTransformation )
|
void CAIRO_GAL::Transform( const MATRIX3x3D& aTransformation )
|
||||||
{
|
{
|
||||||
cairo_matrix_t cairoTransformation;
|
cairo_matrix_t cairoTransformation;
|
||||||
|
|
||||||
|
|
|
@ -112,17 +112,17 @@ void GAL::DrawGrid()
|
||||||
SetTarget( TARGET_NONCACHED );
|
SetTarget( TARGET_NONCACHED );
|
||||||
|
|
||||||
// Draw the origin marker
|
// Draw the origin marker
|
||||||
double origSize = static_cast<double>( gridOriginMarkerSize ) / worldScale;
|
double originSize = gridOriginMarkerSize / worldScale;
|
||||||
SetLayerDepth( GAL::GRID_DEPTH );
|
SetLayerDepth( GAL::GRID_DEPTH );
|
||||||
SetIsFill( false );
|
SetIsFill( false );
|
||||||
SetIsStroke( true );
|
SetIsStroke( true );
|
||||||
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
||||||
SetLineWidth( gridLineWidth / worldScale );
|
SetLineWidth( gridLineWidth / worldScale );
|
||||||
DrawLine( gridOrigin + VECTOR2D( -origSize, -origSize ),
|
DrawLine( gridOrigin + VECTOR2D( -originSize, -originSize ),
|
||||||
gridOrigin + VECTOR2D( origSize, origSize ) );
|
gridOrigin + VECTOR2D( originSize, originSize ) );
|
||||||
DrawLine( gridOrigin + VECTOR2D( -origSize, origSize ),
|
DrawLine( gridOrigin + VECTOR2D( -originSize, originSize ),
|
||||||
gridOrigin + VECTOR2D( origSize, -origSize ) );
|
gridOrigin + VECTOR2D( originSize, -originSize ) );
|
||||||
DrawCircle( gridOrigin, origSize * 0.7 );
|
DrawCircle( gridOrigin, originSize * 0.7 );
|
||||||
|
|
||||||
// Draw the grid
|
// Draw the grid
|
||||||
// For the drawing the start points, end points and increments have
|
// For the drawing the start points, end points and increments have
|
||||||
|
|
|
@ -600,7 +600,7 @@ void OPENGL_GAL::SetStrokeColor( const COLOR4D& aColor )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::Transform( MATRIX3x3D aTransformation )
|
void OPENGL_GAL::Transform( const MATRIX3x3D& aTransformation )
|
||||||
{
|
{
|
||||||
GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
|
GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ int VIEW::Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
|
||||||
|
|
||||||
VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
|
VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
|
||||||
{
|
{
|
||||||
MATRIX3x3D matrix = m_gal->GetWorldScreenMatrix().Inverse();
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
||||||
|
|
||||||
if( aAbsolute )
|
if( aAbsolute )
|
||||||
{
|
{
|
||||||
|
@ -212,7 +212,7 @@ VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
|
||||||
|
|
||||||
VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
|
VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
|
||||||
{
|
{
|
||||||
MATRIX3x3D matrix = m_gal->GetWorldScreenMatrix();
|
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
|
||||||
|
|
||||||
if( aAbsolute )
|
if( aAbsolute )
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,9 +35,7 @@ using namespace KIGFX;
|
||||||
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
|
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
|
||||||
|
|
||||||
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
|
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
|
||||||
VIEW_CONTROLS( aView ),
|
VIEW_CONTROLS( aView ), m_state( IDLE ), m_parentPanel( aParentPanel )
|
||||||
m_state( IDLE ),
|
|
||||||
m_parentPanel( aParentPanel )
|
|
||||||
{
|
{
|
||||||
m_parentPanel->Connect( wxEVT_MOTION,
|
m_parentPanel->Connect( wxEVT_MOTION,
|
||||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
/// @copydoc GAL::Transform()
|
/// @copydoc GAL::Transform()
|
||||||
virtual void Transform( MATRIX3x3D aTransformation );
|
virtual void Transform( const MATRIX3x3D& aTransformation );
|
||||||
|
|
||||||
/// @copydoc GAL::Rotate()
|
/// @copydoc GAL::Rotate()
|
||||||
virtual void Rotate( double aAngle );
|
virtual void Rotate( double aAngle );
|
||||||
|
@ -386,6 +386,9 @@ private:
|
||||||
|
|
||||||
/// Format used to store pixels
|
/// Format used to store pixels
|
||||||
static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24;
|
static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24;
|
||||||
|
|
||||||
|
///> Opacity of a single layer
|
||||||
|
static const float LAYER_ALPHA = 0.8;
|
||||||
};
|
};
|
||||||
} // namespace KIGFX
|
} // namespace KIGFX
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <wx/event.h>
|
|
||||||
|
|
||||||
#include <math/matrix3x3.h>
|
#include <math/matrix3x3.h>
|
||||||
|
|
||||||
#include <gal/color4d.h>
|
#include <gal/color4d.h>
|
||||||
|
@ -162,7 +160,7 @@ public:
|
||||||
virtual bool Show( bool aShow ) = 0;
|
virtual bool Show( bool aShow ) = 0;
|
||||||
|
|
||||||
/// @brief Returns GAL canvas size in pixels
|
/// @brief Returns GAL canvas size in pixels
|
||||||
VECTOR2D GetScreenPixelSize() const
|
const VECTOR2D& GetScreenPixelSize() const
|
||||||
{
|
{
|
||||||
return screenSize;
|
return screenSize;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +220,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the color for stroking the outline.
|
* @return the color for stroking the outline.
|
||||||
*/
|
*/
|
||||||
inline COLOR4D GetStrokeColor()
|
inline const COLOR4D& GetStrokeColor() const
|
||||||
{
|
{
|
||||||
return strokeColor;
|
return strokeColor;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +250,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the actual line width.
|
* @return the actual line width.
|
||||||
*/
|
*/
|
||||||
inline double GetLineWidth()
|
inline double GetLineWidth() const
|
||||||
{
|
{
|
||||||
return lineWidth;
|
return lineWidth;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +333,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param aTransformation is the ransformation matrix.
|
* @param aTransformation is the ransformation matrix.
|
||||||
*/
|
*/
|
||||||
virtual void Transform( MATRIX3x3D aTransformation ) = 0;
|
virtual void Transform( const MATRIX3x3D& aTransformation ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Rotate the context.
|
* @brief Rotate the context.
|
||||||
|
@ -428,11 +426,21 @@ public:
|
||||||
*
|
*
|
||||||
* @return the transformation matrix.
|
* @return the transformation matrix.
|
||||||
*/
|
*/
|
||||||
MATRIX3x3D GetWorldScreenMatrix()
|
const MATRIX3x3D& GetWorldScreenMatrix() const
|
||||||
{
|
{
|
||||||
return worldScreenMatrix;
|
return worldScreenMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the screen <-> world transformation matrix.
|
||||||
|
*
|
||||||
|
* @return the transformation matrix.
|
||||||
|
*/
|
||||||
|
const MATRIX3x3D& GetScreenWorldMatrix() const
|
||||||
|
{
|
||||||
|
return screenWorldMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the world <-> screen transformation matrix.
|
* @brief Set the world <-> screen transformation matrix.
|
||||||
*
|
*
|
||||||
|
@ -487,7 +495,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the look at point.
|
* @return the look at point.
|
||||||
*/
|
*/
|
||||||
inline VECTOR2D GetLookAtPoint()
|
inline const VECTOR2D& GetLookAtPoint() const
|
||||||
{
|
{
|
||||||
return lookAtPoint;
|
return lookAtPoint;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +515,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the zoom factor.
|
* @return the zoom factor.
|
||||||
*/
|
*/
|
||||||
inline double GetZoomFactor()
|
inline double GetZoomFactor() const
|
||||||
{
|
{
|
||||||
return zoomFactor;
|
return zoomFactor;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +536,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Returns the minimum depth in the currently used range (the top).
|
* @brief Returns the minimum depth in the currently used range (the top).
|
||||||
*/
|
*/
|
||||||
inline double GetMinDepth()
|
inline double GetMinDepth() const
|
||||||
{
|
{
|
||||||
return depthRange.x;
|
return depthRange.x;
|
||||||
}
|
}
|
||||||
|
@ -536,7 +544,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Returns the maximum depth in the currently used range (the bottom).
|
* @brief Returns the maximum depth in the currently used range (the bottom).
|
||||||
*/
|
*/
|
||||||
inline double GetMaxDepth()
|
inline double GetMaxDepth() const
|
||||||
{
|
{
|
||||||
return depthRange.y;
|
return depthRange.y;
|
||||||
}
|
}
|
||||||
|
@ -546,7 +554,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the actual world scale factor.
|
* @return the actual world scale factor.
|
||||||
*/
|
*/
|
||||||
inline double GetWorldScale()
|
inline double GetWorldScale() const
|
||||||
{
|
{
|
||||||
return worldScale;
|
return worldScale;
|
||||||
}
|
}
|
||||||
|
@ -694,7 +702,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the grid line width
|
* @return the grid line width
|
||||||
*/
|
*/
|
||||||
inline double GetGridLineWidth()
|
inline double GetGridLineWidth() const
|
||||||
{
|
{
|
||||||
return gridLineWidth;
|
return gridLineWidth;
|
||||||
}
|
}
|
||||||
|
@ -739,7 +747,7 @@ public:
|
||||||
* @param aPoint the pointposition in screen coordinates.
|
* @param aPoint the pointposition in screen coordinates.
|
||||||
* @return the point position in world coordinates.
|
* @return the point position in world coordinates.
|
||||||
*/
|
*/
|
||||||
inline virtual VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
|
inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
|
||||||
{
|
{
|
||||||
return VECTOR2D( screenWorldMatrix * aPoint );
|
return VECTOR2D( screenWorldMatrix * aPoint );
|
||||||
}
|
}
|
||||||
|
@ -750,15 +758,15 @@ public:
|
||||||
* @param aPoint the pointposition in world coordinates.
|
* @param aPoint the pointposition in world coordinates.
|
||||||
* @return the point position in screen coordinates.
|
* @return the point position in screen coordinates.
|
||||||
*/
|
*/
|
||||||
inline virtual VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
|
inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
|
||||||
{
|
{
|
||||||
return VECTOR2D( worldScreenMatrix * aPoint );
|
return VECTOR2D( worldScreenMatrix * aPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable/Disable cursor.
|
* @brief Enable/disable cursor.
|
||||||
*
|
*
|
||||||
* @param aIsCursorEnabled is true if the cursor should be enabled, else false.
|
* @param aCursorEnabled is true if the cursor should be drawn, else false.
|
||||||
*/
|
*/
|
||||||
inline void SetCursorEnabled( bool aCursorEnabled )
|
inline void SetCursorEnabled( bool aCursorEnabled )
|
||||||
{
|
{
|
||||||
|
|
|
@ -157,7 +157,7 @@ public:
|
||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
/// @copydoc GAL::Transform()
|
/// @copydoc GAL::Transform()
|
||||||
virtual void Transform( MATRIX3x3D aTransformation );
|
virtual void Transform( const MATRIX3x3D& aTransformation );
|
||||||
|
|
||||||
/// @copydoc GAL::Rotate()
|
/// @copydoc GAL::Rotate()
|
||||||
virtual void Rotate( double aAngle );
|
virtual void Rotate( double aAngle );
|
||||||
|
|
Loading…
Reference in New Issue