2014-03-24 07:45:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-05-04 12:59:14 +00:00
|
|
|
* Copyright (C) 2014-2016 CERN
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-03-24 07:45:05 +00:00
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2022-02-20 13:53:34 +00:00
|
|
|
#include <tools/edit_tool.h>
|
|
|
|
#include <router/router_tool.h>
|
2021-07-27 14:13:26 +00:00
|
|
|
#include <pgm_base.h>
|
2022-02-20 13:53:34 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
|
|
|
#include <tools/pcb_control.h>
|
|
|
|
#include <tools/pcb_picker_tool.h>
|
|
|
|
#include <tools/pcb_selection_tool.h>
|
|
|
|
#include <tools/board_reannotate_tool.h>
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2019-06-11 14:47:54 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <board_item.h>
|
2021-05-01 22:44:22 +00:00
|
|
|
#include <dialogs/dialog_paste_special.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-06-03 17:03:25 +00:00
|
|
|
#include <pcb_group.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <fp_shape.h>
|
2014-03-24 17:28:21 +00:00
|
|
|
#include <confirm.h>
|
2019-06-11 14:47:54 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2020-10-24 12:53:11 +00:00
|
|
|
#include <core/kicad_algo.h>
|
2017-04-15 16:08:23 +00:00
|
|
|
#include <kicad_clipboard.h>
|
2019-06-11 14:47:54 +00:00
|
|
|
#include <origin_viewitem.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcb_painter.h>
|
|
|
|
#include <properties.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2015-06-18 15:51:52 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-06-04 18:46:52 +00:00
|
|
|
#include <footprint_viewer_frame.h>
|
2019-09-04 16:18:42 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2021-07-27 14:13:26 +00:00
|
|
|
#include <widgets/infobar.h>
|
|
|
|
#include <wx/hyperlink.h>
|
2019-06-04 18:46:52 +00:00
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2015-06-18 15:51:51 +00:00
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
|
2015-08-07 16:24:42 +00:00
|
|
|
// files.cpp
|
2021-02-28 19:30:16 +00:00
|
|
|
extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileName,
|
|
|
|
bool aKicadFilesOnly = false );
|
2015-08-07 16:24:42 +00:00
|
|
|
extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_CONTROL::PCB_CONTROL() :
|
2019-12-23 17:11:45 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.Control" ),
|
2020-01-13 00:17:50 +00:00
|
|
|
m_frame( nullptr ),
|
|
|
|
m_pickerItem( nullptr )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2017-03-02 22:57:13 +00:00
|
|
|
m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
|
2015-06-18 15:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_CONTROL::~PCB_CONTROL()
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
2014-03-24 07:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void PCB_CONTROL::Reset( RESET_REASON aReason )
|
2014-03-24 16:20:23 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
m_frame = getEditFrame<PCB_BASE_FRAME>();
|
2015-06-18 15:51:53 +00:00
|
|
|
|
|
|
|
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
|
|
|
|
{
|
2021-11-09 03:36:40 +00:00
|
|
|
m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
|
2018-02-15 19:24:24 +00:00
|
|
|
m_gridOrigin->SetColor( m_frame->GetGridColor() );
|
2017-03-02 22:57:13 +00:00
|
|
|
getView()->Remove( m_gridOrigin.get() );
|
|
|
|
getView()->Add( m_gridOrigin.get() );
|
2015-06-18 15:51:53 +00:00
|
|
|
}
|
2014-03-24 16:20:23 +00:00
|
|
|
}
|
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
|
2019-06-02 20:07:57 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
if( m_frame->IsType( FRAME_FOOTPRINT_EDITOR ) || m_frame->IsType( FRAME_PCB_EDITOR ) )
|
2019-06-02 20:07:57 +00:00
|
|
|
{
|
|
|
|
if( aEvent.IsAction( &ACTIONS::newLibrary ) )
|
|
|
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
|
|
|
|
else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
|
|
|
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Close( false );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-30 19:17:23 +00:00
|
|
|
template<class T> void Flip( T& aValue )
|
|
|
|
{
|
|
|
|
aValue = !aValue;
|
|
|
|
}
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
Flip( opts.m_DisplayPcbTrackFill );
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( PCB_TRACK* track : board()->Tracks() )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2020-10-21 17:43:14 +00:00
|
|
|
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
|
2021-04-08 21:35:51 +00:00
|
|
|
view()->Update( track, KIGFX::REPAINT );
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2017-10-30 19:17:23 +00:00
|
|
|
canvas()->Refresh();
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::ToggleRatsnest( const TOOL_EVENT& aEvent )
|
2018-04-30 07:52:49 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2018-04-30 07:52:49 +00:00
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
|
|
|
|
{
|
2019-06-13 00:32:47 +00:00
|
|
|
// N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
|
2019-11-07 14:23:09 +00:00
|
|
|
Flip( opts.m_ShowGlobalRatsnest );
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
2019-06-13 00:32:47 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
|
2021-09-13 16:18:58 +00:00
|
|
|
opts.m_ShowGlobalRatsnest );
|
2019-06-13 00:32:47 +00:00
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
|
|
|
|
{
|
2019-11-07 14:23:09 +00:00
|
|
|
Flip( opts.m_DisplayRatsnestLinesCurved );
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
2019-05-15 22:49:48 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 07:52:49 +00:00
|
|
|
canvas()->RedrawRatsnest();
|
|
|
|
canvas()->Refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
Flip( opts.m_DisplayViaFill );
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( PCB_TRACK* track : board()->Tracks() )
|
2014-03-24 16:20:23 +00:00
|
|
|
{
|
2017-03-20 11:06:48 +00:00
|
|
|
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
|
2021-04-08 21:35:51 +00:00
|
|
|
view()->Update( track, KIGFX::REPAINT );
|
2014-03-24 16:20:23 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 19:17:23 +00:00
|
|
|
canvas()->Refresh();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-27 14:13:26 +00:00
|
|
|
/**
|
|
|
|
* We have bug reports indicating that some new users confuse zone filling/unfilling with the
|
|
|
|
* display modes. This will put up a warning if they show zone fills when one or more zones
|
|
|
|
* are unfilled.
|
|
|
|
*/
|
|
|
|
void PCB_CONTROL::unfilledZoneCheck()
|
|
|
|
{
|
|
|
|
if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool unfilledZones = false;
|
|
|
|
|
|
|
|
for( const ZONE* zone : board()->Zones() )
|
|
|
|
{
|
2022-01-31 15:25:20 +00:00
|
|
|
if( !zone->GetIsRuleArea() && !zone->IsFilled() )
|
2021-07-27 14:13:26 +00:00
|
|
|
{
|
|
|
|
unfilledZones = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( unfilledZones )
|
|
|
|
{
|
|
|
|
WX_INFOBAR* infobar = frame()->GetInfoBar();
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
|
|
|
|
wxEmptyString );
|
|
|
|
|
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
|
|
|
[&]( wxHyperlinkEvent& aEvent )
|
|
|
|
{
|
|
|
|
Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning = true;
|
|
|
|
frame()->GetInfoBar()->Dismiss();
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
|
2022-02-05 13:25:43 +00:00
|
|
|
"if you wish to see all fills." ),
|
2021-07-27 14:13:26 +00:00
|
|
|
KeyNameFromKeyCode( PCB_ACTIONS::zoneFillAll.GetHotKey() ) );
|
|
|
|
|
2022-01-31 15:25:20 +00:00
|
|
|
infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
|
2021-07-27 14:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
2021-07-26 17:56:11 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFilled ) )
|
2020-12-24 00:38:33 +00:00
|
|
|
{
|
2021-07-27 14:13:26 +00:00
|
|
|
unfilledZoneCheck();
|
2021-07-26 21:06:52 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
|
2020-12-24 00:38:33 +00:00
|
|
|
}
|
2021-07-26 17:56:11 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
|
2020-12-24 00:38:33 +00:00
|
|
|
{
|
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
|
|
|
|
}
|
2021-07-26 17:56:11 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
|
2020-12-24 00:38:33 +00:00
|
|
|
{
|
2021-07-26 17:56:11 +00:00
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS;
|
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayTriangulated ) )
|
|
|
|
{
|
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_TRIANGULATION;
|
2020-12-24 00:38:33 +00:00
|
|
|
}
|
2019-06-21 10:26:59 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
2021-07-26 17:56:11 +00:00
|
|
|
if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
|
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
|
|
|
|
else
|
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
|
2020-07-11 17:42:00 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
else
|
2020-12-24 00:38:33 +00:00
|
|
|
{
|
2018-06-15 15:11:32 +00:00
|
|
|
wxFAIL;
|
2020-12-24 00:38:33 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
m_frame->SetDisplayOptions( opts );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
2021-04-08 21:35:51 +00:00
|
|
|
view()->Update( zone, KIGFX::REPAINT );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2017-10-30 19:17:23 +00:00
|
|
|
canvas()->Refresh();
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2021-10-04 12:42:08 +00:00
|
|
|
opts.m_ContrastModeDisplay = opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL
|
|
|
|
? HIGH_CONTRAST_MODE::DIMMED
|
|
|
|
: HIGH_CONTRAST_MODE::NORMAL;
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
m_frame->SetDisplayOptions( opts );
|
2020-07-11 17:40:23 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::HighContrastModeCycle( const TOOL_EVENT& aEvent )
|
2020-07-11 17:40:23 +00:00
|
|
|
{
|
2021-07-26 21:06:52 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
2020-07-11 17:40:23 +00:00
|
|
|
|
|
|
|
switch( opts.m_ContrastModeDisplay )
|
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
case HIGH_CONTRAST_MODE::NORMAL: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED; break;
|
|
|
|
case HIGH_CONTRAST_MODE::DIMMED: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN; break;
|
|
|
|
case HIGH_CONTRAST_MODE::HIDDEN: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; break;
|
2020-07-11 17:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-04 12:42:08 +00:00
|
|
|
int PCB_CONTROL::NetColorModeCycle( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
|
|
|
|
|
|
|
switch( opts.m_NetColorMode )
|
|
|
|
{
|
|
|
|
case NET_COLOR_MODE::ALL: opts.m_NetColorMode = NET_COLOR_MODE::RATSNEST; break;
|
|
|
|
case NET_COLOR_MODE::RATSNEST: opts.m_NetColorMode = NET_COLOR_MODE::OFF; break;
|
|
|
|
case NET_COLOR_MODE::OFF: opts.m_NetColorMode = NET_COLOR_MODE::ALL; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_CONTROL::RatsnestModeCycle( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_DISPLAY_OPTIONS opts = displayOptions();
|
|
|
|
|
|
|
|
if( !opts.m_ShowGlobalRatsnest )
|
|
|
|
{
|
|
|
|
opts.m_ShowGlobalRatsnest = true;
|
|
|
|
opts.m_RatsnestMode = RATSNEST_MODE::ALL;
|
|
|
|
}
|
|
|
|
else if( opts.m_RatsnestMode == RATSNEST_MODE::ALL )
|
|
|
|
{
|
|
|
|
opts.m_RatsnestMode = RATSNEST_MODE::VISIBLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
opts.m_ShowGlobalRatsnest = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerSwitch( const TOOL_EVENT& aEvent )
|
2014-07-09 14:25:50 +00:00
|
|
|
{
|
2021-12-09 18:14:11 +00:00
|
|
|
m_frame->SwitchLayer( aEvent.Parameter<PCB_LAYER_ID>() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_BASE_FRAME* editFrame = m_frame;
|
2019-12-29 23:37:25 +00:00
|
|
|
BOARD* brd = board();
|
2020-12-16 13:31:32 +00:00
|
|
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
2019-12-29 23:37:25 +00:00
|
|
|
LAYER_NUM startLayer = layer;
|
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
|
|
|
return 0;
|
|
|
|
|
2019-12-29 23:37:25 +00:00
|
|
|
while( startLayer != ++layer )
|
|
|
|
{
|
|
|
|
if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
|
|
|
|
break;
|
2014-07-09 14:25:50 +00:00
|
|
|
|
2019-12-29 23:37:25 +00:00
|
|
|
if( layer >= B_Cu )
|
|
|
|
layer = F_Cu - 1;
|
|
|
|
}
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2018-06-15 15:11:32 +00:00
|
|
|
wxCHECK( IsCopperLayer( layer ), 0 );
|
2021-12-09 18:14:11 +00:00
|
|
|
editFrame->SwitchLayer( ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_BASE_FRAME* editFrame = m_frame;
|
2019-12-29 23:37:25 +00:00
|
|
|
BOARD* brd = board();
|
2020-12-16 13:31:32 +00:00
|
|
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
2019-12-29 23:37:25 +00:00
|
|
|
LAYER_NUM startLayer = layer;
|
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
|
|
|
return 0;
|
|
|
|
|
2019-12-29 23:37:25 +00:00
|
|
|
while( startLayer != --layer )
|
|
|
|
{
|
2020-01-24 09:13:18 +00:00
|
|
|
if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
|
2021-09-13 16:18:58 +00:00
|
|
|
&& brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
|
|
|
|
{
|
2019-12-29 23:37:25 +00:00
|
|
|
break;
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2019-12-29 23:37:25 +00:00
|
|
|
|
|
|
|
if( layer <= F_Cu )
|
|
|
|
layer = B_Cu + 1;
|
|
|
|
}
|
2014-07-09 14:25:50 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2018-06-15 15:11:32 +00:00
|
|
|
wxCHECK( IsCopperLayer( layer ), 0 );
|
2021-12-09 18:14:11 +00:00
|
|
|
editFrame->SwitchLayer( ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
|
2015-05-18 11:48:11 +00:00
|
|
|
{
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
PCB_SCREEN* screen = m_frame->GetScreen();
|
|
|
|
|
|
|
|
if( currentLayer == screen->m_Route_Layer_TOP )
|
2021-12-09 18:14:11 +00:00
|
|
|
m_frame->SwitchLayer( screen->m_Route_Layer_BOTTOM );
|
2015-05-18 11:48:11 +00:00
|
|
|
else
|
2021-12-09 18:14:11 +00:00
|
|
|
m_frame->SwitchLayer( screen->m_Route_Layer_TOP );
|
2015-05-18 11:48:11 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-22 11:54:01 +00:00
|
|
|
// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
|
2018-02-23 13:04:07 +00:00
|
|
|
// set in wxFormBuilder.
|
|
|
|
#define ALPHA_MIN 0.20
|
|
|
|
#define ALPHA_MAX 1.00
|
|
|
|
#define ALPHA_STEP 0.05
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
COLOR_SETTINGS* settings = m_frame->GetColorSettings();
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2018-02-23 13:04:07 +00:00
|
|
|
if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
|
2014-03-24 17:28:21 +00:00
|
|
|
{
|
2018-02-23 13:04:07 +00:00
|
|
|
currentColor.a += ALPHA_STEP;
|
2020-01-13 01:44:19 +00:00
|
|
|
settings->SetColor( currentLayer, currentColor );
|
|
|
|
m_frame->GetCanvas()->UpdateColors();
|
2019-05-27 00:20:18 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
|
2019-05-27 00:20:18 +00:00
|
|
|
view->UpdateLayerColor( currentLayer );
|
2021-02-09 12:26:08 +00:00
|
|
|
view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
|
|
|
|
|
|
|
|
if( IsCopperLayer( currentLayer ) )
|
|
|
|
view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
|
2018-02-21 16:29:24 +00:00
|
|
|
|
2021-04-07 15:53:43 +00:00
|
|
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->OnLayerAlphaChanged();
|
2014-03-24 17:28:21 +00:00
|
|
|
}
|
2018-02-23 13:04:07 +00:00
|
|
|
else
|
2021-09-13 16:18:58 +00:00
|
|
|
{
|
2018-02-23 13:04:07 +00:00
|
|
|
wxBell();
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
COLOR_SETTINGS* settings = m_frame->GetColorSettings();
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2018-02-23 13:04:07 +00:00
|
|
|
if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
|
2014-03-24 17:28:21 +00:00
|
|
|
{
|
2018-02-23 13:04:07 +00:00
|
|
|
currentColor.a -= ALPHA_STEP;
|
2020-01-13 01:44:19 +00:00
|
|
|
settings->SetColor( currentLayer, currentColor );
|
|
|
|
m_frame->GetCanvas()->UpdateColors();
|
2019-05-27 00:20:18 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
|
2019-05-27 00:20:18 +00:00
|
|
|
view->UpdateLayerColor( currentLayer );
|
2021-02-09 12:26:08 +00:00
|
|
|
view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
|
|
|
|
|
|
|
|
if( IsCopperLayer( currentLayer ) )
|
|
|
|
view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
|
2018-02-21 16:29:24 +00:00
|
|
|
|
2021-04-07 15:53:43 +00:00
|
|
|
static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->OnLayerAlphaChanged();
|
2014-03-24 17:28:21 +00:00
|
|
|
}
|
2018-02-23 13:04:07 +00:00
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2018-02-23 13:04:07 +00:00
|
|
|
wxBell();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void PCB_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
|
|
|
EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
|
2014-06-04 15:46:43 +00:00
|
|
|
{
|
2021-11-09 03:36:40 +00:00
|
|
|
aFrame->GetDesignSettings().SetGridOrigin( wxPoint( aPoint ) );
|
2015-06-18 15:51:51 +00:00
|
|
|
aView->GetGAL()->SetGridOrigin( aPoint );
|
2020-07-01 12:28:10 +00:00
|
|
|
originViewItem->SetPosition( (wxPoint) aPoint );
|
2015-06-18 15:51:51 +00:00
|
|
|
aView->MarkDirty();
|
2018-01-24 21:27:56 +00:00
|
|
|
aFrame->OnModify();
|
2015-06-18 15:51:51 +00:00
|
|
|
}
|
2014-06-04 15:46:43 +00:00
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
2015-06-18 15:51:51 +00:00
|
|
|
{
|
2015-06-30 12:08:03 +00:00
|
|
|
VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
|
2015-06-18 15:51:51 +00:00
|
|
|
|
2015-06-30 12:08:03 +00:00
|
|
|
if( origin )
|
|
|
|
{
|
2018-01-24 10:19:33 +00:00
|
|
|
// We can't undo the other grid dialog settings, so no sense undoing just the origin
|
|
|
|
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
|
2015-06-30 12:08:03 +00:00
|
|
|
delete origin;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
|
2019-07-19 21:13:52 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
2015-06-30 12:08:03 +00:00
|
|
|
|
2021-05-07 08:35:00 +00:00
|
|
|
if( !picker ) // Happens in footprint wizard
|
|
|
|
return 0;
|
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetClickHandler(
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const VECTOR2D& pt ) -> bool
|
|
|
|
{
|
|
|
|
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
|
|
|
|
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
|
|
|
|
return false; // drill origin is a one-shot; don't continue with tool
|
|
|
|
} );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2015-06-30 12:08:03 +00:00
|
|
|
}
|
2014-06-04 15:46:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
|
2016-05-04 12:59:14 +00:00
|
|
|
{
|
2020-08-26 18:04:32 +00:00
|
|
|
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
|
2019-06-24 15:27:05 +00:00
|
|
|
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
|
2016-05-04 12:59:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-25 13:01:22 +00:00
|
|
|
#define HITTEST_THRESHOLD_PIXELS 5
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
2015-06-18 15:51:51 +00:00
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
|
2019-07-19 21:13:52 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
2019-07-15 23:44:01 +00:00
|
|
|
|
2019-06-25 13:01:22 +00:00
|
|
|
m_pickerItem = nullptr;
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2015-06-18 15:51:51 +00:00
|
|
|
|
2019-07-19 20:47:33 +00:00
|
|
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
|
|
|
Activate();
|
|
|
|
|
2020-10-08 11:39:51 +00:00
|
|
|
picker->SetCursor( KICURSOR::REMOVE );
|
2019-07-15 23:44:01 +00:00
|
|
|
|
|
|
|
picker->SetClickHandler(
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const VECTOR2D& aPosition ) -> bool
|
2019-06-25 13:01:22 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
if( m_pickerItem )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
if( m_pickerItem && m_pickerItem->IsLocked() )
|
|
|
|
{
|
|
|
|
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
|
|
|
|
m_statusPopup->SetText( _( "Item locked." ) );
|
|
|
|
m_statusPopup->PopupFor( 2000 );
|
|
|
|
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
|
|
|
return true;
|
|
|
|
}
|
2019-07-15 23:44:01 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
|
|
|
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
|
|
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
|
|
|
m_pickerItem = nullptr;
|
|
|
|
}
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetMotionHandler(
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const VECTOR2D& aPos )
|
2019-07-28 18:30:56 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
|
|
|
GENERAL_COLLECTOR collector;
|
|
|
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
|
|
|
|
|
|
if( m_isFootprintEditor )
|
|
|
|
collector.Collect( board, GENERAL_COLLECTOR::FootprintItems,
|
|
|
|
(wxPoint) aPos, guide );
|
|
|
|
else
|
|
|
|
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems,
|
|
|
|
(wxPoint) aPos, guide );
|
|
|
|
|
|
|
|
// Remove unselectable items
|
|
|
|
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
if( !selectionTool->Selectable( collector[ i ] ) )
|
|
|
|
collector.Remove( i );
|
|
|
|
}
|
2019-07-28 18:30:56 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
if( collector.GetCount() > 1 )
|
|
|
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
2019-07-28 18:30:56 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
if( m_pickerItem != item )
|
|
|
|
{
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
m_pickerItem = item;
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->BrightenItem( m_pickerItem );
|
|
|
|
}
|
|
|
|
} );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetFinalizeHandler(
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const int& aFinalState )
|
|
|
|
{
|
|
|
|
if( m_pickerItem )
|
|
|
|
m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
2020-10-11 17:12:13 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
m_statusPopup.reset();
|
2021-05-26 00:18:34 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
// Ensure the cursor gets changed&updated
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
} );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2015-06-18 15:51:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-05-18 17:21:30 +00:00
|
|
|
|
2018-05-08 08:36:50 +00:00
|
|
|
|
2020-11-25 16:09:23 +00:00
|
|
|
static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
|
|
|
|
std::vector<BOARD_ITEM*>& aPastedItems )
|
2020-03-16 15:47:01 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
aClipFootprint->SetParent( aBoard );
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : aClipFootprint->Pads() )
|
2020-03-16 15:47:01 +00:00
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
pad->SetParent( editorFootprint );
|
2020-03-16 15:47:01 +00:00
|
|
|
aPastedItems.push_back( pad );
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
aClipFootprint->Pads().clear();
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2020-11-25 16:09:23 +00:00
|
|
|
// Not all graphic items can be added to the current footprint:
|
|
|
|
// Reference and value are already existing in the current footprint, and
|
|
|
|
// must be unique.
|
|
|
|
// So they will be skipped
|
2020-11-08 21:29:04 +00:00
|
|
|
for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
|
2020-03-16 15:47:01 +00:00
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
if( item->Type() == PCB_FP_SHAPE_T )
|
2020-03-16 15:47:01 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
shape->SetParent( nullptr );
|
|
|
|
shape->SetLocalCoord();
|
2020-03-16 15:47:01 +00:00
|
|
|
}
|
2020-10-04 14:19:33 +00:00
|
|
|
else if( item->Type() == PCB_FP_TEXT_T )
|
2020-03-16 15:47:01 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
FP_TEXT* text = static_cast<FP_TEXT*>( item );
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
|
2020-11-25 16:09:23 +00:00
|
|
|
continue;
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2021-08-18 15:43:10 +00:00
|
|
|
text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() );
|
2020-03-16 15:47:01 +00:00
|
|
|
|
|
|
|
text->SetParent( nullptr );
|
|
|
|
text->SetLocalCoord();
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
item->SetParent( editorFootprint );
|
2020-03-16 15:47:01 +00:00
|
|
|
aPastedItems.push_back( item );
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
aClipFootprint->GraphicalItems().clear();
|
2020-03-16 15:47:01 +00:00
|
|
|
|
2021-02-07 11:11:00 +00:00
|
|
|
for( FP_ZONE* zone : aClipFootprint->Zones() )
|
|
|
|
{
|
|
|
|
zone->SetParent( editorFootprint );
|
|
|
|
aPastedItems.push_back( zone );
|
|
|
|
}
|
|
|
|
|
|
|
|
aClipFootprint->Zones().clear();
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
for( PCB_GROUP* group : aClipFootprint->Groups() )
|
2020-10-20 12:37:36 +00:00
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
group->SetParent( editorFootprint );
|
2020-10-20 12:37:36 +00:00
|
|
|
aPastedItems.push_back( group );
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
aClipFootprint->Groups().clear();
|
2020-03-16 15:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-09 20:01:34 +00:00
|
|
|
void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|
|
|
{
|
|
|
|
LSET enabledLayers = board()->GetEnabledLayers();
|
|
|
|
std::vector<BOARD_ITEM*> returnItems;
|
|
|
|
bool fpItemDeleted = false;
|
|
|
|
|
|
|
|
auto processFPItem =
|
|
|
|
[&]( FOOTPRINT* aFootprint, BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
LSET allowed = aItem->GetLayerSet() & enabledLayers;
|
|
|
|
|
|
|
|
if( allowed.any() )
|
|
|
|
{
|
|
|
|
aItem->SetLayerSet( allowed );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aFootprint->Remove( aItem );
|
|
|
|
fpItemDeleted = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : aItems )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
|
|
|
|
|
|
|
|
if( !enabledLayers.test( fp->Reference().GetLayer() ) )
|
|
|
|
fp->Reference().SetLayer( fp->IsFlipped() ? B_SilkS : F_SilkS );
|
|
|
|
|
|
|
|
if( !enabledLayers.test( fp->Value().GetLayer() ) )
|
|
|
|
fp->Value().SetLayer( fp->IsFlipped() ? B_Fab : F_Fab );
|
|
|
|
|
|
|
|
// NOTE: all traversals from the back as processFPItem() might delete the item
|
|
|
|
|
|
|
|
for( int ii = static_cast<int>( fp->Pads().size() ) - 1; ii >= 0; ii-- )
|
|
|
|
processFPItem( fp, fp->Pads()[ii] );
|
|
|
|
|
|
|
|
for( int ii = static_cast<int>( fp->Zones().size() ) - 1; ii >= 0; ii-- )
|
|
|
|
processFPItem( fp, fp->Zones()[ii] );
|
|
|
|
|
|
|
|
for( int ii = static_cast<int>( fp->GraphicalItems().size() ) - 1; ii >= 0; ii-- )
|
|
|
|
processFPItem( fp, fp->GraphicalItems()[ii] );
|
|
|
|
|
|
|
|
if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
|
|
|
|
returnItems.push_back( fp );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LSET allowed = item->GetLayerSet() & enabledLayers;
|
|
|
|
|
|
|
|
if( allowed.any() )
|
|
|
|
{
|
|
|
|
item->SetLayerSet( allowed );
|
|
|
|
returnItems.push_back( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
|
|
|
|
{
|
|
|
|
DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
|
|
|
|
"present in the current board.\n"
|
|
|
|
"These items could not be pasted.\n" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
aItems = returnItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
2017-04-15 16:08:23 +00:00
|
|
|
{
|
|
|
|
CLIPBOARD_IO pi;
|
2017-05-18 17:21:30 +00:00
|
|
|
BOARD_ITEM* clipItem = pi.Parse();
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2017-09-29 09:40:10 +00:00
|
|
|
if( !clipItem )
|
2017-09-22 15:17:38 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-10-30 23:33:24 +00:00
|
|
|
// The viewer frames cannot paste
|
|
|
|
if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
|
|
|
|
return 0;
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
PASTE_MODE pasteMode = PASTE_MODE::KEEP_ANNOTATIONS;
|
|
|
|
const wxString defaultRef = wxT( "REF**" );
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
|
|
|
|
{
|
|
|
|
DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode, defaultRef );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
|
2017-05-18 17:21:30 +00:00
|
|
|
|
2020-03-10 23:05:34 +00:00
|
|
|
if( clipItem->Type() == PCB_T )
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
if( isFootprintEditor )
|
2020-03-10 23:05:34 +00:00
|
|
|
{
|
|
|
|
for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
|
|
|
|
item->SetNet( NETINFO_LIST::OrphanedItem() );
|
|
|
|
}
|
|
|
|
else
|
2020-11-08 21:29:04 +00:00
|
|
|
{
|
2020-03-10 23:05:34 +00:00
|
|
|
static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
|
2020-11-08 21:29:04 +00:00
|
|
|
}
|
2020-03-10 23:05:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 22:00:12 +00:00
|
|
|
// The clipboard can contain two different things, an entire kicad_pcb or a single footprint
|
2020-11-10 20:11:53 +00:00
|
|
|
if( isFootprintEditor && ( !board() || !footprint() ) )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2017-09-22 15:17:38 +00:00
|
|
|
return 0;
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch( clipItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_T:
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
BOARD* clipBoard = static_cast<BOARD*>( clipItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
if( isFootprintEditor )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
|
2019-10-31 15:25:39 +00:00
|
|
|
std::vector<BOARD_ITEM*> pastedItems;
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
|
2020-11-08 21:29:04 +00:00
|
|
|
pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
|
|
|
|
{
|
2020-10-04 14:19:33 +00:00
|
|
|
if( clipDrawItem->Type() == PCB_SHAPE_T )
|
2019-10-31 15:25:39 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
// Convert to PCB_FP_SHAPE_T
|
2020-11-08 21:29:04 +00:00
|
|
|
FP_SHAPE* pastedShape = new FP_SHAPE( editorFootprint );
|
2020-10-04 23:34:59 +00:00
|
|
|
static_cast<PCB_SHAPE*>( pastedShape )->SwapData( clipShape );
|
|
|
|
pastedShape->SetLocalCoord();
|
2019-10-31 15:25:39 +00:00
|
|
|
|
2020-09-05 17:51:28 +00:00
|
|
|
// Replace parent nuked by above call to SwapData()
|
2020-11-08 21:29:04 +00:00
|
|
|
pastedShape->SetParent( editorFootprint );
|
2020-10-04 23:34:59 +00:00
|
|
|
pastedItems.push_back( pastedShape );
|
2019-10-31 15:25:39 +00:00
|
|
|
}
|
|
|
|
else if( clipDrawItem->Type() == PCB_TEXT_T )
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
// Convert to PCB_FP_TEXT_T
|
2020-11-08 21:29:04 +00:00
|
|
|
FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
|
2019-10-31 15:25:39 +00:00
|
|
|
static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
|
|
|
|
static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
pastedTextItem->SetParent( editorFootprint );
|
2019-10-31 15:25:39 +00:00
|
|
|
pastedItems.push_back( pastedTextItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete clipBoard;
|
|
|
|
|
2022-09-09 20:01:34 +00:00
|
|
|
pruneItemLayers( pastedItems );
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
placeBoardItems( pastedItems, true, true,
|
|
|
|
pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2019-10-31 15:25:39 +00:00
|
|
|
else
|
|
|
|
{
|
2022-01-10 20:47:18 +00:00
|
|
|
clipBoard->SetElementVisibility( LAYER_RATSNEST,
|
|
|
|
board()->IsElementVisible( LAYER_RATSNEST ) );
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
|
|
|
|
{
|
|
|
|
for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
|
|
|
|
clipFootprint->SetReference( defaultRef );
|
|
|
|
}
|
|
|
|
|
|
|
|
placeBoardItems( clipBoard, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-10-31 15:25:39 +00:00
|
|
|
m_frame->GetBoard()->BuildConnectivity();
|
2020-06-16 18:18:52 +00:00
|
|
|
m_frame->Compile_Ratsnest( true );
|
2019-10-31 15:25:39 +00:00
|
|
|
}
|
2019-10-17 17:03:43 +00:00
|
|
|
|
2017-05-18 17:21:30 +00:00
|
|
|
break;
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
std::vector<BOARD_ITEM*> pastedItems;
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
if( isFootprintEditor )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
|
|
|
|
delete clipFootprint;
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2017-09-22 15:17:38 +00:00
|
|
|
else
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2022-01-10 20:47:18 +00:00
|
|
|
|
|
|
|
for( PAD* pad : clipFootprint->Pads() )
|
|
|
|
pad->SetLocalRatsnestVisible( board()->IsElementVisible( LAYER_RATSNEST ) );
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
|
|
|
|
clipFootprint->SetReference( defaultRef );
|
|
|
|
|
2020-11-08 21:29:04 +00:00
|
|
|
clipFootprint->SetParent( board() );
|
|
|
|
pastedItems.push_back( clipFootprint );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2022-09-09 20:01:34 +00:00
|
|
|
pruneItemLayers( pastedItems );
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
placeBoardItems( pastedItems, true, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
2017-05-18 17:21:30 +00:00
|
|
|
break;
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
2018-05-08 08:36:50 +00:00
|
|
|
|
2017-05-18 17:21:30 +00:00
|
|
|
default:
|
2017-09-22 15:17:38 +00:00
|
|
|
m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
|
2017-05-18 17:21:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-05-08 08:36:50 +00:00
|
|
|
|
2017-05-18 17:21:30 +00:00
|
|
|
return 1;
|
2017-04-15 16:08:23 +00:00
|
|
|
}
|
2015-06-18 15:51:51 +00:00
|
|
|
|
2018-05-08 08:36:50 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::AppendBoardFromFile( const TOOL_EVENT& aEvent )
|
2015-08-07 16:24:42 +00:00
|
|
|
{
|
|
|
|
int open_ctl;
|
|
|
|
wxString fileName;
|
|
|
|
|
|
|
|
PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
if( !editFrame )
|
2017-05-18 17:21:30 +00:00
|
|
|
return 1;
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
// Pick a file to append
|
|
|
|
if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
|
2017-05-18 17:21:30 +00:00
|
|
|
return 1;
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
|
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
|
|
|
|
|
2017-04-15 16:08:23 +00:00
|
|
|
return AppendBoard( *pi, fileName );
|
|
|
|
}
|
2017-05-18 17:21:30 +00:00
|
|
|
|
2018-05-08 08:36:50 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
// Helper function for PCB_CONTROL::placeBoardItems()
|
2019-05-30 13:33:59 +00:00
|
|
|
template<typename T>
|
2020-07-01 12:38:18 +00:00
|
|
|
static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
|
|
|
|
bool aIsNew )
|
2019-05-30 13:33:59 +00:00
|
|
|
{
|
|
|
|
std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
|
2020-05-09 13:14:00 +00:00
|
|
|
[aIsNew]( T aItem )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
2020-06-27 16:06:01 +00:00
|
|
|
bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
|
2020-05-09 13:14:00 +00:00
|
|
|
|
2020-06-27 16:06:01 +00:00
|
|
|
aItem->ClearFlags( SKIP_STRUCT );
|
2020-05-09 13:14:00 +00:00
|
|
|
aItem->SetFlags( aIsNew ? IS_NEW : 0 );
|
|
|
|
|
|
|
|
return doCopy;
|
2019-05-30 13:33:59 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
if( aIsNew )
|
|
|
|
aList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
2018-05-12 18:48:50 +00:00
|
|
|
{
|
2018-05-13 19:50:59 +00:00
|
|
|
if( aList.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
2018-05-12 18:48:50 +00:00
|
|
|
auto obj = aList.front();
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
if( aIsNew )
|
|
|
|
{
|
|
|
|
obj = aList.back();
|
|
|
|
aList.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ; obj ; )
|
|
|
|
{
|
2020-06-27 16:06:01 +00:00
|
|
|
if( obj->HasFlag( SKIP_STRUCT ) )
|
|
|
|
obj->ClearFlags( SKIP_STRUCT );
|
2018-05-12 18:48:50 +00:00
|
|
|
else
|
|
|
|
aTarget.push_back( obj );
|
|
|
|
|
|
|
|
if( aIsNew )
|
|
|
|
{
|
|
|
|
if( aList.size() )
|
|
|
|
{
|
|
|
|
obj = aList.back();
|
|
|
|
aList.pop_back();
|
|
|
|
}
|
|
|
|
else
|
2021-09-13 16:18:58 +00:00
|
|
|
{
|
2018-05-12 18:48:50 +00:00
|
|
|
obj = nullptr;
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2018-05-12 18:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2021-09-13 16:18:58 +00:00
|
|
|
{
|
2018-05-12 18:48:50 +00:00
|
|
|
obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2018-05-12 18:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates )
|
2018-05-08 09:21:55 +00:00
|
|
|
{
|
2017-11-11 08:09:24 +00:00
|
|
|
// items are new if the current board is not the board source
|
|
|
|
bool isNew = board() != aBoard;
|
2018-05-08 09:21:55 +00:00
|
|
|
std::vector<BOARD_ITEM*> items;
|
|
|
|
|
2020-07-01 12:38:18 +00:00
|
|
|
moveUnflaggedItems( aBoard->Tracks(), items, isNew );
|
2020-11-12 23:50:33 +00:00
|
|
|
moveUnflaggedItems( aBoard->Footprints(), items, isNew );
|
2020-07-01 12:38:18 +00:00
|
|
|
moveUnflaggedItems( aBoard->Drawings(), items, isNew );
|
|
|
|
moveUnflaggedItems( aBoard->Zones(), items, isNew );
|
2018-05-08 09:21:55 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
// Subtlety: When selecting a group via the mouse,
|
2020-12-16 13:31:32 +00:00
|
|
|
// PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
|
|
|
|
// descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
|
2020-08-11 19:37:07 +00:00
|
|
|
// mark items non-recursively. That works because the saving of the
|
2021-07-19 23:56:05 +00:00
|
|
|
// selection created aBoard that has the group and all descendants in it.
|
2020-08-11 19:37:07 +00:00
|
|
|
moveUnflaggedItems( aBoard->Groups(), items, isNew );
|
|
|
|
|
2022-09-09 20:01:34 +00:00
|
|
|
pruneItemLayers( items );
|
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
return placeBoardItems( items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
2021-05-01 22:44:22 +00:00
|
|
|
bool aAnchorAtOrigin, bool aReannotateDuplicates )
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
|
2021-04-03 18:08:04 +00:00
|
|
|
|
|
|
|
std::vector<BOARD_ITEM*> itemsToSel;
|
|
|
|
itemsToSel.reserve( aItems.size() );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2020-07-27 17:56:15 +00:00
|
|
|
for( BOARD_ITEM* item : aItems )
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
2020-07-30 17:05:15 +00:00
|
|
|
if( aIsNew )
|
|
|
|
{
|
|
|
|
const_cast<KIID&>( item->m_Uuid ) = KIID();
|
|
|
|
|
2022-07-08 01:17:06 +00:00
|
|
|
// Even though BOARD_COMMIT::Push() will add any new items to the group, we're
|
|
|
|
// going to run PCB_ACTIONS::move first, and the move tool will throw out any
|
|
|
|
// items that aren't in the entered group.
|
2020-09-25 21:15:22 +00:00
|
|
|
if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
|
|
|
|
selectionTool->GetEnteredGroup()->AddItem( item );
|
2020-11-04 00:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update item attributes if needed
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2020-11-04 00:36:27 +00:00
|
|
|
// Dimensions need to have their units updated if they are automatic
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE* dim = static_cast<PCB_DIMENSION_BASE*>( item );
|
2020-11-04 00:36:27 +00:00
|
|
|
|
|
|
|
if( dim->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
|
|
|
|
dim->SetUnits( frame()->GetUserUnits() );
|
|
|
|
|
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-11-04 00:36:27 +00:00
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2020-11-14 22:00:12 +00:00
|
|
|
// Update the footprint path with the new KIID path if the footprint is new
|
2020-11-04 00:36:27 +00:00
|
|
|
if( aIsNew )
|
2020-11-13 15:15:52 +00:00
|
|
|
static_cast<FOOTPRINT*>( item )->SetPath( KIID_PATH() );
|
2020-11-04 00:36:27 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2020-07-30 17:05:15 +00:00
|
|
|
}
|
|
|
|
|
2021-04-03 18:08:04 +00:00
|
|
|
// We only need to add the items that aren't inside a group currently selected
|
|
|
|
// to the selection. If an item is inside a group and that group is selected,
|
|
|
|
// then the selection tool will select it for us.
|
2020-09-26 13:42:40 +00:00
|
|
|
if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
|
2021-04-03 18:08:04 +00:00
|
|
|
itemsToSel.push_back( item );
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-03 18:08:04 +00:00
|
|
|
// Select the items that should be selected
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &itemsToSel );
|
|
|
|
|
2021-08-18 13:34:32 +00:00
|
|
|
// Reannotate duplicate footprints (make sense only in board editor )
|
|
|
|
if( aReannotateDuplicates && m_frame->IsType( FRAME_PCB_EDITOR ) )
|
2021-05-01 22:44:22 +00:00
|
|
|
m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
|
2021-05-01 22:39:16 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item : aItems )
|
|
|
|
{
|
|
|
|
// Commit after reannotation
|
|
|
|
if( aIsNew )
|
|
|
|
editTool->GetCurrentCommit()->Add( item );
|
|
|
|
else
|
|
|
|
editTool->GetCurrentCommit()->Added( item );
|
|
|
|
}
|
|
|
|
|
2021-04-03 18:08:04 +00:00
|
|
|
PCB_SELECTION& selection = selectionTool->GetSelection();
|
|
|
|
|
2019-08-12 19:30:25 +00:00
|
|
|
if( selection.Size() > 0 )
|
|
|
|
{
|
2019-08-20 18:40:26 +00:00
|
|
|
if( aAnchorAtOrigin )
|
|
|
|
{
|
|
|
|
selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
|
2019-08-20 18:40:26 +00:00
|
|
|
selection.SetReferencePoint( item->GetPosition() );
|
|
|
|
}
|
2019-08-12 19:30:25 +00:00
|
|
|
|
|
|
|
getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-08-12 19:30:25 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::move, true );
|
|
|
|
}
|
2017-09-22 15:17:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
|
2017-04-15 16:08:23 +00:00
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2017-05-21 20:18:22 +00:00
|
|
|
if( !editFrame )
|
2017-05-18 17:21:30 +00:00
|
|
|
return 1;
|
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
BOARD* brd = board();
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
if( !brd )
|
2017-05-18 17:21:30 +00:00
|
|
|
return 1;
|
2015-08-07 16:24:42 +00:00
|
|
|
|
2019-06-11 00:00:15 +00:00
|
|
|
// Mark existing items, in order to know what are the new items so we can select only
|
|
|
|
// the new items after loading
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : brd->Tracks() )
|
2020-06-27 16:06:01 +00:00
|
|
|
track->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( FOOTPRINT* footprint : brd->Footprints() )
|
|
|
|
footprint->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( PCB_GROUP* group : brd->Groups() )
|
2020-08-11 19:37:07 +00:00
|
|
|
group->SetFlags( SKIP_STRUCT );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( BOARD_ITEM* drawing : brd->Drawings() )
|
2020-06-27 16:06:01 +00:00
|
|
|
drawing->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( ZONE* zone : brd->Zones() )
|
2020-06-27 16:06:01 +00:00
|
|
|
zone->SetFlags( SKIP_STRUCT );
|
2015-08-07 16:24:42 +00:00
|
|
|
|
2020-08-19 18:29:09 +00:00
|
|
|
std::map<wxString, wxString> oldProperties = brd->GetProperties();
|
|
|
|
std::map<wxString, wxString> newProperties;
|
|
|
|
|
2015-08-07 16:24:42 +00:00
|
|
|
// Keep also the count of copper layers, to adjust if necessary
|
2017-09-22 15:17:38 +00:00
|
|
|
int initialCopperLayerCount = brd->GetCopperLayerCount();
|
|
|
|
LSET initialEnabledLayers = brd->GetEnabledLayers();
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
// Load the data
|
|
|
|
try
|
|
|
|
{
|
|
|
|
PROPERTIES props;
|
|
|
|
char xbuf[30];
|
|
|
|
char ybuf[30];
|
|
|
|
|
|
|
|
// EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
|
|
|
|
sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
|
|
|
|
sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
|
|
|
|
|
|
|
|
props["page_width"] = xbuf;
|
|
|
|
props["page_height"] = ybuf;
|
|
|
|
|
2021-06-23 22:53:08 +00:00
|
|
|
WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
editFrame->GetDesignSettings().GetNetClasses().Clear();
|
2021-06-23 22:53:08 +00:00
|
|
|
pi.Load( fileName, brd, &props, nullptr, &progressReporter );
|
2015-08-07 16:24:42 +00:00
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2020-10-16 00:39:55 +00:00
|
|
|
wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
|
2015-08-07 16:24:42 +00:00
|
|
|
DisplayError( editFrame, msg );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-19 18:29:09 +00:00
|
|
|
newProperties = brd->GetProperties();
|
|
|
|
|
|
|
|
for( const std::pair<const wxString, wxString>& prop : oldProperties )
|
|
|
|
newProperties[ prop.first ] = prop.second;
|
|
|
|
|
|
|
|
brd->SetProperties( newProperties );
|
|
|
|
|
2017-04-22 07:23:02 +00:00
|
|
|
// rebuild nets and ratsnest before any use of nets
|
2017-09-22 15:17:38 +00:00
|
|
|
brd->BuildListOfNets();
|
|
|
|
brd->SynchronizeNetsAndNetClasses();
|
2017-11-11 08:09:24 +00:00
|
|
|
brd->BuildConnectivity();
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
// Synchronize layers
|
|
|
|
// we should not ask PLUGINs to do these items:
|
2017-09-22 15:17:38 +00:00
|
|
|
int copperLayerCount = brd->GetCopperLayerCount();
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
if( copperLayerCount > initialCopperLayerCount )
|
2017-09-22 15:17:38 +00:00
|
|
|
brd->SetCopperLayerCount( copperLayerCount );
|
2015-08-07 16:24:42 +00:00
|
|
|
|
|
|
|
// Enable all used layers, and make them visible:
|
2017-09-22 15:17:38 +00:00
|
|
|
LSET enabledLayers = brd->GetEnabledLayers();
|
2015-08-07 16:24:42 +00:00
|
|
|
enabledLayers |= initialEnabledLayers;
|
2017-09-22 15:17:38 +00:00
|
|
|
brd->SetEnabledLayers( enabledLayers );
|
|
|
|
brd->SetVisibleLayers( enabledLayers );
|
2017-04-18 18:10:06 +00:00
|
|
|
|
2021-05-01 22:44:22 +00:00
|
|
|
return placeBoardItems( brd, false, false ); // Do not reannotate duplicates on Append Board
|
2015-08-07 16:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
|
2019-05-14 19:21:10 +00:00
|
|
|
{
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
if( editFrame )
|
|
|
|
editFrame->RestoreCopyFromUndoList( dummy );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
|
2019-05-14 19:21:10 +00:00
|
|
|
{
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
if( editFrame )
|
|
|
|
editFrame->RestoreCopyFromRedoList( dummy );
|
2019-07-15 23:44:01 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
2019-05-28 23:23:58 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
2022-02-20 13:53:34 +00:00
|
|
|
ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = selTool->GetSelection();
|
2019-05-28 23:23:58 +00:00
|
|
|
|
2022-02-20 16:56:53 +00:00
|
|
|
if( routerTool && routerTool->RoutingInProgress() )
|
2022-02-20 13:53:34 +00:00
|
|
|
{
|
|
|
|
routerTool->UpdateMessagePanel();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
2021-09-26 23:22:32 +00:00
|
|
|
EDA_ITEM* item = selection.Front();
|
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
2019-06-03 22:45:06 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
item->GetMsgPanelInfo( m_frame, msgItems );
|
2019-05-28 23:23:58 +00:00
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
2019-06-03 22:45:06 +00:00
|
|
|
else if( selection.GetSize() > 1 )
|
|
|
|
{
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
|
|
|
wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
|
2019-06-03 22:45:06 +00:00
|
|
|
|
2020-11-18 15:36:47 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg ) );
|
2019-09-04 16:18:42 +00:00
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
2020-01-13 14:00:45 +00:00
|
|
|
else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
|
2019-09-04 16:18:42 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( editFrame->GetModel() );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
if( !footprint )
|
|
|
|
return 0;
|
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
|
|
|
wxString msg;
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
msg = footprint->GetFPID().GetLibNickname().wx_str();
|
2020-11-18 15:36:47 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg ) );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
msg = footprint->GetFPID().GetLibItemName().wx_str();
|
2020-11-18 15:36:47 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg ) );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
|
2020-11-18 15:36:47 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg ) );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
wxString doc, keyword;
|
|
|
|
doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
|
2020-10-20 20:18:48 +00:00
|
|
|
keyword.Printf( _( "Keywords: %s" ), footprint->GetKeywords() );
|
2020-11-18 15:36:47 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword ) );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
2019-06-03 22:45:06 +00:00
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
2019-05-28 23:23:58 +00:00
|
|
|
else
|
|
|
|
{
|
2019-06-03 20:52:40 +00:00
|
|
|
m_frame->SetMsgPanel( m_frame->GetBoard() );
|
2019-05-28 23:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-10 17:05:47 +00:00
|
|
|
int PCB_CONTROL::FlipPcbView( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
view()->SetMirror( !view()->IsMirroredX(), false );
|
|
|
|
view()->RecacheAllItems();
|
|
|
|
frame()->GetCanvas()->ForceRefresh();
|
|
|
|
frame()->OnDisplayOptionsChanged();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void PCB_CONTROL::setTransitions()
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
2019-12-23 17:11:45 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
// Display modes
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ToggleRatsnest, PCB_ACTIONS::ratsnestLineMode.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() );
|
2021-07-26 17:56:11 +00:00
|
|
|
Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayFilled.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutline.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayFractured.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayTriangulated.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::HighContrastModeCycle, ACTIONS::highContrastModeCycle.MakeEvent() );
|
2021-10-04 12:42:08 +00:00
|
|
|
Go( &PCB_CONTROL::NetColorModeCycle, PCB_ACTIONS::netColorModeCycle.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::RatsnestModeCycle, PCB_ACTIONS::ratsnestModeCycle.MakeEvent() );
|
2021-02-10 17:05:47 +00:00
|
|
|
Go( &PCB_CONTROL::FlipPcbView, PCB_ACTIONS::flipBoard.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
// Layer control
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerTop.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner1.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner2.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner3.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner4.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner5.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner6.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner7.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner8.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner9.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner10.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner11.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner12.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner13.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner14.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner15.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner16.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner17.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner18.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner19.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner20.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner21.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner22.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner23.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner24.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner25.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner26.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner27.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner28.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner29.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner30.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerSwitch, PCB_ACTIONS::layerBottom.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerNext, PCB_ACTIONS::layerNext.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerPrev, PCB_ACTIONS::layerPrev.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerToggle, PCB_ACTIONS::layerToggle.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerAlphaInc, PCB_ACTIONS::layerAlphaInc.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::LayerAlphaDec, PCB_ACTIONS::layerAlphaDec.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
// Grid control
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::GridSetOrigin, ACTIONS::gridSetOrigin.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::GridResetOrigin, ACTIONS::gridResetOrigin.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
|
|
|
|
Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
// Miscellaneous
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::DeleteItemCursor, ACTIONS::deleteTool.MakeEvent() );
|
2017-04-15 16:08:23 +00:00
|
|
|
|
|
|
|
// Append control
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::AppendBoardFromFile, PCB_ACTIONS::appendBoard.MakeEvent() );
|
2017-09-17 17:49:06 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
|
2021-05-01 22:44:22 +00:00
|
|
|
Go( &PCB_CONTROL::Paste, ACTIONS::pasteSpecial.MakeEvent() );
|
2019-05-28 23:23:58 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
|
|
|
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );
|
|
|
|
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent );
|
|
|
|
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
|
2014-03-24 07:45:05 +00:00
|
|
|
}
|