Remove more legacy editing code.

This commit is contained in:
Jeff Young 2019-05-27 17:16:54 +01:00
parent 0a6b1ea256
commit 9d9745b555
56 changed files with 434 additions and 2990 deletions

View File

@ -107,7 +107,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_canvas = NULL; m_canvas = NULL;
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
m_galCanvas = NULL; m_galCanvas = NULL;
m_galCanvasActive = false;
m_actions = NULL; m_actions = NULL;
m_toolManager = NULL; m_toolManager = NULL;
m_toolDispatcher = NULL; m_toolDispatcher = NULL;
@ -453,7 +452,7 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
SetCursor( wxNullCursor ); SetCursor( wxNullCursor );
// Change GAL canvas cursor if requested. // Change GAL canvas cursor if requested.
if( IsGalCanvasActive() && aCursor >= 0 ) if( aCursor >= 0 )
GetGalCanvas()->SetCurrentCursor( aCursor ); GetGalCanvas()->SetCurrentCursor( aCursor );
DisplayToolMsg( aToolMsg ); DisplayToolMsg( aToolMsg );
@ -475,8 +474,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
int defaultCursor = wxCURSOR_DEFAULT; int defaultCursor = wxCURSOR_DEFAULT;
// Change GAL canvas cursor if requested. // Change GAL canvas cursor if requested.
if( IsGalCanvasActive() ) defaultCursor = GetGalCanvas()->GetDefaultCursor();
defaultCursor = GetGalCanvas()->GetDefaultCursor();
SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
} }
@ -643,31 +641,16 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
// Display the same view after canvas switching // Display the same view after canvas switching
if( aEnable ) KIGFX::VIEW_CONTROLS* viewControls = galCanvas->GetViewControls();
{ viewControls->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
// Switch to GAL renderer from legacy viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
if( !m_galCanvasActive ) viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
{
// Set up viewport
KIGFX::VIEW* view = galCanvas->GetView();
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
// Transfer EDA_DRAW_PANEL settings
KIGFX::VIEW_CONTROLS* viewControls = galCanvas->GetViewControls();
viewControls->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
}
galCanvas->SetEvtHandlerEnabled( aEnable ); galCanvas->SetEvtHandlerEnabled( aEnable );
galCanvas->StartDrawing(); galCanvas->StartDrawing();
// Reset current tool on switch(); // Reset current tool on switch();
SetNoToolSelected(); SetNoToolSelected();
m_galCanvasActive = aEnable;
} }

View File

@ -134,7 +134,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_canvas = NULL; m_canvas = NULL;
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
m_galCanvas = NULL; m_galCanvas = NULL;
m_galCanvasActive = false;
m_actions = NULL; m_actions = NULL;
m_toolManager = NULL; m_toolManager = NULL;
m_toolDispatcher = NULL; m_toolDispatcher = NULL;
@ -296,9 +295,6 @@ void EDA_DRAW_FRAME::EraseMsgBox()
void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event ) void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
{ {
if( m_canvas )
m_canvas->SetCanStartBlock( -1 );
event.Skip(); // required under wxMAC event.Skip(); // required under wxMAC
} }
@ -401,8 +397,7 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
{ {
int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName ); int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
if( IsGalCanvasActive() ) GetToolManager()->UpdateHotKeys();
GetToolManager()->UpdateHotKeys();
return result; return result;
} }
@ -471,10 +466,8 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
// Notify GAL // Notify GAL
TOOL_MANAGER* mgr = GetToolManager(); TOOL_MANAGER* mgr = GetToolManager();
if( mgr && IsGalCanvasActive() ) if( mgr )
mgr->RunAction( "common.Control.gridPreset", true, idx ); mgr->RunAction( "common.Control.gridPreset", true, idx );
else
SetPresetGrid( idx );
m_canvas->Refresh(); m_canvas->Refresh();
} }
@ -556,7 +549,7 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
m_canvas->SetCurrentCursor( aCursor ); m_canvas->SetCurrentCursor( aCursor );
// Change GAL canvas cursor if requested. // Change GAL canvas cursor if requested.
if( IsGalCanvasActive() && aCursor >= 0 ) if( aCursor >= 0 )
GetGalCanvas()->SetCurrentCursor( aCursor ); GetGalCanvas()->SetCurrentCursor( aCursor );
DisplayToolMsg( aToolMsg ); DisplayToolMsg( aToolMsg );
@ -578,10 +571,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
int defaultCursor = wxCURSOR_DEFAULT; int defaultCursor = wxCURSOR_DEFAULT;
// Change GAL canvas cursor if requested. // Change GAL canvas cursor if requested.
if( IsGalCanvasActive() ) defaultCursor = GetGalCanvas()->GetDefaultCursor();
defaultCursor = GetGalCanvas()->GetDefaultCursor();
else if( m_canvas )
defaultCursor = m_canvas->GetDefaultCursor();
SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
} }
@ -667,16 +657,7 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{ {
wxString Line; wxString Line;
double level = 0.0; double level = m_galCanvas->GetGAL()->GetZoomFactor();
if( IsGalCanvasActive() )
{
level = m_galCanvas->GetGAL()->GetZoomFactor();
}
else if( BASE_SCREEN* screen = GetScreen() )
{
level = m_zoomLevelCoeff / (double) screen->GetZoom();
}
// returns a human readable value which can be displayed as zoom // returns a human readable value which can be displayed as zoom
// level indicator in dialogs. // level indicator in dialogs.
@ -1029,56 +1010,32 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
{ {
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
// Display the same view after canvas switching // Set up grid settings
if( aEnable ) gal->SetGridVisibility( IsGridVisible() );
{ gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
// Switch to GAL renderer from legacy gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
if( !m_galCanvasActive )
{
// Set up viewport
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter(VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
// Set up grid settings // Transfer EDA_DRAW_PANEL settings
gal->SetGridVisibility( IsGridVisible() ); KIGFX::VIEW_CONTROLS* viewControls = GetGalCanvas()->GetViewControls();
gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) ); viewControls->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) ); viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
// Transfer EDA_DRAW_PANEL settings
KIGFX::VIEW_CONTROLS* viewControls = GetGalCanvas()->GetViewControls();
viewControls->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
}
else if( m_galCanvasActive )
{
// Switch to legacy renderer from GAL
m_canvas->SetZoom( GetGalCanvas()->GetLegacyZoom() );
VECTOR2D center = view->GetCenter();
AdjustScrollBars( wxPoint( center.x, center.y ) );
}
m_canvas->SetEvtHandlerEnabled( !aEnable ); m_canvas->SetEvtHandlerEnabled( !aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable ); GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
if( aEnable ) GetGalCanvas()->StartDrawing();
GetGalCanvas()->StartDrawing();
else
GetGalCanvas()->StopDrawing();
// Switch panes // Switch panes
m_auimgr.GetPane( "DrawFrame" ).Show( !aEnable ); // JEY TODO: drop down to a single pane....
m_auimgr.GetPane( "DrawFrameGal" ).Show( aEnable ); m_auimgr.GetPane( "DrawFrame" ).Show( false );
m_auimgr.GetPane( "DrawFrameGal" ).Show( true );
m_auimgr.Update(); m_auimgr.Update();
// Reset current tool on switch(); // Reset current tool on switch();
SetNoToolSelected(); SetNoToolSelected();
m_galCanvasActive = aEnable;
} }
@ -1174,17 +1131,9 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
{ {
// subject to change, borrow from old BASE_SCREEN for now. // subject to change, borrow from old BASE_SCREEN for now.
if( IsGalCanvasActive() ) VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition();
{
VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition();
return wxPoint( cursor.x, cursor.y ); return wxPoint( cursor.x, cursor.y );
}
else
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairPosition( aInvertY );
}
} }
@ -1414,40 +1363,12 @@ bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{ {
// JEY TODO: OBSOLETE // JEY TODO: OBSOLETE
if( IsGalCanvasActive() )
return;
AdjustScrollBars( aCenterPoint );
// Move the mouse cursor to the on grid graphic cursor position
if( aWarpPointer )
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
m_canvas->Update();
} }
void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
{ {
if( IsGalCanvasActive() ) // JEY TODO: OBSOLETE
return;
// Account for scrollbars (see EDA_DRAW_FRAME::AdjustScrollBars that takes
// in account scroolbars area to adjust scroll bars)
wxSize scrollbarSize = m_canvas->GetSize() - m_canvas->GetClientSize();
wxSize sizeAdjusted = m_canvas->GetClientSize() - scrollbarSize;
wxPoint dPos = posBefore - sizeAdjusted / 2;
// screen position of crosshair after zoom
wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() );
wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos );
AdjustScrollBars( newCenter );
m_canvas->Refresh();
m_canvas->Update();
} }
@ -1495,10 +1416,7 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
if( !screen->m_Initialized ) if( !screen->m_Initialized )
SetCrossHairPosition( GetScrollCenterPosition() ); SetCrossHairPosition( GetScrollCenterPosition() );
if( !IsGalCanvasActive() ) m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
RedrawScreen( GetScrollCenterPosition(), aWarpPointer );
else
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
} }
@ -1694,52 +1612,25 @@ wxWindow* findDialog( wxWindowList& aList )
void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, bool aCenterView ) void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, bool aCenterView )
{ {
if( IsGalCanvasActive() ) if( aCenterView )
{ {
if( aCenterView ) wxWindow* dialog = findDialog( GetChildren() );
// If a dialog partly obscures the window, then center on the uncovered area.
if( dialog )
{ {
wxWindow* dialog = findDialog( GetChildren() ); wxRect dialogRect( GetGalCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
dialog->GetSize() );
// If a dialog partly obscures the window, then center on the uncovered area. GetGalCanvas()->GetView()->SetCenter( aPos, dialogRect );
if( dialog )
{
wxRect dialogRect( GetGalCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
dialog->GetSize() );
GetGalCanvas()->GetView()->SetCenter( aPos, dialogRect );
}
else
GetGalCanvas()->GetView()->SetCenter( aPos );
} }
if( aWarpCursor )
GetGalCanvas()->GetViewControls()->SetCursorPosition( aPos );
else else
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( aPos ); GetGalCanvas()->GetView()->SetCenter( aPos );
} }
if( aWarpCursor )
GetGalCanvas()->GetViewControls()->SetCursorPosition( aPos );
else else
{ GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( aPos );
INSTALL_UNBUFFERED_DC( dc, m_canvas );
// There may be need to reframe the drawing.
if( aCenterView || !m_canvas->IsPointOnDisplay( aPos ) )
{
SetCrossHairPosition( aPos );
RedrawScreen( aPos, aWarpCursor );
}
else
{
// Put cursor on item position
m_canvas->CrossHairOff( &dc );
SetCrossHairPosition( aPos );
if( aWarpCursor )
m_canvas->MoveCursorToCrossHair();
}
// Be sure cross hair cursor is ON:
m_canvas->CrossHairOn( &dc );
m_canvas->CrossHairOn( &dc );
}
} }

View File

@ -126,7 +126,6 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true ); Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
m_requestAutoPan = false; m_requestAutoPan = false;
m_enableBlockCommands = false;
m_minDragEventCount = 0; m_minDragEventCount = 0;
#ifdef __WXMAC__ #ifdef __WXMAC__
@ -320,14 +319,7 @@ void EDA_DRAW_PANEL::RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackg
void EDA_DRAW_PANEL::Refresh( bool eraseBackground, const wxRect* rect ) void EDA_DRAW_PANEL::Refresh( bool eraseBackground, const wxRect* rect )
{ {
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->Refresh();
{
GetParent()->GetGalCanvas()->Refresh();
}
else
{
wxScrolledWindow::Refresh( eraseBackground, rect );
}
} }
@ -348,48 +340,7 @@ void EDA_DRAW_PANEL::MoveCursorToCrossHair()
void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition ) void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition )
{ {
if( GetParent()->IsGalCanvasActive() ) // JEY TODO: OBSOLETE
return;
int x, y, xPpu, yPpu;
wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
INSTALL_UNBUFFERED_DC( dc, this );
screenPos.x = dc.LogicalToDeviceX( aPosition.x );
screenPos.y = dc.LogicalToDeviceY( aPosition.y );
// Scroll if the requested mouse position cursor is outside the drawing area.
if( !clientRect.Contains( screenPos ) )
{
GetViewStart( &x, &y );
GetScrollPixelsPerUnit( &xPpu, &yPpu );
CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y );
wxLogTrace( kicadTraceCoords,
wxT( "MoveCursor() initial screen position(%d, %d) " ) \
wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, clientRect.x, clientRect.y,
clientRect.width, clientRect.height, x, y );
if( screenPos.y < clientRect.GetTop() )
y -= m_scrollIncrementY * yPpu;
else if( screenPos.y > clientRect.GetBottom() )
y += m_scrollIncrementY * yPpu;
else if( clientRect.GetRight() < screenPos.x )
x += m_scrollIncrementX * xPpu;
else
x -= m_scrollIncrementX * xPpu;
Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y );
wxLogTrace( kicadTraceCoords,
wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, x, y );
}
WarpPointer( screenPos.x, screenPos.y );
} }
@ -652,16 +603,14 @@ void EDA_DRAW_PANEL::SetEnableMousewheelPan( bool aEnable )
{ {
m_enableMousewheelPan = aEnable; m_enableMousewheelPan = aEnable;
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableMousewheelPan( aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableMousewheelPan( aEnable );
} }
void EDA_DRAW_PANEL::SetEnableAutoPan( bool aEnable ) void EDA_DRAW_PANEL::SetEnableAutoPan( bool aEnable )
{ {
m_enableAutoPan = aEnable; m_enableAutoPan = aEnable;
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable );
} }
@ -669,8 +618,7 @@ void EDA_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
{ {
m_enableZoomNoCenter = aEnable; m_enableZoomNoCenter = aEnable;
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableCursorWarping( !aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableCursorWarping( !aEnable );
} }
@ -1160,7 +1108,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// or this is the end of a double click, already seen // or this is the end of a double click, already seen
// Note also m_ignoreNextLeftButtonRelease can be set by // Note also m_ignoreNextLeftButtonRelease can be set by
// the call to OnLeftClick(), so do not change it after calling OnLeftClick // the call to OnLeftClick(), so do not change it after calling OnLeftClick
bool ignoreEvt = m_ignoreNextLeftButtonRelease;
m_ignoreNextLeftButtonRelease = false; m_ignoreNextLeftButtonRelease = false;
} }
else if( !event.LeftIsDown() ) else if( !event.LeftIsDown() )

View File

