diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 5ca919bde5..2403d8bf29 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -345,7 +345,7 @@ bool NETLIST_OBJECT::IsLabelBusMemberType() const /* * return the net name of the item */ -wxString NETLIST_OBJECT::GetNetName() const +wxString NETLIST_OBJECT::GetNetName( bool adoptTimestamp ) const { if( m_netNameCandidate == NULL ) return wxEmptyString; @@ -353,7 +353,7 @@ wxString NETLIST_OBJECT::GetNetName() const wxString netName; if( m_netNameCandidate->m_Type == NET_PIN ) - return GetShortNetName(); + return GetShortNetName( adoptTimestamp ); if( !m_netNameCandidate->IsLabelGlobal() ) { @@ -371,7 +371,7 @@ wxString NETLIST_OBJECT::GetNetName() const * from the "best" label without any prefix. * 2 different nets can have the same short name */ -wxString NETLIST_OBJECT::GetShortNetName() const +wxString NETLIST_OBJECT::GetShortNetName( bool adoptTimestamp ) const { if( m_netNameCandidate == NULL ) return wxEmptyString; @@ -385,6 +385,10 @@ wxString NETLIST_OBJECT::GetShortNetName() const { netName = wxT("Net-("); netName << link->GetRef( &m_netNameCandidate->m_SheetPath ); + + if( adoptTimestamp && netName.Last() == '?' ) + netName << link->GetTimeStamp(); + netName << wxT("-Pad") << LIB_PIN::PinStringNum( m_netNameCandidate->m_PinNum ) << wxT(")"); diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h index 403badeb51..80667c1238 100644 --- a/eeschema/class_netlist_object.h +++ b/eeschema/class_netlist_object.h @@ -240,18 +240,20 @@ public: /** * Function GetNetName + * @param adoptTimestamp if annotation is not done (i.e. GetRef returns something with an ? at the end) * @return the full net name of the item, i.e. the net name * from the "best" label, prefixed by the sheet path */ - wxString GetNetName() const; + wxString GetNetName( bool adoptTimestamp = false ) const; /** * Function GetShortNetName + * @param adoptTimestamp if annotation is not done (i.e. GetRef returns something with an ? at the end) * @return the short net name of the item i.e. the net name * from the "best" label without any prefix. * 2 different nets can have the same short name */ - wxString GetShortNetName() const; + wxString GetShortNetName( bool adoptTimestamp = false ) const; /** * Function ConvertBusToNetListItems diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 7f21b165fc..c0baaf1cdf 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -211,6 +211,7 @@ static PARAM_CFG_ARRAY& cfg_params() CLR( "ColorErcEEx", LAYER_ERC_ERR, RED ) CLR( "ColorGridEx", LAYER_GRID, DARKGRAY ) CLR( "ColorBgCanvasEx", LAYER_BACKGROUND, WHITE ) + CLR( "ColorBrighenedEx", LAYER_BRIGHTENED, PUREMAGENTA ) } return ca; diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 33dda9f172..0f879e0ab0 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -74,6 +74,7 @@ enum id_eeschema_frm /* Schematic editor veritcal toolbar IDs */ ID_SCHEMATIC_VERTICAL_TOOLBAR_START, + ID_HIGHLIGHT, ID_HIERARCHY_PUSH_POP_BUTT, ID_SCH_PLACE_COMPONENT, ID_PLACE_POWER_BUTT, diff --git a/eeschema/general.h b/eeschema/general.h index 87c8ec954d..ae34229af2 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -97,6 +97,7 @@ typedef enum { LAYER_DEVICE_BACKGROUND, LAYER_GRID, LAYER_BACKGROUND, + LAYER_BRIGHTENED, LAYERSCH_ID_COUNT } LAYERSCH_ID; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 5334a87f4b..3b408b0324 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -40,6 +40,8 @@ #include #include +#include +#include enum { @@ -49,6 +51,9 @@ enum class HIERARCHY_NAVIG_DLG; +//Imported function: +int TestDuplicateSheetNames( bool aCreateMarker ); + /* This class derived from wxTreeItemData stores the SCH_SHEET_PATH of each * sheet in hierarchy in each TreeItem, in its associated data buffer */ @@ -302,6 +307,49 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() RedrawScreen( GetScrollCenterPosition(), true ); } + + // Disable highlight on all items (Note: might be the wrong call if needed for something else than net highlighting) + for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() ) + { + ptr->SetState( BRIGHTENED, false ); + + if( ptr->Type() == SCH_SHEET_T ) + { + for( SCH_SHEET_PIN& pin : static_cast( ptr )->GetPins() ) + pin.SetState( BRIGHTENED, false ); + } + } + + //avoid selection of buses as they are nameless + if( m_SelectedNetName != "" ) + { + if( TestDuplicateSheetNames( false ) ) + SetStatusText( "duplicated sheets names prevent net highlighting" ); + else + { + // Build netlist info to get the proper netnames + std::unique_ptr objectsConnectedList( BuildNetListBase( false ) ); + + // highlight the new items + for( auto obj1 : *objectsConnectedList ) + { + if( obj1->m_SheetPath == *m_CurrentSheet && obj1->GetNetName( true ) == m_SelectedNetName && obj1->m_Comp ) + { + obj1->m_Comp->SetState( BRIGHTENED, true ); + + //if a bus is associated with this net highlight it as well + if( obj1->m_BusNetCode ) + { + for( auto obj2 : *objectsConnectedList ) + { + if( obj2 && obj2->m_Comp && obj2->m_SheetPath == *m_CurrentSheet && obj1->m_BusNetCode == obj2->m_BusNetCode ) + obj2->m_Comp->SetState( BRIGHTENED, true ); + } + } + } + } + } + } // Now refresh m_canvas. Should be not necessary, but because screen has changed // the previous refresh has set all new draw parameters (scroll position ..) // but most of time there were some inconsitencies about cursor parameters diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 4dd4008681..f84fcdf600 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -155,7 +155,7 @@ void NETLIST_OBJECT_LIST::SortListbySheet() } -NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase() +NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase( bool updateStatusText ) { // I own this list until I return it to the new owner. std::unique_ptr ret( new NETLIST_OBJECT_LIST() ); @@ -168,13 +168,15 @@ NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase() if( !success ) { - SetStatusText( _( "No Objects" ) ); + if( updateStatusText ) + SetStatusText( _( "No Objects" ) ); return ret.release(); } wxString msg = wxString::Format( _( "Net count = %d" ), int( ret->size() ) ); - SetStatusText( msg ); + if( updateStatusText ) + SetStatusText( msg ); return ret.release(); } diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 6d7c89e92e..3cd1cc753e 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,8 @@ #include #include // fo class SCHLIB_FILTER to filter power parts + //Imported function: +int TestDuplicateSheetNames( bool aCreateMarker ); // TODO(hzeller): These pairs of elmenets should be represented by an object, but don't want // to refactor too much right now to not get in the way with other code changes. @@ -110,6 +113,34 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_NO_TOOL_SELECTED: break; + case ID_HIGHLIGHT: + { + m_SelectedNetName = ""; + + //find which item is selected + EDA_ITEMS nodeList; + + if( GetScreen()->GetNode( gridPosition,nodeList ) + && ( !TestDuplicateSheetNames( false ) + || IsOK( NULL, _( "Error: duplicate sheet names. Continue?" ) ) ) ) + { + // Build netlist info to get the proper netnames + std::unique_ptr objectsConnectedList( BuildNetListBase() ); + + for( auto obj : *objectsConnectedList ) + { + if( obj->m_SheetPath == *m_CurrentSheet && obj->m_Comp == nodeList[0] ) + { + m_SelectedNetName = obj->GetNetName( true ); + break; + } + } + } + + SetStatusText( "selected net: " + m_SelectedNetName ); + DisplayCurrentSheet(); + }break; + case ID_HIERARCHY_PUSH_POP_BUTT: if( ( item && item->GetFlags() ) || ( g_RootSheet->CountSheets() == 0 ) ) break; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 8e772f8353..07749cced8 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -189,7 +189,7 @@ void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( aColor >= 0 ) color = aColor; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( aDC, aDrawMode ); diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 9c08b63987..a0b7efc542 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -117,7 +117,7 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs if( aColor >= 0 ) color = aColor; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( aDC, aDrawMode ); diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index ecf4421cfa..e3f21bfd15 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -220,7 +220,7 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, if( Color >= 0 ) color = Color; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( DC, DrawMode ); @@ -559,7 +559,7 @@ bool SCH_LINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) EDA_RECT rect = aRect; if ( aAccuracy ) - rect.Inflate( aAccuracy ); + rect.Inflate( aAccuracy ); if( aContained ) return rect.Contains( m_start ) && rect.Contains( m_end ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index ec2bfd6d9b..497e199eee 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -354,7 +354,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, if( Color >= 0 ) color = Color; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( DC, DrawMode ); @@ -1238,7 +1238,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, if( Color >= 0 ) color = Color; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( DC, DrawMode ); @@ -1591,7 +1591,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, if( Color >= 0 ) color = Color; else - color = GetLayerColor( m_Layer ); + color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer ); GRSetDrawMode( DC, DrawMode ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index d60c513dd8..44c3de6e34 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -529,6 +529,10 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) SetToolID( id, m_canvas->GetDefaultCursor(), _( "No tool selected" ) ); break; + case ID_HIGHLIGHT: + SetToolID( id, m_canvas->GetDefaultCursor(), _("click to highlight") ); + break; + case ID_ZOOM_SELECTION: SetToolID( id, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); break; diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 09329f789c..324ca5a8b5 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -278,6 +278,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) // Tools and buttons for vertical toolbar. EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool ) + EVT_TOOL( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnSelectTool ) EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool ) EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, SCH_EDIT_FRAME::OnSelectTool ) @@ -319,6 +320,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins ) EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation ) EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool ) + EVT_UPDATE_UI( ID_HIGHLIGHT, SCH_EDIT_FRAME::OnUpdateSelectTool ) EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool ) EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, SCH_EDIT_FRAME::OnUpdateSelectTool ) diff --git a/eeschema/schframe.h b/eeschema/schframe.h index a75ff84d57..bebb40ed28 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -119,6 +119,7 @@ class SCH_EDIT_FRAME : public SCH_BASE_FRAME private: SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. wxString m_DefaultSchematicFileName; + wxString m_SelectedNetName; PARAM_CFG_ARRAY m_projectFileParams; PARAM_CFG_ARRAY m_configSettings; @@ -490,9 +491,10 @@ public: * netlist generation: * Creates a flat list which stores all connected objects, and mainly * pins and labels. + * @param updateStatusText = decides if window StatusText should be modified * @return NETLIST_OBJECT_LIST* - caller owns the object. */ - NETLIST_OBJECT_LIST* BuildNetListBase(); + NETLIST_OBJECT_LIST* BuildNetListBase( bool updateStatusText = true ); /** * Function CreateNetlist diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index 5802e09f30..979d4062a6 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -190,6 +190,9 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ), wxEmptyString, wxITEM_CHECK ); + m_drawToolBar->AddTool( ID_HIGHLIGHT, wxEmptyString, KiBitmap( net_highlight_xpm ), + _( "Click to highlight net" ), wxITEM_CHECK ); + m_drawToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ), _( "Zoom to selection" ), wxITEM_CHECK ); diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp index d3d0c80061..d8dd97f673 100644 --- a/eeschema/widgets/widget_eeschema_color_config.cpp +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -94,6 +94,7 @@ static COLORBUTTON miscColorButtons[] = { { _( "ERC warning" ), LAYER_ERC_WARN }, { _( "ERC error" ), LAYER_ERC_ERR }, { _( "Grid" ), LAYER_GRID }, + { _( "Brightened" ), LAYER_BRIGHTENED }, { wxT( "" ), -1 } // Sentinel marking end of list. };