2014-07-09 11:50:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
2022-04-17 17:14:50 +00:00
|
|
|
* Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-07-09 11:50:27 +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
|
|
|
|
*/
|
2021-08-03 16:53:30 +00:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
#include <pgm_base.h>
|
2021-03-29 13:04:41 +00:00
|
|
|
#include <advanced_config.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include "board_editor_control.h"
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <bitmaps.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <pcb_painter.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_commit.h>
|
|
|
|
#include <board_design_settings.h>
|
2023-12-15 17:36:42 +00:00
|
|
|
#include <pcb_generator.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <pcb_target.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-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2020-01-29 16:33:57 +00:00
|
|
|
#include <confirm.h>
|
2019-05-26 15:36:40 +00:00
|
|
|
#include <dialogs/dialog_page_settings.h>
|
2019-06-03 13:49:17 +00:00
|
|
|
#include <dialogs/dialog_update_pcb.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <dialogs/dialog_assign_netclass.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-01-29 16:33:57 +00:00
|
|
|
#include <kiway.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
|
|
|
#include <origin_viewitem.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <project.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <project/project_file.h> // LAST_PATH_TYPE
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2021-08-03 16:53:30 +00:00
|
|
|
#include <tool/tool_event.h>
|
|
|
|
#include <tools/drawing_tool.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2024-02-03 13:43:41 +00:00
|
|
|
#include <tools/pcb_edit_table_tool.h>
|
2021-08-03 16:53:30 +00:00
|
|
|
#include <tools/pcb_picker_tool.h>
|
2022-12-20 15:16:25 +00:00
|
|
|
#include <tools/pcb_selection_conditions.h>
|
2021-08-03 16:53:30 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
|
|
|
#include <tools/edit_tool.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <tools/tool_event_utils.h>
|
2022-11-14 23:39:08 +00:00
|
|
|
#include <tools/zone_filler_tool.h>
|
2020-12-02 16:23:59 +00:00
|
|
|
#include <router/router_tool.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <view/view_group.h>
|
2019-06-04 20:59:59 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_undo_item.h>
|
2020-06-27 11:57:40 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/filedlg.h>
|
2021-06-03 12:11:15 +00:00
|
|
|
#include <wx/log.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
|
2022-06-12 03:09:47 +00:00
|
|
|
#include <widgets/legacyfiledlg_netlist_options.h>
|
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
class ZONE_CONTEXT_MENU : public ACTION_MENU
|
2014-07-09 14:57:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-06-15 00:29:42 +00:00
|
|
|
ZONE_CONTEXT_MENU() :
|
|
|
|
ACTION_MENU( true )
|
2014-07-09 14:57:01 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
SetIcon( BITMAPS::add_zone );
|
2017-01-23 13:47:49 +00:00
|
|
|
SetTitle( _( "Zones" ) );
|
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
Add( PCB_ACTIONS::zoneFill );
|
2017-02-21 12:42:08 +00:00
|
|
|
Add( PCB_ACTIONS::zoneFillAll );
|
2022-11-29 17:22:25 +00:00
|
|
|
Add( PCB_ACTIONS::zoneUnfill );
|
2017-02-21 12:42:08 +00:00
|
|
|
Add( PCB_ACTIONS::zoneUnfillAll );
|
2017-02-06 03:45:56 +00:00
|
|
|
|
|
|
|
AppendSeparator();
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
Add( PCB_ACTIONS::zoneMerge );
|
|
|
|
Add( PCB_ACTIONS::zoneDuplicate );
|
|
|
|
Add( PCB_ACTIONS::drawZoneCutout );
|
|
|
|
Add( PCB_ACTIONS::drawSimilarZone );
|
2015-06-19 15:32:33 +00:00
|
|
|
}
|
|
|
|
|
2017-01-20 17:33:11 +00:00
|
|
|
protected:
|
2019-05-14 11:14:00 +00:00
|
|
|
ACTION_MENU* create() const override
|
2017-01-20 17:33:11 +00:00
|
|
|
{
|
|
|
|
return new ZONE_CONTEXT_MENU();
|
|
|
|
}
|
2014-07-09 14:57:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-12-20 15:16:25 +00:00
|
|
|
class LOCK_CONTEXT_MENU : public CONDITIONAL_MENU
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-12-20 15:16:25 +00:00
|
|
|
LOCK_CONTEXT_MENU( TOOL_INTERACTIVE* aTool ) :
|
|
|
|
CONDITIONAL_MENU( aTool )
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
SetIcon( BITMAPS::locked );
|
2017-01-23 13:47:49 +00:00
|
|
|
SetTitle( _( "Locking" ) );
|
|
|
|
|
2022-12-20 15:16:25 +00:00
|
|
|
AddItem( PCB_ACTIONS::lock, PCB_SELECTION_CONDITIONS::HasUnlockedItems );
|
|
|
|
AddItem( PCB_ACTIONS::unlock, PCB_SELECTION_CONDITIONS::HasLockedItems );
|
|
|
|
AddItem( PCB_ACTIONS::toggleLock, SELECTION_CONDITIONS::ShowAlways );
|
2016-05-09 08:29:06 +00:00
|
|
|
}
|
2017-01-20 17:33:11 +00:00
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
ACTION_MENU* create() const override
|
2017-01-20 17:33:11 +00:00
|
|
|
{
|
2022-12-20 15:16:25 +00:00
|
|
|
return new LOCK_CONTEXT_MENU( this->m_tool );
|
2017-01-20 17:33:11 +00:00
|
|
|
}
|
2016-05-09 08:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.EditorControl" ),
|
2021-06-20 10:02:44 +00:00
|
|
|
m_frame( nullptr ),
|
|
|
|
m_inPlaceFootprint( false ),
|
2021-10-15 07:24:16 +00:00
|
|
|
m_placingFootprint( false ),
|
2021-06-20 10:02:44 +00:00
|
|
|
m_inPlaceTarget( false )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
|
|
|
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
|
2015-06-18 15:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
BOARD_EDITOR_CONTROL::~BOARD_EDITOR_CONTROL()
|
2015-06-18 15:51:54 +00:00
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void BOARD_EDITOR_CONTROL::Reset( RESET_REASON aReason )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
|
|
|
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
2015-06-18 15:51:54 +00:00
|
|
|
|
2022-12-26 16:23:44 +00:00
|
|
|
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
|
2015-06-18 15:51:54 +00:00
|
|
|
{
|
2022-01-02 02:06:40 +00:00
|
|
|
m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
|
2017-03-02 22:57:13 +00:00
|
|
|
getView()->Remove( m_placeOrigin.get() );
|
|
|
|
getView()->Add( m_placeOrigin.get() );
|
2015-06-18 15:51:54 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
bool BOARD_EDITOR_CONTROL::Init()
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2020-12-09 22:16:24 +00:00
|
|
|
auto activeToolCondition =
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
2020-12-09 22:16:24 +00:00
|
|
|
{
|
|
|
|
return ( !m_frame->ToolStackIsEmpty() );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto inactiveStateCondition =
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
2020-12-09 22:16:24 +00:00
|
|
|
{
|
|
|
|
return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto placeModuleCondition =
|
2021-09-13 16:18:58 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
2020-12-09 22:16:24 +00:00
|
|
|
{
|
2021-01-25 13:58:30 +00:00
|
|
|
return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
|
2020-12-09 22:16:24 +00:00
|
|
|
};
|
2018-02-11 01:15:16 +00:00
|
|
|
|
|
|
|
auto& ctxMenu = m_menu.GetMenu();
|
|
|
|
|
|
|
|
// "Cancel" goes at the top of the context menu when a tool is active
|
2019-06-02 15:37:24 +00:00
|
|
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
|
2019-06-15 16:40:14 +00:00
|
|
|
ctxMenu.AddSeparator( 1 );
|
2018-02-11 01:15:16 +00:00
|
|
|
|
|
|
|
// "Get and Place Footprint" should be available for Place Footprint tool
|
2019-07-26 19:19:17 +00:00
|
|
|
ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
|
2019-06-15 16:40:14 +00:00
|
|
|
ctxMenu.AddSeparator( 1000 );
|
2018-02-11 01:15:16 +00:00
|
|
|
|
|
|
|
// Finally, add the standard zoom & grid items
|
2019-06-11 14:38:21 +00:00
|
|
|
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
|
2018-02-11 01:15:16 +00:00
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
|
2017-01-12 10:07:52 +00:00
|
|
|
zoneMenu->SetTool( this );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2022-12-20 15:16:25 +00:00
|
|
|
std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
|
|
|
// Add the PCB control menus to relevant other tools
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
2014-07-09 14:57:01 +00:00
|
|
|
|
|
|
|
if( selTool )
|
|
|
|
{
|
2022-09-03 18:29:02 +00:00
|
|
|
TOOL_MENU& toolMenu = selTool->GetToolMenu();
|
|
|
|
CONDITIONAL_MENU& menu = toolMenu.GetMenu();
|
2016-05-09 08:29:06 +00:00
|
|
|
|
2018-02-11 01:15:16 +00:00
|
|
|
// Add "Get and Place Footprint" when Selection tool is in an inactive state
|
2019-07-26 19:19:17 +00:00
|
|
|
menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
|
2019-06-15 16:40:14 +00:00
|
|
|
menu.AddSeparator();
|
2018-02-11 01:15:16 +00:00
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
toolMenu.RegisterSubMenu( zoneMenu );
|
|
|
|
toolMenu.RegisterSubMenu( lockMenu );
|
2017-01-12 10:07:52 +00:00
|
|
|
|
2020-12-09 22:16:24 +00:00
|
|
|
menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
|
2020-09-10 19:58:05 +00:00
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
|
2014-07-09 14:57:01 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
|
|
|
|
|
|
|
if( drawingTool )
|
|
|
|
{
|
2022-09-03 18:29:02 +00:00
|
|
|
TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
|
|
|
|
CONDITIONAL_MENU& menu = toolMenu.GetMenu();
|
2017-01-12 10:07:52 +00:00
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
toolMenu.RegisterSubMenu( zoneMenu );
|
2017-01-12 10:07:52 +00:00
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
// Functor to say if the PCB_EDIT_FRAME is in a given mode
|
|
|
|
// Capture the tool pointer and tool mode by value
|
2021-09-13 16:18:58 +00:00
|
|
|
auto toolActiveFunctor =
|
|
|
|
[=]( DRAWING_TOOL::MODE aMode )
|
|
|
|
{
|
|
|
|
return [=]( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return drawingTool->GetDrawingMode() == aMode;
|
|
|
|
};
|
|
|
|
};
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_NEW_BOARD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_LOAD_FILE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_SAVE_BOARD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_SAVE_BOARD_AS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-24 16:38:34 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::SaveCopy( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_COPY_BOARD_AS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-17 17:14:50 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Revert( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_REVERT_BOARD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST undoCmd;
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
|
2020-08-26 18:04:32 +00:00
|
|
|
ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
|
2019-05-26 15:36:40 +00:00
|
|
|
|
|
|
|
undoCmd.PushItem( wrapper );
|
2023-08-27 16:11:23 +00:00
|
|
|
undoCmd.SetDescription( _( "Page Settings" ) );
|
2020-08-26 18:04:32 +00:00
|
|
|
m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
|
2019-05-26 15:36:40 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
DIALOG_PAGES_SETTINGS dlg( m_frame, pcbIUScale.IU_PER_MILS, VECTOR2I( MAX_PAGE_SIZE_PCBNEW_MILS,
|
|
|
|
MAX_PAGE_SIZE_PCBNEW_MILS ) );
|
2021-05-30 22:56:24 +00:00
|
|
|
dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
|
2019-05-26 15:36:40 +00:00
|
|
|
|
2021-12-06 23:07:46 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2022-02-04 00:12:59 +00:00
|
|
|
{
|
2022-12-03 13:25:20 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
|
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> int
|
2022-02-04 00:12:59 +00:00
|
|
|
{
|
2022-11-29 15:17:38 +00:00
|
|
|
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
|
2022-02-04 00:12:59 +00:00
|
|
|
|
2022-11-29 15:17:38 +00:00
|
|
|
if( text && text->HasTextVars() )
|
2022-12-03 13:25:20 +00:00
|
|
|
{
|
|
|
|
text->ClearRenderCache();
|
|
|
|
text->ClearBoundingBoxCache();
|
|
|
|
return KIGFX::GEOMETRY | KIGFX::REPAINT;
|
|
|
|
}
|
2022-02-04 00:12:59 +00:00
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
return 0;
|
2022-02-04 00:12:59 +00:00
|
|
|
} );
|
|
|
|
|
2021-12-06 23:07:46 +00:00
|
|
|
m_frame->OnModify();
|
2022-02-04 00:12:59 +00:00
|
|
|
}
|
2021-12-06 23:07:46 +00:00
|
|
|
else
|
2022-02-04 00:12:59 +00:00
|
|
|
{
|
2019-05-26 15:36:40 +00:00
|
|
|
m_frame->RollbackFromUndo();
|
2022-02-04 00:12:59 +00:00
|
|
|
}
|
2019-05-26 15:36:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
|
2019-05-26 15:36:40 +00:00
|
|
|
{
|
2019-06-04 20:59:59 +00:00
|
|
|
m_frame->ToPlotter( ID_GEN_PLOT );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Search( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->ToggleSearch();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-27 17:15:51 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::Find( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->ShowFindDialog();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BOARD_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-01-26 14:36:41 +00:00
|
|
|
m_frame->FindNext( aEvent.IsAction( &ACTIONS::findPrevious ) );
|
2021-08-27 17:15:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::BoardSetup( const TOOL_EVENT& aEvent )
|
2019-06-04 20:59:59 +00:00
|
|
|
{
|
2020-05-24 14:54:26 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ImportNetlist( const TOOL_EVENT& aEvent )
|
2019-06-04 20:59:59 +00:00
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ImportSpecctraSession( const TOOL_EVENT& aEvent )
|
2019-06-04 20:59:59 +00:00
|
|
|
{
|
|
|
|
wxString fullFileName = frame()->GetBoard()->GetFileName();
|
|
|
|
wxString path;
|
|
|
|
wxString name;
|
|
|
|
wxString ext;
|
|
|
|
|
|
|
|
wxFileName::SplitPath( fullFileName, &path, &name, &ext );
|
2024-03-21 01:52:19 +00:00
|
|
|
name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
2021-07-28 17:25:40 +00:00
|
|
|
fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
|
2024-03-21 01:52:19 +00:00
|
|
|
wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
|
2023-12-28 02:10:01 +00:00
|
|
|
FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
|
2021-07-28 17:25:40 +00:00
|
|
|
frame() );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
|
|
|
if( !fullFileName.IsEmpty() )
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ExportSpecctraDSN( const TOOL_EVENT& aEvent )
|
2019-06-04 20:59:59 +00:00
|
|
|
{
|
2019-08-03 03:03:03 +00:00
|
|
|
wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
|
|
|
|
wxFileName fn;
|
2019-06-04 20:59:59 +00:00
|
|
|
|
2019-08-03 03:03:03 +00:00
|
|
|
if( fullFileName.IsEmpty() )
|
|
|
|
{
|
|
|
|
fn = m_frame->GetBoard()->GetFileName();
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::SpecctraDsnFileExtension );
|
2019-08-03 03:03:03 +00:00
|
|
|
}
|
|
|
|
else
|
2021-09-13 16:18:58 +00:00
|
|
|
{
|
2019-08-03 03:03:03 +00:00
|
|
|
fn = fullFileName;
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2019-06-04 20:59:59 +00:00
|
|
|
|
2021-07-28 17:25:40 +00:00
|
|
|
fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
|
2023-12-28 02:10:01 +00:00
|
|
|
FILEEXT::SpecctraDsnFileExtension, FILEEXT::SpecctraDsnFileWildcard(),
|
2021-07-28 17:25:40 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
|
|
|
if( !fullFileName.IsEmpty() )
|
2019-08-03 03:03:03 +00:00
|
|
|
{
|
|
|
|
m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
|
2019-08-03 03:03:03 +00:00
|
|
|
}
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-28 12:37:54 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxCHECK( m_frame, 0 );
|
|
|
|
|
|
|
|
wxFileName fn = m_frame->Prj().GetProjectFullName();
|
|
|
|
|
|
|
|
// Use a different file extension for the board netlist so the schematic netlist file
|
2021-06-09 19:32:58 +00:00
|
|
|
// is accidentally overwritten.
|
2022-02-05 13:25:43 +00:00
|
|
|
fn.SetExt( wxT( "pcb_net" ) );
|
2021-03-28 12:37:54 +00:00
|
|
|
|
|
|
|
wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
|
2021-08-20 21:07:00 +00:00
|
|
|
_( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
|
2021-03-28 12:37:54 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
2022-06-12 03:09:47 +00:00
|
|
|
dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
|
2021-03-28 12:37:54 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( !fn.IsDirWritable() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( _( "Path `%s` is read only." ), fn.GetPath() );
|
|
|
|
wxMessageDialog( m_frame, msg, _( "I/O Error" ), wxOK | wxCENTER | wxICON_EXCLAMATION );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-12 03:09:47 +00:00
|
|
|
const LEGACYFILEDLG_NETLIST_OPTIONS* noh =
|
|
|
|
dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
|
2021-03-28 12:37:54 +00:00
|
|
|
wxCHECK( noh, 0 );
|
|
|
|
|
|
|
|
NETLIST netlist;
|
|
|
|
|
|
|
|
for( const FOOTPRINT* footprint : board()->Footprints() )
|
|
|
|
{
|
|
|
|
COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
|
|
|
|
footprint->GetValue(), footprint->GetPath(),
|
|
|
|
{ footprint->m_Uuid } );
|
|
|
|
|
|
|
|
for( const PAD* pad : footprint->Pads() )
|
|
|
|
{
|
|
|
|
const wxString& netname = pad->GetShortNetname();
|
|
|
|
|
|
|
|
if( !netname.IsEmpty() )
|
|
|
|
{
|
2021-08-23 23:10:21 +00:00
|
|
|
component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
|
2021-03-28 12:37:54 +00:00
|
|
|
pad->GetPinType() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 13:16:32 +00:00
|
|
|
nlohmann::ordered_map<wxString, wxString> fields;
|
2023-07-31 14:38:02 +00:00
|
|
|
for( PCB_FIELD* field : footprint->Fields() )
|
|
|
|
fields[field->GetCanonicalName()] = field->GetText();
|
|
|
|
|
|
|
|
component->SetFields( fields );
|
|
|
|
|
2021-03-28 12:37:54 +00:00
|
|
|
netlist.AddComponent( component );
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
|
|
|
|
|
|
|
|
netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::GenerateFabFiles( const TOOL_EVENT& aEvent )
|
2019-06-04 20:59:59 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2019-06-04 20:59:59 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
|
|
|
|
m_frame->ToPlotter( ID_GEN_PLOT_GERBER );
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
|
|
|
|
m_frame->GenFootprintsReport( dummy );
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
|
|
|
|
m_frame->GenD356File( dummy );
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
|
|
|
|
m_frame->RecreateBOMFileFromBoard( dummy );
|
2023-06-12 18:12:39 +00:00
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::generateIPC2581File ) )
|
|
|
|
m_frame->GenIPC2581File( dummy );
|
2019-06-04 20:59:59 +00:00
|
|
|
else
|
2022-02-05 13:25:43 +00:00
|
|
|
wxFAIL_MSG( wxT( "GenerateFabFiles(): unexpected request" ) );
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::RepairBoard( const TOOL_EVENT& aEvent )
|
2020-08-11 14:01:26 +00:00
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
wxString details;
|
2021-05-28 23:43:46 +00:00
|
|
|
bool quiet = aEvent.Parameter<bool>();
|
2020-08-11 14:01:26 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Repair duplicate IDs and missing nets.
|
2020-08-11 14:01:26 +00:00
|
|
|
std::set<KIID> ids;
|
|
|
|
int duplicates = 0;
|
|
|
|
|
2020-10-10 15:10:04 +00:00
|
|
|
auto processItem =
|
|
|
|
[&]( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( ids.count( aItem->m_Uuid ) )
|
|
|
|
{
|
|
|
|
duplicates++;
|
|
|
|
const_cast<KIID&>( aItem->m_Uuid ) = KIID();
|
|
|
|
}
|
|
|
|
|
|
|
|
ids.insert( aItem->m_Uuid );
|
|
|
|
|
|
|
|
BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
|
|
|
|
|
|
|
|
if( cItem && cItem->GetNetCode() )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* netinfo = cItem->GetNet();
|
2020-08-11 14:01:26 +00:00
|
|
|
|
2020-10-10 15:10:04 +00:00
|
|
|
if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
|
|
|
|
{
|
|
|
|
board()->Add( netinfo );
|
|
|
|
|
|
|
|
details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
|
|
|
|
netinfo->GetNetname() );
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-08-11 14:01:26 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// Footprint IDs are the most important, so give them the first crack at "claiming" a
|
|
|
|
// particular KIID.
|
2020-08-11 14:01:26 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : board()->Footprints() )
|
2020-10-14 23:37:26 +00:00
|
|
|
processItem( footprint );
|
2020-08-11 14:01:26 +00:00
|
|
|
|
|
|
|
// After that the principal use is for DRC marker pointers, which are most likely to pads
|
|
|
|
// or tracks.
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : board()->Footprints() )
|
2020-08-11 14:01:26 +00:00
|
|
|
{
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( pad );
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : board()->Tracks() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( track );
|
|
|
|
|
|
|
|
// From here out I don't think order matters much.
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : board()->Footprints() )
|
2020-08-11 14:01:26 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
processItem( &footprint->Reference() );
|
|
|
|
processItem( &footprint->Value() );
|
2020-08-11 14:01:26 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
for( BOARD_ITEM* item : footprint->GraphicalItems() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( item );
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : footprint->Zones() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( zone );
|
2020-10-10 15:10:04 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
for( PCB_GROUP* group : footprint->Groups() )
|
2020-10-10 15:10:04 +00:00
|
|
|
processItem( group );
|
2020-08-11 14:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* drawing : board()->Drawings() )
|
|
|
|
processItem( drawing );
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( zone );
|
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
for( PCB_MARKER* marker : board()->Markers() )
|
2020-08-11 14:01:26 +00:00
|
|
|
processItem( marker );
|
|
|
|
|
2020-10-10 15:10:04 +00:00
|
|
|
for( PCB_GROUP* group : board()->Groups() )
|
|
|
|
processItem( group );
|
|
|
|
|
2020-08-11 14:01:26 +00:00
|
|
|
if( duplicates )
|
|
|
|
{
|
|
|
|
errors += duplicates;
|
|
|
|
details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* Your test here
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* Inform the user
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( errors )
|
|
|
|
{
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
|
2021-05-28 23:43:46 +00:00
|
|
|
|
|
|
|
if( !quiet )
|
|
|
|
DisplayInfoMessage( m_frame, msg, details );
|
2020-08-11 14:01:26 +00:00
|
|
|
}
|
2021-05-28 23:43:46 +00:00
|
|
|
else if( !quiet )
|
2020-08-11 14:01:26 +00:00
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "No board problems found." ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::UpdatePCBFromSchematic( const TOOL_EVENT& aEvent )
|
2019-06-03 13:49:17 +00:00
|
|
|
{
|
|
|
|
NETLIST netlist;
|
|
|
|
|
2021-01-30 16:30:35 +00:00
|
|
|
if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
|
|
|
|
"schematic." ) ) )
|
2019-06-03 13:49:17 +00:00
|
|
|
{
|
|
|
|
DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
|
|
|
|
updateDialog.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB( const TOOL_EVENT& aEvent )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2022-02-05 13:25:43 +00:00
|
|
|
DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
|
|
|
|
"stand-alone mode. In order to create or update PCBs "
|
|
|
|
"from schematics, you must launch the KiCad project "
|
|
|
|
"manager and create a project." ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->RunEeschema();
|
|
|
|
KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
std::string payload;
|
2022-07-12 21:44:53 +00:00
|
|
|
|
|
|
|
if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
|
|
|
|
blocking_win->Close( true );
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
m_frame->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_UPDATE, payload, m_frame );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-03 13:49:17 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ShowEeschema( const TOOL_EVENT& aEvent )
|
2019-07-08 23:43:08 +00:00
|
|
|
{
|
|
|
|
m_frame->RunEeschema();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ToggleLayersManager( const TOOL_EVENT& aEvent )
|
2019-06-04 21:29:51 +00:00
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
|
2019-06-04 21:29:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-04 08:40:25 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-04 23:00:26 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ToggleNetInspector( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleNetInspector();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ToggleSearch( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::TogglePythonConsole( const TOOL_EVENT& aEvent )
|
2019-06-03 13:49:17 +00:00
|
|
|
{
|
|
|
|
m_frame->ScriptingConsoleEnableDisable();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
// Track & via size control
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
if( m_frame->ToolStackIsEmpty()
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
for( int i = 0; i < (int) bds.m_TrackWidthList.size(); ++i )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int candidate = bds.m_NetSettings->m_DefaultNetClass->GetTrackWidth();
|
|
|
|
|
|
|
|
if( i > 0 )
|
|
|
|
candidate = bds.m_TrackWidthList[ i ];
|
2021-11-12 17:50:14 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
if( candidate > track->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( track );
|
|
|
|
track->SetWidth( candidate );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 13:25:43 +00:00
|
|
|
commit.Push( wxT( "Increase Track Width" ) );
|
2020-12-02 16:23:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
|
|
|
|
|
|
|
|
if( routerTool && routerTool->IsToolActive()
|
2022-08-20 09:27:35 +00:00
|
|
|
&& routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
|
2020-12-02 16:23:59 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int widthIndex = (int) bds.GetDiffPairIndex() + 1;
|
2020-12-02 16:23:59 +00:00
|
|
|
|
|
|
|
// If we go past the last track width entry in the list, start over at the beginning
|
2023-10-01 20:01:18 +00:00
|
|
|
if( widthIndex >= (int) bds.m_DiffPairDimensionsList.size() )
|
2020-12-02 16:23:59 +00:00
|
|
|
widthIndex = 0;
|
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetDiffPairIndex( widthIndex );
|
|
|
|
bds.UseCustomDiffPairDimensions( false );
|
2020-12-02 16:23:59 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int widthIndex = (int) bds.GetTrackWidthIndex();
|
2021-12-15 15:48:34 +00:00
|
|
|
|
|
|
|
if( routerTool && routerTool->IsToolActive()
|
|
|
|
&& routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK
|
2023-10-01 20:01:18 +00:00
|
|
|
&& bds.m_UseConnectedTrackWidth && !bds.m_TempOverrideTrackWidth )
|
2021-12-15 15:48:34 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.m_TempOverrideTrackWidth = true;
|
2021-12-15 15:48:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
widthIndex++;
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-06-25 22:43:29 +00:00
|
|
|
// If we go past the last track width entry in the list, start over at the beginning
|
2023-10-01 20:01:18 +00:00
|
|
|
if( widthIndex >= (int) bds.m_TrackWidthList.size() )
|
2020-06-25 22:43:29 +00:00
|
|
|
widthIndex = 0;
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetTrackWidthIndex( widthIndex );
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
if( m_frame->ToolStackIsEmpty()
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
for( int i = (int) bds.m_TrackWidthList.size() - 1; i >= 0; --i )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int candidate = bds.m_NetSettings->m_DefaultNetClass->GetTrackWidth();
|
|
|
|
|
|
|
|
if( i > 0 )
|
|
|
|
candidate = bds.m_TrackWidthList[ i ];
|
2019-07-08 21:17:21 +00:00
|
|
|
|
|
|
|
if( candidate < track->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( track );
|
|
|
|
track->SetWidth( candidate );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 13:25:43 +00:00
|
|
|
commit.Push( wxT( "Decrease Track Width" ) );
|
2020-12-02 16:23:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
|
|
|
|
|
|
|
|
if( routerTool && routerTool->IsToolActive()
|
|
|
|
&& routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
|
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int widthIndex = (int) bds.GetDiffPairIndex() - 1;
|
2020-12-02 16:23:59 +00:00
|
|
|
|
|
|
|
// If we get to the lowest entry start over at the highest
|
|
|
|
if( widthIndex < 0 )
|
2023-10-01 20:01:18 +00:00
|
|
|
widthIndex = (int) bds.m_DiffPairDimensionsList.size() - 1;
|
2020-12-02 16:23:59 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetDiffPairIndex( widthIndex );
|
|
|
|
bds.UseCustomDiffPairDimensions( false );
|
2020-12-02 16:23:59 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int widthIndex = (int) bds.GetTrackWidthIndex();
|
2021-12-15 15:48:34 +00:00
|
|
|
|
|
|
|
if( routerTool && routerTool->IsToolActive()
|
|
|
|
&& routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK
|
2023-10-01 20:01:18 +00:00
|
|
|
&& bds.m_UseConnectedTrackWidth && !bds.m_TempOverrideTrackWidth )
|
2021-12-15 15:48:34 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.m_TempOverrideTrackWidth = true;
|
2021-12-15 15:48:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
widthIndex--;
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-12-02 16:23:59 +00:00
|
|
|
// If we get to the lowest entry start over at the highest
|
|
|
|
if( widthIndex < 0 )
|
2023-10-01 20:01:18 +00:00
|
|
|
widthIndex = (int) bds.m_TrackWidthList.size() - 1;
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetTrackWidthIndex( widthIndex );
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
if( m_frame->ToolStackIsEmpty()
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( item );
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
for( int i = 0; i < (int) bds.m_ViasDimensionsList.size(); ++i )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
VIA_DIMENSION dims( bds.m_NetSettings->m_DefaultNetClass->GetViaDiameter(),
|
|
|
|
bds.m_NetSettings->m_DefaultNetClass->GetViaDrill() );
|
|
|
|
|
|
|
|
if( i> 0 )
|
|
|
|
dims = bds.m_ViasDimensionsList[ i ];
|
|
|
|
|
|
|
|
if( dims.m_Diameter > via->GetWidth() )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
commit.Modify( via );
|
2023-10-01 20:01:18 +00:00
|
|
|
via->SetWidth( dims.m_Diameter );
|
|
|
|
via->SetDrill( dims.m_Drill );
|
2019-07-08 21:17:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 13:25:43 +00:00
|
|
|
commit.Push( wxT( "Increase Via Size" ) );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
int sizeIndex = (int) bds.GetViaSizeIndex() + 1;
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-06-25 22:43:29 +00:00
|
|
|
// If we go past the last via entry in the list, start over at the beginning
|
2023-10-01 20:01:18 +00:00
|
|
|
if( sizeIndex >= (int) bds.m_ViasDimensionsList.size() )
|
2020-06-25 22:43:29 +00:00
|
|
|
sizeIndex = 0;
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetViaSizeIndex( sizeIndex );
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
if( m_frame->ToolStackIsEmpty()
|
|
|
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( item );
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
for( int i = (int) bds.m_ViasDimensionsList.size() - 1; i >= 0; --i )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
VIA_DIMENSION dims( bds.m_NetSettings->m_DefaultNetClass->GetViaDiameter(),
|
|
|
|
bds.m_NetSettings->m_DefaultNetClass->GetViaDrill() );
|
|
|
|
|
|
|
|
if( i > 0 )
|
|
|
|
dims = bds.m_ViasDimensionsList[ i ];
|
2019-07-08 21:17:21 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
if( dims.m_Diameter < via->GetWidth() )
|
2019-07-08 21:17:21 +00:00
|
|
|
{
|
|
|
|
commit.Modify( via );
|
2023-10-01 20:01:18 +00:00
|
|
|
via->SetWidth( dims.m_Diameter );
|
|
|
|
via->SetDrill( dims.m_Drill );
|
2019-07-08 21:17:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( "Decrease Via Size" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-25 22:43:29 +00:00
|
|
|
int sizeIndex = 0; // Assume we only have a single via size entry
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-06-25 22:43:29 +00:00
|
|
|
// If there are more, cycle through them backwards
|
2023-10-01 20:01:18 +00:00
|
|
|
if( bds.m_ViasDimensionsList.size() > 0 )
|
2020-06-25 22:43:29 +00:00
|
|
|
{
|
2023-10-01 20:01:18 +00:00
|
|
|
sizeIndex = (int) bds.GetViaSizeIndex() - 1;
|
2020-06-25 22:43:29 +00:00
|
|
|
|
|
|
|
// If we get to the lowest entry start over at the highest
|
|
|
|
if( sizeIndex < 0 )
|
2023-10-01 20:01:18 +00:00
|
|
|
sizeIndex = (int) bds.m_ViasDimensionsList.size() - 1;
|
2020-06-25 22:43:29 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-10-01 20:01:18 +00:00
|
|
|
bds.SetViaSizeIndex( sizeIndex );
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
|
2019-07-08 21:17:21 +00:00
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-25 13:58:30 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inPlaceFootprint )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inPlaceFootprint );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
|
2022-05-16 22:41:30 +00:00
|
|
|
bool fromOtherCommand = fp != nullptr;
|
2015-03-10 15:58:26 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
2020-11-13 15:15:52 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
BOARD* board = getModel<BOARD>();
|
2022-05-16 22:41:30 +00:00
|
|
|
COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PushTool( aEvent );
|
2021-09-13 12:23:10 +00:00
|
|
|
|
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
|
|
|
};
|
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
auto cleanup =
|
|
|
|
[&] ()
|
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2022-05-16 22:41:30 +00:00
|
|
|
commit.Revert();
|
|
|
|
|
|
|
|
if( fromOtherCommand )
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
|
|
|
|
|
|
|
|
if( undo )
|
|
|
|
{
|
|
|
|
m_frame->PutDataInPreviousState( undo );
|
2022-11-11 17:09:25 +00:00
|
|
|
m_frame->ClearListAndDeleteItems( undo );
|
2022-05-16 22:41:30 +00:00
|
|
|
delete undo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fp = nullptr;
|
|
|
|
m_placingFootprint = false;
|
|
|
|
};
|
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
Activate();
|
2021-09-13 12:23:10 +00:00
|
|
|
// Must be done after Activate() so that it gets set into the correct context
|
|
|
|
controls->ShowCursor( true );
|
|
|
|
// Set initial cursor
|
|
|
|
setCursor();
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2017-09-17 17:49:06 +00:00
|
|
|
VECTOR2I cursorPos = controls->GetCursorPosition();
|
2022-05-16 22:41:30 +00:00
|
|
|
bool ignorePrimePosition = false;
|
2019-06-24 15:27:05 +00:00
|
|
|
bool reselect = false;
|
2017-12-14 16:10:06 +00:00
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
// Prime the pump
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp )
|
2017-05-18 17:21:30 +00:00
|
|
|
{
|
2021-09-29 15:39:43 +00:00
|
|
|
m_placingFootprint = true;
|
2022-05-16 22:41:30 +00:00
|
|
|
fp->SetPosition( cursorPos );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, fp );
|
|
|
|
m_toolMgr->PostAction( ACTIONS::refreshPreview );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2022-05-16 22:41:30 +00:00
|
|
|
else if( aEvent.HasPosition() )
|
2021-09-13 16:18:58 +00:00
|
|
|
{
|
2022-05-16 09:22:55 +00:00
|
|
|
m_toolMgr->PrimeTool( aEvent.Position() );
|
2021-09-13 16:18:58 +00:00
|
|
|
}
|
2022-05-16 22:41:30 +00:00
|
|
|
else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
|
|
|
|
{
|
|
|
|
m_toolMgr->PrimeTool( { 0, 0 } );
|
|
|
|
ignorePrimePosition = true;
|
|
|
|
}
|
2018-01-19 13:20:15 +00:00
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2021-05-09 19:17:01 +00:00
|
|
|
cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( reselect && fp )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, fp );
|
2018-01-19 13:20:15 +00:00
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
if( evt->IsCancelInteractive() || ( fp && evt->IsAction( &ACTIONS::undo ) ) )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp )
|
2021-09-29 15:39:43 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
2021-09-29 15:39:43 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2019-07-01 21:01:33 +00:00
|
|
|
break;
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp )
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
|
|
|
|
|
|
|
if( evt->IsMoveTool() )
|
2019-06-24 15:27:05 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
// leave ourselves on the stack so we come back after the move
|
2019-06-27 11:47:24 +00:00
|
|
|
break;
|
2019-06-24 15:27:05 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
|
|
|
{
|
2022-09-14 17:31:56 +00:00
|
|
|
frame()->PopTool( aEvent );
|
2015-03-10 15:58:26 +00:00
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
if( !fp )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
// Pick the footprint to be placed
|
2023-09-26 17:31:45 +00:00
|
|
|
fp = m_frame->SelectFootprintFromLibrary();
|
2016-08-16 14:56:20 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( fp == nullptr )
|
2015-03-10 15:58:26 +00:00
|
|
|
continue;
|
|
|
|
|
2022-05-16 22:41:30 +00:00
|
|
|
// If we started with a hotkey which has a position then warp back to that.
|
|
|
|
// Otherwise update to the current mouse position pinned inside the autoscroll
|
|
|
|
// boundaries.
|
|
|
|
if( evt->IsPrime() && !ignorePrimePosition )
|
|
|
|
{
|
|
|
|
cursorPos = evt->Position();
|
|
|
|
getViewControls()->WarpMouseCursor( cursorPos, true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getViewControls()->PinCursorInsideNonAutoscrollArea( true );
|
|
|
|
cursorPos = getViewControls()->GetMousePosition();
|
|
|
|
}
|
|
|
|
|
2021-09-29 15:39:43 +00:00
|
|
|
m_placingFootprint = true;
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
fp->SetLink( niluuid );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
2023-01-02 19:49:22 +00:00
|
|
|
fp->SetFlags( IS_NEW ); // whatever
|
2019-01-18 03:17:34 +00:00
|
|
|
|
2019-04-14 18:25:32 +00:00
|
|
|
// Set parent so that clearance can be loaded
|
2020-10-14 23:37:26 +00:00
|
|
|
fp->SetParent( board );
|
2023-03-13 20:25:27 +00:00
|
|
|
board->UpdateUserUnits( fp, m_frame->GetCanvas()->GetView() );
|
2019-04-14 18:25:32 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
for( PAD* pad : fp->Pads() )
|
2021-01-11 19:23:26 +00:00
|
|
|
{
|
2022-07-24 15:49:46 +00:00
|
|
|
pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
|
2021-01-25 01:19:35 +00:00
|
|
|
|
|
|
|
// Pads in the library all have orphaned nets. Replace with Default.
|
2020-10-22 10:48:39 +00:00
|
|
|
pad->SetNetCode( 0 );
|
2021-01-11 19:23:26 +00:00
|
|
|
}
|
2020-10-22 10:48:39 +00:00
|
|
|
|
2019-01-18 01:50:50 +00:00
|
|
|
// Put it on FRONT layer,
|
|
|
|
// (Can be stored flipped if the lib is an archive built from a board)
|
2020-10-14 23:37:26 +00:00
|
|
|
if( fp->IsFlipped() )
|
2022-07-24 15:49:46 +00:00
|
|
|
fp->Flip( fp->GetPosition(), m_frame->GetPcbNewSettings()->m_FlipLeftRight );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
2022-01-13 17:27:36 +00:00
|
|
|
fp->SetOrientation( ANGLE_0 );
|
2022-05-16 22:41:30 +00:00
|
|
|
fp->SetPosition( cursorPos );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
// Fill this in since it won't be synced from a symbol
|
|
|
|
fp->GetField( FOOTPRINT_FIELD )->SetText( UnescapeString( fp->GetFPIDAsString() ) );
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
commit.Add( fp );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, fp );
|
2021-12-07 17:27:17 +00:00
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->PostAction( ACTIONS::refreshPreview );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Place a Footprint" ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
fp = nullptr; // to indicate that there is no footprint that we currently modify
|
2021-09-29 15:39:43 +00:00
|
|
|
m_placingFootprint = false;
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-11 01:15:16 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2018-02-11 01:15:16 +00:00
|
|
|
}
|
2020-10-14 23:37:26 +00:00
|
|
|
else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2022-05-16 22:41:30 +00:00
|
|
|
fp->SetPosition( cursorPos );
|
2019-05-19 21:04:04 +00:00
|
|
|
selection().SetReferencePoint( cursorPos );
|
2020-12-08 16:52:30 +00:00
|
|
|
getView()->Update( &selection() );
|
|
|
|
getView()->Update( fp );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
2020-10-14 23:37:26 +00:00
|
|
|
else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
|
2018-01-19 13:20:15 +00:00
|
|
|
{
|
|
|
|
// Calling 'Properties' action clears the selection, so we need to restore it
|
|
|
|
reselect = true;
|
|
|
|
}
|
2023-07-15 16:37:17 +00:00
|
|
|
else if( fp && ( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
|
|
|
|
|| evt->IsAction( &ACTIONS::redo ) ) )
|
2022-11-14 23:39:08 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-11-19 20:08:58 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-11-19 20:08:58 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// Enable autopanning and cursor capture only when there is a footprint to be placed
|
2021-06-20 10:02:44 +00:00
|
|
|
controls->SetAutoPan( fp != nullptr );
|
|
|
|
controls->CaptureCursor( fp != nullptr );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
controls->SetAutoPan( false );
|
|
|
|
controls->CaptureCursor( false );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ToggleLockSelected( const TOOL_EVENT& aEvent )
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
return modifyLockSelected( TOGGLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::LockSelected( const TOOL_EVENT& aEvent )
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
return modifyLockSelected( ON );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::UnlockSelected( const TOOL_EVENT& aEvent )
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
return modifyLockSelected( OFF );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
|
2015-09-03 15:35:41 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
const PCB_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
2015-09-03 15:35:41 +00:00
|
|
|
|
2016-05-09 08:29:06 +00:00
|
|
|
if( selection.Empty() )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor );
|
2015-09-03 15:35:41 +00:00
|
|
|
|
2020-12-09 22:09:34 +00:00
|
|
|
// Resolve TOGGLE mode
|
|
|
|
if( aMode == TOGGLE )
|
|
|
|
{
|
|
|
|
aMode = ON;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
2020-12-09 22:09:34 +00:00
|
|
|
|
2023-07-13 10:24:33 +00:00
|
|
|
if( board_item && board_item->IsLocked() )
|
2020-12-09 22:09:34 +00:00
|
|
|
{
|
|
|
|
aMode = OFF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-20 15:26:49 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2015-09-03 15:35:41 +00:00
|
|
|
{
|
2023-07-13 10:24:33 +00:00
|
|
|
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
|
|
|
|
wxCHECK2( board_item, continue );
|
2019-08-20 15:26:49 +00:00
|
|
|
|
2023-12-15 17:36:42 +00:00
|
|
|
PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( board_item->GetParentGroup() );
|
|
|
|
|
2023-12-15 21:04:33 +00:00
|
|
|
if( generator && commit.GetStatus( generator ) != CHT_MODIFY )
|
|
|
|
{
|
2023-12-15 17:36:42 +00:00
|
|
|
commit.Modify( generator );
|
|
|
|
|
2023-12-15 21:04:33 +00:00
|
|
|
if( aMode == ON )
|
|
|
|
generator->SetLocked( true );
|
|
|
|
else
|
|
|
|
generator->SetLocked( false );
|
|
|
|
}
|
|
|
|
|
2019-08-20 15:26:49 +00:00
|
|
|
commit.Modify( board_item );
|
2016-05-09 08:29:06 +00:00
|
|
|
|
2020-12-09 22:09:34 +00:00
|
|
|
if( aMode == ON )
|
2023-12-15 21:04:33 +00:00
|
|
|
board_item->SetLocked( true );
|
2020-12-09 22:09:34 +00:00
|
|
|
else
|
2023-12-15 21:04:33 +00:00
|
|
|
board_item->SetLocked( false );
|
2015-09-03 15:35:41 +00:00
|
|
|
}
|
|
|
|
|
2023-12-15 17:36:42 +00:00
|
|
|
if( !commit.Empty() )
|
2019-06-10 22:42:02 +00:00
|
|
|
{
|
2020-12-10 00:07:12 +00:00
|
|
|
commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
|
2021-05-26 15:03:04 +00:00
|
|
|
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedEvent );
|
2016-05-09 08:29:06 +00:00
|
|
|
m_frame->OnModify();
|
2019-06-10 22:42:02 +00:00
|
|
|
}
|
2015-09-03 15:35:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-21 19:54:54 +00:00
|
|
|
static bool mergeZones( EDA_DRAW_FRAME* aFrame, BOARD_COMMIT& aCommit,
|
|
|
|
std::vector<ZONE*>& aOriginZones, std::vector<ZONE*>& aMergedZones )
|
2016-11-04 21:29:47 +00:00
|
|
|
{
|
2021-02-22 23:43:31 +00:00
|
|
|
aCommit.Modify( aOriginZones[0] );
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
for( unsigned int i = 1; i < aOriginZones.size(); i++ )
|
2016-11-04 21:29:47 +00:00
|
|
|
{
|
2017-03-07 12:06:00 +00:00
|
|
|
aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2016-11-04 21:29:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
|
2016-11-04 21:29:47 +00:00
|
|
|
|
2022-01-21 19:54:54 +00:00
|
|
|
// We should have one polygon, possibly with holes. If we end up with two polygons (either
|
|
|
|
// because the intersection was a single point or because the intersection was within one of
|
|
|
|
// the zone's holes) then we can't merge.
|
|
|
|
if( aOriginZones[0]->Outline()->IsSelfIntersecting()
|
|
|
|
|| aOriginZones[0]->Outline()->OutlineCount() > 1 )
|
2016-11-04 21:29:47 +00:00
|
|
|
{
|
2022-01-21 19:54:54 +00:00
|
|
|
DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
|
|
|
|
aCommit.Revert();
|
2016-11-04 21:29:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
for( unsigned int i = 1; i < aOriginZones.size(); i++ )
|
2016-11-04 21:29:47 +00:00
|
|
|
aCommit.Remove( aOriginZones[i] );
|
|
|
|
|
|
|
|
aMergedZones.push_back( aOriginZones[0] );
|
|
|
|
|
|
|
|
aOriginZones[0]->SetLocalFlags( 1 );
|
2020-08-07 14:04:34 +00:00
|
|
|
aOriginZones[0]->HatchBorder();
|
2017-11-23 16:20:27 +00:00
|
|
|
aOriginZones[0]->CacheTriangulation();
|
2016-11-04 21:29:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-12-08 22:41:47 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
|
2015-06-19 15:32:33 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
2015-06-19 15:32:33 +00:00
|
|
|
|
|
|
|
if( selection.Size() < 2 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int netcode = -1;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* firstZone = nullptr;
|
|
|
|
std::vector<ZONE*> toMerge, merged;
|
2016-11-04 21:29:47 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2015-06-19 15:32:33 +00:00
|
|
|
{
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* curr_area = dynamic_cast<ZONE*>( item );
|
2015-06-19 15:32:33 +00:00
|
|
|
|
|
|
|
if( !curr_area )
|
|
|
|
continue;
|
|
|
|
|
2016-11-04 21:29:47 +00:00
|
|
|
if( !firstZone )
|
|
|
|
firstZone = curr_area;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2016-11-04 21:29:47 +00:00
|
|
|
netcode = curr_area->GetNetCode();
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
if( firstZone->GetNetCode() != netcode )
|
2022-01-21 19:54:54 +00:00
|
|
|
{
|
|
|
|
wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
|
2018-05-04 12:01:26 +00:00
|
|
|
continue;
|
2022-01-21 19:54:54 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2022-03-01 14:53:35 +00:00
|
|
|
if( curr_area->GetAssignedPriority() != firstZone->GetAssignedPriority() )
|
2022-01-21 19:54:54 +00:00
|
|
|
{
|
|
|
|
wxLogMessage( _( "Some zone priorities did not match and were not merged." ) );
|
2018-05-04 12:01:26 +00:00
|
|
|
continue;
|
2022-01-21 19:54:54 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
|
2022-01-21 19:54:54 +00:00
|
|
|
{
|
|
|
|
wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
|
2018-05-04 12:01:26 +00:00
|
|
|
continue;
|
2022-01-21 19:54:54 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2022-04-23 20:29:46 +00:00
|
|
|
if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
|
2022-01-21 19:54:54 +00:00
|
|
|
{
|
|
|
|
wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
|
2018-05-04 12:01:26 +00:00
|
|
|
continue;
|
2022-01-21 19:54:54 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2022-04-29 17:29:28 +00:00
|
|
|
bool intersects = curr_area == firstZone;
|
|
|
|
|
|
|
|
for( ZONE* candidate : toMerge )
|
|
|
|
{
|
|
|
|
if( intersects )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( board->TestZoneIntersection( curr_area, candidate ) )
|
|
|
|
intersects = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !intersects )
|
2022-01-21 19:54:54 +00:00
|
|
|
{
|
|
|
|
wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
|
2018-05-04 12:01:26 +00:00
|
|
|
continue;
|
2022-01-21 19:54:54 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
toMerge.push_back( curr_area );
|
2015-06-19 15:32:33 +00:00
|
|
|
}
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2022-04-29 17:29:28 +00:00
|
|
|
if( !toMerge.empty() )
|
2015-06-19 15:32:33 +00:00
|
|
|
{
|
2022-04-29 17:29:28 +00:00
|
|
|
if( mergeZones( m_frame, commit, toMerge, merged ) )
|
|
|
|
{
|
2023-07-15 16:37:17 +00:00
|
|
|
commit.Push( wxT( "Merge Zones" ) );
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2022-04-29 17:29:28 +00:00
|
|
|
for( EDA_ITEM* item : merged )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, item );
|
2022-04-29 17:29:28 +00:00
|
|
|
}
|
2015-06-19 15:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::ZoneDuplicate( const TOOL_EVENT& aEvent )
|
2017-02-06 03:45:56 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
const PCB_SELECTION& selection = selTool->GetSelection();
|
2017-02-06 03:45:56 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
// because this pops up the zone editor, it would be confusing to handle multiple zones,
|
|
|
|
// so just handle single selections containing exactly one zone
|
2017-02-06 03:45:56 +00:00
|
|
|
if( selection.Size() != 1 )
|
|
|
|
return 0;
|
|
|
|
|
2023-06-24 17:19:44 +00:00
|
|
|
ZONE* oldZone = dynamic_cast<ZONE*>( selection[0] );
|
2017-02-06 03:45:56 +00:00
|
|
|
|
|
|
|
if( !oldZone )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ZONE_SETTINGS zoneSettings;
|
|
|
|
zoneSettings << *oldZone;
|
2018-05-25 14:56:04 +00:00
|
|
|
int dialogResult;
|
2017-02-06 03:45:56 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( oldZone->GetIsRuleArea() )
|
|
|
|
dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
|
2017-02-06 03:45:56 +00:00
|
|
|
else if( oldZone->IsOnCopperLayer() )
|
2018-05-25 14:56:04 +00:00
|
|
|
dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
|
2017-02-06 03:45:56 +00:00
|
|
|
else
|
2018-05-25 14:56:04 +00:00
|
|
|
dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
|
|
|
|
|
|
|
|
if( dialogResult != wxID_OK )
|
|
|
|
return 0;
|
2017-02-06 03:45:56 +00:00
|
|
|
|
|
|
|
// duplicate the zone
|
2018-05-25 14:56:04 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
|
2018-05-25 14:56:04 +00:00
|
|
|
newZone->ClearSelected();
|
|
|
|
newZone->UnFill();
|
|
|
|
zoneSettings.ExportSetting( *newZone );
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// If the new zone is on the same layer(s) as the initial zone,
|
2018-05-25 14:56:04 +00:00
|
|
|
// offset it a bit so it can more easily be picked.
|
2023-10-21 14:06:50 +00:00
|
|
|
if( oldZone->GetLayerSet() == zoneSettings.m_Layers )
|
2023-02-19 03:40:07 +00:00
|
|
|
newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
|
2018-05-25 14:56:04 +00:00
|
|
|
|
|
|
|
commit.Add( newZone.release() );
|
2023-07-15 16:37:17 +00:00
|
|
|
commit.Push( _( "Duplicate Zone" ) );
|
2017-02-06 03:45:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-19 15:00:35 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::CrossProbeToSch( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
doCrossProbePcbToSch( aEvent, false );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BOARD_EDITOR_CONTROL::ExplicitCrossProbeToSch( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
doCrossProbePcbToSch( aEvent, true );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BOARD_EDITOR_CONTROL::doCrossProbePcbToSch( const TOOL_EVENT& aEvent, bool aForce )
|
|
|
|
{
|
|
|
|
// Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
|
|
|
|
if( m_frame->m_probingSchToPcb )
|
|
|
|
return;
|
|
|
|
|
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
const PCB_SELECTION& selection = selTool->GetSelection();
|
|
|
|
EDA_ITEM* focusItem = nullptr;
|
|
|
|
|
|
|
|
if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
|
|
|
|
focusItem = selection.GetLastAddedItem();
|
|
|
|
|
|
|
|
m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
|
|
|
|
|
|
|
|
// Update 3D viewer highlighting
|
|
|
|
m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
|
|
|
|
const PCB_SELECTION& selection = selectionTool->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
// Iterate from the back so we don't have to worry about removals.
|
|
|
|
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
|
|
|
|
aCollector.Remove( aCollector[ i ] );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true /* prompt user regarding locked items */ );
|
|
|
|
|
2022-09-28 23:57:21 +00:00
|
|
|
int netCode = -1;
|
2022-09-03 18:29:02 +00:00
|
|
|
wxString netName;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
|
|
|
|
|
|
|
|
if( !net->HasAutoGeneratedNetname() )
|
|
|
|
{
|
|
|
|
netCode = net->GetNetCode();
|
|
|
|
netName = net->GetNetname();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( netName.IsEmpty() )
|
|
|
|
{
|
2022-09-29 00:09:43 +00:00
|
|
|
m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
|
2022-09-03 18:29:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectionTool->ClearSelection();
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectNet, netCode );
|
2022-09-03 20:33:56 +00:00
|
|
|
canvas()->ForceRefresh();
|
2022-09-03 18:29:02 +00:00
|
|
|
|
2022-09-03 20:33:56 +00:00
|
|
|
DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates(),
|
2022-09-12 19:51:15 +00:00
|
|
|
[this]( const std::vector<wxString>& aNetNames )
|
2022-09-03 20:33:56 +00:00
|
|
|
{
|
2022-09-12 19:51:15 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
selTool->ClearSelection();
|
2022-09-03 20:33:56 +00:00
|
|
|
|
2022-09-05 14:50:03 +00:00
|
|
|
for( const wxString& curr_netName : aNetNames )
|
2022-09-03 20:33:56 +00:00
|
|
|
{
|
2022-09-05 14:50:03 +00:00
|
|
|
int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
|
2022-09-03 20:33:56 +00:00
|
|
|
|
2022-09-05 14:50:03 +00:00
|
|
|
if( curr_netCode > 0 )
|
2022-09-12 19:51:15 +00:00
|
|
|
selTool->SelectAllItemsOnNet( curr_netCode );
|
2022-09-03 20:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
canvas()->ForceRefresh();
|
2022-11-22 14:53:24 +00:00
|
|
|
m_frame->UpdateMsgPanel();
|
2022-09-03 20:33:56 +00:00
|
|
|
} );
|
2022-09-03 18:29:02 +00:00
|
|
|
|
2022-11-22 14:24:20 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2022-11-22 14:53:24 +00:00
|
|
|
{
|
2022-11-22 14:24:20 +00:00
|
|
|
board()->SynchronizeNetsAndNetClasses( false );
|
2022-12-27 01:57:58 +00:00
|
|
|
// Refresh UI that depends on netclasses, such as the properties panel
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified );
|
2022-11-22 14:53:24 +00:00
|
|
|
}
|
2022-09-03 18:29:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
|
2020-06-27 11:57:40 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
const PCB_SELECTION& selection = selTool->RequestSelection( EDIT_TOOL::FootprintFilter );
|
2020-06-27 11:57:40 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
2024-02-03 13:43:41 +00:00
|
|
|
{
|
|
|
|
// Giant hack: by default we assign Edit Table to the same hotkey, so give the table
|
|
|
|
// tool a chance to handle it if we can't.
|
|
|
|
if( PCB_EDIT_TABLE_TOOL* tableTool = m_toolMgr->GetTool<PCB_EDIT_TABLE_TOOL>() )
|
|
|
|
tableTool->EditTable( aEvent );
|
|
|
|
|
2020-06-27 11:57:40 +00:00
|
|
|
return 0;
|
2024-02-03 13:43:41 +00:00
|
|
|
}
|
2020-06-27 11:57:40 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* fp = selection.FirstOfKind<FOOTPRINT>();
|
2020-06-27 11:57:40 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
if( !fp )
|
2020-06-27 11:57:40 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
|
|
|
|
auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
|
|
|
|
|
2021-10-25 16:23:22 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::editFpInFpEditor ) )
|
|
|
|
editor->LoadFootprintFromBoard( fp );
|
|
|
|
else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
|
|
|
|
editor->LoadFootprintFromLibrary( fp->GetFPID() );
|
2020-06-27 11:57:40 +00:00
|
|
|
|
|
|
|
editor->Show( true );
|
|
|
|
editor->Raise(); // Iconize( false );
|
|
|
|
|
|
|
|
if( selection.IsHover() )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2020-06-27 11:57:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
|
|
|
EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
|
2015-06-18 15:51:51 +00:00
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
|
2022-01-02 02:06:40 +00:00
|
|
|
originViewItem->SetPosition( aPosition );
|
2015-06-18 15:51:54 +00:00
|
|
|
aView->MarkDirty();
|
2018-01-24 21:27:56 +00:00
|
|
|
aFrame->OnModify();
|
2015-06-18 15:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
2015-06-18 15:51:51 +00:00
|
|
|
{
|
2023-11-20 12:23:16 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::drillResetOrigin ) )
|
|
|
|
{
|
|
|
|
m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
|
|
|
|
DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), VECTOR2D( 0, 0 ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
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->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_placeOrigin.get(), UNDO_REDO::DRILLORIGIN );
|
2019-06-24 15:27:05 +00:00
|
|
|
DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
|
|
|
|
return false; // drill origin is a one-shot; don't continue with tool
|
|
|
|
} );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
|
2019-07-15 12:15:58 +00:00
|
|
|
|
2015-06-18 15:51:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-28 14:58:41 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
void BOARD_EDITOR_CONTROL::setTransitions()
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
2022-04-24 16:38:34 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::SaveCopy, ACTIONS::saveCopy.MakeEvent() );
|
2022-04-17 17:14:50 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::Revert, ACTIONS::revert.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
|
|
|
|
2022-09-25 15:56:41 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::Search, ACTIONS::showSearch.MakeEvent() );
|
2021-08-27 17:15:51 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() );
|
2023-01-26 14:36:41 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::FindNext, ACTIONS::findPrevious.MakeEvent() );
|
2021-08-27 17:15:51 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::BoardSetup, PCB_ACTIONS::boardSetup.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ImportNetlist, PCB_ACTIONS::importNetlist.MakeEvent() );
|
2023-07-15 16:37:17 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ImportSpecctraSession, PCB_ACTIONS::importSpecctraSession.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ExportSpecctraDSN, PCB_ACTIONS::exportSpecctraDSN.MakeEvent() );
|
2021-03-29 13:04:41 +00:00
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame &&
|
|
|
|
m_frame->GetExportNetlistAction() )
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ExportNetlist, m_frame->GetExportNetlistAction()->MakeEvent() );
|
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateDrillFiles, PCB_ACTIONS::generateDrillFiles.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateGerbers.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::GeneratePosFile, PCB_ACTIONS::generatePosFile.MakeEvent() );
|
2023-07-15 16:37:17 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateReportFile.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateD356File.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateBOM.MakeEvent() );
|
2023-06-12 18:12:39 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateIPC2581File.MakeEvent() );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
// Track & via size control
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::TrackWidthInc, PCB_ACTIONS::trackWidthInc.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::TrackWidthDec, PCB_ACTIONS::trackWidthDec.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ViaSizeInc, PCB_ACTIONS::viaSizeInc.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ViaSizeDec, PCB_ACTIONS::viaSizeDec.MakeEvent() );
|
2014-07-09 14:57:01 +00:00
|
|
|
|
|
|
|
// Zone actions
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ZoneMerge, PCB_ACTIONS::zoneMerge.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ZoneDuplicate, PCB_ACTIONS::zoneDuplicate.MakeEvent() );
|
2015-02-14 20:52:22 +00:00
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
// Placing tools
|
2021-01-31 14:08:05 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::PlaceFootprint, PCB_ACTIONS::placeFootprint.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillOrigin.MakeEvent() );
|
2023-11-20 12:23:16 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillResetOrigin.MakeEvent() );
|
2020-06-27 11:57:40 +00:00
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::EditFpInFpEditor, PCB_ACTIONS::editFpInFpEditor.MakeEvent() );
|
2021-10-25 16:23:22 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::EditFpInFpEditor, PCB_ACTIONS::editLibFpInFpEditor.MakeEvent() );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2022-07-19 15:00:35 +00:00
|
|
|
// Cross-select
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::CrossProbeToSch, EVENTS::PointSelectedEvent );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::CrossProbeToSch, EVENTS::SelectedEvent );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::CrossProbeToSch, EVENTS::UnselectedEvent );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::CrossProbeToSch, EVENTS::ClearedEvent );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ExplicitCrossProbeToSch, PCB_ACTIONS::selectOnSchematic.MakeEvent() );
|
|
|
|
|
2015-06-18 15:51:50 +00:00
|
|
|
// Other
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ToggleLockSelected, PCB_ACTIONS::toggleLock.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::LockSelected, PCB_ACTIONS::lock.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::UnlockSelected, PCB_ACTIONS::unlock.MakeEvent() );
|
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::AssignNetclass, PCB_ACTIONS::assignNetClass.MakeEvent() );
|
|
|
|
|
2023-07-15 16:37:17 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::UpdatePCBFromSchematic, ACTIONS::updatePcbFromSchematic.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB, ACTIONS::updateSchematicFromPcb.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ShowEeschema, PCB_ACTIONS::showEeschema.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
|
2023-06-21 01:57:20 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() );
|
2024-03-04 23:00:26 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ToggleNetInspector, PCB_ACTIONS::showNetInspector.MakeEvent() );
|
2022-11-25 14:11:20 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::ToggleSearch, PCB_ACTIONS::showSearch.MakeEvent() );
|
2020-12-16 13:31:32 +00:00
|
|
|
Go( &BOARD_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
|
|
|
|
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
2015-03-10 15:58:26 +00:00
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000;
|