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.
This commit is contained in:
jean-pierre charras 2012-01-06 20:00:59 +01:00
parent 148aecf963
commit 9cc4f5d0a6
6 changed files with 64 additions and 43 deletions

View File

@ -36,6 +36,19 @@
* 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 "class_drawpanel.h"
#include "base_struct.h"
@ -265,7 +278,29 @@ EDA_RECT SCH_FIELD::GetBoundingBox() const
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
// 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:
wxPoint origin = parentComponent->GetPosition();

View File

@ -233,14 +233,6 @@ public:
bool aOverwrite,
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();
/**

View File

@ -784,6 +784,16 @@ public:
*/
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
* Creates a BOM file from the current loaded board

View File

@ -123,12 +123,6 @@ void C_MICROSTRIP::delta_u_thickness()
*/
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 )
aux_ms = new MICROSTRIP();
@ -144,9 +138,6 @@ void C_MICROSTRIP::compute_single_line()
aux_ms->murC = murC;
aux_ms->microstrip_Z0();
aux_ms->dispersion();
er_eff_single = aux_ms->er_eff_0;
Z0_single = aux_ms->Z0_0;
}

View File

@ -1076,11 +1076,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_MENU_ARCHIVE_NEW_MODULES:
Archive_Modules( wxEmptyString, true );
ArchiveModulesOnBoard( wxEmptyString, true );
break;
case ID_MENU_ARCHIVE_ALL_MODULES:
Archive_Modules( wxEmptyString, false );
ArchiveModulesOnBoard( wxEmptyString, false );
break;
default:

View File

@ -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;
MODULE* Module;
wxString fileName = LibName, path;
wxString fileName = aLibName;
wxString path;
if( GetBoard()->m_Modules == NULL )
{
@ -362,7 +366,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
path = wxGetApp().ReturnLastVisitedLibraryPath();
if( LibName.IsEmpty() )
if( aLibName.IsEmpty() )
{
wxFileDialog dlg( this, _( "Library" ), path,
wxEmptyString, ModuleFileWildcard,
@ -378,7 +382,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
bool file_exists = wxFileExists( fileName );
if( !NewModulesOnly && file_exists )
if( !aNewModulesOnly && file_exists )
{
wxString msg;
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
m_canvas->SetAbortRequest( false );
// 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;
@ -409,26 +413,14 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
fclose( lib_module );
}
/* Calculate the number of modules. */
Module = (MODULE*) GetBoard()->m_Modules;
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() )
MODULE* Module = (MODULE*) GetBoard()->m_Modules;
for( int ii = 1; Module != NULL; ii++, Module = Module->Next() )
{
if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? false : true,
aNewModulesOnly ? false : true,
false ) == 0 )
break;
DisplayActivity( (int) ( ii * step ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */
if( m_canvas->GetAbortRequest() )
break;
@ -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 ) */
tmp = aModule->GetTimeStamp(); aModule->SetTimeStamp( 0 );
tmp = aModule->GetTimeStamp();
aModule->SetTimeStamp( 0 );
aModule->Save( dest );
aModule->SetTimeStamp( tmp );