Eeschema: code cleanup
This commit is contained in:
parent
b4bd181d07
commit
535a4d1f92
|
@ -21,25 +21,25 @@
|
|||
*/
|
||||
|
||||
/* Standard page sizes in 1/1000 inch */
|
||||
Ki_PageDescr g_Sheet_A4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) );
|
||||
Ki_PageDescr g_Sheet_A3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) );
|
||||
Ki_PageDescr g_Sheet_A2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) );
|
||||
Ki_PageDescr g_Sheet_A1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) );
|
||||
Ki_PageDescr g_Sheet_A0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) );
|
||||
Ki_PageDescr g_Sheet_A( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) );
|
||||
Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
|
||||
Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) );
|
||||
Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) );
|
||||
Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) );
|
||||
Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ),
|
||||
Ki_PageDescr g_Sheet_A4( wxSize( 11700, 8267 ), wxPoint( 0, 0 ), wxT( "A4" ) );
|
||||
Ki_PageDescr g_Sheet_A3( wxSize( 16535, 11700 ), wxPoint( 0, 0 ), wxT( "A3" ) );
|
||||
Ki_PageDescr g_Sheet_A2( wxSize( 23400, 16535 ), wxPoint( 0, 0 ), wxT( "A2" ) );
|
||||
Ki_PageDescr g_Sheet_A1( wxSize( 33070, 23400 ), wxPoint( 0, 0 ), wxT( "A1" ) );
|
||||
Ki_PageDescr g_Sheet_A0( wxSize( 46800, 33070 ), wxPoint( 0, 0 ), wxT( "A0" ) );
|
||||
Ki_PageDescr g_Sheet_A( wxSize( 11000, 8500 ), wxPoint( 0, 0 ), wxT( "A" ) );
|
||||
Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
|
||||
Ki_PageDescr g_Sheet_C( wxSize( 22000, 17000 ), wxPoint( 0, 0 ), wxT( "C" ) );
|
||||
Ki_PageDescr g_Sheet_D( wxSize( 34000, 22000 ), wxPoint( 0, 0 ), wxT( "D" ) );
|
||||
Ki_PageDescr g_Sheet_E( wxSize( 44000, 34000 ), wxPoint( 0, 0 ), wxT( "E" ) );
|
||||
Ki_PageDescr g_Sheet_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ),
|
||||
wxT( "GERBER" ) );
|
||||
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ),
|
||||
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ),
|
||||
wxT( "User" ) );
|
||||
|
||||
Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
|
||||
{
|
||||
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0,
|
||||
&g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E,
|
||||
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0,
|
||||
&g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E,
|
||||
&g_Sheet_user, NULL
|
||||
};
|
||||
|
||||
|
@ -57,33 +57,33 @@ const wxString PdfFileExtension( wxT( "pdf" ) );
|
|||
|
||||
/* Proper wxFileDialog wild card definitions. */
|
||||
const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) );
|
||||
const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") );
|
||||
const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd" ) );
|
||||
const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) );
|
||||
const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) );
|
||||
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
|
||||
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
|
||||
const wxString AllFilesWildcard( _( "All files (*)|*") );
|
||||
const wxString AllFilesWildcard( _( "All files (*)|*" ) );
|
||||
|
||||
|
||||
wxString g_ProductName = wxT( "KiCad E.D.A. " );
|
||||
bool g_ShowPageLimits = true;
|
||||
int g_GridColor = DARKGRAY;
|
||||
wxString g_UserLibDirBuffer;
|
||||
int g_DebugLevel;
|
||||
int g_MouseOldButtons;
|
||||
int g_KeyPressed;
|
||||
wxString g_ProductName = wxT( "KiCad E.D.A. " );
|
||||
bool g_ShowPageLimits = true;
|
||||
int g_GridColor = DARKGRAY;
|
||||
wxString g_UserLibDirBuffer;
|
||||
int g_DebugLevel;
|
||||
int g_MouseOldButtons;
|
||||
int g_KeyPressed;
|
||||
|
||||
// Nom (full file name) du file Configuration par defaut (kicad.pro)
|
||||
wxString g_Prj_Default_Config_FullFilename;
|
||||
wxString g_Prj_Default_Config_FullFilename;
|
||||
|
||||
// Nom du file Configuration local (<curr projet>.pro)
|
||||
wxString g_Prj_Config_LocalFilename;
|
||||
wxString g_Prj_Config_LocalFilename;
|
||||
|
||||
// Handle the preferd editor for browsing report files:
|
||||
int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
|
||||
int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
|
||||
|
||||
/* Draw color for moving objects: */
|
||||
int g_GhostColor;
|
||||
int g_GhostColor;
|
||||
|
||||
/* predefined colors used in kicad.
|
||||
* Please: if you change a value, remember these values are carefully chosen
|
||||
|
@ -92,45 +92,43 @@ int g_GhostColor;
|
|||
*/
|
||||
StructColors ColorRefs[NBCOLOR] =
|
||||
{
|
||||
{ 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY},
|
||||
{ 192, 0, 0, BLUE, wxT("BLUE"), LIGHTBLUE},
|
||||
{ 0, 160, 0, GREEN, wxT("GREEN"), LIGHTGREEN },
|
||||
{ 160, 160, 0, CYAN, wxT("CYAN"), LIGHTCYAN },
|
||||
{ 0, 0, 160, RED, wxT("RED"), LIGHTRED },
|
||||
{ 160, 0, 160, MAGENTA, wxT("MAGENTA"), LIGHTMAGENTA },
|
||||
{ 0, 128, 128, BROWN, wxT("BROWN"), YELLOW },
|
||||
{ 192, 192, 192, LIGHTGRAY, wxT("GRAY"), WHITE },
|
||||
{ 128, 128, 128, DARKGRAY, wxT("DARKGRAY"), LIGHTGRAY },
|
||||
{ 255, 0, 0, LIGHTBLUE, wxT("LIGHTBLUE"), LIGHTBLUE },
|
||||
{ 0, 255, 0, LIGHTGREEN, wxT("LIGHTGREEN"), LIGHTGREEN },
|
||||
{ 255, 255, 0, LIGHTCYAN, wxT("LIGHTCYAN"), LIGHTCYAN },
|
||||
{ 0, 0, 255, LIGHTRED, wxT("LIGHTRED"), LIGHTRED },
|
||||
{ 255, 0, 255, LIGHTMAGENTA, wxT("LIGHTMAGENTA"), LIGHTMAGENTA },
|
||||
{ 0, 255, 255, YELLOW, wxT("YELLOW"), YELLOW },
|
||||
{ 255, 255, 255, WHITE, wxT("WHITE"), WHITE },
|
||||
{ 64, 64, 64, DARKDARKGRAY, wxT("DARKDARKGRAY"), DARKGRAY },
|
||||
{ 64, 0, 0, DARKBLUE, wxT("DARKBLUE"), BLUE },
|
||||
{ 0, 64, 0, DARKGREEN, wxT("DARKGREEN"), GREEN },
|
||||
{ 64, 64, 0, DARKCYAN, wxT("DARKCYAN"), CYAN },
|
||||
{ 0, 0, 80, DARKRED, wxT("DARKRED"), RED },
|
||||
{ 64, 0, 64, DARKMAGENTA, wxT("DARKMAGENTA"), MAGENTA },
|
||||
{ 0, 64, 64, DARKBROWN, wxT("DARKBROWN"), BROWN },
|
||||
{ 128, 255, 255, LIGHTYELLOW, wxT("LIGHTYELLOW"), LIGHTYELLOW }
|
||||
{ 0, 0, 0, BLACK, wxT( "BLACK" ), DARKDARKGRAY },
|
||||
{ 192, 0, 0, BLUE, wxT( "BLUE" ), LIGHTBLUE },
|
||||
{ 0, 160, 0, GREEN, wxT( "GREEN" ), LIGHTGREEN },
|
||||
{ 160, 160, 0, CYAN, wxT( "CYAN" ), LIGHTCYAN },
|
||||
{ 0, 0, 160, RED, wxT( "RED" ), LIGHTRED },
|
||||
{ 160, 0, 160, MAGENTA, wxT( "MAGENTA" ), LIGHTMAGENTA },
|
||||
{ 0, 128, 128, BROWN, wxT( "BROWN" ), YELLOW },
|
||||
{ 192, 192, 192, LIGHTGRAY, wxT( "GRAY" ), WHITE },
|
||||
{ 128, 128, 128, DARKGRAY, wxT( "DARKGRAY" ), LIGHTGRAY },
|
||||
{ 255, 0, 0, LIGHTBLUE, wxT( "LIGHTBLUE" ), LIGHTBLUE },
|
||||
{ 0, 255, 0, LIGHTGREEN, wxT( "LIGHTGREEN" ), LIGHTGREEN },
|
||||
{ 255, 255, 0, LIGHTCYAN, wxT( "LIGHTCYAN" ), LIGHTCYAN },
|
||||
{ 0, 0, 255, LIGHTRED, wxT( "LIGHTRED" ), LIGHTRED },
|
||||
{ 255, 0, 255, LIGHTMAGENTA, wxT( "LIGHTMAGENTA" ), LIGHTMAGENTA },
|
||||
{ 0, 255, 255, YELLOW, wxT( "YELLOW" ), YELLOW },
|
||||
{ 255, 255, 255, WHITE, wxT( "WHITE" ), WHITE },
|
||||
{ 64, 64, 64, DARKDARKGRAY, wxT( "DARKDARKGRAY" ), DARKGRAY },
|
||||
{ 64, 0, 0, DARKBLUE, wxT( "DARKBLUE" ), BLUE },
|
||||
{ 0, 64, 0, DARKGREEN, wxT( "DARKGREEN" ), GREEN },
|
||||
{ 64, 64, 0, DARKCYAN, wxT( "DARKCYAN" ), CYAN },
|
||||
{ 0, 0, 80, DARKRED, wxT( "DARKRED" ), RED },
|
||||
{ 64, 0, 64, DARKMAGENTA, wxT( "DARKMAGENTA" ), MAGENTA },
|
||||
{ 0, 64, 64, DARKBROWN, wxT( "DARKBROWN" ), BROWN },
|
||||
{ 128, 255, 255, LIGHTYELLOW, wxT( "LIGHTYELLOW" ), LIGHTYELLOW }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
/** Function GetBuildVersion()
|
||||
* Return the build date
|
||||
*/
|
||||
/****************/
|
||||
wxString GetBuildVersion()
|
||||
/****************/
|
||||
{
|
||||
return g_BuildVersion;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/** Function GetAboutBuildVersion()
|
||||
* Return custom build date for about dialog
|
||||
*/
|
||||
wxString GetAboutBuildVersion()
|
||||
|
@ -140,15 +138,15 @@ wxString GetAboutBuildVersion()
|
|||
|
||||
|
||||
/** function SetLocaleTo_C_standard
|
||||
* because kicad is internationalized, switch internatization to "C" standard
|
||||
* i.e. uses the . (dot) as separator in print/read float numbers
|
||||
* (some contries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called before read or write ascii files using float numbers in data
|
||||
* the SetLocaleTo_C_standard function must be called after reading or writing the file
|
||||
*
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
|
||||
* but could make more easier an optional use of locale in kicad
|
||||
*/
|
||||
* because kicad is internationalized, switch internatization to "C" standard
|
||||
* i.e. uses the . (dot) as separator in print/read float numbers
|
||||
* (some contries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called before read or write ascii files using float numbers in data
|
||||
* the SetLocaleTo_C_standard function must be called after reading or writing the file
|
||||
*
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
|
||||
* but could make more easier an optional use of locale in kicad
|
||||
*/
|
||||
/********************************/
|
||||
void SetLocaleTo_C_standard( void )
|
||||
{
|
||||
|
@ -157,13 +155,13 @@ void SetLocaleTo_C_standard( void )
|
|||
|
||||
|
||||
/** function SetLocaleTo_Default
|
||||
* because kicad is internationalized, switch internatization to default
|
||||
* to use the default separator in print/read float numbers
|
||||
* (. (dot) but some contries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called after a call to SetLocaleTo_C_standard
|
||||
* because kicad is internationalized, switch internatization to default
|
||||
* to use the default separator in print/read float numbers
|
||||
* (. (dot) but some contries (France, Germany ..) use , (comma) as separator)
|
||||
* This function must be called after a call to SetLocaleTo_C_standard
|
||||
*
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
|
||||
* but could make more easier an optional use of locale in kicad
|
||||
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
|
||||
* but could make more easier an optional use of locale in kicad
|
||||
*/
|
||||
/********************************/
|
||||
void SetLocaleTo_Default( void )
|
||||
|
@ -174,24 +172,25 @@ void SetLocaleTo_Default( void )
|
|||
|
||||
|
||||
/********************************************************************/
|
||||
bool EnsureTextCtrlWidth(wxTextCtrl* aCtrl,
|
||||
const wxString* aString )
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
|
||||
const wxString* aString )
|
||||
/********************************************************************/
|
||||
{
|
||||
wxWindow* window = aCtrl->GetParent();
|
||||
wxWindow* window = aCtrl->GetParent();
|
||||
|
||||
if( !window )
|
||||
window = aCtrl;
|
||||
|
||||
wxString ctrlText;
|
||||
wxString ctrlText;
|
||||
|
||||
if( !aString )
|
||||
{
|
||||
ctrlText = aCtrl->GetValue();
|
||||
aString = &ctrlText;
|
||||
aString = &ctrlText;
|
||||
}
|
||||
|
||||
wxCoord width;
|
||||
wxCoord height;
|
||||
wxCoord width;
|
||||
wxCoord height;
|
||||
|
||||
{
|
||||
wxClientDC dc( window );
|
||||
|
@ -211,9 +210,9 @@ bool EnsureTextCtrlWidth(wxTextCtrl* aCtrl,
|
|||
|
||||
|
||||
/*********************************************************************************************/
|
||||
Ki_PageDescr::Ki_PageDescr(const wxSize& size,
|
||||
const wxPoint& offset,
|
||||
const wxString& name )
|
||||
Ki_PageDescr::Ki_PageDescr( const wxSize& size,
|
||||
const wxPoint& offset,
|
||||
const wxString& name )
|
||||
/*********************************************************************************************/
|
||||
{
|
||||
// All sizes are in 1/1000 inch
|
||||
|
@ -223,12 +222,12 @@ Ki_PageDescr::Ki_PageDescr(const wxSize& size,
|
|||
|
||||
// Adjust the default value for margins to 400 mils (0,4 inch or 10 mm)
|
||||
#if defined(KICAD_GOST)
|
||||
m_LeftMargin = LEFTMARGIN;
|
||||
m_RightMargin = RIGHTMARGIN;
|
||||
m_TopMargin = TOPMARGIN;
|
||||
m_LeftMargin = LEFTMARGIN;
|
||||
m_RightMargin = RIGHTMARGIN;
|
||||
m_TopMargin = TOPMARGIN;
|
||||
m_BottomMargin = BOTTOMMARGIN;
|
||||
#else
|
||||
m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400;
|
||||
m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -323,9 +322,9 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
|
|||
StringValue << aValue;
|
||||
else
|
||||
{
|
||||
value_to_print = To_User_Unit( (bool)aUnits, aValue, aInternal_Unit );
|
||||
value_to_print = To_User_Unit( (bool) aUnits, aValue, aInternal_Unit );
|
||||
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
|
||||
value_to_print );
|
||||
value_to_print );
|
||||
}
|
||||
|
||||
if( aAdd_unit_symbol )
|
||||
|
@ -366,11 +365,12 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
|
|||
if( Units >= CENTIMETRE )
|
||||
Value = wxRound( dtmp );
|
||||
else
|
||||
Value = From_User_Unit( (bool)Units, dtmp, Internal_Unit );
|
||||
Value = From_User_Unit( (bool) Units, dtmp, Internal_Unit );
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function wxStringSplit
|
||||
* Split a String to a String List when founding 'splitter'
|
||||
|
@ -379,25 +379,26 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
|
|||
* @param splitter : wxChar : the 'split' character
|
||||
*/
|
||||
/**********************************************************/
|
||||
wxArrayString* wxStringSplit(wxString txt, wxChar splitter)
|
||||
wxArrayString* wxStringSplit( wxString txt, wxChar splitter )
|
||||
/**********************************************************/
|
||||
{
|
||||
wxArrayString* list = new wxArrayString();
|
||||
while (1)
|
||||
{
|
||||
int index=txt.Find(splitter);
|
||||
if (index == wxNOT_FOUND)
|
||||
break;
|
||||
|
||||
wxString tmp;
|
||||
tmp = txt.Mid(0,index);
|
||||
txt = txt.Mid( index+1, txt.size() - index);
|
||||
list->Add(tmp);
|
||||
while( 1 )
|
||||
{
|
||||
int index = txt.Find( splitter );
|
||||
if( index == wxNOT_FOUND )
|
||||
break;
|
||||
|
||||
wxString tmp;
|
||||
tmp = txt.Mid( 0, index );
|
||||
txt = txt.Mid( index + 1, txt.size() - index );
|
||||
list->Add( tmp );
|
||||
}
|
||||
|
||||
if (!txt.IsEmpty())
|
||||
if( !txt.IsEmpty() )
|
||||
{
|
||||
list->Add(txt);
|
||||
list->Add( txt );
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -407,6 +408,7 @@ wxArrayString* wxStringSplit(wxString txt, wxChar splitter)
|
|||
/******************************************************************/
|
||||
double To_User_Unit( bool is_metric, int val, int internal_unit_value )
|
||||
/******************************************************************/
|
||||
|
||||
/**
|
||||
* Function To_User_Unit
|
||||
* Convert in inch or mm the variable "val" (double)given in internal units
|
||||
|
@ -419,18 +421,20 @@ double To_User_Unit( bool is_metric, int val, int internal_unit_value )
|
|||
double value;
|
||||
|
||||
if( is_metric )
|
||||
value = (double) (val) * 25.4 / internal_unit_value;
|
||||
value = (double) ( val ) * 25.4 / internal_unit_value;
|
||||
else
|
||||
value = (double) (val) / internal_unit_value;
|
||||
value = (double) ( val ) / internal_unit_value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
double To_User_Unit( bool is_metric,
|
||||
double val,
|
||||
int internal_unit_value )
|
||||
double To_User_Unit( bool is_metric,
|
||||
double val,
|
||||
int internal_unit_value )
|
||||
/******************************************************************/
|
||||
|
||||
/**
|
||||
* Function To_User_Unit
|
||||
* Convert in inch or mm the variable "val" (double)given in internal units
|
||||
|
@ -451,7 +455,6 @@ double To_User_Unit( bool is_metric,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return in internal units the value "val" given in inch or mm
|
||||
*/
|
||||
|
@ -490,8 +493,8 @@ wxString GenDate()
|
|||
time( &buftime );
|
||||
Date = gmtime( &buftime );
|
||||
string_date.Printf( wxT( "%d %s %d" ), Date->tm_mday,
|
||||
mois[Date->tm_mon].GetData(),
|
||||
Date->tm_year + 1900 );
|
||||
mois[Date->tm_mon].GetData(),
|
||||
Date->tm_year + 1900 );
|
||||
return string_date;
|
||||
}
|
||||
|
||||
|
@ -580,7 +583,8 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
|
|||
// These are only default layer names. For PCBNEW, the copper names
|
||||
// may be over-ridden in the BOARD file *.brd.
|
||||
|
||||
static const wxString layer_name_list[] = {
|
||||
static const wxString layer_name_list[] =
|
||||
{
|
||||
_( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ),
|
||||
_( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ),
|
||||
_( "Inner L8 " ), _( "Inner L9 " ), _( "Inner L10" ), _( "Inner L11" ),
|
||||
|
@ -622,22 +626,22 @@ EVT_CLOSE( WinEDA_TextFrame::OnClose )
|
|||
END_EVENT_TABLE()
|
||||
|
||||
/***************************************************************************/
|
||||
WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
|
||||
WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
|
||||
const wxString& title ) :
|
||||
wxDialog( parent,
|
||||
-1, title,
|
||||
wxPoint( -1, -1 ),
|
||||
wxSize( 250, 350 ),
|
||||
wxDEFAULT_DIALOG_STYLE |
|
||||
wxFRAME_FLOAT_ON_PARENT |
|
||||
MAYBE_RESIZE_BORDER )
|
||||
wxDialog( parent,
|
||||
-1, title,
|
||||
wxPoint( -1, -1 ),
|
||||
wxSize( 250, 350 ),
|
||||
wxDEFAULT_DIALOG_STYLE |
|
||||
wxFRAME_FLOAT_ON_PARENT |
|
||||
MAYBE_RESIZE_BORDER )
|
||||
/***************************************************************************/
|
||||
{
|
||||
/*
|
||||
* TODO background and foreground colors of WinEDA_TextFrame should be
|
||||
* controllable / settable with project settings or config file and not
|
||||
* hardcoded in binairy !
|
||||
*/
|
||||
* TODO background and foreground colors of WinEDA_TextFrame should be
|
||||
* controllable / settable with project settings or config file and not
|
||||
* hardcoded in binairy !
|
||||
*/
|
||||
|
||||
wxSize size;
|
||||
|
||||
|
|
2920
common/trigo.cpp
2920
common/trigo.cpp
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,7 @@ set(EESCHEMA_SRCS
|
|||
build_BOM.cpp
|
||||
busentry.cpp
|
||||
bus-wire-junction.cpp
|
||||
class_BodyItem_Text.cpp
|
||||
class_drawsheet.cpp
|
||||
class_drawsheetpath.cpp
|
||||
class_hierarchical_PIN_sheet.cpp
|
||||
|
|
|
@ -254,26 +254,52 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
|||
*/
|
||||
bool LibDrawField::HitTest( const wxPoint& refPos )
|
||||
{
|
||||
// Reference designator text has one additional character (displays U?)
|
||||
if( m_FieldId == REFERENCE )
|
||||
m_Text.Append('?');
|
||||
// if using TextHitTest() remember this function uses top to bottom y axis convention
|
||||
// and for lib items we are using bottom to top convention
|
||||
// so for non center Y justification we use a trick.
|
||||
GRTextVertJustifyType vJustify = m_VJustify;
|
||||
if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
else if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
|
||||
bool hit = TextHitTest(refPos);
|
||||
m_VJustify = vJustify;
|
||||
|
||||
if( m_FieldId == REFERENCE )
|
||||
m_Text.RemoveLast( );
|
||||
return hit;
|
||||
return HitTest( refPos, 0, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = unused here (TextHitTest calculates its threshold )
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
int extraCharCount = 0;
|
||||
// Reference designator text has one or 2 additional character (displays U? or U?A)
|
||||
if( m_FieldId == REFERENCE )
|
||||
{
|
||||
extraCharCount++;
|
||||
m_Text.Append('?');
|
||||
EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent;
|
||||
if ( parent && ( parent->m_UnitCount > 1 ) )
|
||||
{
|
||||
m_Text.Append('A');
|
||||
extraCharCount++;
|
||||
}
|
||||
}
|
||||
|
||||
wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos );
|
||||
wxPoint tmp = m_Pos;
|
||||
m_Pos = physicalpos;
|
||||
/* The text orientation may need to be flipped if the
|
||||
* transformation matrix causes xy axes to be flipped.
|
||||
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
|
||||
*/
|
||||
int t1 = ( aTransMat[0][0] != 0 ) ^ ( m_Orient != 0 );
|
||||
int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT;
|
||||
EXCHG( m_Orient, orient );
|
||||
|
||||
bool hit = TextHitTest(aPosRef);
|
||||
|
||||
EXCHG( m_Orient, orient );
|
||||
m_Pos = tmp;
|
||||
|
||||
while( extraCharCount-- )
|
||||
m_Text.RemoveLast( );
|
||||
|
||||
return hit;
|
||||
}
|
||||
|
||||
// Creation et Duplication d'un field
|
||||
LibDrawField* LibDrawField::GenCopy()
|
||||
|
|
|
@ -74,6 +74,14 @@ public:
|
|||
*/
|
||||
bool HitTest( const wxPoint& refPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
void operator=( const LibDrawField& field )
|
||||
{
|
||||
m_FieldId = field.m_FieldId;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
#include "gr_basic.h"
|
||||
#include "trigo.h"
|
||||
#include "common.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "drawtxt.h"
|
||||
|
@ -14,6 +15,20 @@
|
|||
#include "plot_common.h"
|
||||
#include "protos.h"
|
||||
|
||||
const wxChar* MsgPinElectricType[] =
|
||||
{
|
||||
wxT( "input" ),
|
||||
wxT( "output" ),
|
||||
wxT( "BiDi" ),
|
||||
wxT( "3state" ),
|
||||
wxT( "passive" ),
|
||||
wxT( "unspc" ),
|
||||
wxT( "power_in" ),
|
||||
wxT( "power_out" ),
|
||||
wxT( "openCol" ),
|
||||
wxT( "openEm" ),
|
||||
wxT( "?????" )
|
||||
};
|
||||
|
||||
LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
|
||||
{
|
||||
|
@ -27,8 +42,42 @@ LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
|
|||
m_PinNameSize = 50; /* Default size for pin name and num */
|
||||
m_Width = 0;
|
||||
m_typeName = _( "Pin" );
|
||||
m_PinNumShapeOpt = 0;
|
||||
m_PinNameShapeOpt = 0;
|
||||
m_PinNumPositionOpt = 0;
|
||||
m_PinNamePositionOpt = 0;
|
||||
}
|
||||
|
||||
// m_PinNumWidth = m_PinNameWidth = 0; // Unused
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawPin::HitTest( const wxPoint& aRefPos )
|
||||
{
|
||||
int mindist = m_Width ? m_Width / 2 : g_DrawDefaultLineThickness / 2;
|
||||
|
||||
// Have a minimal tolerance for hit test
|
||||
if( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
|
||||
return HitTest( aRefPos, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near a pin
|
||||
* @param aRefPos = a wxPoint to test
|
||||
* @param aThreshold = max distance to a segment
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawPin::HitTest( wxPoint aRefPos, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
wxPoint pinPos = TransformCoordinate( aTransMat, m_Pos );
|
||||
wxPoint pinEnd = TransformCoordinate( aTransMat, ReturnPinEndPoint() );
|
||||
|
||||
return TestSegmentHit( aRefPos, pinPos, pinEnd, aThreshold );
|
||||
}
|
||||
|
||||
|
||||
|
@ -461,6 +510,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
|
||||
|
||||
int nameLineWidth = g_DrawDefaultLineThickness;
|
||||
|
||||
nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_PinNameSize, false );
|
||||
int numLineWidth = g_DrawDefaultLineThickness;
|
||||
numLineWidth = Clamp_Text_PenSize( numLineWidth, m_PinNumSize, false );
|
||||
|
@ -561,7 +611,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
||||
false, false);
|
||||
false, false );
|
||||
}
|
||||
else /* PIN_UP */
|
||||
{
|
||||
|
@ -582,7 +632,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
TEXT_ORIENT_VERT, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth,
|
||||
false, false);
|
||||
false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -611,7 +661,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
TEXT_ORIENT_HORIZ, PinNumSize,
|
||||
GR_TEXT_HJUSTIFY_CENTER,
|
||||
GR_TEXT_VJUSTIFY_TOP, numLineWidth,
|
||||
false, false);
|
||||
false, false );
|
||||
}
|
||||
}
|
||||
else /* Its a vertical line. */
|
||||
|
@ -643,6 +693,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Plot pin number and pin text info, given the pin line coordinates. *
|
||||
* Same as DrawPinTexts((), but output is the plotter
|
||||
|
@ -653,11 +704,11 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
|
|||
* the opposite direction to x2,y2), otherwise all is drawn outside. *
|
||||
*****************************************************************************/
|
||||
void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
|
||||
int orient,
|
||||
int TextInside,
|
||||
bool DrawPinNum,
|
||||
bool DrawPinName,
|
||||
int aWidth )
|
||||
int orient,
|
||||
int TextInside,
|
||||
bool DrawPinNum,
|
||||
bool DrawPinName,
|
||||
int aWidth )
|
||||
{
|
||||
int x, y, x1, y1;
|
||||
wxString StringPinNum;
|
||||
|
@ -956,19 +1007,23 @@ LibDrawPin* LibDrawPin::GenCopy()
|
|||
{
|
||||
LibDrawPin* newpin = new LibDrawPin();
|
||||
|
||||
newpin->m_Pos = m_Pos;
|
||||
newpin->m_PinLen = m_PinLen;
|
||||
newpin->m_Orient = m_Orient;
|
||||
newpin->m_PinShape = m_PinShape;
|
||||
newpin->m_PinType = m_PinType;
|
||||
newpin->m_Attributs = m_Attributs;
|
||||
newpin->m_PinNum = m_PinNum;
|
||||
newpin->m_PinNumSize = m_PinNumSize;
|
||||
newpin->m_PinNameSize = m_PinNameSize;
|
||||
newpin->m_Unit = m_Unit;
|
||||
newpin->m_Convert = m_Convert;
|
||||
newpin->m_Flags = m_Flags;
|
||||
newpin->m_Width = m_Width;
|
||||
newpin->m_Pos = m_Pos;
|
||||
newpin->m_PinLen = m_PinLen;
|
||||
newpin->m_Orient = m_Orient;
|
||||
newpin->m_PinShape = m_PinShape;
|
||||
newpin->m_PinType = m_PinType;
|
||||
newpin->m_Attributs = m_Attributs;
|
||||
newpin->m_PinNum = m_PinNum;
|
||||
newpin->m_PinNumSize = m_PinNumSize;
|
||||
newpin->m_PinNameSize = m_PinNameSize;
|
||||
newpin->m_PinNumShapeOpt = m_PinNumShapeOpt;
|
||||
newpin->m_PinNameShapeOpt = m_PinNameShapeOpt;
|
||||
newpin->m_PinNumPositionOpt = m_PinNumPositionOpt;
|
||||
newpin->m_PinNamePositionOpt = m_PinNamePositionOpt;
|
||||
newpin->m_Unit = m_Unit;
|
||||
newpin->m_Convert = m_Convert;
|
||||
newpin->m_Flags = m_Flags;
|
||||
newpin->m_Width = m_Width;
|
||||
|
||||
newpin->m_PinName = m_PinName;
|
||||
|
||||
|
|
|
@ -15,21 +15,6 @@
|
|||
#include "protos.h"
|
||||
|
||||
|
||||
const wxChar* MsgPinElectricType[] =
|
||||
{
|
||||
wxT( "input" ),
|
||||
wxT( "output" ),
|
||||
wxT( "BiDi" ),
|
||||
wxT( "3state" ),
|
||||
wxT( "passive" ),
|
||||
wxT( "unspc" ),
|
||||
wxT( "power_in" ),
|
||||
wxT( "power_out" ),
|
||||
wxT( "openCol" ),
|
||||
wxT( "openEm" ),
|
||||
wxT( "?????" )
|
||||
};
|
||||
|
||||
static int fill_tab[3] = { 'N', 'F', 'f' };
|
||||
|
||||
//#define DRAW_ARC_WITH_ANGLE // Used to draw arcs
|
||||
|
@ -177,21 +162,38 @@ bool LibDrawArc::Load( char* line, wxString& errorMsg )
|
|||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @param aRefPoint A wxPoint to test in eeschema space
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawArc::HitTest( const wxPoint& aRefPos )
|
||||
bool LibDrawArc::HitTest( const wxPoint& aRefPoint )
|
||||
{
|
||||
wxPoint relpos = aRefPos - m_Pos;
|
||||
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) );
|
||||
int mindist = m_Width ? m_Width /2 : g_DrawDefaultLineThickness / 2;
|
||||
// Have a minimal tolerance for hit test
|
||||
if ( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
if( abs( dist - m_Rayon ) > mindist )
|
||||
|
||||
return HitTest( aRefPoint, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aRefPoint = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
// TODO: use aTransMat to calculmates parameters
|
||||
wxPoint relpos = aRefPoint;
|
||||
NEGATE(relpos.y); // reverse Y axis
|
||||
|
||||
relpos -= m_Pos;
|
||||
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) );
|
||||
|
||||
if( abs( dist - m_Rayon ) > aThreshold )
|
||||
return false;
|
||||
|
||||
// We are on the circle, ensure we are on the arc, between m_ArcStart and m_ArcEnd
|
||||
// We are on the circle, ensure we are only on the arc, i.e. between m_ArcStart and m_ArcEnd
|
||||
int astart = t1; // arc starting point ( in 0.1 degree)
|
||||
int aend = t2; // arc ending point ( in 0.1 degree)
|
||||
int atest = wxRound( atan2(relpos.y, relpos.x) * 1800.0 / M_PI );
|
||||
|
@ -208,6 +210,7 @@ bool LibDrawArc::HitTest( const wxPoint& aRefPos )
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
LibDrawArc* LibDrawArc::GenCopy()
|
||||
{
|
||||
LibDrawArc* newitem = new LibDrawArc();
|
||||
|
@ -422,23 +425,36 @@ bool LibDrawCircle::Load( char* line, wxString& errorMsg )
|
|||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @param aRefPos A wxPoint to test in eeschema space
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawCircle::HitTest( const wxPoint& aRefPos )
|
||||
bool LibDrawCircle::HitTest( const wxPoint& aPosRef )
|
||||
{
|
||||
wxPoint relpos = aRefPos - m_Pos;
|
||||
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) );
|
||||
int mindist = m_Width ? m_Width /2 : g_DrawDefaultLineThickness / 2;
|
||||
// Have a minimal tolerance for hit test
|
||||
if ( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
if( abs( dist - m_Rayon ) > mindist )
|
||||
return false;
|
||||
|
||||
return HitTest( aPosRef, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
wxPoint relpos = aPosRef - TransformCoordinate( aTransMat, m_Pos );
|
||||
|
||||
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) );
|
||||
if( abs( dist - m_Rayon ) <= aThreshold )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LibDrawCircle* LibDrawCircle::GenCopy()
|
||||
{
|
||||
LibDrawCircle* newitem = new LibDrawCircle();
|
||||
|
@ -526,216 +542,6 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
}
|
||||
|
||||
|
||||
/***********************/
|
||||
/** class LibDrawText **/
|
||||
/***********************/
|
||||
|
||||
LibDrawText::LibDrawText() :
|
||||
LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ), EDA_TextStruct()
|
||||
{
|
||||
m_Size = wxSize( 50, 50 );
|
||||
m_typeName = _( "Text" );
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawText::Save( FILE* ExportFile ) const
|
||||
{
|
||||
wxString text = m_Text;
|
||||
|
||||
// Spaces are not allowed in text because it is not double quoted:
|
||||
// changed to '~'
|
||||
text.Replace( wxT( " " ), wxT( "~" ) );
|
||||
|
||||
fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient,
|
||||
m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert,
|
||||
CONV_TO_UTF8( text ) );
|
||||
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", (m_Bold>0) ? 1 : 0 );
|
||||
|
||||
char hjustify = 'C';
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
char vjustify = 'C';
|
||||
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
fprintf( ExportFile, " %c %c", hjustify, vjustify );
|
||||
|
||||
fprintf( ExportFile, "\n" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawText::Load( char* line, wxString& errorMsg )
|
||||
{
|
||||
int cnt, thickness;
|
||||
char hjustify = 'C', vjustify = 'C';
|
||||
char buf[256];
|
||||
char tmp[256];
|
||||
|
||||
buf[0] = 0;
|
||||
tmp[0] = 0; // For italic option, Not in old versions
|
||||
|
||||
cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s %s %d %c %c",
|
||||
&m_Orient, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
|
||||
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify, &vjustify );
|
||||
|
||||
if( cnt < 8 )
|
||||
{
|
||||
errorMsg.Printf( _( "text only had %d parameters of the required 8" ),
|
||||
cnt );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Size.y = m_Size.x;
|
||||
|
||||
if( strnicmp( tmp, "Italic", 6 ) == 0 )
|
||||
m_Italic = true;
|
||||
if( thickness > 0 )
|
||||
{
|
||||
m_Bold = true;
|
||||
}
|
||||
|
||||
switch( hjustify )
|
||||
{
|
||||
case 'L':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
switch( vjustify )
|
||||
{
|
||||
case 'T':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert '~' to spaces. */
|
||||
m_Text = CONV_FROM_UTF8( buf );
|
||||
m_Text.Replace( wxT( "~" ), wxT( " " ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param refPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawText::HitTest( const wxPoint& refPos )
|
||||
{
|
||||
// if using TextHitTest() remember this function uses top to bottom y axis convention
|
||||
// and for lib items we are using bottom to top convention
|
||||
// so for non center Y justification we use a trick.
|
||||
GRTextVertJustifyType vJustify = m_VJustify;
|
||||
if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
else if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
|
||||
bool hit = TextHitTest(refPos);
|
||||
m_VJustify = vJustify;
|
||||
|
||||
return hit;
|
||||
}
|
||||
|
||||
|
||||
LibDrawText* LibDrawText::GenCopy()
|
||||
{
|
||||
LibDrawText* newitem = new LibDrawText();
|
||||
|
||||
newitem->m_Pos = m_Pos;
|
||||
newitem->m_Orient = m_Orient;
|
||||
newitem->m_Size = m_Size;
|
||||
newitem->m_Attributs = m_Attributs;
|
||||
newitem->m_Unit = m_Unit;
|
||||
newitem->m_Convert = m_Convert;
|
||||
newitem->m_Flags = m_Flags;
|
||||
newitem->m_Text = m_Text;
|
||||
newitem->m_Width = m_Width;
|
||||
newitem->m_Italic = m_Italic;
|
||||
newitem->m_Bold = m_Bold;
|
||||
newitem->m_HJustify = m_HJustify;
|
||||
newitem->m_VJustify = m_VJustify;
|
||||
return newitem;
|
||||
}
|
||||
|
||||
|
||||
void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
||||
const wxPoint& aOffset, int aColor, int aDrawMode,
|
||||
void* aData, const int aTransformMatrix[2][2] )
|
||||
{
|
||||
wxPoint pos1, pos2;
|
||||
|
||||
int color = ReturnLayerColor( LAYER_DEVICE );
|
||||
int linewidth = m_Width;
|
||||
|
||||
if( linewidth == 0 ) // Use default values for pen size
|
||||
{
|
||||
if( m_Bold )
|
||||
linewidth = GetPenSizeForBold( m_Size.x );
|
||||
else
|
||||
linewidth = g_DrawDefaultLineThickness;
|
||||
}
|
||||
|
||||
// Clip pen size for small texts:
|
||||
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
|
||||
|
||||
if( aColor < 0 ) // Used normal color or selected color
|
||||
{
|
||||
if( ( m_Selected & IS_SELECTED ) )
|
||||
color = g_ItemSelectetColor;
|
||||
}
|
||||
else
|
||||
color = aColor;
|
||||
|
||||
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
|
||||
|
||||
/* The text orientation may need to be flipped if the
|
||||
* transformation matrix causes xy axes to be flipped. */
|
||||
int t1 = ( aTransformMatrix[0][0] != 0 ) ^ ( m_Orient != 0 );
|
||||
|
||||
DrawGraphicText( aPanel, aDC, pos1, (EDA_Colors) color, m_Text,
|
||||
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
|
||||
m_Size, m_HJustify, m_VJustify,
|
||||
linewidth, m_Italic, m_Bold );
|
||||
}
|
||||
|
||||
|
||||
void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
LibEDA_BaseStruct::DisplayInfo( frame );
|
||||
|
||||
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
|
||||
EESCHEMA_INTERNAL_UNIT, true );
|
||||
|
||||
frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE );
|
||||
}
|
||||
|
||||
|
||||
/*************************/
|
||||
/** class LibDrawSquare **/
|
||||
|
@ -857,6 +663,62 @@ EDA_Rect LibDrawSquare::GetBoundingBox()
|
|||
return rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPoint A wxPoint to test in eeschema space
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawSquare::HitTest( const wxPoint& aRefPoint )
|
||||
{
|
||||
|
||||
int mindist = (m_Width ? m_Width /2 : g_DrawDefaultLineThickness / 2) + 1;
|
||||
// Have a minimal tolerance for hit test
|
||||
if ( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
|
||||
return HitTest( aRefPoint, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aRefPoint = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
wxPoint actualStart = TransformCoordinate( aTransMat, m_Pos);
|
||||
wxPoint actualEnd = TransformCoordinate( aTransMat, m_End);
|
||||
|
||||
// locate lower segment
|
||||
wxPoint start, end;
|
||||
start = actualStart;
|
||||
end.x = actualEnd.x;
|
||||
end.y = actualStart.y;
|
||||
if( TestSegmentHit( aRefPoint, start, end, aThreshold ) )
|
||||
return true;
|
||||
|
||||
// locate right segment
|
||||
start.x = actualEnd.x;
|
||||
end.y = actualEnd.y;
|
||||
if( TestSegmentHit( aRefPoint, start, end, aThreshold ) )
|
||||
return true;
|
||||
|
||||
// locate upper segment
|
||||
start.y = actualEnd.y;
|
||||
end.x = actualStart.x;
|
||||
if( TestSegmentHit( aRefPoint, start, end, aThreshold ) )
|
||||
return true;
|
||||
|
||||
// locate left segment
|
||||
start.x = actualStart.x;
|
||||
end.x = actualStart.y;
|
||||
if( TestSegmentHit( aRefPoint, start, end, aThreshold ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/** class LibDrawSegment **/
|
||||
|
@ -939,6 +801,36 @@ void LibDrawSegment::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
frame->MsgPanel->Affiche_1_Parametre( 60, _( "Bounding box" ), msg, BROWN );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawSegment::HitTest( const wxPoint& aPosRef )
|
||||
{
|
||||
int mindist = m_Width ? m_Width /2 : g_DrawDefaultLineThickness / 2;
|
||||
// Have a minimal tolerance for hit test
|
||||
if ( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
|
||||
return HitTest( aPosRef, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
|
||||
{
|
||||
wxPoint start = TransformCoordinate( aTransMat, m_Pos );
|
||||
wxPoint end = TransformCoordinate( aTransMat, m_End );
|
||||
|
||||
return TestSegmentHit( aPosRef, start, end, aThreshold );
|
||||
}
|
||||
|
||||
|
||||
/***************************/
|
||||
/** class LibDrawPolyline **/
|
||||
|
@ -1108,6 +1000,21 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool LibDrawPolyline::HitTest( const wxPoint& aRefPos )
|
||||
{
|
||||
int mindist = m_Width ? m_Width /2 : g_DrawDefaultLineThickness / 2;
|
||||
// Have a minimal tolerance for hit test
|
||||
if ( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
return HitTest( aRefPos, mindist, DefaultTransformMatrix );
|
||||
}
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near a segment
|
||||
* @param aPosRef = a wxPoint to test
|
||||
|
@ -1123,10 +1030,8 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold,
|
|||
{
|
||||
start = TransformCoordinate( aTransMat, m_PolyPoints[ii - 1] );
|
||||
end = TransformCoordinate( aTransMat, m_PolyPoints[ii] );
|
||||
ref = aPosRef - start;
|
||||
end -= start;
|
||||
|
||||
if( distance( end.x, end.y, ref.x, ref.y, aThreshold ) )
|
||||
if ( TestSegmentHit( aPosRef, start, end, aThreshold ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,29 @@ public:
|
|||
virtual bool Save( FILE* aFile ) const = 0;
|
||||
virtual bool Load( char* line, wxString& errorMsg ) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param refPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& refPos )
|
||||
{
|
||||
return false; // derived classes should override this function
|
||||
}
|
||||
|
||||
/** Function HitTest (overlayed)
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) = 0;
|
||||
|
||||
/** Function GetBoundingBox
|
||||
* @return the boundary box for this, in library coordinates
|
||||
*/
|
||||
virtual EDA_Rect GetBoundingBox()
|
||||
{
|
||||
return EDA_BaseStruct::GetBoundingBox();
|
||||
|
@ -188,8 +211,12 @@ public:
|
|||
int m_PinNumSize;
|
||||
int m_PinNameSize; /* Pin num and Pin name sizes */
|
||||
|
||||
// int m_PinNumWidth, m_PinNameWidth; /* (Currently Unused) Pin num and Pin name text width */
|
||||
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
|
||||
// (Currently Unused) Pin num and Pin name text opt: italic/normal/bold, 0 = default:
|
||||
char m_PinNumShapeOpt, m_PinNameShapeOpt;
|
||||
// (Currently Unused) Pin num and Pin name text opt position, 0 = default:
|
||||
char m_PinNumPositionOpt, m_PinNamePositionOpt;
|
||||
|
||||
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
|
||||
* point (segments) */
|
||||
int m_Width; /* Line width */
|
||||
|
||||
|
@ -217,6 +244,22 @@ public:
|
|||
virtual bool Load( char* line, wxString& errorMsg );
|
||||
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
LibDrawPin* GenCopy();
|
||||
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
|
||||
virtual EDA_Rect GetBoundingBox();
|
||||
|
@ -288,7 +331,14 @@ public:
|
|||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
LibDrawArc* GenCopy();
|
||||
|
||||
|
@ -339,6 +389,14 @@ public:
|
|||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
LibDrawCircle* GenCopy();
|
||||
|
||||
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
||||
|
@ -385,6 +443,14 @@ public:
|
|||
*/
|
||||
virtual bool HitTest( const wxPoint& refPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near a segment
|
||||
* @param aPosRef = a wxPoint to test, in eeschema coordinates
|
||||
* @param aThreshold = max distance to a segment
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
/**
|
||||
* Function HitTest (overlayed)
|
||||
* tests if the given EDA_Rect intersect this object.
|
||||
|
@ -436,6 +502,22 @@ public:
|
|||
virtual bool Save( FILE* aFile ) const;
|
||||
virtual bool Load( char* line, wxString& errorMsg );
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
LibDrawSquare* GenCopy();
|
||||
|
||||
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
||||
|
@ -476,6 +558,22 @@ public:
|
|||
virtual bool Save( FILE* aFile ) const;
|
||||
virtual bool Load( char* line, wxString& errorMsg );
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
LibDrawSegment* GenCopy();
|
||||
|
||||
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
||||
|
@ -523,13 +621,21 @@ public:
|
|||
*/
|
||||
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
virtual bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near a segment
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to a segment
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
||||
|
||||
/** Function GetBoundingBox
|
||||
* @return the boundary box for this, in library coordinates
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "fctsys.h"
|
||||
#include "appl_wxstruct.h"
|
||||
#include "common.h"
|
||||
#include "trigo.h"
|
||||
#include "confirm.h"
|
||||
#include "class_drawpickedstruct.h"
|
||||
#include "program.h"
|
||||
|
@ -16,8 +17,7 @@
|
|||
|
||||
|
||||
/* Routines locales */
|
||||
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
|
||||
EDA_DrawLineStruct* TstSegm );
|
||||
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm );
|
||||
|
||||
/* Variable locales */
|
||||
|
||||
|
@ -37,7 +37,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
|
|||
|
||||
WinEDA_SchematicFrame* frame;
|
||||
|
||||
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
|
||||
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
||||
|
||||
DrawList = EEDrawList;
|
||||
for( ; DrawList != NULL; DrawList = DrawList->Next() )
|
||||
|
@ -50,7 +50,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
|
|||
if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
||||
{
|
||||
flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList,
|
||||
(EDA_DrawLineStruct*) TstDrawList );
|
||||
(EDA_DrawLineStruct*) TstDrawList );
|
||||
if( flag ) /* Suppression de TstSegm */
|
||||
{
|
||||
/* keep the bits set in .m_Flags, because the deleted segment can be flagged */
|
||||
|
@ -87,7 +87,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
|
|||
if( Screen == NULL )
|
||||
{
|
||||
DisplayError( NULL,
|
||||
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
|
||||
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,6 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
|
|||
{
|
||||
EDA_BaseStruct* DrawList;
|
||||
EDA_DrawLineStruct* segment, * NewSegment;
|
||||
int ox, oy, fx, fy;
|
||||
DrawPickedStruct* List = NULL;
|
||||
|
||||
DrawList = screen->EEDrawList;
|
||||
|
@ -154,17 +153,13 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
|
|||
{
|
||||
case DRAW_SEGMENT_STRUCT_TYPE:
|
||||
segment = (EDA_DrawLineStruct*) DrawList;
|
||||
ox = segment->m_Start.x; oy = segment->m_Start.y;
|
||||
fx = segment->m_End.x; fy = segment->m_End.y;
|
||||
if( distance( fx - ox, fy - oy, breakpoint.x - ox, breakpoint.y -
|
||||
oy, 0 ) == 0 )
|
||||
|
||||
if( !TestSegmentHit( breakpoint, segment->m_Start, segment->m_End, 0 ) )
|
||||
break;
|
||||
|
||||
/* Segment connecte: doit etre coupe en 2 si px,py n'est
|
||||
* pas une extremite */
|
||||
if( (ox == breakpoint.x) && (oy == breakpoint.y ) )
|
||||
break;
|
||||
if( (fx == breakpoint.x) && (fy == breakpoint.y ) )
|
||||
if( (segment->m_Start == breakpoint) || (segment->m_End == breakpoint ) )
|
||||
break;
|
||||
/* Ici il faut couper le segment en 2 */
|
||||
if( PutInUndoList ) // First: put copy of the old segment in undo list
|
||||
|
|
|
@ -15,15 +15,11 @@
|
|||
|
||||
#include "protos.h"
|
||||
|
||||
/* Routines exportees */
|
||||
int distance( int dx, int dy, int spot_cX, int spot_cY, int seuil );
|
||||
|
||||
/* Routines Locales */
|
||||
static SCH_ITEM* LastSnappedStruct = NULL;
|
||||
static int PickedBoxMinX, PickedBoxMinY, PickedBoxMaxX, PickedBoxMaxY;
|
||||
static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
|
||||
int StartX2, int StartY2, int EndX2, int EndY2 );
|
||||
static bool IsPointOnSegment( wxPoint aPosRef, wxPoint aSegmStart, wxPoint aSegmEnd, int aDist = 0 );
|
||||
static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
||||
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, double aScaleFactor );
|
||||
|
||||
|
@ -208,6 +204,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
|||
if( DontSnap->m_PickedStruct == DrawList )
|
||||
continue;
|
||||
|
||||
int hitminDist = MAX( g_DrawDefaultLineThickness, 3 ) ;
|
||||
switch( DrawList->Type() )
|
||||
{
|
||||
case DRAW_POLYLINE_STRUCT_TYPE:
|
||||
|
@ -218,8 +215,8 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
|||
|
||||
for( unsigned i = 0; i < STRUCT->GetCornerCount() - 1; i++ )
|
||||
{
|
||||
if( IsPointOnSegment( aPosRef, STRUCT->m_PolyPoints[i],
|
||||
STRUCT->m_PolyPoints[i + 1] ) )
|
||||
if( TestSegmentHit( aPosRef, STRUCT->m_PolyPoints[i],
|
||||
STRUCT->m_PolyPoints[i + 1], hitminDist ) )
|
||||
{
|
||||
LastSnappedStruct = DrawList;
|
||||
return TRUE;
|
||||
|
@ -234,7 +231,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
|||
if( !( SearchMask & (DRAWITEM | WIREITEM | BUSITEM) ) )
|
||||
break;
|
||||
|
||||
if( IsPointOnSegment( aPosRef, STRUCT->m_Start, STRUCT->m_End ) )
|
||||
if( TestSegmentHit( aPosRef, STRUCT->m_Start, STRUCT->m_End, 0 ) )
|
||||
{
|
||||
if( ( (SearchMask & DRAWITEM) && (STRUCT->GetLayer() == LAYER_NOTES) )
|
||||
|| ( (SearchMask & WIREITEM) && (STRUCT->GetLayer() == LAYER_WIRE) )
|
||||
|
@ -266,7 +263,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
|
|||
if( !( SearchMask & (RACCORDITEM) ) )
|
||||
break;
|
||||
|
||||
if( IsPointOnSegment( aPosRef, STRUCT->m_Pos, STRUCT->m_End() ) )
|
||||
if( TestSegmentHit( aPosRef, STRUCT->m_Pos, STRUCT->m_End(), hitminDist ) )
|
||||
{
|
||||
LastSnappedStruct = DrawList;
|
||||
return TRUE;
|
||||
|
@ -654,25 +651,6 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
|
|||
}
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
static bool IsPointOnSegment( wxPoint aPosRef, wxPoint aSegmStart, wxPoint aSegmEnd, int aDist )
|
||||
/********************************************************************************/
|
||||
|
||||
/* Routine detectant que le point pX,pY est sur le Segment X1,Y1 a X2,Y2
|
||||
* Retourne TRUE ou FALSE.
|
||||
*/
|
||||
{
|
||||
/* Move coordinates origin to aSegmStart */
|
||||
aPosRef -= aSegmStart;
|
||||
aSegmEnd -= aSegmStart;
|
||||
|
||||
if( distance( aSegmEnd.x, aSegmEnd.y, aPosRef.x, aPosRef.y, aDist ) )
|
||||
return TRUE;
|
||||
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************/
|
||||
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
||||
|
@ -702,15 +680,6 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
|||
|
||||
DrawItem = LibEntry->m_Drawings;
|
||||
|
||||
int seuil = 3; /* Tolerance: 1/2 pas de petite grille */
|
||||
|
||||
// Calculates aRefPoint according to library components Y axis convention:
|
||||
// Y axis is bottom to top
|
||||
// RefPoint Y is top to bottom
|
||||
// so negate the aRefPoint Y coordinate value does the trick
|
||||
wxPoint pointInLibitemsSpace = aRefPoint;
|
||||
NEGATE( pointInLibitemsSpace.y );
|
||||
|
||||
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
||||
{
|
||||
if( Unit && DrawItem->m_Unit && (Unit != DrawItem->m_Unit) )
|
||||
|
@ -721,88 +690,45 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
|||
switch( DrawItem->Type() )
|
||||
{
|
||||
case COMPONENT_ARC_DRAW_TYPE:
|
||||
{
|
||||
LibDrawArc* Arc = (LibDrawArc*) DrawItem;
|
||||
if( (masque & LOCATE_COMPONENT_ARC_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
if( Arc->HitTest( pointInLibitemsSpace ) )
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_CIRCLE_DRAW_TYPE:
|
||||
{
|
||||
LibDrawCircle* Circle = (LibDrawCircle*) DrawItem;
|
||||
if( (masque & LOCATE_COMPONENT_CIRCLE_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
if( Circle->HitTest( pointInLibitemsSpace ) )
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_RECT_DRAW_TYPE:
|
||||
{ // Locate a rect if the mouse cursor is on a side of this rectangle
|
||||
LibDrawSquare* Square = (LibDrawSquare*) DrawItem;
|
||||
case COMPONENT_RECT_DRAW_TYPE: // Locate a rect if the mouse cursor is on a side of this rectangle
|
||||
if( (masque & LOCATE_COMPONENT_RECT_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
wxPoint start, end;
|
||||
start.x = Square->m_Pos.x;
|
||||
start.y = -Square->m_Pos.y;
|
||||
end.x = Square->m_End.x;
|
||||
end.y = -Square->m_Pos.y;
|
||||
|
||||
// locate lower segment
|
||||
if( IsPointOnSegment( aRefPoint, start, end, seuil ) )
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
|
||||
// locate right segment
|
||||
start.x = Square->m_End.x;
|
||||
end.y = -Square->m_End.y;
|
||||
if( IsPointOnSegment( aRefPoint, start, end, seuil ) )
|
||||
return DrawItem;
|
||||
|
||||
// locate upper segment
|
||||
start.y = -Square->m_End.y;
|
||||
end.x = Square->m_Pos.x;
|
||||
if( IsPointOnSegment( aRefPoint, start, end, seuil ) )
|
||||
return DrawItem;
|
||||
|
||||
// locate left segment
|
||||
start.x = Square->m_Pos.x;
|
||||
end.x = -Square->m_Pos.y;
|
||||
if( IsPointOnSegment( aRefPoint, start, end, seuil ) )
|
||||
return DrawItem;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case COMPONENT_POLYLINE_DRAW_TYPE:
|
||||
{
|
||||
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
|
||||
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
if( polyline->HitTest( aRefPoint, seuil, DefaultTransformMatrix ) )
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_LINE_DRAW_TYPE:
|
||||
{
|
||||
LibDrawSegment* Segment = (LibDrawSegment*) DrawItem;
|
||||
if( (masque & LOCATE_COMPONENT_LINE_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
if( IsPointOnSegment( pointInLibitemsSpace, Segment->m_Pos, Segment->m_End, seuil ) )
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
}
|
||||
break;
|
||||
|
||||
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
||||
{
|
||||
LibDrawText* Text = (LibDrawText*) DrawItem;
|
||||
if( (masque & LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) == 0 )
|
||||
break;
|
||||
if( Text->HitTest( pointInLibitemsSpace ) )
|
||||
return DrawItem; /* Found! */
|
||||
}
|
||||
if( DrawItem->HitTest( aRefPoint ) )
|
||||
return DrawItem;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -814,117 +740,6 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
int distance( int dx, int dy, int spot_cX, int spot_cY, int seuil )
|
||||
/****************************************************************/
|
||||
|
||||
/*
|
||||
* Calcul de la distance du point spot_cx,spot_cy a un segment de droite,
|
||||
* d'origine 0,0 et d'extremite dx, dy;
|
||||
* retourne:
|
||||
* 0 si distance > seuil
|
||||
* 1 si distance <= seuil
|
||||
* Variables utilisees ( sont ramenees au repere centre sur l'origine du segment)
|
||||
* dx, dy = coord de l'extremite segment.
|
||||
* spot_cX,spot_cY = coord du curseur souris
|
||||
* la recherche se fait selon 4 cas:
|
||||
* segment horizontal
|
||||
* segment vertical
|
||||
* segment quelconque
|
||||
*/
|
||||
{
|
||||
int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */
|
||||
segX, segY; /* coord extremite segment tj >= 0 */
|
||||
int pointX, pointY; /* coord point a tester dans repere modifie dans lequel
|
||||
* segX et segY sont >=0 */
|
||||
|
||||
segX = dx; segY = dy; pointX = spot_cX; pointY = spot_cY;
|
||||
|
||||
/*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/
|
||||
if( segX < 0 ) /* mise en0 par symetrie par rapport a l'axe Y */
|
||||
{
|
||||
segX = -segX; pointX = -pointX;
|
||||
}
|
||||
if( segY < 0 ) /* mise en > 0 par symymetrie par rapport a l'axe X */
|
||||
{
|
||||
segY = -segY; pointY = -pointY;
|
||||
}
|
||||
|
||||
|
||||
if( segY == 0 ) /* piste Horizontale */
|
||||
{
|
||||
if( abs( pointY ) <= seuil )
|
||||
{
|
||||
if( (pointX >= 0) && (pointX <= segX) )
|
||||
return 1;
|
||||
/* Etude des extremites : cercle de rayon seuil */
|
||||
if( (pointX < 0) && (pointX >= -seuil) )
|
||||
{
|
||||
if( ( (pointX * pointX) + (pointY * pointY) ) <= (seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
if( (pointX > segX) && ( pointX <= (segX + seuil) ) )
|
||||
{
|
||||
if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <=
|
||||
(seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( segX == 0 ) /* piste verticale */
|
||||
{
|
||||
if( abs( pointX ) <= seuil )
|
||||
{
|
||||
if( (pointY >= 0 ) && (pointY <= segY) )
|
||||
return 1;
|
||||
if( (pointY < 0) && (pointY >= -seuil) )
|
||||
{
|
||||
if( ( (pointY * pointY) + (pointX * pointX) ) <= (seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
if( (pointY > segY) && ( pointY <= (segY + seuil) ) )
|
||||
{
|
||||
if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <=
|
||||
(seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* orientation quelconque */
|
||||
{
|
||||
/* On fait un changement d'axe (rotation) de facon a ce que le segment
|
||||
* de piste soit horizontal dans le nouveau repere */
|
||||
int angle;
|
||||
|
||||
angle = (int) ( atan2( (double) segY, (double) segX ) * 1800 / M_PI );
|
||||
cXrot = pointX; cYrot = pointY;
|
||||
RotatePoint( &cXrot, &cYrot, angle ); /* Rotation du point a tester */
|
||||
RotatePoint( &segX, &segY, angle ); /* Rotation du segment */
|
||||
|
||||
/*la piste est Horizontale , par suite des modifs de coordonnes
|
||||
* et d'axe, donc segX = longueur du segment */
|
||||
|
||||
if( abs( cYrot ) <= seuil ) /* ok sur axe vertical) */
|
||||
{
|
||||
if( (cXrot >= 0) && (cXrot <= segX) )
|
||||
return 1;
|
||||
/* Etude des extremites : cercle de rayon seuil */
|
||||
if( (cXrot < 0) && (cXrot >= -seuil) )
|
||||
{
|
||||
if( ( (cXrot * cXrot) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
if( (cXrot > segX) && ( cXrot <= (segX + seuil) ) )
|
||||
{
|
||||
if( ( ( (cXrot - segX) * (cXrot - segX) ) + (cYrot * cYrot) ) <= (seuil * seuil) )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
|
||||
SCH_COMPONENT* eComponent )
|
||||
|
@ -989,10 +804,6 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
|
|||
* Si convert = 0, le numero convert n'est pas teste
|
||||
*/
|
||||
{
|
||||
LibEDA_BaseStruct* DrawItem;
|
||||
LibDrawPin* Pin;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
if( Entry == NULL )
|
||||
return NULL;
|
||||
|
||||
|
@ -1002,12 +813,12 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
DrawItem = Entry->m_Drawings;
|
||||
LibEDA_BaseStruct* DrawItem = Entry->m_Drawings;
|
||||
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
|
||||
{
|
||||
if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */
|
||||
{
|
||||
Pin = (LibDrawPin*) DrawItem;
|
||||
LibDrawPin* Pin = (LibDrawPin*) DrawItem;
|
||||
|
||||
if( Unit && DrawItem->m_Unit && (DrawItem->m_Unit != Unit) )
|
||||
continue;
|
||||
|
@ -1015,36 +826,22 @@ LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
|
|||
if( convert && DrawItem->m_Convert && (DrawItem->m_Convert != convert) )
|
||||
continue;
|
||||
|
||||
x2 = Pin->m_Pos.x;
|
||||
y2 = Pin->m_Pos.y;
|
||||
x1 = Pin->ReturnPinEndPoint().x;
|
||||
y1 = Pin->ReturnPinEndPoint().y;
|
||||
|
||||
if( DrawLibItem == NULL )
|
||||
{
|
||||
y1 = -y1; y2 = -y2;
|
||||
if ( Pin->HitTest( RefPos ) )
|
||||
return DrawItem;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int x = x1, y = y1;
|
||||
x1 = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] *x
|
||||
+ DrawLibItem->m_Transform[0][1] *y;
|
||||
y1 = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] *x
|
||||
+ DrawLibItem->m_Transform[1][1] *y;
|
||||
x = x2; y = y2;
|
||||
x2 = DrawLibItem->m_Pos.x + DrawLibItem->m_Transform[0][0] *x
|
||||
+ DrawLibItem->m_Transform[0][1] *y;
|
||||
y2 = DrawLibItem->m_Pos.y + DrawLibItem->m_Transform[1][0] *x
|
||||
+ DrawLibItem->m_Transform[1][1] *y;
|
||||
int mindist = Pin->m_Width ? Pin->m_Width / 2 : g_DrawDefaultLineThickness / 2;
|
||||
|
||||
// Have a minimal tolerance for hit test
|
||||
if( mindist < 3 )
|
||||
mindist = 3; // = 3 mils
|
||||
if ( Pin->HitTest( RefPos - DrawLibItem->m_Pos, mindist, DrawLibItem->m_Transform ) )
|
||||
return DrawItem;
|
||||
}
|
||||
|
||||
if( x1 > x2 )
|
||||
EXCHG( x1, x2 );if( y1 > y2 )
|
||||
EXCHG( y1, y2 );
|
||||
|
||||
if( (RefPos.x >= x1) && (RefPos.x <= x2)
|
||||
&& (RefPos.y >= y1) && (RefPos.y <= y2) )
|
||||
return DrawItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,12 +139,12 @@ SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMas
|
|||
|
||||
|
||||
Return:
|
||||
-Bloc searc:
|
||||
-Bloc search:
|
||||
pointeur sur liste de pointeurs de structures si Plusieurs
|
||||
structures selectionnees.
|
||||
pointeur sur la structure si 1 seule
|
||||
|
||||
Positon serach:
|
||||
Positon search:
|
||||
pointeur sur la structure.
|
||||
Si pas de structures selectionnees: retourne NULL */
|
||||
|
||||
|
@ -160,20 +160,6 @@ LibDrawPin * LocateAnyPin(SCH_ITEM *DrawList, const wxPoint & RefPos,
|
|||
Hierarchical_PIN_Sheet_Struct * LocateAnyPinSheet(const wxPoint & RefPos,
|
||||
SCH_ITEM *DrawList);
|
||||
|
||||
int distance(int dx, int dy, int spot_cX, int spot_cY, int seuil);
|
||||
/* Calcul de la distance du point spot_cx,spot_cy a un segment de droite,
|
||||
d'origine 0,0 et d'extremite dx, dy;
|
||||
retourne:
|
||||
0 si distance > seuil
|
||||
1 si distance <= seuil
|
||||
Variables utilisees ( sont ramenees au repere centre sur l'origine du segment)
|
||||
dx, dy = coord de l'extremite segment.
|
||||
spot_cX,spot_cY = coord du curseur souris
|
||||
la recherche se fait selon 4 cas:
|
||||
segment horizontal
|
||||
segment vertical
|
||||
segment quelconque */
|
||||
|
||||
|
||||
/***************/
|
||||
/* EEREDRAW.CPP */
|
||||
|
|
|
@ -271,13 +271,8 @@ void InitKiCadAbout( wxAboutDialogInfo& info);
|
|||
wxString GetBuildVersion(); /* Return the build date */
|
||||
wxString GetAboutBuildVersion(); /* Return custom build date for about dialog */
|
||||
|
||||
void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
|
||||
int pos_X,
|
||||
const wxString& texte_H,
|
||||
const wxString& texte_L,
|
||||
int color );
|
||||
|
||||
/*
|
||||
/**
|
||||
* function Affiche_1_Parametre
|
||||
* Routine d'affichage d'un parametre.
|
||||
* pos_X = cadrage horizontal
|
||||
* si pos_X < 0 : la position horizontale est la derniere
|
||||
|
@ -288,6 +283,11 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
|
|||
* si "", par d'affichage sur cette ligne
|
||||
* color = couleur d'affichage
|
||||
*/
|
||||
void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
|
||||
int pos_X,
|
||||
const wxString& texte_H,
|
||||
const wxString& texte_L,
|
||||
int color );
|
||||
|
||||
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
|
||||
const wxString& KeyW );
|
||||
|
|
|
@ -14,15 +14,27 @@ void RotatePoint( wxPoint* point, int angle );
|
|||
void RotatePoint( wxPoint *point, const wxPoint & centre, int angle );
|
||||
void RotatePoint( double *pX, double *pY, int angle );
|
||||
void RotatePoint( double *pX, double *pY, double cx, double cy, int angle );
|
||||
int ArcTangente( int dy, int dx );
|
||||
/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
|
||||
|
||||
/** function ArcTangente
|
||||
Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
|
||||
entre -1800 et 1800
|
||||
Analogue a atan2 ( mais plus rapide pour les caculs si
|
||||
l'angle est souvent 0, -1800, ou +- 900 */
|
||||
int ArcTangente( int dy, int dx );
|
||||
|
||||
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY );
|
||||
|
||||
|
||||
/** Function TestSegmentHit
|
||||
* test for hit on line segment
|
||||
* i.e. cursor within a given distance from segment
|
||||
* @param aRefPoint = cursor (point to test) coords
|
||||
* @param aStart is the first end-point of the line segment
|
||||
* @param aEnd is the second end-point of the line segment
|
||||
* @param aDist = maximum distance for hit
|
||||
*/
|
||||
bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist );
|
||||
|
||||
/*******************/
|
||||
/* Macro NEW_COORD */
|
||||
/*******************/
|
||||
|
|
Loading…
Reference in New Issue