2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-03-23 12:16:27 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-10-06 18:07:43 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2018-08-15 11:19:41 +00:00
|
|
|
* Copyright (C) 2004-2018 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 edit_component_in_schematic.cpp
|
|
|
|
* @brief Schematic component editing code.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <sch_component.h>
|
2017-10-06 18:07:43 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2019-02-20 23:20:06 +00:00
|
|
|
#include <dialogs/dialog_edit_component_in_schematic.h>
|
|
|
|
#include <dialogs/dialog_edit_one_field.h>
|
2012-02-22 14:04:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-06-03 11:16:08 +00:00
|
|
|
void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
wxCHECK_RET( aField != NULL && aField->Type() == SCH_FIELD_T,
|
2011-03-29 15:21:35 +00:00
|
|
|
wxT( "Cannot edit invalid schematic field." ) );
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) aField->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxCHECK_RET( component != NULL && component->Type() == SCH_COMPONENT_T,
|
|
|
|
wxT( "Invalid schematic field parent item." ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
// Save old component in undo list if not already in edit, or moving.
|
2019-04-22 08:58:06 +00:00
|
|
|
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
2011-03-25 19:16:05 +00:00
|
|
|
SaveCopyInUndoList( component, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
wxString title;
|
2011-12-07 18:47:59 +00:00
|
|
|
title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
|
2011-03-29 15:21:35 +00:00
|
|
|
|
2012-02-22 14:04:48 +00:00
|
|
|
DIALOG_SCH_EDIT_ONE_FIELD dlg( this, title, aField );
|
|
|
|
|
2016-04-02 12:25:44 +00:00
|
|
|
// The dialog may invoke a kiway player for footprint fields
|
|
|
|
// so we must use a quasimodal
|
|
|
|
if( dlg.ShowQuasiModal() != wxID_OK )
|
|
|
|
return;
|
2015-03-23 11:45:31 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
dlg.UpdateField( aField, g_CurrentSheet );
|
2015-12-13 16:56:47 +00:00
|
|
|
|
2016-04-02 12:25:44 +00:00
|
|
|
if( m_autoplaceFields )
|
|
|
|
component->AutoAutoplaceFields( GetScreen() );
|
2015-12-13 16:56:47 +00:00
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
RefreshItem( aField );
|
|
|
|
OnModify();
|
2012-02-22 14:04:48 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
2019-06-09 22:21:53 +00:00
|
|
|
component->GetMsgPanelInfo( m_userUnits, items );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( items );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-20 23:20:06 +00:00
|
|
|
void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( aComponent != nullptr && aComponent->Type() == SCH_COMPONENT_T,
|
|
|
|
wxT( "Invalid component object pointer. Bad Programmer!" ) );
|
|
|
|
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( this, aComponent );
|
|
|
|
|
|
|
|
// This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
|
|
|
|
// frame. Therefore this dialog as a modal frame parent, MUST be run under
|
|
|
|
// quasimodal mode for the quasimodal frame support to work. So don't use
|
|
|
|
// the QUASIMODAL macros here.
|
|
|
|
int ret = dlg.ShowQuasiModal();
|
|
|
|
|
|
|
|
if( ret == wxID_OK )
|
|
|
|
{
|
|
|
|
if( m_autoplaceFields )
|
|
|
|
aComponent->AutoAutoplaceFields( GetScreen() );
|
|
|
|
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
}
|