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
|
2020-07-01 12:28:10 +00:00
|
|
|
* Copyright (C) 2019-2020 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
|
|
|
|
*/
|
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
#include "edit_tool.h"
|
2019-06-11 14:47:54 +00:00
|
|
|
#include "pcb_actions.h"
|
|
|
|
#include "pcbnew_control.h"
|
|
|
|
#include "pcbnew_picker_tool.h"
|
|
|
|
#include "selection_tool.h"
|
|
|
|
#include <3d_viewer/eda_3d_viewer.h>
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
2014-03-24 07:45:05 +00:00
|
|
|
#include <class_board.h>
|
2019-06-11 14:47:54 +00:00
|
|
|
#include <class_board_item.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>
|
2019-10-31 15:25:39 +00:00
|
|
|
#include <class_edge_mod.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>
|
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>
|
2014-03-24 16:20:23 +00:00
|
|
|
#include <view/view_controls.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>
|
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
|
|
|
|
extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName,
|
|
|
|
bool aKicadFilesOnly = false );
|
|
|
|
extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
|
|
|
|
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
PCBNEW_CONTROL::PCBNEW_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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCBNEW_CONTROL::~PCBNEW_CONTROL()
|
|
|
|
{
|
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>();
|
2015-06-18 15:51:53 +00:00
|
|
|
|
|
|
|
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
|
|
|
|
{
|
2020-07-01 12:28:10 +00:00
|
|
|
m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
|
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
|
|
|
|
2019-06-02 20:07:57 +00:00
|
|
|
int PCBNEW_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
auto 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
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
for( auto track : board()->Tracks() )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
|
|
|
if( track->Type() == PCB_TRACE_T )
|
2017-09-22 15:17:38 +00:00
|
|
|
view()->Update( track, KIGFX::GEOMETRY );
|
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
|
|
|
|
|
|
|
int PCBNEW_CONTROL::ToggleRatsnest( const TOOL_EVENT& aEvent )
|
2018-04-30 07:52:49 +00:00
|
|
|
{
|
|
|
|
auto opts = displayOptions();
|
|
|
|
|
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,
|
2019-11-07 14:23:09 +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
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
auto 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
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
for( auto 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 )
|
2017-10-30 19:17:23 +00:00
|
|
|
view()->Update( track, KIGFX::GEOMETRY );
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
auto opts = displayOptions();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
// Apply new display options to the GAL canvas
|
2017-02-21 12:42:08 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayEnable ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::HIDE_FILLED;
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_OUTLINED;
|
2019-06-21 10:26:59 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
|
|
|
int nextMode = ( static_cast<int>( opts.m_ZoneDisplayMode ) + 1 ) % 3;
|
|
|
|
opts.m_ZoneDisplayMode = static_cast<ZONE_DISPLAY_MODE>( nextMode );
|
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
else
|
2018-06-15 15:11:32 +00:00
|
|
|
wxFAIL;
|
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-08-26 23:52:12 +00:00
|
|
|
for( ZONE_CONTAINER* zone : board()->Zones() )
|
|
|
|
view()->Update( zone, KIGFX::GEOMETRY );
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
auto opts = displayOptions();
|
2014-03-24 16:20:23 +00:00
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
opts.m_ContrastModeDisplay =
|
|
|
|
( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
|
|
|
|
HIGH_CONTRAST_MODE::DIMMED :
|
|
|
|
HIGH_CONTRAST_MODE::NORMAL;
|
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
m_frame->SetDisplayOptions( opts );
|
2020-07-11 17:40:23 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCBNEW_CONTROL::HighContrastModeCycle( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
auto opts = displayOptions();
|
|
|
|
|
|
|
|
switch( opts.m_ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->SetDisplayOptions( opts );
|
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
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
|
|
|
{
|
2019-06-17 22:02:30 +00:00
|
|
|
m_frame->SwitchLayer( NULL, aEvent.Parameter<PCB_LAYER_ID>() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
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;
|
2019-12-29 23:37:25 +00:00
|
|
|
BOARD* brd = board();
|
2014-07-09 11:50:27 +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 );
|
2014-06-29 13:05:51 +00:00
|
|
|
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
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;
|
2019-12-29 23:37:25 +00:00
|
|
|
BOARD* brd = board();
|
2014-07-09 11:50:27 +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)
|
|
|
|
&& brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
|
2019-12-29 23:37:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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 );
|
2014-06-29 13:05:51 +00:00
|
|
|
editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-18 11:48:11 +00:00
|
|
|
int PCBNEW_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
|
|
|
PCB_SCREEN* screen = m_frame->GetScreen();
|
|
|
|
|
|
|
|
if( currentLayer == screen->m_Route_Layer_TOP )
|
|
|
|
m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM );
|
|
|
|
else
|
|
|
|
m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP );
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2020-05-16 17:15:43 +00:00
|
|
|
auto settings = m_frame->GetColorSettings();
|
2014-03-24 17:28:21 +00:00
|
|
|
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
2020-01-13 01:44:19 +00:00
|
|
|
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 );
|
2018-02-21 16:29:24 +00:00
|
|
|
|
|
|
|
wxUpdateUIEvent dummy;
|
|
|
|
static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
|
2014-03-24 17:28:21 +00:00
|
|
|
}
|
2018-02-23 13:04:07 +00:00
|
|
|
else
|
|
|
|
wxBell();
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
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
|
|
|
{
|
2020-05-16 17:15:43 +00:00
|
|
|
auto settings = m_frame->GetColorSettings();
|
2014-03-24 17:28:21 +00:00
|
|
|
|
|
|
|
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
|
2020-01-13 01:44:19 +00:00
|
|
|
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 );
|
2018-02-21 16:29:24 +00:00
|
|
|
|
|
|
|
wxUpdateUIEvent dummy;
|
|
|
|
static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
|
2014-03-24 17:28:21 +00:00
|
|
|
}
|
2018-02-23 13:04:07 +00:00
|
|
|
else
|
|
|
|
wxBell();
|
2014-03-24 17:28:21 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Grid control
|
2019-06-12 22:04:00 +00:00
|
|
|
void PCBNEW_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
2018-01-24 10:19:33 +00:00
|
|
|
BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
|
2014-06-04 15:46:43 +00:00
|
|
|
{
|
2020-07-01 12:28:10 +00:00
|
|
|
aFrame->GetDesignSettings().m_GridOrigin = (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
|
|
|
|
|
|
|
|
2015-06-18 15:51:51 +00:00
|
|
|
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
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
|
|
|
|
{
|
2019-07-19 21:13:52 +00:00
|
|
|
if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
|
|
|
|
return 0;
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
2019-05-20 10:23:32 +00:00
|
|
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
2015-06-30 12:08:03 +00:00
|
|
|
|
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(
|
|
|
|
[this] ( const VECTOR2D& pt ) -> bool
|
2019-06-24 15:27:05 +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(), pt );
|
|
|
|
return false; // drill origin is a one-shot; don't continue with tool
|
|
|
|
} );
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-04 12:59:14 +00:00
|
|
|
int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
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
|
|
|
|
|
|
|
|
|
2015-06-18 15:51:51 +00:00
|
|
|
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-07-19 21:13:52 +00:00
|
|
|
if( m_editModules && !m_frame->GetBoard()->GetFirstModule() )
|
|
|
|
return 0;
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
2019-05-20 10:23:32 +00:00
|
|
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_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();
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
|
|
|
|
|
|
|
picker->SetClickHandler(
|
|
|
|
[this] ( const VECTOR2D& aPosition ) -> bool
|
2019-06-25 13:01:22 +00:00
|
|
|
{
|
2019-07-15 23:44:01 +00:00
|
|
|
if( m_pickerItem )
|
2019-06-25 13:01:22 +00:00
|
|
|
{
|
2019-07-15 23:44:01 +00:00
|
|
|
if( m_pickerItem && m_pickerItem->IsLocked() )
|
|
|
|
{
|
|
|
|
STATUS_TEXT_POPUP statusPopup( m_frame );
|
|
|
|
statusPopup.SetText( _( "Item locked." ) );
|
|
|
|
statusPopup.PopupFor( 2000 );
|
|
|
|
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
2019-09-08 18:43:54 +00:00
|
|
|
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
|
|
|
m_pickerItem = nullptr;
|
2019-06-25 13:01:22 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
return true;
|
|
|
|
} );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
picker->SetMotionHandler(
|
|
|
|
[this] ( const VECTOR2D& aPos )
|
|
|
|
{
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
2019-07-28 18:30:56 +00:00
|
|
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
2019-07-15 23:44:01 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
|
|
|
GENERAL_COLLECTOR collector;
|
|
|
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( m_editModules )
|
|
|
|
collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
|
|
|
|
else
|
|
|
|
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-28 18:30:56 +00:00
|
|
|
// Remove unselectable items
|
|
|
|
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
if( !selectionTool->Selectable( collector[ i ] ) )
|
|
|
|
collector.Remove( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( collector.GetCount() > 1 )
|
|
|
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( m_pickerItem != item )
|
|
|
|
{
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
if( m_pickerItem )
|
|
|
|
selectionTool->UnbrightenItem( m_pickerItem );
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +00:00
|
|
|
m_pickerItem = item;
|
2019-06-25 13:01:22 +00:00
|
|
|
|
2019-07-15 23:44:01 +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(
|
2019-07-22 01:06:06 +00:00
|
|
|
[this] ( const int& aFinalState )
|
2019-07-15 23:44:01 +00:00
|
|
|
{
|
2019-06-25 13:01:22 +00:00
|
|
|
if( m_pickerItem )
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolMgr->GetTool<SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
|
|
} );
|
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-03-16 15:47:01 +00:00
|
|
|
void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
|
|
|
|
std::vector<BOARD_ITEM*>& aPastedItems )
|
|
|
|
{
|
|
|
|
MODULE* editModule = aBoard->GetFirstModule();
|
|
|
|
|
|
|
|
aClipModule->SetParent( aBoard );
|
|
|
|
|
|
|
|
for( D_PAD* pad : aClipModule->Pads() )
|
|
|
|
{
|
|
|
|
pad->SetParent( editModule );
|
|
|
|
aPastedItems.push_back( pad );
|
|
|
|
}
|
|
|
|
|
|
|
|
aClipModule->Pads().clear();
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : aClipModule->GraphicalItems() )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_MODULE_EDGE_T )
|
|
|
|
{
|
|
|
|
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
|
|
|
|
|
|
|
|
edge->SetParent( nullptr );
|
|
|
|
edge->SetLocalCoord();
|
|
|
|
}
|
|
|
|
else if( item->Type() == PCB_MODULE_TEXT_T )
|
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
|
|
|
|
|
|
|
|
if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
|
|
|
|
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
if( text->GetText() == "${VALUE}" )
|
2020-03-16 15:47:01 +00:00
|
|
|
text->SetText( aClipModule->GetValue() );
|
2020-03-26 11:02:59 +00:00
|
|
|
else if( text->GetText() == "${REFERENCE}" )
|
2020-03-16 15:47:01 +00:00
|
|
|
text->SetText( aClipModule->GetReference() );
|
|
|
|
|
|
|
|
text->SetTextAngle( aClipModule->GetOrientation() );
|
|
|
|
|
|
|
|
text->SetParent( nullptr );
|
|
|
|
text->SetLocalCoord();
|
|
|
|
}
|
|
|
|
|
|
|
|
item->SetParent( editModule );
|
|
|
|
aPastedItems.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
aClipModule->GraphicalItems().clear();
|
|
|
|
|
|
|
|
if( !aClipModule->GetReference().IsEmpty() )
|
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Reference() );
|
|
|
|
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
|
|
|
text->SetTextAngle( aClipModule->GetOrientation() );
|
|
|
|
|
|
|
|
text->SetParent( nullptr );
|
|
|
|
text->SetLocalCoord();
|
|
|
|
|
|
|
|
text->SetParent( editModule );
|
|
|
|
aPastedItems.push_back( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aClipModule->GetValue().IsEmpty() )
|
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Value() );
|
|
|
|
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
|
|
|
text->SetTextAngle( aClipModule->GetOrientation() );
|
|
|
|
|
|
|
|
text->SetParent( nullptr );
|
|
|
|
text->SetLocalCoord();
|
|
|
|
|
|
|
|
text->SetParent( editModule );
|
|
|
|
aPastedItems.push_back( text );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
int PCBNEW_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;
|
|
|
|
|
2019-09-05 22:00:47 +00:00
|
|
|
bool editModules = m_editModules || 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 )
|
|
|
|
{
|
|
|
|
if( editModules )
|
|
|
|
{
|
|
|
|
for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
|
|
|
|
item->SetNet( NETINFO_LIST::OrphanedItem() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
|
|
|
|
}
|
|
|
|
|
2017-05-18 17:21:30 +00:00
|
|
|
// The clipboard can contain two different things, an entire kicad_pcb
|
|
|
|
// or a single module
|
|
|
|
|
2017-09-29 09:40:10 +00:00
|
|
|
if( editModules && ( !board() || !module() ) )
|
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
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
if( editModules )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2019-10-31 15:25:39 +00:00
|
|
|
MODULE* editModule = board()->GetFirstModule();
|
|
|
|
std::vector<BOARD_ITEM*> pastedItems;
|
|
|
|
|
|
|
|
for( MODULE* clipModule : clipBoard->Modules() )
|
2020-03-16 15:47:01 +00:00
|
|
|
pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
|
|
|
|
{
|
|
|
|
if( clipDrawItem->Type() == PCB_LINE_T )
|
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
|
|
|
// Convert to PCB_MODULE_EDGE_T
|
|
|
|
EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
|
|
|
|
static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
|
|
|
|
pastedDrawSeg->SetLocalCoord();
|
|
|
|
|
|
|
|
pastedItems.push_back( pastedDrawSeg );
|
|
|
|
}
|
|
|
|
else if( clipDrawItem->Type() == PCB_TEXT_T )
|
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
|
|
|
|
// Convert to PCB_MODULE_TEXT_T
|
|
|
|
TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
|
|
|
|
static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
|
|
|
|
static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
|
|
|
|
|
|
|
|
pastedItems.push_back( pastedTextItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete clipBoard;
|
|
|
|
|
|
|
|
placeBoardItems( pastedItems, true, true );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2019-10-31 15:25:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
placeBoardItems( clipBoard, true );
|
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
|
|
|
}
|
|
|
|
|
2017-05-18 17:21:30 +00:00
|
|
|
case PCB_MODULE_T:
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
MODULE* clipModule = static_cast<MODULE*>( clipItem );
|
2019-10-31 15:25:39 +00:00
|
|
|
std::vector<BOARD_ITEM*> pastedItems;
|
2017-09-22 15:17:38 +00:00
|
|
|
|
|
|
|
if( editModules )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2020-03-16 15:47:01 +00:00
|
|
|
pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
|
2019-10-31 15:25:39 +00:00
|
|
|
delete clipModule;
|
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
|
|
|
{
|
2019-10-31 15:25:39 +00:00
|
|
|
clipModule->SetParent( board() );
|
|
|
|
pastedItems.push_back( clipModule );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-10-31 15:25:39 +00:00
|
|
|
placeBoardItems( pastedItems, true, true );
|
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
|
|
|
|
2017-04-15 16:08:23 +00:00
|
|
|
int PCBNEW_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
|
|
|
|
2019-05-30 13:33:59 +00:00
|
|
|
// Helper function for PCBNEW_CONTROL::placeBoardItems()
|
|
|
|
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-07-01 12:38:18 +00:00
|
|
|
static void moveUnflaggedItems( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget,
|
2020-06-27 16:06:01 +00:00
|
|
|
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
|
|
|
|
obj = nullptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-08-20 18:40:26 +00:00
|
|
|
int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
|
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 );
|
|
|
|
moveUnflaggedItems( aBoard->Modules(), items, isNew );
|
|
|
|
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,
|
|
|
|
// SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
|
|
|
|
// descendants. In PCBNEW_CONTROL::placeBoardItems, below, we skip that and
|
|
|
|
// mark items non-recursively. That works because the saving of the
|
|
|
|
// selection created aBoard that has the group and all descendents in it.
|
|
|
|
moveUnflaggedItems( aBoard->Groups(), items, isNew );
|
|
|
|
|
2019-08-20 18:40:26 +00:00
|
|
|
return placeBoardItems( items, isNew, aAnchorAtOrigin );
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-20 18:40:26 +00:00
|
|
|
int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
|
|
|
bool aAnchorAtOrigin )
|
2017-09-22 15:17:38 +00:00
|
|
|
{
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2020-07-27 17:56:15 +00:00
|
|
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
|
2017-09-22 15:17:38 +00:00
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
PCBNEW_SELECTION& selection = selectionTool->GetSelection();
|
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();
|
|
|
|
|
|
|
|
if( item->Type() == PCB_MODULE_T )
|
2020-09-02 01:09:34 +00:00
|
|
|
{
|
2020-07-30 17:05:15 +00:00
|
|
|
static_cast<MODULE*>( item )->SetPath( KIID_PATH() );
|
2020-09-02 01:09:34 +00:00
|
|
|
}
|
|
|
|
else if( item->Type() == PCB_GROUP_T )
|
|
|
|
{
|
|
|
|
// If pasting a group, its immediate children must be updated to have its new KIID
|
|
|
|
static_cast<PCB_GROUP*>( item )->RunOnChildren( [item] ( BOARD_ITEM* aBrdItem )
|
|
|
|
{
|
|
|
|
aBrdItem->SetGroup( item->m_Uuid );
|
|
|
|
} );
|
|
|
|
}
|
2020-07-30 17:05:15 +00:00
|
|
|
}
|
|
|
|
|
2017-11-11 08:09:24 +00:00
|
|
|
// Add or just select items for the move/place command
|
|
|
|
if( aIsNew )
|
|
|
|
editTool->GetCurrentCommit()->Add( item );
|
|
|
|
else
|
|
|
|
editTool->GetCurrentCommit()->Added( item );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
// Matching the logic of SELECTION_TOOL::select for PCB_GROUP_T, there
|
|
|
|
// is a distinction between which items are SetSelected and which are in
|
|
|
|
// the selection object. Top-level groups or items not in groups are
|
|
|
|
// added to the selection object (via selection.Add(), below), but all
|
|
|
|
// items have SetSelected called. This is because much of the selection
|
|
|
|
// management logic (e.g. move) recursively acts on groups in the
|
|
|
|
// selection, so descendents of groups should not be in the selection
|
|
|
|
// object.
|
|
|
|
item->SetSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter out from selection any items that are in groups that are also in the selection
|
|
|
|
// For PCB_GROUP_T, a selection including the group should not include its descendants.
|
2020-08-12 11:23:30 +00:00
|
|
|
std::unordered_set<PCB_GROUP*> groups;
|
2020-08-11 19:37:07 +00:00
|
|
|
for( BOARD_ITEM* item : aItems )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_GROUP_T )
|
2020-08-12 11:23:30 +00:00
|
|
|
groups.insert( static_cast<PCB_GROUP*>( item ) );
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
for( BOARD_ITEM* item : aItems )
|
|
|
|
{
|
|
|
|
bool inGroup = false;
|
2020-08-12 11:23:30 +00:00
|
|
|
for( PCB_GROUP* grp : groups )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
|
|
|
if( grp->GetItems().find( item ) != grp->GetItems().end() )
|
|
|
|
{
|
|
|
|
inGroup = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( !inGroup )
|
|
|
|
{
|
|
|
|
selection.Add( item );
|
|
|
|
}
|
2017-09-22 15:17:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
|
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
|
|
|
|
2017-04-15 16:08:23 +00:00
|
|
|
int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
|
|
|
|
{
|
|
|
|
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
|
2017-09-22 15:17:38 +00:00
|
|
|
for( auto track : brd->Tracks() )
|
2020-06-27 16:06:01 +00:00
|
|
|
track->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
|
|
|
for( auto module : brd->Modules() )
|
2020-06-27 16:06:01 +00:00
|
|
|
module->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
for( auto group : brd->Groups() )
|
|
|
|
group->SetFlags( SKIP_STRUCT );
|
|
|
|
|
2017-11-11 08:09:24 +00:00
|
|
|
for( auto drawing : brd->Drawings() )
|
2020-06-27 16:06:01 +00:00
|
|
|
drawing->SetFlags( SKIP_STRUCT );
|
2017-11-11 08:09:24 +00:00
|
|
|
|
|
|
|
for( auto 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;
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
editFrame->GetDesignSettings().GetNetClasses().Clear();
|
2017-09-22 15:17:38 +00:00
|
|
|
pi.Load( fileName, brd, &props );
|
2015-08-07 16:24:42 +00:00
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2016-09-14 22:36:45 +00:00
|
|
|
wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( 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
|
|
|
|
2019-08-20 18:40:26 +00:00
|
|
|
return placeBoardItems( brd, false );
|
2015-08-07 16:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
int PCBNEW_CONTROL::Undo( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
if( editFrame )
|
|
|
|
editFrame->RestoreCopyFromUndoList( dummy );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
PCBNEW_SELECTION& selection = selTool->GetSelection();
|
2019-05-28 23:23:58 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
2020-01-13 14:19:44 +00:00
|
|
|
EDA_ITEM* item = selection.Front();
|
2019-05-28 23:23:58 +00:00
|
|
|
MSG_PANEL_ITEMS 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 )
|
|
|
|
{
|
|
|
|
MSG_PANEL_ITEMS msgItems;
|
|
|
|
wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
|
|
|
|
|
2019-09-04 16:18:42 +00:00
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
|
|
|
|
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-01-13 14:19:44 +00:00
|
|
|
MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
|
2019-09-04 16:18:42 +00:00
|
|
|
|
|
|
|
if( !footprint )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
MSG_PANEL_ITEMS msgItems;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg = footprint->GetFPID().GetLibNickname().wx_str();
|
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
|
|
|
|
|
|
|
|
msg = footprint->GetFPID().GetLibItemName().wx_str();
|
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
|
|
|
|
|
|
|
|
wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
|
|
|
|
|
|
|
|
if( footprint->GetLastEditTime() && date.IsValid() )
|
|
|
|
// Date format: see http://www.cplusplus.com/reference/ctime/strftime
|
|
|
|
msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
|
|
|
|
else
|
|
|
|
msg = _( "Unknown" );
|
|
|
|
|
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
|
|
|
|
|
|
|
|
msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
|
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
|
|
|
|
|
|
|
|
wxString doc, keyword;
|
|
|
|
doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
|
|
|
|
keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
|
|
|
|
msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-31 12:30:51 +00:00
|
|
|
void PCBNEW_CONTROL::setTransitions()
|
2014-03-24 07:45:05 +00:00
|
|
|
{
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
2019-12-23 17:11:45 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
// Display modes
|
2020-07-11 17:40:23 +00:00
|
|
|
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::ratsnestLineMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayEnable.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::HighContrastModeCycle, ACTIONS::highContrastModeCycle.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
// Layer control
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerTop.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner1.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner2.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner3.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner4.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner5.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner6.MakeEvent() );
|
2019-06-21 10:43:39 +00:00
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner7.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner8.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner9.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner10.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner11.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner12.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner13.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner14.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner15.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner16.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner17.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner18.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner19.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner20.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner21.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner22.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner23.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner24.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner25.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner26.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner27.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner28.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner29.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerInner30.MakeEvent() );
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerBottom.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerNext, PCB_ACTIONS::layerNext.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerPrev, PCB_ACTIONS::layerPrev.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerToggle, PCB_ACTIONS::layerToggle.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerAlphaInc, PCB_ACTIONS::layerAlphaInc.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::LayerAlphaDec, PCB_ACTIONS::layerAlphaDec.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
|
|
|
// Grid control
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::GridSetOrigin, ACTIONS::gridSetOrigin.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::GridResetOrigin, ACTIONS::gridResetOrigin.MakeEvent() );
|
2014-03-24 07:45:05 +00:00
|
|
|
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
|
|
|
|
Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2014-03-24 07:45:05 +00:00
|
|
|
// Miscellaneous
|
2019-07-31 12:10:13 +00:00
|
|
|
Go( &PCBNEW_CONTROL::DeleteItemCursor, ACTIONS::deleteTool.MakeEvent() );
|
2017-04-15 16:08:23 +00:00
|
|
|
|
|
|
|
// Append control
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::AppendBoardFromFile, PCB_ACTIONS::appendBoard.MakeEvent() );
|
2017-09-17 17:49:06 +00:00
|
|
|
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
|
2019-05-28 23:23:58 +00:00
|
|
|
|
2019-06-04 18:46:52 +00:00
|
|
|
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
|
|
|
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );
|
|
|
|
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent );
|
2019-06-10 22:42:02 +00:00
|
|
|
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
|
2014-03-24 07:45:05 +00:00
|
|
|
}
|