Browse Source
Use full net names in netclasses
Use full net names in netclasses
Short net names are not unique; full names with paths must be used. Added a grid cell renderer that does the escaping, to make it easier to display net names in grid cells. Once you unescape a net name, you can't go back to the escaped form because you can't assume which `/` should be {slash} and which `/` Because of this, we cannot use Unescape/Escape on the data model in the netclass setup panel, and instead do the Unescape in the view. Fixes https://gitlab.com/kicad/code/kicad/-/issues/5331pull/16/head
8 changed files with 120 additions and 90 deletions
-
1common/CMakeLists.txt
-
24common/dialogs/panel_setup_netclasses.cpp
-
4common/dialogs/panel_setup_netclasses.h
-
52common/widgets/grid_text_helpers.cpp
-
70eeschema/schematic.cpp
-
44include/widgets/grid_text_helpers.h
-
10pcbnew/class_board.cpp
-
5pcbnew/widgets/appearance_controls.cpp
@ -0,0 +1,52 @@ |
|||||
|
/*
|
||||
|
* This program source code file is part of KiCad, a free EDA CAD application. |
||||
|
* |
||||
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
||||
|
* @author Jon Evans <jon@craftyjon.com> |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation, either version 3 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
|
* General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
#include <kicad_string.h>
|
||||
|
#include <widgets/grid_text_helpers.h>
|
||||
|
|
||||
|
|
||||
|
GRID_CELL_ESCAPED_TEXT_RENDERER::GRID_CELL_ESCAPED_TEXT_RENDERER() : |
||||
|
wxGridCellStringRenderer() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
void GRID_CELL_ESCAPED_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, |
||||
|
const wxRect& aRect, int aRow, int aCol, |
||||
|
bool isSelected ) |
||||
|
{ |
||||
|
wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) ); |
||||
|
|
||||
|
wxRect rect = aRect; |
||||
|
rect.Inflate( -1 ); |
||||
|
|
||||
|
// erase background
|
||||
|
wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected ); |
||||
|
|
||||
|
SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected ); |
||||
|
aGrid.DrawTextRectangle( aDC, unescaped, rect, wxALIGN_LEFT, wxALIGN_CENTRE ); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
wxSize GRID_CELL_ESCAPED_TEXT_RENDERER::GetBestSize( wxGrid & aGrid, wxGridCellAttr & aAttr, |
||||
|
wxDC & aDC, int aRow, int aCol ) |
||||
|
{ |
||||
|
wxString unescaped = UnescapeString( aGrid.GetCellValue( aRow, aCol ) ); |
||||
|
return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, unescaped ); |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
/* |
||||
|
* This program source code file is part of KiCad, a free EDA CAD application. |
||||
|
* |
||||
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. |
||||
|
* @author Jon Evans <jon@craftyjon.com> |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify it |
||||
|
* under the terms of the GNU General Public License as published by the |
||||
|
* Free Software Foundation, either version 3 of the License, or (at your |
||||
|
* option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, but |
||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
|
* General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License along |
||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#ifndef KICAD_GRID_TEXT_HELPERS_H |
||||
|
#define KICAD_GRID_TEXT_HELPERS_H |
||||
|
|
||||
|
#include <wx/generic/gridctrl.h> |
||||
|
|
||||
|
class wxGrid; |
||||
|
|
||||
|
/** |
||||
|
* A text renderer that can unescape text for display |
||||
|
* This is useful where it's desired to keep the underlying storage escaped. |
||||
|
*/ |
||||
|
class GRID_CELL_ESCAPED_TEXT_RENDERER : public wxGridCellStringRenderer |
||||
|
{ |
||||
|
public: |
||||
|
GRID_CELL_ESCAPED_TEXT_RENDERER(); |
||||
|
|
||||
|
void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, |
||||
|
const wxRect& aRect, int aRow, int aCol, bool isSelected ) override; |
||||
|
|
||||
|
wxSize GetBestSize( wxGrid & grid, wxGridCellAttr & attr, wxDC & dc, |
||||
|
int row, int col ) override; |
||||
|
}; |
||||
|
|
||||
|
#endif // KICAD_GRID_TEXT_HELPERS_H |
Write
Preview
Loading…
Cancel
Save
Reference in new issue