2007-08-20 01:20:48 +00:00
|
|
|
/********************************/
|
|
|
|
/* Scehematic component edition */
|
|
|
|
/********************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Fonctions locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Prepare le deplacement du texte en cours d'edition
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
SetCurrentField( aField );
|
|
|
|
if( aField == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( aField->m_Text == wxEmptyString )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "No Field to move" ), 10 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint pos, newpos;
|
2008-11-24 06:53:43 +00:00
|
|
|
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2008-11-24 06:53:43 +00:00
|
|
|
g_ItemToUndoCopy = comp->GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
pos = comp->m_Pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice
|
|
|
|
* de rotation-miroir */
|
2009-01-02 13:19:34 +00:00
|
|
|
newpos = aField->m_Pos - pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Empirically this is necessary. The Y coordinate appears to be inverted
|
|
|
|
// under some circumstances, but that inversion is not preserved by all
|
|
|
|
// combinations of mirroring and rotation. The following clause is true
|
|
|
|
// when the number of rotations and the number of mirrorings are both odd.
|
2008-11-24 06:53:43 +00:00
|
|
|
if( comp->m_Transform[1][0] * comp->m_Transform[0][1] < 0 )
|
2009-01-02 13:19:34 +00:00
|
|
|
NEGATE (newpos.y);
|
|
|
|
|
|
|
|
newpos = TransformCoordinate( comp->m_Transform, newpos) + pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->m_Curseur = newpos;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
m_OldPos = aField->m_Pos;
|
|
|
|
m_Multiflag = 0;
|
|
|
|
if( aField->m_FieldId == REFERENCE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( comp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry != NULL )
|
|
|
|
{
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Multiflag = 1;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortMoveCmpField;
|
|
|
|
DrawPanel->ManageCurseur = MoveCmpField;
|
2008-11-24 06:53:43 +00:00
|
|
|
aField->m_Flags = IS_MOVED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
2008-09-17 17:26:25 +00:00
|
|
|
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************************************/
|
|
|
|
/* Edit the field Field (text, size) */
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
int fieldNdx, flag;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Field == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "No Field To Edit" ), 10 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
fieldNdx = Field->m_FieldId;
|
|
|
|
if( fieldNdx == VALUE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry && (Entry->m_Options == ENTRY_POWER) )
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
DisplayInfoMessage( this,
|
2007-08-20 01:20:48 +00:00
|
|
|
_(
|
|
|
|
"Part is a POWER, value cannot be modified!\nYou must create a new power" )
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
if( fieldNdx == REFERENCE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry != NULL )
|
|
|
|
{
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
if( Field->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( Cmp, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxString newtext = Field->m_Text;
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2008-09-22 16:03:12 +00:00
|
|
|
Get_Message( Field->m_Name, _("Component field text"), newtext, this );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
Field->m_AddExtraText = flag;
|
|
|
|
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !newtext.IsEmpty() )
|
|
|
|
{
|
|
|
|
if( Field->m_Text.IsEmpty() )
|
|
|
|
{
|
|
|
|
Field->m_Pos = Cmp->m_Pos;
|
2008-11-24 06:53:43 +00:00
|
|
|
Field->m_Size.x = Field->m_Size.y = m_TextFieldSize;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
Field->m_Text = newtext;
|
2008-11-24 06:53:43 +00:00
|
|
|
if( fieldNdx == REFERENCE ){
|
2008-03-20 01:50:21 +00:00
|
|
|
Cmp->SetRef(GetSheet(), newtext);
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else /* Nouveau texte NULL */
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( fieldNdx == REFERENCE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Reference needed !, No change" ) );
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
else if( fieldNdx == VALUE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Value needed !, No change" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Field->m_Text = wxT( "~" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Routine de deplacement d'un texte type Field.
|
2007-08-20 01:20:48 +00:00
|
|
|
* Celle routine est normalement attachee au deplacement du curseur
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint pos;
|
|
|
|
int x1, y1;
|
2008-11-24 06:53:43 +00:00
|
|
|
int fieldNdx;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent();
|
|
|
|
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
|
|
|
|
|
|
|
|
if( currentField == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) currentField->GetParent();
|
|
|
|
fieldNdx = currentField->m_FieldId;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
// Effacement:
|
|
|
|
currentField->m_AddExtraText = frame->m_Multiflag;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode );
|
2008-04-14 19:22:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
pos = ( (SCH_COMPONENT*) currentField->GetParent() )->m_Pos;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Les positions sont caculees par la matrice TRANSPOSEE de la matrice
|
2008-11-24 06:53:43 +00:00
|
|
|
* de rotation-miroir
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
x1 = panel->GetScreen()->m_Curseur.x - pos.x;
|
|
|
|
y1 = panel->GetScreen()->m_Curseur.y - pos.y;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
currentField->m_Pos.x = pos.x + component->m_Transform[0][0] * x1 + component->m_Transform[1][0] * y1;
|
|
|
|
currentField->m_Pos.y = pos.y + component->m_Transform[0][1] * x1 + component->m_Transform[1][1] * y1;
|
|
|
|
|
|
|
|
currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
Panel->ManageCurseur = NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent();
|
|
|
|
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
|
|
|
|
|
|
|
|
if( currentField )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
currentField->m_AddExtraText = frame->m_Multiflag;
|
|
|
|
currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode );
|
|
|
|
currentField->m_Flags = 0;
|
|
|
|
currentField->m_Pos = frame->m_OldPos;
|
|
|
|
currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
frame->SetCurrentField( NULL );
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
2008-09-17 17:26:25 +00:00
|
|
|
void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
int fieldNdx, flag;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Field == NULL )
|
|
|
|
return;
|
|
|
|
if( Field->m_Text == wxEmptyString )
|
|
|
|
return;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
fieldNdx = Field->m_FieldId;
|
2007-08-20 01:20:48 +00:00
|
|
|
flag = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
if( fieldNdx == REFERENCE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent(
|
|
|
|
( (SCH_COMPONENT*) Field->GetParent() )->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry != NULL )
|
|
|
|
{
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
if( Field->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( Cmp, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
Field->m_AddExtraText = flag;
|
|
|
|
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Field->m_Orient == TEXT_ORIENT_HORIZ )
|
|
|
|
Field->m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
else
|
|
|
|
Field->m_Orient = TEXT_ORIENT_HORIZ;
|
2008-04-14 19:22:48 +00:00
|
|
|
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
/* Edit the component text reference*/
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2007-08-20 01:20:48 +00:00
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
if( Cmp == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Entry->m_UnitCount > 1 )
|
|
|
|
flag = 1;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
wxString ref = Cmp->GetRef(GetSheet());
|
2008-10-07 16:33:57 +00:00
|
|
|
Get_Message( _( "Reference" ), _("Component reference"), ref, this );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
if( !ref.IsEmpty() ) // New text entered
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
if( Cmp->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( Cmp, UR_CHANGED );
|
2008-03-20 01:50:21 +00:00
|
|
|
Cmp->SetRef(GetSheet(), ref);
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
|
|
|
|
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2008-03-20 01:50:21 +00:00
|
|
|
Cmp->SetRef(GetSheet(), ref );
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0),
|
2007-08-20 01:20:48 +00:00
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************************/
|
|
|
|
/* Routine de changement du texte selectionne */
|
|
|
|
{
|
2008-09-22 16:03:12 +00:00
|
|
|
wxString message;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Cmp == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-09-22 16:03:12 +00:00
|
|
|
message = TextField->m_Text;
|
2008-10-07 16:33:57 +00:00
|
|
|
if( Get_Message( _( "Value" ), _("Component value"), message, this ) )
|
2008-09-22 16:03:12 +00:00
|
|
|
message.Empty(); //allow the user to remove the value.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-09-22 16:03:12 +00:00
|
|
|
if( !message.IsEmpty() && !message.IsEmpty())
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
if( Cmp->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( Cmp, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
TextField->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
2008-09-22 16:03:12 +00:00
|
|
|
TextField->m_Text = message;
|
2008-04-14 19:22:48 +00:00
|
|
|
TextField->Draw( DrawPanel, DC, wxPoint(0,0),
|
2007-08-20 01:20:48 +00:00
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
/*****************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC )
|
2007-12-11 16:41:43 +00:00
|
|
|
/*****************************************************************************************/
|
|
|
|
{
|
2008-09-22 16:03:12 +00:00
|
|
|
wxString message;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2008-03-20 01:50:21 +00:00
|
|
|
bool wasEmpty = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
if( Cmp == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
if( Entry == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT );
|
2007-12-11 16:41:43 +00:00
|
|
|
|
2008-09-22 16:03:12 +00:00
|
|
|
message = TextField->m_Text;
|
|
|
|
if(message.IsEmpty() )
|
2008-03-20 01:50:21 +00:00
|
|
|
wasEmpty = true;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-10-07 16:33:57 +00:00
|
|
|
if( Get_Message( _( "Footprint" ), _("Component footprint"), message, this ) )
|
2008-10-06 05:44:29 +00:00
|
|
|
message.Empty(); // allow the user to remove the value.
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
// save old cmp in undo list if not already in edit, or moving ...
|
2008-03-20 01:50:21 +00:00
|
|
|
if( Cmp->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( Cmp, UR_CHANGED );
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
|
|
|
|
|
|
|
|
// move the field if it was new.
|
|
|
|
if( wasEmpty && !message.IsEmpty() )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->m_Pos = Cmp->GetField( REFERENCE )->m_Pos;
|
|
|
|
|
|
|
|
// add offset here - ? suitable heuristic below?
|
|
|
|
Cmp->GetField( FOOTPRINT )->m_Pos.x +=
|
|
|
|
(Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x) > 0 ?
|
|
|
|
(Cmp->GetField( REFERENCE )->m_Size.x) : (-1*Cmp->GetField( REFERENCE )->m_Size.x);
|
|
|
|
|
|
|
|
Cmp->GetField( FOOTPRINT )->m_Pos.y +=
|
|
|
|
(Cmp->GetField( REFERENCE )->m_Pos.y - Cmp->m_Pos.y) > 0 ?
|
|
|
|
(Cmp->GetField( REFERENCE )->m_Size.y) : (-1*Cmp->GetField( REFERENCE )->m_Size.y);
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2008-09-22 16:03:12 +00:00
|
|
|
TextField->m_Text = message;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0),
|
2008-03-20 01:50:21 +00:00
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2007-12-11 16:41:43 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|