2014-03-24 07:45:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pcbnew_control.h"
|
|
|
|
#include "common_actions.h"
|
|
|
|
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <class_board.h>
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <class_module.h>
|
2014-03-24 16:20:23 +00:00
|
|
|
#include <class_track.h>
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <class_zone.h>
|
2014-04-04 09:56:04 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2014-03-24 07:45:05 +00:00
|
|
|
#include <class_pcb_screen.h>
|
2014-03-24 17:28:21 +00:00
|
|
|
#include <confirm.h>
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2014-03-24 16:20:23 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <pcb_painter.h>
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
PCBNEW_CONTROL::PCBNEW_CONTROL() :
|
2015-02-15 22:21:52 +00:00
|
|
|
TOOL_INTERACTIVE( "pcbnew.Control" ), m_frame( NULL )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-24 16:20:23 +00:00
|
|
|
void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame = getEditFrame<PCB_BASE_FRAME>();
|
2014-03-24 16:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
bool PCBNEW_CONTROL::Init()
|
|
|
|
{
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
2014-05-13 09:22:51 +00:00
|
|
|
double zoomScale = 1.0;
|
2014-03-24 16:20:23 +00:00
|
|
|
|
|
|
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
|
2014-05-13 09:22:51 +00:00
|
|
|
zoomScale = 1.3;
|
2014-03-24 16:20:23 +00:00
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
|
2014-05-13 09:22:51 +00:00
|
|
|
zoomScale = 0.7;
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoomInOutCenter( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
2014-05-13 09:22:51 +00:00
|
|
|
double zoomScale = 1.0;
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
|
2014-05-13 09:22:51 +00:00
|
|
|
zoomScale = 1.3;
|
2014-07-09 09:22:42 +00:00
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
|
2014-05-13 09:22:51 +00:00
|
|
|
zoomScale = 0.7;
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
view->SetScale( view->GetScale() * zoomScale );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoomCenter( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
|
|
|
view->SetCenter( getViewControls()->GetCursorPosition() );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
|
|
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
2014-07-23 10:06:24 +00:00
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
board->ComputeBoundingBox();
|
|
|
|
BOX2I boardBBox = board->ViewBBox();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
if( boardBBox.GetSize().x == 0 || boardBBox.GetSize().y == 0 )
|
|
|
|
{
|
|
|
|
// Empty view
|
|
|
|
view->SetScale( 100000.0 );
|
|
|
|
view->SetCenter( VECTOR2D( 0, 0 ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Autozoom to board
|
|
|
|
VECTOR2I screenSize = gal->GetScreenPixelSize();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
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 );
|
|
|
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
|
|
|
double zoom = 1.0 / ( zoomFactor * bestZoom );
|
|
|
|
|
|
|
|
view->SetScale( zoom );
|
|
|
|
view->SetCenter( boardBBox.Centre() );
|
|
|
|
}
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::PCB_PAINTER* painter =
|
|
|
|
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
2014-07-09 13:02:56 +00:00
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
|
|
|
displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill;
|
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
|
|
|
|
{
|
|
|
|
if( track->Type() == PCB_TRACE_T )
|
|
|
|
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
|
|
|
}
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
m_frame->GetGalCanvas()->Refresh();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 13:02:56 +00:00
|
|
|
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() );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
|
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
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();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
KIGFX::PCB_PAINTER* painter =
|
|
|
|
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
2014-07-09 13:02:56 +00:00
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayViaFill = !displ_opts->m_DisplayViaFill;
|
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
for( TRACK* track = getModel<BOARD>()->m_Track; track; track = track->Next() )
|
2014-03-24 16:20:23 +00:00
|
|
|
{
|
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
track->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
|
|
|
}
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
m_frame->GetGalCanvas()->Refresh();
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
|
|
|
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() );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
|
|
|
if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayEnable ) )
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayZonesMode = 0;
|
2014-07-09 13:02:56 +00:00
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayDisable ) )
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayZonesMode = 1;
|
2014-07-09 13:02:56 +00:00
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::zoneDisplayOutlines ) )
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayZonesMode = 2;
|
2014-07-09 13:02:56 +00:00
|
|
|
else
|
|
|
|
assert( false );
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
for( int i = 0; i < board->GetAreaCount(); ++i )
|
|
|
|
board->GetArea( i )->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
|
|
|
|
|
|
|
m_frame->GetGalCanvas()->Refresh();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 16:20:23 +00:00
|
|
|
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() );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay;
|
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2014-07-09 08:57:32 +00:00
|
|
|
m_frame->GetGalCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::HighContrastInc( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
|
|
|
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
|
|
|
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Layer control
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent )
|
2014-07-09 14:25:50 +00:00
|
|
|
{
|
|
|
|
if( aEvent.IsAction( &COMMON_ACTIONS::layerTop ) )
|
|
|
|
m_frame->SwitchLayer( NULL, F_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner1 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In1_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner2 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In2_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner3 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In3_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner4 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In4_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner5 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In5_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner6 ) )
|
|
|
|
m_frame->SwitchLayer( NULL, In6_Cu );
|
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerBottom ) )
|
|
|
|
m_frame->SwitchLayer( NULL, B_Cu );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_BASE_FRAME* editFrame = m_frame;
|
|
|
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
2014-06-06 12:59:55 +00:00
|
|
|
|
2014-07-09 14:25:50 +00:00
|
|
|
if( layer < F_Cu || layer > B_Cu )
|
2014-06-06 12:59:55 +00:00
|
|
|
{
|
|
|
|
setTransitions();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-09 14:25:50 +00:00
|
|
|
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
|
|
|
|
|
|
|
|
if( layer == layerCount - 2 || layerCount < 2 )
|
2014-06-24 16:17:18 +00:00
|
|
|
layer = B_Cu;
|
2014-07-09 14:25:50 +00:00
|
|
|
else if( layer == B_Cu )
|
2014-07-09 09:50:27 +00:00
|
|
|
layer = F_Cu;
|
2014-06-06 12:59:55 +00:00
|
|
|
else
|
|
|
|
++layer;
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2014-07-09 14:44:22 +00:00
|
|
|
assert( IsCopperLayer( layer ) );
|
2014-06-29 13:05:51 +00:00
|
|
|
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_BASE_FRAME* editFrame = m_frame;
|
|
|
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2014-07-09 14:25:50 +00:00
|
|
|
if( layer < F_Cu || layer > B_Cu )
|
2014-06-06 12:59:55 +00:00
|
|
|
{
|
|
|
|
setTransitions();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-09 14:25:50 +00:00
|
|
|
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
|
|
|
|
|
|
|
|
if( layer == F_Cu || layerCount < 2 )
|
2014-06-24 16:17:18 +00:00
|
|
|
layer = B_Cu;
|
|
|
|
else if( layer == B_Cu )
|
2014-07-09 14:25:50 +00:00
|
|
|
layer = layerCount - 2;
|
2014-06-06 12:59:55 +00:00
|
|
|
else
|
|
|
|
--layer;
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
assert( IsCopperLayer( layer ) );
|
2014-06-29 13:05:51 +00:00
|
|
|
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 17:28:21 +00:00
|
|
|
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() );
|
|
|
|
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
|
|
|
|
|
|
|
|
if( currentColor.a <= 0.95 )
|
|
|
|
{
|
|
|
|
currentColor.a += 0.05;
|
|
|
|
settings->SetLayerColor( currentLayer, currentColor );
|
|
|
|
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
|
|
|
|
}
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 17:28:21 +00:00
|
|
|
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() );
|
|
|
|
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
|
|
|
|
|
|
|
|
if( currentColor.a >= 0.05 )
|
|
|
|
{
|
|
|
|
currentColor.a -= 0.05;
|
|
|
|
settings->SetLayerColor( currentLayer, currentColor );
|
|
|
|
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
|
|
|
|
}
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Grid control
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame->SetFastGrid1();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame->SetFastGrid2();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::GridNext( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame->SetNextGrid();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::GridPrev( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame->SetPrevGrid();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
2014-06-04 15:46:43 +00:00
|
|
|
{
|
|
|
|
Activate();
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL,
|
2014-06-04 15:46:43 +00:00
|
|
|
_( "Adjust grid origin" ) );
|
|
|
|
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
|
|
controls->ShowCursor( true );
|
|
|
|
controls->SetSnapping( true );
|
|
|
|
controls->SetAutoPan( true );
|
|
|
|
|
|
|
|
while( OPT_TOOL_EVENT evt = Wait() )
|
|
|
|
{
|
|
|
|
if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
|
|
|
getView()->GetGAL()->SetGridOrigin( controls->GetCursorPosition() );
|
|
|
|
getView()->MarkDirty();
|
|
|
|
}
|
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
else if( evt->IsCancel() || evt->IsActivate() )
|
2014-06-04 15:46:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
controls->SetAutoPan( false );
|
|
|
|
controls->SetSnapping( false );
|
|
|
|
controls->ShowCursor( false );
|
|
|
|
setTransitions();
|
|
|
|
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
// Miscellaneous
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 17:28:21 +00:00
|
|
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
|
|
|
|
|
|
|
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
|
|
|
|
m_frame->UpdateStatusBar();
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
|
2014-07-09 13:10:32 +00:00
|
|
|
{
|
|
|
|
const unsigned int BIG_CURSOR = 4000;
|
|
|
|
const unsigned int SMALL_CURSOR = 80;
|
|
|
|
|
|
|
|
KIGFX::GAL* gal = getEditFrame<PCB_BASE_FRAME>()->GetGalCanvas()->GetGAL();
|
|
|
|
|
|
|
|
if( gal->GetCursorSize() == BIG_CURSOR )
|
|
|
|
gal->SetCursorSize( SMALL_CURSOR );
|
|
|
|
else
|
|
|
|
gal->SetCursorSize( BIG_CURSOR );
|
|
|
|
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 17:28:21 +00:00
|
|
|
// TODO should not it be refactored to pcb_frame member function?
|
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
|
|
|
|
if( g_UserUnit == INCHES )
|
|
|
|
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
|
|
|
|
else
|
|
|
|
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
|
|
|
|
|
|
|
|
m_frame->ProcessEvent( evt );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2014-03-24 17:28:21 +00:00
|
|
|
// TODO
|
|
|
|
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
|
|
|
|
setTransitions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
void PCBNEW_CONTROL::setTransitions()
|
|
|
|
{
|
|
|
|
// View controls
|
2014-03-24 16:20:23 +00:00
|
|
|
Go( &PCBNEW_CONTROL::ZoomInOut, COMMON_ACTIONS::zoomIn.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() );
|
2014-03-24 07:45:05 +00:00
|
|
|
Go( &PCBNEW_CONTROL::ZoomCenter, COMMON_ACTIONS::zoomCenter.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoomFitScreen, COMMON_ACTIONS::zoomFitScreen.MakeEvent() );
|
|
|
|
|
|
|
|
// Display modes
|
|
|
|
Go( &PCBNEW_CONTROL::TrackDisplayMode, COMMON_ACTIONS::trackDisplayMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::PadDisplayMode, COMMON_ACTIONS::padDisplayMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ViaDisplayMode, COMMON_ACTIONS::viaDisplayMode.MakeEvent() );
|
2014-07-09 13:02:56 +00:00
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayEnable.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayDisable.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
Go( &PCBNEW_CONTROL::HighContrastMode, COMMON_ACTIONS::highContrastMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::HighContrastInc, COMMON_ACTIONS::highContrastInc.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::HighContrastDec, COMMON_ACTIONS::highContrastDec.MakeEvent() );
|
|
|
|
|
|
|
|
// Layer control
|
2014-07-09 14:25:50 +00:00
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerTop.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner1.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner2.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner3.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner4.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner5.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner6.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerBottom.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
Go( &PCBNEW_CONTROL::LayerNext, COMMON_ACTIONS::layerNext.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerPrev, COMMON_ACTIONS::layerPrev.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerAlphaInc, COMMON_ACTIONS::layerAlphaInc.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerAlphaDec , COMMON_ACTIONS::layerAlphaDec.MakeEvent() );
|
|
|
|
|
|
|
|
// Grid control
|
|
|
|
Go( &PCBNEW_CONTROL::GridFast1, COMMON_ACTIONS::gridFast1.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::GridFast2, COMMON_ACTIONS::gridFast2.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::GridNext, COMMON_ACTIONS::gridNext.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::GridPrev, COMMON_ACTIONS::gridPrev.MakeEvent() );
|
2014-06-04 15:46:43 +00:00
|
|
|
Go( &PCBNEW_CONTROL::GridSetOrigin, COMMON_ACTIONS::gridSetOrigin.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
// Miscellaneous
|
|
|
|
Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() );
|
2014-07-09 13:10:32 +00:00
|
|
|
Go( &PCBNEW_CONTROL::SwitchCursor, COMMON_ACTIONS::switchCursor.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
Go( &PCBNEW_CONTROL::SwitchUnits, COMMON_ACTIONS::switchUnits.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ShowHelp, COMMON_ACTIONS::showHelp.MakeEvent() );
|
2014-07-09 11:50:27 +00:00
|
|
|
Go( &PCBNEW_CONTROL::ToBeDone, COMMON_ACTIONS::toBeDone.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
}
|