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
|
|
|
|
2012-02-22 14:04:48 +00:00
|
|
|
#include <dialog_edit_one_field.h>
|
|
|
|
|
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.
|
2018-09-27 20:09:00 +00:00
|
|
|
int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | HIGHLIGHTED | BRIGHTENED );
|
|
|
|
if( ( aField->GetFlags() & mask ) == 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-10-21 18:17:51 +00:00
|
|
|
// Don't use GetText() here. If the field is the reference designator and it's parent
|
|
|
|
// component has multiple parts, we don't want the part suffix added to the field.
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2010-07-20 10:30:40 +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 )
|
2015-03-23 11:45:31 +00:00
|
|
|
{
|
2016-04-02 12:25:44 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
|
|
|
return;
|
2015-03-23 11:45:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-22 13:29:47 +00:00
|
|
|
dlg.UpdateField( aField, m_CurrentSheet );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2016-04-02 12:25:44 +00:00
|
|
|
OnModify();
|
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
|
|
|
|
2016-04-02 12:25:44 +00:00
|
|
|
m_canvas->Refresh();
|
2012-02-22 14:04:48 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
2016-02-15 20:15:51 +00:00
|
|
|
component->SetCurrentSheetPath( &GetCurrentSheet() );
|
2018-04-10 10:52:12 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 12:16:27 +00:00
|
|
|
void SCH_EDIT_FRAME::RotateField( SCH_FIELD* aField )
|
2010-04-27 19:19:04 +00:00
|
|
|
{
|
2011-03-29 15:21:35 +00:00
|
|
|
wxCHECK_RET( aField != NULL && aField->Type() == SCH_FIELD_T && !aField->GetText().IsEmpty(),
|
|
|
|
wxT( "Cannot rotate invalid schematic field." ) );
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) aField->GetParent();
|
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.
|
2018-09-27 20:09:00 +00:00
|
|
|
int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | HIGHLIGHTED | BRIGHTENED );
|
|
|
|
if( ( aField->GetFlags() & mask ) == 0 )
|
2011-03-29 15:21:35 +00:00
|
|
|
SaveCopyInUndoList( component, UR_CHANGED );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( aField->GetTextAngle() == TEXT_ANGLE_HORIZ )
|
|
|
|
aField->SetTextAngle( TEXT_ANGLE_VERT );
|
2011-03-29 15:21:35 +00:00
|
|
|
else
|
2017-01-23 20:30:11 +00:00
|
|
|
aField->SetTextAngle( TEXT_ANGLE_HORIZ );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-05-23 17:39:47 +00:00
|
|
|
OnModify();
|
2007-12-11 16:41:43 +00:00
|
|
|
}
|