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-10-10 17:27:53 +00:00
|
|
|
#include "class_drawpanel.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 "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "libeditfrm.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
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();
|
2009-10-10 17:27:53 +00:00
|
|
|
DrawPanel->Refresh();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WinEDA_LibeditFrame::EditComponentProperties()
|
|
|
|
{
|
|
|
|
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();
|
2009-09-22 12:27:57 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
GetScreen()->SetModify();
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
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;
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
|
|
|
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
if( component == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_Parent->GetAliasName().IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
entry = component;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
entry =
|
|
|
|
( CMP_LIB_ENTRY* ) library->FindAlias( m_Parent->GetAliasName() );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
if( entry == NULL )
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
m_Doc->SetValue( entry->GetDescription() );
|
|
|
|
m_Keywords->SetValue( entry->GetKeyWords() );
|
|
|
|
m_Docfile->SetValue( entry->GetDocFileName() );
|
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
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_Parent->GetShowDeMorgan() )
|
2009-09-22 12:27:57 +00:00
|
|
|
m_AsConvertButt->SetValue( true );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
/* Default values for a new component. */
|
|
|
|
if( component == NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
m_ShowPinNumButt->SetValue( true );
|
|
|
|
m_ShowPinNameButt->SetValue( true );
|
|
|
|
m_PinsNameInsideButt->SetValue( true );
|
|
|
|
m_SelNumberOfUnits->SetValue( 1 );
|
|
|
|
m_SetSkew->SetValue( 40 );
|
|
|
|
m_OptionPower->SetValue( false );
|
|
|
|
m_OptionPartsLocked->SetValue( false );
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
m_ShowPinNumButt->SetValue( component->m_DrawPinNum );
|
|
|
|
m_ShowPinNameButt->SetValue( component->m_DrawPinName );
|
|
|
|
m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 );
|
2009-10-05 17:52:41 +00:00
|
|
|
m_SelNumberOfUnits->SetValue( component->GetPartCount() );
|
2009-09-22 12:27:57 +00:00
|
|
|
m_SetSkew->SetValue( component->m_TextInside );
|
2009-12-15 21:11:05 +00:00
|
|
|
m_OptionPower->SetValue( component->isPower() );
|
2009-09-22 12:27:57 +00:00
|
|
|
m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked );
|
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-10-10 17:27:53 +00:00
|
|
|
CMP_LIB_ENTRY* entry = NULL;
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2009-10-10 17:27:53 +00:00
|
|
|
if( component == NULL )
|
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_Parent->GetAliasName().IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
entry = (CMP_LIB_ENTRY*) component;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2009-10-10 17:27:53 +00:00
|
|
|
else if ( library )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
entry = library->FindEntry( m_Parent->GetAliasName() );
|
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;
|
2009-09-22 12:27:57 +00:00
|
|
|
msg.Printf( _( "Alias <%s> not found for component <%s> in library \
|
|
|
|
<%s>." ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( m_Parent->GetAliasName() ),
|
|
|
|
GetChars( component->GetName() ),
|
|
|
|
GetChars( library->GetName() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
wxMessageBox( msg, _( "Component Library Error" ),
|
|
|
|
wxID_OK | wxICON_ERROR, this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
entry->SetDescription( m_Doc->GetValue() );
|
|
|
|
entry->SetKeyWords( m_Keywords->GetValue() );
|
|
|
|
entry->SetDocFileName( m_Docfile->GetValue() );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
if( m_PartAliasList->GetStrings() != component->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-22 12:27:57 +00:00
|
|
|
index = component->m_AliasList.Index( aliases[ i ], false );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
|
|
|
continue;
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
alias = new LIB_ALIAS( aliases[ i ], component );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( !library->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. */
|
2009-09-30 09:01:16 +00:00
|
|
|
for( i = 0; i < component->m_AliasList.GetCount(); i++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
index = aliases.Index( component->m_AliasList[ i ], false );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
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-25 18:49:04 +00:00
|
|
|
library->FindAlias( component->m_AliasList[ i ] );
|
2009-09-14 13:24:17 +00:00
|
|
|
if( alias != NULL )
|
2009-09-25 18:49:04 +00:00
|
|
|
library->RemoveEntry( alias );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
component->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
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( !m_Parent->GetShowDeMorgan() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
m_Parent->SetShowDeMorgan( true );
|
2009-09-14 13:24:17 +00:00
|
|
|
SetUnsetConvert();
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_Parent->GetShowDeMorgan() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
m_Parent->SetShowDeMorgan( false );
|
2009-09-14 13:24:17 +00:00
|
|
|
SetUnsetConvert();
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
component->m_DrawPinNum = m_ShowPinNumButt->GetValue() ? 1 : 0;
|
|
|
|
component->m_DrawPinName = m_ShowPinNameButt->GetValue() ? 1 : 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
if( m_PinsNameInsideButt->GetValue() == false )
|
|
|
|
component->m_TextInside = 0; // pin text outside the body (name is on the pin)
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
2009-09-22 12:27:57 +00:00
|
|
|
component->m_TextInside = m_SetSkew->GetValue();
|
2009-10-10 17:27:53 +00:00
|
|
|
// Ensure component->m_TextInside != 0, because the meaning is "text outside".
|
|
|
|
if( component->m_TextInside == 0 )
|
|
|
|
component->m_TextInside = 20; // give a reasonnable value
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
if( m_OptionPower->GetValue() == true )
|
2009-12-15 21:11:05 +00:00
|
|
|
component->SetPower();
|
2007-09-20 21:06:49 +00:00
|
|
|
else
|
2009-12-15 21:11:05 +00:00
|
|
|
component->SetNormal();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
/* Set the option "Units locked".
|
2009-10-10 17:27:53 +00:00
|
|
|
* Obviously, cannot be true if there is only one part */
|
2009-09-22 12:27:57 +00:00
|
|
|
component->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue();
|
2009-10-05 17:52:41 +00:00
|
|
|
if( component->GetPartCount() <= 1 )
|
2009-10-10 17:27:53 +00:00
|
|
|
component->m_UnitSelectionLocked = false;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
/* Update the footprint filter list */
|
2009-09-22 12:27:57 +00:00
|
|
|
component->m_FootprintList.Clear();
|
|
|
|
component->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-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( component == NULL || m_Parent->GetAliasName().IsEmpty() )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
m_Doc->SetValue( component->GetDescription() );
|
|
|
|
m_Docfile->SetValue( component->GetDocFileName() );
|
|
|
|
m_Keywords->SetValue( component->GetKeyWords() );
|
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-25 18:49:04 +00:00
|
|
|
if( m_PartAliasList->FindString( m_Parent->GetAliasName() )
|
|
|
|
!= wxNOT_FOUND )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Alias <%s> cannot be removed while it is being \
|
|
|
|
edited!" ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( m_Parent->GetAliasName() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_Parent->GetAliasName().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();
|
2009-10-10 17:27:53 +00:00
|
|
|
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;
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
|
|
|
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
if( component == NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-25 18:49:04 +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
|
2009-09-25 18:49:04 +00:00
|
|
|
|| library->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>." ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( aliasname ),
|
|
|
|
GetChars( library->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 );
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_Parent->GetAliasName().IsEmpty() )
|
2009-10-10 17:27:53 +00:00
|
|
|
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-25 18:49:04 +00:00
|
|
|
if( aliasname.CmpNoCase( m_Parent->GetAliasName() ) == 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!" ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( 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
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
m_ButtonDeleteAllAlias->Enable( false );
|
|
|
|
m_ButtonDeleteOneAlias->Enable( false );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/*
|
|
|
|
* Change the number of parts per package.
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-10-05 17:52:41 +00:00
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( component == NULL || component->GetPartCount() == MaxUnit
|
|
|
|
|| MaxUnit < 1 )
|
|
|
|
return false;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( MaxUnit < component->GetPartCount()
|
|
|
|
&& !IsOK( this, _( "Delete extra parts from component?" ) ) )
|
|
|
|
return false;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
component->SetPartCount( MaxUnit );
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/*
|
|
|
|
* Set or clear the component alternate body style ( DeMorgan ).
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-10-05 17:52:41 +00:00
|
|
|
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( component == NULL
|
|
|
|
|| ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) )
|
|
|
|
return false;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
if( m_Parent->GetShowDeMorgan() )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
if( !IsOK( this, _( "Add new pins for alternate body style \
|
|
|
|
( DeMorgan ) to component?" ) ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
return false;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
else if( component->HasConversion() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from component?" ) ) )
|
|
|
|
{
|
|
|
|
m_Parent->SetShowDeMorgan( true );
|
|
|
|
return false;
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
component->SetConversion( m_Parent->GetShowDeMorgan() );
|
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
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,
|
2009-10-10 17:27:53 +00:00
|
|
|
true
|
2007-09-20 21:06:49 +00:00
|
|
|
);
|
|
|
|
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);
|
2009-10-23 15:28:45 +00:00
|
|
|
// Filenames are always stored in unix like mode, ie separator "\" is stored as "/"
|
|
|
|
// to ensure files are identical under unices and windows
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
filename.Replace(wxT("\\"), wxT("/") );
|
|
|
|
#endif
|
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();
|
2009-10-10 17:27:53 +00:00
|
|
|
m_ButtonDeleteAllFootprintFilter->Enable( false );
|
|
|
|
m_ButtonDeleteOneFootprintFilter->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::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;
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
if( component == NULL )
|
2007-09-20 21:06:49 +00:00
|
|
|
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." ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( Line ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_FootprintFilterListBox->Append( Line );
|
2009-10-10 17:27:53 +00:00
|
|
|
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
|
|
|
/********************************************************/
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_COMPONENT* component = m_Parent->GetComponent();
|
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
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
if( !component || (m_FootprintFilterListBox->GetCount() == 0) )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
m_ButtonDeleteAllFootprintFilter->Enable( false );
|
|
|
|
m_ButtonDeleteOneFootprintFilter->Enable( false );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|