Commit 539f041b authored by charras's avatar charras

pcbnew: fixed bug in modedit: delete module in library not working

parent cffe0cfc
...@@ -30,8 +30,6 @@ static int s_DefaultShapeGLabel = (int) NET_INPUT; ...@@ -30,8 +30,6 @@ static int s_DefaultShapeGLabel = (int) NET_INPUT;
static int s_DefaultOrientGLabel = 0; static int s_DefaultOrientGLabel = 0;
/****************************************************************************/ /****************************************************************************/
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
/****************************************************************************/ /****************************************************************************/
...@@ -57,12 +55,12 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -57,12 +55,12 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
m_CurrentText->m_Shape = m_TextShape->GetSelection(); m_CurrentText->m_Shape = m_TextShape->GetSelection();
int style = m_TextStyle->GetSelection(); int style = m_TextStyle->GetSelection();
if ( ( style & 1 ) ) if( ( style & 1 ) )
m_CurrentText->m_Italic = 1; m_CurrentText->m_Italic = 1;
else else
m_CurrentText->m_Italic = 0; m_CurrentText->m_Italic = 0;
if ( ( style & 2 ) ) if( ( style & 2 ) )
{ {
m_CurrentText->m_Bold = true; m_CurrentText->m_Bold = true;
m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x ); m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x );
...@@ -172,6 +170,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -172,6 +170,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/* Rotation du texte */ /* Rotation du texte */
int orient; int orient;
switch( TextStruct->Type() ) switch( TextStruct->Type() )
{ {
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
...@@ -380,12 +379,18 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -380,12 +379,18 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
return; return;
} }
/* copy the old text settings */ /* copy the old text settings
* Justifications are not copied because they are not used in labels,
* and can be used in texts
* So they will be set to default in conversion.
*/
newtext->m_Shape = Text->m_Shape; newtext->m_Shape = Text->m_Shape;
newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() ); newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
newtext->m_Size = Text->m_Size; newtext->m_Size = Text->m_Size;
newtext->m_Width = Text->m_Width; newtext->m_Width = Text->m_Width;
newtext->m_IsDangling = Text->m_IsDangling; newtext->m_Italic = Text->m_Italic;
newtext->m_Bold = Text->m_Bold;
// save current text flag: // save current text flag:
int flags = Text->m_Flags; int flags = Text->m_Flags;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* $EndLIBRARY * $EndLIBRARY
*/ */
#define OLD_EXT wxT( "bak" ) #define BACKUP_EXT wxT( "bak" )
#define FILETMP_EXT wxT( "$$$" ) #define FILETMP_EXT wxT( "$$$" )
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" ) #define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
...@@ -359,12 +359,12 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const ...@@ -359,12 +359,12 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
/* Le fichier ancienne librairie est renommee en .bak */ /* Le fichier ancienne librairie est renommee en .bak */
wxFileName backupFileName = oldFileName; wxFileName backupFileName = oldFileName;
backupFileName.SetExt( OLD_EXT ); backupFileName.SetExt( BACKUP_EXT );
if( backupFileName.FileExists() ) if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() ); wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( newFileName.GetFullPath(), if( !wxRenameFile( oldFileName.GetFullPath(),
backupFileName.GetFullPath() ) ) backupFileName.GetFullPath() ) )
{ {
DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) );
...@@ -669,7 +669,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -669,7 +669,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
/* The old library file is renamed .bak */ /* The old library file is renamed .bak */
oldFileName = aLibName; oldFileName = aLibName;
oldFileName.SetExt( OLD_EXT ); oldFileName.SetExt( BACKUP_EXT );
if( oldFileName.FileExists() ) if( oldFileName.FileExists() )
wxRemoveFile( oldFileName.GetFullPath() ); wxRemoveFile( oldFileName.GetFullPath() );
......
...@@ -213,11 +213,14 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF ...@@ -213,11 +213,14 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullF
tmp = wxGetApp().FindLibraryPath( fn ); tmp = wxGetApp().FindLibraryPath( fn );
if( !tmp ) if( !tmp )
{
if ( aDisplayMessageError )
{ {
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ), msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
fn.GetFullName().c_str() ); fn.GetFullName().c_str() );
wxMessageBox( msg, _( "Library Load Error" ), wxMessageBox( msg, _( "Library Load Error" ),
wxOK | wxICON_ERROR, this ); wxOK | wxICON_ERROR, this );
}
continue; continue;
} }
......
...@@ -124,10 +124,12 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event ) ...@@ -124,10 +124,12 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
case 1: case 1:
case 2: case 2:
m_NewModule->Enable( true ); m_NewModule->Enable( true );
m_Browsebutton->Enable( true );
break; break;
case 3: case 3:
m_NewModule->Enable( false ); m_NewModule->Enable( false );
m_Browsebutton->Enable( false );
break; break;
} }
} }
...@@ -202,7 +204,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -202,7 +204,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
strtok( buf, ";\n\r" ); strtok( buf, ";\n\r" );
if( stricmp( buf, CONV_TO_UTF8( reference ) ) == 0 ) if( stricmp( buf, CONV_TO_UTF8( reference ) ) == 0 )
{ {
start_descr = TRUE; start_descr = true;
} }
} }
...@@ -247,7 +249,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Module() ...@@ -247,7 +249,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Module()
if( newmodulename == wxEmptyString ) if( newmodulename == wxEmptyString )
return; return;
if( Change_1_Module( m_CurrentModule, newmodulename, TRUE ) ) if( Change_1_Module( m_CurrentModule, newmodulename, true ) )
{ {
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
...@@ -272,9 +274,9 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -272,9 +274,9 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
MODULE* Module, * PtBack; MODULE* Module, * PtBack;
bool change = FALSE; bool change = FALSE;
wxString newmodulename = m_NewModule->GetValue(); wxString newmodulename = m_NewModule->GetValue();
wxString value, lib_reference; // pour memo Reflib et value de reference wxString value, lib_reference;
bool check_module_value = FALSE; bool check_module_value = FALSE;
int ShowErr = 5; // Affiche 5 messages d'err maxi int ShowErr = 3; // Affiche 3 messages d'err maxi
if( m_Parent->GetBoard()->m_Modules == NULL ) if( m_Parent->GetBoard()->m_Modules == NULL )
return; return;
...@@ -284,7 +286,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -284,7 +286,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
lib_reference = m_CurrentModule->m_LibRef; lib_reference = m_CurrentModule->m_LibRef;
if( aUseValue ) if( aUseValue )
{ {
check_module_value = TRUE; check_module_value = true;
value = m_CurrentModule->m_Value->m_Text; value = m_CurrentModule->m_Value->m_Text;
msg.Printf( _( "Change modules <%s> -> <%s> (val = %s)?" ), msg.Printf( _( "Change modules <%s> -> <%s> (val = %s)?" ),
m_CurrentModule->m_LibRef.GetData(), m_CurrentModule->m_LibRef.GetData(),
...@@ -320,7 +322,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -320,7 +322,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
} }
module = Change_1_Module( Module, newmodulename.GetData(), ShowErr ); module = Change_1_Module( Module, newmodulename.GetData(), ShowErr );
if( module ) if( module )
change = TRUE; change = true;
else if( ShowErr ) else if( ShowErr )
ShowErr--; ShowErr--;
} }
...@@ -345,7 +347,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -345,7 +347,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
{ {
MODULE* Module, * PtBack; MODULE* Module, * PtBack;
bool change = FALSE; bool change = FALSE;
int ShowErr = 5; // Affiche 5 messages d'err maxi int ShowErr = 3; // Affiche 3 messages d'err maxi
if( m_Parent->GetBoard()->m_Modules == NULL ) if( m_Parent->GetBoard()->m_Modules == NULL )
return; return;
...@@ -364,7 +366,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -364,7 +366,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
{ {
PtBack = Module->Back(); PtBack = Module->Back();
if( Change_1_Module( Module, Module->m_LibRef.GetData(), ShowErr ) ) if( Change_1_Module( Module, Module->m_LibRef.GetData(), ShowErr ) )
change = TRUE; change = true;
else if( ShowErr ) else if( ShowErr )
ShowErr--; ShowErr--;
} }
...@@ -411,7 +413,7 @@ MODULE* DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -411,7 +413,7 @@ MODULE* DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
Module->m_Reference->m_Text.GetData(), oldnamecmp.GetData() ); Module->m_Reference->m_Text.GetData(), oldnamecmp.GetData() );
m_WinMessages->AppendText( Line ); m_WinMessages->AppendText( Line );
namecmp.Trim( TRUE ); namecmp.Trim( true );
namecmp.Trim( FALSE ); namecmp.Trim( FALSE );
NewModule = m_Parent->Get_Librairie_Module( wxEmptyString, NewModule = m_Parent->Get_Librairie_Module( wxEmptyString,
namecmp, namecmp,
...@@ -468,19 +470,19 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, ...@@ -468,19 +470,19 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff,
Place_Module( NewModule, NULL, true ); Place_Module( NewModule, NULL, true );
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
/* Changement eventuel de couche */ /* Flip footprint if needed */
if( OldModule->GetLayer() != NewModule->GetLayer() ) if( OldModule->GetLayer() != NewModule->GetLayer() )
{ {
GetBoard()->Change_Side_Module( NewModule, NULL ); GetBoard()->Change_Side_Module( NewModule, NULL );
} }
/* Rotation eventuelle du module */ /* Rotate footprint if needed */
if( OldModule->m_Orient != NewModule->m_Orient ) if( OldModule->m_Orient != NewModule->m_Orient )
{ {
Rotate_Module( NULL, NewModule, OldModule->m_Orient, FALSE ); Rotate_Module( NULL, NewModule, OldModule->m_Orient, FALSE );
} }
/* Mise a jour des textes ref et val */ /* Update reference and value */
NewModule->m_Reference->m_Text = OldModule->m_Reference->m_Text; NewModule->m_Reference->m_Text = OldModule->m_Reference->m_Text;
NewModule->m_Value->m_Text = OldModule->m_Value->m_Text; NewModule->m_Value->m_Text = OldModule->m_Value->m_Text;
...@@ -488,7 +490,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, ...@@ -488,7 +490,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff,
NewModule->m_TimeStamp = OldModule->m_TimeStamp; NewModule->m_TimeStamp = OldModule->m_TimeStamp;
NewModule->m_Path = OldModule->m_Path; NewModule->m_Path = OldModule->m_Path;
/* mise a jour des netnames ( lorsque c'est possible) */ /* Update pad netnames ( when possible) */
pad = NewModule->m_Pads; pad = NewModule->m_Pads;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment