Commit 34094e77 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix and enable optimized grid drawing and other minor changes.

* Fix optimized bitmap grid drawing method.
* Enable optimized grid drawing method on Windows and Linux.
* Create a helper class for resetting and restoring device context scale
  and origin settings for blitting purposes.
* Use wxLogTrace instead of wxLogDebug for coordinate dumping in
  drawpanel.cpp.  See comments for more information on enabling coordinate
  tracing.
* Add flag to allow hiding the drawing cross hair.  Hide cross hair by
  default on OSX.
* Move get cross hair device position code from draw panel object to base
  screen object.
* Remove redundant parent member variable from draw panel object by
  overriding wxWindow::GetParent() method.
parent 563bff9d
......@@ -423,6 +423,18 @@ wxPoint BASE_SCREEN::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize )
}
wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
{
wxPoint pos = m_Curseur - m_DrawOrg;
double scalar = GetScalingFactor();
pos.x = wxRound( (double) pos.x * scalar );
pos.y = wxRound( (double) pos.y * scalar );
return pos;
}
/* free the undo and the redo lists
*/
void BASE_SCREEN::ClearUndoRedoList()
......
......@@ -727,12 +727,12 @@ void EDA_DRAW_FRAME::LoadSettings()
bool btmp;
if ( cfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
SetGridVisibility( btmp);
SetGridVisibility( btmp );
int itmp;
if( cfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
SetGridColor(itmp);
SetGridColor( itmp );
cfg->Read( m_FrameName + LastGridSizeId, &m_LastGridSizeId, 0L );
}
......
This diff is collapsed.
......@@ -198,7 +198,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur;
sheet->LastScreen()->m_Curseur = pos;
curpos = DrawPanel->CursorScreenPosition();
curpos = GetScreen()->GetCrossHairScreenPosition();
DrawPanel->GetViewStart( &( GetScreen()->m_StartVisu.x ),
&( GetScreen()->m_StartVisu.y ) );
......
......@@ -134,7 +134,9 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
layerDC.SelectObject( *layerBitmap );
EDA_Rect tmpRect = aPanel->m_ClipBox;
aPanel->DoPrepareDC( layerDC );
aPanel->m_ClipBox = tmpRect;
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
......
......@@ -244,7 +244,7 @@ public:
* @return the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( )
*/
double GetScalingFactor()
double GetScalingFactor() const
{
return (double) m_ZoomScalar / (double) GetZoom();
}
......@@ -365,6 +365,13 @@ public:
*/
wxPoint GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize = NULL );
/**
* Function GetCursorScreenPosition
* returns the cross hair position in device (display) units.b
* @return The current cross hair position.
*/
wxPoint GetCrossHairScreenPosition() const;
/**
* Function GetNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
......
This diff is collapsed.
......@@ -86,6 +86,55 @@ private:
};
/**
* Class EDA_BLIT_NORMALIZER
* is a helper class for clearing a device context scale and offset parameters before
* performing a Blit operation.
* <p>
* This class keeps a temporary copy of the scale and offset parameters of a device
* context and then restores them when it goes out of scope.
* </p>
*/
class EDA_BLIT_NORMALIZER
{
public:
EDA_BLIT_NORMALIZER( wxDC* aDC )
: m_dc( aDC )
{
if( aDC )
{
aDC->GetUserScale( &m_userScaleX, &m_userScaleY );
aDC->GetLogicalOrigin( &m_logicalOriginX, &m_logicalOriginY );
aDC->GetDeviceOrigin( &m_deviceOriginX, &m_deviceOriginY );
aDC->SetUserScale( 1.0, 1.0 );
aDC->SetLogicalOrigin( 0, 0 );
aDC->SetDeviceOrigin( 0, 0 );
}
}
~EDA_BLIT_NORMALIZER()
{
if( m_dc )
{
m_dc->SetUserScale( m_userScaleX, m_userScaleY );
m_dc->SetLogicalOrigin( m_logicalOriginX, m_logicalOriginY );
m_dc->SetDeviceOrigin( m_deviceOriginX, m_deviceOriginY );
}
}
private:
wxDC* m_dc;
double m_userScaleX;
double m_userScaleY;
int m_logicalOriginX;
int m_logicalOriginY;
int m_deviceOriginX;
int m_deviceOriginY;
DECLARE_NO_COPY_CLASS( EDA_BLIT_NORMALIZER )
};
#if USE_WX_GRAPHICS_CONTEXT
#include <wx/dcgraph.h>
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment