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
......
......@@ -64,12 +64,9 @@ void WinEDA_GerberFrame::PrintPage( wxDC* aDC, int aPrintMasklayer,
}
/*******************************************************************/
void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
/* Redraws the full screen, including axis and grid
*/
void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
......@@ -78,8 +75,6 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
wxBusyCursor dummy;
GRSetDrawMode( DC, GR_COPY );
int drawMode = -1;
switch ( GetDisplayMode() )
......@@ -96,9 +91,9 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
drawMode = GR_OR;
break;
}
GetBoard()->Draw( DrawPanel, DC,
drawMode, // this needs to be GR_COPY or GR_OR, set from a toggle button.
wxPoint( 0, 0 ) );
// Draw according to the current setting. This needs to be GR_COPY or GR_OR.
GetBoard()->Draw( DrawPanel, DC, drawMode, wxPoint( 0, 0 ) );
// Draw the "background" now, i.e. grid and axis after gerber layers
// because most of time the actual background is erased by succesive drawings of each gerber
......@@ -146,20 +141,12 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
aDC->GetDeviceOrigin( &dev_org.x, &dev_org.y );
aDC->GetLogicalOrigin( &logical_org.x, &logical_org.y );
aDC->GetUserScale( &dc_scalex, &dc_scaley );
if( aDrawMode != -1 )
{
aDC->SetUserScale( 1.0, 1.0 );
aDC->SetDeviceOrigin( 0, 0 );
aDC->SetLogicalOrigin( 0, 0 );
}
#endif
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
wxBitmap* layerBitmap = NULL;
wxBitmap* screenBitmap = NULL;
wxBitmap* layerBitmap;
wxBitmap* screenBitmap;
wxMemoryDC layerDC; // used sequentially for each gerber layer
wxMemoryDC screenDC;
......@@ -168,24 +155,27 @@ 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 );
aPanel->DoPrepareDC( layerDC );
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
aPanel->DrawBackGround( &layerDC );
screenDC.SelectObject( *screenBitmap );
screenDC.SetBackground( bgBrush );
screenDC.SetBackgroundMode( wxSOLID );
screenDC.Clear();
aPanel->DoPrepareDC(layerDC);
aPanel->DrawBackGround( &layerDC );
plotDC = &layerDC;
}
bool doBlit = false; // this flag requests an image transfert to actual screen when true.
for( int layer = 0; layer < 32; layer++ )
{
if( !GetBoard()->IsLayerVisible( layer ) )
continue;
GERBER_IMAGE* gerber = g_GERBER_List[layer];
if( gerber == NULL ) // Graphic layer not yet used
continue;
......@@ -193,40 +183,38 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
{
// Draw each layer into a bitmap first. Negative Gerber
// layers are drawn in background color.
if( gerber->HasNegativeItems() )
if( gerber->HasNegativeItems() && doBlit )
{
if( doBlit )
{
#if AVOID_BLIT_SCALE_BUG
layerDC.SetUserScale( 1.0, 1.0 );
layerDC.SetDeviceOrigin( 0, 0 );
layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1.0, 1.0 );
layerDC.SetDeviceOrigin( 0, 0 );
layerDC.SetLogicalOrigin( 0, 0 );
#endif
if( aDrawMode == GR_COPY )
{
// Use the layer bitmap itself as a mask when blitting.
// The bitmap cannot be referenced by a device context
// when setting the mask.
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
// On Linux with a large screen, this version is much faster and without flicker,
// but gives a PCBNEW look where layer colors blend together. Plus it works
// only because the background color is black. But it may be more useable for some.
// The difference is due in part because of the cpu cycles needed to create the
// monochromatic bitmap above, and the extra time needed to do bit indexing
// into the monochromatic bitmap on the blit above.
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
if( aDrawMode == GR_COPY )
{
// Use the layer bitmap itself as a mask when blitting. The bitmap
// cannot be referenced by a device context when setting the mask.
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
// On Linux with a large screen, this version is much faster and without
// flicker, but gives a PCBNEW look where layer colors blend together.
// Plus it works only because the background color is black. But it may
// be more useable for some. The difference is due in part because of
// the cpu cycles needed to create the monochromatic bitmap above, and
// the extra time needed to do bit indexing into the monochromatic bitmap
// on the blit above.
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
doBlit = false;
layerDC.Clear();
}
doBlit = false;
layerDC.Clear();
}
#if AVOID_BLIT_SCALE_BUG
......@@ -234,6 +222,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC.SetDeviceOrigin( dev_org.x, dev_org.y );
layerDC.SetLogicalOrigin( logical_org.x, logical_org.y );
#endif
if( gerber->m_ImageNegative )
{
// Draw background negative (i.e. in graphic layer color) for negative images.
......@@ -252,33 +241,38 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
}
int dcode_highlight = 0;
if( layer == m_PcbFrame->GetScreen()->m_Active_Layer )
dcode_highlight = gerber->m_Selected_Tool;
int layerdrawMode = GR_COPY;
if( aDrawMode == GR_OR && !gerber->HasNegativeItems() )
layerdrawMode = GR_OR;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer() != layer )
continue;
int drawMode = layerdrawMode;
if( dcode_highlight && dcode_highlight == gerb_item->m_DCode )
drawMode |= GR_SURBRILL;
gerb_item->Draw( aPanel, plotDC, drawMode );
doBlit = true;
}
}
if( doBlit && aDrawMode != -1 ) // Blit is used only if aDrawMode >= 0
{
// this is the last transfert to screenDC
// If there are no negative items, this is the only one
#if AVOID_BLIT_SCALE_BUG
// this is the last transfert to screenDC. If there are no negative items, this is
// the only one
#if AVOID_BLIT_SCALE_BUG
if( aDrawMode != -1 )
{
layerDC.SetUserScale( 1.0, 1.0 );
......@@ -290,25 +284,28 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
{
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR, false );
}
}
if( aDrawMode != -1 )
{
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY );
#if AVOID_BLIT_SCALE_BUG
// Restore scale and offsets values:
aDC->SetUserScale( dc_scalex, dc_scaley );
aDC->SetDeviceOrigin( dev_org.x, dev_org.y );
aDC->SetLogicalOrigin( logical_org.x, logical_org.y );
#endif
layerDC.SelectObject( wxNullBitmap );
screenDC.SelectObject( wxNullBitmap );
delete layerBitmap;
delete screenBitmap;
}
......@@ -328,11 +325,14 @@ void WinEDA_GerberFrame::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
GRSetDrawMode( aDC, aDrawMode );
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( GetBoard()->IsLayerVisible( gerb_item->GetLayer() ) == false )
continue;
if( gerb_item->m_DCode <= 0 )
continue;
......@@ -354,6 +354,7 @@ void WinEDA_GerberFrame::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
width = MIN( gerb_item->m_Size.x, gerb_item->m_Size.y );
orient = TEXT_ORIENT_HORIZ;
if( gerb_item->m_Flashed )
{
// A reasonnable size for text is width/3 because most of time this text has 3 chars.
......@@ -362,6 +363,7 @@ void WinEDA_GerberFrame::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
else // this item is a line
{
wxPoint delta = gerb_item->m_Start - gerb_item->m_End;
if( abs( delta.x ) < abs( delta.y ) )
orient = TEXT_ORIENT_VERT;
// A reasonnable size for text is width/2 because text needs margin below and above it.
......@@ -371,8 +373,7 @@ void WinEDA_GerberFrame::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
int color = g_ColorsSettings.GetItemColor( DCODES_VISIBLE );
DrawGraphicText( DrawPanel, aDC,
pos, (EDA_Colors) color, Line,
DrawGraphicText( DrawPanel, aDC, pos, (EDA_Colors) color, Line,
orient, wxSize( width, width ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
0, false, false );
......
......@@ -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 );
......
......@@ -26,103 +26,86 @@
/****************************************/
BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
EVT_SIZE( WinEDA_GerberFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom )
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
// Menu Files:
EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW,
WinEDA_GerberFrame::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory )
EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions )
// menu Preferences
EVT_MENU( ID_CONFIG_REQ,
WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_CONFIG_SAVE,
WinEDA_GerberFrame::Process_Config )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START,
ID_PREFERENCES_HOTKEY_END,
WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
EDA_DRAW_FRAME::SetLanguage )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE,
WinEDA_GerberFrame::Process_Special_Functions )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE,
WinEDA_GerberFrame::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL,
WinEDA_GerberFrame::Process_Special_Functions )
// Vertical toolbar:
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_GerberFrame::Process_Special_Functions )
// Pop up menu
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
WinEDA_GerberFrame::Process_Special_Functions )
// Option toolbar
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_0,
WinEDA_GerberFrame::OnSelectDisplayMode )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_1,
WinEDA_GerberFrame::OnSelectDisplayMode )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_2,
WinEDA_GerberFrame::OnSelectDisplayMode )
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
EVT_SIZE( WinEDA_GerberFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom )
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
// Menu Files:
EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, WinEDA_GerberFrame::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_GerberFrame::OnFileHistory )
EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions )
// menu Preferences
EVT_MENU( ID_CONFIG_REQ, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_CONFIG_SAVE, WinEDA_GerberFrame::Process_Config )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START,
ID_PREFERENCES_HOTKEY_END,
WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_MENU( ID_GERBVIEW_OPTIONS_SETUP, WinEDA_GerberFrame::InstallGerberOptionsDialog )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, WinEDA_GerberFrame::Process_Special_Functions )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, WinEDA_GerberFrame::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, WinEDA_GerberFrame::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_TOOL,
WinEDA_GerberFrame::Process_Special_Functions )
// Vertical toolbar:
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GERBVIEW_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_GerberFrame::Process_Special_Functions )
// Pop up menu
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
// Option toolbar
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_0, WinEDA_GerberFrame::OnSelectDisplayMode )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_1, WinEDA_GerberFrame::OnSelectDisplayMode )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GBR_MODE_2, WinEDA_GerberFrame::OnSelectDisplayMode )
END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
const wxString& title,
......@@ -171,13 +154,9 @@ END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( GetDisplayMode() == 1 || GetDisplayMode() == 2 )
DrawPanel->m_DisableEraseBG = true;
ReCreateMenuBar();
ReCreateHToolbar();
// ReCreateVToolbar(); // Currently: no right vertical toolbar
ReCreateOptToolbar();
m_auimgr.SetManagedWindow( this );
......@@ -203,26 +182,26 @@ END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father
if( m_HToolBar )
m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
if( m_VToolBar )
m_auimgr.AddPane( m_VToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Row( 1 ) );
m_auimgr.AddPane( m_LayersManager,
lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) );
lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Row( 0 ) );
if( m_OptionsToolBar )
m_auimgr.AddPane( m_OptionsToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
if( DrawPanel )
m_auimgr.AddPane( DrawPanel,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
if( MsgPanel )
m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
ReFillLayerWidget(); // this is near end because contents establish size
......@@ -256,6 +235,7 @@ int WinEDA_GerberFrame::BestZoom()
EDA_Rect bbox;
BOARD_ITEM* item = GetBoard()->m_Drawings;
bbox = ( (GERBER_DRAW_ITEM*) item )->GetBoundingBox();
for( ; item; item = item->Next() )
{
......@@ -263,11 +243,10 @@ int WinEDA_GerberFrame::BestZoom()
bbox.Merge( gerb_item->GetBoundingBox() );
}
bbox.Inflate( wxRound( GetScreen()->GetGridSize().x * 2 ),
wxRound( GetScreen()->GetGridSize().y * 2 ) );
wxSize size = DrawPanel->GetClientSize();
x = bbox.GetWidth() / (double) size.x;
y = bbox.GetHeight() / (double) size.y;
x = (double) bbox.GetWidth() / (double) size.x;
y = (double) bbox.GetHeight() / (double) size.y;
GetScreen()->m_Curseur = bbox.Centre();
int best_zoom = wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar );
......@@ -433,13 +412,16 @@ void WinEDA_GerberFrame::syncLayerBox()
m_SelLayerBox->SetSelection( getActiveLayer() );
int dcodeSelected = -1;
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer()];
if( gerber )
dcodeSelected = gerber->m_Selected_Tool;
if( m_DCodeSelector )
{
m_DCodeSelector->SetDCodeSelection( dcodeSelected );
m_DCodeSelector->Enable( gerber != NULL );
}
UpdateTitleAndInfo();
}
......@@ -560,8 +542,8 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
// Display Image Name and Layer Name (from the current gerber data):
text.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
GetChars( gerber->m_ImageName ),
GetChars( gerber->GetLayerParams().m_LayerName ) );
GetChars( gerber->m_ImageName ),
GetChars( gerber->GetLayerParams().m_LayerName ) );
SetStatusText( text, 0 );
// Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
......@@ -586,21 +568,19 @@ void WinEDA_GerberFrame::OnSelectDisplayMode( wxCommandEvent& event )
{
case ID_TB_OPTIONS_SHOW_GBR_MODE_0:
SetDisplayMode( 0 );
DrawPanel->m_DisableEraseBG = false;
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_1:
SetDisplayMode( 1 );
DrawPanel->m_DisableEraseBG = true;
break;
case ID_TB_OPTIONS_SHOW_GBR_MODE_2:
SetDisplayMode( 2 );
DrawPanel->m_DisableEraseBG = true;
break;
}
SetToolbars();
if( GetDisplayMode() != oldMode )
DrawPanel->Refresh();
}
......@@ -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