Eradicate g_UserUnit from ERC/DRC.

(cherry picked from commit 98b8cd4)
This commit is contained in:
Jeff Young 2018-06-15 05:49:50 +01:00
parent 2ff414adb4
commit ef3e045a9b
16 changed files with 90 additions and 91 deletions

View File

@ -103,14 +103,14 @@ MARKER_BASE::MARKER_BASE()
} }
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, MARKER_BASE::MARKER_BASE( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* aItem, const wxPoint& aPos,
EDA_ITEM* bItem, const wxPoint& bPos ) EDA_ITEM* bItem, const wxPoint& bPos )
{ {
m_ScalingFactor = M_SHAPE_SCALE; m_ScalingFactor = M_SHAPE_SCALE;
init(); init();
SetData( aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos ); SetData( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos );
} }
@ -130,6 +130,7 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
{ {
m_ScalingFactor = M_SHAPE_SCALE; m_ScalingFactor = M_SHAPE_SCALE;
init(); init();
SetData( aErrorCode, aMarkerPos, aText, aPos ); SetData( aErrorCode, aMarkerPos, aText, aPos );
} }
@ -139,12 +140,12 @@ MARKER_BASE::~MARKER_BASE()
} }
void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, void MARKER_BASE::SetData( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* aItem, const wxPoint& aPos,
EDA_ITEM* bItem, const wxPoint& bPos ) EDA_ITEM* bItem, const wxPoint& bPos )
{ {
m_Pos = aMarkerPos; m_Pos = aMarkerPos;
m_drc.SetData( aErrorCode, aItem, aPos, bItem, bPos ); m_drc.SetData( aUnits, aErrorCode, aItem, aPos, bItem, bPos );
m_drc.SetParent( this ); m_drc.SetParent( this );
} }
@ -207,7 +208,7 @@ void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDr
void MARKER_BASE::DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame ) void MARKER_BASE::DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame )
{ {
wxString msg = m_drc.ShowHtml(); wxString msg = m_drc.ShowHtml( aFrame->GetUserUnits() );
DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ), DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ),
wxGetMousePosition(), wxSize( 550, 140 ) ); wxGetMousePosition(), wxSize( 550, 140 ) );

View File

@ -68,7 +68,7 @@ public:
* Function DisplayList(); * Function DisplayList();
* Build the Html marker list and show it * Build the Html marker list and show it
*/ */
void DisplayList() void DisplayList( EDA_UNITS_T aUnits )
{ {
wxString htmlpage; wxString htmlpage;
wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
@ -82,7 +82,7 @@ public:
for( unsigned ii = 0; ii < m_MarkerListReferences.size(); ii++ ) for( unsigned ii = 0; ii < m_MarkerListReferences.size(); ii++ )
{ {
href.Printf( wxT( "href='%d'" ), ii ); href.Printf( wxT( "href='%d'" ), ii );
marker_text = m_MarkerListReferences[ii]->GetReporter().ShowHtml(); marker_text = m_MarkerListReferences[ii]->GetReporter().ShowHtml( aUnits );
marker_text.Replace( wxT( "href=''"), href ); marker_text.Replace( wxT( "href=''"), href );
htmlpage += marker_text; htmlpage += marker_text;
} }

View File

@ -409,7 +409,7 @@ void DIALOG_ERC::DisplayERC_MarkersList()
} }
} }
m_MarkersList->DisplayList(); m_MarkersList->DisplayList( GetUserUnits() );
} }
@ -637,7 +637,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
if( WriteDiagnosticERC( dlg.GetPath() ) ) if( WriteDiagnosticERC( GetUserUnits(), dlg.GetPath() ) )
ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) ); ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) );
} }
} }

View File