@ -79,10 +79,8 @@ static std::unique_ptr<wxStaticBitmap> makeColorSwatch( wxWindow* aParent, COLOR
} }
COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground ):
bool aArbitraryColors, COLOR4D aBackground ):
wxPanel( aParent, aID ), wxPanel( aParent, aID ),
m_arbitraryColors( aArbitraryColors ),
m_color( aColor ), m_color( aColor ),
m_background( aBackground ) m_background( aBackground )
{ {
@ -159,15 +157,10 @@ void COLOR_SWATCH::GetNewSwatchColor()
{ {
COLOR4D newColor = COLOR4D::UNSPECIFIED; COLOR4D newColor = COLOR4D::UNSPECIFIED;
if( m_arbitraryColors ) DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( this ), m_color, true );
{
DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( this ), m_color, true );
if( dialog.ShowModal() == wxID_OK ) if( dialog.ShowModal() == wxID_OK )
newColor = dialog.GetColor(); newColor = dialog.GetColor();
}
else
newColor = DisplayColorFrame( this, m_color );
if( newColor != COLOR4D::UNSPECIFIED ) if( newColor != COLOR4D::UNSPECIFIED )
{ {

View File

@ -171,8 +171,7 @@ void SCH_DRAW_PANEL::SetEnableMousewheelPan( bool aEnable )
{ {
m_enableMousewheelPan = aEnable; m_enableMousewheelPan = aEnable;
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableMousewheelPan( aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableMousewheelPan( aEnable );
} }
@ -180,14 +179,12 @@ void SCH_DRAW_PANEL::SetEnableAutoPan( bool aEnable )
{ {
EDA_DRAW_PANEL::SetEnableAutoPan( aEnable ); EDA_DRAW_PANEL::SetEnableAutoPan( aEnable );
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableAutoPan( aEnable );
} }
void SCH_DRAW_PANEL::SetAutoPanRequest( bool aEnable ) void SCH_DRAW_PANEL::SetAutoPanRequest( bool aEnable )
{ {
wxCHECK( GetParent()->IsGalCanvasActive(), /*void*/ );
GetParent()->GetGalCanvas()->GetViewControls()->SetAutoPan( aEnable ); GetParent()->GetGalCanvas()->GetViewControls()->SetAutoPan( aEnable );
} }
@ -196,8 +193,7 @@ void SCH_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
{ {
m_enableZoomNoCenter = aEnable; m_enableZoomNoCenter = aEnable;
if( GetParent()->IsGalCanvasActive() ) GetParent()->GetGalCanvas()->GetViewControls()->EnableCursorWarping( !aEnable );
GetParent()->GetGalCanvas()->GetViewControls()->EnableCursorWarping( !aEnable );
} }

View File

@ -85,10 +85,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, GERBVIEW_FRAME::Process_Config ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, GERBVIEW_FRAME::Process_Config )
EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::Process_Config ) EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::Process_Config )
EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas ) EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnUpdateSwitchCanvas ) EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnSwitchCanvas )
@ -146,22 +144,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
switch( id )
{
case ID_POPUP_CANCEL_CURRENT_COMMAND:
m_canvas->EndMouseCapture();
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetNoToolSelected();
else
m_canvas->SetCursor( (wxStockCursor) m_canvas->GetCurrentCursor() );
break;
default:
m_canvas->EndMouseCapture();
break;
}
GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem(); GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
switch( id ) switch( id )
@ -175,13 +157,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) ); SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
break; break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
break;
case ID_GERBVIEW_SHOW_LIST_DCODES: case ID_GERBVIEW_SHOW_LIST_DCODES:
Liste_D_Codes(); Liste_D_Codes();
break; break;
@ -224,31 +199,26 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event ) void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
{ {
if( IsGalCanvasActive() ) auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetGalCanvas()->GetView()->GetPainter() )->GetSettings();
switch( event.GetId() )
{ {
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetGalCanvas()->GetView()->GetPainter() )->GetSettings(); case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
break;
switch( event.GetId() ) case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
{ settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE: break;
settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
break;
case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE: case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection(); settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
break; break;
case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
break;
}
GetGalCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
GetGalCanvas()->Refresh();
} }
else
m_canvas->Refresh(); GetGalCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
GetGalCanvas()->Refresh();
} }
@ -408,10 +378,6 @@ void GERBVIEW_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{ {
switch( aEvent.GetId() ) switch( aEvent.GetId() )
{ {
case ID_MENU_CANVAS_LEGACY:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
break;
case ID_MENU_CANVAS_CAIRO: case ID_MENU_CANVAS_CAIRO:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break; break;

View File

@ -112,9 +112,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
// GerbView requires draw priority for rendering negative objects // GerbView requires draw priority for rendering negative objects
galCanvas->GetView()->UseDrawPriority( true ); galCanvas->GetView()->UseDrawPriority( true );
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
// Give an icon // Give an icon
wxIcon icon; wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
@ -181,8 +178,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
"and faster experience. This option is turned off by " "and faster experience. This option is turned off by "
"default since it is not compatible with all computers.\n\n" "default since it is not compatible with all computers.\n\n"
"Would you like to try enabling graphics acceleration?\n\n" "Would you like to try enabling graphics acceleration?\n\n"
"If you'd like to choose later, select Modern Toolset " "If you'd like to choose later, select Accelerated Graphics "
"(Accelerated) in the Preferences menu." ); "in the Preferences menu." );
wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO ); wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
@ -215,19 +212,14 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_firstRunDialogSetting = 1; m_firstRunDialogSetting = 1;
SaveSettings( config() ); SaveSettings( config() );
} }
else if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) else
{ {
if( GetGalCanvas()->SwitchBackend( canvasType ) ) GetGalCanvas()->SwitchBackend( canvasType );
UseGalCanvas( true ); UseGalCanvas( true );
wxUpdateUIEvent e; wxUpdateUIEvent e;
OnUpdateSwitchCanvas( e ); OnUpdateSwitchCanvas( e );
} }
else
{
m_colorsSettings->SetLegacyMode( true );
m_canvas->Refresh();
}
// Enable the axes to match legacy draw style // Enable the axes to match legacy draw style
auto& galOptions = GetGalDisplayOptions(); auto& galOptions = GetGalDisplayOptions();
@ -256,11 +248,8 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
if( m_toolManager ) if( m_toolManager )
m_toolManager->DeactivateTool(); m_toolManager->DeactivateTool();
if( IsGalCanvasActive() ) // Be sure any OpenGL event cannot be fired after frame deletion:
{ GetGalCanvas()->SetEvtHandlerEnabled( false );
// Be sure any OpenGL event cannot be fired after frame deletion:
GetGalCanvas()->SetEvtHandlerEnabled( false );
}
Destroy(); Destroy();
} }
@ -934,15 +923,12 @@ void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
UpdateTitleAndInfo(); UpdateTitleAndInfo();
if( IsGalCanvasActive() ) m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
{ GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
GetGalCanvas()->SetHighContrastLayer( GERBER_DRAW_LAYER( aLayer ) ); GetGalCanvas()->SetHighContrastLayer( GERBER_DRAW_LAYER( aLayer ) );
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
}
} }
@ -954,23 +940,20 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
if( screen ) if( screen )
screen->InitDataPoints( aPageSettings.GetSizeIU() ); screen->InitDataPoints( aPageSettings.GetSizeIU() );
if( IsGalCanvasActive() ) auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetGalCanvas() );
// Prepare worksheet template
auto worksheet =
new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
if( screen != NULL )
{ {
auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetGalCanvas() ); worksheet->SetSheetNumber( 1 );
worksheet->SetSheetCount( 1 );
// Prepare worksheet template
auto worksheet =
new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
if( screen != NULL )
{
worksheet->SetSheetNumber( 1 );
worksheet->SetSheetCount( 1 );
}
// PCB_DRAW_PANEL_GAL takes ownership of the worksheet
drawPanel->SetWorksheet( worksheet );
} }
// PCB_DRAW_PANEL_GAL takes ownership of the worksheet
drawPanel->SetWorksheet( worksheet );
} }
@ -1039,8 +1022,7 @@ void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor ) void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
{ {
if( IsGalCanvasActive() ) GetGalCanvas()->GetGAL()->SetGridColor( aColor );
GetGalCanvas()->GetGAL()->SetGridColor( aColor );
m_gridColor = aColor; m_gridColor = aColor;
} }
@ -1152,7 +1134,8 @@ unsigned GERBVIEW_FRAME::ImagesMaxCount() const
void GERBVIEW_FRAME::unitsChangeRefresh() void GERBVIEW_FRAME::unitsChangeRefresh()
{ // Called on units change (see EDA_DRAW_FRAME) {
// Called on units change (see EDA_DRAW_FRAME)
EDA_DRAW_FRAME::unitsChangeRefresh(); EDA_DRAW_FRAME::unitsChangeRefresh();
updateDCodeSelectBox(); updateDCodeSelectBox();
updateGridSelectBox(); updateGridSelectBox();
@ -1285,7 +1268,7 @@ void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
int current = 0; // display Auto if no match found int current = 0; // display Auto if no match found
// check for a match within 1% // check for a match within 1%
double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom(); double zoom = GetGalCanvas()->GetLegacyZoom();
for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ ) for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
{ {

View File

@ -79,12 +79,6 @@ GERBER_FILE_IMAGE_LIST* GERBER_LAYER_WIDGET::GetImagesList()
} }
bool GERBER_LAYER_WIDGET::AreArbitraryColorsAllowed()
{
return myframe->IsGalCanvasActive();
}
void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( ) void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( )
{ {
m_notebook->SetPageText(0, _("Layers") ); m_notebook->SetPageText(0, _("Layers") );
@ -267,12 +261,9 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
myframe->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor ); myframe->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor );
myframe->m_SelLayerBox->ResyncBitmapOnly(); myframe->m_SelLayerBox->ResyncBitmapOnly();
if( myframe->IsGalCanvasActive() ) KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
{ view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView(); view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) );
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) );
}
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();
} }
@ -315,21 +306,14 @@ void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
myframe->SetVisibleElementColor( aId, aColor ); myframe->SetVisibleElementColor( aId, aColor );
auto galCanvas = myframe->GetGalCanvas(); auto galCanvas = myframe->GetGalCanvas();
auto view = galCanvas->GetView();
if( galCanvas && myframe->IsGalCanvasActive() ) view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
{ view->UpdateLayerColor( aId );
auto view = galCanvas->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
view->UpdateLayerColor( aId );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
view->UpdateAllItems( KIGFX::COLOR ); view->UpdateAllItems( KIGFX::COLOR );
} galCanvas->Refresh();
if( galCanvas && myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
} }
@ -350,10 +334,7 @@ void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
galCanvas->GetView()->SetLayerVisible( aId, isEnabled ); galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
} }
if( galCanvas && myframe->IsGalCanvasActive() ) galCanvas->Refresh();
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
} }
//-----</LAYER_WIDGET callbacks>------------------------------------------ //-----</LAYER_WIDGET callbacks>------------------------------------------

View File

@ -65,8 +65,6 @@ class GERBER_LAYER_WIDGET : public LAYER_WIDGET
*/ */
virtual bool useAlternateBitmap(int aRow) override; virtual bool useAlternateBitmap(int aRow) override;
virtual bool AreArbitraryColorsAllowed() override;
GERBER_FILE_IMAGE_LIST* GetImagesList(); GERBER_FILE_IMAGE_LIST* GetImagesList();
public: public:

View File

@ -211,11 +211,6 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
cmd.SetId( ID_MENU_CANVAS_OPENGL ); cmd.SetId( ID_MENU_CANVAS_OPENGL );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
break; break;
case HK_CANVAS_LEGACY:
cmd.SetId( ID_MENU_CANVAS_LEGACY );
GetEventHandler()->ProcessEvent( cmd );
break;
} }
return true; return true;

View File

@ -278,22 +278,14 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// Canvas selection // Canvas selection
configMenu->AppendSeparator(); configMenu->AppendSeparator();
if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) text = AddHotkeyName( _( "Accelerated Graphics" ), GerbviewHotkeysDescr, HK_CANVAS_OPENGL );
{
text = AddHotkeyName( _( "Legacy Tool&set" ), GerbviewHotkeysDescr, HK_CANVAS_LEGACY );
AddMenuItem( configMenu, ID_MENU_CANVAS_LEGACY, text,
_( "Use Legacy Toolset (not all features will be available)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
}
text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), GerbviewHotkeysDescr, HK_CANVAS_OPENGL );
AddMenuItem( configMenu, ID_MENU_CANVAS_OPENGL, text, AddMenuItem( configMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ), _( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Modern Toolset (Fallba&ck)" ), GerbviewHotkeysDescr, HK_CANVAS_CAIRO ); text = AddHotkeyName( _( "Standard Graphics" ), GerbviewHotkeysDescr, HK_CANVAS_CAIRO );
AddMenuItem( configMenu, ID_MENU_CANVAS_CAIRO, text, AddMenuItem( configMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use Modern Toolset with software graphics (fall-back)" ), _( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
configMenu->AppendSeparator(); configMenu->AppendSeparator();

View File

@ -99,7 +99,6 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions;
protected: protected:
bool m_galCanvasActive; ///< whether to use new GAL engine
bool m_useSingleCanvasPane; bool m_useSingleCanvasPane;
wxSocketServer* m_socketServer; wxSocketServer* m_socketServer;
@ -848,14 +847,6 @@ public:
*/ */
virtual bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ); virtual bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
/**
* Function IsGalCanvasActive
* is used to check which canvas (GAL-based or standard) is currently in use.
*
* @return True for GAL-based canvas, false for standard canvas.
*/
bool IsGalCanvasActive() const { return m_galCanvasActive; }
/** /**
* Return a pointer to GAL-based canvas of given EDA draw frame. * Return a pointer to GAL-based canvas of given EDA draw frame.
* *

View File

@ -91,8 +91,6 @@ private:
*/ */
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true.
bool m_enableBlockCommands; ///< True enables block commands.
/** /**
* Count the drag events. Used to filter mouse moves before starting a * Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if * block command. A block command can be started only if
@ -162,13 +160,9 @@ public:
void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; } void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; }
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
bool GetPrintMirrored() const { return m_PrintIsMirrored; } bool GetPrintMirrored() const { return m_PrintIsMirrored; }
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
/** /**
* Function DrawBackGround * Function DrawBackGround
* @param DC = current Device Context * @param DC = current Device Context

View File

@ -370,38 +370,10 @@ public:
*/ */
void DeletePad( D_PAD* aPad, bool aQuery = true ); void DeletePad( D_PAD* aPad, bool aQuery = true );
/**
* Function StartMovePad
* Initialize a drag or move pad command
* @param aPad = the pad to move or drag
* @param aDC = the current device context
* @param aDragConnectedTracks = true to drag connected tracks,
* false to just move the pad
*/
void StartMovePad( D_PAD* aPad, wxDC* aDC, bool aDragConnectedTracks );
void PlacePad( D_PAD* Pad, wxDC* DC ); void PlacePad( D_PAD* Pad, wxDC* DC );
void Export_Pad_Settings( D_PAD* aPad ); void Export_Pad_Settings( D_PAD* aPad );
void Import_Pad_Settings( D_PAD* aPad, bool aDraw ); void Import_Pad_Settings( D_PAD* aPad, bool aDraw );
/**
* Function DoPushPadProperties
* Function to change pad settings for the given footprint or all identical footprints
* @param aPad is the pattern. The given footprint is the parent of this pad
* @param aSameFootprints: if true, make changes on all identical footprints
* @param aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
* @param aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
* @param aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
* @param aSaveForUndo: if true: create an entry in the Undo/Redo list
* (usually: true in Schematic editor, false in Module editor)
*/
void DoPushPadProperties( D_PAD* aPad,
bool aSameFootprints,
bool aPadShapeFilter,
bool aPadOrientFilter,
bool aPadLayerFilter,
bool aSaveForUndo );
/** /**
* Function SelectFootprintFromLibTree * Function SelectFootprintFromLibTree
* opens a dialog to select a footprint. * opens a dialog to select a footprint.

View File

@ -48,8 +48,7 @@ public:
* @param aArbitraryColors true to allow selection of any 32 bits color for GAL canvas, * @param aArbitraryColors true to allow selection of any 32 bits color for GAL canvas,
* and false to allow a selection from a set of colors accepted by the legacy canvas. * and false to allow a selection from a set of colors accepted by the legacy canvas.
*/ */
COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground );
bool aArbitraryColors, KIGFX::COLOR4D aBackground );
/** /**
* Set the current swatch color directly. * Set the current swatch color directly.
@ -82,9 +81,6 @@ private:
*/ */
void rePostEvent( wxEvent& aEvt ); void rePostEvent( wxEvent& aEvt );
///> Can the swatch have any color, or only preset ones for legacy canvas?
bool m_arbitraryColors;
///> The current colour of the swatch ///> The current colour of the swatch
KIGFX::COLOR4D m_color; KIGFX::COLOR4D m_color;

View File

@ -91,14 +91,6 @@ void PCB_EDIT_FRAME::OnPlaceOrRouteFootprints( wxCommandEvent& event )
LockModule( NULL, true ); LockModule( NULL, true );
return; return;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( m_canvas->IsMouseCaptured() )
{
m_canvas->CallEndMouseCapture( &dc );
}
break;
default: // Abort a current command (if any) default: // Abort a current command (if any)
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
break; break;

View File

@ -113,69 +113,53 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
} }
} }
if( IsGalCanvasActive() ) auto view = m_toolManager->GetView();
auto rs = view->GetPainter()->GetSettings();
rs->SetHighlight( ( netcode >= 0 ), netcode );
view->UpdateAllLayersColor();
BOX2I bbox;
bool first = true;
auto merge_area = [netcode, &bbox, &first]( BOARD_CONNECTED_ITEM* aItem )
{ {
auto view = m_toolManager->GetView(); if( aItem->GetNetCode() == netcode )
auto rs = view->GetPainter()->GetSettings();
rs->SetHighlight( ( netcode >= 0 ), netcode );
view->UpdateAllLayersColor();
BOX2I bbox;
bool first = true;
auto merge_area = [netcode, &bbox, &first]( BOARD_CONNECTED_ITEM* aItem )
{ {
if( aItem->GetNetCode() == netcode ) if( first )
{ {
if( first ) bbox = aItem->GetBoundingBox();
{ first = false;
bbox = aItem->GetBoundingBox(); }
first = false; else
} {
else bbox.Merge( aItem->GetBoundingBox() );
{
bbox.Merge( aItem->GetBoundingBox() );
}
} }
};
for( auto zone : pcb->Zones() )
merge_area( zone );
for( auto track : pcb->Tracks() )
merge_area( track );
for( auto mod : pcb->Modules() )
for ( auto mod_pad : mod->Pads() )
merge_area( mod_pad );
if( netcode > 0 && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
{
auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
auto screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
double ratio = std::max( fabs( bbSize.x / screenSize.x ),
fabs( bbSize.y / screenSize.y ) );
double scale = view->GetScale() / ratio;
view->SetScale( scale );
view->SetCenter( bbox.Centre() );
} }
};
GetGalCanvas()->Refresh(); for( auto zone : pcb->Zones() )
} merge_area( zone );
else
for( auto track : pcb->Tracks() )
merge_area( track );
for( auto mod : pcb->Modules() )
for ( auto mod_pad : mod->Pads() )
merge_area( mod_pad );
if( netcode > 0 && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
{ {
if( netcode > 0 ) auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
{ auto screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
pcb->HighLightON(); double ratio = std::max( fabs( bbSize.x / screenSize.x ),
pcb->SetHighLightNet( netcode ); fabs( bbSize.y / screenSize.y ) );
} double scale = view->GetScale() / ratio;
else
{ view->SetScale( scale );
pcb->HighLightOFF(); view->SetCenter( bbox.Centre() );
pcb->SetHighLightNet( -1 );
}
} }
GetGalCanvas()->Refresh();
} }
return; return;
@ -279,20 +263,12 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( module ) // if found, center the module on screen, and redraw the screen. if( module ) // if found, center the module on screen, and redraw the screen.
{ {
if( IsGalCanvasActive() ) GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb,
{ true,
GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, pad ?
true, static_cast<BOARD_ITEM*>( pad ) :
pad ? static_cast<BOARD_ITEM*>( module )
static_cast<BOARD_ITEM*>( pad ) : );
static_cast<BOARD_ITEM*>( module )
);
}
else
{
SetCrossHairPosition( pos );
RedrawScreen( pos, false );
}
} }
} }

View File

