From 69f121d907bb6f64ee84b47374d4de06a3148123 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 22 May 2020 11:31:14 +0100 Subject: [PATCH] Another attempt to get DRC and status bar to share message content. --- pcbnew/class_module.cpp | 93 ++++++++------------- pcbnew/class_pad.cpp | 2 +- pcbnew/class_track.cpp | 12 +-- pcbnew/class_zone.cpp | 6 +- pcbnew/drc/drc_clearance_test_functions.cpp | 8 +- pcbnew/drc/drc_drilled_hole_tester.cpp | 12 +-- 6 files changed, 56 insertions(+), 77 deletions(-) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 1a7b8e7dbe..322bd3fb58 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include @@ -43,7 +41,6 @@ #include #include #include -#include #include MODULE::MODULE( BOARD* parent ) : @@ -545,77 +542,60 @@ SHAPE_POLY_SET MODULE::GetBoundingPoly() const void MODULE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - wxString msg; + wxString msg, msg2; - aList.emplace_back( MSG_PANEL_ITEM( m_Reference->GetShownText(), m_Value->GetShownText(), DARKCYAN ) ); + aList.emplace_back( m_Reference->GetShownText(), m_Value->GetShownText(), DARKCYAN ); - // Display last date the component was edited (useful in Module Editor). - wxDateTime date( static_cast( m_LastEditTime ) ); + if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER ) + || aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) + || aFrame->IsType( FRAME_FOOTPRINT_EDITOR ) ) + { + wxDateTime date( static_cast( m_LastEditTime ) ); - if( m_LastEditTime && date.IsValid() ) - // Date format: see http://www.cplusplus.com/reference/ctime/strftime - msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year - else - msg = _( "Unknown" ); + // Date format: see http://www.cplusplus.com/reference/ctime/strftime + if( m_LastEditTime && date.IsValid() ) + msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year + else + msg = _( "Unknown" ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) ); + aList.emplace_back( _( "Last Change" ), msg, BROWN ); + } + else if( aFrame->IsType( FRAME_PCB_EDITOR ) ) + { + aList.emplace_back( _( "Board Side" ), IsFlipped() ? _( "Back (Flipped)" ) + : _( "Front" ), RED ); + } - // display the board side placement - aList.emplace_back( MSG_PANEL_ITEM( _( "Board Side" ), - IsFlipped()? _( "Back (Flipped)" ) : _( "Front" ), RED ) ); - - msg.Printf( wxT( "%zu" ), m_pads.size() ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) ); - - msg = wxT( ".." ); + msg = wxT( ". ." ); if( IsLocked() ) msg[0] = 'L'; if( m_ModuleStatus & MODULE_is_PLACED ) - msg[1] = 'P'; + msg[2] = 'P'; - aList.emplace_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) ); - - msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Rotation" ), msg, BROWN ) ); + aList.emplace_back( _( "Status" ), msg, MAGENTA ); // Controls on right side of the dialog switch( m_Attributs & 255 ) { - case 0: - msg = _( "Normal" ); - break; - - case MOD_CMS: - msg = _( "Insert" ); - break; - - case MOD_VIRTUAL: - msg = _( "Virtual" ); - break; - - default: - msg = wxT( "???" ); - break; + case 0: msg = _( "Normal" ); break; + case MOD_CMS: msg = _( "Insert" ); break; + case MOD_VIRTUAL: msg = _( "Virtual" ); break; + default: msg = wxT( "???" ); break; } - aList.emplace_back( MSG_PANEL_ITEM( _( "Attributes" ), msg, BROWN ) ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Footprint" ), FROM_UTF8( m_fpid.Format().c_str() ), BLUE ) ); + aList.emplace_back( _( "Attributes" ), msg, BROWN ); - if( m_3D_Drawings.empty() ) - msg = _( "No 3D shape" ); - else - msg = m_3D_Drawings.front().m_Filename; + msg.Printf( _( "Footprint: %s" ), + GetChars( m_fpid.Format().c_str() ) ); + msg2.Printf( _( "3D-Shape: %s" ), + m_3D_Drawings.empty() ? _( "none" ) : m_3D_Drawings.front().m_Filename ); + aList.emplace_back( msg, msg2, BLUE ); - // Search the first active 3D shape in list - - aList.emplace_back( MSG_PANEL_ITEM( _( "3D-Shape" ), msg, RED ) ); - - wxString doc, keyword; - doc.Printf( _( "Doc: %s" ), m_Doc ); - keyword.Printf( _( "Key Words: %s" ), m_KeyWord ); - aList.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) ); + msg.Printf( _( "Doc: %s" ), m_Doc ); + msg2.Printf( _( "Keywords: %s" ), m_KeyWord ); + aList.emplace_back( msg, msg2, BLACK ); } @@ -707,8 +687,7 @@ D_PAD* MODULE::GetTopLeftPad() wxPoint pnt = p->GetPosition(); // GetPosition() returns the center of the pad if( ( pnt.x < topLeftPad->GetPosition().x ) || - ( ( topLeftPad->GetPosition().x == pnt.x ) && - ( pnt.y < topLeftPad->GetPosition().y ) ) ) + ( topLeftPad->GetPosition().x == pnt.x && pnt.y < topLeftPad->GetPosition().y ) ) { topLeftPad = p; } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index aaa8b58501..dee887ec6a 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -1008,7 +1008,7 @@ void D_PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector int clearance = GetClearance( nullptr, &source ); msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) ); - msg2.Printf( _( "Source: %s" ), source ); + msg2.Printf( _( "(from %s)" ), source ); aList.emplace_back( msg, msg2, BLACK ); } diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 8ee2e6498a..683267ea62 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -143,7 +143,7 @@ int TRACK::GetMinWidth( wxString* aSource ) const int minWidth = bds.m_TrackMinWidth; if( aSource ) - *aSource = _( "board" ); + *aSource = _( "board minumum" ); for( DRC_SELECTOR* selector : matched ) { @@ -178,7 +178,7 @@ int VIA::GetMinAnnulus( wxString* aSource ) const int minAnnulus = bds.m_ViasMinAnnulus; if( aSource ) - *aSource = _( "board" ); + *aSource = _( "board minumum" ); MatchSelectors( bds.m_DRCRuleSelectors, this, netclass, nullptr, nullptr, &matched ); @@ -631,13 +631,13 @@ void TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector int clearance = GetClearance( nullptr, &source ); msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) ); - msg2.Printf( _( "Source: %s" ), source ); + msg2.Printf( _( "(from %s)" ), source ); aList.emplace_back( msg, msg2, BLACK ); int minWidth = GetMinWidth( &source ); msg.Printf( _( "Min Width: %s" ), MessageTextFromValue( units, minWidth, true ) ); - msg2.Printf( _( "Source: %s" ), source ); + msg2.Printf( _( "(from %s)" ), source ); aList.emplace_back( msg, msg2, BLACK ); } @@ -703,13 +703,13 @@ void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& int clearance = GetClearance( nullptr, &source ); msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) ); - msg2.Printf( _( "Source: %s" ), source ); + msg2.Printf( _( "(from %s)" ), source ); aList.emplace_back( msg, msg2, BLACK ); int minAnnulus = GetMinAnnulus( &source ); msg.Printf( _( "Min Annulus: %s" ), MessageTextFromValue( units, minAnnulus, true ) ); - msg2.Printf( _( "Source: %s" ), source ); + msg2.Printf( _( "(from %s)" ), source ); aList.emplace_back( msg, msg2, BLACK ); } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 4caaf063ed..2bbf4dfd6e 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -526,7 +526,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorm_contour > 0 ) msg << wxT( " " ) << _( "Cutout" ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); + aList.emplace_back( _( "Type" ), msg, DARKCYAN ); if( GetIsKeepout() ) { @@ -578,7 +578,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetErrorText() + _( " (%s minimum %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), m_clearanceSource, MessageTextFromValue( userUnits(), minAnnulus, true ), MessageTextFromValue( userUnits(), viaAnnulus, true ) ); @@ -199,14 +199,14 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS if( bds.m_ViasMinAnnulus > minAnnulus ) { minAnnulus = bds.m_ViasMinAnnulus; - m_clearanceSource = _( "board" ); + m_clearanceSource = _( "board minimum" ); } if( viaAnnulus < minAnnulus ) { DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TOO_SMALL_VIA_ANNULUS ); - m_msg.Printf( drcItem->GetErrorText() + _( " (%s minimum %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), m_clearanceSource, MessageTextFromValue( userUnits(), minAnnulus, true ), MessageTextFromValue( userUnits(), viaAnnulus, true ) ); @@ -323,7 +323,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TOO_SMALL_TRACK_WIDTH ); - m_msg.Printf( drcItem->GetErrorText() + _( " (%s minimum %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), m_clearanceSource, MessageTextFromValue( userUnits(), minWidth, true ), MessageTextFromValue( userUnits(), refSegWidth, true ) ); diff --git a/pcbnew/drc/drc_drilled_hole_tester.cpp b/pcbnew/drc/drc_drilled_hole_tester.cpp index dcd4859b61..dcca4117af 100644 --- a/pcbnew/drc/drc_drilled_hole_tester.cpp +++ b/pcbnew/drc/drc_drilled_hole_tester.cpp @@ -94,7 +94,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkPad( D_PAD* aPad ) NETCLASS* netclass = aPad->GetNet()->GetNet() == 0 ? bds.GetDefault() : aPad->GetNetClass(); int minHole = bds.m_MinThroughDrill; - wxString minHoleSource = _( "board" ); + wxString minHoleSource = _( "board minimum" ); std::vector matched; MatchSelectors( bds.m_DRCRuleSelectors, aPad, netclass, nullptr, nullptr, &matched ); @@ -112,7 +112,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkPad( D_PAD* aPad ) { DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TOO_SMALL_PAD_DRILL ); - m_msg.Printf( drcItem->GetErrorText() + _( " (%s min hole %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), minHoleSource, MessageTextFromValue( m_units, minHole, true ), MessageTextFromValue( m_units, holeSize, true ) ); @@ -144,7 +144,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkVia( VIA* via ) NETCLASS* netclass = via->GetNet()->GetNet() == 0 ? bds.GetDefault() : via->GetNetClass(); int minHole = bds.m_MinThroughDrill; - wxString minHoleSource = _( "board" ); + wxString minHoleSource = _( "board minimum" ); std::vector matched; MatchSelectors( bds.m_DRCRuleSelectors, via, netclass, nullptr, nullptr, &matched ); @@ -162,7 +162,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkVia( VIA* via ) { DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TOO_SMALL_VIA_DRILL ); - m_msg.Printf( drcItem->GetErrorText() + _( " (%s min hole %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), minHoleSource, MessageTextFromValue( m_units, minHole, true ), MessageTextFromValue( m_units, via->GetDrillValue(), true ) ); @@ -194,7 +194,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkMicroVia( VIA* via ) NETCLASS* netclass = via->GetNet()->GetNet() == 0 ? bds.GetDefault() : via->GetNetClass(); int minHole = bds.m_MicroViasMinDrill; - wxString minHoleSource = _( "board" ); + wxString minHoleSource = _( "board minimum" ); std::vector matched; MatchSelectors( bds.m_DRCRuleSelectors, via, netclass, nullptr, nullptr, &matched ); @@ -212,7 +212,7 @@ bool DRC_DRILLED_HOLE_TESTER::checkMicroVia( VIA* via ) { DRC_ITEM* drcItem = new DRC_ITEM( DRCE_TOO_SMALL_MICROVIA_DRILL ); - m_msg.Printf( drcItem->GetErrorText() + _( " (%s minimum %s; actual %s)" ), + m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s; actual %s)" ), minHoleSource, MessageTextFromValue( m_units, minHole, true ), MessageTextFromValue( m_units, via->GetDrillValue(), true ) );