Commit e01f8967 authored by Wayne Stambaugh's avatar Wayne Stambaugh

GerbView rendering bug fix and other minor improvements.

* Fix rendering bug in GerbView caused by wxDC scaling change caused by
  setting the wxDC clipping region.
* Eliminate the need to have optional background erasing as the change
  above fixed that problem as well.
* Default cursor handling improvements.
parent a86385bf
......@@ -307,4 +307,5 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC )
screen->m_BlockLocate.m_Command = BLOCK_IDLE;
Panel->GetParent()->DisplayToolMsg( wxEmptyString );
Panel->SetCursor( Panel->GetDefaultCursor() );
}
......@@ -28,11 +28,10 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPage( this );
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
{
if( GetScreen()->IsBlockActive() )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor ) );
DrawPanel->SetCursor( wxCursor( DrawPanel->GetDefaultCursor() ) );
DrawPanel->UnManageCursor();
}
......
......@@ -388,10 +388,9 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
// Keep default cursor in toolbars
SetCursor( wxNullCursor );
// Change Cursor in DrawPanel only
if( DrawPanel )
// Change DrawPanel cursor if requested.
if( DrawPanel && aCursor >= 0 )
{
DrawPanel->m_PanelDefaultCursor = aCursor;
DrawPanel->SetCursor( aCursor );
}
......
......@@ -58,8 +58,7 @@ END_EVENT_TABLE()
EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
const wxPoint& pos, const wxSize& size ) :
wxScrolledWindow( parent, id, pos, size,
wxBORDER | wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE )
wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL )
{
m_Parent = parent;
wxASSERT( m_Parent );
......@@ -82,7 +81,6 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_AbortEnable = m_AbortRequest = false;
m_AutoPAN_Enable = TRUE;
m_IgnoreMouseEvents = 0;
m_DisableEraseBG = false;
ManageCurseur = NULL;
ForceCloseManageCurseur = NULL;
......@@ -92,11 +90,11 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_AutoPAN_Request = false;
m_Block_Enable = false;
m_PanelDefaultCursor = m_PanelCursor = wxCURSOR_ARROW;
m_defaultCursor = m_cursor = wxCURSOR_ARROW;
m_CursorLevel = 0;
m_PrintIsMirrored = false;
wxLog::AddTraceMask( KICAD_TRACE_COORDS );
// wxLog::AddTraceMask( KICAD_TRACE_COORDS );
}
......@@ -517,8 +515,7 @@ void EDA_DRAW_PANEL::OnPaint( wxPaintEvent& event )
wxRect region = GetUpdateRegion().GetBox();
SetClipBox( paintDC, &region );
wxDCClipper dcclip( paintDC, m_ClipBox );
ReDraw( &paintDC, m_DisableEraseBG ? false : true );
ReDraw( &paintDC, true );
}
......@@ -549,8 +546,15 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
GRResetPenAndBrush( DC );
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
DC->SetBackgroundMode( wxSOLID );
m_Parent->RedrawActiveWindow( DC, erasebg );
// Verfies that the clipping is working correctly. If these two sets of numbers are
// not the same or really close. The clipping algorithms are broken.
wxLogTrace( KICAD_TRACE_COORDS,
wxT( "Clip box: (%d, %d, %d, %d), Draw extents (%d, %d, %d, %d)" ),
m_ClipBox.GetX(), m_ClipBox.GetY(), m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
DC->MinX(), DC->MinY(), DC->MaxX(), DC->MaxY() );
}
......@@ -1088,7 +1092,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
else
{
m_AutoPAN_Request = TRUE;
SetCursor( m_PanelCursor = wxCURSOR_SIZING );
SetCursor( m_cursor = wxCURSOR_SIZING );
}
}
}
......@@ -1116,18 +1120,18 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_AutoPAN_Request = false;
}
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
SetCursor( m_cursor = m_defaultCursor );
}
else if( screen->m_BlockLocate.m_State == STATE_BLOCK_END )
{
m_AutoPAN_Request = false;
m_Parent->HandleBlockEnd( &DC );
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
SetCursor( m_cursor = m_defaultCursor );
if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
{
m_AutoPAN_Request = TRUE;
SetCursor( m_PanelCursor = wxCURSOR_HAND );
SetCursor( wxCURSOR_HAND );
}
}
}
......@@ -1163,7 +1167,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
{
long key, localkey;
bool escape = false;
wxPoint pos;
key = localkey = event.GetKeyCode();
......@@ -1180,7 +1183,13 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
return;
case WXK_ESCAPE:
escape = m_AbortRequest = TRUE;
m_AbortRequest = true;
if( ManageCurseur && ForceCloseManageCurseur )
UnManageCursor( -1, m_defaultCursor );
else
UnManageCursor( 0, m_cursor, wxEmptyString );
break;
}
......@@ -1204,21 +1213,6 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
g_KeyPressed = localkey;
if( escape )
{
if( ManageCurseur && ForceCloseManageCurseur )
{
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
ForceCloseManageCurseur( this, &DC );
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
}
else
{
m_PanelCursor = m_PanelDefaultCursor = wxCURSOR_ARROW;
m_Parent->SetToolID( 0, m_PanelCursor, wxEmptyString );
}
}
// Some key commands use the current mouse position: refresh it.
pos = wxGetMousePosition() - GetScreenPosition();
......@@ -1293,6 +1287,8 @@ void EDA_DRAW_PANEL::UnManageCursor( int id, int cursor, const wxString& title )
{
INSTALL_UNBUFFERED_DC( dc, this );
ForceCloseManageCurseur( this, &dc );
ManageCurseur = NULL;
ForceCloseManageCurseur = NULL;
m_AutoPAN_Request = false;
}
......
......@@ -33,7 +33,7 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
*/
INSTALL_DC( dc, DrawPanel );
DrawPanel->SetClipBox( dc );
DrawPanel->ReDraw( &dc, DrawPanel->m_DisableEraseBG ? false : true );
DrawPanel->ReDraw( &dc, true );
#else
DrawPanel->Refresh();
DrawPanel->Update();
......
......@@ -187,7 +187,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
block->ClearItemsList();
}
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh();
}
......@@ -324,7 +324,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
if( zoom_command )
......@@ -419,7 +419,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_ZOOM: /* Window Zoom */
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
Window_Zoom( GetScreen()->m_BlockLocate );
break;
......@@ -489,7 +489,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
}
......
......@@ -184,7 +184,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh( true );
}
......@@ -273,7 +273,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
GetScreen()->SetCurItem( NULL );
DrawPanel->Refresh( true );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
......
......@@ -134,8 +134,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
default:
// Stop the current command and deselect the current tool
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = wxCURSOR_ARROW;
DrawPanel->UnManageCursor( 0, DrawPanel->m_PanelCursor );
DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() );
break;
}
......@@ -794,8 +793,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
if( screen->IsBlockActive() )
{
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor ) );
DrawPanel->SetCursor( wxCursor( DrawPanel->GetDefaultCursor() ) );
screen->ClearBlockCommand();
// Stop the current command (if any) but keep the current tool
......
This diff is collapsed.
......@@ -108,7 +108,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
if( m_ID_current_state == 0 )
SetToolID( 0, 0, wxEmptyString );
else
DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
break;
default:
......
......@@ -175,7 +175,7 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
}
}
Zoom_Automatique( false );
Zoom_Automatique( true );
GetScreen()->SetRefreshReq();
g_SaveTime = time( NULL );
......
This diff is collapsed.
......@@ -19,6 +19,8 @@ class EDA_DRAW_PANEL : public wxScrolledWindow
{
private:
EDA_DRAW_FRAME* m_Parent;
int m_cursor; ///< Current mouse cursor shape id.
int m_defaultCursor; ///< The default mouse cursor shape id.
public:
EDA_Rect m_ClipBox; // the clipbox used in screen
......@@ -35,10 +37,6 @@ public:
bool m_AbortEnable; // TRUE if abort button or menu to
// be displayed
bool m_DisableEraseBG; // if true: do not allow background erasure
// (used to reduce flicker in Gerbview )
bool m_AutoPAN_Enable; // TRUE to allow auto pan
bool m_AutoPAN_Request; // TRUE to request an auto pan
// (will be made only if
......@@ -57,10 +55,6 @@ public:
// because arcs are oriented, and
// in mirror mode, orientations are
// reversed
int m_PanelDefaultCursor; // Current mouse cursor default
// shape id for this window
int m_PanelCursor; // Current mouse cursor shape id
// for this window
int m_CursorLevel; // Index for cursor redraw in XOR
// mode
......@@ -190,7 +184,10 @@ public:
* <p>
* If \a aRect is NULL, then the entire visible area of the screen is used as the clip
* area. The clip box is used when drawing to determine which objects are not visible
* and do not need to be drawn.
* and do not need to be drawn. Note that this is not the same as setting the device
* context clipping with wxDC::SetClippingRegion(). This is the rectangle used by the
* drawing functions in gr_basic.cpp used to determine if the item to draw is off screen
* and therefore not drawn.
* </p>
* @param aDC The device context use for drawing with the correct scale and
* offsets already configured. See DoPrepareDC().
......@@ -255,17 +252,25 @@ public:
// remove the grid cursor from the display
void CursorOff( wxDC* DC );
// display the grid cursor
void CursorOn( wxDC* DC );
/**
* Release managed cursor.
*
* Check to see if the cursor is being managed for block or editing
* commands and release it.
* Check to see if the cursor is being managed for block or editing commands and release it.
* @param aId The command ID to restore or -1 to keep the current command ID.
* @param aCursorId The wxWidgets stock cursor ID to set the cursor to or -1 to keep the
* current cursor.
* @param aTitle The tool message to display in the status bar or wxEmptyString to clear
* the message.
*/
void UnManageCursor( int id = -1, int cursor = -1,
const wxString& title = wxEmptyString );
void UnManageCursor( int aId = -1, int aCursorId = -1,
const wxString& aTitle = wxEmptyString );
int GetDefaultCursor() const { return m_defaultCursor; }
DECLARE_EVENT_TABLE()
};
......
......@@ -98,7 +98,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
break;
default: // Abort a current command (if any)
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() );
break;
}
......
......@@ -93,12 +93,9 @@ static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, const wxString& t
nocmd = dlg.ShowModal();
parent->GetScreen()->m_Curseur = oldpos;
parent->DrawPanel->MouseToCursorSchema();
parent->DrawPanel->m_IgnoreMouseEvents = false;
parent->DrawPanel->SetCursor( parent->DrawPanel->m_PanelCursor =
parent->DrawPanel->m_PanelDefaultCursor );
parent->DrawPanel->SetCursor( parent->DrawPanel->GetDefaultCursor() );
return nocmd ? false : true;
}
......@@ -255,8 +252,7 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
}
DisplayToolMsg( wxEmptyString );
DrawPanel->SetCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor );
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
}
......
......@@ -195,8 +195,7 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
DrawPanel->Refresh( TRUE );
}
......@@ -281,9 +280,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
SetCurItem( NULL );
DrawPanel->Refresh( TRUE );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
......
......@@ -133,7 +133,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
if( m_ID_current_state == 0 )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
else
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
SetCursor( DrawPanel->GetDefaultCursor() );
break;
default: // Finish (abort) the command
......
......@@ -27,7 +27,7 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event )
if( fn != wxEmptyString )
{
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() );
::wxSetWorkingDirectory( ::wxPathOnly( fn ) );
LoadOnePcbFile( fn );
ReCreateAuxiliaryToolbar();
......@@ -45,7 +45,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
wxString msg;
// If an edition is in progress, stop it
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
DrawPanel->UnManageCursor( 0, DrawPanel->GetDefaultCursor() );
switch( id )
{
......
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