Browse Source
ADDED alternate pin definitions and assignments.
ADDED alternate pin definitions and assignments.
Fixes https://gitlab.com/kicad/code/kicad/issues/2002pull/16/head
49 changed files with 2428 additions and 785 deletions
-
3eeschema/CMakeLists.txt
-
9eeschema/autoplace_fields.cpp
-
4eeschema/connection_graph.cpp
-
29eeschema/cross-probing.cpp
-
18eeschema/dialogs/dialog_edit_component_in_lib_base.cpp
-
20eeschema/dialogs/dialog_edit_component_in_lib_base.fbp
-
9eeschema/dialogs/dialog_edit_component_in_schematic.cpp
-
1eeschema/dialogs/dialog_edit_component_in_schematic.h
-
11eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp
-
77eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp
-
2eeschema/dialogs/dialog_edit_component_in_schematic_base.h
-
95eeschema/dialogs/dialog_lib_edit_pin_table.cpp
-
25eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp
-
38eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp
-
265eeschema/dialogs/dialog_pin_properties.cpp
-
48eeschema/dialogs/dialog_pin_properties.h
-
88eeschema/dialogs/dialog_pin_properties_base.cpp
-
421eeschema/dialogs/dialog_pin_properties_base.fbp
-
18eeschema/dialogs/dialog_pin_properties_base.h
-
410eeschema/dialogs/dialog_sch_pin_table.cpp
-
69eeschema/dialogs/dialog_sch_pin_table.h
-
94eeschema/dialogs/dialog_sch_pin_table_base.cpp
-
174eeschema/dialogs/dialog_sch_pin_table_base.fbp
-
55eeschema/dialogs/dialog_sch_pin_table_base.h
-
2eeschema/erc.cpp
-
152eeschema/lib_pin.cpp
-
91eeschema/lib_pin.h
-
4eeschema/netlist_exporters/netlist_exporter.cpp
-
75eeschema/pin_shape.cpp
-
57eeschema/pin_shape.h
-
216eeschema/pin_type.cpp
-
41eeschema/pin_type.h
-
76eeschema/sch_component.cpp
-
49eeschema/sch_component.h
-
2eeschema/sch_eagle_plugin.cpp
-
2eeschema/sch_edit_frame.cpp
-
9eeschema/sch_file_versions.h
-
2eeschema/sch_item.cpp
-
19eeschema/sch_painter.cpp
-
103eeschema/sch_pin.cpp
-
24eeschema/sch_pin.h
-
198eeschema/sch_sexpr_parser.cpp
-
40eeschema/sch_sexpr_plugin.cpp
-
4eeschema/sch_sheet_path.cpp
-
4eeschema/tools/backannotate.cpp
-
32eeschema/tools/ee_selection_tool.cpp
-
15eeschema/tools/sch_editor_control.cpp
-
3eeschema/widgets/pin_shape_combobox.h
-
10include/widgets/grid_icon_text_helpers.h
@ -0,0 +1,410 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2020 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 "dialog_sch_pin_table.h"
|
|||
#include <grid_tricks.h>
|
|||
#include <pin_number.h>
|
|||
#include <sch_edit_frame.h>
|
|||
#include <confirm.h>
|
|||
#include <lib_edit_frame.h>
|
|||
#include <widgets/grid_icon_text_helpers.h>
|
|||
#include <widgets/wx_grid.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <widgets/grid_combobox.h>
|
|||
|
|||
class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN> |
|||
{ |
|||
protected: |
|||
std::vector<wxGridCellAttr*> m_nameAttrs; |
|||
wxGridCellAttr* m_typeAttr; |
|||
wxGridCellAttr* m_shapeAttr; |
|||
|
|||
public: |
|||
SCH_PIN_TABLE_DATA_MODEL() : |
|||
m_typeAttr( nullptr ), |
|||
m_shapeAttr( nullptr ) |
|||
{ |
|||
} |
|||
|
|||
~SCH_PIN_TABLE_DATA_MODEL() |
|||
{ |
|||
for( wxGridCellAttr* attr : m_nameAttrs ) |
|||
attr->DecRef(); |
|||
|
|||
m_typeAttr->DecRef(); |
|||
m_shapeAttr->DecRef(); |
|||
} |
|||
|
|||
void BuildAttrs() |
|||
{ |
|||
for( const SCH_PIN& pin : *this ) |
|||
{ |
|||
wxArrayString choices; |
|||
LIB_PIN* lib_pin = pin.GetLibPin(); |
|||
|
|||
choices.push_back( lib_pin->GetName() ); |
|||
|
|||
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->GetAlternates() ) |
|||
choices.push_back( alt.first ); |
|||
|
|||
wxGridCellAttr* attr = new wxGridCellAttr(); |
|||
attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) ); |
|||
|
|||
m_nameAttrs.push_back( attr ); |
|||
} |
|||
|
|||
m_typeAttr = new wxGridCellAttr; |
|||
m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) ); |
|||
m_typeAttr->SetReadOnly( true ); |
|||
|
|||
m_shapeAttr = new wxGridCellAttr; |
|||
m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) ); |
|||
m_shapeAttr->SetReadOnly( true ); |
|||
} |
|||
|
|||
int GetNumberRows() override { return (int) size(); } |
|||
int GetNumberCols() override { return COL_COUNT; } |
|||
|
|||
wxString GetColLabelValue( int aCol ) override |
|||
{ |
|||
switch( aCol ) |
|||
{ |
|||
case COL_NUMBER: return _( "Number" ); |
|||
case COL_NAME: return _( "Name" ); |
|||
case COL_TYPE: return _( "Electrical Type" ); |
|||
case COL_SHAPE: return _( "Graphic Style" ); |
|||
default: wxFAIL; return wxEmptyString; |
|||
} |
|||
} |
|||
|
|||
bool IsEmptyCell( int row, int col ) override |
|||
{ |
|||
return false; // don't allow adjacent cell overflow, even if we are actually empty
|
|||
} |
|||
|
|||
wxString GetValue( int aRow, int aCol ) override |
|||
{ |
|||
return GetValue( at( aRow ), aCol ); |
|||
} |
|||
|
|||
static wxString GetValue( const SCH_PIN& aPin, int aCol ) |
|||
{ |
|||
switch( aCol ) |
|||
{ |
|||
case COL_NUMBER: return aPin.GetNumber(); |
|||
case COL_NAME: return aPin.GetName(); |
|||
case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )]; |
|||
case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )]; |
|||
default: wxFAIL; return wxEmptyString; |
|||
} |
|||
} |
|||
|
|||
wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override |
|||
{ |
|||
switch( aCol ) |
|||
{ |
|||
case COL_NAME: |
|||
m_nameAttrs[ aRow ]->IncRef(); |
|||
return m_nameAttrs[ aRow ]; |
|||
|
|||
case COL_NUMBER: |
|||
return nullptr; |
|||
|
|||
case COL_TYPE: |
|||
m_typeAttr->IncRef(); |
|||
return m_typeAttr; |
|||
|
|||
case COL_SHAPE: |
|||
m_shapeAttr->IncRef(); |
|||
return m_shapeAttr; |
|||
|
|||
default: |
|||
wxFAIL; |
|||
return nullptr; |
|||
} |
|||
} |
|||
|
|||
void SetValue( int aRow, int aCol, const wxString &aValue ) override |
|||
{ |
|||
switch( aCol ) |
|||
{ |
|||
case COL_NAME: |
|||
if( aValue == at( aRow ).GetName() ) |
|||
at( aRow ).SetAlt( wxEmptyString ); |
|||
else |
|||
at( aRow ).SetAlt( aValue ); |
|||
break; |
|||
|
|||
case COL_NUMBER: |
|||
case COL_TYPE: |
|||
case COL_SHAPE: |
|||
// Read-only.
|
|||
break; |
|||
|
|||
default: |
|||
wxFAIL; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending ) |
|||
{ |
|||
wxString lhStr = GetValue( lhs, sortCol ); |
|||
wxString rhStr = GetValue( rhs, sortCol ); |
|||
|
|||
if( lhStr == rhStr ) |
|||
{ |
|||
// Secondary sort key is always COL_NUMBER
|
|||
sortCol = COL_NUMBER; |
|||
lhStr = GetValue( lhs, sortCol ); |
|||
rhStr = GetValue( rhs, sortCol ); |
|||
} |
|||
|
|||
bool res; |
|||
|
|||
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth
|
|||
// to get the opposite sort. i.e. ~(a<b) != (a>b)
|
|||
auto cmp = [ ascending ]( const auto a, const auto b ) |
|||
{ |
|||
if( ascending ) |
|||
return a < b; |
|||
else |
|||
return b < a; |
|||
}; |
|||
|
|||
switch( sortCol ) |
|||
{ |
|||
case COL_NUMBER: |
|||
case COL_NAME: |
|||
res = cmp( PinNumbers::Compare( lhStr, rhStr ), 0 ); |
|||
break; |
|||
case COL_TYPE: |
|||
case COL_SHAPE: |
|||
res = cmp( lhStr.CmpNoCase( rhStr ), 0 ); |
|||
break; |
|||
default: |
|||
res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); |
|||
break; |
|||
} |
|||
|
|||
return res; |
|||
} |
|||
|
|||
void SortRows( int aSortCol, bool ascending ) |
|||
{ |
|||
std::sort( begin(), end(), |
|||
[ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool |
|||
{ |
|||
return compare( lhs, rhs, aSortCol, ascending ); |
|||
} ); |
|||
} |
|||
}; |
|||
|
|||
|
|||
DIALOG_SCH_PIN_TABLE::DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aComp ) : |
|||
DIALOG_SCH_PIN_TABLE_BASE( parent ), |
|||
m_editFrame( parent ), |
|||
m_comp( aComp ) |
|||
{ |
|||
m_dataModel = new SCH_PIN_TABLE_DATA_MODEL(); |
|||
|
|||
// Make a copy of the pins for editing
|
|||
for( const std::unique_ptr<SCH_PIN>& pin : m_comp->GetRawPins() ) |
|||
m_dataModel->push_back( *pin ); |
|||
|
|||
m_dataModel->SortRows( COL_NUMBER, true ); |
|||
m_dataModel->BuildAttrs(); |
|||
|
|||
// Save original columns widths so we can do proportional sizing.
|
|||
for( int i = 0; i < COL_COUNT; ++i ) |
|||
m_originalColWidths[ i ] = m_grid->GetColSize( i ); |
|||
|
|||
// Give a bit more room for combobox editors
|
|||
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); |
|||
|
|||
m_grid->SetTable( m_dataModel ); |
|||
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); |
|||
|
|||
GetSizer()->SetSizeHints(this); |
|||
Centre(); |
|||
|
|||
m_ButtonsOK->SetDefault(); |
|||
m_initialized = true; |
|||
m_modified = false; |
|||
m_width = 0; |
|||
|
|||
// Connect Events
|
|||
m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this ); |
|||
} |
|||
|
|||
|
|||
DIALOG_SCH_PIN_TABLE::~DIALOG_SCH_PIN_TABLE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this ); |
|||
|
|||
// Prevents crash bug in wxGrid's d'tor
|
|||
m_grid->DestroyTable( m_dataModel ); |
|||
|
|||
// Delete the GRID_TRICKS.
|
|||
m_grid->PopEventHandler( true ); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_SCH_PIN_TABLE::TransferDataToWindow() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool DIALOG_SCH_PIN_TABLE::TransferDataFromWindow() |
|||
{ |
|||
if( !m_grid->CommitPendingChanges() ) |
|||
return false; |
|||
|
|||
// Update any assignments
|
|||
for( const SCH_PIN& model_pin : *m_dataModel ) |
|||
{ |
|||
// map from the edited copy back to the "real" pin in the component
|
|||
SCH_PIN* src_pin = m_comp->GetPin( model_pin.GetLibPin() ); |
|||
src_pin->SetAlt( model_pin.GetAlt() ); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::OnCellEdited( wxGridEvent& aEvent ) |
|||
{ |
|||
int row = aEvent.GetRow(); |
|||
|
|||
// These are just to get the cells refreshed
|
|||
m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) ); |
|||
m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) ); |
|||
|
|||
m_modified = true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::OnColSort( wxGridEvent& aEvent ) |
|||
{ |
|||
int sortCol = aEvent.GetCol(); |
|||
bool ascending; |
|||
|
|||
// This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
|
|||
// event, and if we ask it will give us pre-event info.
|
|||
if( m_grid->IsSortingBy( sortCol ) ) |
|||
// same column; invert ascending
|
|||
ascending = !m_grid->IsSortOrderAscending(); |
|||
else |
|||
// different column; start with ascending
|
|||
ascending = true; |
|||
|
|||
m_dataModel->SortRows( sortCol, ascending ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::adjustGridColumns( int aWidth ) |
|||
{ |
|||
m_width = aWidth; |
|||
|
|||
// Account for scroll bars
|
|||
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x ); |
|||
|
|||
wxGridUpdateLocker deferRepaintsTillLeavingScope; |
|||
|
|||
// The Number and Name columns must be at least wide enough to hold their contents, but
|
|||
// no less wide than their original widths.
|
|||
|
|||
m_grid->AutoSizeColumn( COL_NUMBER ); |
|||
|
|||
if( m_grid->GetColSize( COL_NUMBER ) < m_originalColWidths[ COL_NUMBER ] ) |
|||
m_grid->SetColSize( COL_NUMBER, m_originalColWidths[ COL_NUMBER ] ); |
|||
|
|||
m_grid->AutoSizeColumn( COL_NAME ); |
|||
|
|||
if( m_grid->GetColSize( COL_NAME ) < m_originalColWidths[ COL_NAME ] ) |
|||
m_grid->SetColSize( COL_NAME, m_originalColWidths[ COL_NAME ] ); |
|||
|
|||
// If the grid is still wider than the columns, then stretch the Number and Name columns
|
|||
// to fit.
|
|||
|
|||
for( int i = 0; i < COL_COUNT; ++i ) |
|||
aWidth -= m_grid->GetColSize( i ); |
|||
|
|||
if( aWidth > 0 ) |
|||
{ |
|||
m_grid->SetColSize( COL_NUMBER, m_grid->GetColSize( COL_NUMBER ) + aWidth / 2 ); |
|||
m_grid->SetColSize( COL_NAME, m_grid->GetColSize( COL_NAME ) + aWidth / 2 ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::OnSize( wxSizeEvent& event ) |
|||
{ |
|||
auto new_size = event.GetSize().GetX(); |
|||
|
|||
if( m_initialized && m_width != new_size ) |
|||
{ |
|||
adjustGridColumns( new_size ); |
|||
} |
|||
|
|||
// Always propagate for a grid repaint (needed if the height changes, as well as width)
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::OnCancel( wxCommandEvent& event ) |
|||
{ |
|||
Close(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_SCH_PIN_TABLE::OnClose( wxCloseEvent& event ) |
|||
{ |
|||
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
|
|||
m_grid->CommitPendingChanges( true ); |
|||
|
|||
int retval = wxCANCEL; |
|||
|
|||
if( m_modified && !HandleUnsavedChanges( this, _( "Save changes?" ), |
|||
[&]()->bool |
|||
{ |
|||
if( TransferDataFromWindow() ) |
|||
{ |
|||
retval = wxOK; |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} ) ) |
|||
{ |
|||
event.Veto(); |
|||
return; |
|||
} |
|||
|
|||
if( IsQuasiModal() ) |
|||
EndQuasiModal( retval ); |
|||
else |
|||
EndModal( retval ); |
|||
} |
|||
@ -0,0 +1,69 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2019 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 "dialog_sch_pin_table_base.h" |
|||
#include <sch_pin.h> |
|||
|
|||
enum COL_ORDER |
|||
{ |
|||
COL_NUMBER, |
|||
COL_NAME, |
|||
COL_TYPE, |
|||
COL_SHAPE, |
|||
|
|||
COL_COUNT // keep as last |
|||
}; |
|||
|
|||
|
|||
class SCH_PIN_TABLE_DATA_MODEL; |
|||
class SCH_EDIT_FRAME; |
|||
|
|||
|
|||
class DIALOG_SCH_PIN_TABLE : public DIALOG_SCH_PIN_TABLE_BASE |
|||
{ |
|||
public: |
|||
DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aPart ); |
|||
~DIALOG_SCH_PIN_TABLE() override; |
|||
|
|||
bool TransferDataToWindow() override; |
|||
bool TransferDataFromWindow() override; |
|||
|
|||
void OnColSort( wxGridEvent& aEvent ); |
|||
void OnCellEdited( wxGridEvent& event ) override; |
|||
void OnSize( wxSizeEvent& event ) override; |
|||
void OnCancel( wxCommandEvent& event ) override; |
|||
void OnClose( wxCloseEvent& event ) override; |
|||
|
|||
protected: |
|||
void adjustGridColumns( int aWidth ); |
|||
|
|||
SCH_EDIT_FRAME* m_editFrame; |
|||
bool m_initialized = false; |
|||
int m_originalColWidths[ COL_COUNT ]; |
|||
SCH_COMPONENT* m_comp; |
|||
|
|||
int m_width; |
|||
|
|||
SCH_PIN_TABLE_DATA_MODEL* m_dataModel; |
|||
bool m_modified; ///< true when there are unsaved changes |
|||
}; |
|||
@ -0,0 +1,94 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "widgets/wx_grid.h"
|
|||
|
|||
#include "dialog_sch_pin_table_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_SCH_PIN_TABLE_BASE::DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) |
|||
{ |
|||
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
wxBoxSizer* top_sizer; |
|||
top_sizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); |
|||
|
|||
// Grid
|
|||
m_grid->CreateGrid( 5, 4 ); |
|||
m_grid->EnableEditing( true ); |
|||
m_grid->EnableGridLines( true ); |
|||
m_grid->EnableDragGridSize( false ); |
|||
m_grid->SetMargins( 0, 0 ); |
|||
|
|||
// Columns
|
|||
m_grid->SetColSize( 0, 84 ); |
|||
m_grid->SetColSize( 1, 140 ); |
|||
m_grid->SetColSize( 2, 140 ); |
|||
m_grid->SetColSize( 3, 140 ); |
|||
m_grid->EnableDragColMove( false ); |
|||
m_grid->EnableDragColSize( true ); |
|||
m_grid->SetColLabelSize( 24 ); |
|||
m_grid->SetColLabelValue( 0, _("Number") ); |
|||
m_grid->SetColLabelValue( 1, _("Name") ); |
|||
m_grid->SetColLabelValue( 2, _("Electrical Type") ); |
|||
m_grid->SetColLabelValue( 3, _("Graphic Style") ); |
|||
m_grid->SetColLabelValue( 4, _("Orientation") ); |
|||
m_grid->SetColLabelValue( 5, _("Number Text Size") ); |
|||
m_grid->SetColLabelValue( 6, _("Name Text Size") ); |
|||
m_grid->SetColLabelValue( 7, _("Length") ); |
|||
m_grid->SetColLabelValue( 8, _("X Position") ); |
|||
m_grid->SetColLabelValue( 9, _("Y Position") ); |
|||
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); |
|||
|
|||
// Rows
|
|||
m_grid->EnableDragRowSize( false ); |
|||
m_grid->SetRowLabelSize( 0 ); |
|||
m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); |
|||
|
|||
// Label Appearance
|
|||
|
|||
// Cell Defaults
|
|||
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); |
|||
m_grid->SetMinSize( wxSize( 512,320 ) ); |
|||
|
|||
top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 15 ); |
|||
|
|||
m_Buttons = new wxStdDialogButtonSizer(); |
|||
m_ButtonsOK = new wxButton( this, wxID_OK ); |
|||
m_Buttons->AddButton( m_ButtonsOK ); |
|||
m_ButtonsCancel = new wxButton( this, wxID_CANCEL ); |
|||
m_Buttons->AddButton( m_ButtonsCancel ); |
|||
m_Buttons->Realize(); |
|||
|
|||
top_sizer->Add( m_Buttons, 0, wxEXPAND|wxALL, 5 ); |
|||
|
|||
|
|||
this->SetSizer( top_sizer ); |
|||
this->Layout(); |
|||
top_sizer->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) ); |
|||
m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this ); |
|||
m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this ); |
|||
m_ButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_SCH_PIN_TABLE_BASE::~DIALOG_SCH_PIN_TABLE_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) ); |
|||
m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this ); |
|||
m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this ); |
|||
m_ButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this ); |
|||
|
|||
} |
|||
@ -0,0 +1,174 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
|||
<wxFormBuilder_Project> |
|||
<FileVersion major="1" minor="15" /> |
|||
<object class="Project" expanded="1"> |
|||
<property name="class_decoration"></property> |
|||
<property name="code_generation">C++</property> |
|||
<property name="disconnect_events">1</property> |
|||
<property name="disconnect_mode">source_name</property> |
|||
<property name="disconnect_php_events">0</property> |
|||
<property name="disconnect_python_events">0</property> |
|||
<property name="embedded_files_path">res</property> |
|||
<property name="encoding">UTF-8</property> |
|||
<property name="event_generation">connect</property> |
|||
<property name="file">dialog_sch_pin_table_base</property> |
|||
<property name="first_id">1000</property> |
|||
<property name="help_provider">none</property> |
|||
<property name="indent_with_spaces"></property> |
|||
<property name="internationalize">1</property> |
|||
<property name="name">dialog_sch_pin_table</property> |
|||
<property name="namespace"></property> |
|||
<property name="path">.</property> |
|||
<property name="precompiled_header"></property> |
|||
<property name="relative_path">1</property> |
|||
<property name="skip_lua_events">1</property> |
|||
<property name="skip_php_events">1</property> |
|||
<property name="skip_python_events">1</property> |
|||
<property name="ui_table">UI</property> |
|||
<property name="use_enum">0</property> |
|||
<property name="use_microsoft_bom">0</property> |
|||
<object class="Dialog" expanded="1"> |
|||
<property name="aui_managed">0</property> |
|||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> |
|||
<property name="bg"></property> |
|||
<property name="center">wxBOTH</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="enabled">1</property> |
|||
<property name="event_handler">decl_pure_virtual</property> |
|||
<property name="extra_style"></property> |
|||
<property name="fg"></property> |
|||
<property name="font"></property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">DIALOG_SCH_PIN_TABLE_BASE</property> |
|||
<property name="pos"></property> |
|||
<property name="size">-1,-1</property> |
|||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> |
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> |
|||
<property name="title">Pin Table</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnClose">OnClose</event> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">top_sizer</property> |
|||
<property name="orient">wxVERTICAL</property> |
|||
<property name="permission">none</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">15</property> |
|||
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property> |
|||
<property name="proportion">1</property> |
|||
<object class="wxGrid" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="autosize_cols">0</property> |
|||
<property name="autosize_rows">0</property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="cell_bg"></property> |
|||
<property name="cell_font"></property> |
|||
<property name="cell_horiz_alignment">wxALIGN_LEFT</property> |
|||
<property name="cell_text"></property> |
|||
<property name="cell_vert_alignment">wxALIGN_TOP</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property> |
|||
<property name="col_label_size">24</property> |
|||
<property name="col_label_values">"Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position"</property> |
|||
<property name="col_label_vert_alignment">wxALIGN_CENTER</property> |
|||
<property name="cols">4</property> |
|||
<property name="column_sizes">84,140,140,140</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="drag_col_move">0</property> |
|||
<property name="drag_col_size">1</property> |
|||
<property name="drag_grid_size">0</property> |
|||
<property name="drag_row_size">0</property> |
|||
<property name="editing">1</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="grid_line_color"></property> |
|||
<property name="grid_lines">1</property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label_bg"></property> |
|||
<property name="label_font"></property> |
|||
<property name="label_text"></property> |
|||
<property name="margin_height">0</property> |
|||
<property name="margin_width">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size">512,320</property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_grid</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="row_label_horiz_alignment">wxALIGN_CENTER</property> |
|||
<property name="row_label_size">0</property> |
|||
<property name="row_label_values"></property> |
|||
<property name="row_label_vert_alignment">wxALIGN_CENTER</property> |
|||
<property name="row_sizes"></property> |
|||
<property name="rows">5</property> |
|||
<property name="show">1</property> |
|||
<property name="size">-1,-1</property> |
|||
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<event name="OnGridCellChange">OnCellEdited</event> |
|||
<event name="OnSize">OnSize</event> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND|wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStdDialogButtonSizer" expanded="1"> |
|||
<property name="Apply">0</property> |
|||
<property name="Cancel">1</property> |
|||
<property name="ContextHelp">0</property> |
|||
<property name="Help">0</property> |
|||
<property name="No">0</property> |
|||
<property name="OK">1</property> |
|||
<property name="Save">0</property> |
|||
<property name="Yes">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">m_Buttons</property> |
|||
<property name="permission">protected</property> |
|||
<event name="OnCancelButtonClick">OnCancel</event> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</wxFormBuilder_Project> |
|||
@ -0,0 +1,55 @@ |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
// C++ code generated with wxFormBuilder (version Oct 26 2018) |
|||
// http://www.wxformbuilder.org/ |
|||
// |
|||
// PLEASE DO *NOT* EDIT THIS FILE! |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#pragma once |
|||
|
|||
#include <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include <wx/intl.h> |
|||
class WX_GRID; |
|||
|
|||
#include "dialog_shim.h" |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/string.h> |
|||
#include <wx/font.h> |
|||
#include <wx/grid.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/button.h> |
|||
#include <wx/dialog.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DIALOG_SCH_PIN_TABLE_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DIALOG_SCH_PIN_TABLE_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
WX_GRID* m_grid; |
|||
wxStdDialogButtonSizer* m_Buttons; |
|||
wxButton* m_ButtonsOK; |
|||
wxButton* m_ButtonsCancel; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void OnClose( wxCloseEvent& event ) = 0; |
|||
virtual void OnCellEdited( wxGridEvent& event ) = 0; |
|||
virtual void OnSize( wxSizeEvent& event ) = 0; |
|||
virtual void OnCancel( wxCommandEvent& event ) = 0; |
|||
|
|||
|
|||
public: |
|||
|
|||
DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Table"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); |
|||
~DIALOG_SCH_PIN_TABLE_BASE(); |
|||
|
|||
}; |
|||
|
|||
@ -1,75 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004-2015 KiCad Developers, see change_log.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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file pin_shape.cpp |
|||
* @brief Pin shape handling |
|||
*/ |
|||
|
|||
#include "pin_shape.h"
|
|||
|
|||
#include <macros.h>
|
|||
|
|||
|
|||
struct pinShapeStruct |
|||
{ |
|||
wxString name; |
|||
const BITMAP_OPAQUE* bitmap; |
|||
}; |
|||
|
|||
/*
|
|||
* Conversion map between PLOT_DASH_TYPE values and style names displayed |
|||
*/ |
|||
// clang-format off
|
|||
const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes = { |
|||
{ GRAPHIC_PINSHAPE::LINE, { _( "Line" ), pinshape_normal_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::INVERTED, { _( "Inverted" ), pinshape_invert_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::CLOCK, { _( "Clock" ), pinshape_clock_normal_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::INVERTED_CLOCK, { _( "Inverted clock" ), pinshape_clock_invert_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::INPUT_LOW, { _( "Input low" ), pinshape_active_low_input_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::CLOCK_LOW, { _( "Clock low" ), pinshape_clock_active_low_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::OUTPUT_LOW, { _( "Output low" ), pinshape_active_low_output_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, { _( "Falling edge clock" ), pinshape_clock_fall_xpm } }, |
|||
{ GRAPHIC_PINSHAPE::NONLOGIC, { _( "NonLogic" ), pinshape_nonlogic_xpm } }, |
|||
}; |
|||
// clang-format on
|
|||
|
|||
|
|||
wxString PinShapeGetText( GRAPHIC_PINSHAPE aShape ) |
|||
{ |
|||
auto findIt = pinShapes.find( aShape ); |
|||
|
|||
wxCHECK_MSG( findIt != pinShapes.end(), wxT( "?" ), "Could not find pinshape in lookup map" ); |
|||
|
|||
return findIt->second.name; |
|||
} |
|||
|
|||
|
|||
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE aShape ) |
|||
{ |
|||
auto findIt = pinShapes.find( aShape ); |
|||
|
|||
wxCHECK_MSG( findIt != pinShapes.end(), nullptr, "Could not find pinshape in lookup map" ); |
|||
|
|||
return findIt->second.bitmap; |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004-2015 KiCad Developers, see change_log.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 |
|||
*/ |
|||
|
|||
/** |
|||
* @file pin_shape.h |
|||
* @brief Pin shape handling |
|||
*/ |
|||
|
|||
#ifndef _PIN_SHAPE_H_ |
|||
#define _PIN_SHAPE_H_ |
|||
|
|||
#include <wx/string.h> |
|||
#include <bitmaps.h> |
|||
|
|||
enum class GRAPHIC_PINSHAPE |
|||
{ |
|||
LINE, |
|||
INVERTED, |
|||
CLOCK, |
|||
INVERTED_CLOCK, |
|||
INPUT_LOW, |
|||
CLOCK_LOW, |
|||
OUTPUT_LOW, |
|||
FALLING_EDGE_CLOCK, |
|||
NONLOGIC, |
|||
|
|||
LAST_OPTION = NONLOGIC ///< this is the sentinel value, must be set to last enum value |
|||
}; |
|||
|
|||
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 ) |
|||
|
|||
|
|||
// UI |
|||
wxString PinShapeGetText( GRAPHIC_PINSHAPE shape ); |
|||
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE shape ); |
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue