Commit 84fa537b authored by Maciej Suminski's avatar Maciej Suminski

Changes in display options are handled by PCBNEW_CONTROL (GAL).

parent 2b1d6b30
......@@ -154,11 +154,6 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
bool state = event.IsChecked();
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
KICAD_T updateType = EOT;
switch( id )
{
......@@ -193,44 +188,33 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
updateType = PCB_VIA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
updateType = PCB_TRACE_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
{
DisplayOpt.ContrastModeDisplay = state;
// Apply new display options to the GAL canvas (this is faster than recaching)
settings->LoadDisplayOptions( DisplayOpt );
GetGalCanvas()->SetHighContrastLayer( GetActiveLayer() );
m_canvas->Refresh();
break;
}
......@@ -260,21 +244,4 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
break;
}
if( updateType != EOT )
{
// Apply new display options to the GAL canvas
settings->LoadDisplayOptions( DisplayOpt );
// Find items that require update
KICAD_T scanList[] = { updateType, EOT };
TYPE_COLLECTOR collector;
collector.Collect( GetBoard(), scanList );
for( int i = 0; i < collector.GetCount(); ++i )
collector[i]->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
if( IsGalCanvasActive() )
GetGalCanvas()->Refresh();
}
......@@ -157,6 +157,18 @@ TOOL_ACTION COMMON_ACTIONS::viaDisplayMode( "pcbnew.Control.viaDisplayMode",
AS_GLOBAL, 'L', // TODO temporarily, find a better hot key
"", "" );
TOOL_ACTION COMMON_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::highContrastMode( "pcbnew.Control.highContrastMode",
AS_GLOBAL, 'H',
"", "" );
......@@ -381,6 +393,29 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
return COMMON_ACTIONS::zoomFitScreen.MakeEvent();
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
return COMMON_ACTIONS::trackDisplayMode.MakeEvent();
case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
return COMMON_ACTIONS::padDisplayMode.MakeEvent();
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
return COMMON_ACTIONS::viaDisplayMode.MakeEvent();
case ID_TB_OPTIONS_SHOW_ZONES:
return COMMON_ACTIONS::zoneDisplayEnable.MakeEvent();
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
return COMMON_ACTIONS::zoneDisplayDisable.MakeEvent();
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
return COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent();
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
return COMMON_ACTIONS::highContrastMode.MakeEvent();
case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
case ID_PCB_DELETE_ITEM_BUTT:
case ID_PCB_HIGHLIGHT_BUTT:
case ID_PCB_SHOW_1_RATSNEST_BUTT:
......
......@@ -144,6 +144,9 @@ public:
static TOOL_ACTION trackDisplayMode;
static TOOL_ACTION padDisplayMode;
static TOOL_ACTION viaDisplayMode;
static TOOL_ACTION zoneDisplayEnable;
static TOOL_ACTION zoneDisplayDisable;
static TOOL_ACTION zoneDisplayOutlines;
static TOOL_ACTION highContrastMode;
static TOOL_ACTION highContrastInc;
static TOOL_ACTION highContrastDec;
......
......@@ -28,7 +28,9 @@
#include <pcbnew_id.h>
#include <wxPcbStruct.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <class_zone.h>
#include <class_draw_panel_gal.h>
#include <class_pcb_screen.h>
#include <pcbcommon.h>
......@@ -129,17 +131,20 @@ int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
// Apply new display options to the GAL canvas
DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill;
m_frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
settings->LoadDisplayOptions( DisplayOpt );
BOARD* board = getModel<BOARD>();
for( TRACK* track = board->m_Track; track; track = track->Next() )
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
{
if( track->Type() == PCB_TRACE_T )
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
......@@ -148,8 +153,23 @@ int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnTogglePadDrawMode( dummy );
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
// Apply new display options to the GAL canvas
DisplayOpt.DisplayPadFill = !DisplayOpt.DisplayPadFill;
m_frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
settings->LoadDisplayOptions( DisplayOpt );
for( MODULE* module = getModel<BOARD>()->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
pad->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
......@@ -161,20 +181,50 @@ int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
// Apply new display options to the GAL canvas
DisplayOpt.DisplayViaFill = !DisplayOpt.DisplayViaFill;
m_frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
settings->LoadDisplayOptions( DisplayOpt );
BOARD* board = getModel<BOARD>();
for( TRACK* track = board->m_Track; track; track = track->Next() )
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
{
if( track->Type() == PCB_VIA_T )
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
}
int PCBNEW_CONTROL::ZoneDisplayMode( TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
// Apply new display options to the GAL canvas
if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayEnable ) )
DisplayOpt.DisplayZonesMode = 0;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayDisable ) )
DisplayOpt.DisplayZonesMode = 1;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayOutlines ) )
DisplayOpt.DisplayZonesMode = 2;
else
assert( false );
settings->LoadDisplayOptions( DisplayOpt );
BOARD* board = getModel<BOARD>();
for( int i = 0; i < board->GetAreaCount(); ++i )
board->GetArea( i )->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_frame->GetGalCanvas()->Refresh();
setTransitions();
return 0;
......@@ -529,6 +579,9 @@ void PCBNEW_CONTROL::setTransitions()
Go( &PCBNEW_CONTROL::TrackDisplayMode, COMMON_ACTIONS::trackDisplayMode.MakeEvent() );
Go( &PCBNEW_CONTROL::PadDisplayMode, COMMON_ACTIONS::padDisplayMode.MakeEvent() );
Go( &PCBNEW_CONTROL::ViaDisplayMode, COMMON_ACTIONS::viaDisplayMode.MakeEvent() );
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayEnable.MakeEvent() );
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayDisable.MakeEvent() );
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent() );
Go( &PCBNEW_CONTROL::HighContrastMode, COMMON_ACTIONS::highContrastMode.MakeEvent() );
Go( &PCBNEW_CONTROL::HighContrastInc, COMMON_ACTIONS::highContrastInc.MakeEvent() );
Go( &PCBNEW_CONTROL::HighContrastDec, COMMON_ACTIONS::highContrastDec.MakeEvent() );
......
......@@ -56,6 +56,7 @@ public:
int TrackDisplayMode( TOOL_EVENT& aEvent );
int PadDisplayMode( TOOL_EVENT& aEvent );
int ViaDisplayMode( TOOL_EVENT& aEvent );
int ZoneDisplayMode( TOOL_EVENT& aEvent );
int HighContrastMode( TOOL_EVENT& aEvent );
int HighContrastInc( TOOL_EVENT& aEvent );
int HighContrastDec( TOOL_EVENT& aEvent );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment