Browse Source
NetClass settings for Eeschema.
NetClass settings for Eeschema.
ADDED Eeschema-specific netclass settings including wire and bus thickness, color, and line style. Netclasses override individual wire & bus colors and line styles. If that proves an issue we might look at something more sophisticated with inheritance. Fixes https://gitlab.com/kicad/code/kicad/issues/4581pull/16/head
26 changed files with 586 additions and 242 deletions
-
1common/CMakeLists.txt
-
87common/dialogs/panel_setup_netclasses.cpp
-
2common/dialogs/panel_setup_netclasses.h
-
25common/dialogs/panel_setup_netclasses_base.cpp
-
20common/dialogs/panel_setup_netclasses_base.fbp
-
2common/dialogs/panel_setup_netclasses_base.h
-
50common/netclass.cpp
-
34common/project/net_settings.cpp
-
162common/widgets/grid_color_swatch_helpers.cpp
-
79common/widgets/grid_color_swatch_helpers.h
-
16common/widgets/grid_icon_text_helpers.cpp
-
2eeschema/dialogs/dialog_schematic_setup.cpp
-
33eeschema/sch_bus_entry.cpp
-
4eeschema/sch_bus_entry.h
-
19eeschema/sch_item.cpp
-
3eeschema/sch_item.h
-
51eeschema/sch_line.cpp
-
8eeschema/sch_line.h
-
45eeschema/sch_painter.cpp
-
16eeschema/sim/ngspice.cpp
-
4include/board_design_settings.h
-
92include/convert_to_biu.h
-
57include/netclass.h
-
1include/widgets/grid_icon_text_helpers.h
-
2pcbnew/dialogs/dialog_board_setup.cpp
-
13pcbnew/pcbnew.h
@ -0,0 +1,162 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 2 |
|||
* 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, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <grid_color_swatch_helpers.h>
|
|||
|
|||
#include <settings/color_settings.h>
|
|||
#include <dialogs/dialog_color_picker.h>
|
|||
#include <dialog_shim.h>
|
|||
|
|||
|
|||
//-------- Custom wxGridCellRenderers --------------------------------------------------
|
|||
|
|||
|
|||
GRID_CELL_COLOR_RENDERER::GRID_CELL_COLOR_RENDERER() |
|||
{ |
|||
} |
|||
|
|||
|
|||
GRID_CELL_COLOR_RENDERER::~GRID_CELL_COLOR_RENDERER() |
|||
{ |
|||
} |
|||
|
|||
|
|||
wxGridCellRenderer* GRID_CELL_COLOR_RENDERER::Clone() const |
|||
{ |
|||
return new GRID_CELL_COLOR_RENDERER; |
|||
} |
|||
|
|||
|
|||
wxSize GRID_CELL_COLOR_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, |
|||
int row, int col ) |
|||
{ |
|||
wxSize bestSize; |
|||
|
|||
dc.SetFont(attr.GetFont()); |
|||
dc.GetTextExtent( "WWW", &bestSize.x, &bestSize.y ); |
|||
|
|||
return bestSize; |
|||
} |
|||
|
|||
|
|||
void GRID_CELL_COLOR_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, |
|||
const wxRect& aRect, int aRow, int aCol, bool isSelected ) |
|||
{ |
|||
wxRect rect = aRect; |
|||
|
|||
// erase background
|
|||
wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected ); |
|||
|
|||
// draw the swatch
|
|||
wxBitmap bitmap( aRect.GetWidth() + 1, aRect.GetHeight() + 1 ); |
|||
wxMemoryDC bmpDC; |
|||
wxBrush brush; |
|||
wxColour color; |
|||
|
|||
// Prepare Bitmap
|
|||
bmpDC.SelectObject( bitmap ); |
|||
|
|||
color.Set( aGrid.GetTable()->GetValue( aRow, aCol ) ); |
|||
brush.SetStyle( wxBRUSHSTYLE_SOLID ); |
|||
brush.SetColour( color ); |
|||
bmpDC.SetBrush( brush ); |
|||
bmpDC.DrawRectangle( -1, -1, bitmap.GetWidth()+1, bitmap.GetHeight()+1 ); |
|||
|
|||
aDC.DrawBitmap( bitmap, rect.GetTopLeft(), true ); |
|||
} |
|||
|
|||
|
|||
|
|||
//-------- Custom wxGridCellEditors ----------------------------------------------------
|
|||
//
|
|||
// Note: this implementation is an adaptation of wxGridCellBoolEditor
|
|||
|
|||
|
|||
GRID_CELL_COLOR_SELECTOR::GRID_CELL_COLOR_SELECTOR( DIALOG_SHIM* aDialog, wxGrid* aGrid ) : |
|||
m_dialog( aDialog ), |
|||
m_grid( aGrid ), |
|||
m_value( COLOR4D::UNSPECIFIED ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
wxGridCellEditor* GRID_CELL_COLOR_SELECTOR::Clone() const |
|||
{ |
|||
return new GRID_CELL_COLOR_SELECTOR( m_dialog, m_grid ); |
|||
} |
|||
|
|||
|
|||
void GRID_CELL_COLOR_SELECTOR::Create( wxWindow* aParent, wxWindowID aId, |
|||
wxEvtHandler* aEventHandler ) |
|||
{ |
|||
// wxWidgets needs a control to hold on to the event handler
|
|||
m_control = new wxCheckBox( aParent, wxID_ANY, wxEmptyString ); |
|||
|
|||
wxGridCellEditor::Create( aParent, aId, aEventHandler ); |
|||
} |
|||
|
|||
|
|||
wxString GRID_CELL_COLOR_SELECTOR::GetValue() const |
|||
{ |
|||
return m_value.ToWxString( wxC2S_CSS_SYNTAX ); |
|||
} |
|||
|
|||
|
|||
void GRID_CELL_COLOR_SELECTOR::BeginEdit( int row, int col, wxGrid* grid ) |
|||
{ |
|||
m_value.SetFromWxString( grid->GetTable()->GetValue( row, col ) ); |
|||
|
|||
DIALOG_COLOR_PICKER dialog( m_dialog, m_value, false ); |
|||
|
|||
if( dialog.ShowModal() == wxID_OK ) |
|||
m_value = dialog.GetColor(); |
|||
|
|||
m_grid->GetTable()->SetValue( row, col, GetValue() ); |
|||
|
|||
// That's it; we're all done
|
|||
m_grid->HideCellEditControl(); |
|||
m_grid->ForceRefresh(); |
|||
} |
|||
|
|||
|
|||
bool GRID_CELL_COLOR_SELECTOR::EndEdit( int row, int col, const wxGrid* grid, |
|||
const wxString& oldval, wxString *newval ) |
|||
{ |
|||
if ( newval ) |
|||
*newval = GetValue(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void GRID_CELL_COLOR_SELECTOR::ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) |
|||
{ |
|||
aGrid->GetTable()->SetValue( aRow, aCol, GetValue() ); |
|||
} |
|||
|
|||
|
|||
void GRID_CELL_COLOR_SELECTOR::Reset() |
|||
{ |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,79 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* 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 2 |
|||
* 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, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef GRID_COLOR_SWATCH_HELPERS |
|||
#define GRID_COLOR_SWATCH_HELPERS |
|||
|
|||
#include <wx/generic/gridctrl.h> |
|||
#include <wx/generic/grideditors.h> |
|||
#include <gal/color4d.h> |
|||
|
|||
|
|||
class wxGrid; |
|||
class DIALOG_SHIM; |
|||
|
|||
|
|||
//-------- Custom wxGridCellRenderers -------------------------------------------------- |
|||
|
|||
class GRID_CELL_COLOR_RENDERER : public wxGridCellRenderer |
|||
{ |
|||
public: |
|||
GRID_CELL_COLOR_RENDERER(); |
|||
~GRID_CELL_COLOR_RENDERER() override; |
|||
|
|||
wxGridCellRenderer* Clone() const override; |
|||
wxSize GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col ) override; |
|||
|
|||
void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow, |
|||
int aCol, bool isSelected ) override; |
|||
}; |
|||
|
|||
|
|||
//-------- Custom wxGridCellEditors ---------------------------------------------------- |
|||
// |
|||
// Note: this implementation is an adaptation of wxGridCellChoiceEditor |
|||
|
|||
class GRID_CELL_COLOR_SELECTOR : public wxGridCellEditor |
|||
{ |
|||
public: |
|||
GRID_CELL_COLOR_SELECTOR( DIALOG_SHIM* aDialog, wxGrid* aGrid ); |
|||
|
|||
wxGridCellEditor* Clone() const override; |
|||
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override; |
|||
|
|||
wxString GetValue() const override; |
|||
|
|||
void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override; |
|||
bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *newval ) override; |
|||
void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override; |
|||
void Reset() override; |
|||
|
|||
protected: |
|||
DIALOG_SHIM* m_dialog; |
|||
wxGrid* m_grid; |
|||
KIGFX::COLOR4D m_value; |
|||
|
|||
wxDECLARE_NO_COPY_CLASS( GRID_CELL_COLOR_SELECTOR ); |
|||
}; |
|||
|
|||
#endif // GRID_COLOR_SWATCH_HELPERS |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue