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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Prepare the displacement of the text being edited.
|
|
|
|
*/
|
2010-04-27 19:19:04 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC )
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Positions are computed by the transpose matrix. Rotating mirror. */
|
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-11-03 13:26:31 +00:00
|
|
|
NEGATE( newpos.y );
|
2009-01-02 13:19:34 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
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 )
|
|
|
|
{
|
2009-10-05 17:52:41 +00:00
|
|
|
if( Entry->GetPartCount() > 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Edit the field Field (text, size) */
|
2009-11-03 13:26:31 +00:00
|
|
|
/******************************************************************************/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_FIELD* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +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
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( Entry && Entry->isPower() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
DisplayInfoMessage( this, _( "Part is a POWER, value cannot be \
|
|
|
|
modified!\nYou must create a new power" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
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 )
|
|
|
|
{
|
2009-10-05 17:52:41 +00:00
|
|
|
if( Entry->GetPartCount() > 1 )
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2010-07-20 10:30:40 +00:00
|
|
|
|
|
|
|
wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext );
|
|
|
|
int diag = dlg.ShowModal();
|
|
|
|
newtext = dlg.GetValue( );
|
2010-07-21 08:15:54 +00:00
|
|
|
newtext.Trim( true );
|
|
|
|
newtext.Trim( false );
|
2010-07-20 10:30:40 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2010-07-20 10:30:40 +00:00
|
|
|
if ( diag != wxID_OK )
|
|
|
|
return; // cancelled by user
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
Field->m_AddExtraText = flag;
|
2009-11-03 13:26:31 +00:00
|
|
|
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;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( fieldNdx == REFERENCE )
|
|
|
|
{
|
|
|
|
Cmp->SetRef( GetSheet(), newtext );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-03 13:26:31 +00:00
|
|
|
else
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
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( "~" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2010-04-27 19:19:04 +00:00
|
|
|
OnModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
/*
|
|
|
|
* Move standard text field. This routine is normally attached to the cursor.
|
|
|
|
*/
|
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
|
|
|
wxPoint pos;
|
2009-11-03 13:26:31 +00:00
|
|
|
int x1, y1;
|
|
|
|
int fieldNdx;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent();
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* currentField = frame->GetCurrentField();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
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
|
|
|
currentField->m_AddExtraText = frame->m_Multiflag;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Positions are calculated by the transpose matrix, Rotating mirror. */
|
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
|
|
|
|
2009-11-03 13:26:31 +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;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent();
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* currentField = frame->GetCurrentField();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
if( currentField )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
currentField->m_AddExtraText = frame->m_Multiflag;
|
2009-11-03 13:26:31 +00:00
|
|
|
currentField->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2008-11-24 06:53:43 +00:00
|
|
|
currentField->m_Flags = 0;
|
|
|
|
currentField->m_Pos = frame->m_OldPos;
|
2009-11-03 13:26:31 +00:00
|
|
|
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
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::RotateCmpField( SCH_FIELD* Field, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +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;
|
2009-11-03 13:26:31 +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 )
|
|
|
|
{
|
2009-10-05 17:52:41 +00:00
|
|
|
if( Entry->GetPartCount() > 1 )
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2009-11-03 13:26:31 +00:00
|
|
|
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;
|
2009-11-03 13:26:31 +00:00
|
|
|
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
OnModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Edit the component text reference*/
|
2010-04-27 19:19:04 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC )
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
2009-11-03 13:26:31 +00:00
|
|
|
int flag = 0;
|
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;
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( Entry->GetPartCount() > 1 )
|
2007-08-20 01:20:48 +00:00
|
|
|
flag = 1;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
wxString ref = Cmp->GetRef( GetSheet() );
|
2010-07-20 10:30:40 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "Reference" ), _( "Component reference" ), ref );
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return; // cancelled by user
|
|
|
|
|
|
|
|
ref = dlg.GetValue( );
|
2010-07-21 08:15:54 +00:00
|
|
|
ref.Trim( true );
|
|
|
|
ref.Trim( false );
|
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 );
|
2009-11-03 13:26:31 +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;
|
2010-04-27 19:19:04 +00:00
|
|
|
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2009-11-03 13:26:31 +00:00
|
|
|
Cmp->SetRef( GetSheet(), ref );
|
2010-04-27 19:19:04 +00:00
|
|
|
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-04-27 19:19:04 +00:00
|
|
|
|
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
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Routine to change the selected text */
|
2009-11-03 13:26:31 +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
|
|
|
{
|
2009-11-03 13:26:31 +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;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_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;
|
2010-07-20 10:30:40 +00:00
|
|
|
|
|
|
|
wxTextEntryDialog dlg( this, _( "Value" ), _( "Component value" ), message );
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return; // cancelled by user
|
|
|
|
|
|
|
|
message = dlg.GetValue( );
|
2010-07-21 08:15:54 +00:00
|
|
|
message.Trim( true );
|
|
|
|
message.Trim( false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
if( !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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
TextField->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2008-09-22 16:03:12 +00:00
|
|
|
TextField->m_Text = message;
|
2009-11-03 13:26:31 +00:00
|
|
|
TextField->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
2010-04-27 19:19:04 +00:00
|
|
|
OnModify();
|
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
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC )
|
2007-12-11 16:41:43 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
wxString message;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* Entry;
|
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;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
|
2010-05-29 18:34:18 +00:00
|
|
|
message = TextField->m_Text;
|
2007-12-11 16:41:43 +00:00
|
|
|
|
2010-07-20 10:30:40 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "Footprint" ), _( "Component footprint" ), message );
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return; // cancelled by user
|
|
|
|
|
|
|
|
message = dlg.GetValue( );
|
2010-07-21 08:15:54 +00:00
|
|
|
message.Trim( true );
|
|
|
|
message.Trim( false );
|
2010-05-23 17:39:47 +00:00
|
|
|
|
|
|
|
bool wasEmpty = false;
|
|
|
|
if( TextField->m_Text.IsEmpty() )
|
|
|
|
wasEmpty = true;
|
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 );
|
2010-04-27 19:19:04 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2010-05-23 17:39:47 +00:00
|
|
|
// Give a suitable position to the field if it was new,
|
|
|
|
// and therefore has no position already given.
|
2008-10-06 05:44:29 +00:00
|
|
|
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 +=
|
2009-11-03 13:26:31 +00:00
|
|
|
( Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x ) > 0 ?
|
|
|
|
( Cmp->GetField( REFERENCE )->m_Size.x ) :
|
|
|
|
( -1 * Cmp->GetField( REFERENCE )->m_Size.x );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
Cmp->GetField( FOOTPRINT )->m_Pos.y +=
|
2009-11-03 13:26:31 +00:00
|
|
|
( 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
|
|
|
|
2010-04-27 19:19:04 +00:00
|
|
|
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-05-23 17:39:47 +00:00
|
|
|
TextField->m_Text = message;
|
|
|
|
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
|
|
|
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
|
|
|
|
OnModify();
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Cmp->DisplayInfo( this );
|
2007-12-11 16:41:43 +00:00
|
|
|
}
|