2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-04-09 09:16:47 +00:00
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
2011-10-17 20:01:27 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2017-11-13 17:00:02 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew/onleftclick.cpp
|
|
|
|
* @brief Functions called when the left button is clicked or double clicked.
|
|
|
|
*/
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2014-09-10 15:18:42 +00:00
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_dimension.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_pcb_text.h>
|
2014-09-10 15:18:42 +00:00
|
|
|
#include <class_text_mod.h>
|
|
|
|
#include <class_module.h>
|
2017-10-31 15:38:10 +00:00
|
|
|
#include <class_pcb_target.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <origin_viewitem.h>
|
2014-05-09 18:35:48 +00:00
|
|
|
#include <project.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2018-01-24 21:27:56 +00:00
|
|
|
#include <tools/pcb_editor_control.h>
|
|
|
|
#include <tools/pcbnew_control.h>
|
2007-09-29 15:30:16 +00:00
|
|
|
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/* Handle the left button mouse click, when a tool is active
|
2007-09-29 15:30:16 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
BOARD_ITEM* curr_item = GetCurItem();
|
2009-09-28 12:21:54 +00:00
|
|
|
bool exit = false;
|
2011-02-24 20:22:12 +00:00
|
|
|
bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( no_tool || ( curr_item && curr_item->GetEditFlags() ) )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2011-02-24 20:22:12 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item && curr_item->GetEditFlags() ) // Command in progress
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
switch( curr_item->Type() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item->IsNew() )
|
2011-02-24 12:35:14 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2011-02-24 12:35:14 +00:00
|
|
|
Begin_Zone( aDC );
|
|
|
|
}
|
|
|
|
else
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
End_Move_Zone_Corner_Or_Outlines( aDC, static_cast<ZONE_CONTAINER*>( curr_item ) );
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
exit = true;
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item->IsDragging() )
|
2011-02-24 12:35:14 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceDraggedOrMovedTrackSegment( static_cast<TRACK*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
Place_Texte_Pcb( static_cast<TEXTE_PCB*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceTexteModule( static_cast<TEXTE_MODULE*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
PlacePad( static_cast<D_PAD*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceModule( static_cast<MODULE*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceTarget( static_cast<PCB_TARGET*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2011-02-24 12:35:14 +00:00
|
|
|
if( no_tool ) // when no tools: existing item moving.
|
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
Place_DrawItem( static_cast<DRAWSEGMENT*>( curr_item ), aDC );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
}
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( ! curr_item->IsNew() )
|
2011-11-24 19:57:41 +00:00
|
|
|
{ // We are moving the text of an existing dimension. Place it
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceDimensionText( static_cast<DIMENSION*>( curr_item ), aDC );
|
2011-11-24 19:57:41 +00:00
|
|
|
exit = true;
|
|
|
|
}
|
2011-02-24 12:35:14 +00:00
|
|
|
break;
|
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
case PCB_MARKER_T: // MARKER_PCB, a marker used to show something
|
|
|
|
curr_item->ClearFlags(); // Not reason to have flags set
|
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
default:
|
|
|
|
DisplayError( this,
|
2016-02-19 14:10:23 +00:00
|
|
|
wxString::Format(
|
|
|
|
"PCB_EDIT_FRAME::OnLeftClick() err: curr_item type %d m_Flags != 0 (%X)",
|
2019-04-22 08:58:06 +00:00
|
|
|
curr_item->Type(), curr_item->GetEditFlags() ) );
|
2011-02-24 12:35:14 +00:00
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2011-02-23 13:48:19 +00:00
|
|
|
|
2011-02-24 12:35:14 +00:00
|
|
|
if( exit )
|
|
|
|
return;
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2009-09-28 12:21:54 +00:00
|
|
|
else if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
|
|
|
|
&& !wxGetKeyState( WXK_CONTROL ) )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = PcbGeneralLocateAndDisplay();
|
2011-03-01 19:26:17 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item )
|
|
|
|
SendMessageToEESCHEMA( curr_item );
|
2008-02-23 04:53:44 +00:00
|
|
|
}
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item ) // display netclass info for zones, tracks and pads
|
2009-10-26 19:00:46 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
switch( curr_item->Type() )
|
2009-10-26 19:00:46 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
case PCB_PAD_T:
|
2014-09-28 14:44:47 +00:00
|
|
|
SetCurrentNetClass(
|
2016-02-19 14:10:23 +00:00
|
|
|
((BOARD_CONNECTED_ITEM*)curr_item)->GetNetClassName() );
|
2009-10-26 19:00:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
|
|
|
case ID_MAIN_MENUBAR:
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2016-06-08 11:19:53 +00:00
|
|
|
case ID_ZOOM_SELECTION:
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_HIGHLIGHT_BUTT:
|
2009-09-28 12:21:54 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
int netcode = SelectHighLight( aDC );
|
|
|
|
|
2009-09-28 12:21:54 +00:00
|
|
|
if( netcode < 0 )
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( GetBoard() );
|
2009-09-28 12:21:54 +00:00
|
|
|
else
|
2008-02-23 04:53:44 +00:00
|
|
|
{
|
2009-09-28 12:21:54 +00:00
|
|
|
NETINFO_ITEM* net = GetBoard()->FindNet( netcode );
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2009-09-28 12:21:54 +00:00
|
|
|
if( net )
|
2013-01-12 17:32:24 +00:00
|
|
|
{
|
|
|
|
MSG_PANEL_ITEMS items;
|
2018-04-10 10:52:12 +00:00
|
|
|
net->GetMsgPanelInfo( m_UserUnits, items );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
}
|
2009-09-28 12:21:54 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
case ID_LOCAL_RATSNEST_BUTT:
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = PcbGeneralLocateAndDisplay();
|
|
|
|
Show_1_Ratsnest( curr_item, aDC );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item )
|
|
|
|
SendMessageToEESCHEMA( curr_item );
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2017-10-31 15:38:10 +00:00
|
|
|
case ID_PCB_TARGET_BUTT:
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
SetCurItem( (BOARD_ITEM*) CreateTarget( aDC ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item->Type() == PCB_TARGET_T )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
PlaceTarget( (PCB_TARGET*) curr_item, aDC );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "OnLeftClick err: not a PCB_TARGET_T" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_CIRCLE_BUTT:
|
|
|
|
case ID_PCB_ARC_BUTT:
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_PCB_ADD_LINE_BUTT:
|
2012-05-22 17:51:18 +00:00
|
|
|
{
|
|
|
|
STROKE_T shape = S_SEGMENT;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2012-05-22 17:51:18 +00:00
|
|
|
if( GetToolId() == ID_PCB_CIRCLE_BUTT )
|
|
|
|
shape = S_CIRCLE;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2012-05-22 17:51:18 +00:00
|
|
|
if( GetToolId() == ID_PCB_ARC_BUTT )
|
|
|
|
shape = S_ARC;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2012-05-22 17:51:18 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = (BOARD_ITEM*) Begin_DrawSegment( NULL, shape, aDC );
|
|
|
|
SetCurItem( curr_item );
|
2012-05-22 17:51:18 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item
|
|
|
|
&& (curr_item->Type() == PCB_LINE_T)
|
|
|
|
&& curr_item->IsNew() )
|
2012-05-22 17:51:18 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = (BOARD_ITEM*) Begin_DrawSegment( (DRAWSEGMENT*) curr_item, shape, aDC );
|
|
|
|
SetCurItem( curr_item );
|
2012-05-22 17:51:18 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TRACK_BUTT:
|
2014-03-21 10:17:47 +00:00
|
|
|
if( !IsCopperLayer( GetActiveLayer() ) )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-11-13 18:02:44 +00:00
|
|
|
DisplayError( this, _( "Tracks on Copper layers only" ) );
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = (BOARD_ITEM*) Begin_Route( NULL, aDC );
|
|
|
|
SetCurItem( curr_item );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item && curr_item->IsNew() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
TRACK* track = Begin_Route( (TRACK*) curr_item, aDC );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// SetCurItem() must not write to the msg panel
|
|
|
|
// because a track info is displayed while moving the mouse cursor
|
|
|
|
if( track ) // A new segment was created
|
2016-02-19 14:10:23 +00:00
|
|
|
SetCurItem( curr_item = (BOARD_ITEM*) track, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
|
|
|
case ID_PCB_ZONES_BUTT:
|
2019-05-15 22:49:48 +00:00
|
|
|
case ID_PCB_KEEPOUT_BUTT:
|
2012-07-13 18:55:29 +00:00
|
|
|
/* ZONE or KEEPOUT Tool is selected. Determine action for a left click:
|
2009-09-28 12:21:54 +00:00
|
|
|
* this can be start a new zone or select and move an existing zone outline corner
|
|
|
|
* if found near the mouse cursor
|
|
|
|
*/
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2012-06-17 16:06:12 +00:00
|
|
|
if( Begin_Zone( aDC ) )
|
2008-02-23 04:53:44 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = GetBoard()->m_CurrentZoneContour;
|
|
|
|
GetScreen()->SetCurItem( curr_item );
|
2008-02-23 04:53:44 +00:00
|
|
|
}
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item && (curr_item->Type() == PCB_ZONE_AREA_T) && curr_item->IsNew() )
|
2011-09-20 15:07:52 +00:00
|
|
|
{ // Add a new corner to the current outline being created:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2011-02-02 19:01:21 +00:00
|
|
|
Begin_Zone( aDC );
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = GetBoard()->m_CurrentZoneContour;
|
|
|
|
GetScreen()->SetCurItem( curr_item );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() zone internal error" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_PCB_ADD_TEXT_BUTT:
|
2014-06-24 16:17:18 +00:00
|
|
|
if( Edge_Cuts == GetActiveLayer() )
|
2014-01-26 17:30:20 +00:00
|
|
|
{
|
|
|
|
DisplayError( this,
|
2014-01-27 08:48:17 +00:00
|
|
|
_( "Texts not allowed on Edge Cut layer" ) );
|
2014-01-26 17:30:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2012-07-04 19:50:47 +00:00
|
|
|
SetCurItem( CreateTextePcb( aDC ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item->Type() == PCB_TEXT_T )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
Place_Texte_Pcb( (TEXTE_PCB*) curr_item, aDC );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "OnLeftClick err: not a PCB_TEXT_T" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
case ID_PCB_DIMENSION_BUTT:
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( GetActiveLayer() ) || GetActiveLayer() == Edge_Cuts )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
DisplayError( this, _( "Dimension not allowed on Copper or Edge Cut layers" ) );
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( !curr_item || !curr_item->GetEditFlags() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = (BOARD_ITEM*) EditDimension( NULL, aDC );
|
|
|
|
SetCurItem( curr_item );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2016-02-19 14:10:23 +00:00
|
|
|
else if( curr_item && (curr_item->Type() == PCB_DIMENSION_T) && curr_item->IsNew() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = (BOARD_ITEM*) EditDimension( (DIMENSION*) curr_item, aDC );
|
|
|
|
SetCurItem( curr_item );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() error item is not a DIMENSION" ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_DELETE_ITEM_BUTT:
|
2019-04-22 08:58:06 +00:00
|
|
|
if( !curr_item || !curr_item->GetEditFlags() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = PcbGeneralLocateAndDisplay();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item && curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
RemoveStruct( curr_item, aDC );
|
|
|
|
SetCurItem( curr_item = NULL );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
|
2018-01-24 21:27:56 +00:00
|
|
|
PCB_EDITOR_CONTROL::SetDrillOrigin( GetGalCanvas()->GetView(), this,
|
|
|
|
new KIGFX::ORIGIN_VIEWITEM( GetAuxOrigin(), UR_TRANSIENT ),
|
|
|
|
GetCrossHairPosition() );
|
|
|
|
m_canvas->Refresh();
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-13 10:42:32 +00:00
|
|
|
case ID_PCB_PLACE_GRID_COORD_BUTT:
|
2018-01-24 21:27:56 +00:00
|
|
|
PCBNEW_CONTROL::SetGridOrigin( GetGalCanvas()->GetView(), this,
|
|
|
|
new KIGFX::ORIGIN_VIEWITEM( GetBoard()->GetGridOrigin(), UR_TRANSIENT ),
|
|
|
|
GetCrossHairPosition() );
|
|
|
|
m_canvas->Refresh();
|
2010-07-13 10:42:32 +00:00
|
|
|
break;
|
|
|
|
|
2017-07-28 09:31:26 +00:00
|
|
|
case ID_PCB_DRAW_VIA_BUTT:
|
2018-02-19 19:26:02 +00:00
|
|
|
DisplayError( this, _( "Via Tool not available in Legacy Toolset" ) );
|
|
|
|
SetNoToolSelected();
|
|
|
|
break;
|
|
|
|
|
2017-03-09 09:09:13 +00:00
|
|
|
case ID_PCB_MEASUREMENT_TOOL:
|
2018-02-19 19:26:02 +00:00
|
|
|
DisplayError( this, _( "Measurement Tool not available in Legacy Toolset" ) );
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2017-03-09 09:09:13 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
default:
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "PCB_EDIT_FRAME::OnLeftClick() id error" ) );
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
/* handle the double click on the mouse left button
|
2007-09-29 15:30:16 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
BOARD_ITEM* curr_item = GetCurItem();
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() == 0 )
|
2016-02-19 14:10:23 +00:00
|
|
|
curr_item = PcbGeneralLocateAndDisplay();
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item == NULL || curr_item->GetEditFlags() != 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
SendMessageToEESCHEMA( curr_item );
|
2007-09-29 15:30:16 +00:00
|
|
|
|
|
|
|
// An item is found
|
2016-02-19 14:10:23 +00:00
|
|
|
SetCurItem( curr_item );
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
switch( curr_item->Type() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item->IsNew() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
if( End_Route( (TRACK*) curr_item, aDC ) )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2019-04-22 08:58:06 +00:00
|
|
|
else if( curr_item->GetEditFlags() == 0 )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
Edit_TrackSegm_Width( aDC, (TRACK*) curr_item );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_PAD_T:
|
|
|
|
case PCB_MODULE_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
|
|
|
case PCB_MODULE_TEXT_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
OnEditItemRequest( aDC, curr_item );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2016-02-19 14:10:23 +00:00
|
|
|
OnEditItemRequest( aDC, curr_item );
|
2009-01-05 05:21:35 +00:00
|
|
|
break;
|
2007-09-29 15:30:16 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2019-04-22 08:58:06 +00:00
|
|
|
if( curr_item->GetEditFlags() )
|
2008-10-09 19:13:25 +00:00
|
|
|
break;
|
2011-12-21 13:42:02 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
OnEditItemRequest( aDC, curr_item );
|
2008-10-09 19:13:25 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break; // end case 0
|
|
|
|
|
|
|
|
case ID_TRACK_BUTT:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item && curr_item->IsNew() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
if( End_Route( (TRACK*) curr_item, aDC ) )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2007-09-29 15:30:16 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_ZONES_BUTT:
|
2019-05-15 22:49:48 +00:00
|
|
|
case ID_PCB_KEEPOUT_BUTT:
|
2011-02-02 19:01:21 +00:00
|
|
|
if( End_Zone( aDC ) )
|
2008-02-23 04:53:44 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2008-02-23 04:53:44 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_PCB_ADD_LINE_BUTT:
|
2007-09-29 15:30:16 +00:00
|
|
|
case ID_PCB_ARC_BUTT:
|
|
|
|
case ID_PCB_CIRCLE_BUTT:
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item == NULL )
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item->Type() != PCB_LINE_T )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2017-08-01 11:12:59 +00:00
|
|
|
DisplayErrorMessage( this, "Item type is incorrect",
|
|
|
|
wxString::Format( "Selected item type is %d\n"
|
|
|
|
"Expected: %d", curr_item->Type(), PCB_LINE_T ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2016-02-19 14:10:23 +00:00
|
|
|
if( curr_item->IsNew() )
|
2007-09-29 15:30:16 +00:00
|
|
|
{
|
2016-02-19 14:10:23 +00:00
|
|
|
End_Edge( (DRAWSEGMENT*) curr_item, aDC );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2007-09-29 15:30:16 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-09-29 15:30:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
|
2010-08-10 18:34:26 +00:00
|
|
|
{
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
Edit_TrackSegm_Width( aDC, static_cast<TRACK*>( aItem ) );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2018-06-06 10:05:56 +00:00
|
|
|
InstallTextOptionsFrame( aItem, aDC );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2018-01-31 13:54:31 +00:00
|
|
|
InstallFootprintPropertiesDialog( static_cast<MODULE*>( aItem ), aDC );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ), aDC );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
ShowDimensionPropertyDialog( static_cast<DIMENSION*>( aItem ), aDC );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2018-06-06 10:05:56 +00:00
|
|
|
InstallTextOptionsFrame( aItem, aDC );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2018-09-12 19:39:37 +00:00
|
|
|
InstallGraphicItemPropertiesDialog( aItem );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
Edit_Zone_Params( aDC, static_cast<ZONE_CONTAINER*>( aItem ) );
|
2010-08-10 18:34:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|