@ -77,7 +77,7 @@ wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos )
} }
wxString DRC_ITEM::ShowHtml() const wxString DRC_ITEM::ShowHtml( EDA_UNITS_T aUnits ) const
{ {
wxString mainText = m_MainText; wxString mainText = m_MainText;
// a wxHtmlWindows does not like < and > in the text to display // a wxHtmlWindows does not like < and > in the text to display
@ -107,9 +107,9 @@ wxString DRC_ITEM::ShowHtml() const
return wxString::Format( _( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s<br>&nbsp;&nbsp; %s: %s" ), return wxString::Format( _( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s<br>&nbsp;&nbsp; %s: %s" ),
errText, errText,
hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), hrefColour.GetAsString( wxC2S_HTML_SYNTAX ),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
mainText, mainText,
ShowCoord( g_UserUnit, m_AuxiliaryPosition ), ShowCoord( aUnits, m_AuxiliaryPosition ),
auxText ); auxText );
} }
else else
@ -117,22 +117,22 @@ wxString DRC_ITEM::ShowHtml() const
return wxString::Format( _( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s" ), return wxString::Format( _( "<p><b>%s</b><br>&nbsp;&nbsp; <font color='%s'><a href=''>%s</a></font>: %s" ),
errText, errText,
hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), hrefColour.GetAsString( wxC2S_HTML_SYNTAX ),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
mainText ); mainText );
} }
} }
wxString DRC_ITEM::ShowReport() const wxString DRC_ITEM::ShowReport( EDA_UNITS_T aUnits ) const
{ {
if( m_hasSecondItem ) if( m_hasSecondItem )
{ {
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
m_ErrorCode, m_ErrorCode,
GetErrorText(), GetErrorText(),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
m_MainText, m_MainText,
ShowCoord( g_UserUnit, m_AuxiliaryPosition ), ShowCoord( aUnits, m_AuxiliaryPosition ),
m_AuxiliaryText ); m_AuxiliaryText );
} }
else else
@ -140,7 +140,7 @@ wxString DRC_ITEM::ShowReport() const
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ), return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
m_ErrorCode, m_ErrorCode,
GetErrorText(), GetErrorText(),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
m_MainText ); m_MainText );
} }
} }

View File

@ -580,7 +580,7 @@ int NETLIST_OBJECT_LIST::CountPinsInNet( unsigned aNetStart )
return count; return count;
} }
bool WriteDiagnosticERC( const wxString& aFullFileName ) bool WriteDiagnosticERC( EDA_UNITS_T aUnits, const wxString& aFullFileName )
{ {
wxString msg; wxString msg;
@ -621,7 +621,7 @@ bool WriteDiagnosticERC( const wxString& aFullFileName )
if( marker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_WARNING ) if( marker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_WARNING )
warn_count++; warn_count++;
msg << marker->GetReporter().ShowReport(); msg << marker->GetReporter().ShowReport( aUnits );
} }
} }

View File

@ -79,7 +79,7 @@ extern const wxString CommentERC_V[];
* *
* @param aFullFileName A wxString object containing the file name and path. * @param aFullFileName A wxString object containing the file name and path.
*/ */
bool WriteDiagnosticERC( const wxString& aFullFileName ); bool WriteDiagnosticERC( EDA_UNITS_T aUnits, const wxString& aFullFileName );
/** /**
* Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef * Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef

View File

@ -72,10 +72,10 @@ public:
m_auxItemWeakRef = nullptr; m_auxItemWeakRef = nullptr;
} }
DRC_ITEM( int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos, DRC_ITEM( EDA_UNITS_T aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos,
EDA_ITEM* bAuxiliaryItem, const wxPoint& bAuxiliaryPos ) EDA_ITEM* bAuxiliaryItem, const wxPoint& bAuxiliaryPos )
{ {
SetData( aErrorCode, aMainItem, aMainPos, bAuxiliaryItem, bAuxiliaryPos ); SetData( aUnits, aErrorCode, aMainItem, aMainPos, bAuxiliaryItem, bAuxiliaryPos );
} }
@ -88,11 +88,11 @@ public:
* @param aMainPos = position the first item and therefore of this issue * @param aMainPos = position the first item and therefore of this issue
* @param bAuxiliaryPos = position the second item * @param bAuxiliaryPos = position the second item
*/ */
void SetData( int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos, void SetData( EDA_UNITS_T aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos,
EDA_ITEM* bAuxiliaryItem = nullptr, const wxPoint& bAuxiliaryPos = wxPoint() ) EDA_ITEM* bAuxiliaryItem = nullptr, const wxPoint& bAuxiliaryPos = wxPoint() )
{ {
m_ErrorCode = aErrorCode; m_ErrorCode = aErrorCode;
m_MainText = aMainItem->GetSelectMenuText( g_UserUnit ); m_MainText = aMainItem->GetSelectMenuText( aUnits );
m_AuxiliaryText = wxEmptyString; m_AuxiliaryText = wxEmptyString;
m_MainPosition = aMainPos; m_MainPosition = aMainPos;
m_AuxiliaryPosition = bAuxiliaryPos; m_AuxiliaryPosition = bAuxiliaryPos;
@ -101,7 +101,7 @@ public:
m_parent = nullptr; m_parent = nullptr;
if( m_hasSecondItem ) if( m_hasSecondItem )
m_AuxiliaryText = bAuxiliaryItem->GetSelectMenuText( g_UserUnit ); m_AuxiliaryText = bAuxiliaryItem->GetSelectMenuText( aUnits );
// Weak references (void*). One must search the BOARD_ITEMS or SCH_ITEMS for a match. // Weak references (void*). One must search the BOARD_ITEMS or SCH_ITEMS for a match.
m_mainItemWeakRef = aMainItem; m_mainItemWeakRef = aMainItem;
@ -174,7 +174,7 @@ public:
* wxWidget's wxHtmlListBox class. * wxWidget's wxHtmlListBox class.
* @return wxString - the html text. * @return wxString - the html text.
*/ */
wxString ShowHtml() const; wxString ShowHtml( EDA_UNITS_T aUnits ) const;
/** /**
* Function ShowReport * Function ShowReport
@ -182,7 +182,7 @@ public:
* to disk in a report. * to disk in a report.
* @return wxString - the simple multi-line report text. * @return wxString - the simple multi-line report text.
*/ */
wxString ShowReport() const; wxString ShowReport( EDA_UNITS_T aUnits ) const;
/** /**
* Function GetErrorCode * Function GetErrorCode

View File

@ -78,7 +78,7 @@ public:
* @param bItem The second of the two conflicting objects * @param bItem The second of the two conflicting objects
* @param bPos The position of the second of two objects * @param bPos The position of the second of two objects
*/ */
MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, MARKER_BASE( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* aItem, const wxPoint& aPos,
EDA_ITEM* bItem, const wxPoint& bPos ); EDA_ITEM* bItem, const wxPoint& bPos );
@ -175,7 +175,7 @@ public:
* @param bItem The second of the two conflicting objects * @param bItem The second of the two conflicting objects
* @param bPos The position of the second of two objects * @param bPos The position of the second of two objects
*/ */
void SetData( int aErrorCode, const wxPoint& aMarkerPos, void SetData( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
EDA_ITEM* aItem, const wxPoint& aPos, EDA_ITEM* aItem, const wxPoint& aPos,
EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );

View File

@ -47,18 +47,18 @@
MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) : MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_MARKER_T ), BOARD_ITEM( aParent, PCB_MARKER_T ),
MARKER_BASE(), m_item( NULL ) MARKER_BASE(), m_item( nullptr )
{ {
m_Color = WHITE; m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR; m_ScalingFactor = SCALING_FACTOR;
} }
MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB::MARKER_PCB( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
BOARD_ITEM* aItem, const wxPoint& aPos, BOARD_ITEM* aItem, const wxPoint& aPos,
BOARD_ITEM* bItem, const wxPoint& bPos ) : BOARD_ITEM* bItem, const wxPoint& bPos ) :
BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add() BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add()
MARKER_BASE( aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos ), m_item( NULL ) MARKER_BASE( aUnits, aErrorCode, aMarkerPos, aItem, aPos, bItem, bPos ), m_item( nullptr )
{ {
m_Color = WHITE; m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR; m_ScalingFactor = SCALING_FACTOR;
@ -68,8 +68,8 @@ MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos, const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos ) : const wxString& bText, const wxPoint& bPos ) :
BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add() BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add()
MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( NULL ) MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( nullptr )
{ {
m_Color = WHITE; m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR; m_ScalingFactor = SCALING_FACTOR;
@ -95,30 +95,20 @@ bool MARKER_PCB::IsOnLayer( PCB_LAYER_ID aLayer ) const
void MARKER_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) void MARKER_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
{ {
const DRC_ITEM& rpt = m_drc; wxString errorTxt, txtA, txtB;
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) ); aList.emplace_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) );
wxString errorTxt; errorTxt.Printf( _( "ErrType (%d)- %s:" ), m_drc.GetErrorCode(), m_drc.GetErrorText() );
errorTxt.Printf( _( "ErrType (%d)- %s:" ), aList.emplace_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) );
rpt.GetErrorCode(),
GetChars( rpt.GetErrorText() ) );
aList.push_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) ); txtA.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointA() ), m_drc.GetTextA() );
wxString txtA = wxString::Format( wxT( "%s: %s" ), if( m_drc.HasSecondItem() )
DRC_ITEM::ShowCoord( aUnits, rpt.GetPointA() ), txtB.Printf( wxT( "%s: %s" ), DRC_ITEM::ShowCoord( aUnits, m_drc.GetPointB() ), m_drc.GetTextB() );
rpt.GetTextA() );
wxString txtB;
if( rpt.HasSecondItem() )
{
txtB = wxString::Format( wxT( "%s: %s" ),
DRC_ITEM::ShowCoord( aUnits, rpt.GetPointB() ),
rpt.GetTextB() );
}
aList.push_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) ); aList.emplace_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) );
} }

