2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-11-16 12:09:34 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2011-10-19 20:32:21 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2017-03-23 00:59:25 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-19 20:32:21 +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-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file eeschema/onleftclick.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2016-08-11 12:41:11 +00:00
|
|
|
#include <kiway.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <class_drawpanel.h>
|
2016-11-16 10:07:02 +00:00
|
|
|
#include <confirm.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2016-08-11 12:41:11 +00:00
|
|
|
#include <sim/sim_plot_frame.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_bus_entry.h>
|
|
|
|
#include <sch_text.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_junction.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_no_connect.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_sheet.h>
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <sch_sheet_path.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_bitmap.h>
|
2016-08-11 12:41:11 +00:00
|
|
|
|
|
|
|
#include <class_netlist_object.h>
|
2015-04-16 15:26:51 +00:00
|
|
|
#include <class_library.h> // fo class SCHLIB_FILTER to filter power parts
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2014-02-18 21:41:27 +00:00
|
|
|
// TODO(hzeller): These pairs of elmenets should be represented by an object, but don't want
|
|
|
|
// to refactor too much right now to not get in the way with other code changes.
|
2017-03-23 00:59:25 +00:00
|
|
|
static SCH_BASE_FRAME::HISTORY_LIST s_CmpNameList;
|
|
|
|
static SCH_BASE_FRAME::HISTORY_LIST s_PowerNameList;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-08-06 22:59:07 +00:00
|
|
|
SCH_ITEM* item = GetScreen()->GetCurItem();
|
|
|
|
wxPoint gridPosition = GetGridPosition( aPosition );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->GetFlags() ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2013-08-05 21:02:41 +00:00
|
|
|
SetRepeatItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
if( item && item->GetFlags() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_TEXT_T:
|
2011-03-30 19:26:05 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_SHEET_T:
|
2013-04-01 10:35:20 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_COMPONENT_T:
|
|
|
|
case SCH_FIELD_T:
|
2011-08-31 14:59:20 +00:00
|
|
|
case SCH_BITMAP_T:
|
2011-10-19 20:32:21 +00:00
|
|
|
case SCH_NO_CONNECT_T:
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-23 15:42:56 +00:00
|
|
|
case SCH_LINE_T: // May already be drawing segment.
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-02-23 15:42:56 +00:00
|
|
|
wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick error. Item type <" ) +
|
|
|
|
item->GetClass() + wxT( "> is already being edited." ) );
|
2011-03-03 01:58:12 +00:00
|
|
|
item->ClearFlags();
|
2012-06-20 09:52:29 +00:00
|
|
|
break;
|
2010-08-28 18:02:24 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
item = LocateAndShowItem( aPosition );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2017-06-10 07:06:25 +00:00
|
|
|
case ID_ZOOM_SELECTION:
|
|
|
|
break;
|
|
|
|
|
2016-11-16 10:07:02 +00:00
|
|
|
case ID_HIGHLIGHT:
|
2016-11-16 12:09:34 +00:00
|
|
|
HighlightConnectionAtPosition( aPosition );
|
|
|
|
break;
|
2016-11-16 10:07:02 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_NOCONN_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-04-19 18:41:57 +00:00
|
|
|
if( GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) == NULL )
|
2012-06-20 09:52:29 +00:00
|
|
|
{
|
2013-08-05 21:02:41 +00:00
|
|
|
SCH_NO_CONNECT* no_connect = AddNoConnect( aDC, gridPosition );
|
|
|
|
SetRepeatItem( no_connect );
|
|
|
|
GetScreen()->SetCurItem( no_connect );
|
2012-06-20 09:52:29 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_JUNCTION_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-04-19 18:41:57 +00:00
|
|
|
if( GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) == NULL )
|
2012-06-20 09:52:29 +00:00
|
|
|
{
|
2013-08-05 21:02:41 +00:00
|
|
|
SCH_JUNCTION* junction = AddJunction( aDC, gridPosition, true );
|
|
|
|
SetRepeatItem( junction );
|
|
|
|
GetScreen()->SetCurItem( junction );
|
2012-06-20 09:52:29 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_WIRETOBUS_ENTRY_BUTT:
|
2013-04-01 10:35:20 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
CreateBusWireEntry();
|
2013-04-01 10:35:20 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2013-04-01 10:35:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-08-05 21:02:41 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_BUSTOBUS_ENTRY_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
CreateBusBusEntry();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
DeleteItemAtCrossHair( aDC );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_WIRE_BUTT:
|
2011-02-02 19:01:21 +00:00
|
|
|
BeginSegment( aDC, LAYER_WIRE );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_BUS_BUTT:
|
2011-02-02 19:01:21 +00:00
|
|
|
BeginSegment( aDC, LAYER_BUS );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LINE_COMMENT_BUTT:
|
2011-02-02 19:01:21 +00:00
|
|
|
BeginSegment( aDC, LAYER_NOTES );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TEXT_COMMENT_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-08-31 14:59:20 +00:00
|
|
|
case ID_ADD_IMAGE_BUTT:
|
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
|
|
|
{
|
|
|
|
GetScreen()->SetCurItem( CreateNewImage( aDC ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2011-08-31 14:59:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2011-08-31 14:59:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_LABEL_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GLABEL_BUTT:
|
2008-03-16 04:47:43 +00:00
|
|
|
case ID_HIERLABEL_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( (item == NULL) || (item->GetFlags() == 0) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_GLABEL_BUTT )
|
2011-02-02 19:01:21 +00:00
|
|
|
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) );
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_HIERLABEL_BUTT )
|
2011-02-02 19:01:21 +00:00
|
|
|
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_HIERLABEL ) );
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2008-03-16 04:47:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_SHEET_SYMBOL_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-01-04 22:08:46 +00:00
|
|
|
item = CreateSheet( aDC );
|
|
|
|
|
|
|
|
if( item != NULL )
|
|
|
|
{
|
|
|
|
GetScreen()->SetCurItem( item );
|
|
|
|
m_canvas->SetAutoPanRequest( true );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
case ID_IMPORT_HLABEL_BUTT:
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_SHEET_PIN_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::SheetsAndSheetLabels );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
if( item == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
|
2011-03-30 19:26:05 +00:00
|
|
|
GetScreen()->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, aDC ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2011-03-30 19:26:05 +00:00
|
|
|
GetScreen()->SetCurItem( CreateSheetPin( (SCH_SHEET*) item, aDC ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-03-30 19:26:05 +00:00
|
|
|
else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_SCH_PLACE_COMPONENT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( (item == NULL) || (item->GetFlags() == 0) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-04-16 15:26:51 +00:00
|
|
|
GetScreen()->SetCurItem( Load_Component( aDC, NULL,
|
2017-03-23 00:59:25 +00:00
|
|
|
s_CmpNameList, true ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PLACE_POWER_BUTT:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2015-04-16 15:26:51 +00:00
|
|
|
SCHLIB_FILTER filter;
|
|
|
|
filter.FilterPowerParts( true );
|
|
|
|
GetScreen()->SetCurItem( Load_Component( aDC, &filter,
|
2017-03-23 00:59:25 +00:00
|
|
|
s_PowerNameList, false ) );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-28 16:45:05 +00:00
|
|
|
addCurrentItemToList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-08-11 12:42:13 +00:00
|
|
|
#ifdef KICAD_SPICE
|
2016-08-11 12:41:45 +00:00
|
|
|
case ID_SIM_PROBE:
|
2016-08-11 12:41:11 +00:00
|
|
|
{
|
2017-10-15 16:11:31 +00:00
|
|
|
constexpr KICAD_T wiresAndComponents[] = { SCH_LINE_T,
|
|
|
|
SCH_COMPONENT_T, SCH_SHEET_PIN_T, EOT };
|
2016-08-11 12:41:11 +00:00
|
|
|
item = LocateAndShowItem( aPosition, wiresAndComponents );
|
|
|
|
|
|
|
|
if( !item )
|
|
|
|
break;
|
|
|
|
|
|
|
|
NETLIST_OBJECT_LIST* netlist = BuildNetListBase();
|
|
|
|
|
|
|
|
for( NETLIST_OBJECT* obj : *netlist )
|
|
|
|
{
|
|
|
|
if( obj->m_Comp == item )
|
|
|
|
{
|
|
|
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
|
|
|
|
|
|
|
|
if( simFrame )
|
|
|
|
simFrame->AddVoltagePlot( obj->GetNetName() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-08-11 12:41:45 +00:00
|
|
|
case ID_SIM_TUNE:
|
|
|
|
{
|
2017-10-15 16:11:31 +00:00
|
|
|
constexpr KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
|
2016-08-11 12:41:45 +00:00
|
|
|
item = LocateAndShowItem( aPosition, fieldsAndComponents );
|
|
|
|
|
|
|
|
if( !item )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
item = static_cast<SCH_ITEM*>( item->GetParent() );
|
|
|
|
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
|
|
|
|
|
|
|
|
if( simFrame )
|
|
|
|
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
|
|
|
}
|
|
|
|
break;
|
2016-08-11 12:42:13 +00:00
|
|
|
#endif /* KICAD_SPICE */
|
2016-08-11 12:41:45 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2017-06-12 14:17:48 +00:00
|
|
|
SetNoToolSelected();
|
2011-02-23 15:42:56 +00:00
|
|
|
wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick invalid tool ID <" ) +
|
2011-02-24 20:22:12 +00:00
|
|
|
wxString::Format( wxT( "%d> selected." ), GetToolId() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function OnLeftDClick
|
2009-01-31 18:08:47 +00:00
|
|
|
* called on a double click event from the drawpanel mouse handler
|
|
|
|
* if an editable item is found (text, component)
|
|
|
|
* Call the suitable dialog editor.
|
2009-11-04 20:46:53 +00:00
|
|
|
* Id a create command is in progress:
|
2009-01-31 18:08:47 +00:00
|
|
|
* validate and finish the command
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-02-02 19:01:21 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
EDA_ITEM* item = GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-02 19:01:21 +00:00
|
|
|
item = LocateAndShowItem( aPosition );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
if( ( item == NULL ) || ( item->GetFlags() != 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-02 19:01:21 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_SHEET_T:
|
2016-02-27 19:35:45 +00:00
|
|
|
m_CurrentSheet->push_back( (SCH_SHEET*) item );
|
2011-02-05 02:21:11 +00:00
|
|
|
DisplayCurrentSheet();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2011-08-30 19:24:28 +00:00
|
|
|
EditComponent( (SCH_COMPONENT*) item );
|
2015-06-28 16:45:05 +00:00
|
|
|
GetCanvas()->MoveCursorToCrossHair();
|
|
|
|
|
|
|
|
if( item->GetFlags() == 0 )
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
GetCanvas()->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
2011-02-02 19:01:21 +00:00
|
|
|
EditSchematicText( (SCH_TEXT*) item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-08-31 14:59:20 +00:00
|
|
|
case SCH_BITMAP_T:
|
|
|
|
EditImage( (SCH_BITMAP*) item );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
2012-06-03 11:16:08 +00:00
|
|
|
EditComponentFieldText( (SCH_FIELD*) item );
|
2015-06-28 16:45:05 +00:00
|
|
|
GetCanvas()->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_MARKER_T:
|
2011-02-02 19:01:21 +00:00
|
|
|
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
2009-07-09 17:02:15 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_BUS_BUTT:
|
|
|
|
case ID_WIRE_BUTT:
|
|
|
|
case ID_LINE_COMMENT_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
if( item && item->IsNew() )
|
2011-02-02 19:01:21 +00:00
|
|
|
EndSegment( aDC );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|