2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************/
|
2009-09-04 18:57:37 +00:00
|
|
|
|
/* librairy editor: edition of component general properties */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-04-12 14:39:54 +00:00
|
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "confirm.h"
|
|
|
|
|
#include "gestfich.h"
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int CurrentUnit;
|
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
|
/* Dialog box to edit a libentry (a component in library) properties */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
|
/* Creates a NoteBook dialog
|
|
|
|
|
* Edition:
|
|
|
|
|
* Doc and keys words
|
|
|
|
|
* Parts per package
|
|
|
|
|
* General properties
|
2009-08-18 11:07:21 +00:00
|
|
|
|
* Fields are NOT edited here. There is a specific dialog box to do that
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
#include "dialog_edit_component_in_lib.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
EditComponentProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::EditComponentProperties()
|
|
|
|
|
{
|
|
|
|
|
wxASSERT( CurrentLibEntry != NULL && CurrentLib != NULL );
|
|
|
|
|
|
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
UpdateAliasSelectList();
|
|
|
|
|
UpdatePartSelectList();
|
|
|
|
|
DisplayLibInfos();
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
SaveCopyInUndoList( CurrentLibEntry );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
CMP_LIB_ENTRY* entry;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( CurrentAliasName.IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
entry = CurrentLibEntry;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
entry = ( CMP_LIB_ENTRY* ) CurrentLib->FindAlias( CurrentAliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
if( entry == NULL )
|
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_Doc->SetValue( entry->m_Doc );
|
|
|
|
|
m_Keywords->SetValue( entry->m_KeyWord );
|
|
|
|
|
m_Docfile->SetValue( entry->m_DocFile );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/*
|
|
|
|
|
* create the basic panel for component properties editing
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2009-09-14 13:24:17 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( g_AsDeMorgan )
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_AsConvertButt->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
{
|
|
|
|
|
if( CurrentLibEntry->m_DrawPinNum )
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_ShowPinNumButt->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_ShowPinNumButt->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
{
|
|
|
|
|
if( CurrentLibEntry->m_DrawPinName )
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_ShowPinNameButt->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_ShowPinNameButt->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
{
|
|
|
|
|
if( CurrentLibEntry->m_TextInside )
|
|
|
|
|
m_PinsNameInsideButt->SetValue( TRUE );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_PinsNameInsideButt->SetValue( TRUE );
|
|
|
|
|
|
|
|
|
|
int number, number_of_units;
|
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
number_of_units = CurrentLibEntry->m_UnitCount;
|
|
|
|
|
else
|
|
|
|
|
number_of_units = 1;
|
2009-08-18 11:07:21 +00:00
|
|
|
|
m_SelNumberOfUnits->SetValue( number_of_units );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry && CurrentLibEntry->m_TextInside )
|
|
|
|
|
number = CurrentLibEntry->m_TextInside;
|
|
|
|
|
else
|
|
|
|
|
number = 40;
|
|
|
|
|
m_SetSkew->SetValue( number );
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( CurrentLibEntry && CurrentLibEntry->m_Options == ENTRY_POWER )
|
|
|
|
|
m_OptionPower->SetValue( TRUE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( CurrentLibEntry && CurrentLibEntry->m_UnitSelectionLocked )
|
|
|
|
|
m_OptionPartsLocked->SetValue( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
/* Update the doc, keyword and doc filename strings */
|
2009-09-14 13:24:17 +00:00
|
|
|
|
size_t i;
|
|
|
|
|
int index;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
CMP_LIB_ENTRY* entry;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
if( CurrentAliasName.IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
entry = CurrentLibEntry;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
entry = CurrentLib->FindEntry( CurrentAliasName );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( entry == NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
msg.Printf( _( "Alias <%s> not found for component <%s> in library <%s>." ),
|
|
|
|
|
(const wxChar*) CurrentAliasName,
|
|
|
|
|
(const wxChar*) CurrentLibEntry->GetName(),
|
2009-09-18 14:56:05 +00:00
|
|
|
|
(const wxChar*) CurrentLib->GetName() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxMessageBox( msg, _( "Component Library Error" ),
|
|
|
|
|
wxID_OK | wxICON_ERROR, this );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entry->m_Doc = m_Doc->GetValue();
|
|
|
|
|
entry->m_KeyWord = m_Keywords->GetValue();
|
|
|
|
|
entry->m_DocFile = m_Docfile->GetValue();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( m_PartAliasList->GetStrings() != CurrentLibEntry->m_AliasList )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
|
LIB_ALIAS* alias;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxArrayString aliases = m_PartAliasList->GetStrings();
|
|
|
|
|
|
|
|
|
|
/* Add names not existing in the old alias list. */
|
|
|
|
|
for( i = 0; i < aliases.GetCount(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
index = CurrentLibEntry->m_AliasList.Index( aliases[ i ], false );
|
|
|
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
|
|
|
|
continue;
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
alias = new LIB_ALIAS( aliases[ i ], CurrentLibEntry );
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( !CurrentLib->AddAlias( alias ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
delete alias;
|
|
|
|
|
alias = NULL;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
/* Remove names and library alias entries not in the new alias list. */
|
|
|
|
|
for( i = 0; CurrentLibEntry->m_AliasList.GetCount(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
index = aliases.Index( CurrentLibEntry->m_AliasList[ i ], false );
|
|
|
|
|
|
|
|
|
|
if( index == wxNOT_FOUND )
|
|
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
CMP_LIB_ENTRY* alias =
|
2009-09-14 13:24:17 +00:00
|
|
|
|
CurrentLib->FindAlias( CurrentLibEntry->m_AliasList[ i ] );
|
|
|
|
|
if( alias != NULL )
|
|
|
|
|
CurrentLib->RemoveEntry( alias );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
CurrentLibEntry->m_AliasList = aliases;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
index = m_SelNumberOfUnits->GetValue();
|
|
|
|
|
ChangeNbUnitsPerPackage( index );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
if( m_AsConvertButt->GetValue() )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
if( !g_AsDeMorgan )
|
|
|
|
|
{
|
|
|
|
|
g_AsDeMorgan = 1;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
SetUnsetConvert();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( g_AsDeMorgan )
|
|
|
|
|
{
|
|
|
|
|
g_AsDeMorgan = 0;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
SetUnsetConvert();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
CurrentLibEntry->m_DrawPinNum = m_ShowPinNumButt->GetValue() ? 1 : 0;
|
|
|
|
|
CurrentLibEntry->m_DrawPinName = m_ShowPinNameButt->GetValue() ? 1 : 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
if( m_PinsNameInsideButt->GetValue() == FALSE )
|
|
|
|
|
CurrentLibEntry->m_TextInside = 0;
|
|
|
|
|
else
|
|
|
|
|
CurrentLibEntry->m_TextInside = m_SetSkew->GetValue();
|
|
|
|
|
|
|
|
|
|
if( m_OptionPower->GetValue() == TRUE )
|
|
|
|
|
CurrentLibEntry->m_Options = ENTRY_POWER;
|
|
|
|
|
else
|
|
|
|
|
CurrentLibEntry->m_Options = ENTRY_NORMAL;
|
|
|
|
|
|
|
|
|
|
/* Set the option "Units locked".
|
|
|
|
|
* Obviously, cannot be TRUE if there is only one part */
|
|
|
|
|
CurrentLibEntry->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue();
|
|
|
|
|
if( CurrentLibEntry->m_UnitCount <= 1 )
|
|
|
|
|
CurrentLibEntry->m_UnitSelectionLocked = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Update the footprint filter list */
|
|
|
|
|
CurrentLibEntry->m_FootprintList.Clear();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
CurrentLibEntry->m_FootprintList = m_FootprintFilterListBox->GetStrings();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
EndModal( wxID_OK );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( CurrentLibEntry == NULL || CurrentAliasName.IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_Doc->SetValue( CurrentLibEntry->m_Doc );
|
|
|
|
|
m_Docfile->SetValue( CurrentLibEntry->m_DocFile );
|
|
|
|
|
m_Keywords->SetValue( CurrentLibEntry->m_KeyWord );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart(
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( m_PartAliasList->FindString( CurrentAliasName ) != wxNOT_FOUND )
|
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
|
|
|
|
msg.Printf( _( "Alias <%s> cannot be removed while it is being \
|
|
|
|
|
edited!" ),
|
|
|
|
|
(const wxChar*) CurrentAliasName );
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
CurrentAliasName.Empty();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
|
|
if( IsOK( this, _( "Remove all aliases from list?" ) ) )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_PartAliasList->Clear();
|
|
|
|
|
m_ButtonDeleteAllAlias->Enable( FALSE );
|
|
|
|
|
m_ButtonDeleteOneAlias->Enable( FALSE );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*******************************************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*******************************************************************************/
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Add a new name to the alias list box
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* New name cannot be the root name, and must not exists
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxString Line;
|
|
|
|
|
wxString aliasname;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
|
if( Get_Message( _( "New alias:" ), _( "Component Alias" ), Line, this ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
aliasname = Line;
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( m_PartAliasList->FindString( aliasname ) != wxNOT_FOUND
|
|
|
|
|
|| CurrentLib->FindEntry( aliasname ) != NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
msg.Printf( _( "Alias or component name <%s> already exists in \
|
|
|
|
|
library <%s>." ),
|
|
|
|
|
(const wxChar*) aliasname,
|
2009-09-18 14:56:05 +00:00
|
|
|
|
(const wxChar*) CurrentLib->GetName() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_PartAliasList->Append( aliasname );
|
|
|
|
|
if( CurrentAliasName.IsEmpty() )
|
|
|
|
|
m_ButtonDeleteAllAlias->Enable( TRUE );
|
|
|
|
|
m_ButtonDeleteOneAlias->Enable( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart(
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxString aliasname = m_PartAliasList->GetStringSelection();
|
|
|
|
|
|
|
|
|
|
if( aliasname.IsEmpty() )
|
|
|
|
|
return;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( aliasname.CmpNoCase( CurrentAliasName ) == 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
msg.Printf( _( "Alias <%s> cannot be removed while it is being \
|
|
|
|
|
edited!" ),
|
|
|
|
|
(const wxChar*) aliasname );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
m_PartAliasList->Delete( m_PartAliasList->GetSelection() );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( m_PartAliasList->IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
|
|
|
|
m_ButtonDeleteAllAlias->Enable( FALSE );
|
|
|
|
|
m_ButtonDeleteOneAlias->Enable( FALSE );
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************************************/
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine de modification du nombre d'unites par package pour le
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* composant courant;
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int OldNumUnits, ii, FlagDel = -1;
|
|
|
|
|
LibEDA_BaseStruct* DrawItem, * NextDrawItem;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Si pas de changement: termine */
|
|
|
|
|
if( CurrentLibEntry->m_UnitCount == MaxUnit )
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
OldNumUnits = CurrentLibEntry->m_UnitCount;
|
|
|
|
|
if( OldNumUnits < 1 )
|
|
|
|
|
OldNumUnits = 1;
|
|
|
|
|
|
|
|
|
|
CurrentLibEntry->m_UnitCount = MaxUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Traitement des unites enlevees ou rajoutees */
|
|
|
|
|
if( OldNumUnits > CurrentLibEntry->m_UnitCount )
|
|
|
|
|
{
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
|
|
|
|
|
{
|
|
|
|
|
NextDrawItem = DrawItem->Next();
|
|
|
|
|
if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */
|
|
|
|
|
{
|
|
|
|
|
if( FlagDel < 0 )
|
|
|
|
|
{
|
|
|
|
|
if( IsOK( this, _( "Delete units" ) ) )
|
|
|
|
|
{
|
|
|
|
|
/* Si part selectee n'existe plus: selection 1ere unit */
|
|
|
|
|
if( CurrentUnit > MaxUnit )
|
|
|
|
|
CurrentUnit = 1;
|
|
|
|
|
FlagDel = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlagDel = 0;
|
|
|
|
|
MaxUnit = OldNumUnits;
|
|
|
|
|
CurrentLibEntry->m_UnitCount = MaxUnit;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
|
|
CurrentLibEntry->RemoveDrawItem( DrawItem );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( OldNumUnits < CurrentLibEntry->m_UnitCount )
|
|
|
|
|
{
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
|
|
|
|
{
|
|
|
|
|
/* Duplication des items pour autres elements */
|
|
|
|
|
if( DrawItem->m_Unit == 1 )
|
|
|
|
|
{
|
|
|
|
|
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
|
|
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
|
NextDrawItem = DrawItem->GenCopy();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = NextDrawItem;
|
|
|
|
|
NextDrawItem->m_Unit = ii;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************/
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
/* cr<63>e ou efface (selon option AsConvert) les <20>l<EFBFBD>ments
|
|
|
|
|
* de la repr<EFBFBD>sentation convertie d'un composant
|
2007-09-20 21:06:49 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int FlagDel = 0;
|
|
|
|
|
LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem;
|
|
|
|
|
|
|
|
|
|
if( g_AsDeMorgan ) /* Representation convertie a creer */
|
|
|
|
|
{
|
|
|
|
|
/* Traitement des elements a ajouter ( pins seulement ) */
|
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
|
|
|
|
{
|
|
|
|
|
/* Duplication des items pour autres elements */
|
|
|
|
|
if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
|
|
|
|
|
continue;
|
|
|
|
|
if( DrawItem->m_Convert == 1 )
|
|
|
|
|
{
|
|
|
|
|
if( FlagDel == 0 )
|
|
|
|
|
{
|
|
|
|
|
if( IsOK( this, _( "Create pins for Convert items" ) ) )
|
|
|
|
|
FlagDel = 1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( IsOK( this, _( "Part as \"De Morgan\" anymore" ) ) )
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
g_AsDeMorgan = 0; return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-02 18:12:45 +00:00
|
|
|
|
NextDrawItem = DrawItem->GenCopy();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NextDrawItem->SetNext( CurrentLibEntry->m_Drawings );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
CurrentLibEntry->m_Drawings = NextDrawItem;
|
2009-04-12 14:39:54 +00:00
|
|
|
|
NextDrawItem->m_Convert = 2;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else /* Representation convertie a supprimer */
|
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
/* Traitement des elements <20> supprimer */
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
|
DrawItem = CurrentLibEntry->m_Drawings;
|
|
|
|
|
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
|
|
|
|
|
{
|
|
|
|
|
NextDrawItem = DrawItem->Next();
|
|
|
|
|
if( DrawItem->m_Convert > 1 ) /* Item a effacer */
|
|
|
|
|
{
|
|
|
|
|
if( FlagDel == 0 )
|
|
|
|
|
{
|
|
|
|
|
if( IsOK( this, _( "Delete Convert items" ) ) )
|
|
|
|
|
{
|
|
|
|
|
CurrentConvert = 1;
|
|
|
|
|
FlagDel = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_AsDeMorgan = 1;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
2009-09-04 18:57:37 +00:00
|
|
|
|
CurrentLibEntry->RemoveDrawItem( DrawItem );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************************/
|
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxString FullFileName, mask;
|
2009-04-14 16:45:22 +00:00
|
|
|
|
wxString docpath, filename;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
|
docpath = wxGetApp().ReturnLastVisitedLibraryPath(wxT( "doc" ));
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
|
mask = wxT( "*" );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
FullFileName = EDA_FileSelector( _( "Doc Files" ),
|
|
|
|
|
docpath, /* Chemin par defaut */
|
|
|
|
|
wxEmptyString, /* nom fichier par defaut */
|
|
|
|
|
wxEmptyString, /* extension par defaut */
|
|
|
|
|
mask, /* Masque d'affichage */
|
|
|
|
|
this,
|
|
|
|
|
wxFD_OPEN,
|
|
|
|
|
TRUE
|
|
|
|
|
);
|
|
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-04-19 15:03:48 +00:00
|
|
|
|
/* If the path is already in the library search paths
|
2009-04-12 14:39:54 +00:00
|
|
|
|
* list, just add the library name to the list. Otherwise, add
|
|
|
|
|
* the library name with the full or relative path.
|
|
|
|
|
* the relative path, when possible is preferable,
|
|
|
|
|
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
|
|
|
|
|
*/
|
|
|
|
|
wxFileName fn = FullFileName;
|
2009-04-14 16:45:22 +00:00
|
|
|
|
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
|
2009-04-15 15:53:21 +00:00
|
|
|
|
|
|
|
|
|
filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath(FullFileName);
|
2007-09-20 21:06:49 +00:00
|
|
|
|
m_Docfile->SetValue( filename );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter(
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( IsOK( this, _( "Ok to Delete FootprintFilter LIST" ) ) )
|
|
|
|
|
{
|
|
|
|
|
m_FootprintFilterListBox->Clear();
|
|
|
|
|
m_ButtonDeleteAllFootprintFilter->Enable( FALSE );
|
|
|
|
|
m_ButtonDeleteOneFootprintFilter->Enable( FALSE );
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*******************************************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*******************************************************************************/
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Add a new name to the alias list box
|
2007-09-20 21:06:49 +00:00
|
|
|
|
* New name cannot be the root name, and must not exists
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxString Line;
|
|
|
|
|
|
|
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
if( Get_Message( _( "Add Footprint Filter" ), _( "Footprint Filter" ),
|
|
|
|
|
Line, this ) != 0 )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Line.Replace( wxT( " " ), wxT( "_" ) );
|
|
|
|
|
|
|
|
|
|
/* test for an existing name: */
|
2009-09-14 13:24:17 +00:00
|
|
|
|
int index = m_FootprintFilterListBox->FindString( Line );
|
|
|
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
2007-09-20 21:06:49 +00:00
|
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
|
|
msg.Printf( _( "Foot print filter <%s> is already defined." ),
|
|
|
|
|
(const wxChar*) Line );
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_FootprintFilterListBox->Append( Line );
|
|
|
|
|
m_ButtonDeleteAllFootprintFilter->Enable( TRUE );
|
|
|
|
|
m_ButtonDeleteOneFootprintFilter->Enable( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************************/
|
2009-08-18 11:07:21 +00:00
|
|
|
|
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter(
|
2007-09-20 21:06:49 +00:00
|
|
|
|
wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/********************************************************/
|
|
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
|
int ii = m_FootprintFilterListBox->GetSelection();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
m_FootprintFilterListBox->Delete( ii );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
if( !CurrentLibEntry || (m_FootprintFilterListBox->GetCount() == 0) )
|
|
|
|
|
{
|
|
|
|
|
m_ButtonDeleteAllFootprintFilter->Enable( FALSE );
|
|
|
|
|
m_ButtonDeleteOneFootprintFilter->Enable( FALSE );
|
|
|
|
|
}
|
|
|
|
|
}
|