View File

@ -54,7 +54,7 @@ public:
* @param bItem The second of the two conflicting objects * @param bItem The second of the two conflicting objects
* @param bPos The position of the second of two objects * @param bPos The position of the second of two objects
*/ */
MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos, MARKER_PCB( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
BOARD_ITEM* aItem, const wxPoint& aPos, BOARD_ITEM* aItem, const wxPoint& aPos,
BOARD_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() ); BOARD_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );

View File

@ -631,6 +631,7 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName )
return false; return false;
int count; int count;
EDA_UNITS_T units = GetUserUnits();
fprintf( fp, "** Drc report for %s **\n", fprintf( fp, "** Drc report for %s **\n",
TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) ); TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) );
@ -644,14 +645,14 @@ bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName )
fprintf( fp, "\n** Found %d DRC errors **\n", count ); fprintf( fp, "\n** Found %d DRC errors **\n", count );
for( int i = 0; i<count; ++i ) for( int i = 0; i<count; ++i )
fprintf( fp, "%s", TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport()) ); fprintf( fp, "%s", TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport( units ) ) );
count = m_UnconnectedListBox->GetItemCount(); count = m_UnconnectedListBox->GetItemCount();
fprintf( fp, "\n** Found %d unconnected pads **\n", count ); fprintf( fp, "\n** Found %d unconnected pads **\n", count );
for( int i = 0; i<count; ++i ) for( int i = 0; i<count; ++i )
fprintf( fp, "%s", TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport() ) ); fprintf( fp, "%s", TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport( units ) ) );
fprintf( fp, "\n** End of Report **\n" ); fprintf( fp, "\n** End of Report **\n" );

View File

