2014-02-06 16:12:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-02-08 09:13:43 +00:00
|
|
|
* Copyright (C) 2014-2017 CERN
|
2021-03-13 20:19:46 +00:00
|
|
|
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-02-06 16:12:37 +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-03-13 20:19:46 +00:00
|
|
|
#include "drawing_tool.h"
|
|
|
|
#include "pcb_actions.h"
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2014-02-13 11:46:39 +00:00
|
|
|
#include <confirm.h>
|
2018-10-13 18:37:28 +00:00
|
|
|
#include <import_gfx/dialog_import_gfx.h>
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view.h>
|
2014-02-13 11:46:39 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2021-01-16 23:17:32 +00:00
|
|
|
#include <tools/pcb_grid_helper.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2020-12-01 14:58:33 +00:00
|
|
|
#include <tools/tool_event_utils.h>
|
|
|
|
#include <tools/zone_create_helper.h>
|
2021-04-05 22:29:12 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2021-02-14 22:31:11 +00:00
|
|
|
#include <router/router_tool.h>
|
2018-07-12 12:05:18 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2021-02-01 22:45:56 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2016-06-21 15:06:28 +00:00
|
|
|
#include <board_commit.h>
|
2017-01-11 17:22:53 +00:00
|
|
|
#include <scoped_set_reset.h>
|
2017-02-20 18:10:20 +00:00
|
|
|
#include <bitmaps.h>
|
2017-02-26 17:45:52 +00:00
|
|
|
#include <painter.h>
|
2018-02-19 14:25:07 +00:00
|
|
|
#include <status_popup.h>
|
2018-06-06 10:05:56 +00:00
|
|
|
#include <dialogs/dialog_text_properties.h>
|
2017-02-26 20:08:45 +00:00
|
|
|
#include <preview_items/arc_assistant.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <fp_shape.h>
|
2021-06-03 17:03:25 +00:00
|
|
|
#include <pcb_group.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-07-03 15:05:17 +00:00
|
|
|
#include <preview_items/two_point_assistant.h>
|
|
|
|
#include <preview_items/two_point_geom_manager.h>
|
|
|
|
#include <ratsnest/ratsnest_data.h>
|
2020-08-31 22:32:11 +00:00
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <dialogs/dialog_track_via_size.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2021-02-01 22:45:56 +00:00
|
|
|
#include <widgets/infobar.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2017-01-09 17:29:40 +00:00
|
|
|
|
|
|
|
using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>;
|
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
|
2020-08-31 22:32:11 +00:00
|
|
|
class VIA_SIZE_MENU : public ACTION_MENU
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VIA_SIZE_MENU() :
|
|
|
|
ACTION_MENU( true )
|
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
SetIcon( BITMAPS::width_track_via );
|
2020-08-31 22:32:11 +00:00
|
|
|
SetTitle( _( "Select Via Size" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ACTION_MENU* create() const override
|
|
|
|
{
|
|
|
|
return new VIA_SIZE_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
void update() override
|
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) getToolManager()->GetToolHolder();
|
|
|
|
EDA_UNITS units = frame->GetUserUnits();
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = frame->GetBoard()->GetDesignSettings();
|
|
|
|
bool useIndex = !bds.m_UseConnectedTrackWidth
|
|
|
|
&& !bds.UseCustomTrackViaSize();
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Use Custom Values..." ),
|
|
|
|
_( "Specify custom track and via sizes" ), wxITEM_CHECK );
|
|
|
|
Check( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, bds.UseCustomTrackViaSize() );
|
|
|
|
|
|
|
|
AppendSeparator();
|
|
|
|
|
|
|
|
for( unsigned i = 1; i < bds.m_ViasDimensionsList.size(); i++ )
|
|
|
|
{
|
|
|
|
VIA_DIMENSION via = bds.m_ViasDimensionsList[i];
|
|
|
|
|
|
|
|
if( via.m_Drill > 0 )
|
2020-12-01 14:58:33 +00:00
|
|
|
{
|
2020-08-31 22:32:11 +00:00
|
|
|
msg.Printf( _("Via %s, drill %s" ),
|
2020-10-02 20:51:24 +00:00
|
|
|
MessageTextFromValue( units, via.m_Diameter ),
|
|
|
|
MessageTextFromValue( units, via.m_Drill ) );
|
2020-12-01 14:58:33 +00:00
|
|
|
}
|
2020-08-31 22:32:11 +00:00
|
|
|
else
|
2020-12-01 14:58:33 +00:00
|
|
|
{
|
2020-10-02 20:51:24 +00:00
|
|
|
msg.Printf( _( "Via %s" ), MessageTextFromValue( units, via.m_Diameter ) );
|
2020-12-01 14:58:33 +00:00
|
|
|
}
|
2020-08-31 22:32:11 +00:00
|
|
|
|
|
|
|
int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i;
|
|
|
|
Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
|
|
|
|
Check( menuIdx, useIndex && bds.GetViaSizeIndex() == i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OPT_TOOL_EVENT eventHandler( const wxMenuEvent& aEvent ) override
|
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) getToolManager()->GetToolHolder();
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = frame->GetBoard()->GetDesignSettings();
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
|
|
|
|
// On Windows, this handler can be called with an event ID not existing in any
|
|
|
|
// menuitem, so only set flags when we have an ID match.
|
|
|
|
|
|
|
|
if( id == ID_POPUP_PCB_SELECT_CUSTOM_WIDTH )
|
|
|
|
{
|
|
|
|
DIALOG_TRACK_VIA_SIZE sizeDlg( frame, bds );
|
|
|
|
|
2021-02-08 17:39:40 +00:00
|
|
|
if( sizeDlg.ShowModal() == wxID_OK )
|
2020-08-31 22:32:11 +00:00
|
|
|
{
|
|
|
|
bds.UseCustomTrackViaSize( true );
|
|
|
|
bds.m_UseConnectedTrackWidth = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( id >= ID_POPUP_PCB_SELECT_VIASIZE1 && id <= ID_POPUP_PCB_SELECT_VIASIZE16 )
|
|
|
|
{
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
|
|
|
bds.m_UseConnectedTrackWidth = false;
|
|
|
|
bds.SetViaSizeIndex( id - ID_POPUP_PCB_SELECT_VIASIZE1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPT_TOOL_EVENT( PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-06 16:12:37 +00:00
|
|
|
DRAWING_TOOL::DRAWING_TOOL() :
|
2019-05-12 11:49:58 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.InteractiveDrawing" ),
|
2021-02-01 22:45:56 +00:00
|
|
|
m_view( nullptr ),
|
|
|
|
m_controls( nullptr ),
|
|
|
|
m_board( nullptr ),
|
|
|
|
m_frame( nullptr ),
|
|
|
|
m_mode( MODE::NONE ),
|
2021-06-26 17:44:18 +00:00
|
|
|
m_inDrawingTool( false ),
|
|
|
|
m_lineWidth( 1 )
|
2014-02-06 16:12:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DRAWING_TOOL::~DRAWING_TOOL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
bool DRAWING_TOOL::Init()
|
|
|
|
{
|
2020-08-31 22:32:11 +00:00
|
|
|
auto activeToolFunctor = [this]( const SELECTION& aSel )
|
2020-04-24 17:34:05 +00:00
|
|
|
{
|
2017-05-04 22:43:43 +00:00
|
|
|
return m_mode != MODE::NONE;
|
|
|
|
};
|
2017-02-06 16:00:51 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
// some interactive drawing tools can undo the last point
|
2020-08-31 22:32:11 +00:00
|
|
|
auto canUndoPoint = [this]( const SELECTION& aSel )
|
2020-04-24 17:34:05 +00:00
|
|
|
{
|
|
|
|
return ( m_mode == MODE::ARC
|
|
|
|
|| m_mode == MODE::ZONE
|
|
|
|
|| m_mode == MODE::KEEPOUT
|
|
|
|
|| m_mode == MODE::GRAPHIC_POLYGON );
|
2017-05-04 22:43:43 +00:00
|
|
|
};
|
2017-02-26 17:45:52 +00:00
|
|
|
|
2020-04-24 17:34:05 +00:00
|
|
|
// functor for tools that can automatically close the outline
|
2020-08-31 22:32:11 +00:00
|
|
|
auto canCloseOutline = [this]( const SELECTION& aSel )
|
2020-04-24 17:34:05 +00:00
|
|
|
{
|
|
|
|
return ( m_mode == MODE::ZONE
|
|
|
|
|| m_mode == MODE::KEEPOUT
|
|
|
|
|| m_mode == MODE::GRAPHIC_POLYGON );
|
|
|
|
};
|
2017-02-26 20:08:45 +00:00
|
|
|
|
2020-08-31 22:32:11 +00:00
|
|
|
auto viaToolActive = [this]( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_mode == MODE::VIA;
|
|
|
|
};
|
|
|
|
|
2017-02-06 16:00:51 +00:00
|
|
|
auto& ctxMenu = m_menu.GetMenu();
|
|
|
|
|
2018-08-01 16:58:27 +00:00
|
|
|
// cancel current tool goes in main context menu at the top if present
|
|
|
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 );
|
2019-06-15 16:40:14 +00:00
|
|
|
ctxMenu.AddSeparator( 1 );
|
2017-02-26 20:08:45 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
// tool-specific actions
|
2020-04-24 17:34:05 +00:00
|
|
|
ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 );
|
2019-06-17 00:34:21 +00:00
|
|
|
ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 );
|
2017-02-26 20:08:45 +00:00
|
|
|
|
2019-06-15 16:40:14 +00:00
|
|
|
ctxMenu.AddSeparator( 500 );
|
2017-02-06 16:00:51 +00:00
|
|
|
|
2020-08-31 22:32:11 +00:00
|
|
|
std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
|
|
|
|
viaSizeMenu->SetTool( this );
|
|
|
|
m_menu.AddSubMenu( viaSizeMenu );
|
|
|
|
ctxMenu.AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
|
|
|
|
|
|
|
|
ctxMenu.AddSeparator( 500 );
|
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
// Type-specific sub-menus will be added for us by other tools
|
|
|
|
// For example, zone fill/unfill is provided by the PCB control tool
|
|
|
|
|
|
|
|
// Finally, add the standard zoom/grid items
|
2019-06-11 14:38:21 +00:00
|
|
|
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-06 16:12:37 +00:00
|
|
|
void DRAWING_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
2014-02-14 08:49:49 +00:00
|
|
|
// Init variables used by every drawing tool
|
|
|
|
m_view = getView();
|
|
|
|
m_controls = getViewControls();
|
2014-06-06 12:59:25 +00:00
|
|
|
m_board = getModel<BOARD>();
|
2016-06-08 09:24:46 +00:00
|
|
|
m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
2014-02-06 16:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
DRAWING_TOOL::MODE DRAWING_TOOL::GetDrawingMode() const
|
|
|
|
{
|
|
|
|
return m_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
2014-02-06 16:12:37 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2018-05-14 03:22:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_frame->GetModel() );
|
2020-11-07 17:50:22 +00:00
|
|
|
PCB_SHAPE* line = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2019-06-24 15:27:05 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2017-01-09 17:29:40 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
|
2019-07-02 13:31:30 +00:00
|
|
|
OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
line->SetShape( SHAPE_T::SEGMENT );
|
2019-06-24 15:27:05 +00:00
|
|
|
line->SetFlags( IS_NEW );
|
|
|
|
|
|
|
|
if( aEvent.HasPosition() )
|
2021-05-09 19:17:01 +00:00
|
|
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
2014-04-04 09:50:15 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2019-06-16 10:03:56 +00:00
|
|
|
Activate();
|
|
|
|
|
2020-11-05 15:05:52 +00:00
|
|
|
while( drawSegment( tool, &line, startingPoint ) )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
|
|
|
if( line )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-10-04 23:34:59 +00:00
|
|
|
static_cast<FP_SHAPE*>( line )->SetLocalCoord();
|
2019-01-17 16:58:17 +00:00
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
commit.Add( line );
|
|
|
|
commit.Push( _( "Draw a line segment" ) );
|
2017-11-01 11:14:16 +00:00
|
|
|
startingPoint = VECTOR2D( line->GetEnd() );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
else
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2017-11-01 11:14:16 +00:00
|
|
|
startingPoint = NULLOPT;
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
line = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2021-07-21 18:31:25 +00:00
|
|
|
line->SetShape( SHAPE_T::SEGMENT );
|
2019-06-15 19:42:17 +00:00
|
|
|
line->SetFlags( IS_NEW );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2014-02-06 16:12:37 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
return 0;
|
2014-02-06 16:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-15 19:50:20 +00:00
|
|
|
int DRAWING_TOOL::DrawRectangle( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2020-06-15 19:50:20 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_frame->GetModel() );
|
2020-11-07 17:50:22 +00:00
|
|
|
PCB_SHAPE* rect = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2020-06-15 19:50:20 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2020-06-21 08:36:01 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::RECTANGLE );
|
2020-06-15 19:50:20 +00:00
|
|
|
OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
rect->SetShape( SHAPE_T::RECT );
|
2020-11-14 01:16:02 +00:00
|
|
|
rect->SetFilled( false );
|
2020-06-15 19:50:20 +00:00
|
|
|
rect->SetFlags(IS_NEW );
|
|
|
|
|
|
|
|
if( aEvent.HasPosition() )
|
2021-05-09 19:17:01 +00:00
|
|
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
2020-06-15 19:50:20 +00:00
|
|
|
|
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
|
|
|
Activate();
|
|
|
|
|
2020-11-05 15:05:52 +00:00
|
|
|
while( drawSegment( tool, &rect, startingPoint ) )
|
2020-06-15 19:50:20 +00:00
|
|
|
{
|
|
|
|
if( rect )
|
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-10-04 23:34:59 +00:00
|
|
|
static_cast<FP_SHAPE*>( rect )->SetLocalCoord();
|
2020-06-15 19:50:20 +00:00
|
|
|
|
|
|
|
commit.Add( rect );
|
|
|
|
commit.Push( _( "Draw a rectangle" ) );
|
|
|
|
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, rect );
|
|
|
|
}
|
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
rect = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2021-07-21 18:31:25 +00:00
|
|
|
rect->SetShape( SHAPE_T::RECT );
|
2020-11-14 01:16:02 +00:00
|
|
|
rect->SetFilled( false );
|
2020-06-15 19:50:20 +00:00
|
|
|
rect->SetFlags(IS_NEW );
|
|
|
|
startingPoint = NULLOPT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
2014-02-10 09:58:58 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2018-05-14 03:22:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_frame->GetModel() );
|
2020-11-07 17:50:22 +00:00
|
|
|
PCB_SHAPE* circle = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2019-06-24 15:27:05 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
|
2019-07-02 13:31:30 +00:00
|
|
|
OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
|
2014-02-10 09:58:58 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
circle->SetShape( SHAPE_T::CIRCLE );
|
2020-11-14 01:16:02 +00:00
|
|
|
circle->SetFilled( false );
|
2019-06-15 19:42:17 +00:00
|
|
|
circle->SetFlags( IS_NEW );
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
if( aEvent.HasPosition() )
|
2021-05-09 19:17:01 +00:00
|
|
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
2014-02-14 10:35:48 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2019-06-16 10:03:56 +00:00
|
|
|
Activate();
|
|
|
|
|
2020-11-05 15:05:52 +00:00
|
|
|
while( drawSegment( tool, &circle, startingPoint ) )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
|
|
|
if( circle )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-10-04 23:34:59 +00:00
|
|
|
static_cast<FP_SHAPE*>( circle )->SetLocalCoord();
|
2019-01-17 16:58:17 +00:00
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
commit.Add( circle );
|
|
|
|
commit.Push( _( "Draw a circle" ) );
|
2019-06-27 11:47:24 +00:00
|
|
|
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, circle );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
circle = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2021-07-21 18:31:25 +00:00
|
|
|
circle->SetShape( SHAPE_T::CIRCLE );
|
2020-11-14 01:16:02 +00:00
|
|
|
circle->SetFilled( false );
|
2019-06-15 19:42:17 +00:00
|
|
|
circle->SetFlags( IS_NEW );
|
2019-06-24 15:27:05 +00:00
|
|
|
startingPoint = NULLOPT;
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
|
|
|
|
2016-06-08 09:24:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2018-05-14 03:22:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2021-04-07 13:50:18 +00:00
|
|
|
FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_frame->GetModel() );
|
2020-11-07 17:50:22 +00:00
|
|
|
PCB_SHAPE* arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2019-06-24 15:27:05 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2017-01-09 17:29:40 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
|
2019-06-24 15:27:05 +00:00
|
|
|
bool immediateMode = aEvent.HasPosition();
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
arc->SetShape( SHAPE_T::ARC );
|
2019-06-15 19:42:17 +00:00
|
|
|
arc->SetFlags( IS_NEW );
|
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2019-06-24 15:27:05 +00:00
|
|
|
Activate();
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
while( drawArc( tool, &arc, immediateMode ) )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
|
|
|
if( arc )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-10-04 23:34:59 +00:00
|
|
|
static_cast<FP_SHAPE*>( arc )->SetLocalCoord();
|
2019-01-17 16:58:17 +00:00
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
commit.Add( arc );
|
|
|
|
commit.Push( _( "Draw an arc" ) );
|
2019-06-27 11:47:24 +00:00
|
|
|
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, arc );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
|
2021-07-21 18:31:25 +00:00
|
|
|
arc->SetShape( SHAPE_T::ARC );
|
2019-06-15 19:42:17 +00:00
|
|
|
arc->SetFlags( IS_NEW );
|
2019-06-24 15:27:05 +00:00
|
|
|
immediateMode = false;
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2014-02-10 09:58:58 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-02-10 09:58:58 +00:00
|
|
|
|
|
|
|
|
2016-06-08 09:24:46 +00:00
|
|
|
int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2018-05-14 03:22:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
BOARD_ITEM* text = nullptr;
|
2016-06-08 09:24:46 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
2021-04-07 13:50:18 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
|
|
|
|
|
|
|
auto cleanup =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
m_controls->ForceCursorPosition( false );
|
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
|
|
|
delete text;
|
2021-07-19 23:56:05 +00:00
|
|
|
text = nullptr;
|
2021-04-07 13:50:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
if( text )
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
|
|
|
else
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
|
|
|
|
};
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2019-07-27 05:38:04 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2016-06-08 09:24:46 +00:00
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
// do not capture or auto-pan until we start placing some text
|
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2016-06-08 09:24:46 +00:00
|
|
|
Activate();
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
// Prime the pump
|
2021-02-24 18:43:12 +00:00
|
|
|
if( !aEvent.IsReactivate() )
|
|
|
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2016-06-08 09:24:46 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2016-06-08 09:24:46 +00:00
|
|
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
2014-02-10 09:58:58 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2016-06-08 09:24:46 +00:00
|
|
|
if( text )
|
2021-04-07 13:50:18 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
2021-04-07 13:50:18 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2019-07-01 21:01:33 +00:00
|
|
|
break;
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( text )
|
|
|
|
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
|
|
|
m_frame->PopTool( tool );
|
2016-06-08 09:24:46 +00:00
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2017-02-10 22:20:18 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
2017-01-09 17:29:40 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2019-05-16 18:54:54 +00:00
|
|
|
bool placing = text != nullptr;
|
|
|
|
|
2016-06-08 09:24:46 +00:00
|
|
|
if( !text )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2020-11-08 00:14:22 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2018-11-11 13:09:02 +00:00
|
|
|
m_controls->ForceCursorPosition( true, m_controls->GetCursorPosition() );
|
2018-04-28 15:22:25 +00:00
|
|
|
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
|
|
|
|
2016-06-08 09:24:46 +00:00
|
|
|
// Init the new item attributes
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FP_TEXT* fpText = new FP_TEXT( (FOOTPRINT*) m_frame->GetModel() );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
fpText->SetLayer( layer );
|
|
|
|
fpText->SetTextSize( dsnSettings.GetTextSize( layer ) );
|
|
|
|
fpText->SetTextThickness( dsnSettings.GetTextThickness( layer ) );
|
|
|
|
fpText->SetItalic( dsnSettings.GetTextItalic( layer ) );
|
|
|
|
fpText->SetKeepUpright( dsnSettings.GetTextUpright( layer ) );
|
|
|
|
fpText->SetTextPos( (wxPoint) cursorPos );
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
text = fpText;
|
2019-05-16 18:54:54 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
DIALOG_TEXT_PROPERTIES textDialog( m_frame, fpText );
|
2019-05-16 18:54:54 +00:00
|
|
|
bool cancelled;
|
2016-09-21 09:54:58 +00:00
|
|
|
|
2020-05-09 13:10:08 +00:00
|
|
|
RunMainStack( [&]()
|
|
|
|
{
|
2020-12-01 14:58:33 +00:00
|
|
|
cancelled = !textDialog.ShowModal();
|
2020-05-09 13:10:08 +00:00
|
|
|
} );
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2020-12-01 14:58:33 +00:00
|
|
|
if( cancelled || NoPrintableChars( fpText->GetText() ) )
|
2019-05-16 18:54:54 +00:00
|
|
|
{
|
|
|
|
delete text;
|
|
|
|
text = nullptr;
|
|
|
|
}
|
2020-10-04 23:34:59 +00:00
|
|
|
else if( fpText->GetTextPos() != (wxPoint) cursorPos )
|
2019-05-16 18:54:54 +00:00
|
|
|
{
|
|
|
|
// If the user modified the location then go ahead and place it there.
|
|
|
|
// Otherwise we'll drag.
|
|
|
|
placing = true;
|
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_TEXT* pcbText = new PCB_TEXT( m_frame->GetModel() );
|
2021-07-19 23:56:05 +00:00
|
|
|
// TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an
|
|
|
|
// undo entry :| LEGACY_CLEANUP
|
2020-10-04 23:34:59 +00:00
|
|
|
pcbText->SetFlags( IS_NEW );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
pcbText->SetLayer( layer );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
|
|
|
// Set the mirrored option for layers on the BACK side of the board
|
|
|
|
if( IsBackLayer( layer ) )
|
2020-10-04 23:34:59 +00:00
|
|
|
pcbText->SetMirrored( true );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
pcbText->SetTextSize( dsnSettings.GetTextSize( layer ) );
|
|
|
|
pcbText->SetTextThickness( dsnSettings.GetTextThickness( layer ) );
|
|
|
|
pcbText->SetItalic( dsnSettings.GetTextItalic( layer ) );
|
|
|
|
pcbText->SetTextPos( (wxPoint) cursorPos );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-05-09 13:10:08 +00:00
|
|
|
RunMainStack( [&]()
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
m_frame->ShowTextPropertiesDialog( pcbText );
|
2020-05-09 13:10:08 +00:00
|
|
|
} );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
2020-12-01 14:58:33 +00:00
|
|
|
if( NoPrintableChars( pcbText->GetText() ) )
|
2020-10-04 23:34:59 +00:00
|
|
|
delete pcbText;
|
2016-06-21 15:06:28 +00:00
|
|
|
else
|
2020-10-04 23:34:59 +00:00
|
|
|
text = pcbText;
|
2016-06-08 09:24:46 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 05:09:55 +00:00
|
|
|
if( text )
|
|
|
|
{
|
2021-04-07 14:01:59 +00:00
|
|
|
if( !m_view->IsLayerVisible( text->GetLayer() ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( text->GetLayer(), true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
2019-08-01 05:09:55 +00:00
|
|
|
m_controls->WarpCursor( text->GetPosition(), true );
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
|
2020-05-09 13:10:08 +00:00
|
|
|
m_view->Update( &selection() );
|
2020-10-08 02:47:01 +00:00
|
|
|
|
|
|
|
// update the cursor so it looks correct before another event
|
|
|
|
setCursor();
|
2019-08-01 05:09:55 +00:00
|
|
|
}
|
2016-06-08 09:24:46 +00:00
|
|
|
}
|
2019-05-16 18:54:54 +00:00
|
|
|
|
|
|
|
if( placing )
|
2016-06-08 09:24:46 +00:00
|
|
|
{
|
|
|
|
text->ClearFlags();
|
2018-01-19 13:19:19 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2016-06-21 15:06:28 +00:00
|
|
|
commit.Add( text );
|
|
|
|
commit.Push( _( "Place a text" ) );
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2019-06-27 11:47:24 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
|
|
|
|
|
2019-08-01 05:09:55 +00:00
|
|
|
text = nullptr;
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2019-08-01 05:09:55 +00:00
|
|
|
|
|
|
|
m_controls->ForceCursorPosition( false );
|
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
m_controls->CaptureCursor( text != nullptr );
|
|
|
|
m_controls->SetAutoPan( text != nullptr );
|
2016-06-08 09:24:46 +00:00
|
|
|
}
|
|
|
|
else if( text && evt->IsMotion() )
|
|
|
|
{
|
2019-04-19 18:23:18 +00:00
|
|
|
text->SetPosition( (wxPoint) cursorPos );
|
2019-05-19 21:04:04 +00:00
|
|
|
selection().SetReferencePoint( cursorPos );
|
|
|
|
m_view->Update( &selection() );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
|
2018-01-19 13:20:15 +00:00
|
|
|
{
|
2020-09-17 21:29:40 +00:00
|
|
|
if( text )
|
|
|
|
{
|
|
|
|
frame()->OnEditItemRequest( text );
|
|
|
|
m_view->Update( &selection() );
|
|
|
|
frame()->SetMsgPanel( text );
|
|
|
|
}
|
2020-11-06 13:21:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2018-01-19 13:20:15 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-02-10 09:58:58 +00:00
|
|
|
}
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
|
|
|
m_frame->SetMsgPanel( board() );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2014-02-10 09:58:58 +00:00
|
|
|
return 0;
|
2014-02-10 14:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void DRAWING_TOOL::constrainDimension( PCB_DIMENSION_BASE* aDim )
|
2018-06-03 04:01:01 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
const VECTOR2I lineVector{ aDim->GetEnd() - aDim->GetStart() };
|
2018-06-03 04:01:01 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
aDim->SetEnd( wxPoint( VECTOR2I( aDim->GetStart() ) + GetVectorSnapped45( lineVector ) ) );
|
2021-01-19 16:08:37 +00:00
|
|
|
aDim->Update();
|
2018-06-03 04:01:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2018-05-14 03:22:11 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2021-04-07 13:50:18 +00:00
|
|
|
enum DIMENSION_STEPS
|
|
|
|
{
|
|
|
|
SET_ORIGIN = 0,
|
|
|
|
SET_END,
|
|
|
|
SET_HEIGHT,
|
|
|
|
FINISHED
|
|
|
|
};
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2021-04-07 13:50:18 +00:00
|
|
|
TOOL_EVENT originalEvent = aEvent;
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE* dimension = nullptr;
|
2021-04-07 13:50:18 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
|
|
|
BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
|
|
|
|
PCB_SELECTION preview; // A VIEW_GROUP that serves as a preview for the new item(s)
|
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
|
|
|
|
int step = SET_ORIGIN;
|
2017-05-04 22:43:43 +00:00
|
|
|
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Add( &preview );
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2021-04-07 13:50:18 +00:00
|
|
|
auto cleanup =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
|
|
|
|
|
|
|
preview.Clear();
|
|
|
|
m_view->Update( &preview );
|
|
|
|
|
|
|
|
delete dimension;
|
|
|
|
dimension = nullptr;
|
|
|
|
step = SET_ORIGIN;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MEASURE );
|
|
|
|
};
|
|
|
|
|
2019-07-27 05:38:04 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2014-02-14 08:49:49 +00:00
|
|
|
m_controls->ShowCursor( true );
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2014-02-11 13:38:44 +00:00
|
|
|
Activate();
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
// Prime the pump
|
2019-07-11 08:48:11 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
if( aEvent.HasPosition() )
|
2019-10-03 16:21:52 +00:00
|
|
|
m_toolMgr->PrimeTool( aEvent.Position() );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2014-02-11 13:38:44 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2020-11-05 15:05:52 +00:00
|
|
|
if( step > SET_ORIGIN )
|
|
|
|
frame()->SetMsgPanel( dimension );
|
|
|
|
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2019-06-27 21:33:48 +00:00
|
|
|
|
2018-10-06 16:50:43 +00:00
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2021-03-04 01:09:24 +00:00
|
|
|
|
|
|
|
VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() : m_controls->GetMousePosition();
|
|
|
|
|
2020-11-05 15:05:52 +00:00
|
|
|
cursorPos = grid.BestSnapAnchor( cursorPos, nullptr );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( true, cursorPos );
|
2018-10-06 16:50:43 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2018-08-06 08:15:58 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
|
2014-02-19 12:51:32 +00:00
|
|
|
if( step != SET_ORIGIN ) // start from the beginning
|
2020-11-19 20:08:58 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
2020-11-19 20:08:58 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
2014-02-19 12:51:32 +00:00
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2019-07-01 21:01:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( step != SET_ORIGIN )
|
|
|
|
cleanup();
|
2014-02-19 12:51:32 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsPointEditor() )
|
|
|
|
{
|
|
|
|
// don't exit (the point editor runs in the background)
|
2014-02-19 12:51:32 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else 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
|
|
|
m_frame->PopTool( tool );
|
2014-07-09 11:50:27 +00:00
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
m_lineWidth += WIDTH_STEP;
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetLineThickness( m_lineWidth );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2018-04-12 16:08:45 +00:00
|
|
|
frame()->SetMsgPanel( dimension );
|
2014-09-01 11:48:51 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
|
2014-09-01 11:48:51 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
if( m_lineWidth > WIDTH_STEP )
|
2014-09-01 11:48:51 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
m_lineWidth -= WIDTH_STEP;
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetLineThickness( m_lineWidth );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2018-04-12 16:08:45 +00:00
|
|
|
frame()->SetMsgPanel( dimension );
|
2014-09-01 11:48:51 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
2017-02-10 22:20:18 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
2017-01-09 17:29:40 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
|
|
|
switch( step )
|
|
|
|
{
|
2014-02-14 10:35:48 +00:00
|
|
|
case SET_ORIGIN:
|
2017-05-04 22:43:43 +00:00
|
|
|
{
|
2019-06-27 11:47:24 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2020-06-27 21:08:13 +00:00
|
|
|
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
// Init the new item attributes
|
2020-09-22 02:32:40 +00:00
|
|
|
auto setMeasurementAttributes =
|
2021-06-11 16:59:28 +00:00
|
|
|
[&]( PCB_DIMENSION_BASE* aDim )
|
2020-09-22 02:32:40 +00:00
|
|
|
{
|
|
|
|
aDim->SetUnitsMode( boardSettings.m_DimensionUnitsMode );
|
|
|
|
aDim->SetUnitsFormat( boardSettings.m_DimensionUnitsFormat );
|
|
|
|
aDim->SetPrecision( boardSettings.m_DimensionPrecision );
|
|
|
|
aDim->SetSuppressZeroes( boardSettings.m_DimensionSuppressZeroes );
|
|
|
|
aDim->SetTextPositionMode( boardSettings.m_DimensionTextPosition );
|
|
|
|
aDim->SetKeepTextAligned( boardSettings.m_DimensionKeepTextAligned );
|
|
|
|
|
|
|
|
if( boardSettings.m_DimensionUnitsMode == DIM_UNITS_MODE::AUTOMATIC )
|
2020-10-02 20:51:24 +00:00
|
|
|
aDim->SetUnits( m_frame->GetUserUnits() );
|
2020-09-22 02:32:40 +00:00
|
|
|
};
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
if( originalEvent.IsAction( &PCB_ACTIONS::drawAlignedDimension ) )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
dimension = new PCB_DIM_ALIGNED( m_board );
|
2020-09-22 02:32:40 +00:00
|
|
|
setMeasurementAttributes( dimension );
|
|
|
|
}
|
|
|
|
else if( originalEvent.IsAction( &PCB_ACTIONS::drawOrthogonalDimension ) )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
dimension = new PCB_DIM_ORTHOGONAL( m_board );
|
2020-09-22 02:32:40 +00:00
|
|
|
setMeasurementAttributes( dimension );
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
2020-09-17 00:54:58 +00:00
|
|
|
else if( originalEvent.IsAction( &PCB_ACTIONS::drawCenterDimension ) )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
dimension = new PCB_DIM_CENTER( m_board );
|
2020-09-17 00:54:58 +00:00
|
|
|
}
|
2020-09-12 20:09:40 +00:00
|
|
|
else if( originalEvent.IsAction( &PCB_ACTIONS::drawLeader ) )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
dimension = new PCB_DIM_LEADER( m_board );
|
2020-09-12 20:09:40 +00:00
|
|
|
dimension->Text().SetPosition( wxPoint( cursorPos ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( "Unhandled action in DRAWING_TOOL::DrawDimension" );
|
|
|
|
}
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
dimension->SetLayer( layer );
|
2018-04-28 15:22:25 +00:00
|
|
|
dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
|
2020-04-14 12:25:00 +00:00
|
|
|
dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetLineThickness( boardSettings.GetLineThickness( layer ) );
|
2020-09-12 00:36:43 +00:00
|
|
|
dimension->SetArrowLength( boardSettings.m_DimensionArrowLength );
|
2020-09-12 15:46:33 +00:00
|
|
|
dimension->SetExtensionOffset( boardSettings.m_DimensionExtensionOffset );
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetStart( (wxPoint) cursorPos );
|
|
|
|
dimension->SetEnd( (wxPoint) cursorPos );
|
2021-01-19 16:08:37 +00:00
|
|
|
dimension->Update();
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2021-04-07 14:01:59 +00:00
|
|
|
if( !m_view->IsLayerVisible( layer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( layer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
preview.Add( dimension );
|
2020-11-05 15:05:52 +00:00
|
|
|
frame()->SetMsgPanel( dimension );
|
2014-02-19 12:51:32 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
m_controls->SetAutoPan( true );
|
|
|
|
m_controls->CaptureCursor( true );
|
2020-11-06 13:21:03 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2014-02-14 14:13:42 +00:00
|
|
|
case SET_END:
|
2020-09-17 00:54:58 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetEnd( (wxPoint) cursorPos );
|
2021-01-19 16:08:37 +00:00
|
|
|
dimension->Update();
|
2014-02-19 14:20:42 +00:00
|
|
|
|
2021-05-09 19:17:01 +00:00
|
|
|
if( !!evt->Modifier( MD_SHIFT ) || dimension->Type() == PCB_DIM_CENTER_T )
|
2018-06-03 04:01:01 +00:00
|
|
|
constrainDimension( dimension );
|
|
|
|
|
2014-02-14 14:13:42 +00:00
|
|
|
// Dimensions that have origin and end in the same spot are not valid
|
2020-09-09 03:17:08 +00:00
|
|
|
if( dimension->GetStart() == dimension->GetEnd() )
|
2014-02-14 14:13:42 +00:00
|
|
|
--step;
|
2020-09-12 20:09:40 +00:00
|
|
|
else if( dimension->Type() == PCB_DIM_LEADER_T )
|
|
|
|
dimension->SetText( wxT( "?" ) );
|
2017-05-04 22:43:43 +00:00
|
|
|
|
2020-09-17 00:54:58 +00:00
|
|
|
if( dimension->Type() == PCB_DIM_CENTER_T )
|
|
|
|
{
|
|
|
|
// No separate height/text step
|
|
|
|
++step;
|
|
|
|
KI_FALLTHROUGH;
|
|
|
|
}
|
|
|
|
else
|
2020-11-06 13:21:03 +00:00
|
|
|
{
|
2020-09-17 00:54:58 +00:00
|
|
|
break;
|
2020-11-06 13:21:03 +00:00
|
|
|
}
|
2020-09-17 00:54:58 +00:00
|
|
|
}
|
2014-02-14 14:13:42 +00:00
|
|
|
|
2014-02-14 10:35:48 +00:00
|
|
|
case SET_HEIGHT:
|
2020-09-12 20:09:40 +00:00
|
|
|
if( dimension->Type() == PCB_DIM_LEADER_T )
|
|
|
|
{
|
|
|
|
assert( dimension->GetStart() != dimension->GetEnd() );
|
|
|
|
assert( dimension->GetLineThickness() > 0 );
|
|
|
|
|
|
|
|
preview.Remove( dimension );
|
|
|
|
|
|
|
|
commit.Add( dimension );
|
|
|
|
commit.Push( _( "Draw a leader" ) );
|
|
|
|
|
|
|
|
// Run the edit immediately to set the leader text
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::properties, true, dimension );
|
|
|
|
}
|
|
|
|
else if( (wxPoint) cursorPos != dimension->GetPosition() )
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2020-09-09 03:17:08 +00:00
|
|
|
assert( dimension->GetStart() != dimension->GetEnd() );
|
|
|
|
assert( dimension->GetLineThickness() > 0 );
|
2014-02-19 12:51:32 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
preview.Remove( dimension );
|
2016-06-08 09:24:46 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
commit.Add( dimension );
|
|
|
|
commit.Push( _( "Draw a dimension" ) );
|
2019-06-27 11:47:24 +00:00
|
|
|
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension );
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
2020-09-17 00:54:58 +00:00
|
|
|
|
|
|
|
break;
|
2017-05-04 22:43:43 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2014-02-14 10:35:48 +00:00
|
|
|
if( ++step == FINISHED )
|
2014-02-19 12:51:32 +00:00
|
|
|
{
|
|
|
|
step = SET_ORIGIN;
|
|
|
|
m_controls->SetAutoPan( false );
|
2015-03-10 13:43:14 +00:00
|
|
|
m_controls->CaptureCursor( false );
|
2014-02-19 12:51:32 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsMotion() )
|
|
|
|
{
|
|
|
|
switch( step )
|
|
|
|
{
|
2014-02-14 10:35:48 +00:00
|
|
|
case SET_END:
|
2020-09-09 03:17:08 +00:00
|
|
|
dimension->SetEnd( (wxPoint) cursorPos );
|
2021-03-05 14:40:02 +00:00
|
|
|
|
|
|
|
if( dimension->Type() == PCB_DIM_ORTHOGONAL_T )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIM_ORTHOGONAL* ortho = static_cast<PCB_DIM_ORTHOGONAL*>( dimension );
|
2021-03-05 14:40:02 +00:00
|
|
|
|
|
|
|
BOX2I bounds( dimension->GetStart(),
|
|
|
|
dimension->GetEnd() - dimension->GetStart() );
|
|
|
|
|
|
|
|
// Create a nice preview by measuring the longer dimension
|
|
|
|
bool vert = bounds.GetWidth() < bounds.GetHeight();
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
ortho->SetOrientation( vert ? PCB_DIM_ORTHOGONAL::DIR::VERTICAL
|
|
|
|
: PCB_DIM_ORTHOGONAL::DIR::HORIZONTAL );
|
2021-03-05 14:40:02 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 16:08:37 +00:00
|
|
|
dimension->Update();
|
2018-06-03 04:01:01 +00:00
|
|
|
|
2021-05-09 19:17:01 +00:00
|
|
|
if( !!evt->Modifier( MD_SHIFT ) || dimension->Type() == PCB_DIM_CENTER_T )
|
2018-06-03 04:01:01 +00:00
|
|
|
constrainDimension( dimension );
|
|
|
|
|
2014-02-11 13:38:44 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-14 10:35:48 +00:00
|
|
|
case SET_HEIGHT:
|
2014-02-11 13:38:44 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
if( dimension->Type() == PCB_DIM_ALIGNED_T )
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIM_ALIGNED* aligned = static_cast<PCB_DIM_ALIGNED*>( dimension );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
// Calculating the direction of travel perpendicular to the selected axis
|
|
|
|
double angle = aligned->GetAngle() + ( M_PI / 2 );
|
2014-02-11 13:38:44 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
wxPoint delta( (wxPoint) cursorPos - dimension->GetEnd() );
|
|
|
|
double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
|
|
|
|
aligned->SetHeight( height );
|
2021-01-19 16:08:37 +00:00
|
|
|
aligned->Update();
|
2020-09-12 20:09:40 +00:00
|
|
|
}
|
2020-09-22 02:32:40 +00:00
|
|
|
else if( dimension->Type() == PCB_DIM_ORTHOGONAL_T )
|
2020-09-12 20:09:40 +00:00
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIM_ORTHOGONAL* ortho = static_cast<PCB_DIM_ORTHOGONAL*>( dimension );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2021-03-05 14:40:02 +00:00
|
|
|
BOX2I bounds( dimension->GetStart(),
|
2020-09-22 02:32:40 +00:00
|
|
|
dimension->GetEnd() - dimension->GetStart() );
|
|
|
|
VECTOR2I direction( cursorPos - bounds.Centre() );
|
2021-03-05 14:40:02 +00:00
|
|
|
bool vert;
|
2020-09-22 02:32:40 +00:00
|
|
|
|
|
|
|
// Only change the orientation when we move outside the bounds
|
|
|
|
if( !bounds.Contains( cursorPos ) )
|
|
|
|
{
|
2021-03-05 14:40:02 +00:00
|
|
|
// If the dimension is horizontal or vertical, set correct orientation
|
|
|
|
// otherwise, test if we're left/right of the bounding box or above/below it
|
|
|
|
if( bounds.GetWidth() == 0 )
|
|
|
|
{
|
|
|
|
vert = true;
|
|
|
|
}
|
|
|
|
else if( bounds.GetHeight() == 0 )
|
|
|
|
{
|
|
|
|
vert = false;
|
|
|
|
}
|
|
|
|
else if( cursorPos.x > bounds.GetLeft() && cursorPos.x < bounds.GetRight() )
|
|
|
|
{
|
|
|
|
vert = false;
|
|
|
|
}
|
|
|
|
else if( cursorPos.y > bounds.GetTop() && cursorPos.y < bounds.GetBottom() )
|
|
|
|
{
|
|
|
|
vert = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vert = std::abs( direction.y ) < std::abs( direction.x );
|
|
|
|
}
|
2021-06-11 16:59:28 +00:00
|
|
|
ortho->SetOrientation( vert ? PCB_DIM_ORTHOGONAL::DIR::VERTICAL
|
|
|
|
: PCB_DIM_ORTHOGONAL::DIR::HORIZONTAL );
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-11 16:59:28 +00:00
|
|
|
vert = ortho->GetOrientation() == PCB_DIM_ORTHOGONAL::DIR::VERTICAL;
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VECTOR2I heightVector( cursorPos - dimension->GetStart() );
|
|
|
|
ortho->SetHeight( vert ? heightVector.x : heightVector.y );
|
2021-01-19 16:08:37 +00:00
|
|
|
ortho->Update();
|
2020-09-22 02:32:40 +00:00
|
|
|
}
|
|
|
|
else if( dimension->Type() == PCB_DIM_LEADER_T )
|
|
|
|
{
|
|
|
|
// Leader: SET_HEIGHT actually sets the text position directly
|
2020-09-12 20:09:40 +00:00
|
|
|
VECTOR2I lineVector( cursorPos - dimension->GetEnd() );
|
|
|
|
dimension->Text().SetPosition( wxPoint( VECTOR2I( dimension->GetEnd() ) +
|
|
|
|
GetVectorSnapped45( lineVector ) ) );
|
|
|
|
dimension->Update();
|
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show a preview of the item
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
2021-04-07 14:01:59 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
|
|
|
|
{
|
|
|
|
if( dimension )
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
|
|
|
|
|
|
|
if( !m_view->IsLayerVisible( layer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( layer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
dimension->SetLayer( layer );
|
|
|
|
dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
|
|
|
|
dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) );
|
|
|
|
dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
|
|
|
|
dimension->SetLineThickness( boardSettings.GetLineThickness( layer ) );
|
|
|
|
dimension->Update();
|
|
|
|
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( dimension );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
|
|
|
|
{
|
2020-11-06 13:21:03 +00:00
|
|
|
if( step == SET_END || step == SET_HEIGHT )
|
2020-09-17 21:29:40 +00:00
|
|
|
{
|
|
|
|
frame()->OnEditItemRequest( dimension );
|
|
|
|
dimension->Update();
|
|
|
|
frame()->SetMsgPanel( dimension );
|
2020-11-06 13:21:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
2020-09-17 21:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-02-11 13:38:44 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 12:51:32 +00:00
|
|
|
if( step != SET_ORIGIN )
|
|
|
|
delete dimension;
|
|
|
|
|
2018-08-06 08:15:58 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
2019-05-11 08:02:59 +00:00
|
|
|
m_controls->ForceCursorPosition( false );
|
2019-08-29 22:07:57 +00:00
|
|
|
m_controls->CaptureCursor( false );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2018-08-06 08:15:58 +00:00
|
|
|
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Remove( &preview );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->SetMsgPanel( board() );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2014-02-11 13:38:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-01 09:47:41 +00:00
|
|
|
int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2016-06-08 09:24:46 +00:00
|
|
|
if( !m_frame->GetModel() )
|
2015-09-13 16:44:07 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
// Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
|
2019-05-31 23:24:38 +00:00
|
|
|
// items if needed
|
2020-11-07 17:50:22 +00:00
|
|
|
DIALOG_IMPORT_GFX dlg( m_frame, m_isFootprintEditor );
|
2014-07-09 13:02:56 +00:00
|
|
|
int dlgResult = dlg.ShowModal();
|
|
|
|
|
2020-08-20 00:22:48 +00:00
|
|
|
std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
if( dlgResult != wxID_OK )
|
2014-07-09 13:02:56 +00:00
|
|
|
return 0;
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
// Ensure the list is not empty:
|
|
|
|
if( list.empty() )
|
|
|
|
{
|
2021-06-22 11:52:40 +00:00
|
|
|
wxMessageBox( _( "No graphic items found in file.") );
|
2018-11-05 16:04:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-27 11:47:24 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
2018-11-05 16:04:05 +00:00
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
std::vector<BOARD_ITEM*> newItems; // all new items, including group
|
|
|
|
std::vector<BOARD_ITEM*> selectedItems; // the group, or newItems if no group
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION preview;
|
2020-11-27 18:02:31 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
PCB_GROUP* group = nullptr;
|
2020-08-20 00:22:48 +00:00
|
|
|
|
|
|
|
if( dlg.ShouldGroupItems() )
|
2020-10-26 23:52:53 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-11-27 18:02:31 +00:00
|
|
|
group = new PCB_GROUP( m_frame->GetBoard()->GetFirstFootprint() );
|
2020-10-26 23:52:53 +00:00
|
|
|
else
|
2020-11-27 18:02:31 +00:00
|
|
|
group = new PCB_GROUP( m_frame->GetBoard() );
|
|
|
|
|
|
|
|
newItems.push_back( group );
|
|
|
|
selectedItems.push_back( group );
|
|
|
|
preview.Add( group );
|
2020-10-26 23:52:53 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
for( std::unique_ptr<EDA_ITEM>& ptr : list )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2020-11-27 18:02:31 +00:00
|
|
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ptr.get() );
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-10-04 14:19:33 +00:00
|
|
|
wxASSERT( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_FP_TEXT_T );
|
2018-11-05 16:04:05 +00:00
|
|
|
else
|
2020-10-04 14:19:33 +00:00
|
|
|
wxASSERT( item->Type() == PCB_SHAPE_T || item->Type() == PCB_TEXT_T );
|
2018-11-05 16:04:05 +00:00
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
newItems.push_back( item );
|
|
|
|
|
|
|
|
if( group )
|
|
|
|
group->AddItem( item );
|
2018-11-05 16:04:05 +00:00
|
|
|
else
|
2020-11-27 18:02:31 +00:00
|
|
|
selectedItems.push_back( item );
|
|
|
|
|
|
|
|
preview.Add( item );
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
ptr.release();
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
if( !dlg.IsPlacementInteractive() )
|
|
|
|
{
|
2020-11-27 18:02:31 +00:00
|
|
|
for( BOARD_ITEM* item : newItems )
|
|
|
|
commit.Add( item );
|
2020-08-20 00:22:48 +00:00
|
|
|
|
2018-11-05 16:04:05 +00:00
|
|
|
commit.Push( _( "Place a DXF_SVG drawing" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Add( &preview );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-08-20 00:22:48 +00:00
|
|
|
// Clear the current selection then select the drawings so that edit tools work on them
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2020-11-27 18:02:31 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
|
2020-08-20 00:22:48 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
m_controls->ShowCursor( true );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( false );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
|
|
|
|
|
2018-07-07 11:04:01 +00:00
|
|
|
// Now move the new items to the current cursor position:
|
2018-10-13 18:37:28 +00:00
|
|
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
2020-11-27 18:02:31 +00:00
|
|
|
VECTOR2I delta = cursorPos - static_cast<BOARD_ITEM*>( preview.Front() )->GetPosition();
|
2018-07-07 11:04:01 +00:00
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
for( BOARD_ITEM* item : selectedItems )
|
|
|
|
item->Move( (wxPoint) delta );
|
2018-07-07 11:04:01 +00:00
|
|
|
|
|
|
|
m_view->Update( &preview );
|
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2014-07-09 13:02:56 +00:00
|
|
|
Activate();
|
2020-10-09 01:15:03 +00:00
|
|
|
|
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
2020-10-08 02:47:01 +00:00
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
|
|
|
};
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2014-07-09 13:02:56 +00:00
|
|
|
cursorPos = m_controls->GetCursorPosition();
|
|
|
|
|
2019-07-09 23:51:47 +00:00
|
|
|
if( evt->IsCancelInteractive() || evt->IsActivate() )
|
|
|
|
{
|
2020-08-20 00:22:48 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
for( BOARD_ITEM* item : newItems )
|
|
|
|
delete item;
|
2020-08-20 00:22:48 +00:00
|
|
|
|
2019-07-09 23:51:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if( evt->IsMotion() )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2020-11-27 18:02:31 +00:00
|
|
|
delta = cursorPos - static_cast<BOARD_ITEM*>( preview.Front() )->GetPosition();
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-11-27 18:02:31 +00:00
|
|
|
for( BOARD_ITEM* item : selectedItems )
|
|
|
|
item->Move( (wxPoint) delta );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2017-02-10 22:20:18 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
2017-01-09 17:29:40 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2020-12-14 22:03:17 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2018-11-05 16:04:05 +00:00
|
|
|
// Place the imported drawings
|
2020-11-27 18:02:31 +00:00
|
|
|
for( BOARD_ITEM* item : newItems )
|
2018-11-05 16:04:05 +00:00
|
|
|
commit.Add( item );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2018-11-01 09:47:41 +00:00
|
|
|
commit.Push( _( "Place a DXF_SVG drawing" ) );
|
2019-08-29 22:02:51 +00:00
|
|
|
break; // This is a one-shot command, not a tool
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
preview.Clear();
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Remove( &preview );
|
2020-11-19 20:08:58 +00:00
|
|
|
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2019-08-29 22:02:51 +00:00
|
|
|
m_frame->PopTool( tool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 20:28:47 +00:00
|
|
|
int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
wxASSERT( m_isFootprintEditor );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2018-05-14 03:22:11 +00:00
|
|
|
if( !m_frame->GetModel() )
|
|
|
|
return 0;
|
|
|
|
|
2021-06-20 10:02:44 +00:00
|
|
|
if( m_inDrawingTool )
|
|
|
|
return 0;
|
2021-07-27 15:36:46 +00:00
|
|
|
|
|
|
|
REENTRANCY_GUARD guard( &m_inDrawingTool );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2017-01-09 17:29:40 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
|
2021-03-12 17:37:09 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
2017-01-09 17:29:40 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2014-07-09 12:01:06 +00:00
|
|
|
Activate();
|
|
|
|
|
2019-07-27 05:38:04 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2015-03-10 13:43:14 +00:00
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
m_controls->SetAutoPan( true );
|
|
|
|
m_controls->CaptureCursor( false );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2020-10-09 01:15:03 +00:00
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
2020-10-08 02:47:01 +00:00
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
|
|
|
|
};
|
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2019-06-08 17:23:38 +00:00
|
|
|
|
2019-08-28 04:38:27 +00:00
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2020-11-04 14:08:06 +00:00
|
|
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(),
|
|
|
|
LSET::AllLayersMask() );
|
2019-08-28 04:38:27 +00:00
|
|
|
m_controls->ForceCursorPosition( true, cursorPos );
|
|
|
|
|
2020-12-14 22:03:17 +00:00
|
|
|
if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = (FOOTPRINT*) m_frame->GetModel();
|
2016-06-21 15:06:28 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2020-11-13 15:15:52 +00:00
|
|
|
commit.Modify( footprint );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
|
|
|
// set the new relative internal local coordinates of footprint items
|
2020-11-13 15:15:52 +00:00
|
|
|
wxPoint moveVector = footprint->GetPosition() - (wxPoint) cursorPos;
|
|
|
|
footprint->MoveAnchorPosition( moveVector );
|
2016-06-21 15:06:28 +00:00
|
|
|
|
|
|
|
commit.Push( _( "Move the footprint reference anchor" ) );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
// Usually, we do not need to change twice the anchor position,
|
|
|
|
// so deselect the active tool
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2014-07-09 12:01:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-10 22:20:18 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
2017-01-09 17:29:40 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2014-07-09 12:01:06 +00:00
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
|
|
|
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2021-06-20 10:02:44 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-05 23:43:32 +00:00
|
|
|
int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
m_frame->Settings().m_Use45DegreeGraphicSegments =
|
|
|
|
!m_frame->Settings().m_Use45DegreeGraphicSegments;
|
2021-02-05 23:43:32 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-03 15:05:17 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Update a #PCB_SHAPE from the current state of a #TWO_POINT_GEOMETRY_MANAGER.
|
2020-07-03 15:05:17 +00:00
|
|
|
*/
|
2020-11-04 14:08:06 +00:00
|
|
|
static void updateSegmentFromGeometryMgr( const KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER& aMgr,
|
|
|
|
PCB_SHAPE* aGraphic )
|
2020-07-03 15:05:17 +00:00
|
|
|
{
|
2020-11-05 15:05:52 +00:00
|
|
|
if( !aMgr.IsReset() )
|
|
|
|
{
|
|
|
|
aGraphic->SetStart( (wxPoint) aMgr.GetOrigin() );
|
|
|
|
aGraphic->SetEnd( (wxPoint) aMgr.GetEnd() );
|
|
|
|
}
|
2020-07-03 15:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-05 15:05:52 +00:00
|
|
|
bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
|
2019-07-15 12:15:58 +00:00
|
|
|
OPT<VECTOR2D> aStartingPoint )
|
2014-02-11 16:15:33 +00:00
|
|
|
{
|
2021-07-21 18:31:25 +00:00
|
|
|
SHAPE_T shape = ( *aGraphic )->GetShape();
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-06-15 19:50:20 +00:00
|
|
|
// Only three shapes are currently supported
|
2021-07-21 18:31:25 +00:00
|
|
|
wxASSERT( shape == SHAPE_T::SEGMENT || shape == SHAPE_T::CIRCLE || shape == SHAPE_T::RECT );
|
2020-11-05 15:05:52 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
EDA_UNITS userUnits = m_frame->GetUserUnits();
|
2021-01-16 23:17:32 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
2021-04-05 22:29:12 +00:00
|
|
|
PCB_SHAPE*& graphic = *aGraphic;
|
|
|
|
PCB_LAYER_ID drawingLayer = m_frame->GetActiveLayer();
|
2014-02-17 10:33:03 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2018-10-03 12:57:02 +00:00
|
|
|
|
2020-07-03 15:05:17 +00:00
|
|
|
// geometric construction manager
|
|
|
|
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPointManager;
|
|
|
|
|
|
|
|
// drawing assistant overlay
|
2020-10-04 14:19:33 +00:00
|
|
|
// TODO: workaround because PCB_SHAPE_TYPE_T is not visible from commons.
|
2020-11-05 15:05:52 +00:00
|
|
|
KIGFX::PREVIEW::GEOM_SHAPE geomShape( static_cast<KIGFX::PREVIEW::GEOM_SHAPE>( shape ) );
|
|
|
|
KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointManager, userUnits, geomShape );
|
2020-07-03 15:05:17 +00:00
|
|
|
|
2014-02-11 16:15:33 +00:00
|
|
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION preview;
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Add( &preview );
|
2020-07-03 15:05:17 +00:00
|
|
|
m_view->Add( &twoPointAsst );
|
2014-02-11 16:15:33 +00:00
|
|
|
|
2014-02-14 09:47:43 +00:00
|
|
|
m_controls->ShowCursor( true );
|
2014-02-11 16:15:33 +00:00
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
bool started = false;
|
2019-07-01 21:01:33 +00:00
|
|
|
bool cancelled = false;
|
2019-06-13 13:34:38 +00:00
|
|
|
bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) );
|
2018-10-07 03:20:38 +00:00
|
|
|
VECTOR2I cursorPos = m_controls->GetMousePosition();
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2020-10-09 01:15:03 +00:00
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
2020-10-08 02:47:01 +00:00
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
|
|
|
};
|
2020-10-06 09:57:30 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
auto cleanup =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
preview.Clear();
|
|
|
|
m_view->Update( &preview );
|
|
|
|
delete graphic;
|
|
|
|
graphic = nullptr;
|
|
|
|
|
|
|
|
if( !isLocalOriginSet )
|
|
|
|
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Prime the pump
|
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
|
|
|
|
|
|
|
if( aStartingPoint )
|
|
|
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2014-02-11 16:15:33 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-02-11 16:15:33 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-11-05 15:05:52 +00:00
|
|
|
|
|
|
|
if( started )
|
|
|
|
m_frame->SetMsgPanel( graphic );
|
2020-09-15 18:21:10 +00:00
|
|
|
|
2018-10-04 00:15:54 +00:00
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2021-04-05 22:29:12 +00:00
|
|
|
cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), drawingLayer );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( true, cursorPos );
|
2014-02-11 16:15:33 +00:00
|
|
|
|
2017-01-10 11:16:47 +00:00
|
|
|
// 45 degree angle constraint enabled with an option and toggled with Ctrl
|
2019-06-27 11:47:24 +00:00
|
|
|
bool limit45 = frame()->Settings().m_Use45DegreeGraphicSegments;
|
|
|
|
|
2021-05-09 19:17:01 +00:00
|
|
|
if( evt->Modifier( MD_SHIFT ) )
|
2019-06-27 11:47:24 +00:00
|
|
|
limit45 = !limit45;
|
2017-01-10 11:16:47 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
2014-02-14 14:13:42 +00:00
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
|
|
|
|
|
|
|
if( !started )
|
2019-06-24 15:27:05 +00:00
|
|
|
{
|
2021-05-25 23:45:57 +00:00
|
|
|
// We've handled the cancel event. Don't cancel other tools
|
|
|
|
evt->SetPassEvent( false );
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( aTool );
|
2019-07-01 21:01:33 +00:00
|
|
|
cancelled = true;
|
2019-06-24 15:27:05 +00:00
|
|
|
}
|
2019-07-03 10:42:56 +00:00
|
|
|
|
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( evt->IsPointEditor() )
|
|
|
|
{
|
|
|
|
// don't exit (the point editor runs in the background)
|
|
|
|
}
|
|
|
|
else if( evt->IsMoveTool() )
|
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
2019-07-01 21:01:33 +00:00
|
|
|
// leave ourselves on the stack so we come back after the move
|
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( aTool );
|
2019-07-01 21:01:33 +00:00
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
2014-02-14 14:13:42 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
|
2017-02-08 09:13:43 +00:00
|
|
|
{
|
2021-04-05 22:29:12 +00:00
|
|
|
drawingLayer = m_frame->GetActiveLayer();
|
2021-04-07 14:01:59 +00:00
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2021-04-05 22:29:12 +00:00
|
|
|
|
2021-04-07 14:01:59 +00:00
|
|
|
if( graphic )
|
2021-04-05 22:29:12 +00:00
|
|
|
{
|
2021-04-07 14:01:59 +00:00
|
|
|
if( !m_view->IsLayerVisible( drawingLayer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
2021-04-05 22:29:12 +00:00
|
|
|
|
2021-04-07 14:01:59 +00:00
|
|
|
graphic->SetLayer( drawingLayer );
|
|
|
|
graphic->SetWidth( m_lineWidth );
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( graphic );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2017-02-08 09:13:43 +00:00
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
|
|
|
|
{
|
|
|
|
if( started )
|
|
|
|
{
|
|
|
|
frame()->OnEditItemRequest( graphic );
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( graphic );
|
2020-11-06 13:21:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
2020-09-17 21:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-09 17:29:40 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2015-07-03 18:58:13 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
2014-02-11 16:15:33 +00:00
|
|
|
{
|
2014-07-09 12:01:06 +00:00
|
|
|
if( !started )
|
2014-02-14 09:47:43 +00:00
|
|
|
{
|
2019-06-27 11:47:24 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
if( aStartingPoint )
|
|
|
|
{
|
|
|
|
cursorPos = aStartingPoint.get();
|
|
|
|
aStartingPoint = NULLOPT;
|
|
|
|
}
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2018-10-18 14:15:22 +00:00
|
|
|
|
2017-02-08 09:13:43 +00:00
|
|
|
// Init the new item attributes
|
2021-07-21 18:31:25 +00:00
|
|
|
graphic->SetShape( static_cast<SHAPE_T>( shape ) );
|
2020-11-14 01:16:02 +00:00
|
|
|
graphic->SetFilled( false );
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2021-04-05 22:29:12 +00:00
|
|
|
graphic->SetLayer( drawingLayer );
|
2020-01-19 04:42:10 +00:00
|
|
|
grid.SetSkipPoint( cursorPos );
|
2014-02-14 09:47:43 +00:00
|
|
|
|
2020-07-03 15:05:17 +00:00
|
|
|
twoPointManager.SetOrigin( (wxPoint) cursorPos );
|
|
|
|
twoPointManager.SetEnd( (wxPoint) cursorPos );
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
if( !isLocalOriginSet )
|
|
|
|
m_frame->GetScreen()->m_LocalOrigin = cursorPos;
|
2017-12-21 20:49:52 +00:00
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
preview.Add( graphic );
|
2020-11-05 15:05:52 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2017-02-08 09:13:43 +00:00
|
|
|
m_controls->SetAutoPan( true );
|
|
|
|
m_controls->CaptureCursor( true );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
if( !m_view->IsLayerVisible( drawingLayer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
2020-11-04 14:08:06 +00:00
|
|
|
updateSegmentFromGeometryMgr( twoPointManager, graphic );
|
2020-07-03 15:05:17 +00:00
|
|
|
|
2017-02-08 09:13:43 +00:00
|
|
|
started = true;
|
2014-02-14 09:47:43 +00:00
|
|
|
}
|
2021-07-21 18:31:25 +00:00
|
|
|
else if( shape == SHAPE_T::CIRCLE )
|
2021-01-15 18:00:39 +00:00
|
|
|
{
|
|
|
|
// No clever logic if drawing a circle
|
|
|
|
preview.Clear();
|
|
|
|
twoPointManager.Reset();
|
|
|
|
break;
|
|
|
|
}
|
2014-02-14 09:47:43 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE* snapItem = dyn_cast<PCB_SHAPE*>( grid.GetSnapped() );
|
2018-11-24 15:58:33 +00:00
|
|
|
|
2020-07-03 15:05:17 +00:00
|
|
|
if( twoPointManager.GetOrigin() == twoPointManager.GetEnd()
|
2021-07-21 18:31:25 +00:00
|
|
|
|| ( evt->IsDblClick( BUT_LEFT ) && shape == SHAPE_T::SEGMENT )
|
2021-05-01 02:33:25 +00:00
|
|
|
|| snapItem )
|
2017-05-04 22:43:43 +00:00
|
|
|
// User has clicked twice in the same spot
|
2018-11-24 15:58:33 +00:00
|
|
|
// or clicked on the end of an existing segment (closing a path)
|
2017-05-04 22:43:43 +00:00
|
|
|
{
|
2018-11-24 15:58:33 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
|
|
|
// If the user clicks on an existing snap point from a drawsegment
|
|
|
|
// we finish the segment as they are likely closing a path
|
2021-05-01 02:33:25 +00:00
|
|
|
if( snapItem
|
2021-07-21 18:31:25 +00:00
|
|
|
&& ( shape == SHAPE_T::RECT || graphic->GetLength() > 0.0 ) )
|
2018-11-24 15:58:33 +00:00
|
|
|
{
|
2020-06-16 09:47:07 +00:00
|
|
|
commit.Add( graphic );
|
2019-06-27 11:47:24 +00:00
|
|
|
commit.Push( _( "Draw a line segment" ) );
|
2020-06-16 09:47:07 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, graphic );
|
2019-06-27 11:47:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-16 09:47:07 +00:00
|
|
|
delete graphic;
|
2015-07-03 18:58:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic = nullptr;
|
2015-07-03 18:58:13 +00:00
|
|
|
}
|
2014-07-09 12:01:06 +00:00
|
|
|
|
|
|
|
preview.Clear();
|
2020-11-05 15:05:52 +00:00
|
|
|
twoPointManager.Reset();
|
2014-07-09 12:01:06 +00:00
|
|
|
break;
|
2014-02-14 09:47:43 +00:00
|
|
|
}
|
2020-07-03 15:05:17 +00:00
|
|
|
|
|
|
|
twoPointManager.SetEnd( cursorPos );
|
2014-02-11 16:15:33 +00:00
|
|
|
}
|
2014-07-09 12:01:06 +00:00
|
|
|
else if( evt->IsMotion() )
|
2014-02-11 16:15:33 +00:00
|
|
|
{
|
2014-02-14 09:47:43 +00:00
|
|
|
// 45 degree lines
|
2021-05-01 02:33:25 +00:00
|
|
|
if( started
|
2021-07-21 18:31:25 +00:00
|
|
|
&& ( ( limit45 && shape == SHAPE_T::SEGMENT )
|
|
|
|
|| ( evt->Modifier( MD_SHIFT ) && shape == SHAPE_T::RECT ) ) )
|
2018-12-08 06:07:53 +00:00
|
|
|
{
|
2020-07-03 15:05:17 +00:00
|
|
|
const VECTOR2I lineVector( cursorPos - VECTOR2I( twoPointManager.GetOrigin() ) );
|
2018-12-08 06:07:53 +00:00
|
|
|
|
|
|
|
// get a restricted 45/H/V line from the last fixed point to the cursor
|
2021-07-21 18:31:25 +00:00
|
|
|
auto newEnd = GetVectorSnapped45( lineVector, ( shape == SHAPE_T::RECT ) );
|
2020-07-03 15:05:17 +00:00
|
|
|
m_controls->ForceCursorPosition( true, VECTOR2I( twoPointManager.GetEnd() ) );
|
|
|
|
twoPointManager.SetEnd( twoPointManager.GetOrigin() + (wxPoint) newEnd );
|
|
|
|
twoPointManager.SetAngleSnap( true );
|
2018-12-08 06:07:53 +00:00
|
|
|
}
|
2014-02-14 09:47:43 +00:00
|
|
|
else
|
2020-07-03 15:05:17 +00:00
|
|
|
{
|
|
|
|
twoPointManager.SetEnd( (wxPoint) cursorPos );
|
|
|
|
twoPointManager.SetAngleSnap( false );
|
|
|
|
}
|
2014-02-14 09:47:43 +00:00
|
|
|
|
2020-11-04 14:08:06 +00:00
|
|
|
updateSegmentFromGeometryMgr( twoPointManager, graphic );
|
2017-02-08 09:13:43 +00:00
|
|
|
m_view->Update( &preview );
|
2020-07-03 15:05:17 +00:00
|
|
|
m_view->Update( &twoPointAsst );
|
2014-02-11 16:15:33 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
|
2014-08-04 12:23:19 +00:00
|
|
|
{
|
2015-02-15 22:21:52 +00:00
|
|
|
m_lineWidth += WIDTH_STEP;
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2017-02-08 09:13:43 +00:00
|
|
|
m_view->Update( &preview );
|
2020-06-16 09:47:07 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2014-08-04 12:23:19 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
|
2014-08-04 12:23:19 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
m_lineWidth -= WIDTH_STEP;
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2020-06-16 09:47:07 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2017-02-08 09:13:43 +00:00
|
|
|
}
|
2019-05-28 14:39:14 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::resetLocalCoords ) )
|
2017-12-21 20:49:52 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
isLocalOriginSet = true;
|
2020-10-06 09:57:30 +00:00
|
|
|
evt->SetPassEvent();
|
2017-12-21 20:49:52 +00:00
|
|
|
}
|
2020-11-04 14:08:06 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
|
|
|
{
|
2020-11-05 15:05:52 +00:00
|
|
|
if( frame()->GetUserUnits() != userUnits )
|
|
|
|
{
|
|
|
|
userUnits = frame()->GetUserUnits();
|
|
|
|
twoPointAsst.SetUnits( userUnits );
|
|
|
|
m_view->Update( &twoPointAsst );
|
|
|
|
}
|
2020-11-04 14:08:06 +00:00
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-02-11 16:15:33 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
if( !isLocalOriginSet ) // reset the relative coordinate if it was not set before
|
2019-06-13 13:34:38 +00:00
|
|
|
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
|
2017-12-21 20:49:52 +00:00
|
|
|
|
2020-07-03 15:05:17 +00:00
|
|
|
m_view->Remove( &twoPointAsst );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Remove( &preview );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->SetMsgPanel( board() );
|
|
|
|
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2017-03-23 13:15:34 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( false );
|
2014-02-19 12:51:32 +00:00
|
|
|
|
2019-07-03 10:42:56 +00:00
|
|
|
return !cancelled;
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2014-02-11 16:15:33 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Update an arc PCB_SHAPE from the current state of an Arc Geometry Manager.
|
2017-02-26 20:08:45 +00:00
|
|
|
*/
|
2017-05-04 22:43:43 +00:00
|
|
|
static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER& aMgr,
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE& aArc )
|
2017-02-26 20:08:45 +00:00
|
|
|
{
|
|
|
|
auto vec = aMgr.GetOrigin();
|
|
|
|
|
|
|
|
aArc.SetCenter( { vec.x, vec.y } );
|
|
|
|
|
|
|
|
vec = aMgr.GetStartRadiusEnd();
|
|
|
|
aArc.SetArcStart( { vec.x, vec.y } );
|
|
|
|
|
|
|
|
aArc.SetAngle( RAD2DECIDEG( -aMgr.GetSubtended() ) );
|
2020-08-09 23:03:31 +00:00
|
|
|
|
|
|
|
vec = aMgr.GetEndRadiusEnd();
|
|
|
|
aArc.SetArcEnd( { vec.x, vec.y } );
|
2017-02-26 20:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2021-04-05 22:29:12 +00:00
|
|
|
PCB_SHAPE*& graphic = *aGraphic;
|
|
|
|
PCB_LAYER_ID drawingLayer = m_frame->GetActiveLayer();
|
|
|
|
|
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2018-10-18 14:15:22 +00:00
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
// Arc geometric construction manager
|
|
|
|
KIGFX::PREVIEW::ARC_GEOM_MANAGER arcManager;
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
// Arc drawing assistant overlay
|
2018-06-14 08:26:11 +00:00
|
|
|
KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
|
|
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION preview;
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Add( &preview );
|
2017-02-26 20:08:45 +00:00
|
|
|
m_view->Add( &arcAsst );
|
2021-01-16 23:17:32 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
bool firstPoint = false;
|
2019-07-01 21:01:33 +00:00
|
|
|
bool cancelled = false;
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-09 01:15:03 +00:00
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
2020-10-08 02:47:01 +00:00
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
|
|
|
};
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
auto cleanup =
|
|
|
|
[&] ()
|
|
|
|
{
|
|
|
|
preview.Clear();
|
|
|
|
delete *aGraphic;
|
|
|
|
*aGraphic = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Prime the pump
|
|
|
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
|
|
|
|
|
|
|
if( aImmediateMode )
|
|
|
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
|
|
|
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2014-07-09 12:01:06 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2020-11-05 15:05:52 +00:00
|
|
|
if( firstPoint )
|
|
|
|
m_frame->SetMsgPanel( graphic );
|
|
|
|
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
graphic->SetLayer( drawingLayer );
|
2018-10-04 00:15:54 +00:00
|
|
|
|
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2021-03-13 20:19:46 +00:00
|
|
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( true, cursorPos );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
|
|
|
|
|
|
|
if( !firstPoint )
|
2019-07-01 21:01:33 +00:00
|
|
|
{
|
2021-05-25 23:45:57 +00:00
|
|
|
// We've handled the cancel event. Don't cancel other tools
|
|
|
|
evt->SetPassEvent( false );
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( aTool );
|
2019-07-01 21:01:33 +00:00
|
|
|
cancelled = true;
|
|
|
|
}
|
2019-07-03 10:42:56 +00:00
|
|
|
|
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( evt->IsPointEditor() )
|
|
|
|
{
|
|
|
|
// don't exit (the point editor runs in the background)
|
|
|
|
}
|
|
|
|
else if( evt->IsMoveTool() )
|
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
2019-07-01 21:01:33 +00:00
|
|
|
// leave ourselves on the stack so we come back after the move
|
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-16 20:57:07 +00:00
|
|
|
cleanup();
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( aTool );
|
2019-07-01 21:01:33 +00:00
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2017-02-26 20:08:45 +00:00
|
|
|
if( !firstPoint )
|
2014-07-09 12:01:06 +00:00
|
|
|
{
|
2019-06-27 11:47:24 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
m_controls->SetAutoPan( true );
|
|
|
|
m_controls->CaptureCursor( true );
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
drawingLayer = m_frame->GetActiveLayer();
|
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2018-10-18 14:15:22 +00:00
|
|
|
|
2017-02-08 09:13:43 +00:00
|
|
|
// Init the new item attributes
|
2017-02-26 20:08:45 +00:00
|
|
|
// (non-geometric, those are handled by the manager)
|
2021-07-21 18:31:25 +00:00
|
|
|
graphic->SetShape( SHAPE_T::ARC );
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
if( !m_view->IsLayerVisible( drawingLayer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
preview.Add( graphic );
|
2020-11-05 15:05:52 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2017-02-26 20:08:45 +00:00
|
|
|
firstPoint = true;
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
arcManager.AddPoint( cursorPos, true );
|
|
|
|
}
|
2019-06-17 00:34:21 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
|
2017-02-26 20:08:45 +00:00
|
|
|
{
|
|
|
|
arcManager.RemoveLastPoint();
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsMotion() )
|
|
|
|
{
|
2017-02-26 20:08:45 +00:00
|
|
|
// set angle snap
|
2021-05-09 19:17:01 +00:00
|
|
|
arcManager.SetAngleSnap( evt->Modifier( MD_SHIFT ) );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
// update, but don't step the manager state
|
|
|
|
arcManager.AddPoint( cursorPos, false );
|
|
|
|
}
|
2018-10-07 04:38:37 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
|
|
|
|
{
|
2021-04-05 22:29:12 +00:00
|
|
|
drawingLayer = m_frame->GetActiveLayer();
|
2021-04-07 14:01:59 +00:00
|
|
|
m_lineWidth = getSegmentWidth( drawingLayer );
|
2021-04-05 22:29:12 +00:00
|
|
|
|
2021-04-07 14:01:59 +00:00
|
|
|
if( graphic )
|
2021-04-05 22:29:12 +00:00
|
|
|
{
|
2021-04-07 14:01:59 +00:00
|
|
|
if( !m_view->IsLayerVisible( drawingLayer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
2021-04-05 22:29:12 +00:00
|
|
|
|
2021-04-07 14:01:59 +00:00
|
|
|
graphic->SetLayer( drawingLayer );
|
|
|
|
graphic->SetWidth( m_lineWidth );
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( graphic );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2018-10-07 04:38:37 +00:00
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
|
|
|
|
{
|
2020-11-05 20:20:16 +00:00
|
|
|
if( arcManager.GetStep() == KIGFX::PREVIEW::ARC_GEOM_MANAGER::SET_START )
|
2020-09-17 21:29:40 +00:00
|
|
|
{
|
2020-11-05 20:20:16 +00:00
|
|
|
graphic->SetAngle( 900, true );
|
2020-09-17 21:29:40 +00:00
|
|
|
frame()->OnEditItemRequest( graphic );
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( graphic );
|
2020-11-05 20:20:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if( arcManager.GetStep() == KIGFX::PREVIEW::ARC_GEOM_MANAGER::SET_ANGLE )
|
|
|
|
{
|
|
|
|
frame()->OnEditItemRequest( graphic );
|
|
|
|
m_view->Update( &preview );
|
|
|
|
frame()->SetMsgPanel( graphic );
|
|
|
|
break;
|
2020-09-17 21:29:40 +00:00
|
|
|
}
|
2020-11-06 13:21:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
}
|
2017-02-26 20:08:45 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
|
2014-08-04 12:23:19 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
m_lineWidth += WIDTH_STEP;
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2020-06-16 09:47:07 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2014-08-04 12:23:19 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
|
2014-08-04 12:23:19 +00:00
|
|
|
{
|
2017-02-08 09:13:43 +00:00
|
|
|
m_lineWidth -= WIDTH_STEP;
|
2020-06-16 09:47:07 +00:00
|
|
|
graphic->SetWidth( m_lineWidth );
|
2017-02-08 09:13:43 +00:00
|
|
|
m_view->Update( &preview );
|
2020-06-16 09:47:07 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2014-08-04 12:23:19 +00:00
|
|
|
}
|
2017-02-21 12:42:08 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
|
2014-08-04 12:23:19 +00:00
|
|
|
{
|
2017-02-26 20:08:45 +00:00
|
|
|
arcManager.ToggleClockwise();
|
|
|
|
}
|
2020-11-04 14:08:06 +00:00
|
|
|
else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
|
|
|
{
|
|
|
|
arcAsst.SetUnits( frame()->GetUserUnits() );
|
|
|
|
m_view->Update( &arcAsst );
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2014-08-04 12:23:19 +00:00
|
|
|
|
2017-02-26 20:08:45 +00:00
|
|
|
if( arcManager.IsComplete() )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if( arcManager.HasGeometryChanged() )
|
|
|
|
{
|
2020-06-16 09:47:07 +00:00
|
|
|
updateArcFromConstructionMgr( arcManager, *graphic );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Update( &preview );
|
2017-02-26 20:08:45 +00:00
|
|
|
m_view->Update( &arcAsst );
|
2018-04-12 16:33:18 +00:00
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
if( firstPoint )
|
2020-06-16 09:47:07 +00:00
|
|
|
frame()->SetMsgPanel( graphic );
|
2018-04-12 16:33:18 +00:00
|
|
|
else
|
|
|
|
frame()->SetMsgPanel( board() );
|
2014-08-04 12:23:19 +00:00
|
|
|
}
|
2014-07-09 12:01:06 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
preview.Remove( graphic );
|
2017-02-26 20:08:45 +00:00
|
|
|
m_view->Remove( &arcAsst );
|
2017-01-18 21:04:35 +00:00
|
|
|
m_view->Remove( &preview );
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->SetMsgPanel( board() );
|
|
|
|
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2017-03-23 13:15:34 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( false );
|
2014-07-09 12:01:06 +00:00
|
|
|
|
2019-07-03 10:42:56 +00:00
|
|
|
return !cancelled;
|
2014-02-11 16:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE** aZone )
|
2017-02-06 05:59:55 +00:00
|
|
|
{
|
2018-08-28 21:49:48 +00:00
|
|
|
bool clearSelection = false;
|
2020-06-16 09:47:07 +00:00
|
|
|
*aZone = nullptr;
|
2017-02-06 05:59:55 +00:00
|
|
|
|
|
|
|
// not an action that needs a source zone
|
2017-10-19 21:14:01 +00:00
|
|
|
if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
|
2017-02-06 05:59:55 +00:00
|
|
|
return true;
|
|
|
|
|
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 05:59:55 +00:00
|
|
|
|
|
|
|
if( selection.Empty() )
|
2018-08-28 21:49:48 +00:00
|
|
|
{
|
|
|
|
clearSelection = true;
|
2017-02-21 12:42:08 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
2018-08-28 21:49:48 +00:00
|
|
|
}
|
2017-02-06 05:59:55 +00:00
|
|
|
|
|
|
|
// we want a single zone
|
2018-08-28 21:49:48 +00:00
|
|
|
if( selection.Size() == 1 )
|
2020-11-11 23:05:59 +00:00
|
|
|
*aZone = dyn_cast<ZONE*>( selection[0] );
|
2017-02-06 05:59:55 +00:00
|
|
|
|
|
|
|
// expected a zone, but didn't get one
|
2020-06-16 09:47:07 +00:00
|
|
|
if( !*aZone )
|
2018-08-28 21:49:48 +00:00
|
|
|
{
|
|
|
|
if( clearSelection )
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2017-02-06 05:59:55 +00:00
|
|
|
return false;
|
2018-08-28 21:49:48 +00:00
|
|
|
}
|
2017-02-06 05:59:55 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
2017-02-06 05:59:55 +00:00
|
|
|
{
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
2019-07-19 21:13:52 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
ZONE_MODE zoneMode = aEvent.Parameter<ZONE_MODE>();
|
|
|
|
MODE drawMode = MODE::ZONE;
|
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::drawRuleArea ) )
|
2019-06-24 15:27:05 +00:00
|
|
|
drawMode = MODE::KEEPOUT;
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &PCB_ACTIONS::drawPolygon ) )
|
|
|
|
drawMode = MODE::GRAPHIC_POLYGON;
|
|
|
|
|
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, drawMode );
|
|
|
|
|
2018-10-12 04:11:42 +00:00
|
|
|
// get a source zone, if we need one. We need it for:
|
|
|
|
// ZONE_MODE::CUTOUT (adding a hole to the source zone)
|
|
|
|
// ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* sourceZone = nullptr;
|
2018-10-12 04:11:42 +00:00
|
|
|
|
2020-06-16 09:47:07 +00:00
|
|
|
if( !getSourceZoneForAction( zoneMode, &sourceZone ) )
|
2018-10-12 04:11:42 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-10-17 19:52:51 +00:00
|
|
|
// Turn zones on if they are off, so that the created object will be visible after completion
|
|
|
|
m_frame->SetObjectVisible( LAYER_ZONES );
|
|
|
|
|
2018-10-12 04:11:42 +00:00
|
|
|
ZONE_CREATE_HELPER::PARAMS params;
|
2018-03-02 09:55:59 +00:00
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
params.m_keepout = drawMode == MODE::KEEPOUT;
|
|
|
|
params.m_mode = zoneMode;
|
2018-10-12 04:11:42 +00:00
|
|
|
params.m_sourceZone = sourceZone;
|
|
|
|
|
2020-06-27 21:08:13 +00:00
|
|
|
if( zoneMode == ZONE_MODE::SIMILAR )
|
2018-10-12 04:11:42 +00:00
|
|
|
params.m_layer = sourceZone->GetLayer();
|
|
|
|
else
|
|
|
|
params.m_layer = m_frame->GetActiveLayer();
|
|
|
|
|
|
|
|
ZONE_CREATE_HELPER zoneTool( *this, params );
|
|
|
|
|
|
|
|
// the geometry manager which handles the zone geometry, and
|
|
|
|
// hands the calculated points over to the zone creator tool
|
|
|
|
POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
|
2019-10-20 16:27:44 +00:00
|
|
|
bool constrainAngle = false;
|
2018-10-12 04:11:42 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
std::string tool = aEvent.GetCommandStr().get();
|
|
|
|
m_frame->PushTool( tool );
|
2018-10-12 04:11:42 +00:00
|
|
|
Activate(); // register for events
|
|
|
|
|
|
|
|
m_controls->ShowCursor( true );
|
|
|
|
|
|
|
|
bool started = false;
|
2021-01-16 23:17:32 +00:00
|
|
|
PCB_GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() );
|
2018-02-19 14:25:07 +00:00
|
|
|
STATUS_TEXT_POPUP status( m_frame );
|
2018-03-02 09:55:59 +00:00
|
|
|
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
|
|
|
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
2014-02-14 09:47:43 +00:00
|
|
|
|
2020-10-09 01:15:03 +00:00
|
|
|
auto setCursor =
|
|
|
|
[&]()
|
2020-10-08 02:47:01 +00:00
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
|
|
|
};
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
auto cleanup =
|
|
|
|
[&] ()
|
|
|
|
{
|
|
|
|
polyGeomMgr.Reset();
|
|
|
|
started = false;
|
|
|
|
grid.ClearSkipPoint();
|
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Prime the pump
|
|
|
|
if( aEvent.HasPosition() )
|
|
|
|
m_toolMgr->PrimeTool( aEvent.Position() );
|
|
|
|
|
2020-10-08 00:50:28 +00:00
|
|
|
// Set initial cursor
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
2020-10-08 00:50:28 +00:00
|
|
|
|
2019-06-24 15:27:05 +00:00
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2014-02-13 11:46:39 +00:00
|
|
|
{
|
2020-10-08 02:47:01 +00:00
|
|
|
setCursor();
|
|
|
|
|
2018-10-04 00:15:54 +00:00
|
|
|
LSET layers( m_frame->GetActiveLayer() );
|
|
|
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
2021-05-09 19:17:01 +00:00
|
|
|
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
|
2021-03-04 01:09:24 +00:00
|
|
|
|
|
|
|
VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() : m_controls->GetMousePosition();
|
|
|
|
cursorPos = grid.BestSnapAnchor( cursorPos, layers );
|
|
|
|
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( true, cursorPos );
|
2014-02-17 10:33:03 +00:00
|
|
|
|
2021-05-09 19:17:01 +00:00
|
|
|
if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_SHIFT ) )
|
2019-10-20 16:27:44 +00:00
|
|
|
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 );
|
|
|
|
else
|
|
|
|
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
if( evt->IsCancelInteractive() )
|
2014-02-13 11:46:39 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
if( polyGeomMgr.IsPolygonInProgress() )
|
2021-05-21 13:53:32 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
cleanup();
|
2021-05-21 13:53:32 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
2019-06-24 15:27:05 +00:00
|
|
|
{
|
2021-05-25 23:45:57 +00:00
|
|
|
// We've handled the cancel event. Don't cancel other tools
|
|
|
|
evt->SetPassEvent( false );
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2019-07-01 21:01:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( polyGeomMgr.IsPolygonInProgress() )
|
|
|
|
cleanup();
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2019-07-01 21:01:33 +00:00
|
|
|
if( evt->IsPointEditor() )
|
|
|
|
{
|
|
|
|
// don't exit (the point editor runs in the background)
|
2019-06-24 15:27:05 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else if( evt->IsMoveTool() )
|
2014-02-19 12:51:32 +00:00
|
|
|
{
|
2019-07-01 21:01:33 +00:00
|
|
|
// leave ourselves on the stack so we come back after the move
|
2014-02-19 12:51:32 +00:00
|
|
|
break;
|
2017-02-26 17:45:52 +00:00
|
|
|
}
|
2019-07-01 21:01:33 +00:00
|
|
|
else
|
|
|
|
{
|
2019-07-15 12:15:58 +00:00
|
|
|
m_frame->PopTool( tool );
|
2019-06-24 15:27:05 +00:00
|
|
|
break;
|
2019-07-01 21:01:33 +00:00
|
|
|
}
|
2018-10-12 04:11:42 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
|
|
|
|
{
|
2020-06-27 21:08:13 +00:00
|
|
|
if( zoneMode != ZONE_MODE::SIMILAR )
|
2018-10-12 04:11:42 +00:00
|
|
|
params.m_layer = frame()->GetActiveLayer();
|
2021-04-05 22:29:12 +00:00
|
|
|
|
|
|
|
if( !m_view->IsLayerVisible( params.m_layer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( params.m_layer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
2014-02-13 11:46:39 +00:00
|
|
|
}
|
2017-01-09 17:29:40 +00:00
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
m_menu.ShowContextMenu( selection() );
|
2017-01-09 17:29:40 +00:00
|
|
|
}
|
2017-02-26 17:45:52 +00:00
|
|
|
// events that lock in nodes
|
|
|
|
else if( evt->IsClick( BUT_LEFT )
|
2017-05-04 22:43:43 +00:00
|
|
|
|| evt->IsDblClick( BUT_LEFT )
|
2020-04-24 17:34:05 +00:00
|
|
|
|| evt->IsAction( &PCB_ACTIONS::closeOutline ) )
|
2014-02-13 11:46:39 +00:00
|
|
|
{
|
2014-02-19 12:51:32 +00:00
|
|
|
// Check if it is double click / closing line (so we have to finish the zone)
|
2017-02-26 17:45:52 +00:00
|
|
|
const bool endPolygon = evt->IsDblClick( BUT_LEFT )
|
2020-04-24 17:34:05 +00:00
|
|
|
|| evt->IsAction( &PCB_ACTIONS::closeOutline )
|
2017-05-04 22:43:43 +00:00
|
|
|
|| polyGeomMgr.NewPointClosesOutline( cursorPos );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
if( endPolygon )
|
2014-02-13 11:46:39 +00:00
|
|
|
{
|
2017-02-26 17:45:52 +00:00
|
|
|
polyGeomMgr.SetFinished();
|
|
|
|
polyGeomMgr.Reset();
|
2014-02-14 14:52:13 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
started = false;
|
2018-10-12 04:11:42 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2017-02-26 17:45:52 +00:00
|
|
|
}
|
2018-01-01 21:14:08 +00:00
|
|
|
// adding a corner
|
|
|
|
else if( polyGeomMgr.AddPoint( cursorPos ) )
|
2017-02-26 17:45:52 +00:00
|
|
|
{
|
|
|
|
if( !started )
|
|
|
|
{
|
|
|
|
started = true;
|
2021-04-05 22:29:12 +00:00
|
|
|
|
|
|
|
POLYGON_GEOM_MANAGER::LEADER_MODE leaderMode = polyGeomMgr.GetLeaderMode();
|
|
|
|
constrainAngle = ( leaderMode == POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 );
|
|
|
|
|
2018-10-12 04:11:42 +00:00
|
|
|
m_controls->SetAutoPan( true );
|
|
|
|
m_controls->CaptureCursor( true );
|
2021-04-05 22:29:12 +00:00
|
|
|
|
|
|
|
if( !m_view->IsLayerVisible( params.m_layer ) )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( params.m_layer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
2017-02-26 17:45:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-17 00:34:21 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
|
2017-02-26 17:45:52 +00:00
|
|
|
{
|
|
|
|
polyGeomMgr.DeleteLastCorner();
|
2014-02-14 09:47:43 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
if( !polyGeomMgr.IsPolygonInProgress() )
|
|
|
|
{
|
|
|
|
// report finished as an empty shape
|
|
|
|
polyGeomMgr.SetFinished();
|
2017-02-06 05:59:55 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
// start again
|
|
|
|
started = false;
|
2018-10-12 04:11:42 +00:00
|
|
|
m_controls->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2017-02-26 17:45:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( polyGeomMgr.IsPolygonInProgress()
|
2017-05-04 22:43:43 +00:00
|
|
|
&& ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
|
2017-02-26 17:45:52 +00:00
|
|
|
{
|
2019-10-20 16:27:44 +00:00
|
|
|
polyGeomMgr.SetCursorPosition( cursorPos );
|
2018-03-02 09:55:59 +00:00
|
|
|
|
|
|
|
if( polyGeomMgr.IsSelfIntersecting( true ) )
|
|
|
|
{
|
|
|
|
wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
|
|
|
|
status.Move( p );
|
2019-05-19 21:04:04 +00:00
|
|
|
status.PopupFor( 1500 );
|
2018-03-02 09:55:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status.Hide();
|
|
|
|
}
|
2017-02-26 17:45:52 +00:00
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
|
|
|
|
{
|
|
|
|
if( started )
|
|
|
|
{
|
|
|
|
frame()->OnEditItemRequest( zoneTool.GetZone() );
|
|
|
|
zoneTool.OnGeometryChange( polyGeomMgr );
|
|
|
|
frame()->SetMsgPanel( zoneTool.GetZone() );
|
|
|
|
}
|
2020-11-06 13:21:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
evt->SetPassEvent();
|
|
|
|
}
|
2020-09-17 21:29:40 +00:00
|
|
|
}
|
2020-11-25 00:08:09 +00:00
|
|
|
/*else if( evt->IsAction( &ACTIONS::updateUnits ) )
|
2020-11-04 14:08:06 +00:00
|
|
|
{
|
|
|
|
// If we ever have an assistant here that reports dimensions, we'll want to
|
|
|
|
// update its units here....
|
|
|
|
// zoneAsst.SetUnits( frame()->GetUserUnits() );
|
|
|
|
// m_view->Update( &zoneAsst );
|
|
|
|
evt->SetPassEvent();
|
2020-11-25 00:08:09 +00:00
|
|
|
}*/
|
2019-07-26 18:16:44 +00:00
|
|
|
else
|
2020-10-06 09:57:30 +00:00
|
|
|
{
|
2019-07-26 18:16:44 +00:00
|
|
|
evt->SetPassEvent();
|
2020-10-06 09:57:30 +00:00
|
|
|
}
|
2019-07-26 18:16:44 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
} // end while
|
2014-02-13 11:46:39 +00:00
|
|
|
|
2020-11-19 20:08:58 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2018-11-13 13:58:54 +00:00
|
|
|
m_controls->ForceCursorPosition( false );
|
2021-05-21 13:53:32 +00:00
|
|
|
controls()->SetAutoPan( false );
|
|
|
|
m_controls->CaptureCursor( false );
|
2014-07-09 12:01:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-22 15:46:31 +00:00
|
|
|
int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
|
|
|
|
{
|
2021-02-01 22:45:56 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* m_frame;
|
|
|
|
PCB_GRID_HELPER m_gridHelper;
|
|
|
|
std::shared_ptr<DRC_ENGINE> m_drcEngine;
|
|
|
|
int m_drcEpsilon;
|
|
|
|
int m_worstClearance;
|
2021-02-14 22:31:11 +00:00
|
|
|
bool m_allowDRCViolations;
|
2018-04-08 16:47:39 +00:00
|
|
|
|
2020-06-13 12:33:29 +00:00
|
|
|
VIA_PLACER( PCB_BASE_EDIT_FRAME* aFrame ) :
|
2021-02-01 22:45:56 +00:00
|
|
|
m_frame( aFrame ),
|
|
|
|
m_gridHelper( aFrame->GetToolManager(), aFrame->GetMagneticItemsSettings() ),
|
|
|
|
m_drcEngine( aFrame->GetBoard()->GetDesignSettings().m_DRCEngine ),
|
|
|
|
m_drcEpsilon( aFrame->GetBoard()->GetDesignSettings().GetDRCEpsilon() ),
|
2021-08-01 20:51:08 +00:00
|
|
|
m_worstClearance( 0 )
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
2021-04-10 09:31:42 +00:00
|
|
|
ROUTER_TOOL* router = m_frame->GetToolManager()->GetTool<ROUTER_TOOL>();
|
2021-02-14 22:31:11 +00:00
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
m_allowDRCViolations = router->Router()->Settings().AllowDRCViolations();
|
2021-02-14 22:31:11 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_drcEngine->InitEngine( aFrame->GetDesignRulesPath() );
|
|
|
|
|
|
|
|
DRC_CONSTRAINT constraint;
|
|
|
|
|
|
|
|
if( m_drcEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint ) )
|
|
|
|
m_worstClearance = constraint.GetValue().Min();
|
|
|
|
|
|
|
|
if( m_drcEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, constraint ) )
|
|
|
|
m_worstClearance = std::max( m_worstClearance, constraint.GetValue().Min() );
|
|
|
|
|
|
|
|
for( FOOTPRINT* footprint : aFrame->GetBoard()->Footprints() )
|
|
|
|
{
|
|
|
|
for( PAD* pad : footprint->Pads() )
|
|
|
|
m_worstClearance = std::max( m_worstClearance, pad->GetLocalClearance() );
|
|
|
|
}
|
|
|
|
}
|
2021-02-20 19:29:11 +00:00
|
|
|
catch( PARSE_ERROR& )
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2018-04-08 16:47:39 +00:00
|
|
|
|
2020-02-05 22:19:14 +00:00
|
|
|
virtual ~VIA_PLACER()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* findTrack( PCB_VIA* aVia )
|
2017-04-22 15:46:31 +00:00
|
|
|
{
|
2018-04-08 16:47:39 +00:00
|
|
|
const LSET lset = aVia->GetLayerSet();
|
2019-07-22 03:19:55 +00:00
|
|
|
wxPoint position = aVia->GetPosition();
|
2019-01-23 15:18:44 +00:00
|
|
|
BOX2I bbox = aVia->GetBoundingBox();
|
2019-07-22 03:19:55 +00:00
|
|
|
|
|
|
|
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
|
2019-06-13 17:28:55 +00:00
|
|
|
auto view = m_frame->GetCanvas()->GetView();
|
2021-06-11 21:07:02 +00:00
|
|
|
std::vector<PCB_TRACK*> possible_tracks;
|
2017-04-22 15:46:31 +00:00
|
|
|
|
2019-01-23 15:18:44 +00:00
|
|
|
view->Query( bbox, items );
|
|
|
|
|
|
|
|
for( auto it : items )
|
2017-06-23 11:56:28 +00:00
|
|
|
{
|
2019-01-23 15:18:44 +00:00
|
|
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
|
|
|
|
|
|
|
|
if( !(item->GetLayerSet() & lset ).any() )
|
2018-04-08 16:47:39 +00:00
|
|
|
continue;
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
if( PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item ) )
|
2019-01-23 15:18:44 +00:00
|
|
|
{
|
2019-07-22 03:19:55 +00:00
|
|
|
if( TestSegmentHit( position, track->GetStart(), track->GetEnd(),
|
2019-01-23 15:18:44 +00:00
|
|
|
( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
|
2019-01-25 15:12:04 +00:00
|
|
|
possible_tracks.push_back( track );
|
2019-01-23 15:18:44 +00:00
|
|
|
}
|
2017-06-23 11:56:28 +00:00
|
|
|
}
|
2017-05-04 22:43:43 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* return_track = nullptr;
|
2019-01-25 15:12:04 +00:00
|
|
|
int min_d = std::numeric_limits<int>::max();
|
2021-02-01 22:45:56 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : possible_tracks )
|
2019-01-25 15:12:04 +00:00
|
|
|
{
|
|
|
|
SEG test( track->GetStart(), track->GetEnd() );
|
2021-02-01 22:45:56 +00:00
|
|
|
int dist = ( test.NearestPoint( position ) - position ).EuclideanNorm();
|
2019-01-25 15:12:04 +00:00
|
|
|
|
|
|
|
if( dist < min_d )
|
|
|
|
{
|
|
|
|
min_d = dist;
|
|
|
|
return_track = track;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_track;
|
2018-04-08 16:47:39 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
bool hasDRCViolation( PCB_VIA* aVia, BOARD_ITEM* aOther )
|
2019-01-23 15:18:44 +00:00
|
|
|
{
|
2021-02-01 22:45:56 +00:00
|
|
|
// It would really be better to know what particular nets a nettie should allow,
|
|
|
|
// but for now it is what it is.
|
|
|
|
if( DRC_ENGINE::IsNetTie( aOther ) )
|
|
|
|
return false;
|
2019-07-22 03:19:55 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aOther );
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
if( cItem && cItem->GetNetCode() == aVia->GetNetCode() )
|
|
|
|
return false;
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-14 22:31:11 +00:00
|
|
|
DRC_CONSTRAINT constraint;
|
|
|
|
int clearance;
|
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
for( PCB_LAYER_ID layer : aOther->GetLayerSet().Seq() )
|
2019-01-23 15:18:44 +00:00
|
|
|
{
|
2021-02-14 22:31:11 +00:00
|
|
|
if( !IsCopperLayer( layer ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, aVia, aOther, layer );
|
|
|
|
clearance = constraint.GetValue().Min();
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
if( clearance >= 0 )
|
2019-01-23 15:18:44 +00:00
|
|
|
{
|
2021-02-01 22:45:56 +00:00
|
|
|
std::shared_ptr<SHAPE> viaShape = DRC_ENGINE::GetShape( aVia, layer );
|
|
|
|
std::shared_ptr<SHAPE> otherShape = DRC_ENGINE::GetShape( aOther, layer );
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
if( viaShape->Collide( otherShape.get(), clearance - m_drcEpsilon ) )
|
|
|
|
return true;
|
2019-01-23 15:18:44 +00:00
|
|
|
}
|
2021-02-01 22:45:56 +00:00
|
|
|
}
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-14 22:31:11 +00:00
|
|
|
std::unique_ptr<SHAPE_SEGMENT> holeShape;
|
|
|
|
|
|
|
|
if( aOther->Type() == PCB_VIA_T )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( aOther );
|
|
|
|
wxPoint pos = via->GetPosition();
|
2021-02-14 22:31:11 +00:00
|
|
|
|
|
|
|
holeShape.reset( new SHAPE_SEGMENT( pos, pos, via->GetDrill() ) );
|
|
|
|
}
|
|
|
|
else if( aOther->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
PAD* pad = static_cast<PAD*>( aOther );
|
|
|
|
|
|
|
|
if( pad->GetDrillSize().x )
|
|
|
|
holeShape.reset( new SHAPE_SEGMENT( *pad->GetEffectiveHoleShape() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( holeShape )
|
|
|
|
{
|
|
|
|
constraint = m_drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, aVia, aOther,
|
|
|
|
UNDEFINED_LAYER );
|
|
|
|
clearance = constraint.GetValue().Min();
|
|
|
|
|
|
|
|
if( clearance >= 0 )
|
|
|
|
{
|
|
|
|
std::shared_ptr<SHAPE> viaShape = DRC_ENGINE::GetShape( aVia, UNDEFINED_LAYER );
|
|
|
|
|
|
|
|
if( viaShape->Collide( holeShape.get(), clearance - m_drcEpsilon ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-07-22 03:19:55 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
bool checkDRCViolation( PCB_VIA* aVia )
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
|
|
|
std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
|
2021-02-14 22:31:11 +00:00
|
|
|
std::set<BOARD_ITEM*> checkedItems;
|
2021-02-01 22:45:56 +00:00
|
|
|
BOX2I bbox = aVia->GetBoundingBox();
|
2019-07-22 03:19:55 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
bbox.Inflate( m_worstClearance );
|
|
|
|
m_frame->GetCanvas()->GetView()->Query( bbox, items );
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
for( std::pair<KIGFX::VIEW_ITEM*, int> it : items )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( it.first );
|
2019-07-22 03:19:55 +00:00
|
|
|
|
2021-02-14 22:31:11 +00:00
|
|
|
if( !item )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
|
2021-02-17 10:56:06 +00:00
|
|
|
continue; // stitching vias bind to zones, so ignore them
|
|
|
|
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T || item->Type() == PCB_GROUP_T )
|
|
|
|
continue; // check against children, but not against footprint itself
|
2021-02-14 22:31:11 +00:00
|
|
|
|
|
|
|
if( item->Type() == PCB_FP_TEXT_T && !static_cast<FP_TEXT*>( item )->IsVisible() )
|
2021-02-17 10:56:06 +00:00
|
|
|
continue; // ignore hidden items
|
2020-08-07 20:18:33 +00:00
|
|
|
|
2021-02-14 22:31:11 +00:00
|
|
|
if( checkedItems.count( item ) )
|
2021-02-01 22:45:56 +00:00
|
|
|
continue;
|
2019-07-22 03:19:55 +00:00
|
|
|
|
2021-02-01 22:45:56 +00:00
|
|
|
if( hasDRCViolation( aVia, item ) )
|
|
|
|
return true;
|
|
|
|
|
2021-02-14 22:31:11 +00:00
|
|
|
checkedItems.insert( item );
|
2019-01-23 15:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
PAD* findPad( PCB_VIA* aVia )
|
2021-04-02 15:19:44 +00:00
|
|
|
{
|
|
|
|
const wxPoint position = aVia->GetPosition();
|
|
|
|
const LSET lset = aVia->GetLayerSet();
|
|
|
|
|
|
|
|
for( FOOTPRINT* fp : m_board->Footprints() )
|
|
|
|
{
|
|
|
|
for(PAD* pad : fp->Pads() )
|
|
|
|
{
|
|
|
|
if( pad->HitTest( position ) && ( pad->GetLayerSet() & lset ).any() )
|
|
|
|
if( pad->GetNetCode() > 0 )
|
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
int findStitchedZoneNet( PCB_VIA* aVia )
|
2018-04-08 16:47:39 +00:00
|
|
|
{
|
2019-07-22 03:19:55 +00:00
|
|
|
const wxPoint position = aVia->GetPosition();
|
|
|
|
const LSET lset = aVia->GetLayerSet();
|
2018-04-08 16:47:39 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
std::vector<ZONE*> foundZones;
|
2017-04-22 15:46:31 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : m_board->Zones() )
|
2017-04-22 15:46:31 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
for( PCB_LAYER_ID layer : LSET( zone->GetLayerSet() & lset ).Seq() )
|
2020-10-13 17:46:48 +00:00
|
|
|
{
|
2020-06-24 02:19:08 +00:00
|
|
|
if( zone->HitTestFilledArea( layer, position ) )
|
|
|
|
foundZones.push_back( zone );
|
2020-10-13 17:46:48 +00:00
|
|
|
}
|
2017-04-22 15:46:31 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
std::sort( foundZones.begin(), foundZones.end(),
|
2020-11-11 23:05:59 +00:00
|
|
|
[] ( const ZONE* a, const ZONE* b )
|
|
|
|
{
|
|
|
|
return a->GetLayer() < b->GetLayer();
|
|
|
|
} );
|
2017-05-04 22:43:43 +00:00
|
|
|
|
|
|
|
// first take the net of the active layer
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* z : foundZones )
|
2017-04-22 15:46:31 +00:00
|
|
|
{
|
2017-05-04 22:43:43 +00:00
|
|
|
if( m_frame->GetActiveLayer() == z->GetLayer() )
|
2017-04-22 15:46:31 +00:00
|
|
|
return z->GetNetCode();
|
|
|
|
}
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
// none? take the topmost visible layer
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* z : foundZones )
|
2017-05-04 22:43:43 +00:00
|
|
|
{
|
|
|
|
if( m_board->IsLayerVisible( z->GetLayer() ) )
|
|
|
|
return z->GetNetCode();
|
|
|
|
}
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-04-08 16:47:39 +00:00
|
|
|
void SnapItem( BOARD_ITEM *aItem ) override
|
|
|
|
{
|
|
|
|
// If you place a Via on a track but not on its centerline, the current
|
|
|
|
// connectivity algorithm will require us to put a kink in the track when
|
|
|
|
// we break it (so that each of the two segments ends on the via center).
|
|
|
|
// That's not ideal, and is in fact probably worse than forcing snap in
|
|
|
|
// this situation.
|
2018-05-07 20:49:36 +00:00
|
|
|
|
2018-10-04 00:15:54 +00:00
|
|
|
m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( aItem );
|
|
|
|
wxPoint position = via->GetPosition();
|
|
|
|
PCB_TRACK* track = findTrack( via );
|
2018-05-07 20:49:36 +00:00
|
|
|
|
2018-10-04 00:15:54 +00:00
|
|
|
if( track )
|
2018-04-08 16:47:39 +00:00
|
|
|
{
|
2019-07-22 03:19:55 +00:00
|
|
|
SEG trackSeg( track->GetStart(), track->GetEnd() );
|
|
|
|
VECTOR2I snap = m_gridHelper.AlignToSegment( position, trackSeg );
|
2018-04-08 16:47:39 +00:00
|
|
|
|
2019-04-19 18:23:18 +00:00
|
|
|
aItem->SetPosition( (wxPoint) snap );
|
2018-04-08 16:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-23 15:18:44 +00:00
|
|
|
bool PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
|
2017-04-22 15:46:31 +00:00
|
|
|
{
|
2021-08-01 20:51:08 +00:00
|
|
|
WX_INFOBAR* infobar = m_frame->GetInfoBar();
|
|
|
|
PCB_VIA* via = static_cast<PCB_VIA*>( aItem );
|
|
|
|
wxPoint viaPos = via->GetPosition();
|
|
|
|
PCB_TRACK* track = findTrack( via );
|
|
|
|
PAD* pad = findPad( via );
|
2018-04-08 16:47:39 +00:00
|
|
|
|
2021-02-17 19:36:09 +00:00
|
|
|
if( track )
|
|
|
|
via->SetNetCode( track->GetNetCode() );
|
2021-04-02 15:19:44 +00:00
|
|
|
else if( pad )
|
|
|
|
via->SetNetCode( pad->GetNetCode() );
|
2021-02-17 19:36:09 +00:00
|
|
|
|
|
|
|
if( !m_allowDRCViolations && checkDRCViolation( via ) )
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
2021-08-01 20:51:08 +00:00
|
|
|
m_frame->ShowInfoBarError( _( "Via location violates DRC." ), true,
|
|
|
|
WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
|
2021-02-17 19:36:09 +00:00
|
|
|
via->SetNetCode( 0 );
|
2019-01-23 15:18:44 +00:00
|
|
|
return false;
|
2021-02-01 22:45:56 +00:00
|
|
|
}
|
2021-08-01 20:51:08 +00:00
|
|
|
else
|
2021-02-01 22:45:56 +00:00
|
|
|
{
|
2021-08-01 20:51:08 +00:00
|
|
|
if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION )
|
|
|
|
infobar->Dismiss();
|
2021-02-01 22:45:56 +00:00
|
|
|
}
|
2019-01-23 15:18:44 +00:00
|
|
|
|
2018-04-08 16:47:39 +00:00
|
|
|
if( track )
|
|
|
|
{
|
2019-07-06 21:53:50 +00:00
|
|
|
if( viaPos != track->GetStart() && viaPos != track->GetEnd() )
|
|
|
|
{
|
|
|
|
aCommit.Modify( track );
|
2020-08-10 13:39:43 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
|
2020-08-10 13:39:43 +00:00
|
|
|
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
|
|
|
|
|
2019-07-06 21:53:50 +00:00
|
|
|
track->SetEnd( viaPos );
|
|
|
|
newTrack->SetStart( viaPos );
|
|
|
|
aCommit.Add( newTrack );
|
|
|
|
}
|
2018-04-08 16:47:39 +00:00
|
|
|
}
|
2021-04-02 15:19:44 +00:00
|
|
|
else if( !pad )
|
2020-12-20 21:29:43 +00:00
|
|
|
{
|
2021-02-17 19:36:09 +00:00
|
|
|
via->SetNetCode( findStitchedZoneNet( via ) );
|
2020-12-20 21:29:43 +00:00
|
|
|
via->SetIsFree();
|
|
|
|
}
|
2017-04-22 15:46:31 +00:00
|
|
|
|
2018-04-08 16:47:39 +00:00
|
|
|
aCommit.Add( aItem );
|
2019-01-23 15:18:44 +00:00
|
|
|
return true;
|
2017-04-22 15:46:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<BOARD_ITEM> CreateItem() override
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
|
|
|
|
PCB_VIA* via = new PCB_VIA( m_board );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
via->SetNetCode( 0 );
|
2021-06-11 21:07:02 +00:00
|
|
|
via->SetViaType( bds.m_CurrentViaType );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
// for microvias, the size and hole will be changed later.
|
2021-06-11 21:07:02 +00:00
|
|
|
via->SetWidth( bds.GetCurrentViaSize() );
|
|
|
|
via->SetDrill( bds.GetCurrentViaDrill() );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
// Usual via is from copper to component.
|
|
|
|
// layer pair is B_Cu and F_Cu.
|
|
|
|
via->SetLayerPair( B_Cu, F_Cu );
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
|
|
|
|
PCB_LAYER_ID last_layer;
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
// prepare switch to new active layer:
|
|
|
|
if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
|
|
|
|
last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
|
|
|
|
else
|
|
|
|
last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
|
|
|
|
|
|
|
|
// Adjust the actual via layer pair
|
|
|
|
switch( via->GetViaType() )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::BLIND_BURIED:
|
2017-04-22 15:46:31 +00:00
|
|
|
via->SetLayerPair( first_layer, last_layer );
|
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case VIATYPE::MICROVIA: // from external to the near neighbor inner layer
|
2017-05-04 22:43:43 +00:00
|
|
|
{
|
|
|
|
PCB_LAYER_ID last_inner_layer =
|
|
|
|
ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
|
|
|
|
|
|
|
|
if( first_layer == B_Cu )
|
|
|
|
last_layer = last_inner_layer;
|
|
|
|
else if( first_layer == F_Cu )
|
|
|
|
last_layer = In1_Cu;
|
|
|
|
else if( first_layer == last_inner_layer )
|
|
|
|
last_layer = B_Cu;
|
|
|
|
else if( first_layer == In1_Cu )
|
|
|
|
last_layer = F_Cu;
|
|
|
|
|
|
|
|
// else error: will be removed later
|
|
|
|
via->SetLayerPair( first_layer, last_layer );
|
|
|
|
|
2020-12-08 12:30:07 +00:00
|
|
|
// Update diameter and hole size, which where set previously for normal vias
|
|
|
|
NETCLASS* netClass = via->GetNetClass();
|
2017-05-04 22:43:43 +00:00
|
|
|
|
2020-12-08 12:30:07 +00:00
|
|
|
via->SetWidth( netClass->GetuViaDiameter() );
|
|
|
|
via->SetDrill( netClass->GetuViaDrill() );
|
2017-05-04 22:43:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
return std::unique_ptr<BOARD_ITEM>( via );
|
2017-04-22 15:46:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-08 16:47:39 +00:00
|
|
|
VIA_PLACER placer( frame() );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
2018-08-01 16:58:27 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
2019-07-15 12:15:58 +00:00
|
|
|
doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place via" ),
|
|
|
|
IPO_REPEAT | IPO_SINGLE_CLICK );
|
2017-04-22 15:46:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-14 13:24:12 +00:00
|
|
|
|
2017-05-04 22:43:43 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
int DRAWING_TOOL::getSegmentWidth( PCB_LAYER_ID aLayer ) const
|
2014-09-01 11:48:51 +00:00
|
|
|
{
|
|
|
|
assert( m_board );
|
2018-04-28 15:22:25 +00:00
|
|
|
return m_board->GetDesignSettings().GetLineThickness( aLayer );
|
2014-09-01 11:48:51 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 15:58:26 +00:00
|
|
|
|
2019-02-14 09:55:57 +00:00
|
|
|
const unsigned int DRAWING_TOOL::WIDTH_STEP = Millimeter2iu( 0.1 );
|
2019-06-24 15:27:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DRAWING_TOOL::setTransitions()
|
|
|
|
{
|
2021-03-13 20:19:46 +00:00
|
|
|
|
|
|
|
Go( &DRAWING_TOOL::PlaceStackup, PCB_ACTIONS::placeStackup.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::PlaceCharacteristics, PCB_ACTIONS::placeCharacteristics.MakeEvent() );
|
2019-06-24 15:27:05 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawLine, PCB_ACTIONS::drawLine.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawPolygon.MakeEvent() );
|
2020-06-15 19:50:20 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawRectangle, PCB_ACTIONS::drawRectangle.MakeEvent() );
|
2019-06-24 15:27:05 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawCircle, PCB_ACTIONS::drawCircle.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::DrawArc, PCB_ACTIONS::drawArc.MakeEvent() );
|
2020-09-12 20:09:40 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawAlignedDimension.MakeEvent() );
|
2020-09-22 02:32:40 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawOrthogonalDimension.MakeEvent() );
|
2020-09-17 00:54:58 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawCenterDimension.MakeEvent() );
|
2020-09-12 20:09:40 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawLeader.MakeEvent() );
|
2019-06-24 15:27:05 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() );
|
2020-09-21 23:32:07 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawRuleArea.MakeEvent() );
|
2019-06-24 15:27:05 +00:00
|
|
|
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZoneCutout.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawSimilarZone.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::DrawVia, PCB_ACTIONS::drawVia.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
|
|
|
|
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
|
2021-02-05 23:43:32 +00:00
|
|
|
Go( &DRAWING_TOOL::ToggleLine45degMode, PCB_ACTIONS::toggleLine45degMode.MakeEvent() );
|
2019-06-24 15:27:05 +00:00
|
|
|
}
|