@ -150,10 +150,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem( wxCommandEvent& event )
if( item ) if( item )
{ {
// When selecting a item, center it on GAL and just move the graphic m_parentFrame->FocusOnLocation( item->GetPointA(), false, true );
// cursor in legacy mode gives the best result
bool center = m_parentFrame->IsGalCanvasActive() ? true : false;
m_parentFrame->FocusOnLocation( item->GetPointA(), false, center );
WINDOW_THAWER thawer( m_parentFrame ); WINDOW_THAWER thawer( m_parentFrame );
m_parentFrame->GetCanvas()->Refresh(); m_parentFrame->GetCanvas()->Refresh();
@ -177,10 +174,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnLeftDClickItem( wxMouseEvent& event )
const DRC_ITEM* item = m_ItemsListBox->GetItem( selection ); const DRC_ITEM* item = m_ItemsListBox->GetItem( selection );
if( item ) if( item )
{ {
// When selecting a item, center it on GAL and just move the graphic m_parentFrame->FocusOnLocation( item->GetPointA(), true, true );
// cursor in legacy mode gives the best result
bool center = m_parentFrame->IsGalCanvasActive() ? true : false;
m_parentFrame->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() ) if( !IsModal() )
{ {

View File

@ -56,7 +56,7 @@ int DIALOG_FOOTPRINT_BOARD_EDITOR::m_page = 0; // remember the last open pag
DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aParent, DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aParent,
MODULE* aModule, wxDC* aDC ) : MODULE* aModule ) :
DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( aParent ), DIALOG_FOOTPRINT_BOARD_EDITOR_BASE( aParent ),
m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ), m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ), m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ),
@ -70,7 +70,6 @@ DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aP
m_config = Kiface().KifaceSettings(); m_config = Kiface().KifaceSettings();
m_frame = aParent; m_frame = aParent;
m_DC = aDC;
m_footprint = aModule; m_footprint = aModule;
m_texts = new TEXT_MOD_GRID_TABLE( m_units, m_frame ); m_texts = new TEXT_MOD_GRID_TABLE( m_units, m_frame );
@ -622,12 +621,6 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow()
if( !m_Panel3D->TransferDataFromWindow() ) if( !m_Panel3D->TransferDataFromWindow() )
return false; return false;
if( m_DC )
{
m_frame->GetCanvas()->CrossHairOff( m_DC );
m_footprint->Draw( m_frame->GetCanvas(), m_DC, GR_XOR );
}
auto view = m_frame->GetGalCanvas()->GetView(); auto view = m_frame->GetGalCanvas()->GetView();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
commit.Modify( m_footprint ); commit.Modify( m_footprint );
@ -740,13 +733,6 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow()
commit.Push( _( "Modify module properties" ) ); commit.Push( _( "Modify module properties" ) );
SetReturnCode( PRM_EDITOR_EDIT_OK ); SetReturnCode( PRM_EDITOR_EDIT_OK );
if( m_DC )
{
m_footprint->Draw( m_frame->GetCanvas(), m_DC, GR_OR );
m_frame->GetCanvas()->CrossHairOn( m_DC );
}
return true; return true;
} }

View File

@ -43,7 +43,6 @@ class DIALOG_FOOTPRINT_BOARD_EDITOR: public DIALOG_FOOTPRINT_BOARD_EDITOR_BASE
private: private:
wxConfigBase* m_config; wxConfigBase* m_config;
PCB_EDIT_FRAME* m_frame; PCB_EDIT_FRAME* m_frame;
wxDC* m_DC;
MODULE* m_footprint; MODULE* m_footprint;
static int m_page; // remember the last open page during session static int m_page; // remember the last open page during session
@ -82,7 +81,7 @@ public:
public: public:
// Constructor and destructor // Constructor and destructor
DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aParent, MODULE* aModule, wxDC* aDC ); DIALOG_FOOTPRINT_BOARD_EDITOR( PCB_EDIT_FRAME* aParent, MODULE* aModule );
~DIALOG_FOOTPRINT_BOARD_EDITOR() override; ~DIALOG_FOOTPRINT_BOARD_EDITOR() override;
bool Validate() override; bool Validate() override;

View File

@ -339,13 +339,8 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow()
{ {
m_parent->SaveCopyInUndoList( itemsListPicker, UR_CHANGED ); m_parent->SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
if( m_parent->IsGalCanvasActive() ) for( TRACK* segment = m_brd->m_Track; segment != nullptr; segment = segment->Next() )
{ m_parent->GetGalCanvas()->GetView()->Update( segment );
for( TRACK* segment = m_brd->m_Track; segment != nullptr; segment = segment->Next() )
m_parent->GetGalCanvas()->GetView()->Update( segment );
}
else
m_parent->GetCanvas()->Refresh();
} }
return !m_failedDRC; return !m_failedDRC;

View File

@ -209,8 +209,7 @@ void DIALOG_PAD_PROPERTIES::OnCancel( wxCommandEvent& event )
{ {
// Mandatory to avoid m_panelShowPadGal trying to draw something // Mandatory to avoid m_panelShowPadGal trying to draw something
// in a non valid context during closing process: // in a non valid context during closing process:
if( m_parent->IsGalCanvasActive() ) m_panelShowPadGal->StopDrawing();
m_panelShowPadGal->StopDrawing();
// Now call default handler for wxID_CANCEL command event // Now call default handler for wxID_CANCEL command event
event.Skip(); event.Skip();
@ -242,44 +241,36 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas()
VECTOR2D( m_dummyPad->GetPosition() ) ); VECTOR2D( m_dummyPad->GetPosition() ) );
m_axisOrigin->SetDrawAtZero( true ); m_axisOrigin->SetDrawAtZero( true );
if( m_parent->IsGalCanvasActive() ) m_panelShowPadGal->UseColorScheme( &m_parent->Settings().Colors() );
{ m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
m_panelShowPadGal->UseColorScheme( &m_parent->Settings().Colors() ); m_panelShowPadGal->SetStealsFocus( false );
m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
m_panelShowPadGal->SetStealsFocus( false );
bool mousewheelPan = m_parent->GetCanvas()->GetEnableMousewheelPan(); bool mousewheelPan = m_parent->GetCanvas()->GetEnableMousewheelPan();
m_panelShowPadGal->GetViewControls()->EnableMousewheelPan( mousewheelPan ); m_panelShowPadGal->GetViewControls()->EnableMousewheelPan( mousewheelPan );
m_panelShowPadGal->Show(); m_panelShowPadGal->Show();
m_panelShowPad->Hide(); m_panelShowPad->Hide();
KIGFX::VIEW* view = m_panelShowPadGal->GetView(); KIGFX::VIEW* view = m_panelShowPadGal->GetView();
// fix the pad render mode (filled/not filled) // fix the pad render mode (filled/not filled)
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() ); auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
bool sketchMode = m_cbShowPadOutline->IsChecked(); bool sketchMode = m_cbShowPadOutline->IsChecked();
settings->SetSketchMode( LAYER_PADS_TH, sketchMode ); settings->SetSketchMode( LAYER_PADS_TH, sketchMode );
settings->SetSketchMode( LAYER_PAD_FR, sketchMode ); settings->SetSketchMode( LAYER_PAD_FR, sketchMode );
settings->SetSketchMode( LAYER_PAD_BK, sketchMode ); settings->SetSketchMode( LAYER_PAD_BK, sketchMode );
settings->SetSketchModeGraphicItems( sketchMode ); settings->SetSketchModeGraphicItems( sketchMode );
// gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid: // gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid:
double gridsize = 0.001 * IU_PER_MM; double gridsize = 0.001 * IU_PER_MM;
view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) ); view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) );
// And do not show the grid: // And do not show the grid:
view->GetGAL()->SetGridVisibility( false ); view->GetGAL()->SetGridVisibility( false );
view->Add( m_dummyPad ); view->Add( m_dummyPad );
view->Add( m_axisOrigin ); view->Add( m_axisOrigin );
m_panelShowPadGal->StartDrawing(); m_panelShowPadGal->StartDrawing();
Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) ); Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
}
else
{
m_panelShowPad->Show();
m_panelShowPadGal->Hide();
}
} }
@ -902,19 +893,16 @@ void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
{ {
m_sketchPreview = m_cbShowPadOutline->GetValue(); m_sketchPreview = m_cbShowPadOutline->GetValue();
if( m_parent->IsGalCanvasActive() ) KIGFX::VIEW* view = m_panelShowPadGal->GetView();
{
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
// fix the pad render mode (filled/not filled) // fix the pad render mode (filled/not filled)
KIGFX::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->SetSketchMode( LAYER_PADS_TH, m_sketchPreview ); settings->SetSketchMode( LAYER_PADS_TH, m_sketchPreview );
settings->SetSketchMode( LAYER_PAD_FR, m_sketchPreview ); settings->SetSketchMode( LAYER_PAD_FR, m_sketchPreview );
settings->SetSketchMode( LAYER_PAD_BK, m_sketchPreview ); settings->SetSketchMode( LAYER_PAD_BK, m_sketchPreview );
settings->SetSketchModeGraphicItems( m_sketchPreview ); settings->SetSketchModeGraphicItems( m_sketchPreview );
}
redraw(); redraw();
} }
@ -1325,104 +1313,97 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
void DIALOG_PAD_PROPERTIES::redraw() void DIALOG_PAD_PROPERTIES::redraw()
{ {
if( m_parent->IsGalCanvasActive() ) KIGFX::VIEW* view = m_panelShowPadGal->GetView();
m_panelShowPadGal->StopDrawing();
// The layer used to place primitive items selected when editing custom pad shapes
// we use here a layer never used in a pad:
#define SELECTED_ITEMS_LAYER Dwgs_User
view->SetTopLayer( SELECTED_ITEMS_LAYER );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->SetLayerColor( SELECTED_ITEMS_LAYER, m_selectedColor );
view->Update( m_dummyPad );
// delete previous items if highlight list
while( m_highlight.size() )
{ {
KIGFX::VIEW* view = m_panelShowPadGal->GetView(); delete m_highlight.back(); // the dtor also removes item from view
m_panelShowPadGal->StopDrawing(); m_highlight.pop_back();
// The layer used to place primitive items selected when editing custom pad shapes
// we use here a layer never used in a pad:
#define SELECTED_ITEMS_LAYER Dwgs_User
view->SetTopLayer( SELECTED_ITEMS_LAYER );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->SetLayerColor( SELECTED_ITEMS_LAYER, m_selectedColor );
view->Update( m_dummyPad );
// delete previous items if highlight list
while( m_highlight.size() )
{
delete m_highlight.back(); // the dtor also removes item from view
m_highlight.pop_back();
}
// highlight selected primitives:
long select = m_listCtrlPrimitives->GetFirstSelected();
while( select >= 0 )
{
PAD_CS_PRIMITIVE& primitive = m_primitives[select];
DRAWSEGMENT* dummySegment = new DRAWSEGMENT;
dummySegment->SetLayer( SELECTED_ITEMS_LAYER );
primitive.ExportTo( dummySegment );
dummySegment->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
dummySegment->Move( m_dummyPad->GetPosition() );
// Update selected primitive (highlight selected)
switch( primitive.m_Shape )
{
case S_SEGMENT:
case S_ARC:
case S_CURVE:
break;
case S_CIRCLE: // ring or circle
if( primitive.m_Thickness == 0 ) // filled circle
{ // the filled circle option does not exist in a DRAWSEGMENT
// but it is easy to create it with a circle having the
// right radius and outline width
wxPoint end = dummySegment->GetCenter();
end.x += primitive.m_Radius / 2;
dummySegment->SetEnd( end );
dummySegment->SetWidth( primitive.m_Radius );
}
break;
case S_POLYGON:
break;
default:
delete dummySegment;
dummySegment = nullptr;
break;
}
if( dummySegment )
{
view->Add( dummySegment );
m_highlight.push_back( dummySegment );
}
select = m_listCtrlPrimitives->GetNextSelected( select );
}
BOX2I bbox = m_dummyPad->ViewBBox();
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
{
// gives a size to the full drawable area
BOX2I drawbox;
drawbox.Move( m_dummyPad->GetPosition() );
drawbox.Inflate( bbox.GetSize().x * 2, bbox.GetSize().y * 2 );
view->SetBoundary( drawbox );
// Autozoom
view->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
// Add a margin
view->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
m_panelShowPadGal->StartDrawing();
m_panelShowPadGal->Refresh();
}
} }
else
// highlight selected primitives:
long select = m_listCtrlPrimitives->GetFirstSelected();
while( select >= 0 )
{ {
m_panelShowPad->Refresh(); PAD_CS_PRIMITIVE& primitive = m_primitives[select];
DRAWSEGMENT* dummySegment = new DRAWSEGMENT;
dummySegment->SetLayer( SELECTED_ITEMS_LAYER );
primitive.ExportTo( dummySegment );
dummySegment->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
dummySegment->Move( m_dummyPad->GetPosition() );
// Update selected primitive (highlight selected)
switch( primitive.m_Shape )
{
case S_SEGMENT:
case S_ARC:
case S_CURVE:
break;
case S_CIRCLE: // ring or circle
if( primitive.m_Thickness == 0 ) // filled circle
{ // the filled circle option does not exist in a DRAWSEGMENT
// but it is easy to create it with a circle having the
// right radius and outline width
wxPoint end = dummySegment->GetCenter();
end.x += primitive.m_Radius / 2;
dummySegment->SetEnd( end );
dummySegment->SetWidth( primitive.m_Radius );
}
break;
case S_POLYGON:
break;
default:
delete dummySegment;
dummySegment = nullptr;
break;
}
if( dummySegment )
{
view->Add( dummySegment );
m_highlight.push_back( dummySegment );
}
select = m_listCtrlPrimitives->GetNextSelected( select );
}
BOX2I bbox = m_dummyPad->ViewBBox();
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
{
// gives a size to the full drawable area
BOX2I drawbox;
drawbox.Move( m_dummyPad->GetPosition() );
drawbox.Inflate( bbox.GetSize().x * 2, bbox.GetSize().y * 2 );
view->SetBoundary( drawbox );
// Autozoom
view->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
// Add a margin
view->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
m_panelShowPadGal->StartDrawing();
m_panelShowPadGal->Refresh();
} }
} }

View File

@ -221,25 +221,12 @@ void DIALOG_SELECT_NET_FROM_LIST::HighlightNet( const wxString& aNetName )
netCode = net->GetNet(); netCode = net->GetNet();
} }
if( m_frame->IsGalCanvasActive() ) auto galCanvas = m_frame->GetGalCanvas();
{ KIGFX::RENDER_SETTINGS* render = galCanvas->GetView()->GetPainter()->GetSettings();
auto galCanvas = m_frame->GetGalCanvas(); render->SetHighlight( netCode >= 0, netCode );
KIGFX::RENDER_SETTINGS* render = galCanvas->GetView()->GetPainter()->GetSettings();
render->SetHighlight( netCode >= 0, netCode );
galCanvas->GetView()->UpdateAllLayersColor(); galCanvas->GetView()->UpdateAllLayersColor();
galCanvas->Refresh(); galCanvas->Refresh();
}
else
{
INSTALL_UNBUFFERED_DC( dc, m_frame->GetCanvas() );
if( m_brd->IsHighLightNetON() )
m_frame->HighLight( &dc );
m_brd->SetHighLightNet( netCode );
m_frame->HighLight( &dc );
}
} }

View File

@ -121,15 +121,12 @@ bool DIALOG_SET_GRID::TransferDataFromWindow()
// Notify GAL // Notify GAL
TOOL_MANAGER* mgr = m_parent->GetToolManager(); TOOL_MANAGER* mgr = m_parent->GetToolManager();
if( mgr && m_parent->IsGalCanvasActive() ) mgr->RunAction( "common.Control.gridPreset", true,
{ screen->GetGridCmdId() - ID_POPUP_GRID_LEVEL_1000 );
mgr->RunAction( "common.Control.gridPreset", true,
screen->GetGridCmdId() - ID_POPUP_GRID_LEVEL_1000 );
TOOL_EVENT gridOriginUpdate = ACTIONS::gridSetOrigin.MakeEvent(); TOOL_EVENT gridOriginUpdate = ACTIONS::gridSetOrigin.MakeEvent();
gridOriginUpdate.SetParameter( new VECTOR2D( m_parent->GetGridOrigin() ) ); gridOriginUpdate.SetParameter( new VECTOR2D( m_parent->GetGridOrigin() ) );
mgr->ProcessEvent( gridOriginUpdate ); mgr->ProcessEvent( gridOriginUpdate );
}
m_parent->UpdateGridSelectBox(); m_parent->UpdateGridSelectBox();

View File

@ -51,11 +51,6 @@
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase ); const wxPoint& aPosition, bool aErase );
static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
static void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
/* Local variables : */ /* Local variables : */
static int status_dimension; /* Used in dimension creation: static int status_dimension; /* Used in dimension creation:
* = 0 : initial value: no dimension in progress * = 0 : initial value: no dimension in progress
@ -211,67 +206,6 @@ void PCB_EDIT_FRAME::DeleteDimension( DIMENSION* aDimension, wxDC* aDC )
*/ */
static wxPoint initialTextPosition; static wxPoint initialTextPosition;
void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
{
if( aItem == NULL )
return;
// Store the initial position for undo/abort command
initialTextPosition = aItem->Text().GetTextPos();
aItem->Draw( m_canvas, DC, GR_XOR );
aItem->SetFlags( IS_MOVED );
SetMsgPanel( aItem );
SetCrossHairPosition( aItem->Text().GetTextPos() );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
SetCurItem( aItem );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
/* Move dimension text following the cursor. */
static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
if( dimension == NULL )
return;
if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->Text().SetTextPos( aPanel->GetParent()->GetCrossHairPosition() );
dimension->Draw( aPanel, aDC, GR_XOR );
}
/*
* Abort current text edit progress.
*
* If a text is selected, its initial coord are regenerated
*/
void AbortMoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
DIMENSION* dimension = (DIMENSION*) aPanel->GetScreen()->GetCurItem();
( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
aPanel->SetMouseCapture( NULL, NULL );
if( dimension == NULL ) // Should not occur
return;
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->Text().SetTextPos( initialTextPosition );
dimension->ClearFlags();
dimension->Draw( aPanel, aDC, GR_OR );
}
/* /*
* Place the current dimension text being moving * Place the current dimension text being moving
*/ */