@ -70,7 +70,7 @@ public:
//-----<Interface DRC_ITEM_LIST>--------------------------------------- //-----<Interface DRC_ITEM_LIST>---------------------------------------
void DeleteAllItems() override void DeleteAllItems() override
{ {
m_board->DeleteMARKERs(); m_board->DeleteMARKERs();
} }
@ -188,6 +188,7 @@ public:
class DRCLISTBOX : public wxHtmlListBox class DRCLISTBOX : public wxHtmlListBox
{ {
private: private:
EDA_UNITS_T m_units;
DRC_ITEM_LIST* m_list; ///< wxHtmlListBox does not own the list, I do DRC_ITEM_LIST* m_list; ///< wxHtmlListBox does not own the list, I do
public: public:
@ -213,10 +214,11 @@ public:
* @param aList The DRC_ITEM_LIST* containing the DRC_ITEMs which will be * @param aList The DRC_ITEM_LIST* containing the DRC_ITEMs which will be
* displayed in the wxHtmlListBox * displayed in the wxHtmlListBox
*/ */
void SetList( DRC_ITEM_LIST* aList ) void SetList( EDA_UNITS_T aUnits, DRC_ITEM_LIST* aList )
{ {
delete m_list; delete m_list;
m_units = aUnits;
m_list = aList; m_list = aList;
SetItemCount( aList->GetCount() ); SetItemCount( aList->GetCount() );
Refresh(); Refresh();
@ -254,7 +256,7 @@ public:
return wxString::Format( wxT( "<font color='%s'>%s</font>" ), return wxString::Format( wxT( "<font color='%s'>%s</font>" ),
color.GetAsString( wxC2S_HTML_SYNTAX ), color.GetAsString( wxC2S_HTML_SYNTAX ),
item->ShowHtml() ); item->ShowHtml( m_units ) );
} }
} }
return wxString(); return wxString();

View File

