2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
#include <wx/checklst.h>
|
|
|
|
#include <wx/tooltip.h>
|
2009-01-02 17:31:32 +00:00
|
|
|
#include <algorithm>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +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"
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "dialog_edit_component_in_schematic.h"
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
|
|
|
|
|
|
|
|
|
2009-01-29 17:30:38 +00:00
|
|
|
wxSize DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = wxDefaultSize;
|
2009-01-29 08:58:48 +00:00
|
|
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
/**********************************************************************/
|
|
|
|
void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
|
|
|
|
SCH_COMPONENT* aComponent )
|
|
|
|
/*********************************************************************/
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
if( aComponent == NULL ) // Null component not accepted
|
2008-11-27 18:42:19 +00:00
|
|
|
return;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
if( aComponent->Type() != TYPE_SCH_COMPONENT )
|
|
|
|
{
|
|
|
|
DisplayError( parent,
|
2008-12-04 20:53:11 +00:00
|
|
|
wxT( "InstallCmpeditFrame() error: This item is not a component" ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-29 08:58:48 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dialog =
|
2008-11-24 06:53:43 +00:00
|
|
|
new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent );
|
|
|
|
|
2009-01-29 08:58:48 +00:00
|
|
|
dialog->InitBuffers( aComponent );
|
|
|
|
|
2009-01-29 17:30:38 +00:00
|
|
|
wxSize sizeNow = dialog->GetSize();
|
|
|
|
|
|
|
|
// this relies on wxDefaultSize being -1,-1, be careful here.
|
|
|
|
if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth()
|
|
|
|
|| sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() )
|
2009-01-29 08:58:48 +00:00
|
|
|
{
|
2009-01-29 17:30:38 +00:00
|
|
|
dialog->SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize );
|
|
|
|
}
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2009-01-29 17:30:38 +00:00
|
|
|
// make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
|
|
|
|
EnsureTextCtrlWidth( dialog->chipnameTextCtrl );
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2009-01-29 17:30:38 +00:00
|
|
|
dialog->ShowModal();
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2009-01-29 17:30:38 +00:00
|
|
|
// Some of the field values are long and are not always fully visible
|
|
|
|
// because the window comes up too narrow.
|
|
|
|
// Remember user's manual window resizing efforts here so it comes up wide enough next time.
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = dialog->GetSize();
|
2009-01-29 08:58:48 +00:00
|
|
|
|
|
|
|
dialog->Destroy();
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
parent->DrawPanel->MouseToCursorSchema();
|
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ) :
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Parent = (WinEDA_SchematicFrame*) parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-04 20:53:11 +00:00
|
|
|
m_LibEntry = NULL;
|
2008-11-26 06:25:20 +00:00
|
|
|
m_skipCopyFromPanel = false;
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
wxListItem columnLabel;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetImage( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetText( _( "Name" ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldListCtrl->InsertColumn( 0, columnLabel );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
columnLabel.SetText( _( "Value" ) );
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldListCtrl->InsertColumn( 1, columnLabel );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
|
|
|
|
textSizeLabel->SetLabel( label );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
label = _( "Pos " );
|
2008-11-26 00:20:16 +00:00
|
|
|
label += _( "X" );
|
|
|
|
label += ReturnUnitSymbol( g_UnitMetric );
|
|
|
|
posXLabel->SetLabel( label );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
label = _( "Pos " );
|
2008-11-26 00:20:16 +00:00
|
|
|
label += _( "Y" );
|
|
|
|
label += ReturnUnitSymbol( g_UnitMetric );
|
|
|
|
posYLabel->SetLabel( label );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
copySelectedFieldToPanel();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
wxToolTip::Enable( true );
|
2009-03-20 10:02:40 +00:00
|
|
|
|
|
|
|
if( GetSizer() )
|
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::reinitializeFieldsIdAndDefaultNames( )
|
|
|
|
/*****************************************************************************/
|
|
|
|
{
|
|
|
|
for( unsigned new_id = FIELD1; new_id < m_FieldsBuf.size(); new_id++ )
|
|
|
|
{
|
|
|
|
unsigned old_id = m_FieldsBuf[new_id].m_FieldId;
|
|
|
|
if ( old_id != new_id )
|
|
|
|
{
|
|
|
|
if ( m_FieldsBuf[new_id].m_Name == ReturnDefaultFieldName( old_id ) )
|
|
|
|
m_FieldsBuf[new_id].m_Name = ReturnDefaultFieldName( new_id );
|
|
|
|
m_FieldsBuf[new_id].m_FieldId = new_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "OnListItemDeselected()\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
if( !m_skipCopyFromPanel )
|
|
|
|
{
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
event.Skip(); // do not go to the next row
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "OnListItemSelected()\n" ); )
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// remember the selected row, statically
|
|
|
|
s_SelectedRow = event.GetIndex();
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
copySelectedFieldToPanel();
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
wxString newname = chipnameTextCtrl->GetValue();
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
newname.MakeUpper();
|
|
|
|
newname.Replace( wxT( " " ), wxT( "_" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( newname.IsEmpty() )
|
|
|
|
DisplayError( this, _( "No Component Name!" ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
|
|
|
|
{
|
|
|
|
if( FindLibPart( newname.GetData(), wxEmptyString, FIND_ALIAS ) == NULL )
|
|
|
|
{
|
|
|
|
wxString message;
|
|
|
|
message.Printf( _( "Component [%s] not found!" ), newname.GetData() );
|
|
|
|
DisplayError( this, message );
|
|
|
|
}
|
2008-11-27 18:42:19 +00:00
|
|
|
else // Change component from lib!
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
m_Cmp->m_ChipName = newname;
|
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-01-02 17:31:32 +00:00
|
|
|
// For components with multiple shapes (De Morgan representation) Set the selected shape:
|
2008-11-26 00:20:16 +00:00
|
|
|
if( convertCheckBox->IsEnabled() )
|
|
|
|
{
|
|
|
|
m_Cmp->m_Convert = convertCheckBox->GetValue() ? 2 : 1;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
//Set the part selection in multiple part per pakcage
|
|
|
|
if( m_Cmp->m_Multi )
|
|
|
|
{
|
|
|
|
int unit_selection = unitChoice->GetCurrentSelection() + 1;
|
|
|
|
m_Cmp->SetUnitSelection( m_Parent->GetSheet(), unit_selection );
|
|
|
|
m_Cmp->m_Multi = unit_selection;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
switch( orientationRadioBox->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_ORIENT_0 );
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 1:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_ORIENT_90 );
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 2:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_ORIENT_180 );
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 3:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_ORIENT_270 );
|
|
|
|
break;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int mirror = mirrorRadioBox->GetSelection();
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
switch( mirror )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 1:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_MIROIR_X );
|
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
case 2:
|
|
|
|
m_Cmp->SetRotationMiroir( CMP_MIROIR_Y );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
copyPanelToOptions();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
/* save old cmp in undo list if not already in edit, or moving ... */
|
|
|
|
if( m_Cmp->m_Flags == 0 )
|
|
|
|
m_Parent->SaveCopyInUndoList( m_Cmp, IS_CHANGED );
|
|
|
|
|
|
|
|
// change all field positions from relative to absolute
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
m_FieldsBuf[i].m_Pos += m_Cmp->m_Pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete any fields with no name
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = FIELD1; i<m_FieldsBuf.size(); )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
|
|
|
if( m_FieldsBuf[i].m_Name.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_LibComponentStruct* entry = FindLibPart(
|
2008-12-31 09:27:19 +00:00
|
|
|
m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
if( entry && entry->m_Options == ENTRY_POWER )
|
|
|
|
m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName;
|
|
|
|
|
|
|
|
// copy all the fields back, and change the length of m_Fields.
|
|
|
|
m_Cmp->SetFields( m_FieldsBuf );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, NULL );
|
|
|
|
|
|
|
|
m_Parent->DrawPanel->Refresh( TRUE );
|
|
|
|
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
// in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
|
|
|
|
// screen contents.
|
2008-11-26 06:25:20 +00:00
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
unsigned fieldNdx = m_FieldsBuf.size();
|
2008-11-26 06:25:20 +00:00
|
|
|
|
|
|
|
SCH_CMP_FIELD blank( wxPoint(), fieldNdx, m_Cmp );
|
|
|
|
|
|
|
|
blank.m_Orient = m_FieldsBuf[REFERENCE].m_Orient;
|
|
|
|
|
|
|
|
m_FieldsBuf.push_back( blank );
|
2008-12-31 15:01:29 +00:00
|
|
|
m_FieldsBuf[fieldNdx].m_Name = ReturnDefaultFieldName(fieldNdx);
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
2008-11-26 06:25:20 +00:00
|
|
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
|
|
|
|
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( fieldNdx < FIELD1 )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
2008-11-26 06:25:20 +00:00
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
|
|
|
|
fieldListCtrl->DeleteItem( fieldNdx );
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() )
|
|
|
|
--fieldNdx;
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
// Reinitialize fields IDs and default names:
|
|
|
|
reinitializeFieldsIdAndDefaultNames();
|
|
|
|
updateDisplay( );
|
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC:: moveUpButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( fieldNdx <= FIELD1 )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// swap the fieldNdx field with the one before it, in both the vector
|
|
|
|
// and in the fieldListCtrl
|
2008-12-31 09:27:19 +00:00
|
|
|
SCH_CMP_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
|
|
|
|
CONV_TO_UTF8( tmp.m_Text ), CONV_TO_UTF8( tmp.m_Name ) ); )
|
2008-11-26 06:25:20 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
|
|
|
|
setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
|
2008-11-26 06:25:20 +00:00
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx] = tmp;
|
|
|
|
setRowItem( fieldNdx, tmp );
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
// Reinitialize fields IDs and default names:
|
|
|
|
reinitializeFieldsIdAndDefaultNames();
|
|
|
|
updateDisplay( );
|
|
|
|
|
2008-11-26 06:25:20 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
|
|
|
setSelectedFieldNdx( fieldNdx - 1 );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
|
|
|
|
{
|
|
|
|
/* deselect old selection, but I think this is done by single selection flag within fieldListCtrl
|
2008-12-31 09:27:19 +00:00
|
|
|
* fieldListCtrl->SetItemState( s_SelectedRow, 0, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
|
|
|
|
*/
|
2008-11-26 00:20:16 +00:00
|
|
|
|
|
|
|
if( aFieldNdx >= (int) m_FieldsBuf.size() )
|
|
|
|
aFieldNdx = m_FieldsBuf.size() - 1;
|
|
|
|
|
|
|
|
if( aFieldNdx < 0 )
|
|
|
|
aFieldNdx = 0;
|
|
|
|
|
|
|
|
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
|
|
fieldListCtrl->EnsureVisible( aFieldNdx );
|
|
|
|
|
|
|
|
s_SelectedRow = aFieldNdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
|
|
|
|
{
|
|
|
|
return s_SelectedRow;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
|
|
|
|
static bool SortFieldsById(const SCH_CMP_FIELD& item1, const SCH_CMP_FIELD& item2)
|
|
|
|
{
|
|
|
|
return item1.m_FieldId < item2.m_FieldId;
|
|
|
|
}
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
/*******************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
|
2008-11-24 21:06:50 +00:00
|
|
|
/*******************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Cmp = aComponent;
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
m_LibEntry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
|
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].m_Pos.x,
|
|
|
|
aComponent->m_Fields[i].m_Pos.y );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#endif
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
// copy all the fields to a work area
|
|
|
|
m_FieldsBuf = aComponent->m_Fields;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
// Sort files by field id,if they are not entered by id
|
|
|
|
sort(m_FieldsBuf.begin(), m_FieldsBuf.end(), SortFieldsById);
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
printf( "m_FieldsBuf[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
|
|
|
|
m_FieldsBuf[i].m_Pos.y );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#endif
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
m_FieldsBuf[REFERENCE].m_Text = m_Cmp->GetRef( m_Parent->GetSheet() );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
// make the editable field position relative to the component
|
2008-11-26 00:20:16 +00:00
|
|
|
m_FieldsBuf[i].m_Pos -= m_Cmp->m_Pos;
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
setRowItem( i, m_FieldsBuf[i] );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2008-12-31 09:27:19 +00:00
|
|
|
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
|
2008-11-26 00:20:16 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
|
|
|
|
m_FieldsBuf[i].m_Pos.y );
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
copyOptionsToPanel();
|
|
|
|
|
|
|
|
// put focus on the list ctrl
|
|
|
|
fieldListCtrl->SetFocus();
|
|
|
|
|
|
|
|
// resume editing at the last row edited, last time dialog was up.
|
|
|
|
setSelectedFieldNdx( s_SelectedRow );
|
2008-11-24 21:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField )
|
|
|
|
{
|
|
|
|
wxASSERT( aFieldNdx >= 0 );
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// insert blanks if aFieldNdx is referencing a "yet to be defined" row
|
2008-11-24 21:06:50 +00:00
|
|
|
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
wxASSERT( ndx >= 0 );
|
|
|
|
|
|
|
|
fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldListCtrl->SetItem( aFieldNdx, 0, aField.m_Name );
|
|
|
|
fieldListCtrl->SetItem( aFieldNdx, 1, aField.m_Text );
|
|
|
|
|
|
|
|
// recompute the column widths here, after setting texts
|
|
|
|
fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
|
|
|
fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
/****************************************************************/
|
2008-11-24 21:06:50 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
|
2008-11-24 06:53:43 +00:00
|
|
|
/****************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-24 21:06:50 +00:00
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
2008-11-24 06:53:43 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
showCheckBox->SetValue( !(field.m_Attributs & TEXT_NO_VISIBLE) );
|
|
|
|
|
|
|
|
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
int style = 0;
|
|
|
|
if( field.m_Italic )
|
|
|
|
style = 1;
|
|
|
|
if( field.m_Width > 1 )
|
|
|
|
style |= 2;
|
|
|
|
m_StyleRadioBox->SetSelection( style );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
fieldNameTextCtrl->SetValue( field.m_Name );
|
|
|
|
|
|
|
|
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing
|
2008-12-30 19:18:56 +00:00
|
|
|
fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 );
|
2008-11-26 00:20:16 +00:00
|
|
|
fieldNameTextCtrl->SetEditable( fieldNdx >= FIELD1 );
|
2009-01-02 17:31:32 +00:00
|
|
|
moveUpButton->Enable( fieldNdx >= FIELD1 ); // disable move up button for non moveable fields
|
|
|
|
// if fieldNdx == REFERENCE, VALUE, then disable delete button
|
|
|
|
deleteFieldButton->Enable( fieldNdx > VALUE );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
|
|
|
fieldValueTextCtrl->SetValue( field.m_Text );
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER )
|
2008-11-26 00:20:16 +00:00
|
|
|
fieldValueTextCtrl->Enable( FALSE );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
textSizeTextCtrl->SetValue(
|
2008-12-31 09:27:19 +00:00
|
|
|
WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, g_UnitMetric, field.m_Size.x ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
wxPoint coord = field.m_Pos;
|
|
|
|
wxPoint zero = -m_Cmp->m_Pos; // relative zero
|
|
|
|
|
|
|
|
// If the field value is empty and the position is at relative zero, we set the
|
2008-11-24 06:53:43 +00:00
|
|
|
// initial position as a small offset from the ref field, and orient
|
|
|
|
// it the same as the ref field. That is likely to put it at least
|
|
|
|
// close to the desired position.
|
2008-11-26 00:20:16 +00:00
|
|
|
if( coord == zero && field.m_Text.IsEmpty() )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].m_Orient == TEXT_ORIENT_VERT );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
coord.x = m_FieldsBuf[REFERENCE].m_Pos.x + (fieldNdx - FIELD1 + 1) * 100;
|
|
|
|
coord.y = m_FieldsBuf[REFERENCE].m_Pos.y + (fieldNdx - FIELD1 + 1) * 100;
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// coord can compute negative if field is < FIELD1, e.g. FOOTPRINT.
|
|
|
|
// That is ok, we basically don't want all the new empty fields on
|
|
|
|
// top of each other.
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
wxString coordText = ReturnStringFromValue( g_UnitMetric, coord.x, EESCHEMA_INTERNAL_UNIT );
|
|
|
|
posXTextCtrl->SetValue( coordText );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
coordText = ReturnStringFromValue( g_UnitMetric, coord.y, EESCHEMA_INTERNAL_UNIT );
|
|
|
|
posYTextCtrl->SetValue( coordText );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
/*****************************************************************/
|
2008-11-26 00:20:16 +00:00
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
|
2008-11-24 21:06:50 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return true;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( showCheckBox->GetValue() )
|
|
|
|
field.m_Attributs &= ~TEXT_NO_VISIBLE;
|
|
|
|
else
|
|
|
|
field.m_Attributs |= TEXT_NO_VISIBLE;
|
|
|
|
|
|
|
|
if( rotateCheckBox->GetValue() )
|
|
|
|
field.m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
else
|
|
|
|
field.m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
|
|
|
|
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
|
|
|
|
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2008-11-24 21:06:50 +00:00
|
|
|
field.m_Name = fieldNameTextCtrl->GetValue();
|
2009-01-02 17:31:32 +00:00
|
|
|
/* Void fields texts for REFERENCE and VALUE (value is the name of the compinent in lib ! ) are not allowed
|
|
|
|
* change them only for a new non void value
|
|
|
|
* When woid, usually netlists are broken
|
|
|
|
*/
|
|
|
|
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
|
|
|
|
field.m_Text = fieldValueTextCtrl->GetValue();
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
setRowItem( fieldNdx, field ); // update fieldListCtrl
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize(
|
|
|
|
textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UnitMetric );
|
2008-11-26 00:20:16 +00:00
|
|
|
field.m_Size.y = field.m_Size.x;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
int style = m_StyleRadioBox->GetSelection();
|
|
|
|
if( (style & 1 ) != 0 )
|
|
|
|
field.m_Italic = true;
|
|
|
|
else
|
|
|
|
field.m_Italic = false;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
if( (style & 2 ) != 0 )
|
|
|
|
field.m_Width = field.m_Size.x / 4;
|
|
|
|
else
|
|
|
|
field.m_Width = 0;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
double value;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
posXTextCtrl->GetValue().ToDouble( &value );
|
|
|
|
field.m_Pos.x = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
|
2008-11-24 21:06:50 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
posYTextCtrl->GetValue().ToDouble( &value );
|
|
|
|
field.m_Pos.y = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
int choiceCount = unitChoice->GetCount();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
// Remove non existing choices (choiceCount must be <= number for parts)
|
2008-12-04 20:53:11 +00:00
|
|
|
int unitcount = m_LibEntry ? m_LibEntry->m_UnitCount : 1;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
if( unitcount < 1 )
|
2008-11-27 18:42:19 +00:00
|
|
|
unitcount = 1;
|
2009-01-29 08:58:48 +00:00
|
|
|
|
2008-12-04 20:53:11 +00:00
|
|
|
if( unitcount < choiceCount )
|
2008-11-27 18:42:19 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
while( unitcount < choiceCount )
|
2008-11-27 18:42:19 +00:00
|
|
|
{
|
|
|
|
choiceCount--;
|
2008-12-31 09:27:19 +00:00
|
|
|
unitChoice->Delete( choiceCount );
|
2008-11-27 18:42:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// For components with multiple parts per package, set the unit selection
|
|
|
|
choiceCount = unitChoice->GetCount();
|
2008-11-26 00:20:16 +00:00
|
|
|
if( m_Cmp->m_Multi <= choiceCount )
|
|
|
|
unitChoice->SetSelection( m_Cmp->m_Multi - 1 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
// Disable unit selection if only one unit exists:
|
2008-12-31 09:27:19 +00:00
|
|
|
if( choiceCount <= 1 )
|
|
|
|
unitChoice->Enable( false );
|
2008-11-27 18:42:19 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int orientation = m_Cmp->GetRotationMiroir() & ~(CMP_MIROIR_X | CMP_MIROIR_Y);
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( orientation == CMP_ORIENT_90 )
|
|
|
|
orientationRadioBox->SetSelection( 1 );
|
|
|
|
else if( orientation == CMP_ORIENT_180 )
|
|
|
|
orientationRadioBox->SetSelection( 2 );
|
|
|
|
else if( orientation == CMP_ORIENT_270 )
|
|
|
|
orientationRadioBox->SetSelection( 3 );
|
2008-11-26 05:08:37 +00:00
|
|
|
else
|
|
|
|
orientationRadioBox->SetSelection( 0 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
int mirror = m_Cmp->GetRotationMiroir() & (CMP_MIROIR_X | CMP_MIROIR_Y);
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( mirror == CMP_MIROIR_X )
|
|
|
|
{
|
|
|
|
mirrorRadioBox->SetSelection( 1 );
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "mirror=X,1\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
|
|
|
else if( mirror == CMP_MIROIR_Y )
|
|
|
|
{
|
|
|
|
mirrorRadioBox->SetSelection( 2 );
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "mirror=Y,2\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
}
|
2008-11-26 05:08:37 +00:00
|
|
|
else
|
|
|
|
mirrorRadioBox->SetSelection( 0 );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
// Activate/Desactivate the normal/convert option ? (activated only if the component has more than one shape)
|
2008-11-24 06:53:43 +00:00
|
|
|
if( m_Cmp->m_Convert > 1 )
|
2008-11-27 18:42:19 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
convertCheckBox->SetValue( true );
|
2008-11-27 18:42:19 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( m_LibEntry == NULL || LookForConvertPart( m_LibEntry ) <= 1 )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
convertCheckBox->Enable( false );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
// Show the "Parts Locked" option?
|
2008-11-24 06:53:43 +00:00
|
|
|
if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked )
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
D( printf( "partsAreLocked->false\n" ); )
|
2008-11-26 00:20:16 +00:00
|
|
|
partsAreLockedLabel->Show( false );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Positionnement de la reference en librairie
|
2008-11-26 00:20:16 +00:00
|
|
|
chipnameTextCtrl->SetValue( m_Cmp->m_ChipName );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
|
|
|
|
/*****************************************************************************/
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
/* reinitialise components parametres to default values found in lib
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2008-11-26 00:20:16 +00:00
|
|
|
EDA_LibComponentStruct* entry;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( m_Cmp == NULL )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
entry = FindLibPart( m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
if( entry == NULL )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
wxClientDC dc( m_Parent->DrawPanel );
|
2008-11-24 06:53:43 +00:00
|
|
|
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
|
|
|
|
|
2008-11-27 18:42:19 +00:00
|
|
|
/* Initialise fields values to default values found in library: */
|
2008-12-31 09:27:19 +00:00
|
|
|
m_Cmp->GetField( REFERENCE )->m_Pos = entry->m_Prefix.m_Pos + m_Cmp->m_Pos;
|
2008-12-31 15:01:29 +00:00
|
|
|
m_Cmp->GetField( REFERENCE )->ImportValues( entry->m_Prefix );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
m_Cmp->GetField( VALUE )->m_Pos = entry->m_Name.m_Pos + m_Cmp->m_Pos;
|
2008-12-31 15:01:29 +00:00
|
|
|
m_Cmp->GetField( VALUE )->ImportValues( entry->m_Name );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-26 00:20:16 +00:00
|
|
|
m_Cmp->SetRotationMiroir( CMP_NORMAL );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
|
2008-11-26 00:20:16 +00:00
|
|
|
EndModal( 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|