Commit 9cc4f5d0 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: add compil option in sch_field.cpp to go back to old behavior for...

Eeschema: add compil option in sch_field.cpp to go back to old behavior for field texts justifications (this option is not activated)
Note: only vertical texts have a modified behavior.
Minor other changes.
parent 148aecf9
...@@ -36,6 +36,19 @@ ...@@ -36,6 +36,19 @@
* They can be renamed and can appear in reports * They can be renamed and can appear in reports
*/ */
/* set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use
* a justification relative to the text itself
* i.e. justification relative to an horizontal text
* or to 1 to keep the initial Eeschema behavior
* The initial behavior is:
* For vertical texts, exchange the horizontal and the vertical justification
* The idea is to keep the justification always left or top for instance,
* no matter the text orientation
* This is a bit tricky when you want to change a text field justification
* when the fiels and the component are both rotated 90.0 degrees
*/
#define USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR 0
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "base_struct.h" #include "base_struct.h"
...@@ -265,7 +278,29 @@ EDA_RECT SCH_FIELD::GetBoundingBox() const ...@@ -265,7 +278,29 @@ EDA_RECT SCH_FIELD::GetBoundingBox() const
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
// Calculate the text bounding box: // Calculate the text bounding box:
EDA_RECT rect = GetTextBox( -1, linewidth ); EDA_RECT rect;
// set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use
// a justification relative to the text itself
// i.e. justification relative to an horizontal text
// or to 1 to keep the initial behavior
#if (USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR == 1 )
if( m_Orient == TEXT_ORIENT_VERT )
{
// For vertical texts, exchange the horizontal and the vertical justification
// The idea is to keep the justification always left or top for instance,
// no matter the text orientation
SCH_FIELD text( *this ); // Make a local copy to swap justifications
// because GetBoundingBox() is const
int tmp = (int)text.m_VJustify;
NEGATE( tmp );
text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify;
text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp;
rect = text.GetTextBox( -1, linewidth );
}
else
#endif
rect = GetTextBox( -1, linewidth );
// Calculate the bounding box position relative to the component: // Calculate the bounding box position relative to the component:
wxPoint origin = parentComponent->GetPosition(); wxPoint origin = parentComponent->GetPosition();
......
...@@ -233,14 +233,6 @@ public: ...@@ -233,14 +233,6 @@ public:
bool aOverwrite, bool aOverwrite,
bool aDisplayDialog ); bool aDisplayDialog );
/**
* 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)
*/
void Archive_Modules( const wxString& LibName, bool NewModulesOnly );
MODULE* GetModuleByName(); MODULE* GetModuleByName();
/** /**
......
...@@ -784,6 +784,16 @@ public: ...@@ -784,6 +784,16 @@ public:
*/ */
void RecreateCmpFileFromBoard( wxCommandEvent& aEvent ); void RecreateCmpFileFromBoard( wxCommandEvent& aEvent );
/**
* Function ArchiveModulesOnBoard
* Save modules in a library:
* @param aLibName: the full filename of the library to create or modify
* @param aNewModulesOnly:
* true : save modules not already existing in this lib
* false: save all modules
*/
void ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly );
/** /**
* Function RecreateBOMFileFromBoard * Function RecreateBOMFileFromBoard
* Creates a BOM file from the current loaded board * Creates a BOM file from the current loaded board
......
...@@ -123,12 +123,6 @@ void C_MICROSTRIP::delta_u_thickness() ...@@ -123,12 +123,6 @@ void C_MICROSTRIP::delta_u_thickness()
*/ */
void C_MICROSTRIP::compute_single_line() void C_MICROSTRIP::compute_single_line()
{ {
double w_h, ht_h;
double Z0_single, er_eff_single;
ht_h = ht / h;
w_h = w / h;
if( aux_ms == NULL ) if( aux_ms == NULL )
aux_ms = new MICROSTRIP(); aux_ms = new MICROSTRIP();
...@@ -144,9 +138,6 @@ void C_MICROSTRIP::compute_single_line() ...@@ -144,9 +138,6 @@ void C_MICROSTRIP::compute_single_line()
aux_ms->murC = murC; aux_ms->murC = murC;
aux_ms->microstrip_Z0(); aux_ms->microstrip_Z0();
aux_ms->dispersion(); aux_ms->dispersion();
er_eff_single = aux_ms->er_eff_0;
Z0_single = aux_ms->Z0_0;
} }
......
...@@ -1076,11 +1076,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1076,11 +1076,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MENU_ARCHIVE_NEW_MODULES: case ID_MENU_ARCHIVE_NEW_MODULES:
Archive_Modules( wxEmptyString, true ); ArchiveModulesOnBoard( wxEmptyString, true );
break; break;
case ID_MENU_ARCHIVE_ALL_MODULES: case ID_MENU_ARCHIVE_ALL_MODULES:
Archive_Modules( wxEmptyString, false ); ArchiveModulesOnBoard( wxEmptyString, false );
break; break;
default: default:
......
...@@ -348,11 +348,15 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) ...@@ -348,11 +348,15 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
} }
void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOnly ) /* Save modules in a library:
* param aNewModulesOnly:
* true : save modules not already existing in this lib
* false: save all modules
*/
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly )
{ {
int ii, NbModules = 0; wxString fileName = aLibName;
MODULE* Module; wxString path;
wxString fileName = LibName, path;
if( GetBoard()->m_Modules == NULL ) if( GetBoard()->m_Modules == NULL )
{ {
...@@ -362,7 +366,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -362,7 +366,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
path = wxGetApp().ReturnLastVisitedLibraryPath(); path = wxGetApp().ReturnLastVisitedLibraryPath();
if( LibName.IsEmpty() ) if( aLibName.IsEmpty() )
{ {
wxFileDialog dlg( this, _( "Library" ), path, wxFileDialog dlg( this, _( "Library" ), path,
wxEmptyString, ModuleFileWildcard, wxEmptyString, ModuleFileWildcard,
...@@ -378,7 +382,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -378,7 +382,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
bool file_exists = wxFileExists( fileName ); bool file_exists = wxFileExists( fileName );
if( !NewModulesOnly && file_exists ) if( !aNewModulesOnly && file_exists )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) ); msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) );
...@@ -390,7 +394,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -390,7 +394,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
m_canvas->SetAbortRequest( false ); m_canvas->SetAbortRequest( 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( !aNewModulesOnly || !file_exists )
{ {
FILE* lib_module; FILE* lib_module;
...@@ -409,26 +413,14 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn ...@@ -409,26 +413,14 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
fclose( lib_module ); fclose( lib_module );
} }
/* Calculate the number of modules. */ MODULE* Module = (MODULE*) GetBoard()->m_Modules;
Module = (MODULE*) GetBoard()->m_Modules; for( int ii = 1; Module != NULL; ii++, Module = Module->Next() )
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
NbModules++;
double step = 100.0 / NbModules;
DisplayActivity( 0, wxEmptyString );
Module = (MODULE*) GetBoard()->m_Modules;
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, aNewModulesOnly ? false : true,
false ) == 0 ) false ) == 0 )
break; break;
DisplayActivity( (int) ( ii * step ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */ /* Check for request to stop backup (ESCAPE key actuated) */
if( m_canvas->GetAbortRequest() ) if( m_canvas->GetAbortRequest() )
break; break;
...@@ -604,7 +596,8 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, ...@@ -604,7 +596,8 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
} }
/* Write the new footprint ( append it to the list of footprint ) */ /* Write the new footprint ( append it to the list of footprint ) */
tmp = aModule->GetTimeStamp(); aModule->SetTimeStamp( 0 ); tmp = aModule->GetTimeStamp();
aModule->SetTimeStamp( 0 );
aModule->Save( dest ); aModule->Save( dest );
aModule->SetTimeStamp( tmp ); aModule->SetTimeStamp( tmp );
......
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