@ -131,6 +131,7 @@ DRC::DRC( PCB_EDIT_FRAME* aPcbWindow )
m_pcbEditorFrame = aPcbWindow; m_pcbEditorFrame = aPcbWindow;
m_pcb = aPcbWindow->GetBoard(); m_pcb = aPcbWindow->GetBoard();
m_drcDialog = NULL; m_drcDialog = NULL;
m_units = aPcbWindow->GetUserUnits();
// establish initial values for everything: // establish initial values for everything:
m_drcInLegacyRoutingMode = false; m_drcInLegacyRoutingMode = false;
@ -205,6 +206,7 @@ int DRC::DrcOnCreatingTrack( TRACK* aRefSegm, TRACK* aList )
int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers ) int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers )
{ {
BOARD* board = m_pcbEditorFrame->GetBoard(); BOARD* board = m_pcbEditorFrame->GetBoard();
EDA_UNITS_T units = m_pcbEditorFrame->GetUserUnits();
BOARD_COMMIT commit( m_pcbEditorFrame ); BOARD_COMMIT commit( m_pcbEditorFrame );
int nerrors = 0; int nerrors = 0;
@ -272,8 +274,8 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers )
if( aCreateMarkers ) if( aCreateMarkers )
{ {
wxPoint pt( currentVertex.x, currentVertex.y ); wxPoint pt( currentVertex.x, currentVertex.y );
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, auto marker = new MARKER_PCB( units, COPPERAREA_INSIDE_COPPERAREA,
pt, zoneRef, pt, zoneToTest, pt ); pt, zoneRef, pt, zoneToTest, pt );
commit.Add( marker ); commit.Add( marker );
} }
@ -292,8 +294,8 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers )
if( aCreateMarkers ) if( aCreateMarkers )
{ {
wxPoint pt( currentVertex.x, currentVertex.y ); wxPoint pt( currentVertex.x, currentVertex.y );
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_INSIDE_COPPERAREA, auto marker = new MARKER_PCB( units, COPPERAREA_INSIDE_COPPERAREA,
pt, zoneToTest, pt, zoneRef, pt ); pt, zoneToTest, pt, zoneRef, pt );
commit.Add( marker ); commit.Add( marker );
} }
@ -338,8 +340,8 @@ int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers )
// COPPERAREA_COPPERAREA error : intersect or too close // COPPERAREA_COPPERAREA error : intersect or too close
if( aCreateMarkers ) if( aCreateMarkers )
{ {
MARKER_PCB* marker = new MARKER_PCB( COPPERAREA_CLOSE_TO_COPPERAREA, auto marker = new MARKER_PCB( units, COPPERAREA_CLOSE_TO_COPPERAREA,
pt, zoneRef, pt, zoneToTest, pt ); pt, zoneRef, pt, zoneToTest, pt );
commit.Add( marker ); commit.Add( marker );
} }
@ -547,8 +549,10 @@ void DRC::updatePointers()
if( m_drcDialog ) // Use diag list boxes only in DRC dialog if( m_drcDialog ) // Use diag list boxes only in DRC dialog
{ {
m_drcDialog->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) ); m_drcDialog->m_ClearanceListBox->SetList(
m_drcDialog->m_UnconnectedListBox->SetList( new DRC_LIST_UNCONNECTED( &m_unconnected ) ); m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_MARKERS( m_pcb ) );
m_drcDialog->m_UnconnectedListBox->SetList(
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_UNCONNECTED( &m_unconnected ) );
m_drcDialog->UpdateDisplayedCounts(); m_drcDialog->UpdateDisplayedCounts();
} }
@ -561,7 +565,7 @@ bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg )
const BOARD_DESIGN_SETTINGS& g = m_pcb->GetDesignSettings(); const BOARD_DESIGN_SETTINGS& g = m_pcb->GetDesignSettings();
#define FmtVal( x ) GetChars( StringFromValue( g_UserUnit, x ) ) #define FmtVal( x ) GetChars( StringFromValue( m_pcbEditorFrame->GetUserUnits(), x ) )
#if 0 // set to 1 when (if...) BOARD_DESIGN_SETTINGS has a m_MinClearance value #if 0 // set to 1 when (if...) BOARD_DESIGN_SETTINGS has a m_MinClearance value
if( nc->GetClearance() < g.m_MinClearance ) if( nc->GetClearance() < g.m_MinClearance )
@ -777,7 +781,8 @@ void DRC::testDrilledHoles()
if( KiROUND( GetLineLength( checkHole.m_location, refHole.m_location ) ) if( KiROUND( GetLineLength( checkHole.m_location, refHole.m_location ) )
< checkHole.m_drillRadius + refHole.m_drillRadius + holeToHoleMin ) < checkHole.m_drillRadius + refHole.m_drillRadius + holeToHoleMin )
{ {
addMarkerToPcb( new MARKER_PCB( DRCE_DRILLED_HOLES_TOO_CLOSE, refHole.m_location, addMarkerToPcb( new MARKER_PCB( m_pcbEditorFrame->GetUserUnits(),
DRCE_DRILLED_HOLES_TOO_CLOSE, refHole.m_location,
refHole.m_owner, refHole.m_location, refHole.m_owner, refHole.m_location,
checkHole.m_owner, checkHole.m_location ) ); checkHole.m_owner, checkHole.m_location ) );
} }
@ -862,12 +867,12 @@ void DRC::testUnconnected()
auto src = edge.GetSourcePos(); auto src = edge.GetSourcePos();
auto dst = edge.GetTargetPos(); auto dst = edge.GetTargetPos();
DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_ITEMS, m_unconnected.emplace_back( new DRC_ITEM( m_pcbEditorFrame->GetUserUnits(),
edge.GetSourceNode()->Parent(), DRCE_UNCONNECTED_ITEMS,
wxPoint( src.x, src.y ), edge.GetSourceNode()->Parent(),
edge.GetTargetNode()->Parent(), wxPoint( src.x, src.y ),
wxPoint( dst.x, dst.y ) ); edge.GetTargetNode()->Parent(),
m_unconnected.push_back( uncItem ); wxPoint( dst.x, dst.y ) ) );
} }
} }
@ -1013,8 +1018,7 @@ void DRC::testTexts()
if( dist < min_dist ) if( dist < min_dist )
{ {
addMarkerToPcb( fillMarker( track, text, addMarkerToPcb( fillMarker( track, text,
DRCE_TRACK_INSIDE_TEXT, DRCE_TRACK_INSIDE_TEXT, m_currentMarker ) );
m_currentMarker ) );
m_currentMarker = nullptr; m_currentMarker = nullptr;
break; break;
} }

View File

