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>
|
2019-04-15 14:34:58 +00:00
|
|
|
* Copyright (C) 1992-2019 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
|
|
|
|
*/
|
|
|
|
|
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>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_sheet.h>
|
2019-04-18 15:45:10 +00:00
|
|
|
#include <sch_bitmap.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_view.h>
|
2019-04-21 23:45:34 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/sch_selection_tool.h>
|
2009-09-25 18:49:04 +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
|
|
|
{
|
2019-04-18 15:45:10 +00:00
|
|
|
SCH_ITEM* item = GetScreen()->GetCurItem();
|
2019-04-21 23:45:34 +00:00
|
|
|
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-04-18 15:45:10 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
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
|
|
|
|
2019-04-18 15:45:10 +00:00
|
|
|
// item_flags != 0 means a current item in edit
|
2019-04-22 08:58:06 +00:00
|
|
|
if( item && item->GetEditFlags() )
|
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
|
|
|
{
|
2019-04-18 15:45:10 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_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:
|
2019-04-18 15:45:10 +00:00
|
|
|
case SCH_BUS_WIRE_ENTRY_T:
|
|
|
|
case SCH_BUS_BUS_ENTRY_T:
|
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_COMPONENT_T:
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
2019-04-18 15:45:10 +00:00
|
|
|
case SCH_BITMAP_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
2019-04-15 14:34:58 +00:00
|
|
|
AddItemToScreen( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
GetCanvas()->GetView()->ClearPreview();
|
2018-09-05 11:15:07 +00:00
|
|
|
GetCanvas()->GetView()->ClearHiddenFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2019-04-21 23:45:34 +00:00
|
|
|
item = selTool->SelectPoint( aPosition );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-29 08:39:08 +00:00
|
|
|
if( !item ) // If clicked on a empty area, clear any highligthed symbol
|
|
|
|
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
|
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
|
|
|
{
|
2019-04-21 23:45:34 +00:00
|
|
|
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
|
|
|
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:
|
2019-04-22 08:58:06 +00:00
|
|
|
if( item == NULL || item->GetEditFlags() == 0 )
|
2019-04-21 23:45:34 +00:00
|
|
|
item = selTool->SelectPoint( aPosition, SCH_COLLECTOR::DoubleClickItems );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( item == NULL || item->GetEditFlags() != 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:
|
2019-03-11 21:32:05 +00:00
|
|
|
g_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();
|
|
|
|
|
2019-04-22 08:58:06 +00:00
|
|
|
if( item->GetEditFlags() == 0 )
|
|
|
|
GetScreen()->SetCurItem( nullptr );
|
2015-06-28 16:45:05 +00:00
|
|
|
|
|
|
|
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:
|
2019-04-15 23:56:41 +00:00
|
|
|
case SCH_HIER_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:
|
2019-02-12 15:40:20 +00:00
|
|
|
// The bitmap is cached in Opengl: clear the cache, because
|
|
|
|
// the cache data is perhaps invalid
|
|
|
|
if( EditImage( (SCH_BITMAP*) item ) )
|
|
|
|
GetCanvas()->GetView()->RecacheAllItems();
|
|
|
|
|
2011-08-31 14:59:20 +00:00
|
|
|
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
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|