PCB_EDIT_FRAME::SetHighContrastLayer() went public.
Refactored code that handled zooming events. Added PCB_RENDER_SETTINGS::Get/SetSketchMode(). PCBNEW_CONTROL reacts to hot keys changing display modes (sketch via/tracks, high contrast).
This commit is contained in:
parent
dc9298730d
commit
60e9546b62
|
@ -27,16 +27,16 @@
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_dispatcher.h>
|
#include <tool/tool_dispatcher.h>
|
||||||
|
#include <tools/common_actions.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <view/wx_view_controls.h>
|
#include <view/wx_view_controls.h>
|
||||||
|
|
||||||
#include <class_drawpanel_gal.h>
|
#include <class_drawpanel_gal.h>
|
||||||
|
#include <pcbnew_id.h>
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
using boost::optional;
|
|
||||||
|
|
||||||
///> Stores information about a mouse button state
|
///> Stores information about a mouse button state
|
||||||
struct TOOL_DISPATCHER::BUTTON_STATE
|
struct TOOL_DISPATCHER::BUTTON_STATE
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
||||||
{
|
{
|
||||||
BUTTON_STATE* st = m_buttons[aIndex];
|
BUTTON_STATE* st = m_buttons[aIndex];
|
||||||
wxEventType type = aEvent.GetEventType();
|
wxEventType type = aEvent.GetEventType();
|
||||||
optional<TOOL_EVENT> evt;
|
boost::optional<TOOL_EVENT> evt;
|
||||||
bool isClick = false;
|
bool isClick = false;
|
||||||
|
|
||||||
bool up = type == st->upEvent;
|
bool up = type == st->upEvent;
|
||||||
|
@ -205,7 +205,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
|
||||||
void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||||
{
|
{
|
||||||
bool motion = false, buttonEvents = false;
|
bool motion = false, buttonEvents = false;
|
||||||
optional<TOOL_EVENT> evt;
|
boost::optional<TOOL_EVENT> evt;
|
||||||
|
|
||||||
int type = aEvent.GetEventType();
|
int type = aEvent.GetEventType();
|
||||||
|
|
||||||
|
@ -270,7 +270,29 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_DISPATCHER::DispatchWxCommand( const wxCommandEvent& aEvent )
|
void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
// no events to dispatch currently
|
boost::optional<TOOL_EVENT> evt;
|
||||||
|
|
||||||
|
switch( aEvent.GetId() )
|
||||||
|
{
|
||||||
|
case ID_ZOOM_IN: // toolbar button "Zoom In"
|
||||||
|
evt = COMMON_ACTIONS::zoomInCenter.MakeEvent();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_ZOOM_OUT: // toolbar button "Zoom In"
|
||||||
|
evt = COMMON_ACTIONS::zoomOutCenter.MakeEvent();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
|
||||||
|
evt = COMMON_ACTIONS::zoomFitScreen.MakeEvent();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
aEvent.Skip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( evt )
|
||||||
|
m_toolMgr->ProcessEvent( *evt );
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,25 +194,22 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
|
||||||
RedrawScreen( center, true );
|
RedrawScreen( center, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( IsGalCanvasActive() )
|
|
||||||
{
|
|
||||||
// Apply computed view settings to GAL
|
|
||||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
|
||||||
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
|
|
||||||
|
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
|
||||||
double zoom = 1.0 / ( zoomFactor * GetZoom() );
|
|
||||||
|
|
||||||
VECTOR2D cursorWorld( GetCrossHairPosition() );
|
|
||||||
view->SetScale( zoom, cursorWorld );
|
|
||||||
|
|
||||||
GetGalCanvas()->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateStatusBar();
|
UpdateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_FRAME::SetNextZoom()
|
||||||
|
{
|
||||||
|
GetScreen()->SetNextZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_FRAME::SetPrevZoom()
|
||||||
|
{
|
||||||
|
GetScreen()->SetPreviousZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* add the zoom list menu the the MasterMenu.
|
/* add the zoom list menu the the MasterMenu.
|
||||||
* used in OnRightClick(wxMouseEvent& event)
|
* used in OnRightClick(wxMouseEvent& event)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
* specified tool).
|
* specified tool).
|
||||||
* @param aEvent is the wxCommandEvent to be processed.
|
* @param aEvent is the wxCommandEvent to be processed.
|
||||||
*/
|
*/
|
||||||
virtual void DispatchWxCommand( const wxCommandEvent& aEvent );
|
virtual void DispatchWxCommand( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///> Number of mouse buttons that is handled in events.
|
///> Number of mouse buttons that is handled in events.
|
||||||
|
|
|
@ -134,12 +134,6 @@ protected:
|
||||||
void createPopUpBlockMenu( wxMenu* menu );
|
void createPopUpBlockMenu( wxMenu* menu );
|
||||||
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
|
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function setHighContrastLayer
|
|
||||||
* takes care of display settings for the given layer to be displayed in high contrast mode.
|
|
||||||
*/
|
|
||||||
void setHighContrastLayer( LAYER_NUM aLayer );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function syncLayerWidgetLayer
|
* Function syncLayerWidgetLayer
|
||||||
* updates the currently layer "selection" within the PCB_LAYER_WIDGET.
|
* updates the currently layer "selection" within the PCB_LAYER_WIDGET.
|
||||||
|
@ -555,6 +549,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void OnModify();
|
virtual void OnModify();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetHighContrastLayer
|
||||||
|
* takes care of display settings for the given layer to be displayed in high contrast mode.
|
||||||
|
*/
|
||||||
|
void SetHighContrastLayer( LAYER_NUM aLayer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetTopLayer
|
* Function SetTopLayer
|
||||||
* moves the selected layer to the top, so it is displayed above all others.
|
* moves the selected layer to the top, so it is displayed above all others.
|
||||||
|
@ -572,7 +572,7 @@ public:
|
||||||
* Function GetActiveLayer
|
* Function GetActiveLayer
|
||||||
* returns the active layer
|
* returns the active layer
|
||||||
*/
|
*/
|
||||||
LAYER_NUM GetActiveLayer()
|
LAYER_NUM GetActiveLayer() const
|
||||||
{
|
{
|
||||||
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
|
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,6 +796,18 @@ public:
|
||||||
|
|
||||||
virtual void OnZoom( wxCommandEvent& event );
|
virtual void OnZoom( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetNextZoom()
|
||||||
|
* changes the zoom to the next one available.
|
||||||
|
*/
|
||||||
|
void SetNextZoom();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetPrevZoom()
|
||||||
|
* changes the zoom to the previous one available.
|
||||||
|
*/
|
||||||
|
void SetPrevZoom();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RedrawScreen
|
* Function RedrawScreen
|
||||||
* redraws the entire screen area by updating the scroll bars and mouse pointer in
|
* redraws the entire screen area by updating the scroll bars and mouse pointer in
|
||||||
|
|
|
@ -228,7 +228,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
||||||
// Apply new display options to the GAL canvas (this is faster than recaching)
|
// Apply new display options to the GAL canvas (this is faster than recaching)
|
||||||
settings->LoadDisplayOptions( DisplayOpt );
|
settings->LoadDisplayOptions( DisplayOpt );
|
||||||
|
|
||||||
setHighContrastLayer( GetActiveLayer() );
|
SetHighContrastLayer( GetActiveLayer() );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -152,7 +152,6 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
|
||||||
cmd.SetEventObject( this );
|
cmd.SetEventObject( this );
|
||||||
|
|
||||||
LAYER_NUM ll;
|
LAYER_NUM ll;
|
||||||
unsigned int cnt;
|
|
||||||
|
|
||||||
switch( hk_id )
|
switch( hk_id )
|
||||||
{
|
{
|
||||||
|
@ -355,8 +354,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_SWITCH_TRACK_DISPLAY_MODE:
|
case HK_SWITCH_TRACK_DISPLAY_MODE:
|
||||||
DisplayOpt.DisplayPcbTrackFill ^= 1;
|
DisplayOpt.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill;
|
||||||
DisplayOpt.DisplayPcbTrackFill &= 1;
|
|
||||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
||||||
GetBoard()->SetVisibleLayers( ALL_LAYERS );
|
GetBoard()->SetVisibleLayers( ALL_LAYERS );
|
||||||
|
|
||||||
// Set currently selected layer to be shown in high contrast mode, when enabled`
|
// Set currently selected layer to be shown in high contrast mode, when enabled`
|
||||||
setHighContrastLayer( GetScreen()->m_Active_Layer );
|
SetHighContrastLayer( GetScreen()->m_Active_Layer );
|
||||||
|
|
||||||
ReFillLayerWidget();
|
ReFillLayerWidget();
|
||||||
|
|
||||||
|
|
|
@ -328,12 +328,12 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
*/
|
*/
|
||||||
// Zoom In
|
// Zoom In
|
||||||
text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr,
|
text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
HK_ZOOM_IN );
|
HK_ZOOM_IN, IS_ACCELERATOR );
|
||||||
AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
|
AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
|
||||||
|
|
||||||
// Zoom Out
|
// Zoom Out
|
||||||
text = AddHotkeyName( _( "Zoom &Out" ), g_Pcbnew_Editor_Hokeys_Descr,
|
text = AddHotkeyName( _( "Zoom &Out" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
HK_ZOOM_OUT );
|
HK_ZOOM_OUT, IS_ACCELERATOR );
|
||||||
AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
|
AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
|
||||||
|
|
||||||
// Fit on Screen
|
// Fit on Screen
|
||||||
|
|
|
@ -46,7 +46,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
|
||||||
// By default everything should be displayed as filled
|
// By default everything should be displayed as filled
|
||||||
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i )
|
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i )
|
||||||
{
|
{
|
||||||
m_sketchModeSelect[i] = false;
|
m_sketchMode[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -94,9 +94,9 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
|
||||||
m_padNumbers = aOptions.DisplayPadNum;
|
m_padNumbers = aOptions.DisplayPadNum;
|
||||||
|
|
||||||
// Whether to draw tracks, vias & pads filled or as outlines
|
// Whether to draw tracks, vias & pads filled or as outlines
|
||||||
m_sketchModeSelect[PADS_VISIBLE] = !aOptions.DisplayPadFill;
|
m_sketchMode[PADS_VISIBLE] = !aOptions.DisplayPadFill;
|
||||||
m_sketchModeSelect[VIA_THROUGH_VISIBLE] = !aOptions.DisplayViaFill;
|
m_sketchMode[VIA_THROUGH_VISIBLE] = !aOptions.DisplayViaFill;
|
||||||
m_sketchModeSelect[TRACKS_VISIBLE] = !aOptions.DisplayPcbTrackFill;
|
m_sketchMode[TRACKS_VISIBLE] = !aOptions.DisplayPcbTrackFill;
|
||||||
|
|
||||||
switch( aOptions.DisplayNetNamesMode )
|
switch( aOptions.DisplayNetNamesMode )
|
||||||
{
|
{
|
||||||
|
@ -248,6 +248,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||||
|
|
||||||
case PCB_MARKER_T:
|
case PCB_MARKER_T:
|
||||||
draw( (MARKER_PCB*) aItem );
|
draw( (MARKER_PCB*) aItem );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Painter does not know how to draw the object
|
// Painter does not know how to draw the object
|
||||||
|
@ -308,7 +309,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
|
||||||
m_gal->SetStrokeColor( color );
|
m_gal->SetStrokeColor( color );
|
||||||
m_gal->SetIsStroke( true );
|
m_gal->SetIsStroke( true );
|
||||||
|
|
||||||
if( m_pcbSettings->m_sketchModeSelect[TRACKS_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[TRACKS_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Outline mode
|
// Outline mode
|
||||||
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth );
|
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth );
|
||||||
|
@ -344,7 +345,7 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer )
|
||||||
|
|
||||||
const COLOR4D& color = m_pcbSettings->GetColor( aVia, aLayer );
|
const COLOR4D& color = m_pcbSettings->GetColor( aVia, aLayer );
|
||||||
|
|
||||||
if( m_pcbSettings->m_sketchModeSelect[VIA_THROUGH_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[VIA_THROUGH_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Outline mode
|
// Outline mode
|
||||||
m_gal->SetIsFill( false );
|
m_gal->SetIsFill( false );
|
||||||
|
@ -475,7 +476,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
|
||||||
|
|
||||||
// Pad drawing
|
// Pad drawing
|
||||||
const COLOR4D& color = m_pcbSettings->GetColor( aPad, aLayer );
|
const COLOR4D& color = m_pcbSettings->GetColor( aPad, aLayer );
|
||||||
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Outline mode
|
// Outline mode
|
||||||
m_gal->SetIsFill( false );
|
m_gal->SetIsFill( false );
|
||||||
|
@ -538,7 +539,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
|
||||||
m = ( size.y - size.x );
|
m = ( size.y - size.x );
|
||||||
n = size.x;
|
n = size.x;
|
||||||
|
|
||||||
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Outline mode
|
// Outline mode
|
||||||
m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
|
m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
|
||||||
|
@ -559,7 +560,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
|
||||||
m = ( size.x - size.y );
|
m = ( size.x - size.y );
|
||||||
n = size.y;
|
n = size.y;
|
||||||
|
|
||||||
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Outline mode
|
// Outline mode
|
||||||
m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
|
m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
|
||||||
|
@ -595,7 +596,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
|
||||||
pointList.push_back( VECTOR2D( corners[2] ) );
|
pointList.push_back( VECTOR2D( corners[2] ) );
|
||||||
pointList.push_back( VECTOR2D( corners[3] ) );
|
pointList.push_back( VECTOR2D( corners[3] ) );
|
||||||
|
|
||||||
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
|
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] )
|
||||||
{
|
{
|
||||||
// Add the beginning point to close the outline
|
// Add the beginning point to close the outline
|
||||||
pointList.push_back( pointList.front() );
|
pointList.push_back( pointList.front() );
|
||||||
|
|
|
@ -99,6 +99,34 @@ public:
|
||||||
*/
|
*/
|
||||||
const COLOR4D& GetLayerColor( int aLayer ) const;
|
const COLOR4D& GetLayerColor( int aLayer ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetSketchMode
|
||||||
|
* Turns on/off sketch mode for given item layer.
|
||||||
|
* @param aItemLayer is the item layer that is changed.
|
||||||
|
* @param aEnabled decides if it is drawn in sketch mode (true for sketched mode,
|
||||||
|
* false for filled mode).
|
||||||
|
*/
|
||||||
|
void SetSketchMode( int aItemLayer, bool aEnabled )
|
||||||
|
{
|
||||||
|
// It is supposed to work only with item layers
|
||||||
|
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
|
||||||
|
|
||||||
|
m_sketchMode[aItemLayer] = aEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetSketchMode
|
||||||
|
* Returns sketch mode setting for a given item layer.
|
||||||
|
* @param aItemLayer is the item layer that is changed.
|
||||||
|
*/
|
||||||
|
bool GetSketchMode( int aItemLayer ) const
|
||||||
|
{
|
||||||
|
// It is supposed to work only with item layers
|
||||||
|
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
|
||||||
|
|
||||||
|
return m_sketchMode[aItemLayer];
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///> @copydoc RENDER_SETTINGS::Update()
|
///> @copydoc RENDER_SETTINGS::Update()
|
||||||
void update();
|
void update();
|
||||||
|
@ -116,7 +144,7 @@ protected:
|
||||||
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
|
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
|
||||||
|
|
||||||
///> Flag determining if items on a given layer should be drawn as an outline or a filled item
|
///> Flag determining if items on a given layer should be drawn as an outline or a filled item
|
||||||
bool m_sketchModeSelect[TOTAL_LAYER_COUNT];
|
bool m_sketchMode[TOTAL_LAYER_COUNT];
|
||||||
|
|
||||||
///> Flag determining if pad numbers should be visible
|
///> Flag determining if pad numbers should be visible
|
||||||
bool m_padNumbers;
|
bool m_padNumbers;
|
||||||
|
|
|
@ -860,7 +860,7 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
|
void PCB_EDIT_FRAME::SetHighContrastLayer( LAYER_NUM aLayer )
|
||||||
{
|
{
|
||||||
// Set display settings for high contrast mode
|
// Set display settings for high contrast mode
|
||||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||||
|
@ -950,7 +950,7 @@ void PCB_EDIT_FRAME::SetActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate
|
||||||
{
|
{
|
||||||
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
|
||||||
|
|
||||||
setHighContrastLayer( aLayer );
|
SetHighContrastLayer( aLayer );
|
||||||
|
|
||||||
if( doLayerWidgetUpdate )
|
if( doLayerWidgetUpdate )
|
||||||
syncLayerWidgetLayer();
|
syncLayerWidgetLayer();
|
||||||
|
|
|
@ -112,6 +112,14 @@ TOOL_ACTION COMMON_ACTIONS::zoomOut( "pcbnew.zoomOut",
|
||||||
AS_GLOBAL, WXK_F2,
|
AS_GLOBAL, WXK_F2,
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
|
TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "pcbnew.zoomInCenter",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
"", "" );
|
||||||
|
|
||||||
|
TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "pcbnew.zoomOutCenter",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
"", "" );
|
||||||
|
|
||||||
TOOL_ACTION COMMON_ACTIONS::zoomCenter( "pcbnew.zoomCenter",
|
TOOL_ACTION COMMON_ACTIONS::zoomCenter( "pcbnew.zoomCenter",
|
||||||
AS_GLOBAL, WXK_F4,
|
AS_GLOBAL, WXK_F4,
|
||||||
"", "" );
|
"", "" );
|
||||||
|
@ -120,6 +128,7 @@ TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "pcbnew.zoomFitScreen",
|
||||||
AS_GLOBAL, WXK_HOME,
|
AS_GLOBAL, WXK_HOME,
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
|
|
||||||
// Display modes
|
// Display modes
|
||||||
TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.trackDisplayMode",
|
TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.trackDisplayMode",
|
||||||
AS_GLOBAL, 'K',
|
AS_GLOBAL, 'K',
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
// View controls
|
// View controls
|
||||||
static TOOL_ACTION zoomIn;
|
static TOOL_ACTION zoomIn;
|
||||||
static TOOL_ACTION zoomOut;
|
static TOOL_ACTION zoomOut;
|
||||||
|
static TOOL_ACTION zoomInCenter;
|
||||||
|
static TOOL_ACTION zoomOutCenter;
|
||||||
static TOOL_ACTION zoomCenter;
|
static TOOL_ACTION zoomCenter;
|
||||||
static TOOL_ACTION zoomFitScreen;
|
static TOOL_ACTION zoomFitScreen;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,16 @@ void PCB_EDIT_FRAME::setupTools()
|
||||||
m_toolDispatcher = new TOOL_DISPATCHER( &m_toolManager, this );
|
m_toolDispatcher = new TOOL_DISPATCHER( &m_toolManager, this );
|
||||||
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
|
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
|
||||||
|
|
||||||
|
// Connect handlers to toolbar buttons
|
||||||
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
||||||
|
Connect( wxEVT_TOOL, wxCommandEventHandler( PCB_EDIT_FRAME::onGenericCommand ), NULL, this );
|
||||||
|
#else
|
||||||
|
Connect( wxEVT_COMMAND_MENU_SELECTED,
|
||||||
|
wxCommandEventHandler( PCB_EDIT_FRAME::onGenericCommand ), NULL, this );
|
||||||
|
Connect( wxEVT_COMMAND_TOOL_CLICKED,
|
||||||
|
wxCommandEventHandler( PCB_EDIT_FRAME::onGenericCommand ), NULL, this );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Register tools
|
// Register tools
|
||||||
m_toolManager.RegisterTool( new SELECTION_TOOL );
|
m_toolManager.RegisterTool( new SELECTION_TOOL );
|
||||||
m_toolManager.RegisterTool( new ROUTER_TOOL );
|
m_toolManager.RegisterTool( new ROUTER_TOOL );
|
||||||
|
@ -75,5 +85,8 @@ void PCB_EDIT_FRAME::destroyTools()
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent& aEvent )
|
void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
m_toolDispatcher->DispatchWxCommand( aEvent );
|
if( IsGalCanvasActive() )
|
||||||
|
m_toolDispatcher->DispatchWxCommand( aEvent );
|
||||||
|
else
|
||||||
|
aEvent.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,14 @@
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
|
#include <class_track.h>
|
||||||
#include <class_drawpanel_gal.h>
|
#include <class_drawpanel_gal.h>
|
||||||
#include <class_pcb_screen.h>
|
#include <class_pcb_screen.h>
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <pcbcommon.h>
|
||||||
|
|
||||||
using namespace KIGFX;
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
using boost::optional;
|
#include <view/view_controls.h>
|
||||||
|
#include <pcb_painter.h>
|
||||||
|
|
||||||
PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
||||||
TOOL_INTERACTIVE( "pcbnew.Settings" )
|
TOOL_INTERACTIVE( "pcbnew.Settings" )
|
||||||
|
@ -41,6 +43,12 @@ PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
|
||||||
|
{
|
||||||
|
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCBNEW_CONTROL::Init()
|
bool PCBNEW_CONTROL::Init()
|
||||||
{
|
{
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
@ -49,18 +57,40 @@ bool PCBNEW_CONTROL::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomIn( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ZoomInOut( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
||||||
|
|
||||||
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
|
||||||
|
m_frame->SetPrevZoom();
|
||||||
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
|
||||||
|
m_frame->SetNextZoom();
|
||||||
|
|
||||||
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||||
|
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );
|
||||||
|
|
||||||
|
view->SetScale( zoom, getViewControls()->GetCursorPosition() );
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomOut( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ZoomInOutCenter( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
||||||
|
|
||||||
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
|
||||||
|
m_frame->SetPrevZoom();
|
||||||
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
|
||||||
|
m_frame->SetNextZoom();
|
||||||
|
|
||||||
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||||
|
double zoom = 1.0 / ( zoomFactor * m_frame->GetZoom() );
|
||||||
|
|
||||||
|
view->SetScale( zoom );
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -69,7 +99,8 @@ int PCBNEW_CONTROL::ZoomOut( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
view->SetCenter( getViewControls()->GetCursorPosition() );
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -78,7 +109,24 @@ int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
||||||
|
BOX2I boardBBox = getModel<BOARD>( PCB_T )->ViewBBox();
|
||||||
|
VECTOR2I screenSize = gal->GetScreenPixelSize();
|
||||||
|
|
||||||
|
double iuPerX = screenSize.x ? boardBBox.GetWidth() / screenSize.x : 1.0;
|
||||||
|
double iuPerY = screenSize.y ? boardBBox.GetHeight() / screenSize.y : 1.0;
|
||||||
|
|
||||||
|
double bestZoom = std::max( iuPerX, iuPerY );
|
||||||
|
// This is needed to avoid "jumpy" zooms if first hot key was used and then mouse scroll
|
||||||
|
// (or other way round).
|
||||||
|
m_frame->GetScreen()->SetZoom( bestZoom );
|
||||||
|
|
||||||
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||||
|
double zoom = 1.0 / ( zoomFactor * bestZoom );
|
||||||
|
|
||||||
|
view->SetScale( zoom );
|
||||||
|
view->SetCenter( boardBBox.Centre() );
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -87,7 +135,20 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
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.DisplayPcbTrackFill = !DisplayOpt.DisplayPcbTrackFill;
|
||||||
|
m_frame->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
|
||||||
|
settings->LoadDisplayOptions( DisplayOpt );
|
||||||
|
|
||||||
|
BOARD* board = getModel<BOARD>( PCB_T );
|
||||||
|
for( TRACK* track = board->m_Track; track; track = track->Next() )
|
||||||
|
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -106,7 +167,23 @@ int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
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.DisplayViaFill = !DisplayOpt.DisplayViaFill;
|
||||||
|
m_frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
|
||||||
|
settings->LoadDisplayOptions( DisplayOpt );
|
||||||
|
|
||||||
|
BOARD* board = getModel<BOARD>( PCB_T );
|
||||||
|
for( TRACK* track = board->m_Track; track; track = track->Next() )
|
||||||
|
{
|
||||||
|
if( track->Type() == PCB_VIA_T )
|
||||||
|
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||||
|
}
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -115,7 +192,15 @@ int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
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() );
|
||||||
|
|
||||||
|
DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
|
||||||
|
settings->LoadDisplayOptions( DisplayOpt );
|
||||||
|
m_frame->SetHighContrastLayer( m_frame->GetActiveLayer() );
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -412,8 +497,10 @@ int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent )
|
||||||
void PCBNEW_CONTROL::setTransitions()
|
void PCBNEW_CONTROL::setTransitions()
|
||||||
{
|
{
|
||||||
// View controls
|
// View controls
|
||||||
Go( &PCBNEW_CONTROL::ZoomIn, COMMON_ACTIONS::zoomIn.MakeEvent() );
|
Go( &PCBNEW_CONTROL::ZoomInOut, COMMON_ACTIONS::zoomIn.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::ZoomOut, COMMON_ACTIONS::zoomOut.MakeEvent() );
|
Go( &PCBNEW_CONTROL::ZoomInOut, COMMON_ACTIONS::zoomOut.MakeEvent() );
|
||||||
|
Go( &PCBNEW_CONTROL::ZoomInOutCenter, COMMON_ACTIONS::zoomInCenter.MakeEvent() );
|
||||||
|
Go( &PCBNEW_CONTROL::ZoomInOutCenter, COMMON_ACTIONS::zoomOutCenter.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::ZoomCenter, COMMON_ACTIONS::zoomCenter.MakeEvent() );
|
Go( &PCBNEW_CONTROL::ZoomCenter, COMMON_ACTIONS::zoomCenter.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::ZoomFitScreen, COMMON_ACTIONS::zoomFitScreen.MakeEvent() );
|
Go( &PCBNEW_CONTROL::ZoomFitScreen, COMMON_ACTIONS::zoomFitScreen.MakeEvent() );
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,12 @@
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
|
|
||||||
|
class PCB_EDIT_FRAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PCBNEW_CONTROL
|
* Class PCBNEW_CONTROL
|
||||||
*
|
*
|
||||||
* TODO
|
* Handles hot keys that are not accepted by any other tool.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PCBNEW_CONTROL : public TOOL_INTERACTIVE
|
class PCBNEW_CONTROL : public TOOL_INTERACTIVE
|
||||||
|
@ -39,14 +41,14 @@ public:
|
||||||
PCBNEW_CONTROL();
|
PCBNEW_CONTROL();
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) {};
|
void Reset( RESET_REASON aReason );
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
// View controls
|
// View controls
|
||||||
int ZoomIn( TOOL_EVENT& aEvent );
|
int ZoomInOut( TOOL_EVENT& aEvent );
|
||||||
int ZoomOut( TOOL_EVENT& aEvent );
|
int ZoomInOutCenter( TOOL_EVENT& aEvent );
|
||||||
int ZoomCenter( TOOL_EVENT& aEvent );
|
int ZoomCenter( TOOL_EVENT& aEvent );
|
||||||
int ZoomFitScreen( TOOL_EVENT& aEvent );
|
int ZoomFitScreen( TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
@ -92,6 +94,9 @@ public:
|
||||||
private:
|
private:
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions();
|
void setTransitions();
|
||||||
|
|
||||||
|
///> Pointerto the currently used edit frame.
|
||||||
|
PCB_EDIT_FRAME* m_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue