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

code cleaning.

parent 5605ce89
......@@ -114,32 +114,3 @@ bool IsOK( wxWindow* parent, const wxString& text )
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;
}
......@@ -16,10 +16,4 @@ void DisplayInfoMessage( 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__ */
......@@ -226,8 +226,16 @@ public:
virtual void OnModify( );
// Modules (footprints)
MODULE* Create_1_Module( wxDC* DC,
const wxString& module_name );
/** Function Create_1_Module
* 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 Rotate_Module( wxDC* DC,
MODULE* module,
......
......@@ -1178,9 +1178,20 @@ public:
void RemoveStruct( EDA_BaseStruct* Item );
void Transform( MODULE* module, int transform );
// loading/exporting Footprint
MODULE* Import_Module( wxDC* DC );
// importing / exporting Footprint
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
* load in Modedit a footfrint from the main board
......@@ -1198,22 +1209,27 @@ public:
// functions to edit footprint edges
/**
* Function Edit_Edge_Width
/** Function Edit_Edge_Width
* changes the width of module perimeter lines, EDGE_MODULEs.
* @param ModuleSegmentWidth (global) = new width
* @param Edge = edge to edit, or NULL. If Edge == NULL change
* the width of all the footprint's edges
* @param DC = current Device Context
* param ModuleSegmentWidth (global) = new width
* @param aEdge = edge to edit, or NULL. If aEdge == NULL change
* the width of all footprint's edges
*/
void Edit_Edge_Width( EDGE_MODULE* Edge );
void Edit_Edge_Width( EDGE_MODULE* aEdge );
void Edit_Edge_Layer( EDGE_MODULE* Edge );
void Delete_Edge_Module( EDGE_MODULE* Edge );
EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
void End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC );
void Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC );
void End_Edge_Module( EDGE_MODULE* Edge );
/** 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 Place_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
void Place_EdgeMod( EDGE_MODULE* drawitem );
// handlers for libraries:
void Delete_Module_In_Library( const wxString& libname );
......
......@@ -84,20 +84,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues()
/* Modules: Edges width */
AddUnitSymbol( *m_EdgeModWidthTitle );
PutValueInLocalUnits( *m_OptModuleEdgesWidth,
ModuleSegmentWidth, PCB_INTERNAL_UNIT );
g_ModuleSegmentWidth, PCB_INTERNAL_UNIT );
/* Modules: Texts: Size & width */
AddUnitSymbol( *m_TextModWidthTitle );
PutValueInLocalUnits( *m_OptModuleTextWidth,
ModuleTextWidth, PCB_INTERNAL_UNIT );
g_ModuleTextWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextModSizeVTitle );
PutValueInLocalUnits( *m_OptModuleTextVSize,
ModuleTextSize.y, PCB_INTERNAL_UNIT );
g_ModuleTextSize.y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextModSizeHTitle );
PutValueInLocalUnits( *m_OptModuleTextHSize,
ModuleTextSize.x, PCB_INTERNAL_UNIT );
g_ModuleTextSize.x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_DefaultPenSizeTitle );
PutValueInLocalUnits( *m_DefaultPenSizeCtrl,
......@@ -118,13 +118,13 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
m_BrdSettings->m_PcbTextSize.x =
ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT );
ModuleSegmentWidth =
g_ModuleSegmentWidth =
ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT );
ModuleTextWidth =
g_ModuleTextWidth =
ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT );
ModuleTextSize.y =
g_ModuleTextSize.y =
ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT );
ModuleTextSize.x =
g_ModuleTextSize.x =
ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT );
g_DrawDefaultLineThickness =
......
......@@ -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
*/
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge )
{
if( Edge == NULL )
return;
......@@ -59,7 +59,6 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
Edge->m_Start0 -= MoveVector;
Edge->m_End0 -= MoveVector;
Edge->Draw( DrawPanel, DC, GR_OR );
Edge->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
......@@ -67,6 +66,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
OnModify();
MODULE* Module = (MODULE*) Edge->GetParent();
Module->Set_Rectangle_Encadrement();
DrawPanel->Refresh( );
}
......@@ -86,8 +86,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Edge->Draw( panel, DC, GR_XOR, MoveVector );
}
MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x);
MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y);
MoveVector = -(screen->m_Curseur - CursorInitialPosition);
Edge->Draw( panel, DC, GR_XOR, MoveVector );
......@@ -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;
SaveCopyInUndoList( Module, UR_MODEDIT );
if( Edge == NULL )
if( aEdge == NULL )
{
Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() )
aEdge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; aEdge != NULL; aEdge = aEdge->Next() )
{
if( Edge->Type() != TYPE_EDGE_MODULE )
if( aEdge->Type() != TYPE_EDGE_MODULE )
continue;
Edge->m_Width = ModuleSegmentWidth;
aEdge->m_Width = g_ModuleSegmentWidth;
}
}
else
Edge->m_Width = ModuleSegmentWidth;
aEdge->m_Width = g_ModuleSegmentWidth;
OnModify();
DrawPanel->Refresh( TRUE );
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
}
......@@ -199,40 +203,32 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
OnModify();
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
DrawPanel->Refresh( TRUE );
}
/* Edition of the edge items width
* Ask for a new width and init ModuleSegmentWidth.
* Change the width of EDGE_MODULE Edge if Edge != NULL
* @param Edge = edge to edit, or NULL
* @param DC = current Device Context
/** 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 WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* aEdge )
{
wxString buffer;
long ll;
buffer << ModuleSegmentWidth;
if( Get_Message( _( "New Width (1/10000\"):" ), _( "Edge Width" ), buffer,
this ) )
return;
buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth, GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
if( buffer.ToLong( &ll ) )
ModuleSegmentWidth = ll;
else
{
DisplayError( this, _( "Incorrect number, no change" ) );
return;
}
if( Edge )
buffer = dlg.GetValue( );
g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() );
if( aEdge )
{
MODULE* Module = GetBoard()->m_Modules;
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
Edge->m_Width = ModuleSegmentWidth;
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
aEdge->m_Width = g_ModuleSegmentWidth;
Module->Set_Rectangle_Encadrement();
OnModify();
}
......@@ -327,7 +323,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
if( Edge->m_Shape == S_ARC )
Edge->m_Angle = ArcValue;
Edge->m_Width = ModuleSegmentWidth;
Edge->m_Width = g_ModuleSegmentWidth;
Edge->SetLayer( module->GetLayer() );
if( module->GetLayer() == LAYER_N_FRONT )
......@@ -376,7 +372,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
Edge = newedge; // point now new item
Edge->m_Flags = IS_NEW;
Edge->m_Width = ModuleSegmentWidth;
Edge->m_Width = g_ModuleSegmentWidth;
Edge->m_Start = GetScreen()->m_Curseur;
Edge->m_End = Edge->m_Start;
......@@ -401,7 +397,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
/* 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;
......
......@@ -45,11 +45,11 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" );
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth,
MIN( ModuleTextSize.x,
ModuleTextSize.y ), true );
Text->m_Size = ModuleTextSize;
Text->m_Width = ModuleTextWidth;
g_ModuleTextWidth = Clamp_Text_PenSize( g_ModuleTextWidth,
MIN( g_ModuleTextSize.x,
g_ModuleTextSize.y ), true );
Text->m_Size = g_ModuleTextSize;
Text->m_Width = g_ModuleTextWidth;
Text->m_Pos = GetScreen()->m_Curseur;
Text->SetLocalCoord();
......
......@@ -502,21 +502,21 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "EdgeModWidth" ) == 0 )
{
ModuleSegmentWidth = atoi( data );
g_ModuleSegmentWidth = atoi( data );
continue;
}
if( stricmp( Line, "TextModWidth" ) == 0 )
{
ModuleTextWidth = atoi( data );
g_ModuleTextWidth = atoi( data );
continue;
}
if( stricmp( Line, "TextModSize" ) == 0 )
{
ModuleTextSize.x = atoi( data );
g_ModuleTextSize.x = atoi( data );
data = strtok( NULL, " =\n\r" );
ModuleTextSize.y = atoi( data );
g_ModuleTextSize.y = atoi( data );
continue;
}
......@@ -668,9 +668,9 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
aBoard->GetBoardDesignSettings()->m_PcbTextSize.x,
aBoard->GetBoardDesignSettings()->m_PcbTextSize.y );
fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth );
fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth );
fprintf( aFile,
"PadSize %d %d\n",
g_Pad_Master.m_Size.x,
......
......@@ -45,7 +45,7 @@ static bool CreateDocLibrary( const wxString& LibName );
* (One footprint per file, Newlib files have no special ext.)
* @param DC = Current Device Context (can be NULL)
*/
MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
MODULE* WinEDA_ModuleEditFrame::Import_Module( )
{
int NbLine = 0;
char Line[1024];
......@@ -129,7 +129,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
/* Display info : */
module->DisplayInfo( this );
Place_Module( module, DC );
Place_Module( module, NULL );
GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NetInfo->BuildListOfNets();
......@@ -394,7 +394,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library(
/** function Archive_Modules
* Save in the library:
* 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,
bool NewModulesOnly )
......@@ -436,7 +436,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
return;
}
DrawPanel->m_AbortRequest = FALSE;
DrawPanel->m_AbortRequest = false;
// Create a new, empty library if no old lib, or if archive all modules
if( !NewModulesOnly || !file_exists )
......@@ -468,8 +468,8 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
{
if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? FALSE : true,
FALSE, false ) == 0 )
NewModulesOnly ? false : true,
false, false ) == 0 )
break;
DisplayActivity( (int) ( ii * Pas ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */
......@@ -522,11 +522,13 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( aDisplayDialog )
{
int cancel = Get_Message( _( "Name:" ), _( "Save module" ), Name_Cmp, this );
if( Name_Cmp.IsEmpty() || cancel )
return 0;
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( dlg.ShowModal() != wxID_OK )
return 0; // cancelled by user
Name_Cmp.Trim( true );
Name_Cmp.Trim( FALSE );
Name_Cmp.Trim( false );
if( Name_Cmp.IsEmpty() )
return 0;
aModule->m_LibRef = Name_Cmp;
}
......@@ -569,7 +571,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is
* found */
{
added = FALSE;
added = false;
newmodule = 0;
if( aDisplayDialog )
{
......@@ -711,32 +713,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
* Creates a new module or footprint : A new module contains 2 texts :
* First = REFERENCE
* Second = VALUE: "VAL**"
* the new module is added on beginning of the linked list of modules
* 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,
const wxString& module_name )
MODULE* WinEDA_BasePcbFrame::Create_1_Module( const wxString& aModuleName )
{
MODULE* Module;
wxString Line;
wxString moduleName;
wxPoint newpos;
moduleName = aModuleName;
/* Ask for the new module reference */
if( module_name.IsEmpty() )
if( moduleName.IsEmpty() )
{
if( Get_Message( _( "Module Reference:" ),
_( "Module Creation" ), Line, this ) != 0 )
wxTextEntryDialog dlg( this, _( "Module Reference:" ),
_( "Module Creation" ), moduleName );
int diag = dlg.ShowModal();
if( diag != wxID_OK )
return NULL; //Aborted by user
}
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
// modules
......@@ -750,17 +759,17 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC,
Module->m_LastEdit_Time = time( NULL );
/* Update its name in lib */
Module->m_LibRef = Line;
Module->m_LibRef = moduleName;
/* Update reference: */
Module->m_Reference->m_Text = Line;
Module->m_Reference->SetWidth( ModuleTextWidth );
Module->m_Reference->m_Size = ModuleTextSize;
Module->m_Reference->m_Text = moduleName;
Module->m_Reference->SetWidth( g_ModuleTextWidth );
Module->m_Reference->m_Size = g_ModuleTextSize;
/* Set the value field to a default value */
Module->m_Value->m_Text = wxT( "VAL**" );
Module->m_Value->SetWidth( ModuleTextWidth );
Module->m_Value->m_Size = ModuleTextSize;
Module->m_Value->SetWidth( g_ModuleTextWidth );
Module->m_Value->m_Size = g_ModuleTextSize;
Module->SetPosition( wxPoint( 0, 0 ) );
......@@ -844,21 +853,21 @@ static bool CreateDocLibrary( const wxString& LibName )
LibMod = wxFopen( LibName, wxT( "rt" ) );
if( LibMod == NULL )
return FALSE;
return false;
/* Read library header. */
GetLine( LibMod, Line, NULL, sizeof(Line) - 1 );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
fclose( LibMod );
return FALSE;
return false;
}
LibDoc = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( LibDoc == NULL )
{
fclose( LibMod );
return FALSE;
return false;
}
fprintf( LibDoc, ENTETE_LIBDOC );
fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) );
......
......@@ -237,7 +237,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL );
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
{
// Initialize data relative to nets and netclasses (for a new
......@@ -350,7 +350,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Import_Module( NULL );
Import_Module( );
redraw = true;
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0;
......@@ -579,7 +579,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) )
{
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc );
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL );
}
break;
......@@ -588,34 +588,40 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->m_Flags & IS_NEW )
&& ( GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE ) )
{
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
}
Enter_Edge_Width( edge, &dc );
Enter_Edge_Width( edge );
DrawPanel->MouseToCursorSchema();
if( edge )
DrawPanel->Refresh();
}
break;
case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE:
DrawPanel->MouseToCursorSchema();
Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
break;
case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE:
DrawPanel->MouseToCursorSchema();
Edit_Edge_Width( NULL );
DrawPanel->Refresh( );
break;
case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE:
DrawPanel->MouseToCursorSchema();
Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
break;
case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE:
DrawPanel->MouseToCursorSchema();
Edit_Edge_Layer( NULL );
DrawPanel->Refresh( );
break;
case ID_POPUP_PCB_DELETE_EDGE:
......
......@@ -36,7 +36,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case TYPE_EDGE_MODULE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC );
Place_EdgeMod( (EDGE_MODULE*) DrawStruct );
break;
case TYPE_PAD:
......@@ -93,13 +93,15 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
{
if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL );
DrawPanel->Refresh();
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT )
{
......@@ -437,8 +439,9 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{
if( DrawStruct && ( DrawStruct->m_Flags & IS_NEW ) )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
End_Edge_Module( (EDGE_MODULE*) DrawStruct );
SetCurItem( NULL );
DrawPanel->Refresh();
}
break;
}
......
......@@ -20,11 +20,13 @@
static void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC );
static MODULE* s_ModuleInitialCopy = NULL; // Copy of module for
// abort/undo command
static PICKED_ITEMS_LIST s_PickedList; // a picked list to
// save initial module
// and dragged tracks
static MODULE* s_ModuleInitialCopy = NULL; /* Copy of module for
* abort/undo command
*/
static PICKED_ITEMS_LIST s_PickedList; /* a picked list to
* save initial module
* and dragged tracks
*/
/* Show or hide module pads.
......@@ -64,16 +66,22 @@ void Rastnest_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module )
*/
MODULE* WinEDA_BasePcbFrame::GetModuleByName()
{
wxString modulename;
wxString moduleName;
MODULE* module = NULL;
Get_Message( _( "Name:" ), _( "Search footprint" ), modulename, this );
if( !modulename.IsEmpty() )
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName );
if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user
moduleName.Trim( true );
moduleName.Trim( false );
if( !moduleName.IsEmpty() )
{
module = GetBoard()->m_Modules;
while( module )
{
if( module->m_Reference->m_Text.CmpNoCase( modulename ) == 0 )
if( module->m_Reference->m_Text.CmpNoCase( moduleName ) == 0 )
break;
module = module->Next();
}
......@@ -101,7 +109,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
module->m_Flags |= IS_MOVED;
/* Show ratsnest. */
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Should not occur ! */
......@@ -221,7 +229,7 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
// Display ratsnest is allowed
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 );
}
......@@ -304,9 +312,9 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module,
/* Confirm module delete. */
if( aAskBeforeDeleting )
{
msg.Printf( _( "Delete Module %s (value %s) ?"),
GetChars(module->m_Reference->m_Text),
GetChars(module->m_Value->m_Text) );
msg.Printf( _( "Delete Module %s (value %s) ?" ),
GetChars( module->m_Reference->m_Text ),
GetChars( module->m_Value->m_Text ) );
if( !IsOK( this, msg ) )
{
return FALSE;
......@@ -324,7 +332,7 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module,
// Redraw the full screen to ensure perfect display of board and ratsnest.
if( DC )
DrawPanel->Refresh( );
DrawPanel->Refresh();
return true;
}
......@@ -362,7 +370,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
}
/* Show ratsnest if necessary. */
if( DC && GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
if( DC && GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC );
g_Offset_Module.x = 0;
......@@ -483,10 +491,9 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
Compile_Ratsnest( DC, true );
if( DC )
DrawPanel->Refresh( );
DrawPanel->Refresh();
module->DisplayInfo( this );
}
......@@ -515,7 +522,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
DrawPanel->PostDirtyRect( module->GetBoundingBox() );
module->m_Flags = tmp;
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC );
}
}
......@@ -540,18 +547,20 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
if( DC )
{
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 );
Compile_Ratsnest( DC, true );
}
else
{ // Beiing moved: just redraw it
{
// Beiing moved: just redraw it
DrawModuleOutlines( DrawPanel, DC, module );
Dessine_Segments_Dragges( DrawPanel, DC );
}
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 )
{
D_PAD* PtPad;
int ll;
double fcoeff;
bool abort = FALSE;
wxString msg;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
......@@ -200,28 +198,13 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
Mself.lng = min_len;
/* Enter the desired length. */
if( !g_UserUnit )
{
fcoeff = 10000.0;
msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff );
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;
msg = ReturnStringFromValue( g_UserUnit, Mself.lng, GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg );
if( dlg.ShowModal() != wxID_OK )
return NULL; // cancelled by user
double fval;
if( !msg.ToDouble( &fval ) )
{
DisplayError( this, _( "Incorrect number, abort" ) );
return NULL;
}
Mself.lng = wxRound( fval * fcoeff );
msg = dlg.GetValue( );
Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Control values (ii = minimum length) */
if( Mself.lng < min_len )
......@@ -245,7 +228,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
/* Generate module. */
MODULE* Module;
Module = Create_1_Module( NULL, wxEmptyString );
Module = Create_1_Module( wxEmptyString );
if( Module == NULL )
return NULL;
......@@ -537,7 +520,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( const wxString& name,
int pad_num = 1;
wxString Line;
Module = Create_1_Module( NULL, name );
Module = Create_1_Module( name );
if( Module == NULL )
return NULL;
......@@ -606,13 +589,11 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
{
int oX;
float fcoeff;
D_PAD* pad;
MODULE* Module;
wxString msg, cmp_name;
int pad_count = 2;
int angle = 0;
bool abort;
/* Enter the size of the gap or stub*/
int gap_size = GetBoard()->GetCurrentTrackWidth();
......@@ -641,36 +622,25 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
break;
}
wxString value;
if( g_UserUnit )
{
fcoeff = 10000.0f / 25.4f;
value.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
msg += _( " (mm):" );
}
else
msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), wxEmptyString );
if( dlg.ShowModal() != wxID_OK )
{
fcoeff = 10000.0;
value.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
msg += _( " (inch):" );
DrawPanel->MouseToCursorSchema();
return NULL; // cancelled by user
}
abort = Get_Message( msg, _( "Create microwave module" ), value, this );
double fval;
if( !value.ToDouble( &fval ) )
{
DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE;
}
gap_size = ABS( wxRound( fval * fcoeff ) );
msg = dlg.GetValue( );
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
if( !abort && ( shape_type == 2 ) )
bool abort = false;
if( shape_type == 2 )
{
fcoeff = 10.0;
value.Printf( wxT( "%3.1f" ), angle / fcoeff );
msg = _( "Angle (0.1deg):" );
abort = Get_Message( msg, _( "Create microwave module" ), value, this );
if( !value.ToDouble( &fval ) )
double fcoeff = 10.0, fval;
msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _( "Create microwave module" ), msg );
msg = angledlg.GetValue( );
if( !msg.ToDouble( &fval ) )
{
DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE;
......@@ -1100,7 +1070,6 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape()
void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
{
int gap_size, oX;
float fcoeff;
D_PAD* pad, * next_pad;
wxString msg;
......@@ -1130,27 +1099,14 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
/* Calculate the current dimension. */
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
/* Entrance to the desired length of the gap. */
if( g_UserUnit )
{
fcoeff = 10000.0f / 25.4f;
msg.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
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 );
}
/* Entrer the desired length of the gap. */
msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
if( !msg.IsEmpty() )
{
double fval;
if( msg.ToDouble( &fval ) )
gap_size = (int) ( fval * fcoeff );
}
msg = dlg.GetValue( );
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Updating sizes of pads forming the gap. */
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
......
......@@ -49,8 +49,9 @@ bool Segments_45_Only; // True to allow horiz, vert. an
bool g_TwoSegmentTrackBuild = true;
bool g_HighLight_Status;
int ModuleSegmentWidth;
int ModuleTextWidth;
wxSize g_ModuleTextSize; /* Default footprint texts size */
int g_ModuleSegmentWidth;
int g_ModuleTextWidth;
int Route_Layer_TOP;
int Route_Layer_BOTTOM;
int g_MaxLinksShowed;
......@@ -58,7 +59,6 @@ int g_MagneticPadOption = capture_cursor_in_track_tool;
int g_MagneticTrackOption = capture_cursor_in_track_tool;
int g_HighLight_NetCode = -1;
wxSize ModuleTextSize; /* Default footprint texts size */
wxPoint g_Offset_Module; /* Offset de trace du modul en depl */
wxString g_Current_PadName; // Last used pad name (pad num)
......
......@@ -67,9 +67,9 @@ extern wxString g_Shapes3DExtBuffer;
extern wxString g_DocModulesFileName;
/* Variables used in footprint handling */
extern wxSize ModuleTextSize; /* Default footprint texts size */
extern int ModuleTextWidth;
extern int ModuleSegmentWidth;
extern wxSize g_ModuleTextSize; /* Default footprint texts size */
extern int g_ModuleTextWidth;
extern int g_ModuleSegmentWidth;
/* Layer pair for auto routing and switch layers by hotkey */
extern int Route_Layer_TOP;
......
......@@ -248,11 +248,11 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ),
&boardDesignSettings.m_PcbTextSize.x,
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 ) );
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 ) );
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 ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ),
&boardDesignSettings.m_SolderMaskMargin,
......@@ -266,7 +266,7 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ),
&boardDesignSettings.m_PcbTextWidth,
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 ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LastNetListRead" ),
&m_lastNetListRead ) );
......
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