View File

@ -79,74 +79,16 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case wxID_COPY: case wxID_COPY:
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
case ID_POPUP_PCB_EDIT_PCB_TARGET:
case ID_POPUP_PCB_EDIT_MODULE_PRMS:
case ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT:
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
case ID_POPUP_PCB_BEGIN_TRACK:
case ID_POPUP_PCB_END_TRACK:
case ID_POPUP_PCB_PLACE_THROUGH_VIA: case ID_POPUP_PCB_PLACE_THROUGH_VIA:
case ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA: case ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA:
case ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA: case ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA:
case ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA: case ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_BLIND_BURIED_VIA:
case ID_POPUP_PCB_PLACE_MICROVIA: case ID_POPUP_PCB_PLACE_MICROVIA:
case ID_POPUP_PCB_SWITCH_TRACK_POSTURE: case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
case ID_POPUP_PCB_APPLY_PAD_SETTINGS:
case ID_POPUP_PCB_COPY_PAD_SETTINGS:
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER:
case ID_POPUP_PCB_FILL_ALL_ZONES: case ID_POPUP_PCB_FILL_ALL_ZONES:
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES:
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE: case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT:
case ID_POPUP_PCB_PLACE_DRAGGED_ZONE_OUTLINE_SEGMENT:
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
case ID_POPUP_PCB_ADD_ZONE_CORNER:
case ID_POPUP_PCB_DELETE_TRACKSEG:
case ID_POPUP_PCB_DELETE_TRACK:
case ID_POPUP_PCB_DELETE_TRACKNET:
case ID_POPUP_PCB_FILL_ZONE: case ID_POPUP_PCB_FILL_ZONE:
case ID_POPUP_PCB_SELECT_LAYER:
case ID_POPUP_PCB_SELECT_CU_LAYER:
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
case ID_POPUP_PCB_MOVE_TRACK_NODE:
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE:
case ID_POPUP_PCB_BREAK_TRACK:
case ID_POPUP_PCB_EDIT_NET:
case ID_POPUP_PCB_EDIT_TRACK:
case ID_POPUP_PCB_EDIT_TRACKSEG:
case ID_POPUP_PCB_LOCK_ON_TRACKSEG:
case ID_POPUP_PCB_LOCK_OFF_TRACKSEG:
case ID_POPUP_PCB_LOCK_ON_TRACK:
case ID_POPUP_PCB_LOCK_OFF_TRACK:
case ID_POPUP_PCB_LOCK_ON_NET:
case ID_POPUP_PCB_LOCK_OFF_NET:
case ID_POPUP_PCB_GETINFO_MARKER:
case ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST:
case ID_POPUP_PCB_MOVE_PCB_TARGET_REQUEST:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( m_canvas->IsMouseCaptured() )
{
m_canvas->EndMouseCapture();
}
if( GetToolId() == ID_NO_TOOL_SELECTED )
SetNoToolSelected();
else
SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
break; break;
default: // Finish (abort) the command default: // Finish (abort) the command
@ -237,63 +179,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
InstallNetlistFrame( &dc ); InstallNetlistFrame( &dc );
break; break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetNoToolSelected();
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
break;
case ID_POPUP_PCB_END_LINE:
m_canvas->MoveCursorToCrossHair();
// EndSegment(&dc);
break;
case ID_POPUP_PCB_EDIT_TRACK:
if( GetCurItem() == NULL )
break;
Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
m_canvas->MoveCursorToCrossHair();
OnModify();
break;
case ID_POPUP_PCB_EDIT_TRACKSEG:
if( GetCurItem() == NULL )
break;
Edit_TrackSegm_Width( &dc, (TRACK*) GetCurItem() );
m_canvas->MoveCursorToCrossHair();
OnModify();
break;
case ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE:
{
wxCommandEvent dummy;
OnEditTracksAndVias( dummy );
}
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_BEGIN_TRACK:
m_canvas->MoveCursorToCrossHair();
OnHotkeyBeginRoute( &dc );
break;
case ID_POPUP_PCB_END_TRACK:
m_canvas->MoveCursorToCrossHair();
End_Route( (TRACK*) GetCurItem(), &dc );
break;
case ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE:
m_canvas->MoveCursorToCrossHair();
if( GetCurItem()->IsDragging() )
{
PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
}
break;
case ID_POPUP_PCB_SWITCH_TRACK_POSTURE: case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
/* change the position of initial segment when creating new tracks /* change the position of initial segment when creating new tracks
* switch from _/ to -\ . * switch from _/ to -\ .
@ -321,6 +206,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetCurItem()->IsDragging() ) if( GetCurItem()->IsDragging() )
{ {
// JEY TODO: reachable?
PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc ); PlaceDraggedOrMovedTrackSegment( (TRACK*) GetCurItem(), &dc );
} }
else else
@ -376,160 +262,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_POPUP_PCB_DELETE_TRACKSEG:
if( GetCurItem() )
{
m_canvas->MoveCursorToCrossHair();
SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
OnModify();
}
break;
case ID_POPUP_PCB_DELETE_TRACK:
if( GetCurItem() )
{
m_canvas->MoveCursorToCrossHair();
Delete_Track( &dc, (TRACK*) GetCurItem() );
SetCurItem( NULL );
OnModify();
}
break;
case ID_POPUP_PCB_DELETE_TRACKNET:
m_canvas->MoveCursorToCrossHair();
Delete_net( &dc, (TRACK*) GetCurItem() );
SetCurItem( NULL );
OnModify();
break;
case ID_POPUP_PCB_LOCK_ON_TRACKSEG:
Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
break;
case ID_POPUP_PCB_LOCK_OFF_TRACKSEG:
Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
break;
case ID_POPUP_PCB_LOCK_ON_TRACK:
Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
break;
case ID_POPUP_PCB_LOCK_OFF_TRACK:
Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
break;
case ID_POPUP_PCB_LOCK_ON_NET:
Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), true );
break;
case ID_POPUP_PCB_LOCK_OFF_NET:
Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), false );
break;
case ID_POPUP_PCB_SETFLAGS_TRACK_MNU:
break;
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
Edit_Zone_Params( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL ); // Outlines can have changed
break;
case ID_POPUP_PCB_ZONE_DUPLICATE:
{
ZONE_CONTAINER* zone = (ZONE_CONTAINER*) GetCurItem();
duplicateZone( &dc, zone );
}
break;
case ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE:
m_canvas->MoveCursorToCrossHair();
m_canvas->SetAutoPanRequest( true );
Add_Similar_Zone( &dc, (ZONE_CONTAINER*) GetCurItem() );
break;
case ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE:
m_canvas->MoveCursorToCrossHair();
m_canvas->SetAutoPanRequest( true );
Add_Zone_Cutout( &dc, (ZONE_CONTAINER*) GetCurItem() );
break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
// Force the main contour selection, to remove the entire zone:
((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
// Fall through
case ID_POPUP_PCB_DELETE_ZONE_CUTOUT:
m_canvas->MoveCursorToCrossHair();
{
int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode();
Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL );
TestNetConnection( NULL, netcode );
SetMsgPanel( GetBoard() );
}
break;
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
Remove_Zone_Corner( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL );
break;
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
m_canvas->SetAutoPanRequest( true );
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), false );
}
break;
case ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT:
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
m_canvas->SetAutoPanRequest( true );
Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->GetSelectedCorner() );
}
break;
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
m_canvas->SetAutoPanRequest( true );
Start_Move_Zone_Outlines( &dc, zone_cont );
}
break;
case ID_POPUP_PCB_ADD_ZONE_CORNER:
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
wxPoint pos = GetCrossHairPosition();
/* add corner between zone_cont->m_CornerSelection
* and zone_cont->m_CornerSelection+1
* and start move the new corner
*/
zone_cont->Draw( m_canvas, &dc, GR_XOR );
zone_cont->Outline()->InsertVertex( zone_cont->GetSelectedCorner(), pos );
zone_cont->SetSelectedCorner( zone_cont->GetSelectedCorner() + 1 );
zone_cont->Draw( m_canvas, &dc, GR_XOR );
m_canvas->SetAutoPanRequest( true );
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), true );
}
break;
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_PLACE_DRAGGED_ZONE_OUTLINE_SEGMENT:
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
m_canvas->SetAutoPanRequest( false );
}
break;
case ID_POPUP_PCB_FILL_ALL_ZONES: case ID_POPUP_PCB_FILL_ALL_ZONES:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Fill_All_Zones(); Fill_All_Zones();
@ -578,190 +310,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
SetCurItem( GetFootprintFromBoardByReference() );
module = (MODULE*) GetCurItem();
if( module == NULL )
break;
if( module->IsLocked() )
{
wxString msg = wxString::Format(
_( "Footprint %s found, but it is locked" ),
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
SendMessageToEESCHEMA( module );
m_canvas->MoveCursorToCrossHair();
StartMoveModule( module, &dc, false );
break;
case ID_POPUP_PCB_UPDATE_FOOTPRINTS:
if( GetCurItem() && GetCurItem()->Type() == PCB_MODULE_T )
{
InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), true, true );
m_canvas->MoveCursorToCrossHair();
}
break;
case ID_POPUP_PCB_EXCHANGE_FOOTPRINTS:
if( GetCurItem() && GetCurItem()->Type() == PCB_MODULE_T )
{
InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), false, true );
m_canvas->MoveCursorToCrossHair();
}
break;
case ID_POPUP_PCB_EDIT_MODULE_PRMS:
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != PCB_MODULE_T )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
break;
InstallFootprintPropertiesDialog( (MODULE*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT:
// If we don't have a current item, there's nothing we can do here
if( !GetCurItem() )
break;
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != PCB_MODULE_T )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
break;
if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
{
GetCurItem()->SetTimeStamp( GetNewTimeStamp() );
OnModify();
}
{
FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
editor->Load_Module_From_BOARD( (MODULE*)GetCurItem() );
SetCurItem( NULL ); // the current module could be deleted by
}
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DRAG_PAD_REQUEST:
module = (MODULE*) GetCurItem()->GetParent();
if( !module || module->Type() != PCB_MODULE_T )
break;
if( module->IsLocked() )
{
wxString msg;
msg.Printf( _( "The parent (%s) of the pad is locked" ),
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
m_canvas->MoveCursorToCrossHair();
StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
break;
case ID_POPUP_PCB_MOVE_PAD_REQUEST:
module = (MODULE*) GetCurItem()->GetParent();
if( !module || module->Type() != PCB_MODULE_T )
break;
if( module->IsLocked() )
{
wxString msg;
msg.Printf( _( "The parent (%s) of the pad is locked" ),
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
m_canvas->MoveCursorToCrossHair();
StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
break;
case ID_POPUP_PCB_EDIT_PAD:
InstallPadOptionsFrame( (D_PAD*) GetCurItem() );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_APPLY_PAD_SETTINGS:
m_canvas->MoveCursorToCrossHair();
SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
break;
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
m_canvas->MoveCursorToCrossHair();
PushPadProperties((D_PAD*) GetCurItem() );
break;
case ID_POPUP_PCB_COPY_PAD_SETTINGS:
m_canvas->MoveCursorToCrossHair();
Export_Pad_Settings( (D_PAD*) GetCurItem() );
break;
case ID_POPUP_PCB_SELECT_LAYER:
{
PCB_LAYER_ID itmp = SelectLayer( GetActiveLayer() );
if( itmp >= 0 )
{
// if user changed colors and we are in high contrast mode, then redraw
// because the PAD_ATTRIB_SMD pads may change color.
if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
{
m_canvas->Refresh();
}
SetActiveLayer( itmp );
}
m_canvas->MoveCursorToCrossHair();
}
break;
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
SelectCopperLayerPair(); SelectCopperLayerPair();
break; break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
{
PCB_LAYER_ID itmp = SelectLayer( GetActiveLayer(), LSET::AllCuMask() );
if( itmp >= 0 )
SetActiveLayer( itmp );
m_canvas->MoveCursorToCrossHair();
}
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
{
PCB_LAYER_ID itmp = SelectLayer( GetActiveLayer(), LSET::AllNonCuMask() );
if( itmp >= 0 )
SetActiveLayer( itmp );
}
break;
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
SelectCopperLayerPair();
m_canvas->MoveCursorToCrossHair();
break;
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );
@ -769,130 +321,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->Refresh( true ); m_canvas->Refresh( true );
break; break;
case ID_POPUP_PCB_MOVE_PCB_TARGET_REQUEST:
BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_EDIT_PCB_TARGET:
ShowTargetOptionsDialog( (PCB_TARGET*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DELETE_PCB_TARGET:
m_canvas->MoveCursorToCrossHair();
DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
SetCurItem( NULL );
break;
case ID_POPUP_PCB_DELETE_DIMENSION:
m_canvas->MoveCursorToCrossHair();
DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
SetCurItem( NULL );
break;
case ID_POPUP_PCB_EDIT_DIMENSION:
ShowDimensionPropertyDialog( (DIMENSION*) GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST:
BeginMoveDimensionText( (DIMENSION*) GetCurItem(), &dc );
break;
case ID_POPUP_PCB_DELETE_MARKER:
RemoveStruct( GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_GETINFO_MARKER:
if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DELETE_DRAWING_LAYER:
if( GetCurItem()->GetEditFlags() != 0 )
break;
Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
SetCurItem( NULL );
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
break;
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
m_canvas->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
m_canvas->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
if( End_Zone( &dc ) )
SetCurItem( NULL );
}
m_canvas->SetAutoPanRequest( false );
break;
case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER:
m_canvas->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
m_canvas->MoveCursorToCrossHair();
StartMoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
case ID_POPUP_PCB_MOVE_TRACK_NODE:
m_canvas->MoveCursorToCrossHair();
StartMoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
m_canvas->MoveCursorToCrossHair();
Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(), &dc );
break;
case ID_POPUP_PCB_BREAK_TRACK:
m_canvas->MoveCursorToCrossHair();
{
TRACK* track = (TRACK*) GetScreen()->GetCurItem();
wxPoint pos = GetCrossHairPosition();
track->Draw( m_canvas, &dc, GR_XOR );
PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
track->Draw( m_canvas, &dc, GR_XOR );
newtrack->Draw( m_canvas, &dc, GR_XOR );
// compute the new ratsnest, because connectivity could change
TestNetConnection( &dc, track->GetNetCode() );
}
break;
case ID_POPUP_PCB_MOVE_EXACT: case ID_POPUP_PCB_MOVE_EXACT:
moveExact(); moveExact();
break; break;
@ -917,14 +345,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Swap_Layers( event ); Swap_Layers( event );
break; break;
case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC:
{
wxConfigBase* cfg = Pgm().CommonSettings();
cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
}
break;
case ID_MENU_ARCHIVE_MODULES_IN_LIBRARY: case ID_MENU_ARCHIVE_MODULES_IN_LIBRARY:
ArchiveModulesOnBoard( false ); ArchiveModulesOnBoard( false );
break; break;

View File

@ -138,66 +138,6 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
} }
void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( PCB_LAYER_ID aLayer )
{
if( IsCopperLayer( aLayer ) )
{
DisplayError( this, _( "Copper layer global delete not allowed!" ) );
return;
}
wxString msg;
msg.Printf( _( "Delete everything on layer %s?" ),
GetChars( GetBoard()->GetLayerName( aLayer ) ) );
if( !IsOK( this, msg ) )
return;
// Step 1: build the list of items to remove.
// because we are using iterators, we cannot modify the drawing list during iterate
// so we are using a 2 steps calculation:
// First, collect items.
// Second, remove items.
std::vector<BOARD_ITEM*> list;
for( auto item : GetBoard()->Drawings() )
{
switch( item->Type() )
{
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_DIMENSION_T:
case PCB_TARGET_T:
if( item->GetLayer() == aLayer )
list.push_back( item );
break;
default:
wxLogDebug( wxT( "Delete_Drawings_All_Layer() error: unknown type %d" ), item->Type() );
}
}
if( list.size() == 0 ) // No item found
return;
// Step 2: remove items from main list, and move them to the undo list
PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker( NULL, UR_DELETED );
for( auto item : list )
{
item->UnLink();
picker.SetItem( item );
pickList.PushItem( picker );
}
OnModify();
SaveCopyInUndoList(pickList, UR_DELETED);
}
static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC ) static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC )
{ {
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();

View File

@ -604,15 +604,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// Select netclass Default as current netclass (it always exists) // Select netclass Default as current netclass (it always exists)
SetCurrentNetClass( NETCLASS::Default ); SetCurrentNetClass( NETCLASS::Default );
// When GAL is active, the connectivity is rebuilt when the board is loaded // Rebuild list of nets (full ratsnest rebuild)
// For legacy, we keep these calls to ensure ratsnest Compile_Ratsnest( NULL, true );
// todo: Remove legacy code GetBoard()->BuildConnectivity();
if( !IsGalCanvasActive() )
{
// Rebuild list of nets (full ratsnest rebuild)
Compile_Ratsnest( NULL, true );
GetBoard()->BuildConnectivity();
}
onBoardLoaded(); onBoardLoaded();

View File

@ -140,20 +140,12 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_POPUP_MODEDIT_EDIT_BODY_ITEM,
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE,
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings ) EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings )
// Menu 3D Frame // Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame ) EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
// Switching canvases // Switching canvases
EVT_MENU( ID_MENU_CANVAS_LEGACY, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
@ -532,11 +524,8 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
if( IsGalCanvasActive() ) GetGalCanvas()->SetEventDispatcher( NULL );
{ GetGalCanvas()->StopDrawing();
GetGalCanvas()->SetEventDispatcher( NULL );
GetGalCanvas()->StopDrawing();
}
// Do not show the layer manager during closing to avoid flicker // Do not show the layer manager during closing to avoid flicker
// on some platforms (Windows) that generate useless redraw of items in // on some platforms (Windows) that generate useless redraw of items in

View File

@ -342,14 +342,6 @@ public:
/// Function to place a graphic item type EDGE_MODULE currently moved /// Function to place a graphic item type EDGE_MODULE currently moved
void Place_EdgeMod( EDGE_MODULE* drawitem ); void Place_EdgeMod( EDGE_MODULE* drawitem );
/**
* Change pad characteristics for the given footprint
* or all footprints which look like the given footprint.
* Options are set by the opened dialog.
* @param aPad is the pattern. The given footprint is the parent of this pad
*/
void PushPadProperties( D_PAD* aPad );
/** /**
* Delete the given module from its library. * Delete the given module from its library.
*/ */

View File

@ -254,15 +254,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case wxID_COPY: case wxID_COPY:
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_MODEDIT_PAD_SETTINGS: case ID_MODEDIT_PAD_SETTINGS:
case ID_POPUP_PCB_COPY_PAD_SETTINGS:
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM:
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
break; break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
default: default:
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
{ {
@ -270,8 +263,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->CallEndMouseCapture( &dc ); m_canvas->CallEndMouseCapture( &dc );
} }
if( id != ID_POPUP_CANCEL_CURRENT_COMMAND ) SetNoToolSelected();
SetNoToolSelected();
break; break;
} }
@ -427,7 +419,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
m_toolManager->GetView()->Update( GetBoard()->m_Modules ); m_toolManager->GetView()->Update( GetBoard()->m_Modules );
if( IsGalCanvasActive() && GetGalCanvas() ) if( GetGalCanvas() )
GetGalCanvas()->ForceRefresh(); GetGalCanvas()->ForceRefresh();
else else
GetCanvas()->Refresh(); GetCanvas()->Refresh();
@ -460,7 +452,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_toolManager->GetView()->Update( GetBoard()->m_Modules ); m_toolManager->GetView()->Update( GetBoard()->m_Modules );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
if( IsGalCanvasActive() && GetGalCanvas() ) if( GetGalCanvas() )
GetGalCanvas()->ForceRefresh(); GetGalCanvas()->ForceRefresh();
else else
GetCanvas()->Refresh(); GetCanvas()->Refresh();
@ -594,26 +586,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
break;
case ID_POPUP_PCB_EDIT_MODULE_PRMS:
editFootprintProperties( (MODULE*) GetScreen()->GetCurItem() );
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
break;
case ID_POPUP_PCB_MOVE_PAD_REQUEST:
m_canvas->MoveCursorToCrossHair();
StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc, false );
break;
case ID_POPUP_PCB_EDIT_PAD:
InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() );
m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_MOVE_EXACT: case ID_POPUP_PCB_MOVE_EXACT:
@ -626,44 +598,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// JEY TODO: many (most? all?) of these are legacy-only and can be removed. // JEY TODO: many (most? all?) of these are legacy-only and can be removed.
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
// Calls the global change dialog:
PushPadProperties((D_PAD*) GetScreen()->GetCurItem());
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_COPY_PAD_SETTINGS:
m_canvas->MoveCursorToCrossHair();
Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() );
break;
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
m_canvas->MoveCursorToCrossHair();
if( GetScreen()->GetCurItem()->IsNew() )
{
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL );
}
break;
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
InstallGraphicItemPropertiesDialog( GetScreen()->GetCurItem() );
break;
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Width( NULL );
m_canvas->Refresh();
break;
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Layer( NULL );
m_canvas->Refresh();
break;
case ID_GEN_IMPORT_GRAPHICS_FILE: case ID_GEN_IMPORT_GRAPHICS_FILE:
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
{ {
@ -866,11 +800,8 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
m_Layers->SelectLayer( GetActiveLayer() ); m_Layers->SelectLayer( GetActiveLayer() );
m_Layers->OnLayerSelected(); m_Layers->OnLayerSelected();
if( IsGalCanvasActive() ) GetGalCanvas()->SetHighContrastLayer( aLayer );
{ GetGalCanvas()->Refresh();
GetGalCanvas()->SetHighContrastLayer( aLayer );
GetGalCanvas()->Refresh();
}
} }
bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )

View File

@ -329,8 +329,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module( const wxString& aName )
SetMsgPanel( module ); SetMsgPanel( module );
PlaceModule( module, NULL ); PlaceModule( module, NULL );
if( IsGalCanvasActive() ) module->SetPosition( wxPoint( 0, 0 ) );
module->SetPosition( wxPoint( 0, 0 ) );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->BuildListOfNets(); GetBoard()->BuildListOfNets();
@ -856,11 +855,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
newmodule->SetTimeStamp( GetNewTimeStamp() ); newmodule->SetTimeStamp( GetNewTimeStamp() );
commit.Push( wxT( "Insert module" ) ); commit.Push( wxT( "Insert module" ) );
if( pcbframe->IsGalCanvasActive() ) pcbframe->Raise();
{ pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
pcbframe->Raise();
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
}
} }
newmodule->ClearFlags(); newmodule->ClearFlags();

View File

@ -499,11 +499,8 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event )
newmodule->SetTimeStamp( GetNewTimeStamp() ); newmodule->SetTimeStamp( GetNewTimeStamp() );
commit.Push( wxT( "Insert module" ) ); commit.Push( wxT( "Insert module" ) );
if( pcbframe->IsGalCanvasActive() ) pcbframe->Raise();
{ pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
pcbframe->Raise();
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
}
newmodule->ClearFlags(); newmodule->ClearFlags();
pcbframe->SetCurItem( NULL ); pcbframe->SetCurItem( NULL );

View File

@ -256,12 +256,9 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
// Delete the GRID_TRICKS. // Delete the GRID_TRICKS.
m_parameterGrid->PopEventHandler( true ); m_parameterGrid->PopEventHandler( true );
if( IsGalCanvasActive() ) GetGalCanvas()->StopDrawing();
{ // Be sure any event cannot be fired after frame deletion:
GetGalCanvas()->StopDrawing(); GetGalCanvas()->SetEvtHandlerEnabled( false );
// Be sure any event cannot be fired after frame deletion:
GetGalCanvas()->SetEvtHandlerEnabled( false );
}
// Be sure a active tool (if exists) is desactivated: // Be sure a active tool (if exists) is desactivated:
if( m_toolManager ) if( m_toolManager )
@ -328,15 +325,12 @@ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
void FOOTPRINT_WIZARD_FRAME::updateView() void FOOTPRINT_WIZARD_FRAME::updateView()
{ {
if( IsGalCanvasActive() ) auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
{ dp->UseColorScheme( &Settings().Colors() );
auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() ); dp->DisplayBoard( GetBoard() );
dp->UseColorScheme( &Settings().Colors() ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
dp->DisplayBoard( GetBoard() ); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); UpdateMsgPanel();
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
UpdateMsgPanel();
}
} }

View File

@ -104,8 +104,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
SetCurItem( NULL ); SetCurItem( NULL );
if( IsGalCanvasActive() ) m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
// Delete the current footprint // Delete the current footprint
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();

View File

@ -413,10 +413,6 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
evt_type = ID_MENU_CANVAS_OPENGL; evt_type = ID_MENU_CANVAS_OPENGL;
break; break;
case HK_CANVAS_LEGACY:
evt_type = ID_MENU_CANVAS_LEGACY;
break;
case HK_ZONE_FILL_OR_REFILL: case HK_ZONE_FILL_OR_REFILL:
evt_type = ID_POPUP_PCB_FILL_ALL_ZONES; evt_type = ID_POPUP_PCB_FILL_ALL_ZONES;
break; break;
@ -522,16 +518,6 @@ bool PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem( int aIdCommand )
evt_type = ID_POPUP_PCB_CREATE_ARRAY; evt_type = ID_POPUP_PCB_CREATE_ARRAY;
break; break;
case HK_DUPLICATE_ITEM_AND_INCREMENT:
if( canDuplicate )
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT;
break;
case HK_DUPLICATE:
if( canDuplicate )
evt_type = ID_POPUP_PCB_DUPLICATE_ITEM;
break;
case HK_MOVE_ITEM_EXACT: case HK_MOVE_ITEM_EXACT:
evt_type = ID_POPUP_PCB_MOVE_EXACT; evt_type = ID_POPUP_PCB_MOVE_EXACT;
break; break;

View File

@ -328,7 +328,7 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
col = COLUMN_COLORBM; col = COLUMN_COLORBM;
auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ), auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
AreArbitraryColorsAllowed(), getBackgroundLayerColor() ); getBackgroundLayerColor() );
bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this ); bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this ); bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) ); bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
@ -403,7 +403,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
if( aSpec.color != COLOR4D::UNSPECIFIED ) if( aSpec.color != COLOR4D::UNSPECIFIED )
{ {
auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ), auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
AreArbitraryColorsAllowed(), getBackgroundLayerColor() ); getBackgroundLayerColor() );
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this ); bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
bmb->SetToolTip( _( "Left double click or middle click for color change" ) ); bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags ); m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );

View File

