Commit ea40d26a authored by jean-pierre charras's avatar jean-pierre charras

code cleaning.Minor enhancements. Fixed issues in microwave tools.

finished replacement of Get_Message (not very useful) by wxTextEntryDialog
parents 42022cfc 3c372703
...@@ -639,7 +639,8 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -639,7 +639,8 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
if( wxTheClipboard->Open() ) if( wxTheClipboard->Open() )
{ {
if( !wxTheClipboard->SetData( dobjBmp ) ) if( !wxTheClipboard->SetData( dobjBmp ) )
wxLogError( _T( "Failed to copy image to clipboard" ) ); wxMessageBox( _( "Failed to copy image to clipboard" ) );
wxTheClipboard->Flush(); /* the data in clipboard will stay wxTheClipboard->Flush(); /* the data in clipboard will stay
* available after the * available after the
* application exits */ * application exits */
...@@ -653,7 +654,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) ...@@ -653,7 +654,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
if( !image.SaveFile( FullFileName, if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : fmt_is_jpeg ? wxBITMAP_TYPE_JPEG :
wxBITMAP_TYPE_PNG ) ) wxBITMAP_TYPE_PNG ) )
wxLogError( wxT( "Can't save file" ) ); wxMessageBox( _( "Can't save file" ) );
image.Destroy(); image.Destroy();
} }
......
...@@ -114,32 +114,3 @@ bool IsOK( wxWindow* parent, const wxString& text ) ...@@ -114,32 +114,3 @@ bool IsOK( wxWindow* parent, const wxString& text )
return FALSE; return FALSE;
} }
/* Get a text from user
* Title = title to display
* Buffer: enter text by user
* Leading and trailing spaces are removed
* Buffer is the initial text displayed, anr the returned text
* Return:
* 0 if OK
* 1 if CANCEL
*/
int Get_Message( const wxString& title, // The question
const wxString& frame_caption, // The frame caption
wxString& buffer, // String input/return buffer
wxWindow* frame )
{
wxString message;
message = wxGetTextFromUser( title, frame_caption,
buffer, frame );
if( !message.IsEmpty() )
{
message.Trim( FALSE ); // Remove blanks at beginning
message.Trim( TRUE ); // Remove blanks at end
buffer = message;
return 0;
}
return 1;
}
...@@ -277,7 +277,7 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event ) ...@@ -277,7 +277,7 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
if( m_ListLibr->GetCount() > 0 && selections.GetCount() > 0 ) if( m_ListLibr->GetCount() > 0 && selections.GetCount() > 0 )
{ {
int pos = selections[selections.GetCount()-1]; int pos = selections[selections.GetCount()-1];
if( pos == m_ListLibr->GetCount() ) if( pos == (int)m_ListLibr->GetCount() )
pos = m_ListLibr->GetCount() - 1; pos = m_ListLibr->GetCount() - 1;
m_ListLibr->SetSelection( pos ); m_ListLibr->SetSelection( pos );
} }
......
...@@ -228,7 +228,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED ...@@ -228,7 +228,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
* New name cannot be the root name, and must not exists * New name cannot be the root name, and must not exists
*/ */
{ {
wxString Line;
wxString aliasname; wxString aliasname;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary(); CMP_LIBRARY* library = m_Parent->GetLibrary();
...@@ -236,12 +235,15 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED ...@@ -236,12 +235,15 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
if( component == NULL ) if( component == NULL )
return; return;
if( Get_Message( _( "New alias:" ), wxTextEntryDialog dlg( this, _( "New alias:" ), _( "Component Alias" ), aliasname );
_( "Component Alias" ), Line, this ) != 0 ) if( dlg.ShowModal() != wxID_OK )
return; return; // cancelled by user
Line.Replace( wxT( " " ), wxT( "_" ) ); aliasname = dlg.GetValue( );
aliasname = Line;
aliasname.Replace( wxT( " " ), wxT( "_" ) );
if( aliasname.IsEmpty() )
return;
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND
|| library->FindEntry( aliasname ) != NULL ) || library->FindEntry( aliasname ) != NULL )
...@@ -405,8 +407,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( ...@@ -405,8 +407,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter(
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************************/ /*******************************************************************************/
/* Add a new name to the alias list box /* Add a new name to the footprint filter list box
* New name cannot be the root name, and must not exists * Obvioulsy, cannot be void
*/ */
{ {
wxString Line; wxString Line;
...@@ -415,12 +417,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU ...@@ -415,12 +417,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
if( component == NULL ) if( component == NULL )
return; return;
if( Get_Message( _( "Add Footprint Filter" ), _( "Footprint Filter" ), wxTextEntryDialog dlg( this, _( "Add Footprint Filter" ), _( "Footprint Filter" ), Line );
Line, this ) != 0 ) if( dlg.ShowModal() != wxID_OK )
return; return; // cancelled by user
Line = dlg.GetValue( );
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
if( Line.IsEmpty() )
return;
/* test for an existing name: */ /* test for an existing name: */
int index = m_FootprintFilterListBox->FindString( Line ); int index = m_FootprintFilterListBox->FindString( Line );
......
...@@ -128,9 +128,17 @@ modified!\nYou must create a new power" ) ); ...@@ -128,9 +128,17 @@ modified!\nYou must create a new power" ) );
wxString newtext = Field->m_Text; wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
Get_Message( Field->m_Name, _( "Component field text" ), newtext, this );
wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext );
int diag = dlg.ShowModal();
newtext = dlg.GetValue( );
newtext.Trim( true );
newtext.Trim( false );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
if ( diag != wxID_OK )
return; // cancelled by user
Field->m_AddExtraText = flag; Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
...@@ -295,7 +303,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -295,7 +303,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
flag = 1; flag = 1;
wxString ref = Cmp->GetRef( GetSheet() ); wxString ref = Cmp->GetRef( GetSheet() );
Get_Message( _( "Reference" ), _( "Component reference" ), ref, this ); wxTextEntryDialog dlg( this, _( "Reference" ), _( "Component reference" ), ref );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
ref = dlg.GetValue( );
ref.Trim( true );
ref.Trim( false );
if( !ref.IsEmpty() ) // New text entered if( !ref.IsEmpty() ) // New text entered
{ {
...@@ -335,8 +349,14 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -335,8 +349,14 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
SCH_FIELD* TextField = Cmp->GetField( VALUE ); SCH_FIELD* TextField = Cmp->GetField( VALUE );
message = TextField->m_Text; message = TextField->m_Text;
if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
message.Empty(); //allow the user to remove the value. wxTextEntryDialog dlg( this, _( "Value" ), _( "Component value" ), message );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
message = dlg.GetValue( );
message.Trim( true );
message.Trim( false );
if( !message.IsEmpty() ) if( !message.IsEmpty() )
{ {
...@@ -371,8 +391,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -371,8 +391,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT ); SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
message = TextField->m_Text; message = TextField->m_Text;
if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) ) wxTextEntryDialog dlg( this, _( "Footprint" ), _( "Component footprint" ), message );
return; // edition cancelled by user. if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
message = dlg.GetValue( );
message.Trim( true );
message.Trim( false );
bool wasEmpty = false; bool wasEmpty = false;
if( TextField->m_Text.IsEmpty() ) if( TextField->m_Text.IsEmpty() )
......
...@@ -211,8 +211,18 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -211,8 +211,18 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( m_component ) if( m_component )
{
// display reference like in schematic (a reference U is shown U? or U?A)
// although it is stored without ? and part id.
// So temporary change the reference by a schematic like reference
LIB_FIELD* Field = m_component->GetField( REFERENCE );
wxString fieldText = Field->m_Text;
wxString fieldfullText = Field->GetFullText( m_unit );
Field->m_Text = fieldfullText;
m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit,
m_convert, GR_DEFAULT_DRAWMODE ); m_convert, GR_DEFAULT_DRAWMODE );
Field->m_Text = fieldText;
}
GetScreen()->ClrRefreshReq(); GetScreen()->ClrRefreshReq();
......
...@@ -27,7 +27,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -27,7 +27,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) Panel->GetParent(); WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) Panel->GetParent();
if( parent == NULL ) if( parent == NULL )
return; return;
...@@ -37,7 +37,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -37,7 +37,7 @@ static void AbortMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
if( item == NULL ) if( item == NULL )
return; return;
wxPoint curpos = Panel->GetScreen()->m_Curseur; wxPoint curpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = s_InitialPosition; Panel->GetScreen()->m_Curseur = s_InitialPosition;
ShowMoveField( Panel, DC, true ); ShowMoveField( Panel, DC, true );
...@@ -54,9 +54,9 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LIB_FIELD* field ) ...@@ -54,9 +54,9 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LIB_FIELD* field )
if( ( m_component == NULL ) || ( field == NULL ) ) if( ( m_component == NULL ) || ( field == NULL ) )
return; return;
m_drawItem = field; m_drawItem = field;
s_InitialPosition = field->m_Pos; s_InitialPosition = field->m_Pos;
NEGATE(s_InitialPosition.y); NEGATE( s_InitialPosition.y );
m_drawItem->m_Flags |= IS_MOVED; m_drawItem->m_Flags |= IS_MOVED;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
...@@ -90,7 +90,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -90,7 +90,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
return; return;
wxString text = Field->GetFullText( parent->GetUnit() ); wxString text = Field->GetFullText( parent->GetUnit() );
wxPoint offset ; wxPoint offset;
offset.x = s_LastPosition.x - Field->m_Pos.x; offset.x = s_LastPosition.x - Field->m_Pos.x;
offset.y = s_LastPosition.y + Field->m_Pos.y; offset.y = s_LastPosition.y + Field->m_Pos.y;
...@@ -123,7 +123,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field ) ...@@ -123,7 +123,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field )
&fieldText, DefaultTransformMatrix ); &fieldText, DefaultTransformMatrix );
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
OnModify( ); OnModify();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
m_drawItem = NULL; m_drawItem = NULL;
...@@ -132,8 +132,9 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field ) ...@@ -132,8 +132,9 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LIB_FIELD* Field )
void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field ) void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
{ {
wxString Text; wxString Text;
wxString title; wxString title;
bool save = true;
if( Field == NULL ) if( Field == NULL )
return; return;
...@@ -141,11 +142,11 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field ) ...@@ -141,11 +142,11 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
switch( Field->m_FieldId ) switch( Field->m_FieldId )
{ {
case REFERENCE: case REFERENCE:
title = wxT( "Reference:" ); title = _( "Reference:" );
break; break;
case VALUE: case VALUE:
title = wxT( "Component Name / Value:" ); title = _( "Component Name / Value:" );
break; break;
default: default:
...@@ -154,10 +155,25 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field ) ...@@ -154,10 +155,25 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
Text = Field->m_Text; Text = Field->m_Text;
/* FIXME: Use wxTextEntry dialog here and check for cancel button. */ {
Get_Message( title, _( "Edit field" ), Text, this ); wxTextEntryDialog dlg( this, title, _( "Edit field" ), Text );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
Text = dlg.GetValue( );
}
Text.Replace( wxT( " " ), wxT( "_" ) ); Text.Replace( wxT( " " ), wxT( "_" ) );
if( Field->m_FieldId == REFERENCE || Field->m_FieldId == VALUE )
{
if( Text.IsEmpty ( ) )
{
DisplayError( this, _( "Value or Reference cannot be void. Aborted" ) );
return;
}
}
wxString fieldText = Field->GetFullText( m_unit ); wxString fieldText = Field->GetFullText( m_unit );
/* If the value field is changed, this is equivalent to creating a new /* If the value field is changed, this is equivalent to creating a new
...@@ -172,11 +188,12 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field ) ...@@ -172,11 +188,12 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field )
/* Test for an existing name in the current components alias list. */ /* Test for an existing name in the current components alias list. */
if( Field->GetParent()->m_AliasList.Index( Text, false ) != wxNOT_FOUND ) if( Field->GetParent()->m_AliasList.Index( Text, false ) != wxNOT_FOUND )
{ {
msg.Printf( _( "The field name <%s> is an existing alias of the \ msg.Printf( _(
"The field name <%s> is an existing alias of the \
component <%s>.\nPlease choose another name that does not conflict with any \ component <%s>.\nPlease choose another name that does not conflict with any \
names in the alias list." ), names in the alias list." ),
GetChars( Text ), GetChars( Text ),
GetChars( Field->GetParent()->GetName() ) ); GetChars( Field->GetParent()->GetName() ) );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
...@@ -186,15 +203,18 @@ names in the alias list." ), ...@@ -186,15 +203,18 @@ names in the alias list." ),
*/ */
if( m_library && m_library->FindEntry( Text ) != NULL ) if( m_library && m_library->FindEntry( Text ) != NULL )
{ {
msg.Printf( _( "The field name <%s> conflicts with an existing \ msg.Printf( _(
"The field name <%s> conflicts with an existing \
entry in the component library <%s>.\nPlease choose another name that does \ entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ), not conflict with any library entries." ),
GetChars( Text ), GetChars( Text ),
GetChars( m_library->GetName() ) ); GetChars( m_library->GetName() ) );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
SaveCopyInUndoList( Field->GetParent() );
save = false;
Field->GetParent()->SetName( Text ); Field->GetParent()->SetName( Text );
} }
...@@ -203,7 +223,8 @@ not conflict with any library entries." ), ...@@ -203,7 +223,8 @@ not conflict with any library entries." ),
if( !Text.IsEmpty() ) if( !Text.IsEmpty() )
{ {
SaveCopyInUndoList( Field->GetParent() ); if( save )
SaveCopyInUndoList( Field->GetParent() );
Field->m_Text = Text; Field->m_Text = Text;
} }
else else
...@@ -220,7 +241,7 @@ not conflict with any library entries." ), ...@@ -220,7 +241,7 @@ not conflict with any library entries." ),
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
OnModify( ); OnModify();
UpdateAliasSelectList(); UpdateAliasSelectList();
} }
...@@ -233,11 +254,10 @@ not conflict with any library entries." ), ...@@ -233,11 +254,10 @@ not conflict with any library entries." ),
*/ */
void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field ) void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
{ {
if( Field == NULL ) if( Field == NULL )
return; return;
OnModify( ); OnModify();
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
GRSetDrawMode( DC, g_XorMode ); GRSetDrawMode( DC, g_XorMode );
...@@ -247,9 +267,9 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field ) ...@@ -247,9 +267,9 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
ShowMoveField( DrawPanel, DC, false ); ShowMoveField( DrawPanel, DC, false );
else else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
if( Field->m_Orient == TEXT_ORIENT_VERT) if( Field->m_Orient == TEXT_ORIENT_VERT )
Field->m_Orient = TEXT_ORIENT_HORIZ; Field->m_Orient = TEXT_ORIENT_HORIZ;
else else
Field->m_Orient = TEXT_ORIENT_VERT; Field->m_Orient = TEXT_ORIENT_VERT;
...@@ -263,7 +283,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field ) ...@@ -263,7 +283,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LIB_FIELD* Field )
ShowMoveField( DrawPanel, DC, false ); ShowMoveField( DrawPanel, DC, false );
else else
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText, Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, drawMode, &fieldText,
DefaultTransformMatrix ); DefaultTransformMatrix );
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
} }
......
...@@ -16,10 +16,4 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& msg, ...@@ -16,10 +16,4 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& msg,
bool IsOK( wxWindow* parent, const wxString& msg ); bool IsOK( wxWindow* parent, const wxString& msg );
int Get_Message( const wxString& title,
const wxString& frame_caption,
wxString& buffer,
wxWindow* frame );
#endif /* __INCLUDE__CONFIRM_H__ */ #endif /* __INCLUDE__CONFIRM_H__ */
...@@ -226,8 +226,16 @@ public: ...@@ -226,8 +226,16 @@ public:
virtual void OnModify( ); virtual void OnModify( );
// Modules (footprints) // Modules (footprints)
MODULE* Create_1_Module( wxDC* DC, /** Function Create_1_Module
const wxString& module_name ); * Creates a new module or footprint : A new module contains 2 texts :
* First = REFERENCE
* Second = VALUE: "VAL**"
* the new module is added to the board module list
* @param aModuleName = name of the new footprint
* (will the component reference in board)
* @return a pointer to the new module
*/
MODULE* Create_1_Module( const wxString& module_name );
void Edit_Module( MODULE* module, wxDC* DC ); void Edit_Module( MODULE* module, wxDC* DC );
void Rotate_Module( wxDC* DC, void Rotate_Module( wxDC* DC,
MODULE* module, MODULE* module,
......
...@@ -1178,9 +1178,20 @@ public: ...@@ -1178,9 +1178,20 @@ public:
void RemoveStruct( EDA_BaseStruct* Item ); void RemoveStruct( EDA_BaseStruct* Item );
void Transform( MODULE* module, int transform ); void Transform( MODULE* module, int transform );
// loading/exporting Footprint // importing / exporting Footprint
MODULE* Import_Module( wxDC* DC );
void Export_Module( MODULE* ptmod, bool createlib ); void Export_Module( MODULE* ptmod, bool createlib );
/**
* Function Import_Module
* Read a file containing only one footprint.
* Used to import (after exporting) a footprint
* Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint
* The import function can also read gpcb footprint file, in Newlib format
* (One footprint per file, Newlib files have no special ext.)
* @param DC = Current Device Context (can be NULL)
*/
MODULE* Import_Module( );
/** function Load_Module_From_BOARD /** function Load_Module_From_BOARD
* load in Modedit a footfrint from the main board * load in Modedit a footfrint from the main board
...@@ -1198,22 +1209,27 @@ public: ...@@ -1198,22 +1209,27 @@ public:
// functions to edit footprint edges // functions to edit footprint edges
/** /** Function Edit_Edge_Width
* Function Edit_Edge_Width
* changes the width of module perimeter lines, EDGE_MODULEs. * changes the width of module perimeter lines, EDGE_MODULEs.
* @param ModuleSegmentWidth (global) = new width * param ModuleSegmentWidth (global) = new width
* @param Edge = edge to edit, or NULL. If Edge == NULL change * @param aEdge = edge to edit, or NULL. If aEdge == NULL change
* the width of all the footprint's edges * the width of all footprint's edges
* @param DC = current Device Context
*/ */
void Edit_Edge_Width( EDGE_MODULE* Edge ); void Edit_Edge_Width( EDGE_MODULE* aEdge );
void Edit_Edge_Layer( EDGE_MODULE* Edge ); void Edit_Edge_Layer( EDGE_MODULE* Edge );
void Delete_Edge_Module( EDGE_MODULE* Edge ); void Delete_Edge_Module( EDGE_MODULE* Edge );
EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge ); EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
void End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ); void End_Edge_Module( EDGE_MODULE* Edge );
void Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ); /** function Enter_Edge_Width
* Edition of the edge items width
* Ask for a new width.
* Change the width of EDGE_MODULE Edge if aEdge != NULL
* @param aEdge = edge to edit, or NULL
* @output ModuleSegmentWidth (global) = new width
*/
void Enter_Edge_Width( EDGE_MODULE* aEdge );
void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC ); void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
void Place_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC ); void Place_EdgeMod( EDGE_MODULE* drawitem );
// handlers for libraries: // handlers for libraries:
void Delete_Module_In_Library( const wxString& libname ); void Delete_Module_In_Library( const wxString& libname );
......
...@@ -853,8 +853,15 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& ) ...@@ -853,8 +853,15 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
wxString buffer = m_TreeProject->GetItemText( curr_item ); wxString buffer = m_TreeProject->GetItemText( curr_item );
wxString msg = _( "Change filename: " ) + tree_data->m_FileName; wxString msg = _( "Change filename: " ) + tree_data->m_FileName;
if( Get_Message( msg, _( "Change filename" ), buffer, this ) != 0 ) wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
return; //Abort command if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
buffer = dlg.GetValue( );
buffer.Trim( true );
buffer.Trim( false );
if( buffer.IsEmpty() )
return; // empty file name not allowed
if( tree_data->Rename( buffer, true ) ) if( tree_data->Rename( buffer, true ) )
m_TreeProject->SetItemText( curr_item, buffer ); m_TreeProject->SetItemText( curr_item, buffer );
......
...@@ -128,7 +128,9 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const ...@@ -128,7 +128,9 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
netclass = net->GetNetClass(); netclass = net->GetNetClass();
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
if( netclass == NULL ) if( netclass == NULL )
{
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL netclass") ); wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL netclass") );
}
#endif #endif
} }
......
...@@ -38,7 +38,7 @@ MODULE::MODULE( BOARD* parent ) : ...@@ -38,7 +38,7 @@ MODULE::MODULE( BOARD* parent ) :
m_CntRot90 = m_CntRot180 = 0; m_CntRot90 = m_CntRot180 = 0;
m_Surface = 0.0; m_Surface = 0.0;
m_Link = 0; m_Link = 0;
m_LastEdit_Time = time( NULL ); m_LastEdit_Time = time( NULL );
m_LocalClearance = 0; m_LocalClearance = 0;
m_LocalSolderMaskMargin = 0; m_LocalSolderMaskMargin = 0;
m_LocalSolderPasteMargin = 0; m_LocalSolderPasteMargin = 0;
...@@ -59,6 +59,7 @@ MODULE::~MODULE() ...@@ -59,6 +59,7 @@ MODULE::~MODULE()
delete m_Value; delete m_Value;
} }
/* Draw the anchor cross (vertical) /* Draw the anchor cross (vertical)
* Must be done after the pads, because drawing the hole will erase overwrite * Must be done after the pads, because drawing the hole will erase overwrite
* every thing already drawn. * every thing already drawn.
...@@ -76,7 +77,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset ...@@ -76,7 +77,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
if( GetBoard()->IsElementVisible( ANCHOR_VISIBLE ) ) if( GetBoard()->IsElementVisible( ANCHOR_VISIBLE ) )
{ {
int color = g_ColorsSettings.GetItemColor(ANCHOR_VISIBLE); int color = g_ColorsSettings.GetItemColor( ANCHOR_VISIBLE );
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y, m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y, m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y,
...@@ -158,9 +159,9 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -158,9 +159,9 @@ void MODULE::Copy( MODULE* aModule )
if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes. if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes.
continue; continue;
S3D_MASTER* t3d = m_3D_Drawings; S3D_MASTER* t3d = m_3D_Drawings;
if( t3d && t3d->m_Shape3DName.IsEmpty() ) // The first entry can if( t3d && t3d->m_Shape3DName.IsEmpty() ) // The first entry can
// exist, but is empty : // exist, but is empty :
// use it. // use it.
t3d->Copy( item ); t3d->Copy( item );
else else
{ {
...@@ -196,7 +197,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -196,7 +197,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
pad->Draw( panel, DC, draw_mode, offset ); pad->Draw( panel, DC, draw_mode, offset );
} }
BOARD * brd = GetBoard(); BOARD* brd = GetBoard();
// Draws footprint anchor // Draws footprint anchor
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode ); DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
...@@ -302,13 +303,13 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -302,13 +303,13 @@ bool MODULE::Save( FILE* aFile ) const
fprintf( aFile, "AR %s\n", CONV_TO_UTF8( m_Path ) ); fprintf( aFile, "AR %s\n", CONV_TO_UTF8( m_Path ) );
fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 ); fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 );
if( m_LocalSolderMaskMargin != 0 ) if( m_LocalSolderMaskMargin != 0 )
fprintf( aFile, ".SolderMask %d\n",m_LocalSolderMaskMargin ); fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin );
if( m_LocalSolderPasteMargin != 0 ) if( m_LocalSolderPasteMargin != 0 )
fprintf( aFile, ".SolderPaste %d\n",m_LocalSolderPasteMargin); fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin );
if( m_LocalSolderPasteMarginRatio != 0) if( m_LocalSolderPasteMarginRatio != 0 )
fprintf( aFile, ".SolderPasteRatio %g\n",m_LocalSolderPasteMarginRatio); fprintf( aFile, ".SolderPasteRatio %g\n", m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 ) if( m_LocalClearance != 0 )
fprintf( aFile, ".LocalClearance %d\n",m_LocalClearance ); fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance );
// attributes // attributes
if( m_Attributs != MOD_DEFAULT ) if( m_Attributs != MOD_DEFAULT )
...@@ -489,7 +490,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -489,7 +490,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
{ {
D_PAD* pad = new D_PAD( this ); D_PAD* pad = new D_PAD( this );
pad->ReadDescr( File, LineNum ); pad->ReadDescr( File, LineNum );
RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y, m_Orient ); RotatePoint( &pad->m_Pos, m_Orient );
pad->m_Pos.x += m_Pos.x; pad->m_Pos.x += m_Pos.x;
pad->m_Pos.y += m_Pos.y; pad->m_Pos.y += m_Pos.y;
...@@ -507,7 +508,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -507,7 +508,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
/* Decode the first code of the current line and read the /* Decode the first code of the current line and read the
* corresponding data * corresponding data
*/ */
switch( Line[0] ) switch( Line[0] )
{ {
case 'P': case 'P':
...@@ -602,20 +603,21 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -602,20 +603,21 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
break; break;
case '.': /* Read specific data */ case '.': /* Read specific data */
if( strnicmp(Line, ".SolderMask ", 12 ) == 0 ) if( strnicmp( Line, ".SolderMask ", 12 ) == 0 )
m_LocalSolderMaskMargin = atoi(Line+12); m_LocalSolderMaskMargin = atoi( Line + 12 );
else if( strnicmp(Line, ".SolderPaste ", 13) == 0 ) else if( strnicmp( Line, ".SolderPaste ", 13 ) == 0 )
m_LocalSolderPasteMargin = atoi(Line+13); m_LocalSolderPasteMargin = atoi( Line + 13 );
else if( strnicmp(Line, ".SolderPasteRatio ", 18) == 0 ) else if( strnicmp( Line, ".SolderPasteRatio ", 18 ) == 0 )
m_LocalSolderPasteMarginRatio = atof(Line+18); m_LocalSolderPasteMarginRatio = atof( Line + 18 );
else if( strnicmp(Line, ".LocalClearance ", 16 ) == 0 ) else if( strnicmp( Line, ".LocalClearance ", 16 ) == 0 )
m_LocalClearance = atoi(Line+16); m_LocalClearance = atoi( Line + 16 );
break; break;
default: default:
break; break;
} }
} }
/* Recalculate the bounding box */ /* Recalculate the bounding box */
Set_Rectangle_Encadrement(); Set_Rectangle_Encadrement();
return 0; return 0;
...@@ -640,51 +642,53 @@ void MODULE::Set_Rectangle_Encadrement() ...@@ -640,51 +642,53 @@ void MODULE::Set_Rectangle_Encadrement()
xmin = ymin = -250; xmin = ymin = -250;
xmax = ymax = 250; xmax = ymax = 250;
for( EDGE_MODULE* pt_edge_mod = (EDGE_MODULE*) m_Drawings.GetFirst(); for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst();
pt_edge_mod; pt_edge_mod = pt_edge_mod->Next() ) edge; edge = edge->Next() )
{ {
if( pt_edge_mod->Type() != TYPE_EDGE_MODULE ) if( edge->Type() != TYPE_EDGE_MODULE )
continue; continue;
width = pt_edge_mod->m_Width / 2; width = edge->m_Width / 2;
switch( pt_edge_mod->m_Shape ) switch( edge->m_Shape )
{ {
case S_ARC: case S_ARC:
case S_CIRCLE: case S_CIRCLE:
{ {
cx = pt_edge_mod->m_Start0.x; cx = edge->m_Start0.x;
cy = pt_edge_mod->m_Start0.y; // center cy = edge->m_Start0.y; // center
uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y; uxf = edge->m_End0.x;
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) ); uyf = edge->m_End0.y;
rayon = (int) hypot( (double) ( cx - uxf ), (double) ( cy - uyf ) );
rayon += width; rayon += width;
xmin = MIN( xmin, cx - rayon ); xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon ); ymin = MIN( ymin, cy - rayon );
xmax = MAX( xmax, cx + rayon ); xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon ); ymax = MAX( ymax, cy + rayon );
break; break;
} }
case S_SEGMENT: case S_SEGMENT:
xmin = MIN( xmin, pt_edge_mod->m_Start0.x - width ); xmin = MIN( xmin, edge->m_Start0.x - width );
xmin = MIN( xmin, pt_edge_mod->m_End0.x - width ); xmin = MIN( xmin, edge->m_End0.x - width );
ymin = MIN( ymin, pt_edge_mod->m_Start0.y - width ); ymin = MIN( ymin, edge->m_Start0.y - width );
ymin = MIN( ymin, pt_edge_mod->m_End0.y - width ); ymin = MIN( ymin, edge->m_End0.y - width );
xmax = MAX( xmax, pt_edge_mod->m_Start0.x + width ); xmax = MAX( xmax, edge->m_Start0.x + width );
xmax = MAX( xmax, pt_edge_mod->m_End0.x + width ); xmax = MAX( xmax, edge->m_End0.x + width );
ymax = MAX( ymax, pt_edge_mod->m_Start0.y + width ); ymax = MAX( ymax, edge->m_Start0.y + width );
ymax = MAX( ymax, pt_edge_mod->m_End0.y + width ); ymax = MAX( ymax, edge->m_End0.y + width );
break; break;
case S_POLYGON: case S_POLYGON:
for( unsigned ii = 0; ii < pt_edge_mod->m_PolyPoints.size(); ii++ ) for( unsigned ii = 0; ii < edge->m_PolyPoints.size(); ii++ )
{ {
wxPoint pt = pt_edge_mod->m_PolyPoints[ii]; wxPoint pt = edge->m_PolyPoints[ii];
xmin = MIN( xmin, (pt.x - width) ); xmin = MIN( xmin, (pt.x - width) );
ymin = MIN( ymin, (pt.y - width) ); ymin = MIN( ymin, (pt.y - width) );
xmax = MAX( xmax, (pt.x + width) ); xmax = MAX( xmax, (pt.x + width) );
ymax = MAX( ymax, (pt.y + width) ); ymax = MAX( ymax, (pt.y + width) );
} }
break; break;
} }
} }
...@@ -696,10 +700,10 @@ void MODULE::Set_Rectangle_Encadrement() ...@@ -696,10 +700,10 @@ void MODULE::Set_Rectangle_Encadrement()
rayon = pad->m_Rayon; rayon = pad->m_Rayon;
cx = pad->m_Pos0.x; cx = pad->m_Pos0.x;
cy = pad->m_Pos0.y; cy = pad->m_Pos0.y;
xmin = MIN( xmin, cx - rayon ); xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon ); ymin = MIN( ymin, cy - rayon );
xmax = MAX( xmax, cx + rayon ); xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon ); ymax = MAX( ymax, cy + rayon );
} }
m_BoundaryBox.m_Pos.x = xmin; m_BoundaryBox.m_Pos.x = xmin;
...@@ -721,24 +725,24 @@ void MODULE::SetRectangleExinscrit() ...@@ -721,24 +725,24 @@ void MODULE::SetRectangleExinscrit()
m_RealBoundaryBox.Inflate( 500 ); // Give a min size m_RealBoundaryBox.Inflate( 500 ); // Give a min size
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst();
edge; edge = edge->Next() ) edge; edge = edge->Next() )
{ {
if( edge->Type() != TYPE_EDGE_MODULE ) // Shoud not occur if( edge->Type() != TYPE_EDGE_MODULE ) // Shoud not occur
continue; continue;
EDA_Rect rect = edge->GetBoundingBox(); EDA_Rect rect = edge->GetBoundingBox();
m_RealBoundaryBox.Merge(rect); m_RealBoundaryBox.Merge( rect );
} }
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{ {
EDA_Rect rect = pad->GetBoundingBox(); EDA_Rect rect = pad->GetBoundingBox();
m_RealBoundaryBox.Merge(rect); m_RealBoundaryBox.Merge( rect );
} }
m_Surface = ABS( (double) m_RealBoundaryBox.GetWidth() m_Surface = ABS( (double) m_RealBoundaryBox.GetWidth()
* m_RealBoundaryBox.GetHeight() ); * m_RealBoundaryBox.GetHeight() );
} }
...@@ -762,7 +766,7 @@ EDA_Rect MODULE::GetBoundingBox() ...@@ -762,7 +766,7 @@ EDA_Rect MODULE::GetBoundingBox()
area.Merge( text_area ); area.Merge( text_area );
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge;
edge = edge->Next() ) edge = edge->Next() )
{ {
if( edge->Type() != TYPE_TEXTE_MODULE ) if( edge->Type() != TYPE_TEXTE_MODULE )
continue; continue;
...@@ -914,6 +918,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const ...@@ -914,6 +918,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
#endif #endif
return pad; return pad;
} }
......
...@@ -656,11 +656,15 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event ) ...@@ -656,11 +656,15 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
{ {
wxString class_name; wxString class_name;
if( Get_Message( _( "New Net Class Name:" ), wxTextEntryDialog dlg( this, _( "New Net Class Name:" ), wxEmptyString, class_name );
wxEmptyString, if( dlg.ShowModal() != wxID_OK )
class_name, return; // cancelled by user
this ) )
return; class_name = dlg.GetValue( );
class_name.Trim( true );
class_name.Trim( false );
if( class_name.IsEmpty() )
return; // empty name not allowed
// The name must dot exists: // The name must dot exists:
for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ ) for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ )
......
...@@ -84,20 +84,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues() ...@@ -84,20 +84,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues()
/* Modules: Edges width */ /* Modules: Edges width */
AddUnitSymbol( *m_EdgeModWidthTitle ); AddUnitSymbol( *m_EdgeModWidthTitle );
PutValueInLocalUnits( *m_OptModuleEdgesWidth, PutValueInLocalUnits( *m_OptModuleEdgesWidth,
ModuleSegmentWidth, PCB_INTERNAL_UNIT ); g_ModuleSegmentWidth, PCB_INTERNAL_UNIT );
/* Modules: Texts: Size & width */ /* Modules: Texts: Size & width */
AddUnitSymbol( *m_TextModWidthTitle ); AddUnitSymbol( *m_TextModWidthTitle );
PutValueInLocalUnits( *m_OptModuleTextWidth, PutValueInLocalUnits( *m_OptModuleTextWidth,
ModuleTextWidth, PCB_INTERNAL_UNIT ); g_ModuleTextWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextModSizeVTitle ); AddUnitSymbol( *m_TextModSizeVTitle );
PutValueInLocalUnits( *m_OptModuleTextVSize, PutValueInLocalUnits( *m_OptModuleTextVSize,
ModuleTextSize.y, PCB_INTERNAL_UNIT ); g_ModuleTextSize.y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextModSizeHTitle ); AddUnitSymbol( *m_TextModSizeHTitle );
PutValueInLocalUnits( *m_OptModuleTextHSize, PutValueInLocalUnits( *m_OptModuleTextHSize,
ModuleTextSize.x, PCB_INTERNAL_UNIT ); g_ModuleTextSize.x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_DefaultPenSizeTitle ); AddUnitSymbol( *m_DefaultPenSizeTitle );
PutValueInLocalUnits( *m_DefaultPenSizeCtrl, PutValueInLocalUnits( *m_DefaultPenSizeCtrl,
...@@ -118,13 +118,13 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event ) ...@@ -118,13 +118,13 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
m_BrdSettings->m_PcbTextSize.x = m_BrdSettings->m_PcbTextSize.x =
ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT );
ModuleSegmentWidth = g_ModuleSegmentWidth =
ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT );
ModuleTextWidth = g_ModuleTextWidth =
ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT );
ModuleTextSize.y = g_ModuleTextSize.y =
ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT );
ModuleTextSize.x = g_ModuleTextSize.x =
ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT );
g_DrawDefaultLineThickness = g_DrawDefaultLineThickness =
......
...@@ -49,7 +49,7 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -49,7 +49,7 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
/* /*
* Function to place a graphic item type EDGE_MODULE currently moved * Function to place a graphic item type EDGE_MODULE currently moved
*/ */
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
...@@ -59,7 +59,6 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -59,7 +59,6 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
Edge->m_Start0 -= MoveVector; Edge->m_Start0 -= MoveVector;
Edge->m_End0 -= MoveVector; Edge->m_End0 -= MoveVector;
Edge->Draw( DrawPanel, DC, GR_OR );
Edge->m_Flags = 0; Edge->m_Flags = 0;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
...@@ -67,6 +66,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) ...@@ -67,6 +66,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
OnModify(); OnModify();
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* Module = (MODULE*) Edge->GetParent();
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
DrawPanel->Refresh( );
} }
...@@ -86,8 +86,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -86,8 +86,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Edge->Draw( panel, DC, GR_XOR, MoveVector ); Edge->Draw( panel, DC, GR_XOR, MoveVector );
} }
MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); MoveVector = -(screen->m_Curseur - CursorInitialPosition);
MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y);
Edge->Draw( panel, DC, GR_XOR, MoveVector ); Edge->Draw( panel, DC, GR_XOR, MoveVector );
...@@ -124,27 +123,32 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -124,27 +123,32 @@ static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge ) /** Function Edit_Edge_Width
* changes the width of module perimeter lines, EDGE_MODULEs.
* param ModuleSegmentWidth (global) = new width
* @param aEdge = edge to edit, or NULL. If aEdge == NULL change
* the width of all footprint's edges
*/
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* aEdge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
SaveCopyInUndoList( Module, UR_MODEDIT ); SaveCopyInUndoList( Module, UR_MODEDIT );
if( Edge == NULL ) if( aEdge == NULL )
{ {
Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings; aEdge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() ) for( ; aEdge != NULL; aEdge = aEdge->Next() )
{ {
if( Edge->Type() != TYPE_EDGE_MODULE ) if( aEdge->Type() != TYPE_EDGE_MODULE )
continue; continue;
Edge->m_Width = ModuleSegmentWidth; aEdge->m_Width = g_ModuleSegmentWidth;
} }
} }
else else
Edge->m_Width = ModuleSegmentWidth; aEdge->m_Width = g_ModuleSegmentWidth;
OnModify(); OnModify();
DrawPanel->Refresh( TRUE );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
} }
...@@ -199,40 +203,32 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge ) ...@@ -199,40 +203,32 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
OnModify(); OnModify();
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
DrawPanel->Refresh( TRUE );
} }
/* Edition of the edge items width /** function Enter_Edge_Width
* Ask for a new width and init ModuleSegmentWidth. * Edition of the edge items width
* Change the width of EDGE_MODULE Edge if Edge != NULL * Ask for a new width.
* @param Edge = edge to edit, or NULL * Change the width of EDGE_MODULE Edge if aEdge != NULL
* @param DC = current Device Context * @param aEdge = edge to edit, or NULL
* @output ModuleSegmentWidth (global) = new width * @output ModuleSegmentWidth (global) = new width
*/ */
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* aEdge )
{ {
wxString buffer; wxString buffer;
long ll;
buffer << ModuleSegmentWidth; buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth, GetScreen()->GetInternalUnits() );
if( Get_Message( _( "New Width (1/10000\"):" ), _( "Edge Width" ), buffer, wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer );
this ) ) if( dlg.ShowModal() != wxID_OK )
return; return; // cancelled by user
if( buffer.ToLong( &ll ) ) buffer = dlg.GetValue( );
ModuleSegmentWidth = ll; g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() );
else
{ if( aEdge )
DisplayError( this, _( "Incorrect number, no change" ) );
return;
}
if( Edge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); aEdge->m_Width = g_ModuleSegmentWidth;
Edge->m_Width = ModuleSegmentWidth;
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
OnModify(); OnModify();
} }
...@@ -327,7 +323,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -327,7 +323,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
if( Edge->m_Shape == S_ARC ) if( Edge->m_Shape == S_ARC )
Edge->m_Angle = ArcValue; Edge->m_Angle = ArcValue;
Edge->m_Width = ModuleSegmentWidth; Edge->m_Width = g_ModuleSegmentWidth;
Edge->SetLayer( module->GetLayer() ); Edge->SetLayer( module->GetLayer() );
if( module->GetLayer() == LAYER_N_FRONT ) if( module->GetLayer() == LAYER_N_FRONT )
...@@ -376,7 +372,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -376,7 +372,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge = newedge; // point now new item Edge = newedge; // point now new item
Edge->m_Flags = IS_NEW; Edge->m_Flags = IS_NEW;
Edge->m_Width = ModuleSegmentWidth; Edge->m_Width = g_ModuleSegmentWidth;
Edge->m_Start = GetScreen()->m_Curseur; Edge->m_Start = GetScreen()->m_Curseur;
Edge->m_End = Edge->m_Start; Edge->m_End = Edge->m_Start;
...@@ -401,7 +397,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, ...@@ -401,7 +397,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
/* Terminate a move or create edge function /* Terminate a move or create edge function
*/ */
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
......
...@@ -45,11 +45,11 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) ...@@ -45,11 +45,11 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" ); Text->m_Text = wxT( "text" );
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth, g_ModuleTextWidth = Clamp_Text_PenSize( g_ModuleTextWidth,
MIN( ModuleTextSize.x, MIN( g_ModuleTextSize.x,
ModuleTextSize.y ), true ); g_ModuleTextSize.y ), true );
Text->m_Size = ModuleTextSize; Text->m_Size = g_ModuleTextSize;
Text->m_Width = ModuleTextWidth; Text->m_Width = g_ModuleTextWidth;
Text->m_Pos = GetScreen()->m_Curseur; Text->m_Pos = GetScreen()->m_Curseur;
Text->SetLocalCoord(); Text->SetLocalCoord();
......
...@@ -502,21 +502,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) ...@@ -502,21 +502,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "EdgeModWidth" ) == 0 ) if( stricmp( Line, "EdgeModWidth" ) == 0 )
{ {
ModuleSegmentWidth = atoi( data ); g_ModuleSegmentWidth = atoi( data );
continue; continue;
} }
if( stricmp( Line, "TextModWidth" ) == 0 ) if( stricmp( Line, "TextModWidth" ) == 0 )
{ {
ModuleTextWidth = atoi( data ); g_ModuleTextWidth = atoi( data );
continue; continue;
} }
if( stricmp( Line, "TextModSize" ) == 0 ) if( stricmp( Line, "TextModSize" ) == 0 )
{ {
ModuleTextSize.x = atoi( data ); g_ModuleTextSize.x = atoi( data );
data = strtok( NULL, " =\n\r" ); data = strtok( NULL, " =\n\r" );
ModuleTextSize.y = atoi( data ); g_ModuleTextSize.y = atoi( data );
continue; continue;
} }
...@@ -668,9 +668,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -668,9 +668,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
aBoard->GetBoardDesignSettings()->m_PcbTextSize.x, aBoard->GetBoardDesignSettings()->m_PcbTextSize.x,
aBoard->GetBoardDesignSettings()->m_PcbTextSize.y ); aBoard->GetBoardDesignSettings()->m_PcbTextSize.y );
fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth ); fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth ); fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth );
fprintf( aFile, fprintf( aFile,
"PadSize %d %d\n", "PadSize %d %d\n",
g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.x,
......
...@@ -45,7 +45,7 @@ static bool CreateDocLibrary( const wxString& LibName ); ...@@ -45,7 +45,7 @@ static bool CreateDocLibrary( const wxString& LibName );
* (One footprint per file, Newlib files have no special ext.) * (One footprint per file, Newlib files have no special ext.)
* @param DC = Current Device Context (can be NULL) * @param DC = Current Device Context (can be NULL)
*/ */
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) MODULE* WinEDA_ModuleEditFrame::Import_Module( )
{ {
int NbLine = 0; int NbLine = 0;
char Line[1024]; char Line[1024];
...@@ -129,7 +129,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -129,7 +129,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
/* Display info : */ /* Display info : */
module->DisplayInfo( this ); module->DisplayInfo( this );
Place_Module( module, DC ); Place_Module( module, NULL );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NetInfo->BuildListOfNets(); GetBoard()->m_NetInfo->BuildListOfNets();
...@@ -394,7 +394,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( ...@@ -394,7 +394,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library(
/** function Archive_Modules /** function Archive_Modules
* Save in the library: * Save in the library:
* All new modules (ie modules not found in this lib) (if NewModulesOnly == true) * All new modules (ie modules not found in this lib) (if NewModulesOnly == true)
* all modules (if NewModulesOnly == FALSE) * all modules (if NewModulesOnly == false)
*/ */
void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
bool NewModulesOnly ) bool NewModulesOnly )
...@@ -436,7 +436,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -436,7 +436,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
return; return;
} }
DrawPanel->m_AbortRequest = FALSE; DrawPanel->m_AbortRequest = false;
// Create a new, empty library if no old lib, or if archive all modules // Create a new, empty library if no old lib, or if archive all modules
if( !NewModulesOnly || !file_exists ) if( !NewModulesOnly || !file_exists )
...@@ -468,8 +468,8 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, ...@@ -468,8 +468,8 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() ) for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
{ {
if( Save_Module_In_Library( fileName, Module, if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? FALSE : true, NewModulesOnly ? false : true,
FALSE, false ) == 0 ) false, false ) == 0 )
break; break;
DisplayActivity( (int) ( ii * Pas ), wxEmptyString ); DisplayActivity( (int) ( ii * Pas ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */ /* Check for request to stop backup (ESCAPE key actuated) */
...@@ -522,11 +522,14 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -522,11 +522,14 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( aDisplayDialog ) if( aDisplayDialog )
{ {
int cancel = Get_Message( _( "Name:" ), _( "Save module" ), Name_Cmp, this ); wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( Name_Cmp.IsEmpty() || cancel ) if( dlg.ShowModal() != wxID_OK )
return 0; return 0; // cancelled by user
Name_Cmp = dlg.GetValue();
Name_Cmp.Trim( true ); Name_Cmp.Trim( true );
Name_Cmp.Trim( FALSE ); Name_Cmp.Trim( false );
if( Name_Cmp.IsEmpty() )
return 0;
aModule->m_LibRef = Name_Cmp; aModule->m_LibRef = Name_Cmp;
} }
...@@ -569,7 +572,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -569,7 +572,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is
* found */ * found */
{ {
added = FALSE; added = false;
newmodule = 0; newmodule = 0;
if( aDisplayDialog ) if( aDisplayDialog )
{ {
...@@ -711,32 +714,39 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName, ...@@ -711,32 +714,39 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
} }
/* Create a new module or footprint : A new module contains 2 texts : /** Function Create_1_Module
* First = REFERENCE * Creates a new module or footprint : A new module contains 2 texts :
* Second = VALUE: "VAL**" * First = REFERENCE
* the new module is added on beginning of the linked list of modules * Second = VALUE: "VAL**"
* the new module is added to the board module list
* @param aModuleName = name of the new footprint
* (will the component reference in board)
* @return a pointer to the new module
*/ */
MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName )
const wxString& module_name )
{ {
MODULE* Module; MODULE* Module;
wxString Line; wxString moduleName;
wxPoint newpos; wxPoint newpos;
moduleName = aModuleName;
/* Ask for the new module reference */ /* Ask for the new module reference */
if( module_name.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
if( Get_Message( _( "Module Reference:" ), wxTextEntryDialog dlg( this, _( "Module Reference:" ),
_( "Module Creation" ), Line, this ) != 0 ) _( "Module Creation" ), moduleName );
{ if( dlg.ShowModal() != wxID_OK )
DisplayInfoMessage( this, _( "No reference, aborted" ) ); return NULL; //Aborted by user
return NULL; moduleName = dlg.GetValue();
} }
moduleName.Trim( true );
moduleName.Trim( false );
if( moduleName.IsEmpty( ) )
{
DisplayInfoMessage( this, _( "No reference, aborted" ) );
return NULL;
} }
else
Line = module_name;
Line.Trim( true );
Line.Trim( FALSE );
// Creates the new module and add it to the head of the linked list of // Creates the new module and add it to the head of the linked list of
// modules // modules
...@@ -750,17 +760,17 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, ...@@ -750,17 +760,17 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC,
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
/* Update its name in lib */ /* Update its name in lib */
Module->m_LibRef = Line; Module->m_LibRef = moduleName;
/* Update reference: */ /* Update reference: */
Module->m_Reference->m_Text = Line; Module->m_Reference->m_Text = moduleName;
Module->m_Reference->SetWidth( ModuleTextWidth ); Module->m_Reference->SetWidth( g_ModuleTextWidth );
Module->m_Reference->m_Size = ModuleTextSize; Module->m_Reference->m_Size = g_ModuleTextSize;
/* Set the value field to a default value */ /* Set the value field to a default value */
Module->m_Value->m_Text = wxT( "VAL**" ); Module->m_Value->m_Text = wxT( "VAL**" );
Module->m_Value->SetWidth( ModuleTextWidth ); Module->m_Value->SetWidth( g_ModuleTextWidth );
Module->m_Value->m_Size = ModuleTextSize; Module->m_Value->m_Size = g_ModuleTextSize;
Module->SetPosition( wxPoint( 0, 0 ) ); Module->SetPosition( wxPoint( 0, 0 ) );
...@@ -844,21 +854,21 @@ static bool CreateDocLibrary( const wxString& LibName ) ...@@ -844,21 +854,21 @@ static bool CreateDocLibrary( const wxString& LibName )
LibMod = wxFopen( LibName, wxT( "rt" ) ); LibMod = wxFopen( LibName, wxT( "rt" ) );
if( LibMod == NULL ) if( LibMod == NULL )
return FALSE; return false;
/* Read library header. */ /* Read library header. */
GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ); GetLine( LibMod, Line, NULL, sizeof(Line) - 1 );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{ {
fclose( LibMod ); fclose( LibMod );
return FALSE; return false;
} }
LibDoc = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); LibDoc = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( LibDoc == NULL ) if( LibDoc == NULL )
{ {
fclose( LibMod ); fclose( LibMod );
return FALSE; return false;
} }
fprintf( LibDoc, ENTETE_LIBDOC ); fprintf( LibDoc, ENTETE_LIBDOC );
fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) ); fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) );
......
...@@ -237,7 +237,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -237,7 +237,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
MODULE* module = Create_1_Module( NULL, wxEmptyString ); MODULE* module = Create_1_Module( wxEmptyString );
if( module ) // i.e. if create module command not aborted if( module ) // i.e. if create module command not aborted
{ {
// Initialize data relative to nets and netclasses (for a new // Initialize data relative to nets and netclasses (for a new
...@@ -350,7 +350,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -350,7 +350,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
SetCurItem( NULL ); SetCurItem( NULL );
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
Import_Module( NULL ); Import_Module( );
redraw = true; redraw = true;
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0; GetBoard()->m_Modules->m_Flags = 0;
...@@ -579,7 +579,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -579,7 +579,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) ) if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) )
{ {
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc ); End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
} }
break; break;
...@@ -588,34 +588,40 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -588,34 +588,40 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
EDGE_MODULE* edge = NULL; EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem() if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->m_Flags & IS_NEW )
&& ( GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE ) ) && ( GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE ) )
{ {
edge = (EDGE_MODULE*) GetScreen()->GetCurItem(); edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
} }
Enter_Edge_Width( edge, &dc ); Enter_Edge_Width( edge );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( edge )
DrawPanel->Refresh();
} }
break; break;
case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE: case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() ); Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
break; break;
case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE: case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Edit_Edge_Width( NULL ); Edit_Edge_Width( NULL );
DrawPanel->Refresh( );
break; break;
case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE: case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() ); Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
break; break;
case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE: case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Edit_Edge_Layer( NULL ); Edit_Edge_Layer( NULL );
DrawPanel->Refresh( );
break; break;
case ID_POPUP_PCB_DELETE_EDGE: case ID_POPUP_PCB_DELETE_EDGE:
......
...@@ -36,7 +36,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -36,7 +36,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC ); Place_EdgeMod( (EDGE_MODULE*) DrawStruct );
break; break;
case TYPE_PAD: case TYPE_PAD:
...@@ -93,13 +93,15 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), ...@@ -93,13 +93,15 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
{ {
if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE ) if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE )
{ {
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->Refresh();
} }
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC ) else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC )
{ {
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->Refresh();
} }
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT ) else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT )
{ {
...@@ -437,8 +439,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -437,8 +439,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{ {
if( DrawStruct && ( DrawStruct->m_Flags & IS_NEW ) ) if( DrawStruct && ( DrawStruct->m_Flags & IS_NEW ) )
{ {
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC ); End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->Refresh();
} }
break; break;
} }
......
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
static void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC );
static MODULE* s_ModuleInitialCopy = NULL; // Copy of module for static MODULE* s_ModuleInitialCopy = NULL; /* Copy of module for
// abort/undo command * abort/undo command
static PICKED_ITEMS_LIST s_PickedList; // a picked list to */
// save initial module static PICKED_ITEMS_LIST s_PickedList; /* a picked list to
// and dragged tracks * save initial module
* and dragged tracks
*/
/* Show or hide module pads. /* Show or hide module pads.
...@@ -64,16 +66,22 @@ void Rastnest_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module ) ...@@ -64,16 +66,22 @@ void Rastnest_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module )
*/ */
MODULE* WinEDA_BasePcbFrame::GetModuleByName() MODULE* WinEDA_BasePcbFrame::GetModuleByName()
{ {
wxString modulename; wxString moduleName;
MODULE* module = NULL; MODULE* module = NULL;
Get_Message( _( "Name:" ), _( "Search footprint" ), modulename, this ); wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName );
if( !modulename.IsEmpty() ) if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user
moduleName = dlg.GetValue();
moduleName.Trim( true );
moduleName.Trim( false );
if( !moduleName.IsEmpty() )
{ {
module = GetBoard()->m_Modules; module = GetBoard()->m_Modules;
while( module ) while( module )
{ {
if( module->m_Reference->m_Text.CmpNoCase( modulename ) == 0 ) if( module->m_Reference->m_Text.CmpNoCase( moduleName ) == 0 )
break; break;
module = module->Next(); module = module->Next();
} }
...@@ -101,7 +109,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -101,7 +109,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
module->m_Flags |= IS_MOVED; module->m_Flags |= IS_MOVED;
/* Show ratsnest. */ /* Show ratsnest. */
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Should not occur ! */ if( g_DragSegmentList ) /* Should not occur ! */
...@@ -221,7 +229,7 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -221,7 +229,7 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
// Display ratsnest is allowed // Display ratsnest is allowed
pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
if( pcbframe->GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) if( pcbframe->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
pcbframe->DrawGeneralRatsnest( DC ); pcbframe->DrawGeneralRatsnest( DC );
} }
...@@ -304,9 +312,9 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, ...@@ -304,9 +312,9 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module,
/* Confirm module delete. */ /* Confirm module delete. */
if( aAskBeforeDeleting ) if( aAskBeforeDeleting )
{ {
msg.Printf( _( "Delete Module %s (value %s) ?"), msg.Printf( _( "Delete Module %s (value %s) ?" ),
GetChars(module->m_Reference->m_Text), GetChars( module->m_Reference->m_Text ),
GetChars(module->m_Value->m_Text) ); GetChars( module->m_Value->m_Text ) );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
{ {
return FALSE; return FALSE;
...@@ -324,7 +332,7 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, ...@@ -324,7 +332,7 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module,
// Redraw the full screen to ensure perfect display of board and ratsnest. // Redraw the full screen to ensure perfect display of board and ratsnest.
if( DC ) if( DC )
DrawPanel->Refresh( ); DrawPanel->Refresh();
return true; return true;
} }
...@@ -344,13 +352,13 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -344,13 +352,13 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
if( Module == NULL ) if( Module == NULL )
return; return;
if( ( Module->GetLayer() != LAYER_N_FRONT ) if( ( Module->GetLayer() != LAYER_N_FRONT )
&& ( Module->GetLayer() != LAYER_N_BACK ) ) && ( Module->GetLayer() != LAYER_N_BACK ) )
return; return;
OnModify(); OnModify();
if( !( Module->m_Flags & IS_MOVED ) ) /* This is a simple flip, no other if( !( Module->m_Flags & IS_MOVED ) ) /* This is a simple flip, no other
*edition in progress */ *edition in progress */
{ {
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK ); GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK );
if( DC ) if( DC )
...@@ -362,7 +370,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -362,7 +370,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
} }
/* Show ratsnest if necessary. */ /* Show ratsnest if necessary. */
if( DC && GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) if( DC && GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
g_Offset_Module.x = 0; g_Offset_Module.x = 0;
...@@ -450,7 +458,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, ...@@ -450,7 +458,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
newpos = GetScreen()->m_Curseur; newpos = GetScreen()->m_Curseur;
module->SetPosition( newpos ); module->SetPosition( newpos );
module->m_Flags = 0; module->m_Flags = 0;
delete s_ModuleInitialCopy; delete s_ModuleInitialCopy;
s_ModuleInitialCopy = NULL; s_ModuleInitialCopy = NULL;
...@@ -483,10 +491,9 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, ...@@ -483,10 +491,9 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
Compile_Ratsnest( DC, true ); Compile_Ratsnest( DC, true );
if( DC ) if( DC )
DrawPanel->Refresh( ); DrawPanel->Refresh();
module->DisplayInfo( this ); module->DisplayInfo( this );
} }
...@@ -515,7 +522,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module, ...@@ -515,7 +522,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
DrawPanel->PostDirtyRect( module->GetBoundingBox() ); DrawPanel->PostDirtyRect( module->GetBoundingBox() );
module->m_Flags = tmp; module->m_Flags = tmp;
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
} }
} }
...@@ -540,18 +547,20 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module, ...@@ -540,18 +547,20 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
if( DC ) if( DC )
{ {
if( !( module->m_Flags & IS_MOVED ) ) if( !( module->m_Flags & IS_MOVED ) )
{ // not beiing moved: redraw the module and update ratsnest {
// not beiing moved: redraw the module and update ratsnest
module->Draw( DrawPanel, DC, GR_OR ); module->Draw( DrawPanel, DC, GR_OR );
Compile_Ratsnest( DC, true ); Compile_Ratsnest( DC, true );
} }
else else
{ // Beiing moved: just redraw it {
// Beiing moved: just redraw it
DrawModuleOutlines( DrawPanel, DC, module ); DrawModuleOutlines( DrawPanel, DC, module );
Dessine_Segments_Dragges( DrawPanel, DC ); Dessine_Segments_Dragges( DrawPanel, DC );
} }
if( module->m_Flags == 0 ) // module not in edit: redraw full screen if( module->m_Flags == 0 ) // module not in edit: redraw full screen
DrawPanel->Refresh( ); DrawPanel->Refresh();
} }
} }
......
...@@ -177,8 +177,6 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -177,8 +177,6 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
{ {
D_PAD* PtPad; D_PAD* PtPad;
int ll; int ll;
double fcoeff;
bool abort = FALSE;
wxString msg; wxString msg;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -200,28 +198,13 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -200,28 +198,13 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
Mself.lng = min_len; Mself.lng = min_len;
/* Enter the desired length. */ /* Enter the desired length. */
if( !g_UserUnit ) msg = ReturnStringFromValue( g_UserUnit, Mself.lng, GetScreen()->GetInternalUnits() );
{ wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg );
fcoeff = 10000.0; if( dlg.ShowModal() != wxID_OK )
msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff ); return NULL; // cancelled by user
abort = Get_Message( _( "Length(inch):" ), _( "Length" ), msg, this );
}
else
{
fcoeff = 10000.0 / 25.4;
msg.Printf( wxT( "%2.3f" ), Mself.lng / fcoeff );
abort = Get_Message( _( "Length(mm):" ), _( "Length" ), msg, this );
}
if( abort )
return NULL;
double fval; msg = dlg.GetValue();
if( !msg.ToDouble( &fval ) ) Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
{
DisplayError( this, _( "Incorrect number, abort" ) );
return NULL;
}
Mself.lng = wxRound( fval * fcoeff );
/* Control values (ii = minimum length) */ /* Control values (ii = minimum length) */
if( Mself.lng < min_len ) if( Mself.lng < min_len )
...@@ -245,7 +228,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) ...@@ -245,7 +228,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
/* Generate module. */ /* Generate module. */
MODULE* Module; MODULE* Module;
Module = Create_1_Module( NULL, wxEmptyString ); Module = Create_1_Module( wxEmptyString );
if( Module == NULL ) if( Module == NULL )
return NULL; return NULL;
...@@ -330,7 +313,7 @@ static void gen_arc( std::vector <wxPoint>& aBuffer, ...@@ -330,7 +313,7 @@ static void gen_arc( std::vector <wxPoint>& aBuffer,
{ {
#define SEGM_COUNT_PER_360DEG 16 #define SEGM_COUNT_PER_360DEG 16
wxPoint first_point = aStartPoint - aCenter; wxPoint first_point = aStartPoint - aCenter;
int seg_count = ( (abs( a_ArcAngle ) ) * SEGM_COUNT_PER_360DEG) / 3600; int seg_count = ( ( abs( a_ArcAngle ) ) * SEGM_COUNT_PER_360DEG ) / 3600;
if( seg_count == 0 ) if( seg_count == 0 )
seg_count = 1; seg_count = 1;
...@@ -395,7 +378,7 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer, ...@@ -395,7 +378,7 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
* Increasing the number of segments to the desired length * Increasing the number of segments to the desired length
* (radius decreases if necessary) * (radius decreases if necessary)
*/ */
wxSize size; wxSize size;
// This scale factor adjust the arc lenght to handle // This scale factor adjust the arc lenght to handle
// the arc to segment approximation. // the arc to segment approximation.
...@@ -445,11 +428,11 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer, ...@@ -445,11 +428,11 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
} }
} }
segm_len = size.x - ( radius * 2 ); segm_len = size.x - ( radius * 2 );
full_len = 2 * stubs_len; // Length of coil connections. full_len = 2 * stubs_len; // Length of coil connections.
full_len += segm_len * segm_count; // Length of full length segments. full_len += segm_len * segm_count; // Length of full length segments.
full_len += wxRound( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius ); // Ard arcs len full_len += wxRound( ( segm_count + 2 ) * M_PI * ADJUST_SIZE * radius ); // Ard arcs len
full_len += segm_len - (2 * radius); // Length of first and last segments full_len += segm_len - (2 * radius); // Length of first and last segments
// (half size segments len = segm_len/2 - radius). // (half size segments len = segm_len/2 - radius).
if( full_len >= aLength ) if( full_len >= aLength )
break; break;
...@@ -457,8 +440,9 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer, ...@@ -457,8 +440,9 @@ int BuildCornersList_S_Shape( std::vector <wxPoint>& aBuffer,
// Adjust len by adjusting segm_len: // Adjust len by adjusting segm_len:
int delta_size = full_len - aLength; int delta_size = full_len - aLength;
// reduce len of the segm_count segments + 2 half size segments (= 1 full size segment) // reduce len of the segm_count segments + 2 half size segments (= 1 full size segment)
segm_len -= delta_size / (segm_count+1); segm_len -= delta_size / (segm_count + 1);
// Generate first line (the first stub) and first arc (90 deg arc) // Generate first line (the first stub) and first arc (90 deg arc)
pt = aStartPoint; pt = aStartPoint;
...@@ -537,19 +521,25 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name, ...@@ -537,19 +521,25 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
int pad_num = 1; int pad_num = 1;
wxString Line; wxString Line;
Module = Create_1_Module( NULL, name ); Module = Create_1_Module( name );
if( Module == NULL ) if( Module == NULL )
return NULL; return NULL;
#define DEFAULT_SIZE 30
Module->m_TimeStamp = GetTimeStamp(); Module->m_TimeStamp = GetTimeStamp();
Module->m_Value->m_Size = wxSize( 30, 30 ); Module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Value->m_Pos0.y = -30; Module->m_Value->m_Pos0.y = -DEFAULT_SIZE;
Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y; Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y;
Module->m_Reference->m_Size = wxSize( 30, 30 ); Module->m_Value->m_Width = DEFAULT_SIZE / 4;
Module->m_Reference->m_Pos0.y = 30; Module->m_Reference->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE );
Module->m_Reference->m_Pos0.y = DEFAULT_SIZE;
Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y; Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y;
Module->m_Reference->m_Width = DEFAULT_SIZE / 4;
/* Create dots forming the gap. */ /* Create 2 pads used in gaps and stubs.
* The gap is between these 2 pads
* the stub is the pad 2
*/
while( pad_count-- ) while( pad_count-- )
{ {
D_PAD* pad = new D_PAD( Module ); D_PAD* pad = new D_PAD( Module );
...@@ -570,33 +560,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name, ...@@ -570,33 +560,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
} }
#if 0
static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
{
MODULE* Module = (MODULE*) frame->GetScreen()->GetCurItem();
if( Module )
{
if( Module->m_Flags & IS_NEW )
{
Module->Draw( frame->DrawPanel, DC, GR_XOR );
Module->DeleteStructure();
}
else
{
Module->Draw( frame->DrawPanel, DC, GR_XOR );
}
}
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->SetCurItem( NULL );
}
#endif
/* Create a module "GAP" or "STUB" /* Create a module "GAP" or "STUB"
* This a "gap" or "stub" used in micro wave designs * This a "gap" or "stub" used in micro wave designs
* This module has 2 pads: * This module has 2 pads:
...@@ -606,13 +569,11 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC ) ...@@ -606,13 +569,11 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
{ {
int oX; int oX;
float fcoeff;
D_PAD* pad; D_PAD* pad;
MODULE* Module; MODULE* Module;
wxString msg, cmp_name; wxString msg, cmp_name;
int pad_count = 2; int pad_count = 2;
int angle = 0; int angle = 0;
bool abort;
/* Enter the size of the gap or stub*/ /* Enter the size of the gap or stub*/
int gap_size = GetBoard()->GetCurrentTrackWidth(); int gap_size = GetBoard()->GetCurrentTrackWidth();
...@@ -641,36 +602,32 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) ...@@ -641,36 +602,32 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
break; break;
} }
wxString value; wxString value = ReturnStringFromValue( g_UserUnit, gap_size,
if( g_UserUnit ) GetScreen()->GetInternalUnits() );
{ wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value );
fcoeff = 10000.0f / 25.4f; if( dlg.ShowModal() != wxID_OK )
value.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
msg += _( " (mm):" );
}
else
{ {
fcoeff = 10000.0; DrawPanel->MouseToCursorSchema();
value.Printf( wxT( "%2.3f" ), gap_size / fcoeff ); return NULL; // cancelled by user
msg += _( " (inch):" );
} }
abort = Get_Message( msg, _( "Create microwave module" ), value, this );
double fval; value = dlg.GetValue();
if( !value.ToDouble( &fval ) ) gap_size = ReturnValueFromString( g_UserUnit, value, GetScreen()->GetInternalUnits() );
{
DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE;
}
gap_size = ABS( wxRound( fval * fcoeff ) );
if( !abort && ( shape_type == 2 ) ) bool abort = false;
if( shape_type == 2 )
{ {
fcoeff = 10.0; double fcoeff = 10.0, fval;
value.Printf( wxT( "%3.1f" ), angle / fcoeff ); msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
msg = _( "Angle (0.1deg):" ); wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _(
abort = Get_Message( msg, _( "Create microwave module" ), value, this ); "Create microwave module" ), msg );
if( !value.ToDouble( &fval ) ) if( angledlg.ShowModal() != wxID_OK )
{
DrawPanel->MouseToCursorSchema();
return NULL; // cancelled by user
}
msg = angledlg.GetValue();
if( !msg.ToDouble( &fval ) )
{ {
DisplayError( this, _( "Incorrect number, abort" ) ); DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE; abort = TRUE;
...@@ -1100,7 +1057,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape() ...@@ -1100,7 +1057,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape()
void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module ) void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
{ {
int gap_size, oX; int gap_size, oX;
float fcoeff;
D_PAD* pad, * next_pad; D_PAD* pad, * next_pad;
wxString msg; wxString msg;
...@@ -1130,27 +1086,14 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module ) ...@@ -1130,27 +1086,14 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
/* Calculate the current dimension. */ /* Calculate the current dimension. */
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x; gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
/* Entrance to the desired length of the gap. */ /* Entrer the desired length of the gap. */
if( g_UserUnit ) msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() );
{ wxTextEntryDialog dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg );
fcoeff = 10000.0f / 25.4f; if( dlg.ShowModal() != wxID_OK )
msg.Printf( wxT( "%2.3f" ), gap_size / fcoeff ); return; // cancelled by user
Get_Message( _( "Gap (mm):" ), _( "Create Microwave Gap" ), msg, this );
}
else
{
fcoeff = 10000.0;
msg.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
Get_Message( _( "Gap (inch):" ), _( "Create Microwave Gap" ), msg,
this );
}
if( !msg.IsEmpty() ) msg = dlg.GetValue();
{ gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
double fval;
if( msg.ToDouble( &fval ) )
gap_size = (int) ( fval * fcoeff );
}
/* Updating sizes of pads forming the gap. */ /* Updating sizes of pads forming the gap. */
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
......
...@@ -49,8 +49,9 @@ bool Segments_45_Only; // True to allow horiz, vert. an ...@@ -49,8 +49,9 @@ bool Segments_45_Only; // True to allow horiz, vert. an
bool g_TwoSegmentTrackBuild = true; bool g_TwoSegmentTrackBuild = true;
bool g_HighLight_Status; bool g_HighLight_Status;
int ModuleSegmentWidth; wxSize g_ModuleTextSize; /* Default footprint texts size */
int ModuleTextWidth; int g_ModuleSegmentWidth;
int g_ModuleTextWidth;
int Route_Layer_TOP; int Route_Layer_TOP;
int Route_Layer_BOTTOM; int Route_Layer_BOTTOM;
int g_MaxLinksShowed; int g_MaxLinksShowed;
...@@ -58,7 +59,6 @@ int g_MagneticPadOption = capture_cursor_in_track_tool; ...@@ -58,7 +59,6 @@ int g_MagneticPadOption = capture_cursor_in_track_tool;
int g_MagneticTrackOption = capture_cursor_in_track_tool; int g_MagneticTrackOption = capture_cursor_in_track_tool;
int g_HighLight_NetCode = -1; int g_HighLight_NetCode = -1;
wxSize ModuleTextSize; /* Default footprint texts size */
wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ wxPoint g_Offset_Module; /* Offset de trace du modul en depl */
wxString g_Current_PadName; // Last used pad name (pad num) wxString g_Current_PadName; // Last used pad name (pad num)
......
...@@ -67,9 +67,9 @@ extern wxString g_Shapes3DExtBuffer; ...@@ -67,9 +67,9 @@ extern wxString g_Shapes3DExtBuffer;
extern wxString g_DocModulesFileName; extern wxString g_DocModulesFileName;
/* Variables used in footprint handling */ /* Variables used in footprint handling */
extern wxSize ModuleTextSize; /* Default footprint texts size */ extern wxSize g_ModuleTextSize; /* Default footprint texts size */
extern int ModuleTextWidth; extern int g_ModuleTextWidth;
extern int ModuleSegmentWidth; extern int g_ModuleSegmentWidth;
/* Layer pair for auto routing and switch layers by hotkey */ /* Layer pair for auto routing and switch layers by hotkey */
extern int Route_Layer_TOP; extern int Route_Layer_TOP;
......
...@@ -248,11 +248,11 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters() ...@@ -248,11 +248,11 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ), m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ),
&boardDesignSettings.m_PcbTextSize.x, &boardDesignSettings.m_PcbTextSize.x,
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); 600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &ModuleTextSize.y, m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &g_ModuleTextSize.y,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); 500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &ModuleTextSize.x, m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &g_ModuleTextSize.x,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ); 500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &ModuleTextWidth, m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &g_ModuleTextWidth,
100, 1, TEXTS_MAX_WIDTH ) ); 100, 1, TEXTS_MAX_WIDTH ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ), m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ),
&boardDesignSettings.m_SolderMaskMargin, &boardDesignSettings.m_SolderMaskMargin,
...@@ -266,7 +266,7 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters() ...@@ -266,7 +266,7 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ), m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ),
&boardDesignSettings.m_PcbTextWidth, &boardDesignSettings.m_PcbTextWidth,
120, 0, 0xFFFF ) ); 120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &ModuleSegmentWidth, m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &g_ModuleSegmentWidth,
120, 0, 0xFFFF ) ); 120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LastNetListRead" ), m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LastNetListRead" ),
&m_lastNetListRead ) ); &m_lastNetListRead ) );
......
...@@ -30,8 +30,11 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event ) ...@@ -30,8 +30,11 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
int selection; int selection;
netFilter = wxT( "*" ); netFilter = wxT( "*" );
Get_Message( _( "Filter for net names:" ), _( "Net Filter" ), wxTextEntryDialog dlg( this, _( "Filter for net names:" ), _( "Net Filter" ), netFilter );
netFilter, this ); if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
netFilter = dlg.GetValue( );
if( netFilter.IsEmpty() ) if( netFilter.IsEmpty() )
return; return;
......
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