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
|
2020-02-20 12:11:04 +00:00
|
|
|
* Copyright (C) 2014-2020 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
|
|
|
|
*/
|
|
|
|
#include "pcb_editor_control.h"
|
2017-01-09 17:29:40 +00:00
|
|
|
#include "drawing_tool.h"
|
2019-12-05 13:43:55 +00:00
|
|
|
#include "pcb_actions.h"
|
2019-05-20 10:23:32 +00:00
|
|
|
#include "pcbnew_picker_tool.h"
|
2019-12-05 13:43:55 +00:00
|
|
|
#include "selection_tool.h"
|
2020-06-27 11:57:40 +00:00
|
|
|
#include "edit_tool.h"
|
2020-09-02 01:09:34 +00:00
|
|
|
#include "tool/tool_event.h"
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
2014-07-09 11:50:27 +00:00
|
|
|
#include <class_board.h>
|
2020-08-12 11:23:30 +00:00
|
|
|
#include <class_pcb_group.h>
|
2015-03-10 15:58:26 +00:00
|
|
|
#include <class_module.h>
|
2017-10-31 15:38:10 +00:00
|
|
|
#include <class_pcb_target.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <class_track.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <class_zone.h>
|
2020-08-11 14:01:26 +00:00
|
|
|
#include <class_marker_pcb.h>
|
2015-06-18 15:51:50 +00:00
|
|
|
#include <collectors.h>
|
2020-01-29 16:33:57 +00:00
|
|
|
#include <confirm.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <cstdint>
|
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>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <functional>
|
2019-06-04 20:59:59 +00:00
|
|
|
#include <gestfich.h>
|
2020-01-29 16:33:57 +00:00
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <kiway.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
|
|
|
#include <origin_viewitem.h>
|
|
|
|
#include <painter.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcbnew_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#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>
|
|
|
|
#include <tools/tool_event_utils.h>
|
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <view/view_group.h>
|
2019-06-04 20:59:59 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <ws_proxy_undo_item.h>
|
2020-06-27 11:57:40 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
|
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
|
|
|
{
|
2015-04-02 14:09:48 +00:00
|
|
|
SetIcon( add_zone_xpm );
|
2017-01-23 13:47:49 +00:00
|
|
|
SetTitle( _( "Zones" ) );
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
Add( PCB_ACTIONS::zoneFill );
|
|
|
|
Add( PCB_ACTIONS::zoneFillAll );
|
|
|
|
Add( PCB_ACTIONS::zoneUnfill );
|
|
|
|
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-11-23 16:20:27 +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
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
class LOCK_CONTEXT_MENU : public ACTION_MENU
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-06-15 00:29:42 +00:00
|
|
|
LOCK_CONTEXT_MENU() :
|
|
|
|
ACTION_MENU( true )
|
2016-05-09 08:29:06 +00:00
|
|
|
{
|
|
|
|
SetIcon( locked_xpm );
|
2017-01-23 13:47:49 +00:00
|
|
|
SetTitle( _( "Locking" ) );
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
Add( PCB_ACTIONS::lock );
|
|
|
|
Add( PCB_ACTIONS::unlock );
|
|
|
|
Add( PCB_ACTIONS::toggleLock );
|
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
|
|
|
{
|
|
|
|
return new LOCK_CONTEXT_MENU();
|
|
|
|
}
|
2016-05-09 08:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
class GROUP_CONTEXT_MENU : public ACTION_MENU
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GROUP_CONTEXT_MENU( ) : ACTION_MENU( true )
|
|
|
|
{
|
|
|
|
SetIcon( locked_xpm ); // fixme
|
|
|
|
SetTitle( _( "Grouping" ) );
|
|
|
|
|
|
|
|
Add( PCB_ACTIONS::groupCreate );
|
|
|
|
Add( PCB_ACTIONS::groupUngroup );
|
|
|
|
Add( PCB_ACTIONS::groupMerge );
|
|
|
|
Add( PCB_ACTIONS::groupRemoveItems );
|
|
|
|
Add( PCB_ACTIONS::groupFlatten );
|
|
|
|
Add( PCB_ACTIONS::groupEnter );
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTION_MENU* create() const override
|
|
|
|
{
|
|
|
|
return new GROUP_CONTEXT_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void update() override
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
|
|
|
|
BOARD* board = selTool->GetBoard();
|
|
|
|
|
|
|
|
const auto& selection = selTool->GetSelection();
|
|
|
|
|
|
|
|
wxString check = board->GroupsSanityCheck();
|
|
|
|
wxCHECK_RET( check == wxEmptyString, _( "Group is in inconsistent state: " ) + check );
|
|
|
|
|
|
|
|
BOARD::GroupLegalOpsField legalOps = board->GroupLegalOps( selection );
|
|
|
|
|
2020-07-23 23:47:19 +00:00
|
|
|
Enable( PCB_ACTIONS::groupCreate.GetUIId(), legalOps.create );
|
|
|
|
Enable( PCB_ACTIONS::groupMerge.GetUIId(), legalOps.merge );
|
|
|
|
Enable( PCB_ACTIONS::groupUngroup.GetUIId(), legalOps.ungroup );
|
|
|
|
Enable( PCB_ACTIONS::groupRemoveItems.GetUIId(), legalOps.removeItems );
|
|
|
|
Enable( PCB_ACTIONS::groupFlatten.GetUIId(), legalOps.flatten );
|
|
|
|
Enable( PCB_ACTIONS::groupEnter.GetUIId(), legalOps.enter );
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.EditorControl" ),
|
2019-06-05 19:15:57 +00:00
|
|
|
m_frame( nullptr )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2019-12-05 13:43:55 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
|
|
|
|
{
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
2015-06-18 15:51:54 +00:00
|
|
|
|
|
|
|
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
|
|
|
|
{
|
2020-07-01 12:28:10 +00:00
|
|
|
m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONTROL::Init()
|
|
|
|
{
|
2018-02-11 01:15:16 +00:00
|
|
|
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
|
2019-06-24 15:27:05 +00:00
|
|
|
return ( !m_frame->ToolStackIsEmpty() );
|
2018-02-11 01:15:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
|
2019-06-24 15:27:05 +00:00
|
|
|
return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
|
2018-02-11 01:15:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
|
2019-06-24 15:27:05 +00:00
|
|
|
return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
|
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
|
|
|
|
2017-01-12 10:07:52 +00:00
|
|
|
auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
|
|
|
|
zoneMenu->SetTool( this );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2017-01-12 10:07:52 +00:00
|
|
|
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
|
|
|
|
lockMenu->SetTool( this );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
auto groupMenu = std::make_shared<GROUP_CONTEXT_MENU>();
|
|
|
|
groupMenu->SetTool( this );
|
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
// Add the PCB control menus to relevant other tools
|
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
|
|
|
|
if( selTool )
|
|
|
|
{
|
2017-01-12 10:07:52 +00:00
|
|
|
auto& toolMenu = selTool->GetToolMenu();
|
|
|
|
auto& 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
|
|
|
|
2017-01-12 10:07:52 +00:00
|
|
|
toolMenu.AddSubMenu( zoneMenu );
|
|
|
|
toolMenu.AddSubMenu( lockMenu );
|
2020-08-11 19:37:07 +00:00
|
|
|
toolMenu.AddSubMenu( groupMenu );
|
2017-01-12 10:07:52 +00:00
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
|
|
|
|
menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
|
2020-08-11 19:37:07 +00:00
|
|
|
menu.AddMenu( groupMenu.get(), SELECTION_CONDITIONS::NotEmpty, 200 );
|
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 )
|
|
|
|
{
|
2017-01-12 10:07:52 +00:00
|
|
|
auto& toolMenu = drawingTool->GetToolMenu();
|
|
|
|
auto& menu = toolMenu.GetMenu();
|
|
|
|
|
|
|
|
toolMenu.AddSubMenu( zoneMenu );
|
|
|
|
|
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
|
|
|
|
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
|
|
|
|
{
|
|
|
|
return [=]( const SELECTION& sel )
|
|
|
|
{
|
|
|
|
return drawingTool->GetDrawingMode() == aMode;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-05-13 20:42:40 +00:00
|
|
|
menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
int PCB_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_NEW_BOARD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_LOAD_FILE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_SAVE_BOARD );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_SAVE_BOARD_AS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::SaveCopyAs( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Files_io_from_id( ID_COPY_BOARD_AS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST undoCmd;
|
|
|
|
WS_PROXY_UNDO_ITEM* undoItem = new WS_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 );
|
2020-08-26 18:04:32 +00:00
|
|
|
m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
|
2019-05-26 15:36:40 +00:00
|
|
|
|
|
|
|
DIALOG_PAGES_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS,
|
|
|
|
MAX_PAGE_SIZE_PCBNEW_MILS ) );
|
|
|
|
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
|
|
|
|
|
2019-07-07 23:05:59 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2019-05-26 15:36:40 +00:00
|
|
|
m_frame->RollbackFromUndo();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-04 20:59:59 +00:00
|
|
|
m_frame->ToPlotter( ID_GEN_PLOT );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::BoardSetup( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-05-24 14:54:26 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::ImportNetlist( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
|
2019-06-04 20:59:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::ImportSpecctraSession( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
wxString fullFileName = frame()->GetBoard()->GetFileName();
|
|
|
|
wxString path;
|
|
|
|
wxString name;
|
|
|
|
wxString ext;
|
|
|
|
|
|
|
|
wxFileName::SplitPath( fullFileName, &path, &name, &ext );
|
|
|
|
name += wxT( ".ses" );
|
|
|
|
|
|
|
|
fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
|
|
|
|
wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::ExportSpecctraDSN( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
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();
|
|
|
|
fn.SetExt( SpecctraDsnFileExtension );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fn = fullFileName;
|
2019-06-04 20:59:59 +00:00
|
|
|
|
|
|
|
fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
|
2019-10-26 15:49:29 +00:00
|
|
|
SpecctraDsnFileExtension, SpecctraDsnFileWildcard(),
|
2019-06-04 20:59:59 +00:00
|
|
|
frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::GenerateFabFiles( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
else
|
|
|
|
wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
|
2019-10-26 15:49:29 +00:00
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-11 14:01:26 +00:00
|
|
|
int PCB_EDITOR_CONTROL::RepairBoard( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int errors = 0;
|
|
|
|
wxString details;
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* Repair duplicate IDs
|
|
|
|
*/
|
|
|
|
|
|
|
|
std::set<KIID> ids;
|
|
|
|
int duplicates = 0;
|
|
|
|
|
|
|
|
auto processItem = [&]( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( ids.count( aItem->m_Uuid ) )
|
|
|
|
{
|
|
|
|
duplicates++;
|
|
|
|
const_cast<KIID&>( aItem->m_Uuid ) = KIID();
|
|
|
|
}
|
|
|
|
|
|
|
|
ids.insert( aItem->m_Uuid );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Module IDs are the most important, so give them the first crack at "owning" a particular
|
|
|
|
// KIID.
|
|
|
|
|
|
|
|
for( MODULE* module : board()->Modules() )
|
|
|
|
processItem( module );
|
|
|
|
|
|
|
|
// After that the principal use is for DRC marker pointers, which are most likely to pads
|
|
|
|
// or tracks.
|
|
|
|
|
|
|
|
for( MODULE* module : board()->Modules() )
|
|
|
|
{
|
|
|
|
for( D_PAD* pad : module->Pads() )
|
|
|
|
processItem( pad );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( TRACK* track : board()->Tracks() )
|
|
|
|
processItem( track );
|
|
|
|
|
|
|
|
// From here out I don't think order matters much.
|
|
|
|
|
|
|
|
for( MODULE* module : board()->Modules() )
|
|
|
|
{
|
|
|
|
processItem( &module->Reference() );
|
|
|
|
processItem( &module->Value() );
|
|
|
|
|
|
|
|
for( BOARD_ITEM* item : module->GraphicalItems() )
|
|
|
|
processItem( item );
|
|
|
|
|
|
|
|
for( ZONE_CONTAINER* zone : module->Zones() )
|
|
|
|
processItem( zone );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* drawing : board()->Drawings() )
|
|
|
|
processItem( drawing );
|
|
|
|
|
|
|
|
for( ZONE_CONTAINER* zone : board()->GetZoneList() )
|
|
|
|
processItem( zone );
|
|
|
|
|
|
|
|
for( MARKER_PCB* marker : board()->Markers() )
|
|
|
|
processItem( marker );
|
|
|
|
|
|
|
|
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 );
|
|
|
|
DisplayInfoMessage( m_frame, msg, details );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "No board problems found." ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-03 13:49:17 +00:00
|
|
|
int PCB_EDITOR_CONTROL::UpdatePCBFromSchematic( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
NETLIST netlist;
|
|
|
|
|
|
|
|
if( m_frame->FetchNetlistFromSchematic( netlist, PCB_EDIT_FRAME::ANNOTATION_DIALOG ) )
|
|
|
|
{
|
|
|
|
DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
|
|
|
|
updateDialog.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
int PCB_EDITOR_CONTROL::UpdateSchematicFromPCB( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
|
|
|
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." ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->RunEeschema();
|
|
|
|
KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
std::string payload;
|
|
|
|
m_frame->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_UPDATE, payload, m_frame );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-03 13:49:17 +00:00
|
|
|
|
2019-07-08 23:43:08 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ShowEeschema( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->RunEeschema();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-04 21:29:51 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ToggleLayersManager( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
|
2019-06-04 21:29:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::ToggleMicrowaveToolbar( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ToggleMicrowaveToolbar();
|
2019-06-04 21:29:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-03 13:49:17 +00:00
|
|
|
int PCB_EDITOR_CONTROL::TogglePythonConsole( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
|
|
|
m_frame->ScriptingConsoleEnableDisable();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
// Track & via size control
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCB_EDITOR_CONTROL::TrackWidthInc( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2019-07-08 21:17:21 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
|
|
|
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
|
|
|
PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_TRACE_T )
|
|
|
|
{
|
|
|
|
TRACK* track = (TRACK*) item;
|
|
|
|
|
|
|
|
for( int candidate : designSettings.m_TrackWidthList )
|
|
|
|
{
|
|
|
|
if( candidate > track->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( track );
|
|
|
|
track->SetWidth( candidate );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( "Increase Track Width" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int widthIndex = designSettings.GetTrackWidthIndex() + 1;
|
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
|
2019-07-08 21:17:21 +00:00
|
|
|
if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
|
2020-06-25 22:43:29 +00:00
|
|
|
{
|
|
|
|
widthIndex = 0;
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
designSettings.SetTrackWidthIndex( widthIndex );
|
|
|
|
designSettings.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCB_EDITOR_CONTROL::TrackWidthDec( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2019-07-08 21:17:21 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
|
|
|
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
|
|
|
PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_TRACE_T )
|
|
|
|
{
|
|
|
|
TRACK* track = (TRACK*) item;
|
|
|
|
|
|
|
|
for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
int candidate = designSettings.m_TrackWidthList[ i ];
|
|
|
|
|
|
|
|
if( candidate < track->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( track );
|
|
|
|
track->SetWidth( candidate );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( "Decrease Track Width" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-25 22:43:29 +00:00
|
|
|
int widthIndex = 0; // Assume we only have a single track width 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
|
|
|
|
if( designSettings.m_TrackWidthList.size() > 0 )
|
|
|
|
{
|
|
|
|
widthIndex = designSettings.GetTrackWidthIndex() - 1;
|
|
|
|
// If we get to the lowest entry start over at the highest
|
|
|
|
if( widthIndex < 0 )
|
|
|
|
widthIndex = designSettings.m_TrackWidthList.size() - 1;
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
designSettings.SetTrackWidthIndex( widthIndex );
|
|
|
|
designSettings.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ViaSizeInc( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2019-07-08 21:17:21 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
|
|
|
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
|
|
|
PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
|
|
|
{
|
|
|
|
VIA* via = (VIA*) item;
|
|
|
|
|
|
|
|
for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
|
|
|
|
{
|
|
|
|
if( candidate.m_Diameter > via->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( via );
|
|
|
|
via->SetWidth( candidate.m_Diameter );
|
|
|
|
via->SetDrill( candidate.m_Drill );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( "Increase Via Size" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int sizeIndex = designSettings.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
|
2019-07-08 21:17:21 +00:00
|
|
|
if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
|
2020-06-25 22:43:29 +00:00
|
|
|
sizeIndex = 0;
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
designSettings.SetViaSizeIndex( sizeIndex );
|
|
|
|
designSettings.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent )
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2019-07-08 21:17:21 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
|
|
|
|
constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
|
|
|
|
PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( m_frame->ToolStackIsEmpty() && SELECTION_CONDITIONS::OnlyTypes( types )( selection ) )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
|
|
|
{
|
|
|
|
VIA* via = (VIA*) item;
|
|
|
|
|
|
|
|
for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
|
|
|
|
|
|
|
|
if( candidate.m_Diameter < via->GetWidth() )
|
|
|
|
{
|
|
|
|
commit.Modify( via );
|
|
|
|
via->SetWidth( candidate.m_Diameter );
|
|
|
|
via->SetDrill( candidate.m_Drill );
|
|
|
|
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
|
|
|
|
if( designSettings.m_ViasDimensionsList.size() > 0 )
|
|
|
|
{
|
|
|
|
sizeIndex = designSettings.GetViaSizeIndex() - 1;
|
|
|
|
|
|
|
|
// If we get to the lowest entry start over at the highest
|
|
|
|
if( sizeIndex < 0 )
|
|
|
|
sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
designSettings.SetViaSizeIndex( sizeIndex );
|
|
|
|
designSettings.UseCustomTrackViaSize( false );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-07-08 21:17:21 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged, true );
|
|
|
|
}
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2017-05-18 17:21:30 +00:00
|
|
|
MODULE* module = aEvent.Parameter<MODULE*>();
|
2015-03-10 15:58:26 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
2017-12-14 16:10:06 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2019-04-14 18:25:32 +00:00
|
|
|
BOARD* board = getModel<BOARD>();
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2015-03-10 15:58:26 +00:00
|
|
|
controls->ShowCursor( true );
|
|
|
|
controls->SetSnapping( true );
|
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2015-03-10 15:58:26 +00:00
|
|
|
Activate();
|
|
|
|
|
2017-09-17 17:49:06 +00:00
|
|
|
VECTOR2I cursorPos = controls->GetCursorPosition();
|
2019-06-24 15:27:05 +00:00
|
|
|
bool reselect = false;
|
2020-08-21 22:23:22 +00:00
|
|
|
bool fromOtherCommand = module != nullptr;
|
2017-12-14 16:10:06 +00:00
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
// Prime the pump
|
2017-05-18 17:21:30 +00:00
|
|
|
if( module )
|
|
|
|
{
|
2017-09-17 17:49:06 +00:00
|
|
|
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
2017-12-14 16:10:06 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
|
2019-07-12 21:59:37 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
2017-05-18 17:21:30 +00:00
|
|
|
}
|
2019-06-24 15:27:05 +00:00
|
|
|
else if( aEvent.HasPosition() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
|
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
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
2019-01-29 14:04:12 +00:00
|
|
|
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2018-01-19 13:20:15 +00:00
|
|
|
if( reselect && module )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
|
|
|
|
|
2019-07-26 15:28:59 +00:00
|
|
|
auto cleanup = [&] ()
|
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
commit.Revert();
|
2020-08-21 22:23:22 +00:00
|
|
|
|
|
|
|
if( fromOtherCommand )
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
|
|
|
|
|
|
|
|
if( undo )
|
|
|
|
{
|
|
|
|
m_frame->PutDataInPreviousState( undo, false );
|
|
|
|
undo->ClearListAndDeleteItems();
|
|
|
|
delete undo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
module = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
if( evt->IsCancelInteractive() )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
|
|
|
if( module )
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
|
|
|
else
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
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() )
|
|
|
|
{
|
|
|
|
if( module )
|
|
|
|
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
|
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
frame()->PopTool( tool );
|
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 ) )
|
|
|
|
{
|
|
|
|
if( !module )
|
|
|
|
{
|
2015-09-21 08:16:23 +00:00
|
|
|
// Pick the module to be placed
|
2018-08-01 10:00:10 +00:00
|
|
|
module = m_frame->SelectFootprintFromLibTree();
|
2016-08-16 14:56:20 +00:00
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
if( module == NULL )
|
|
|
|
continue;
|
|
|
|
|
2020-02-20 12:11:04 +00:00
|
|
|
module->SetLink( niluuid );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
|
|
|
module->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
|
|
|
|
module->SetParent( board );
|
|
|
|
|
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)
|
|
|
|
if( module->IsFlipped() )
|
2019-07-12 21:02:10 +00:00
|
|
|
module->Flip( module->GetPosition(), m_frame->Settings().m_FlipLeftRight );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
|
|
|
module->SetOrientation( 0 );
|
2015-03-10 15:58:26 +00:00
|
|
|
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
2019-01-18 01:50:50 +00:00
|
|
|
|
|
|
|
commit.Add( module );
|
2017-12-14 16:10:06 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
|
|
|
|
controls->SetCursorPosition( cursorPos, false );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-14 16:10:06 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2016-06-21 15:06:28 +00:00
|
|
|
commit.Push( _( "Place a module" ) );
|
2015-03-10 15:58:26 +00:00
|
|
|
module = NULL; // to indicate that there is no module that we currently modify
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-12 21:59:37 +00:00
|
|
|
else if( module && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
|
|
|
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
2019-05-19 21:04:04 +00:00
|
|
|
selection().SetReferencePoint( cursorPos );
|
|
|
|
getView()->Update( & selection() );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
2018-01-19 13:20:15 +00:00
|
|
|
|
|
|
|
else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
|
|
|
|
{
|
|
|
|
// Calling 'Properties' action clears the selection, so we need to restore it
|
|
|
|
reselect = true;
|
|
|
|
}
|
2018-02-15 10:53:17 +00:00
|
|
|
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
|
|
|
evt->SetPassEvent();
|
|
|
|
|
2018-02-15 10:53:17 +00:00
|
|
|
// Enable autopanning and cursor capture only when there is a module to be placed
|
|
|
|
controls->SetAutoPan( !!module );
|
|
|
|
controls->CaptureCursor( !!module );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-09 08:29:06 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ToggleLockSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
return modifyLockSelected( TOGGLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::LockSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
return modifyLockSelected( ON );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::UnlockSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
return modifyLockSelected( OFF );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
|
2015-09-03 15:35:41 +00:00
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
2019-08-20 15:26:49 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2015-09-03 15:35:41 +00:00
|
|
|
|
2016-05-09 08:29:06 +00:00
|
|
|
if( selection.Empty() )
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
2015-09-03 15:35:41 +00:00
|
|
|
|
2016-05-09 08:29:06 +00:00
|
|
|
bool modified = false;
|
|
|
|
|
2019-08-20 15:26:49 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2015-09-03 15:35:41 +00:00
|
|
|
{
|
2019-08-20 15:26:49 +00:00
|
|
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
|
|
|
bool prevState = board_item->IsLocked();
|
|
|
|
|
|
|
|
commit.Modify( board_item );
|
2016-05-09 08:29:06 +00:00
|
|
|
|
|
|
|
switch( aMode )
|
2015-09-03 15:35:41 +00:00
|
|
|
{
|
2019-08-20 15:26:49 +00:00
|
|
|
case ON: board_item->SetLocked( true ); break;
|
|
|
|
case OFF: board_item->SetLocked( false ); break;
|
|
|
|
case TOGGLE: board_item->SetLocked( !prevState ); break;
|
2015-09-03 15:35:41 +00:00
|
|
|
}
|
2016-05-09 08:29:06 +00:00
|
|
|
|
|
|
|
// Check if we really modified an item
|
2019-08-20 15:26:49 +00:00
|
|
|
if( !modified && prevState != board_item->IsLocked() )
|
2016-05-09 08:29:06 +00:00
|
|
|
modified = true;
|
2015-09-03 15:35:41 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 08:29:06 +00:00
|
|
|
if( modified )
|
2019-06-10 22:42:02 +00:00
|
|
|
{
|
2019-08-20 15:26:49 +00:00
|
|
|
switch( aMode )
|
|
|
|
{
|
|
|
|
case ON: commit.Push( _( "Lock" ) ); break;
|
|
|
|
case OFF: commit.Push( _( "Unlock" ) ); break;
|
|
|
|
case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
|
|
|
|
}
|
|
|
|
|
2019-06-10 22:42:02 +00:00
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
int PCB_EDITOR_CONTROL::GroupSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
|
|
|
// why don't we have to update the selection after selectionCursor action?
|
|
|
|
|
2020-08-12 11:23:30 +00:00
|
|
|
PCB_GROUP* group = new PCB_GROUP( board );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
2020-09-02 01:09:34 +00:00
|
|
|
group->AddItem( static_cast<BOARD_ITEM*>( item ) );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
commit.Add( group );
|
|
|
|
commit.Push( _( "GroupCreate" ) );
|
|
|
|
wxString check = board->GroupsSanityCheck();
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( check == wxEmptyString, 0,wxT( "Group create resulted in inconsistent state: " ) + check );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
selTool->ClearSelection();
|
|
|
|
selTool->select( group );
|
|
|
|
|
|
|
|
// Should I call PostEvent and onModify() ?
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::GroupMergeSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
|
|
|
// why don't we have to update the selection after selectionCursor action?
|
|
|
|
|
2020-08-12 11:23:30 +00:00
|
|
|
PCB_GROUP* firstGroup = NULL;
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
|
|
|
|
|
|
|
if( firstGroup == NULL && board_item->Type() == PCB_GROUP_T )
|
|
|
|
{
|
2020-08-12 11:23:30 +00:00
|
|
|
firstGroup = static_cast<PCB_GROUP*>( board_item );
|
2020-08-11 19:37:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// The group submenu update() call only enabled merge if there was a group
|
|
|
|
// in the selection.
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( firstGroup != NULL, 0, "Group not found in selection though selection was checked" );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
commit.Modify( firstGroup );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
|
|
|
|
|
|
|
if( board_item != firstGroup )
|
2020-09-02 01:09:34 +00:00
|
|
|
firstGroup->AddItem( board_item );
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "GroupMerge" );
|
2020-08-11 19:37:07 +00:00
|
|
|
wxString check = board->GroupsSanityCheck();
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( check == wxEmptyString, 0, wxT( "Group merge resulted in inconsistent state: " ) + check );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
selTool->ClearSelection();
|
|
|
|
selTool->select( firstGroup );
|
|
|
|
|
|
|
|
// Should I call PostEvent and onModify() ?
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::UngroupSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
std::unordered_set<BOARD_ITEM*> ungroupedItems;
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
|
|
|
// why don't we have to update the selection after selectionCursor action?
|
|
|
|
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
|
|
|
|
|
|
|
wxCHECK_MSG( board_item->Type() == PCB_GROUP_T, 0,
|
2020-09-04 18:29:22 +00:00
|
|
|
"Selection for ungroup should only have groups in it - was checked." );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
commit.Remove( board_item );
|
|
|
|
|
2020-08-12 11:23:30 +00:00
|
|
|
for( BOARD_ITEM* bItem : static_cast<PCB_GROUP*>( board_item )->GetItems() )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
|
|
|
ungroupedItems.insert( bItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "GroupUngroup" );
|
2020-08-11 19:37:07 +00:00
|
|
|
wxString check = board->GroupsSanityCheck();
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( check == wxEmptyString, 0, wxT( "Group merge resulted in inconsistent state: " ) + check );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
selTool->ClearSelection();
|
|
|
|
for( BOARD_ITEM* item : ungroupedItems )
|
|
|
|
{
|
|
|
|
// commit.Remove() on the group recursively removed children from the view.
|
|
|
|
// Add them back to the view
|
|
|
|
//getView()->Add( item );
|
|
|
|
|
|
|
|
selTool->select( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Should I call PostEvent and onModify() ?
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::GroupRemoveItemsSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
|
|
|
// why don't we have to update the selection after selectionCursor action?
|
|
|
|
|
|
|
|
board->GroupRemoveItems( selection, &commit );
|
|
|
|
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "GroupRemoveItems" );
|
2020-08-11 19:37:07 +00:00
|
|
|
wxString check = board->GroupsSanityCheck();
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( check == wxEmptyString, 0, wxT( "Group removeItems resulted in inconsistent state: " ) + check );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
// Should I call PostEvent and onModify() ?
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::GroupFlattenSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
const PCBNEW_SELECTION origGroups = selTool->GetSelection();
|
|
|
|
// These items were moved up to the top-level group that need to be readded to
|
|
|
|
// the view. That's becuase commit.Remove(group) recursively removed them from
|
|
|
|
// the view.
|
|
|
|
//std::unordered_set<BOARD_ITEM*> movedItems;
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
|
|
|
// why don't we have to update the selection after selectionCursor action?
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
|
|
|
wxCHECK_MSG( board_item->Type() == PCB_GROUP_T, 0,
|
2020-08-15 15:46:52 +00:00
|
|
|
"Selection for ungroup should only have groups in it - was checked." );
|
2020-08-12 11:23:30 +00:00
|
|
|
std::queue<PCB_GROUP*> groupsToFlatten;
|
|
|
|
groupsToFlatten.push( static_cast<PCB_GROUP*>( board_item ) );
|
|
|
|
PCB_GROUP* topGroup = groupsToFlatten.front();
|
2020-08-11 19:37:07 +00:00
|
|
|
commit.Modify( topGroup );
|
|
|
|
std::unordered_set<BOARD_ITEM*> topSubgroupsToRemove;
|
|
|
|
|
|
|
|
while( !groupsToFlatten.empty() )
|
|
|
|
{
|
2020-08-12 11:23:30 +00:00
|
|
|
PCB_GROUP* grp = groupsToFlatten.front();
|
2020-08-11 19:37:07 +00:00
|
|
|
groupsToFlatten.pop();
|
|
|
|
|
|
|
|
for( BOARD_ITEM* grpItem : grp->GetItems() )
|
|
|
|
{
|
|
|
|
if( grpItem->Type() == PCB_GROUP_T )
|
|
|
|
{
|
2020-08-12 11:23:30 +00:00
|
|
|
groupsToFlatten.push( static_cast<PCB_GROUP*>( grpItem ) );
|
2020-08-11 19:37:07 +00:00
|
|
|
commit.Remove( grpItem );
|
|
|
|
if( grp == topGroup )
|
|
|
|
topSubgroupsToRemove.insert( grpItem );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( grp != topGroup )
|
|
|
|
{
|
|
|
|
wxCHECK( topGroup->AddItem( grpItem ), 0 );
|
|
|
|
//movedItems.insert( grpItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BOARD_ITEM* group : topSubgroupsToRemove )
|
|
|
|
{
|
|
|
|
topGroup->RemoveItem( group );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "GroupFlatten" );
|
2020-08-11 19:37:07 +00:00
|
|
|
wxString check = board->GroupsSanityCheck();
|
2020-09-04 18:29:22 +00:00
|
|
|
wxCHECK_MSG( check == wxEmptyString, 0, wxT( "Group flatten resulted in inconsistent state: " ) + check );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
// Removing subgroups deselects the items in them. So reselect everything no that it's flattened.
|
|
|
|
selTool->ClearSelection();
|
|
|
|
for( EDA_ITEM* item : origGroups )
|
|
|
|
selTool->select( static_cast<BOARD_ITEM*>( item ) );
|
|
|
|
|
|
|
|
// Should I call PostEvent and onModify() ?
|
|
|
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
|
|
|
m_frame->OnModify();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::GroupEnterSelected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
|
|
|
|
2020-09-02 01:09:34 +00:00
|
|
|
if( selection.GetSize() == 1 && selection[0]->Type() == PCB_GROUP_T )
|
|
|
|
selTool->EnterGroup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-08-11 19:37:07 +00:00
|
|
|
|
|
|
|
|
2020-09-02 01:09:34 +00:00
|
|
|
int PCB_EDITOR_CONTROL::GroupLeave( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_toolMgr->GetTool<SELECTION_TOOL>()->ExitGroup( true /* Select the group */ );
|
2020-08-11 19:37:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
KIGFX::VIEW* view = getView();
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
|
|
BOARD* board = getModel<BOARD>();
|
|
|
|
PCB_TARGET* target = new PCB_TARGET( board );
|
|
|
|
|
|
|
|
// Init the new item attributes
|
|
|
|
target->SetLayer( Edge_Cuts );
|
2018-04-28 15:22:25 +00:00
|
|
|
target->SetWidth( board->GetDesignSettings().GetLineThickness( Edge_Cuts ) );
|
2015-03-10 15:58:26 +00:00
|
|
|
target->SetSize( Millimeter2iu( 5 ) );
|
|
|
|
VECTOR2I cursorPos = controls->GetCursorPosition();
|
|
|
|
target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
|
|
|
|
|
|
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
|
|
|
KIGFX::VIEW_GROUP preview( view );
|
|
|
|
preview.Add( target );
|
|
|
|
view->Add( &preview );
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2015-03-10 15:58:26 +00:00
|
|
|
controls->SetSnapping( true );
|
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2015-03-10 15:58:26 +00:00
|
|
|
Activate();
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2019-06-27 21:33:48 +00:00
|
|
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
2019-01-29 14:04:12 +00:00
|
|
|
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
2019-06-24 15:27:05 +00:00
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
frame()->PopTool( tool );
|
2015-03-10 15:58:26 +00:00
|
|
|
break;
|
2019-06-24 15:27:05 +00:00
|
|
|
}
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( evt->IsMoveTool() )
|
|
|
|
{
|
|
|
|
// leave ourselves on the stack so we come back after the move
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
frame()->PopTool( tool );
|
2019-07-01 21:01:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
|
|
|
target->SetWidth( target->GetWidth() + WIDTH_STEP );
|
2016-12-02 17:58:12 +00:00
|
|
|
view->Update( &preview );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
|
2015-03-10 15:58:26 +00:00
|
|
|
{
|
|
|
|
int width = target->GetWidth();
|
|
|
|
|
|
|
|
if( width > WIDTH_STEP )
|
|
|
|
{
|
|
|
|
target->SetWidth( width - WIDTH_STEP );
|
2016-12-02 17:58:12 +00:00
|
|
|
view->Update( &preview );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
|
|
|
assert( target->GetSize() > 0 );
|
|
|
|
assert( target->GetWidth() > 0 );
|
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
commit.Add( target );
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "Place a layer alignment target" );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
|
|
|
preview.Remove( target );
|
|
|
|
|
|
|
|
// Create next PCB_TARGET
|
|
|
|
target = new PCB_TARGET( *target );
|
|
|
|
preview.Add( target );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
else if( evt->IsMotion() )
|
|
|
|
{
|
|
|
|
target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
2016-12-02 17:58:12 +00:00
|
|
|
view->Update( &preview );
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
evt->SetPassEvent();
|
2015-03-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
|
2019-07-26 15:28:59 +00:00
|
|
|
preview.Clear();
|
2015-03-10 15:58:26 +00:00
|
|
|
delete target;
|
|
|
|
view->Remove( &preview );
|
2019-06-27 11:47:24 +00:00
|
|
|
controls->SetSnapping( false );
|
2015-03-10 15:58:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-28 14:58:41 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
|
|
|
|
std::vector<ZONE_CONTAINER *>& aMergedZones )
|
2016-11-04 21:29:47 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
// We should have one polygon with hole
|
|
|
|
// We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
|
|
|
|
// and therefore cannot be merged (they are dectected as intersecting)
|
|
|
|
// but we should never have more than 2 polys
|
2017-03-07 12:06:00 +00:00
|
|
|
if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
|
2016-11-04 21:29:47 +00:00
|
|
|
{
|
2018-11-28 14:58:41 +00:00
|
|
|
wxLogMessage( "BOARD::CombineAreas error: more than 2 polys after merging" );
|
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] );
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
aCommit.Modify( aOriginZones[0] );
|
2016-11-04 21:29:47 +00:00
|
|
|
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
|
|
|
|
2015-06-19 15:32:33 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-06-08 21:48:22 +00:00
|
|
|
const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<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;
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
ZONE_CONTAINER* firstZone = nullptr;
|
|
|
|
std::vector<ZONE_CONTAINER*> toMerge, merged;
|
2016-11-04 21:29:47 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
for( auto item : selection )
|
2015-06-19 15:32:33 +00:00
|
|
|
{
|
2016-11-04 21:29:47 +00:00
|
|
|
auto curr_area = dynamic_cast<ZONE_CONTAINER*>( 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 )
|
|
|
|
continue;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
if( curr_area->GetPriority() != firstZone->GetPriority() )
|
|
|
|
continue;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
|
|
|
|
continue;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
if( curr_area->GetLayer() != firstZone->GetLayer() )
|
|
|
|
continue;
|
2015-06-19 15:32:33 +00:00
|
|
|
|
2018-05-04 12:01:26 +00:00
|
|
|
if( !board->TestAreaIntersection( curr_area, firstZone ) )
|
|
|
|
continue;
|
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
|
|
|
}
|
|
|
|
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
if( mergeZones( commit, toMerge, merged ) )
|
2015-06-19 15:32:33 +00:00
|
|
|
{
|
2020-08-15 15:46:52 +00:00
|
|
|
commit.Push( "Merge zones" );
|
2016-12-09 11:04:32 +00:00
|
|
|
|
|
|
|
for( auto item : merged )
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, item );
|
2015-06-19 15:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-06 03:45:56 +00:00
|
|
|
int PCB_EDITOR_CONTROL::ZoneDuplicate( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-06-27 11:57:40 +00:00
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const 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;
|
|
|
|
|
|
|
|
auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if( oldZone->GetIsKeepout() )
|
2018-05-25 14:56:04 +00:00
|
|
|
dialogResult = InvokeKeepoutAreaEditor( 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 );
|
|
|
|
|
|
|
|
auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
|
|
|
|
newZone->ClearSelected();
|
|
|
|
newZone->UnFill();
|
|
|
|
zoneSettings.ExportSetting( *newZone );
|
|
|
|
|
|
|
|
// If the new zone is on the same layer(s) as the the initial zone,
|
|
|
|
// offset it a bit so it can more easily be picked.
|
|
|
|
if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
|
|
|
|
newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
|
2020-06-24 02:19:08 +00:00
|
|
|
else if( !oldZone->GetIsKeepout() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
|
2018-05-25 14:56:04 +00:00
|
|
|
newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
|
|
|
|
|
|
|
|
commit.Add( newZone.release() );
|
|
|
|
commit.Push( _( "Duplicate zone" ) );
|
2017-02-06 03:45:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-27 11:57:40 +00:00
|
|
|
int PCB_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
|
|
|
const SELECTION& selection = selTool->RequestSelection( EDIT_TOOL::FootprintFilter );
|
|
|
|
|
|
|
|
if( selection.Empty() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
MODULE* mod = selection.FirstOfKind<MODULE>();
|
|
|
|
|
|
|
|
if( !mod )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
|
|
|
|
|
|
|
auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
|
|
|
|
|
|
|
|
editor->Load_Module_From_BOARD( mod );
|
|
|
|
|
|
|
|
editor->Show( true );
|
|
|
|
editor->Raise(); // Iconize( false );
|
|
|
|
|
|
|
|
if( selection.IsHover() )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-12 22:04:00 +00:00
|
|
|
void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
2018-01-24 10:19:33 +00:00
|
|
|
BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
|
2015-06-18 15:51:51 +00:00
|
|
|
{
|
2020-07-01 12:28:10 +00:00
|
|
|
aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
|
|
|
|
originViewItem->SetPosition( (wxPoint) 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
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-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
|
|
|
|
} );
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-11-28 14:58:41 +00:00
|
|
|
|
2019-06-03 20:06:58 +00:00
|
|
|
int PCB_EDITOR_CONTROL::FlipPcbView( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
view()->SetMirror( !view()->IsMirroredX(), false );
|
|
|
|
view()->RecacheAllItems();
|
|
|
|
frame()->Refresh();
|
2020-08-18 01:48:11 +00:00
|
|
|
frame()->OnDisplayOptionsChanged();
|
2019-06-03 20:06:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-31 12:30:51 +00:00
|
|
|
void PCB_EDITOR_CONTROL::setTransitions()
|
2014-07-09 11:50:27 +00:00
|
|
|
{
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::SaveCopyAs, ACTIONS::saveCopyAs.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
|
|
|
|
|
|
|
Go( &PCB_EDITOR_CONTROL::BoardSetup, PCB_ACTIONS::boardSetup.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ImportNetlist, PCB_ACTIONS::importNetlist.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ImportSpecctraSession, PCB_ACTIONS::importSpecctraSession.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ExportSpecctraDSN, PCB_ACTIONS::exportSpecctraDSN.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GenerateDrillFiles, PCB_ACTIONS::generateDrillFiles.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateGerbers.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GeneratePosFile, PCB_ACTIONS::generatePosFile.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateReportFile.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateD356File.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GenerateFabFiles, PCB_ACTIONS::generateBOM.MakeEvent() );
|
2019-06-04 20:59:59 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
// Track & via size control
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::TrackWidthInc, PCB_ACTIONS::trackWidthInc.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::TrackWidthDec, PCB_ACTIONS::trackWidthDec.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ViaSizeInc, PCB_ACTIONS::viaSizeInc.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ViaSizeDec, PCB_ACTIONS::viaSizeDec.MakeEvent() );
|
2014-07-09 14:57:01 +00:00
|
|
|
|
|
|
|
// Zone actions
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::ZoneMerge, PCB_ACTIONS::zoneMerge.MakeEvent() );
|
|
|
|
Go( &PCB_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
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::PlaceTarget, PCB_ACTIONS::placeTarget.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::PlaceModule, PCB_ACTIONS::placeModule.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillOrigin.MakeEvent() );
|
2020-06-27 11:57:40 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::EditFpInFpEditor, PCB_ACTIONS::editFpInFpEditor.MakeEvent() );
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2015-06-18 15:51:50 +00:00
|
|
|
// Other
|
2020-09-02 01:09:34 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::ToggleLockSelected, PCB_ACTIONS::toggleLock.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::LockSelected, PCB_ACTIONS::lock.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::UnlockSelected, PCB_ACTIONS::unlock.MakeEvent() );
|
2020-08-11 19:37:07 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupSelected, PCB_ACTIONS::groupCreate.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupMergeSelected, PCB_ACTIONS::groupMerge.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::UngroupSelected, PCB_ACTIONS::groupUngroup.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupRemoveItemsSelected, PCB_ACTIONS::groupRemoveItems.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupFlattenSelected, PCB_ACTIONS::groupFlatten.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupEnterSelected, PCB_ACTIONS::groupEnter.MakeEvent() );
|
2020-09-02 01:09:34 +00:00
|
|
|
Go( &PCB_EDITOR_CONTROL::GroupLeave, PCB_ACTIONS::groupLeave.MakeEvent() );
|
|
|
|
|
|
|
|
Go( &PCB_EDITOR_CONTROL::UpdatePCBFromSchematic, ACTIONS::updatePcbFromSchematic.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::UpdateSchematicFromPCB, ACTIONS::updateSchematicFromPcb.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ShowEeschema, PCB_ACTIONS::showEeschema.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::ToggleMicrowaveToolbar, PCB_ACTIONS::showMicrowaveToolbar.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::FlipPcbView, PCB_ACTIONS::flipBoard.MakeEvent() );
|
|
|
|
Go( &PCB_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
|
2014-07-09 11:50:27 +00:00
|
|
|
}
|
2015-03-10 15:58:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
|