@ -144,13 +144,6 @@ protected:
*/ */
virtual bool useAlternateBitmap(int aRow) { return false; } virtual bool useAlternateBitmap(int aRow) { return false; }
/**
* Subclasses can override this to provide logic for allowing
* arbitrary color selection via wxColourPicker instead of DisplayColorFrame.
*/
// LEGACY TODO: obsolete once legacy canvas removed
virtual bool AreArbitraryColorsAllowed() { return false; }
/** /**
* Subclasses can override this to provide accurate representation * Subclasses can override this to provide accurate representation
* of transparent colour swatches. * of transparent colour swatches.

View File

@ -159,8 +159,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
Update3DView(); Update3DView();
if( IsGalCanvasActive() ) updateView();
updateView();
m_canvas->Refresh(); m_canvas->Refresh();

View File

@ -334,22 +334,14 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
prefs_menu->AppendSeparator(); prefs_menu->AppendSeparator();
if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) text = AddHotkeyName( _( "Accelerated Graphics" ), m_hotkeysDescrList, HK_CANVAS_OPENGL );
{
text = AddHotkeyName( _( "Legacy Tool&set" ), m_hotkeysDescrList, HK_CANVAS_LEGACY );
AddMenuItem( prefs_menu, ID_MENU_CANVAS_LEGACY, text,
_( "Use Legacy Toolset (not all features will be available)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
}
text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), m_hotkeysDescrList, HK_CANVAS_OPENGL );
AddMenuItem( prefs_menu, ID_MENU_CANVAS_OPENGL, text, AddMenuItem( prefs_menu, ID_MENU_CANVAS_OPENGL, text,
_( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ), _( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Modern Toolset (&Fallback)" ), m_hotkeysDescrList, HK_CANVAS_CAIRO ); text = AddHotkeyName( _( "Standard Graphics" ), m_hotkeysDescrList, HK_CANVAS_CAIRO );
AddMenuItem( prefs_menu, ID_MENU_CANVAS_CAIRO, text, AddMenuItem( prefs_menu, ID_MENU_CANVAS_CAIRO, text,
_( "Use Modern Toolset with software graphics (fall-back)" ), _( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
prefs_menu->AppendSeparator(); prefs_menu->AppendSeparator();

View File

@ -475,25 +475,16 @@ void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu )
_( "Show preferences for all open tools" ), _( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) ); KiBitmap( preference_xpm ) );
if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) text = AddHotkeyName( _( "Accelerated Graphics" ), g_Board_Editor_Hotkeys_Descr,
{
text = AddHotkeyName(
_( "Legacy Tool&set" ), g_Board_Editor_Hotkeys_Descr, HK_CANVAS_LEGACY );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_LEGACY, text,
_( "Use Legacy Toolset (not all features will be available)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
}
text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), g_Board_Editor_Hotkeys_Descr,
HK_CANVAS_OPENGL ); HK_CANVAS_OPENGL );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, text, AddMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ), _( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Modern Toolset (Fallbac&k)" ), g_Board_Editor_Hotkeys_Descr, text = AddHotkeyName( _( "Standard Graphics" ), g_Board_Editor_Hotkeys_Descr,
HK_CANVAS_CAIRO ); HK_CANVAS_CAIRO );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, text, AddMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use Modern Toolset with software graphics (fall-back)" ), _( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO ); KiBitmap( tools_xpm ), wxITEM_RADIO );
aParentMenu->AppendSeparator(); aParentMenu->AppendSeparator();

View File

@ -19,103 +19,9 @@
#include <drag.h> #include <drag.h>
static D_PAD* s_CurrentSelectedPad;
static wxPoint Pad_OldPos; static wxPoint Pad_OldPos;
/* Cancel move pad command.
*/
static void Abort_Move_Pad( EDA_DRAW_PANEL* Panel, wxDC* DC )
{
D_PAD* pad = s_CurrentSelectedPad;
Panel->SetMouseCapture( NULL, NULL );
if( pad == NULL )
return;
pad->Draw( Panel, DC, GR_XOR );
pad->ClearFlags();
pad->SetPosition( Pad_OldPos );
pad->Draw( Panel, DC, GR_XOR );
// Pad move in progress: restore origin of dragged tracks, if any.
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* track = g_DragSegmentList[ii].m_Track;
track->Draw( Panel, DC, GR_XOR );
track->SetState( IN_EDIT, false );
track->ClearFlags();
g_DragSegmentList[ii].RestoreInitialValues();
track->Draw( Panel, DC, GR_OR );
}
EraseDragList();
s_CurrentSelectedPad = NULL;
}
/* Draw in drag mode when moving a pad.
*/
static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
TRACK* Track;
D_PAD* pad = s_CurrentSelectedPad;
if( pad == NULL ) // Should not occur
return;
if( aErase )
pad->Draw( aPanel, aDC, GR_XOR );
pad->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
pad->Draw( aPanel, aDC, GR_XOR );
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = g_DragSegmentList[ii].m_Track;
if( aErase )
Track->Draw( aPanel, aDC, GR_XOR );
g_DragSegmentList[ii].SetTrackEndsCoordinates( wxPoint(0, 0) );
Track->Draw( aPanel, aDC, GR_XOR );
}
}
// Function to initialize the "move pad" command
void PCB_BASE_FRAME::StartMovePad( D_PAD* aPad, wxDC* aDC, bool aDragConnectedTracks )
{
if( aPad == NULL )
return;
s_CurrentSelectedPad = aPad;
Pad_OldPos = aPad->GetPosition();
SetMsgPanel( aPad );
m_canvas->SetMouseCapture( Show_Pad_Move, Abort_Move_Pad );
// Draw the pad, in SKETCH mode
aPad->Draw( m_canvas, aDC, GR_XOR );
aPad->SetFlags( IS_MOVED );
aPad->Draw( m_canvas, aDC, GR_XOR );
EraseDragList();
// Build the list of track segments to drag if the command is a drag pad
if( aDragConnectedTracks )
{
DRAG_LIST drglist( GetBoard() );
drglist.BuildDragListe( aPad );
UndrawAndMarkSegmentsToDrag( m_canvas, aDC );
}
}
// Routine to place a moved pad. // Routine to place a moved pad.
void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC ) void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC )
{ {

View File

@ -45,751 +45,9 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aPosition,
bool aErase );
static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC );
static bool InitialiseDragParameters();
static wxPoint PosInit, s_LastPos;
static double s_StartSegmentSlope, s_EndSegmentSlope,
s_MovingSegmentSlope,
s_StartSegment_Yorg, s_EndSegment_Yorg,
s_MovingSegment_Yorg; //slope and intercept parameters of lines
bool s_StartPointVertical, s_EndPointVertical,
s_MovingSegmentVertical, s_MovingSegmentHorizontal,
s_StartPointHorizontal, s_EndPointHorizontal; // vertical or
// horizontal line
// indicators
bool s_StartSegmentPresent, s_EndSegmentPresent;
static PICKED_ITEMS_LIST s_ItemsListPicker; static PICKED_ITEMS_LIST s_ItemsListPicker;
/** Abort function for drag or move track
*/
static void Abort_MoveTrack( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) aPanel->GetParent();
BOARD * pcb = frame->GetBoard();
pcb->HighLightOFF();
pcb->PopHighLight();
frame->SetCurItem( NULL );
aPanel->SetMouseCapture( NULL, NULL );
// Undo move and redraw trace segments.
for( unsigned jj=0 ; jj < g_DragSegmentList.size(); jj++ )
{
TRACK* track = g_DragSegmentList[jj].m_Track;
g_DragSegmentList[jj].RestoreInitialValues();
track->SetState( IN_EDIT, false );
track->ClearFlags();
}
// Clear the undo picker list:
s_ItemsListPicker.ClearListAndDeleteItems();
EraseDragList();
aPanel->Refresh();
}
// Redraw the moved node according to the mouse cursor position
static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*) aPanel->GetDisplayOptions();
wxPoint moveVector;
int tmp = displ_opts->m_DisplayPcbTrackFill;
GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT;
displ_opts->m_DisplayPcbTrackFill = false;
#ifndef USE_WX_OVERLAY
aErase = true;
#else
aErase = false;
#endif
// set the new track coordinates
wxPoint Pos = aPanel->GetParent()->GetCrossHairPosition();
moveVector = Pos - s_LastPos;
s_LastPos = Pos;
TRACK *track = NULL;
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
track = g_DragSegmentList[ii].m_Track;
if( aErase )
track->Draw( aPanel, aDC, draw_mode );
if( track->GetFlags() & STARTPOINT )
track->SetStart( track->GetStart() + moveVector );
if( track->GetFlags() & ENDPOINT )
track->SetEnd( track->GetEnd() + moveVector );
if( track->Type() == PCB_VIA_T )
track->SetEnd( track->GetStart() );
track->Draw( aPanel, aDC, draw_mode );
}
displ_opts->m_DisplayPcbTrackFill = tmp;
// Display track length
if( track )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
frame->SetMsgPanel( track );
}
}
/* drawing the track segment movement
* > s_MovingSegmentSlope slope = moving track segment slope
* > s_StartSegmentSlope slope = slope of the segment connected to the start
* point of the moving segment
* > s_EndSegmentSlope slope = slope of the segment connected to the end point
* of the moving segment
*
* moved segment function :
* yt=s_MovingSegmentSlope * x + s_MovingSegment_Yorg
*
* segment connected to moved segment's start:
* y1 = s_StartSegmentSlope * x + s_StartSegment_Yorg
*
* segment connected to moved segment's end:
* y2=s_EndSegmentSlope * x + s_EndSegment_Yorg
*
* first intersection point will be located at
* y1=yt ->
*
* xi1=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_StartSegmentSlope-s_MovingSegmentSlope)
* yi1=s_MovingSegmentSlope*xi1+s_MovingSegment_Yorg
* or yi1=s_StartSegmentSlope*xi1+s_MovingSegment_Yorg
*
* second intersection point
* y2=yt ->
*
* xi2=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_MovingSegmentSlope-s_MovingSegmentSlope)
* yi2=s_MovingSegmentSlope*xi2+s_MovingSegment_Yorg
* or yi1=s_EndSegmentSlope*xi2+s_MovingSegment_Yorg
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!! special attention to vertical segments because
* !!!!! their slope=infinite
* !!!!! intersection point will be calculated using the
* !!!!! segment intersecting it
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* Slope parameters are computed once, because they can become undetermined
* when moving segments
* (i.e. when a segment length is 0) and we want keep them constant
*/
static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{
double xi1 = 0, yi1 = 0, xi2 = 0, yi2 = 0; // calculated intersection points
double tx1, tx2, ty1, ty2; // temporary storage of points
int dx, dy;
bool update = true;
TRACK* Track;
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if( g_DragSegmentList.size() == 0 )
return;
/* get the segments :
* from last to first in list are:
* the segment to move
* the segment connected to its end point (if exists)
* the segment connected to its start point (if exists)
*/
int ii = g_DragSegmentList.size() - 1;
Track = g_DragSegmentList[ii].m_Track;
if( Track == NULL )
return;
ii--;
if( ii >= 0)
{
if( s_EndSegmentPresent )
{
// Get the segment connected to the end point
tSegmentToEnd = g_DragSegmentList[ii].m_Track;
ii--;
}
if( s_StartSegmentPresent )
{
// Get the segment connected to the start point
if( ii >= 0 )
tSegmentToStart = g_DragSegmentList[ii].m_Track;
}
}
GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT;
// Undraw the current moved track segments before modification
#ifndef USE_WX_OVERLAY
// if( erase )
{
Track->Draw( aPanel, aDC, draw_mode );
if( tSegmentToStart )
tSegmentToStart->Draw( aPanel, aDC, draw_mode );
if( tSegmentToEnd )
tSegmentToEnd->Draw( aPanel, aDC, draw_mode );
}
#endif
// Compute the new track segment position
wxPoint Pos = aPanel->GetParent()->GetCrossHairPosition();
dx = Pos.x - s_LastPos.x;
dy = Pos.y - s_LastPos.y;
// move the line by dx and dy
tx1 = (double) ( Track->GetStart().x + dx );
ty1 = (double) ( Track->GetStart().y + dy );
tx2 = (double) ( Track->GetEnd().x + dx );
ty2 = (double) ( Track->GetEnd().y + dy );
// recalculate the segments new parameters and intersection points
// only the intercept will change, segment slopes does not change
// because we are moving parallel with is initial state
if( !s_MovingSegmentVertical )
s_MovingSegment_Yorg = ty1 - ( s_MovingSegmentSlope * tx1 );
if( ( !s_EndPointVertical ) && ( !s_MovingSegmentVertical ) )
{
xi2 = ( s_MovingSegment_Yorg - s_EndSegment_Yorg )
/ ( s_EndSegmentSlope - s_MovingSegmentSlope );
}
else
{
if( !s_EndPointVertical )
xi2 = tx2;
else
{
//P1=P2
if( !s_EndPointHorizontal )
xi2 = tx2 - dx;
else
update = false;
}
}
if( !s_MovingSegmentVertical )
yi2 = ( s_MovingSegmentSlope * xi2 ) + s_MovingSegment_Yorg;
else
{
if( !s_EndPointVertical )
yi2 = ( s_EndSegmentSlope * xi2 ) + s_EndSegment_Yorg;
else
{
if( !s_EndPointHorizontal )
update = false;
else
yi2 = ( s_MovingSegmentSlope * xi2 ) + s_MovingSegment_Yorg;
}
}
if( ( !s_StartPointVertical ) && ( !s_MovingSegmentVertical ) )
{
xi1 = ( s_MovingSegment_Yorg - s_StartSegment_Yorg )
/ ( s_StartSegmentSlope - s_MovingSegmentSlope );
}
else
{
if( !s_StartPointVertical )
xi1 = tx1;
else
{
//P1=P2
if( !s_StartPointHorizontal )
xi1 = tx1 - dx;
else
{
if( !s_StartPointHorizontal )
update = false;
}
}
}
if( !s_MovingSegmentVertical )
yi1 = ( s_MovingSegmentSlope * xi1 ) + s_MovingSegment_Yorg;
else
{
if( !s_StartPointVertical )
yi1 = ( s_StartSegmentSlope * xi1 ) + s_StartSegment_Yorg;
else
{
if( !s_StartPointHorizontal )
update = false;
else
yi2 = ( s_MovingSegmentSlope * xi1 ) + s_MovingSegment_Yorg;
}
}
// update the segment coordinates (if possible)
if( tSegmentToStart == NULL )
{
xi1 = tx1;
yi1 = ty1;
}
if( tSegmentToEnd == NULL )
{
xi2 = tx2;
yi2 = ty2;
}
if( update )
{
s_LastPos = Pos;
Track->SetStart( wxPoint( KiROUND( xi1 ), KiROUND( yi1 ) ) );
Track->SetEnd( wxPoint( KiROUND( xi2 ), KiROUND( yi2 ) ) );
if( tSegmentToEnd )
{
if( tSegmentToEnd->GetFlags() & STARTPOINT )
tSegmentToEnd->SetStart( Track->GetEnd() );
else
tSegmentToEnd->SetEnd( Track->GetEnd() );
}
if( tSegmentToStart )
{
if( tSegmentToStart->GetFlags() & STARTPOINT )
tSegmentToStart->SetStart( Track->GetStart() );
else
tSegmentToStart->SetEnd( Track->GetStart() );
}
}
Track->Draw( aPanel, aDC, draw_mode );
if( tSegmentToStart )
tSegmentToStart->Draw( aPanel, aDC, draw_mode );
if( tSegmentToEnd )
tSegmentToEnd->Draw( aPanel, aDC, draw_mode );
// Display track length
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
frame->SetMsgPanel( Track );
}
/* Init variables (slope, Y intersect point, flags) for
* Show_Drag_Track_Segment_With_Cte_Slope()
* return true if Ok, false if dragging is not possible
* (2 colinear segments)
*/
bool InitialiseDragParameters()
{
double tx1, tx2, ty1, ty2; // temporary storage of points
TRACK* Track;
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if( g_DragSegmentList.size() == 0 )
return false;
/* get the segments :
* from last to first in list are:
* the segment to move
* the segment connected to its end point (if exists)
* the segment connected to its start point (if exists)
*/
int ii = g_DragSegmentList.size() - 1;
Track = g_DragSegmentList[ii].m_Track;
if( Track == NULL )
return false;
ii--;
if( ii >= 0)
{
if( s_EndSegmentPresent )
{
tSegmentToEnd = g_DragSegmentList[ii].m_Track; // Get the segment connected to
// the end point
ii--;
}
if( s_StartSegmentPresent )
{
if( ii >= 0 )
tSegmentToStart = g_DragSegmentList[ii].m_Track; // Get the segment connected to
// the start point
}
}
// would be nice to eliminate collinear segments here, so we don't
// have to deal with that annoying "Unable to drag this segment: two
// collinear segments"
s_StartPointVertical = false;
s_EndPointVertical = false;
s_MovingSegmentVertical = false;
s_StartPointHorizontal = false;
s_EndPointHorizontal = false;
s_MovingSegmentHorizontal = false;
// Init parameters for the starting point of the moved segment
if( tSegmentToStart )
{
if( tSegmentToStart->GetFlags() & ENDPOINT )
{
tx1 = (double) tSegmentToStart->GetStart().x;
ty1 = (double) tSegmentToStart->GetStart().y;
tx2 = (double) tSegmentToStart->GetEnd().x;
ty2 = (double) tSegmentToStart->GetEnd().y;
}
else
{
tx1 = (double) tSegmentToStart->GetEnd().x;
ty1 = (double) tSegmentToStart->GetEnd().y;
tx2 = (double) tSegmentToStart->GetStart().x;
ty2 = (double) tSegmentToStart->GetStart().y;
}
}
else // move the start point on a line starting at Track->GetStart(), and perpendicular to Track
{
tx1 = (double) Track->GetStart().x;
ty1 = (double) Track->GetStart().y;
tx2 = (double) Track->GetEnd().x;
ty2 = (double) Track->GetEnd().y;
RotatePoint( &tx2, &ty2, tx1, ty1, 900 );
}
if( tx1 != tx2 )
{
s_StartSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
s_StartSegment_Yorg = ty1 - ( ty2 - ty1 ) * tx1 / ( tx2 - tx1 );
}
else
{
s_StartPointVertical = true; //signal first segment vertical
}
if( ty1 == ty2 )
{
s_StartPointHorizontal = true;
}
// Init parameters for the ending point of the moved segment
if( tSegmentToEnd )
{
//check if second line is vertical
if( tSegmentToEnd->GetFlags() & STARTPOINT )
{
tx1 = (double) tSegmentToEnd->GetStart().x;
ty1 = (double) tSegmentToEnd->GetStart().y;
tx2 = (double) tSegmentToEnd->GetEnd().x;
ty2 = (double) tSegmentToEnd->GetEnd().y;
}
else
{
tx1 = (double) tSegmentToEnd->GetEnd().x;
ty1 = (double) tSegmentToEnd->GetEnd().y;
tx2 = (double) tSegmentToEnd->GetStart().x;
ty2 = (double) tSegmentToEnd->GetStart().y;
}
}
else // move the start point on a line starting at Track->GetEnd(), and perpendicular to Track
{
tx1 = (double) Track->GetEnd().x;
ty1 = (double) Track->GetEnd().y;
tx2 = (double) Track->GetStart().x;
ty2 = (double) Track->GetStart().y;
RotatePoint( &tx2, &ty2, tx1, ty1, -900 );
}
if( tx2 != tx1 )
{
s_EndSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
s_EndSegment_Yorg = ty1 - ( ty2 - ty1 ) * tx1 / ( tx2 - tx1 );
}
else
{
s_EndPointVertical = true; //signal second segment vertical
}
if( ty1 == ty2 )
{
s_EndPointHorizontal = true;
}
// Init parameters for the moved segment
tx1 = (double) Track->GetStart().x;
ty1 = (double) Track->GetStart().y;
tx2 = (double) Track->GetEnd().x;
ty2 = (double) Track->GetEnd().y;
if( tx2 != tx1 )
{
s_MovingSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
}
else
{
s_MovingSegmentVertical = true; // signal vertical line
}
if( ty1 == ty2 )
{
s_MovingSegmentHorizontal = true;
}
// Test if drag is possible:
if( s_MovingSegmentVertical )
{
if( s_EndPointVertical || s_StartPointVertical )
return false;
}
else
{
if( !s_EndPointVertical && ( s_MovingSegmentSlope == s_EndSegmentSlope ) )
return false;
if( !s_StartPointVertical && ( s_MovingSegmentSlope == s_StartSegmentSlope ) )
return false;
}
return true;
}
void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aCommand )
{
if( !aTrack )
return;
EraseDragList();
// Change highlighted net: the new one will be highlighted
GetBoard()->PushHighLight();
if( GetBoard()->IsHighLightNetON() )
HighLight( aDC );
PosInit = GetCrossHairPosition();
if( aTrack->Type() == PCB_VIA_T )
{
aTrack->SetFlags( IS_DRAGGED | STARTPOINT | ENDPOINT );
AddSegmentToDragList( aTrack->GetFlags(), aTrack );
if( aCommand != ID_POPUP_PCB_MOVE_TRACK_SEGMENT )
{
Collect_TrackSegmentsToDrag( GetBoard(), aTrack->GetStart(),
aTrack->GetLayerSet(),
aTrack->GetNetCode(), aTrack->GetWidth() / 2 );
}
PosInit = aTrack->GetStart();
}
else
{
STATUS_FLAGS diag = aTrack->IsPointOnEnds( GetCrossHairPosition(), -1 );
wxPoint pos;
switch( aCommand )
{
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: // Move segment
aTrack->SetFlags( IS_DRAGGED | ENDPOINT | STARTPOINT );
AddSegmentToDragList( aTrack->GetFlags(), aTrack );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: // drag a segment
pos = aTrack->GetStart();
Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerSet(),
aTrack->GetNetCode(), aTrack->GetWidth() / 2 );
pos = aTrack->GetEnd();
aTrack->SetFlags( IS_DRAGGED | ENDPOINT | STARTPOINT );
Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerSet(),
aTrack->GetNetCode(), aTrack->GetWidth() / 2 );
break;
case ID_POPUP_PCB_MOVE_TRACK_NODE: // Drag via or move node
pos = (diag & STARTPOINT) ? aTrack->GetStart() : aTrack->GetEnd();
Collect_TrackSegmentsToDrag( GetBoard(), pos, aTrack->GetLayerSet(),
aTrack->GetNetCode(), aTrack->GetWidth() / 2 );
PosInit = pos;
break;
}
aTrack->SetFlags( IS_DRAGGED );
}
// Prepare the Undo command
ITEM_PICKER picker( aTrack, UR_CHANGED );
picker.SetLink( aTrack->Clone() );
s_ItemsListPicker.PushItem( picker );
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* draggedtrack = g_DragSegmentList[ii].m_Track;
picker.SetItem( draggedtrack );
picker.SetLink( draggedtrack->Clone() );
s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.GetLink();
draggedtrack->SetStatus( 0 );
draggedtrack->ClearFlags();
}
s_LastPos = PosInit;
m_canvas->SetMouseCapture( Show_MoveNode, Abort_MoveTrack );
GetBoard()->SetHighLightNet( aTrack->GetNetCode() );
GetBoard()->HighLightON();
GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
UndrawAndMarkSegmentsToDrag( m_canvas, aDC );
}
void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC )
{
TRACK* TrackToStartPoint = NULL;
TRACK* TrackToEndPoint = NULL;
bool error = false;
if( !track )
return;
// TODO: Use cleanup functions to merge collinear segments if track
// is connected to a collinear segment.
s_StartSegmentPresent = s_EndSegmentPresent = true;
if( ( track->start == NULL ) || ( track->start->Type() == PCB_TRACE_T ) )
TrackToStartPoint = track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START, true, false );
// Test if more than one segment is connected to this point
if( TrackToStartPoint )
{
TrackToStartPoint->SetState( BUSY, true );
if( ( TrackToStartPoint->Type() == PCB_VIA_T )
|| track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START, true, false ) )
error = true;
TrackToStartPoint->SetState( BUSY, false );
}
if( ( track->end == NULL ) || ( track->end->Type() == PCB_TRACE_T ) )
TrackToEndPoint = track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END, true, false );
// Test if more than one segment is connected to this point
if( TrackToEndPoint )
{
TrackToEndPoint->SetState( BUSY, true );
if( (TrackToEndPoint->Type() == PCB_VIA_T)
|| track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END, true, false ) )
error = true;
TrackToEndPoint->SetState( BUSY, false );
}
if( error )
{
DisplayError( this,
_( "Unable to drag this segment: too many segments connected" ) );
return;
}
if( !TrackToStartPoint || ( TrackToStartPoint->Type() != PCB_TRACE_T ) )
s_StartSegmentPresent = false;
if( !TrackToEndPoint || ( TrackToEndPoint->Type() != PCB_TRACE_T ) )
s_EndSegmentPresent = false;
// Change high light net: the new one will be highlighted
GetBoard()->PushHighLight();
if( GetBoard()->IsHighLightNetON() )
HighLight( DC );
EraseDragList();
track->SetFlags( IS_DRAGGED );
if( TrackToStartPoint )
{
STATUS_FLAGS flag = STARTPOINT;
if( track->GetStart() != TrackToStartPoint->GetStart() )
flag = ENDPOINT;
AddSegmentToDragList( flag, TrackToStartPoint );
track->SetFlags( STARTPOINT );
}
if( TrackToEndPoint )
{
STATUS_FLAGS flag = STARTPOINT;
if( track->GetEnd() != TrackToEndPoint->GetStart() )
flag = ENDPOINT;
AddSegmentToDragList( flag, TrackToEndPoint );
track->SetFlags( ENDPOINT );
}
AddSegmentToDragList( track->GetFlags(), track );
UndrawAndMarkSegmentsToDrag( m_canvas, DC );
PosInit = GetCrossHairPosition();
s_LastPos = GetCrossHairPosition();
m_canvas->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack );
GetBoard()->SetHighLightNet( track->GetNetCode() );
GetBoard()->HighLightON();
GetBoard()->DrawHighLight( m_canvas, DC, GetBoard()->GetHighLightNetCode() );
// Prepare the Undo command
ITEM_PICKER picker( NULL, UR_CHANGED );
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* draggedtrack = g_DragSegmentList[ii].m_Track;
picker.SetItem( draggedtrack);
picker.SetLink ( draggedtrack->Clone() );
s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.GetLink();
draggedtrack->SetStatus( 0 );
draggedtrack->ClearFlags();
}
if( !InitialiseDragParameters() )
{
DisplayError( this, _( "Unable to drag this segment: two collinear segments" ) );
m_canvas->SetMouseCaptureCallback( NULL );
Abort_MoveTrack( m_canvas, DC );
return;
}
}
// Place a dragged (or moved) track segment or via // Place a dragged (or moved) track segment or via
bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
{ {

View File

@ -115,35 +115,24 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater,
wxPoint areaPosition = GetCrossHairPosition(); wxPoint areaPosition = GetCrossHairPosition();
EDA_RECT bbox = board->GetBoundingBox(); EDA_RECT bbox = board->GetBoundingBox();
if( !IsGalCanvasActive() )
{
// In legacy mode place area to the left side of the board.
// if the board is empty, the bbox position is (0,0)
areaPosition.x = bbox.GetEnd().x + Millimeter2iu( 10 );
areaPosition.y = bbox.GetOrigin().y;
}
toolManager->RunAction( PCB_ACTIONS::selectionClear, true ); toolManager->RunAction( PCB_ACTIONS::selectionClear, true );
SpreadFootprints( &newFootprints, false, false, areaPosition, false ); SpreadFootprints( &newFootprints, false, false, areaPosition, false );
if( IsGalCanvasActive() ) // Start drag command for new modules
if( !newFootprints.empty() )
{ {
// Start drag command for new modules for( MODULE* footprint : newFootprints )
if( !newFootprints.empty() ) toolManager->RunAction( PCB_ACTIONS::selectItem, true, footprint );
{
for( MODULE* footprint : newFootprints )
toolManager->RunAction( PCB_ACTIONS::selectItem, true, footprint );
*aRunDragCommand = true; *aRunDragCommand = true;
// Now fix a reference point to move the footprints. // Now fix a reference point to move the footprints.
// We use the first footprint in list as reference point // We use the first footprint in list as reference point
// The graphic cursor will be on this fp when moving the footprints. // The graphic cursor will be on this fp when moving the footprints.
SELECTION_TOOL* selTool = toolManager->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = toolManager->GetTool<SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); SELECTION& selection = selTool->GetSelection();
selection.SetReferencePoint( newFootprints[0]->GetPosition() ); selection.SetReferencePoint( newFootprints[0]->GetPosition() );
}
} }
GetCanvas()->Refresh(); GetCanvas()->Refresh();

View File

@ -185,154 +185,3 @@ void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery )
OnModify(); OnModify();
} }
/*
* PCB_EDIT_FRAME::Function PushPadProperties
* Function to change pad caracteristics for the given footprint or all identical footprints
* Options are set by the opened dialog.
*/
void PCB_EDIT_FRAME::PushPadProperties( D_PAD* aPad )
{
if( !aPad )
return;
MODULE* module = aPad->GetParent();
if( !module )
return;
SetMsgPanel( module );
DIALOG_PUSH_PAD_PROPERTIES dlg( this );
int retCode = dlg.ShowModal();
if( retCode == wxID_CANCEL )
return;
bool edit_Same_Modules = ( retCode == 1 );
DoPushPadProperties( aPad, edit_Same_Modules,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Shape_Filter,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Orient_Filter,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Layer_Filter,
true );
}
/*
* FOOTPRINT_EDIT_FRAME::Function PushPadProperties
* Function to change pad caracteristics for the footprint.
* Options are set by the opened dialog.
*/
void FOOTPRINT_EDIT_FRAME::PushPadProperties( D_PAD* aPad )
{
if( !aPad )
return;
MODULE* module = aPad->GetParent();
if( !module )
return;
SetMsgPanel( module );
DIALOG_PUSH_PAD_PROPERTIES dlg( this );
int retCode = dlg.ShowModal();
if( retCode == wxID_CANCEL )
return;
bool edit_Same_Modules = ( retCode == 1 );
DoPushPadProperties( aPad, edit_Same_Modules,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Shape_Filter,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Orient_Filter,
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Layer_Filter,
false );
}
/*
* Function DoPushPadProperties
* Function to change pad properties for the given footprint or all identical footprints
* aPad is the pattern. The given footprint is the parent of this pad
* aSameFootprints: if true, make changes on all identical footprints
* aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
* aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
* aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
* aSaveForUndo: if true: create an entry in the Undo/Redo list
* (usually: true in Schematic editor, false in Module editor)
*/
void PCB_BASE_FRAME::DoPushPadProperties( D_PAD* aPad, bool aSameFootprints,
bool aPadShapeFilter,
bool aPadOrientFilter,
bool aPadLayerFilter,
bool aSaveForUndo )
{
MODULE* Module_Ref = aPad->GetParent();
double pad_orient = aPad->GetOrientation() - Module_Ref->GetOrientation();
// Prepare an undo list:
if( aSaveForUndo )
{
PICKED_ITEMS_LIST itemsList;
if( aSameFootprints )
{
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
if( module->GetFPID() == Module_Ref->GetFPID() )
{
ITEM_PICKER itemWrapper( module, UR_CHANGED );
itemsList.PushItem( itemWrapper );
}
}
}
else
{
ITEM_PICKER itemWrapper( Module_Ref, UR_CHANGED );
itemsList.PushItem( itemWrapper );
}
SaveCopyInUndoList( itemsList, UR_CHANGED );
}
// Update the current module and same others modules if requested.
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
if( !aSameFootprints && (module != Module_Ref) )
continue;
if( module->GetFPID() != Module_Ref->GetFPID() )
continue;
// Erase module on screen
module->SetFlags( DO_NOT_DRAW );
m_canvas->RefreshDrawingRect( module->GetBoundingBox() );
module->ClearFlags( DO_NOT_DRAW );
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) )
continue;
double currpad_orient = pad->GetOrientation() - module->GetOrientation();
if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
continue;
if( aPadLayerFilter && ( pad->GetLayerSet() != aPad->GetLayerSet() ) )
continue;
// Do not copy pad to itself, it can create issues with custom pad primitives.
if( pad == aPad )
continue;
pad->ImportSettingsFromMaster( *aPad );
}
module->CalculateBoundingBox();
m_canvas->RefreshDrawingRect( module->GetBoundingBox() );
}
OnModify();
}

View File

@ -89,7 +89,6 @@ BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid ) EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom ) EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
// Switching canvases // Switching canvases
EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas ) EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas ) EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
@ -225,10 +224,7 @@ void PCB_BASE_FRAME::AddModuleToBoard( MODULE* module )
module->SetFlags( IS_NEW ); module->SetFlags( IS_NEW );
if( IsGalCanvasActive() ) module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
else
module->SetPosition( GetCrossHairPosition() );
module->SetTimeStamp( GetNewTimeStamp() ); module->SetTimeStamp( GetNewTimeStamp() );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
@ -601,10 +597,6 @@ void PCB_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{ {
switch( aEvent.GetId() ) switch( aEvent.GetId() )
{ {
case ID_MENU_CANVAS_LEGACY:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
break;
case ID_MENU_CANVAS_CAIRO: case ID_MENU_CANVAS_CAIRO:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break; break;
@ -624,7 +616,7 @@ void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
int current = 0; // display Auto if no match found int current = 0; // display Auto if no match found
// check for a match within 1% // check for a match within 1%
double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom(); double zoom = GetGalCanvas()->GetLegacyZoom();
for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ ) for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
{ {
@ -676,16 +668,9 @@ void PCB_BASE_FRAME::UpdateMsgPanel()
MSG_PANEL_ITEMS items; MSG_PANEL_ITEMS items;
if( item ) if( item )
{
item->GetMsgPanelInfo( m_UserUnits, items ); item->GetMsgPanelInfo( m_UserUnits, items );
}
else // show general information about the board else // show general information about the board
{ GetGalCanvas()->GetMsgPanelInfo( m_UserUnits, items );
if( IsGalCanvasActive() )
GetGalCanvas()->GetMsgPanelInfo( m_UserUnits, items );
else
m_Pcb->GetMsgPanelInfo( m_UserUnits, items );
}
SetMsgPanel( items ); SetMsgPanel( items );
} }
@ -929,11 +914,8 @@ void PCB_BASE_FRAME::OnModify()
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->SetSave(); GetScreen()->SetSave();
if( IsGalCanvasActive() ) UpdateStatusBar();
{ UpdateMsgPanel();
UpdateStatusBar();
UpdateMsgPanel();
}
} }
@ -1060,12 +1042,10 @@ void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas(); EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
if( IsGalCanvasActive() && gal_canvas ) canvasType = gal_canvas->GetBackend();
canvasType = gal_canvas->GetBackend();
struct { int menuId; int galType; } menuList[] = struct { int menuId; int galType; } menuList[] =
{ {
{ ID_MENU_CANVAS_LEGACY, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE },
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL }, { ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO }, { ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
}; };

View File

@ -183,7 +183,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame ) EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
// Switching canvases // Switching canvases
EVT_MENU( ID_MENU_CANVAS_LEGACY, PCB_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::OnSwitchCanvas ) EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::OnSwitchCanvas )
@ -240,7 +239,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
// popup menus // popup menus
EVT_MENU( ID_POPUP_PCB_DELETE_TRACKSEG, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
PCB_EDIT_FRAME::Process_Special_Functions ) PCB_EDIT_FRAME::Process_Special_Functions )
@ -365,7 +363,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_canvasType = LoadCanvasTypeSetting(); m_canvasType = LoadCanvasTypeSetting();
// Nudge user to switch to OpenGL if they are on legacy or Cairo // Nudge user to switch to OpenGL if they are on Cairo
if( m_firstRunDialogSetting < 1 ) if( m_firstRunDialogSetting < 1 )
{ {
if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
@ -374,11 +372,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
"and faster experience. This option is turned off by " "and faster experience. This option is turned off by "
"default since it is not compatible with all computers.\n\n" "default since it is not compatible with all computers.\n\n"
"Would you like to try enabling graphics acceleration?\n\n" "Would you like to try enabling graphics acceleration?\n\n"
"If you'd like to choose later, select Modern Toolset " "If you'd like to choose later, select Accelerated Graphics "
"(Accelerated) in the Preferences menu." ); "in the Preferences menu." );
wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
wxYES_NO );
dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) ); dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
@ -400,8 +397,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
} }
else else
{ {
// If they were on legacy, or they've been coerced into GAL // If they were on legacy, switch to Cairo
// due to unavailable legacy (GTK3), switch to Cairo
wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
GetEventHandler()->ProcessEvent( evt ); GetEventHandler()->ProcessEvent( evt );
} }
@ -411,13 +407,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SaveSettings( config() ); SaveSettings( config() );
} }
if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) GetGalCanvas()->SwitchBackend( m_canvasType );
{ UseGalCanvas( true );
if( GetGalCanvas()->SwitchBackend( m_canvasType ) )
UseGalCanvas( true );
}
enableGALSpecificMenus();
// disable Export STEP item if kicad2step does not exist // disable Export STEP item if kicad2step does not exist
wxString strK2S = Pgm().GetExecutablePath(); wxString strK2S = Pgm().GetExecutablePath();
@ -453,13 +444,10 @@ void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard )
{ {
PCB_BASE_EDIT_FRAME::SetBoard( aBoard ); PCB_BASE_EDIT_FRAME::SetBoard( aBoard );
if( IsGalCanvasActive() ) aBoard->GetConnectivity()->Build( aBoard );
{
aBoard->GetConnectivity()->Build( aBoard );
// reload the worksheet // reload the worksheet
SetPageSettings( aBoard->GetPageSettings() ); SetPageSettings( aBoard->GetPageSettings() );
}
} }
@ -473,30 +461,27 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{ {
PCB_BASE_FRAME::SetPageSettings( aPageSettings ); PCB_BASE_FRAME::SetPageSettings( aPageSettings );
if( IsGalCanvasActive() ) PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
// Prepare worksheet template
KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
&m_Pcb->GetTitleBlock() );
worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
BASE_SCREEN* screen = GetScreen();
if( screen != NULL )
{ {
PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() ); worksheet->SetSheetNumber( screen->m_ScreenNumber );
worksheet->SetSheetCount( screen->m_NumberOfScreens );
// Prepare worksheet template
KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
&m_Pcb->GetTitleBlock() );
worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
BASE_SCREEN* screen = GetScreen();
if( screen != NULL )
{
worksheet->SetSheetNumber( screen->m_ScreenNumber );
worksheet->SetSheetCount( screen->m_NumberOfScreens );
}
if( auto board = GetBoard() )
worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
// PCB_DRAW_PANEL_GAL takes ownership of the worksheet
drawPanel->SetWorksheet( worksheet );
} }
if( auto board = GetBoard() )
worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
// PCB_DRAW_PANEL_GAL takes ownership of the worksheet
drawPanel->SetWorksheet( worksheet );
} }
@ -584,16 +569,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
if( IsGalCanvasActive() ) // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
{ // when closing this frame if a footprint was selected, and the footprint editor called
// On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes // to edit this footprint, and when closing pcbnew if this footprint is still selected
// when closing this frame if a footprint was selected, and the footprint editor called // See https://bugs.launchpad.net/kicad/+bug/1655858
// to edit this footprint, and when closing pcbnew if this footprint is still selected // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
// See https://bugs.launchpad.net/kicad/+bug/1655858 // avoid the crash (JPC)
// I think this is certainly a OpenGL event fired after frame deletion, so this workaround GetGalCanvas()->SetEvtHandlerEnabled( false );
// avoid the crash (JPC)
GetGalCanvas()->SetEvtHandlerEnabled( false );
}
GetGalCanvas()->StopDrawing(); GetGalCanvas()->StopDrawing();
@ -645,67 +627,20 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable ) void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
{ {
if( !aEnable )
Compile_Ratsnest( NULL, true );
PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable ); PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
COLORS_DESIGN_SETTINGS& cds = Settings().Colors(); COLORS_DESIGN_SETTINGS& cds = Settings().Colors();
if( aEnable ) cds.SetLegacyMode( false );
{ GetGalCanvas()->GetGAL()->SetGridColor( cds.GetLayerColor( LAYER_GRID ) );
cds.SetLegacyMode( false ); auto view = GetGalCanvas()->GetView();
GetGalCanvas()->GetGAL()->SetGridColor( cds.GetLayerColor( LAYER_GRID ) ); view->GetPainter()->GetSettings()->ImportLegacyColors( &cds );
auto view = GetGalCanvas()->GetView(); GetGalCanvas()->Refresh();
view->GetPainter()->GetSettings()->ImportLegacyColors( &cds );
GetGalCanvas()->Refresh();
}
enableGALSpecificMenus();
// Force colors to be legacy-compatible in case they were changed in GAL
if( !aEnable )
{
cds.SetLegacyMode( true );
Refresh();
}
// Re-create the layer manager to allow arbitrary colors when GAL is enabled // Re-create the layer manager to allow arbitrary colors when GAL is enabled
UpdateUserInterface(); UpdateUserInterface();
} }
void PCB_EDIT_FRAME::enableGALSpecificMenus()
{
// some menus are active only in GAL mode and do nothing in legacy mode.
// So enable or disable them, depending on the display mode
ReCreateMenuBar();
if( GetMenuBar() )
{
// Enable / disable some menus which are usable only on GAL
pcbnew_ids id_list[] =
{
ID_MENU_INTERACTIVE_ROUTER_SETTINGS,
ID_DIFF_PAIR_BUTT,
ID_TUNE_SINGLE_TRACK_LEN_BUTT,
ID_TUNE_DIFF_PAIR_LEN_BUTT,
ID_TUNE_DIFF_PAIR_SKEW_BUTT,
ID_MENU_DIFF_PAIR_DIMENSIONS,
ID_MENU_PCB_FLIP_VIEW
};
bool enable = IsGalCanvasActive();
for( auto& id : id_list )
{
if( GetMenuBar()->FindItem( id ) )
GetMenuBar()->FindItem( id )->Enable( enable );
}
}
}
void PCB_EDIT_FRAME::ShowBoardSetupDialog( wxCommandEvent& event ) void PCB_EDIT_FRAME::ShowBoardSetupDialog( wxCommandEvent& event )
{ {
DoShowBoardSetupDialog(); DoShowBoardSetupDialog();
@ -727,13 +662,10 @@ void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
UpdateUserInterface(); UpdateUserInterface();
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
if( IsGalCanvasActive() ) for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{ GetGalCanvas()->GetView()->Update( module );
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
GetGalCanvas()->GetView()->Update( module );
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
}
//this event causes the routing tool to reload its design rules information //this event causes the routing tool to reload its design rules information
TOOL_EVENT toolEvent( TC_COMMAND, TA_MODEL_CHANGE, AS_ACTIVE ); TOOL_EVENT toolEvent( TC_COMMAND, TA_MODEL_CHANGE, AS_ACTIVE );
@ -804,10 +736,7 @@ void PCB_EDIT_FRAME::SetGridColor( COLOR4D aColor )
Settings().Colors().SetItemColor( LAYER_GRID, aColor ); Settings().Colors().SetItemColor( LAYER_GRID, aColor );
if( IsGalCanvasActive() ) GetGalCanvas()->GetGAL()->SetGridColor( aColor );
{
GetGalCanvas()->GetGAL()->SetGridColor( aColor );
}
} }
@ -838,14 +767,11 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
syncLayerWidgetLayer(); syncLayerWidgetLayer();
if( IsGalCanvasActive() ) m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
{ GetGalCanvas()->SetFocus(); // allow capture of hotkeys
m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
GetGalCanvas()->SetHighContrastLayer( aLayer ); GetGalCanvas()->SetHighContrastLayer( aLayer );
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
}
} }
@ -1072,7 +998,7 @@ void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent ) void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{ {
// switches currently used canvas (default / Cairo / OpenGL). // switches currently used canvas (Cairo / OpenGL).
PCB_BASE_FRAME::OnSwitchCanvas( aEvent ); PCB_BASE_FRAME::OnSwitchCanvas( aEvent );
// The base class method *does not reinit* the layers manager. // The base class method *does not reinit* the layers manager.
@ -1321,13 +1247,7 @@ void PCB_EDIT_FRAME::InstallFootprintPropertiesDialog( MODULE* Module, wxDC* DC
if( Module == NULL ) if( Module == NULL )
return; return;
#ifdef __WXMAC__ DIALOG_FOOTPRINT_BOARD_EDITOR* dlg = new DIALOG_FOOTPRINT_BOARD_EDITOR( this, Module );
// avoid Avoid "writes" in the dialog, creates errors with WxOverlay and NSView & Modal
// Raising an Exception - Fixes #764678
DC = NULL;
#endif
DIALOG_FOOTPRINT_BOARD_EDITOR* dlg = new DIALOG_FOOTPRINT_BOARD_EDITOR( this, Module, DC );
int retvalue = dlg->ShowModal(); int retvalue = dlg->ShowModal();
/* retvalue = /* retvalue =
@ -1342,10 +1262,8 @@ void PCB_EDIT_FRAME::InstallFootprintPropertiesDialog( MODULE* Module, wxDC* DC
if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_OK ) if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_OK )
{ {
#ifdef __WXMAC__
// If something edited, push a refresh request // If something edited, push a refresh request
m_canvas->Refresh(); m_canvas->Refresh();
#endif
} }
else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_BOARD_FOOTPRINT ) else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_BOARD_FOOTPRINT )
{ {

View File

@ -100,29 +100,13 @@ protected:
// The Tool Framework initalization // The Tool Framework initalization
void setupTools(); void setupTools();
// we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu );
void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu );
void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
void createPopUpBlockMenu( wxMenu* menu );
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
wxString createBackupFile( const wxString& aFileName ); wxString createBackupFile( const wxString& aFileName );
/**
* an helper function to enable some menus only active when the display
* is switched to GAL mode and which do nothing in legacy mode
*/
void enableGALSpecificMenus();
/** /**
* switches currently used canvas (default / Cairo / OpenGL). * switches currently used canvas (default / Cairo / OpenGL).
* It also reinit the layers manager that slightly changes with canvases * It also reinit the layers manager that slightly changes with canvases
*/ */
virtual void OnSwitchCanvas( wxCommandEvent& aEvent ) override; void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
/** /**
@ -874,9 +858,8 @@ public:
* @return true if Ok. * @return true if Ok.
*/ */
bool ExportVRML_File( const wxString & aFullFileName, double aMMtoWRMLunit, bool ExportVRML_File( const wxString & aFullFileName, double aMMtoWRMLunit,
bool aExport3DFiles, bool aUseRelativePaths, bool aExport3DFiles, bool aUseRelativePaths, bool aUsePlainPCB,
bool aUsePlainPCB, const wxString & a3D_Subdir, const wxString & a3D_Subdir, double aXRef, double aYRef );
double aXRef, double aYRef );
/** /**
* Function OnExportIDF3 * Function OnExportIDF3
@ -997,15 +980,6 @@ public:
*/ */
void StartMoveModule( MODULE* aModule, wxDC* aDC, bool aDragConnectedTracks ); void StartMoveModule( MODULE* aModule, wxDC* aDC, bool aDragConnectedTracks );
/**
* Function PushPadProperties
* Function to change pad caracteristics for the given footprint
* or all footprints which look like the given footprint
* Options are set by the opened dialog.
* @param aPad is the pattern. The given footprint is the parent of this pad
*/
void PushPadProperties( D_PAD* aPad );
/** /**
* Function Delete Module * Function Delete Module
* Remove a footprint from m_Modules linked list and put it in undelete buffer * Remove a footprint from m_Modules linked list and put it in undelete buffer
@ -1159,26 +1133,8 @@ public:
void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ); void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
/**
* Function StartMoveOneNodeOrSegment
* initializes the parameters to move one via or/and a terminal point of a track segment
* The terminal point of other connected segments (if any) are moved too.
*/
void StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aCommand );
bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ); bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
/**
* @todo This function is broken, because it merge segments having different
* widths or without any connectivity test.
* 2 collinear segments can be merged only if no other segment or via is
* connected to the common point and if they have the same width. See
* cleanup.cpp for merge functions and consider MarkTrace() to locate segments
* that can be merged
*/
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) override; void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) override;
/** /**
@ -1364,7 +1320,6 @@ public:
// Target handling // Target handling
PCB_TARGET* CreateTarget( wxDC* DC ); PCB_TARGET* CreateTarget( wxDC* DC );
void DeleteTarget( PCB_TARGET* aTarget, wxDC* DC ); void DeleteTarget( PCB_TARGET* aTarget, wxDC* DC );
void BeginMoveTarget( PCB_TARGET* aTarget, wxDC* DC );
void PlaceTarget( PCB_TARGET* aTarget, wxDC* DC ); void PlaceTarget( PCB_TARGET* aTarget, wxDC* DC );
void ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC ); void ShowTargetOptionsDialog( PCB_TARGET* aTarget, wxDC* DC );
@ -1372,7 +1327,6 @@ public:
DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC ); DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC );
void End_Edge( DRAWSEGMENT* Segment, wxDC* DC ); void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ); void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
void Delete_Drawings_All_Layer( PCB_LAYER_ID aLayer );
// Dimension handling: // Dimension handling:
void ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* aDC ); void ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* aDC );

View File

@ -133,12 +133,6 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwn
} }
bool PCB_LAYER_WIDGET::AreArbitraryColorsAllowed()
{
return myframe->IsGalCanvasActive();
}
COLOR4D PCB_LAYER_WIDGET::getBackgroundLayerColor() COLOR4D PCB_LAYER_WIDGET::getBackgroundLayerColor()
{ {
return myframe->Settings().Colors().GetLayerColor( LAYER_PCB_BACKGROUND ); return myframe->Settings().Colors().GetLayerColor( LAYER_PCB_BACKGROUND );
@ -580,24 +574,12 @@ void PCB_LAYER_WIDGET::ReFill()
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
{ {
// Avoid setting the alpha channel, when we are in legacy mode,
// because in legacy mode the alpha channel is not used, but changing it
// destroys the GAL color setup
if( !myframe->IsGalCanvasActive() )
{
COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( aLayer );
aColor.a = oldColor.a;
}
myframe->Settings().Colors().SetLayerColor( aLayer, aColor ); myframe->Settings().Colors().SetLayerColor( aLayer, aColor );
if( myframe->IsGalCanvasActive() ) KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
{ view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() );
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView(); view->UpdateLayerColor( aLayer );
view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() ); view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
view->UpdateLayerColor( aLayer );
view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
}
myframe->ReCreateHToolbar(); myframe->ReCreateHToolbar();
@ -685,22 +667,19 @@ void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas && myframe->IsGalCanvasActive() ) if( aId == LAYER_GRID )
{ galCanvas->GetGAL()->SetGridColor( aColor );
if( aId == LAYER_GRID )
galCanvas->GetGAL()->SetGridColor( aColor );
KIGFX::VIEW* view = galCanvas->GetView(); KIGFX::VIEW* view = galCanvas->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() ); view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
view->UpdateLayerColor( aId ); view->UpdateLayerColor( aId );
// plated-through-holes don't have their own color; they use the background color // plated-through-holes don't have their own color; they use the background color
if( aId == LAYER_PCB_BACKGROUND ) if( aId == LAYER_PCB_BACKGROUND )
view->UpdateLayerColor( LAYER_PADS_PLATEDHOLES ); view->UpdateLayerColor( LAYER_PADS_PLATEDHOLES );
galCanvas->ForceRefresh(); galCanvas->ForceRefresh();
}
myframe->ReCreateHToolbar(); myframe->ReCreateHToolbar();
@ -725,25 +704,21 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas && myframe->IsGalCanvasActive() ) if( aId == LAYER_GRID )
{ {
if( aId == LAYER_GRID ) galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
{ galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
else if( aId == LAYER_RATSNEST )
{
// don't touch the layers. ratsnest is enabled on per-item basis.
galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
galCanvas->GetView()->SetLayerVisible( aId, true );
}
else
galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
galCanvas->Refresh();
} }
else if( aId == LAYER_RATSNEST )
{
// don't touch the layers. ratsnest is enabled on per-item basis.
galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
galCanvas->GetView()->SetLayerVisible( aId, true );
}
else
galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
galCanvas->Refresh();
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();
} }

View File

@ -137,8 +137,6 @@ protected:
ID_LAST_VALUE ID_LAST_VALUE
}; };
virtual bool AreArbitraryColorsAllowed() override;
virtual COLOR4D getBackgroundLayerColor() override; virtual COLOR4D getBackgroundLayerColor() override;
/** /**

View File

@ -57,62 +57,17 @@ enum pcbnew_ids
ID_MENU_PCB_FLIP_VIEW, ID_MENU_PCB_FLIP_VIEW,
ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_START_RANGE,
ID_POPUP_PCB_EDIT_MODULE_PRMS,
ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT,
ID_POPUP_PCB_UPDATE_FOOTPRINTS,
ID_POPUP_PCB_EXCHANGE_FOOTPRINTS,
ID_POPUP_PCB_EDIT_PAD,
ID_POPUP_PCB_MOVE_PAD_REQUEST,
ID_POPUP_PCB_DRAG_PAD_REQUEST,
ID_POPUP_PCB_DUPLICATE_ITEM,
ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT,
ID_POPUP_PCB_MOVE_EXACT, ID_POPUP_PCB_MOVE_EXACT,
ID_POPUP_PCB_CREATE_ARRAY, ID_POPUP_PCB_CREATE_ARRAY,
ID_POPUP_PCB_DELETE_DRAWING_LAYER,
ID_POPUP_PCB_END_LINE, ID_POPUP_PCB_END_LINE,
ID_POPUP_PCB_BEGIN_TRACK,
ID_POPUP_PCB_EDIT_TRACK,
ID_POPUP_PCB_DELETE_TRACK,
ID_POPUP_PCB_DELETE_TRACKNET,
ID_POPUP_PCB_DELETE_TRACK_MNU,
ID_POPUP_PCB_MOVE_ZONE_CORNER,
ID_POPUP_PCB_ADD_ZONE_CORNER,
ID_POPUP_PCB_DELETE_ZONE_CORNER,
ID_POPUP_PCB_PLACE_ZONE_CORNER,
ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER,
ID_POPUP_PCB_EDIT_ZONE_PARAMS,
ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
ID_POPUP_PCB_FILL_ALL_ZONES, ID_POPUP_PCB_FILL_ALL_ZONES,
ID_POPUP_PCB_FILL_ZONE, ID_POPUP_PCB_FILL_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
ID_POPUP_PCB_ZONE_DUPLICATE,
ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
ID_POPUP_PCB_DRAG_ZONE_OUTLINE_SEGMENT,
ID_POPUP_PCB_PLACE_DRAGGED_ZONE_OUTLINE_SEGMENT,
ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES,
ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE,
ID_POPUP_PCB_DELETE_MARKER,
ID_POPUP_PCB_DELETE_DIMENSION,
ID_POPUP_PCB_MOVE_TEXT_DIMENSION_REQUEST,
ID_POPUP_PCB_MOVE_PCB_TARGET_REQUEST,
ID_POPUP_PCB_DELETE_PCB_TARGET,
ID_POPUP_PCB_EDIT_PCB_TARGET,
ID_POPUP_PCB_STOP_CURRENT_DRAWING,
ID_POPUP_PCB_EDIT_DIMENSION,
ID_POPUP_PCB_END_TRACK,
ID_POPUP_PCB_PLACE_THROUGH_VIA, ID_POPUP_PCB_PLACE_THROUGH_VIA,
ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA, ID_POPUP_PCB_SELECT_CU_LAYER_AND_PLACE_THROUGH_VIA,
ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA, ID_POPUP_PCB_PLACE_BLIND_BURIED_VIA,
@ -120,39 +75,8 @@ enum pcbnew_ids
ID_POPUP_PCB_PLACE_MICROVIA, ID_POPUP_PCB_PLACE_MICROVIA,
ID_POPUP_PCB_SWITCH_TRACK_POSTURE, ID_POPUP_PCB_SWITCH_TRACK_POSTURE,
ID_POPUP_PCB_APPLY_PAD_SETTINGS,
ID_POPUP_PCB_COPY_PAD_SETTINGS,
ID_POPUP_PCB_EDIT_TRACKSEG,
ID_POPUP_PCB_EDIT_TRACK_MNU,
ID_POPUP_PCB_EDIT_NET,
ID_POPUP_PCB_SELECT_LAYER,
ID_POPUP_PCB_SELECT_CU_LAYER,
ID_POPUP_PCB_SELECT_NO_CU_LAYER,
ID_POPUP_PCB_SELECT_LAYER_PAIR,
ID_POPUP_PCB_DELETE_EDGE,
ID_POPUP_PCB_MOVE_EDGE,
ID_POPUP_PCB_PLACE_EDGE,
ID_POPUP_PCB_END_EDGE,
ID_POPUP_PCB_LOCK_ON_TRACKSEG,
ID_POPUP_PCB_LOCK_OFF_TRACKSEG,
ID_POPUP_PCB_LOCK_ON_TRACK,
ID_POPUP_PCB_LOCK_OFF_TRACK,
ID_POPUP_PCB_LOCK_ON_NET,
ID_POPUP_PCB_LOCK_OFF_NET,
ID_POPUP_PCB_SETFLAGS_TRACK_MNU,
ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS,
ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE,
ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC,
ID_POPUP_PCB_MOVE_TRACK_NODE,
ID_POPUP_PCB_BREAK_TRACK,
ID_POPUP_PCB_PLACE_MOVED_TRACK_NODE,
ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE,
ID_POPUP_PCB_DRAG_TRACK_SEGMENT,
ID_POPUP_PCB_MOVE_TRACK_SEGMENT,
ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST,
ID_POPUP_PCB_GETINFO_MARKER,
ID_POPUP_PCB_END_RANGE, ID_POPUP_PCB_END_RANGE,
// Tracks and vias sizes general options // Tracks and vias sizes general options
@ -295,9 +219,6 @@ enum pcbnew_ids
ID_MODEDIT_MEASUREMENT_TOOL, ID_MODEDIT_MEASUREMENT_TOOL,
// ID used in module editor: // ID used in module editor:
ID_POPUP_MODEDIT_GLOBAL_EDIT_EDGE,
ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE,
ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
ID_MODEDIT_CHECK, ID_MODEDIT_CHECK,
ID_MODEDIT_CREATE_NEW_LIB, ID_MODEDIT_CREATE_NEW_LIB,
ID_MODEDIT_ADD_LIBRARY, ID_MODEDIT_ADD_LIBRARY,

View File

@ -380,16 +380,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
GetScreen()->PushCommandToUndoList( oldBuffer ); GetScreen()->PushCommandToUndoList( oldBuffer );
if( IsGalCanvasActive() ) UseGalCanvas( GetGalCanvas() );
{
UseGalCanvas( GetGalCanvas() );
}
else
{
UpdateUserInterface();
GetScreen()->SetModify();
Refresh();
}
} }

View File

@ -155,18 +155,11 @@ void Refresh()
auto board = s_PcbEditFrame->GetBoard(); auto board = s_PcbEditFrame->GetBoard();
board->BuildConnectivity(); board->BuildConnectivity();
if( s_PcbEditFrame->IsGalCanvasActive() ) auto gal_canvas = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
{
auto gal_canvas = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
// Reinit everything: this is the easy way to do that // Reinit everything: this is the easy way to do that
s_PcbEditFrame->UseGalCanvas( true ); s_PcbEditFrame->UseGalCanvas( true );
gal_canvas->Refresh(); gal_canvas->Refresh();
}
else
// first argument is erase background, second is a wxRect that
// defines a reftresh area (all canvas if null)
s_PcbEditFrame->GetCanvas()->Refresh( true, NULL );
} }
} }

View File

@ -216,18 +216,6 @@ PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC )
} }
void PCB_EDIT_FRAME::BeginMoveTarget( PCB_TARGET* aTarget, wxDC* DC )
{
if( aTarget == NULL )
return;
s_TargetCopy = *aTarget;
aTarget->SetFlags( IS_MOVED );
m_canvas->SetMouseCapture( ShowTargetShapeWhileMovingMouse, AbortMoveAndEditTarget );
SetCurItem( aTarget );
}
void PCB_EDIT_FRAME::PlaceTarget( PCB_TARGET* aTarget, wxDC* DC ) void PCB_EDIT_FRAME::PlaceTarget( PCB_TARGET* aTarget, wxDC* DC )
{ {
if( aTarget == NULL ) if( aTarget == NULL )

View File

@ -924,10 +924,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii ); ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
edge_zone->Draw( m_canvas, DC, GR_XOR ); edge_zone->Draw( m_canvas, DC, GR_XOR );
if( IsGalCanvasActive() ) GetGalCanvas()->GetView()->Update( edge_zone );
{
GetGalCanvas()->GetView()->Update( edge_zone );
}
} }
zoneInfo.ExportSetting( *aZone ); zoneInfo.ExportSetting( *aZone );
@ -979,9 +976,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
GetBoard()->GetConnectivity()->RecalculateRatsnest(); GetBoard()->GetConnectivity()->RecalculateRatsnest();
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
if( !IsGalCanvasActive() )
m_canvas->Refresh();
} }

View File

@ -81,9 +81,7 @@ void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow )
{ {
m_ZoneFillsDirty = false; m_ZoneFillsDirty = false;
if( IsGalCanvasActive() && GetGalCanvas() ) GetGalCanvas()->ForceRefresh();
GetGalCanvas()->ForceRefresh();
GetCanvas()->Refresh(); GetCanvas()->Refresh();
} }
} }