@ -214,6 +214,7 @@ private:
PCB_EDIT_FRAME* m_pcbEditorFrame; ///< The pcb frame editor which owns the board PCB_EDIT_FRAME* m_pcbEditorFrame; ///< The pcb frame editor which owns the board
BOARD* m_pcb; BOARD* m_pcb;
DIALOG_DRC_CONTROL* m_drcDialog; DIALOG_DRC_CONTROL* m_drcDialog;
EDA_UNITS_T m_units;
DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs

View File

@ -155,7 +155,7 @@ wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos )
} }
wxString DRC_ITEM::ShowHtml() const wxString DRC_ITEM::ShowHtml( EDA_UNITS_T aUnits ) const
{ {
wxString mainText = m_MainText; wxString mainText = m_MainText;
// a wxHtmlWindows does not like < and > in the text to display // a wxHtmlWindows does not like < and > in the text to display
@ -185,31 +185,31 @@ wxString DRC_ITEM::ShowHtml() const
// to add color if you want: // to add color if you want:
return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s<br>&nbsp;&nbsp; %s: %s" ), return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s<br>&nbsp;&nbsp; %s: %s" ),
errText, errText,
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
mainText, mainText,
ShowCoord( g_UserUnit, m_AuxiliaryPosition ), ShowCoord( aUnits, m_AuxiliaryPosition ),
auxText ); auxText );
} }
else else
{ {
return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s" ), return wxString::Format( wxT( "<b>%s</b><br>&nbsp;&nbsp; %s: %s" ),
errText, errText,
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
mainText ); mainText );
} }
} }
wxString DRC_ITEM::ShowReport() const wxString DRC_ITEM::ShowReport( EDA_UNITS_T aUnits ) const
{ {
if( m_hasSecondItem ) if( m_hasSecondItem )
{ {
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ),
m_ErrorCode, m_ErrorCode,
GetErrorText(), GetErrorText(),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
m_MainText, m_MainText,
ShowCoord( g_UserUnit, m_AuxiliaryPosition ), ShowCoord( aUnits, m_AuxiliaryPosition ),
m_AuxiliaryText ); m_AuxiliaryText );
} }
else else
@ -217,7 +217,7 @@ wxString DRC_ITEM::ShowReport() const
return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ), return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ),
m_ErrorCode, m_ErrorCode,
GetErrorText(), GetErrorText(),
ShowCoord( g_UserUnit, m_MainPosition ), ShowCoord( aUnits, m_MainPosition ),
m_MainText ); m_MainText );
} }
} }

View File

@ -90,9 +90,9 @@ MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* bItem, int aErrorCode, M
posA = aTrack->GetPosition(); posA = aTrack->GetPosition();
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB ); fillMe->SetData( m_units, aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB );
else else
fillMe = new MARKER_PCB( aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB ); fillMe = new MARKER_PCB( m_units, aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB );
return fillMe; return fillMe;
} }
@ -122,9 +122,9 @@ MARKER_PCB* DRC::fillMarker( D_PAD* aPad, BOARD_ITEM* aItem, int aErrorCode, MAR
} }
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, posA, aPad, posA, aItem, posB ); fillMe->SetData( m_units, aErrorCode, posA, aPad, posA, aItem, posB );
else else
fillMe = new MARKER_PCB( aErrorCode, posA, aPad, posA, aItem, posB ); fillMe = new MARKER_PCB( m_units, aErrorCode, posA, aPad, posA, aItem, posB );
return fillMe; return fillMe;
} }
@ -141,9 +141,9 @@ MARKER_PCB* DRC::fillMarker( const wxPoint& aPos, BOARD_ITEM* aItem, BOARD_ITEM*
int aErrorCode, MARKER_PCB* fillMe ) int aErrorCode, MARKER_PCB* fillMe )
{ {
if( fillMe ) if( fillMe )
fillMe->SetData( aErrorCode, aPos, aItem, aPos, bItem, aPos ); fillMe->SetData( m_units, aErrorCode, aPos, aItem, aPos, bItem, aPos );
else else
fillMe = new MARKER_PCB( aErrorCode, aPos, aItem, aPos, bItem, aPos ); fillMe = new MARKER_PCB( m_units, aErrorCode, aPos, aItem, aPos, bItem, aPos );
return fillMe; return fillMe;
} }