diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index c513a269ab..f375684889 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -79,8 +79,8 @@ set( EESCHEMA_DLGS dialogs/dialog_lib_text_properties_base.cpp dialogs/dialog_lib_textbox_properties.cpp dialogs/dialog_lib_textbox_properties_base.cpp - dialogs/dialog_line_wire_bus_properties.cpp - dialogs/dialog_line_wire_bus_properties_base.cpp + dialogs/dialog_line_properties.cpp + dialogs/dialog_line_properties_base.cpp dialogs/dialog_migrate_buses.cpp dialogs/dialog_migrate_buses_base.cpp dialogs/dialog_netlist.cpp @@ -116,6 +116,8 @@ set( EESCHEMA_DLGS dialogs/dialog_update_from_pcb_base.cpp dialogs/dialog_update_symbol_fields.cpp dialogs/dialog_update_symbol_fields_base.cpp + dialogs/dialog_wire_bus_properties.cpp + dialogs/dialog_wire_bus_properties_base.cpp dialogs/panel_eeschema_color_settings.cpp dialogs/panel_eeschema_display_options.cpp dialogs/panel_eeschema_display_options_base.cpp diff --git a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp index ba81dc73d9..88e8a33055 100644 --- a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -250,7 +250,8 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS SCH_TEXT* sch_text = dynamic_cast( aItem ); SCH_JUNCTION* junction = dynamic_cast( aItem ); - m_parent->SaveCopyInUndoList( aSheetPath.LastScreen(), aItem, UNDO_REDO::CHANGED, m_appendUndo ); + m_parent->SaveCopyInUndoList( aSheetPath.LastScreen(), aItem, UNDO_REDO::CHANGED, m_appendUndo, + false ); m_appendUndo = true; if( eda_text ) diff --git a/eeschema/dialogs/dialog_junction_props.cpp b/eeschema/dialogs/dialog_junction_props.cpp index 81035bf251..4b18d39536 100644 --- a/eeschema/dialogs/dialog_junction_props.cpp +++ b/eeschema/dialogs/dialog_junction_props.cpp @@ -97,7 +97,7 @@ bool DIALOG_JUNCTION_PROPS::TransferDataFromWindow() for( SCH_JUNCTION* junction : m_junctions ) pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), junction, UNDO_REDO::CHANGED ) ); - m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false ); + m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); for( SCH_JUNCTION* junction : m_junctions ) { diff --git a/eeschema/dialogs/dialog_line_wire_bus_properties.cpp b/eeschema/dialogs/dialog_line_properties.cpp similarity index 72% rename from eeschema/dialogs/dialog_line_wire_bus_properties.cpp rename to eeschema/dialogs/dialog_line_properties.cpp index 4736e9cec5..97a9242712 100644 --- a/eeschema/dialogs/dialog_line_wire_bus_properties.cpp +++ b/eeschema/dialogs/dialog_line_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Seth Hillbrand - * Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2022 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 @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include #include @@ -31,11 +31,11 @@ #include -DIALOG_LINE_WIRE_BUS_PROPERTIES::DIALOG_LINE_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME* aParent, - std::deque& aItems ) : - DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE( aParent ), +DIALOG_LINE_PROPERTIES::DIALOG_LINE_PROPERTIES( SCH_EDIT_FRAME* aParent, + std::deque& aLines ) : + DIALOG_LINE_PROPERTIES_BASE( aParent ), m_frame( aParent ), - m_strokeItems( aItems ), + m_lines( aLines ), m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true ) { m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); @@ -57,12 +57,12 @@ DIALOG_LINE_WIRE_BUS_PROPERTIES::DIALOG_LINE_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME } -bool DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow() +bool DIALOG_LINE_PROPERTIES::TransferDataToWindow() { - SCH_ITEM* first_stroke_item = m_strokeItems.front(); + SCH_LINE* first_stroke_item = m_lines.front(); - if( std::all_of( m_strokeItems.begin() + 1, m_strokeItems.end(), - [&]( const SCH_ITEM* r ) + if( std::all_of( m_lines.begin() + 1, m_lines.end(), + [&]( const SCH_LINE* r ) { return r->GetPenWidth() == first_stroke_item->GetPenWidth(); } ) ) @@ -74,8 +74,8 @@ bool DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow() m_width.SetValue( INDETERMINATE_ACTION ); } - if( std::all_of( m_strokeItems.begin() + 1, m_strokeItems.end(), - [&]( const SCH_ITEM* r ) + if( std::all_of( m_lines.begin() + 1, m_lines.end(), + [&]( const SCH_LINE* r ) { return r->GetStroke().GetColor() == first_stroke_item->GetStroke().GetColor(); } ) ) @@ -87,8 +87,8 @@ bool DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow() m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); } - if( std::all_of( m_strokeItems.begin() + 1, m_strokeItems.end(), - [&]( const SCH_ITEM* r ) + if( std::all_of( m_lines.begin() + 1, m_lines.end(), + [&]( const SCH_LINE* r ) { return r->GetStroke().GetPlotStyle() == first_stroke_item->GetStroke().GetPlotStyle(); } ) ) @@ -112,7 +112,7 @@ bool DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow() } -void DIALOG_LINE_WIRE_BUS_PROPERTIES::resetDefaults( wxCommandEvent& event ) +void DIALOG_LINE_PROPERTIES::resetDefaults( wxCommandEvent& event ) { m_width.SetValue( 0 ); m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); @@ -123,35 +123,31 @@ void DIALOG_LINE_WIRE_BUS_PROPERTIES::resetDefaults( wxCommandEvent& event ) } -bool DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataFromWindow() +bool DIALOG_LINE_PROPERTIES::TransferDataFromWindow() { PICKED_ITEMS_LIST pickedItems; - STROKE_PARAMS stroke; - for( SCH_ITEM* strokeItem : m_strokeItems ) - pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), strokeItem, UNDO_REDO::CHANGED ) ); + for( SCH_LINE* line : m_lines ) + pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), line, UNDO_REDO::CHANGED ) ); - m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false ); + m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); - for( SCH_ITEM* strokeItem : m_strokeItems ) + for( SCH_LINE* line : m_lines ) { - stroke = strokeItem->GetStroke(); - if( !m_width.IsIndeterminate() ) - stroke.SetWidth( m_width.GetValue() ); + line->SetLineWidth( m_width.GetValue() ); auto it = lineTypeNames.begin(); std::advance( it, m_typeCombo->GetSelection() ); if( it == lineTypeNames.end() ) - stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); + line->SetLineStyle( PLOT_DASH_TYPE::DEFAULT ); else - stroke.SetPlotStyle( it->first ); + line->SetLineStyle( it->first ); - stroke.SetColor( m_colorSwatch->GetSwatchColor() ); + line->SetLineColor( m_colorSwatch->GetSwatchColor() ); - strokeItem->SetStroke( stroke ); - m_frame->UpdateItem( strokeItem, false, true ); + m_frame->UpdateItem( line, false, true ); } m_frame->GetCanvas()->Refresh(); diff --git a/eeschema/dialogs/dialog_line_wire_bus_properties.h b/eeschema/dialogs/dialog_line_properties.h similarity index 74% rename from eeschema/dialogs/dialog_line_wire_bus_properties.h rename to eeschema/dialogs/dialog_line_properties.h index 974750f904..35c26220f4 100644 --- a/eeschema/dialogs/dialog_line_wire_bus_properties.h +++ b/eeschema/dialogs/dialog_line_properties.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Seth Hillbrand - * Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2022 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 @@ -22,10 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef DIALOG_LINE_WIRE_BUS_PROPERTIES_H -#define DIALOG_LINE_WIRE_BUS_PROPERTIES_H +#ifndef DIALOG_LINE_PROPERTIES_H +#define DIALOG_LINE_PROPERTIES_H -#include +#include #include @@ -33,21 +33,21 @@ class SCH_EDIT_FRAME; class SCH_LINE; -class DIALOG_LINE_WIRE_BUS_PROPERTIES : public DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE +class DIALOG_LINE_PROPERTIES : public DIALOG_LINE_PROPERTIES_BASE { public: - DIALOG_LINE_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME* aParent, std::deque& aItems ); + DIALOG_LINE_PROPERTIES( SCH_EDIT_FRAME* aParent, std::deque& aLines ); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; private: SCH_EDIT_FRAME* m_frame; - std::deque m_strokeItems; + std::deque m_lines; UNIT_BINDER m_width; void resetDefaults( wxCommandEvent& event ) override; }; -#endif // DIALOG_LINE_WIRE_BUS_PROPERTIES_H +#endif // DIALOG_LINE_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_line_wire_bus_properties_base.cpp b/eeschema/dialogs/dialog_line_properties_base.cpp similarity index 87% rename from eeschema/dialogs/dialog_line_wire_bus_properties_base.cpp rename to eeschema/dialogs/dialog_line_properties_base.cpp index 3d4c5e54e5..e3a11762ac 100644 --- a/eeschema/dialogs/dialog_line_wire_bus_properties_base.cpp +++ b/eeschema/dialogs/dialog_line_properties_base.cpp @@ -7,15 +7,15 @@ #include "widgets/color_swatch.h" -#include "dialog_line_wire_bus_properties_base.h" +#include "dialog_line_properties_base.h" /////////////////////////////////////////////////////////////////////////// -BEGIN_EVENT_TABLE( DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE, DIALOG_SHIM ) - EVT_BUTTON( wxID_APPLY, DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE::_wxFB_resetDefaults ) +BEGIN_EVENT_TABLE( DIALOG_LINE_PROPERTIES_BASE, DIALOG_SHIM ) + EVT_BUTTON( wxID_APPLY, DIALOG_LINE_PROPERTIES_BASE::_wxFB_resetDefaults ) END_EVENT_TABLE() -DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE::DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_LINE_PROPERTIES_BASE::DIALOG_LINE_PROPERTIES_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 ); @@ -73,7 +73,7 @@ DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE::DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE( wxWi mainSizer->Add( fgSizerGeneral, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 10 ); - m_helpLabel1 = new wxStaticText( this, wxID_ANY, _("Set width to 0 to use Netclass line widths."), wxDefaultPosition, wxDefaultSize, 0 ); + m_helpLabel1 = new wxStaticText( this, wxID_ANY, _("Set width to 0 to use Schematic default line width."), wxDefaultPosition, wxDefaultSize, 0 ); m_helpLabel1->Wrap( 333 ); mainSizer->Add( m_helpLabel1, 0, wxRIGHT|wxLEFT, 10 ); @@ -103,6 +103,6 @@ DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE::DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE( wxWi this->Centre( wxBOTH ); } -DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE::~DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE() +DIALOG_LINE_PROPERTIES_BASE::~DIALOG_LINE_PROPERTIES_BASE() { } diff --git a/eeschema/dialogs/dialog_line_wire_bus_properties_base.fbp b/eeschema/dialogs/dialog_line_properties_base.fbp similarity index 99% rename from eeschema/dialogs/dialog_line_wire_bus_properties_base.fbp rename to eeschema/dialogs/dialog_line_properties_base.fbp index 2fbd0874ac..500c1329c6 100644 --- a/eeschema/dialogs/dialog_line_wire_bus_properties_base.fbp +++ b/eeschema/dialogs/dialog_line_properties_base.fbp @@ -11,12 +11,12 @@ res UTF-8 table - dialog_line_wire_bus_properties_base + dialog_line_properties_base 1000 none 1 - dialog_line_wire_bus_properties + dialog_line_properties . @@ -43,12 +43,12 @@ wxID_ANY - DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE + DIALOG_LINE_PROPERTIES_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Line, Wire & Bus Properties + Line Properties @@ -616,7 +616,7 @@ 0 0 wxID_ANY - Set width to 0 to use Netclass line widths. + Set width to 0 to use Schematic default line width. 0 0 diff --git a/eeschema/dialogs/dialog_line_wire_bus_properties_base.h b/eeschema/dialogs/dialog_line_properties_base.h similarity index 80% rename from eeschema/dialogs/dialog_line_wire_bus_properties_base.h rename to eeschema/dialogs/dialog_line_properties_base.h index c165401a92..c44b0fc785 100644 --- a/eeschema/dialogs/dialog_line_wire_bus_properties_base.h +++ b/eeschema/dialogs/dialog_line_properties_base.h @@ -30,9 +30,9 @@ class COLOR_SWATCH; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE +/// Class DIALOG_LINE_PROPERTIES_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE : public DIALOG_SHIM +class DIALOG_LINE_PROPERTIES_BASE : public DIALOG_SHIM { DECLARE_EVENT_TABLE() private: @@ -64,8 +64,8 @@ class DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE : public DIALOG_SHIM public: - DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Line, Wire & Bus Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_LINE_WIRE_BUS_PROPERTIES_BASE(); + DIALOG_LINE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Line Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_LINE_PROPERTIES_BASE(); }; diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index 9d32329c79..a28a59473d 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -90,7 +90,10 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() return false; if( !m_shape->IsNew() ) - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_shape, UNDO_REDO::CHANGED, false ); + { + m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_shape, UNDO_REDO::CHANGED, false, + false ); + } STROKE_PARAMS stroke = m_shape->GetStroke(); diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 3037257aaf..49e31f34c2 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -333,7 +333,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() if( m_currentItem->GetEditFlags() == 0 ) { m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_currentItem, UNDO_REDO::CHANGED, - false ); + false, false ); } m_frame->GetCanvas()->Refresh(); diff --git a/eeschema/dialogs/dialog_wire_bus_properties.cpp b/eeschema/dialogs/dialog_wire_bus_properties.cpp new file mode 100644 index 0000000000..71ec5bafa2 --- /dev/null +++ b/eeschema/dialogs/dialog_wire_bus_properties.cpp @@ -0,0 +1,225 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 Seth Hillbrand + * Copyright (C) 2014-2021 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 +#include +#include +#include +#include +#include +#include +#include +#include + + +DIALOG_WIRE_BUS_PROPERTIES::DIALOG_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME* aParent, + std::deque& aItems ) : + DIALOG_WIRE_BUS_PROPERTIES_BASE( aParent ), + m_frame( aParent ), + m_items( aItems ), + m_wireWidth( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits ), + m_junctionSize( aParent, m_dotSizeLabel, m_dotSizeCtrl, m_dotSizeUnits ) +{ + m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + + m_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() ); + m_helpLabel2->SetFont( KIUI::GetInfoFont( this ).Italic() ); + + SetInitialFocus( m_lineWidth ); + + for( const std::pair& typeEntry : lineTypeNames ) + m_typeCombo->Append( typeEntry.second.name, KiBitmap( typeEntry.second.bitmap ) ); + + m_typeCombo->Append( DEFAULT_STYLE ); + + SetupStandardButtons( { { wxID_APPLY, _( "Default" ) } } ); + + // Now all widgets have the size fixed, call FinishDialogSettings + finishDialogSettings(); +} + + +bool DIALOG_WIRE_BUS_PROPERTIES::TransferDataToWindow() +{ + STROKE_PARAMS stroke; + COLOR4D color; + int dotSize; + + for( SCH_ITEM* item : m_items ) + { + if( item->HasLineStroke() ) + { + stroke = item->GetStroke(); + color = stroke.GetColor(); + } + else + { + wxASSERT( item->Type() == SCH_JUNCTION_T ); + SCH_JUNCTION* junction = static_cast( item ); + color = junction->GetColor(); + dotSize = junction->GetDiameter(); + } + } + + if( std::all_of( m_items.begin(), m_items.end(), + [&]( const SCH_ITEM* item ) + { + return !item->HasLineStroke() || item->GetStroke().GetWidth() == stroke.GetWidth(); + } ) ) + { + m_wireWidth.SetValue( stroke.GetWidth() ); + } + else + { + m_wireWidth.SetValue( INDETERMINATE_ACTION ); + } + + if( std::all_of( m_items.begin(), m_items.end(), + [&]( const SCH_ITEM* item ) + { + if( item->HasLineStroke() ) + return item->GetStroke().GetColor() == color; + else + return static_cast( item )->GetColor() == color; + } ) ) + { + m_colorSwatch->SetSwatchColor( color, false ); + } + else + { + m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); + } + + if( std::all_of( m_items.begin(), m_items.end(), + [&]( const SCH_ITEM* item ) + { + return !item->HasLineStroke() + || item->GetStroke().GetPlotStyle() == stroke.GetPlotStyle(); + } ) ) + { + int style = static_cast( stroke.GetPlotStyle() ); + + if( style == -1 ) + m_typeCombo->SetStringSelection( DEFAULT_STYLE ); + else if( style < (int) lineTypeNames.size() ) + m_typeCombo->SetSelection( style ); + else + wxFAIL_MSG( "Line type not found in the type lookup map" ); + } + else + { + m_typeCombo->Append( INDETERMINATE_STYLE ); + m_typeCombo->SetStringSelection( INDETERMINATE_STYLE ); + } + + if( std::all_of( m_items.begin(), m_items.end(), + [&]( const SCH_ITEM* item ) + { + return item->Type() != SCH_JUNCTION_T + || static_cast( item )->GetDiameter() == dotSize; + } ) ) + { + m_junctionSize.SetValue( dotSize ); + } + else + { + m_junctionSize.SetValue( INDETERMINATE_ACTION ); + } + + return true; +} + + +void DIALOG_WIRE_BUS_PROPERTIES::resetDefaults( wxCommandEvent& event ) +{ + m_wireWidth.SetValue( 0 ); + m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false ); + m_typeCombo->SetStringSelection( DEFAULT_STYLE ); + m_junctionSize.SetValue( 0 ); + + Refresh(); +} + + +bool DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow() +{ + PICKED_ITEMS_LIST pickedItems; + + for( SCH_ITEM* strokeItem : m_items ) + pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), strokeItem, UNDO_REDO::CHANGED ) ); + + m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); + + for( SCH_ITEM* item : m_items ) + { + if( item->HasLineStroke() ) + { + if( !m_wireWidth.IsIndeterminate() ) + { + int width = m_wireWidth.GetValue(); + + if( item->Type() == SCH_LINE_T ) + static_cast( item )->SetLineWidth( width ); + else if( dynamic_cast( item ) ) + static_cast( item )->SetPenWidth( width ); + } + + PLOT_DASH_TYPE lineStyle = PLOT_DASH_TYPE::DEFAULT; + + auto it = lineTypeNames.begin(); + std::advance( it, m_typeCombo->GetSelection() ); + + if( it != lineTypeNames.end() ) + lineStyle = it->first; + + if( item->Type() == SCH_LINE_T ) + static_cast( item )->SetLineStyle( lineStyle ); + else if( dynamic_cast( item ) ) + static_cast( item )->SetLineStyle( lineStyle ); + + COLOR4D color = m_colorSwatch->GetSwatchColor(); + + if( item->Type() == SCH_LINE_T ) + static_cast( item )->SetLineColor( color ); + else if( dynamic_cast( item ) ) + static_cast( item )->SetBusEntryColor( color ); + } + else + { + SCH_JUNCTION* junction = static_cast( item ); + + junction->SetColor( m_colorSwatch->GetSwatchColor() ); + + if( !m_junctionSize.IsIndeterminate() ) + junction->SetDiameter( m_junctionSize.GetValue() ); + } + + m_frame->UpdateItem( item, false, true ); + } + + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify(); + + return true; +} diff --git a/eeschema/dialogs/dialog_wire_bus_properties.h b/eeschema/dialogs/dialog_wire_bus_properties.h new file mode 100644 index 0000000000..6455014de8 --- /dev/null +++ b/eeschema/dialogs/dialog_wire_bus_properties.h @@ -0,0 +1,54 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 Seth Hillbrand + * Copyright (C) 2014-2022 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 DIALOG_WIRE_BUS_PROPERTIES_H +#define DIALOG_WIRE_BUS_PROPERTIES_H + +#include +#include + + +class SCH_EDIT_FRAME; +class SCH_LINE; + + +class DIALOG_WIRE_BUS_PROPERTIES : public DIALOG_WIRE_BUS_PROPERTIES_BASE +{ +public: + DIALOG_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME* aParent, std::deque& aItems ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + +private: + SCH_EDIT_FRAME* m_frame; + std::deque m_items; + + UNIT_BINDER m_wireWidth; + UNIT_BINDER m_junctionSize; + + void resetDefaults( wxCommandEvent& event ) override; +}; + +#endif // DIALOG_WIRE_BUS_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_wire_bus_properties_base.cpp b/eeschema/dialogs/dialog_wire_bus_properties_base.cpp new file mode 100644 index 0000000000..f538556577 --- /dev/null +++ b/eeschema/dialogs/dialog_wire_bus_properties_base.cpp @@ -0,0 +1,122 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/color_swatch.h" + +#include "dialog_wire_bus_properties_base.h" + +/////////////////////////////////////////////////////////////////////////// + +BEGIN_EVENT_TABLE( DIALOG_WIRE_BUS_PROPERTIES_BASE, DIALOG_SHIM ) + EVT_BUTTON( wxID_APPLY, DIALOG_WIRE_BUS_PROPERTIES_BASE::_wxFB_resetDefaults ) +END_EVENT_TABLE() + +DIALOG_WIRE_BUS_PROPERTIES_BASE::DIALOG_WIRE_BUS_PROPERTIES_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* mainSizer; + mainSizer = new wxBoxSizer( wxVERTICAL ); + + wxFlexGridSizer* fgSizerGeneral; + fgSizerGeneral = new wxFlexGridSizer( 0, 3, 0, 0 ); + fgSizerGeneral->AddGrowableCol( 1 ); + fgSizerGeneral->SetFlexibleDirection( wxBOTH ); + fgSizerGeneral->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Wire/bus width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextWidth->Wrap( -1 ); + fgSizerGeneral->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 3 ); + + m_lineWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + fgSizerGeneral->Add( m_lineWidth, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 3 ); + + m_staticWidthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticWidthUnits->Wrap( -1 ); + m_staticWidthUnits->SetMinSize( wxSize( 40,-1 ) ); + + fgSizerGeneral->Add( m_staticWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 3 ); + + m_staticTextColor = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextColor->Wrap( -1 ); + fgSizerGeneral->Add( m_staticTextColor, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + m_panel1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxVERTICAL ); + + m_colorSwatch = new COLOR_SWATCH( m_panel1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_colorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panel1->SetSizer( bSizer2 ); + m_panel1->Layout(); + bSizer2->Fit( m_panel1 ); + fgSizerGeneral->Add( m_panel1, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 2 ); + + + fgSizerGeneral->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_staticTextStyle = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextStyle->Wrap( -1 ); + fgSizerGeneral->Add( m_staticTextStyle, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + m_typeCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); + m_typeCombo->SetMinSize( wxSize( 240,-1 ) ); + + fgSizerGeneral->Add( m_typeCombo, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 3 ); + + + fgSizerGeneral->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_dotSizeLabel = new wxStaticText( this, wxID_ANY, _("Junction size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dotSizeLabel->Wrap( -1 ); + fgSizerGeneral->Add( m_dotSizeLabel, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_dotSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerGeneral->Add( m_dotSizeCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_dotSizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dotSizeUnits->Wrap( -1 ); + fgSizerGeneral->Add( m_dotSizeUnits, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 3 ); + + + mainSizer->Add( fgSizerGeneral, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 10 ); + + m_helpLabel1 = new wxStaticText( this, wxID_ANY, _("Set width to 0 to use Netclass wire/bus widths."), wxDefaultPosition, wxDefaultSize, 0 ); + m_helpLabel1->Wrap( 333 ); + mainSizer->Add( m_helpLabel1, 0, wxRIGHT|wxLEFT, 10 ); + + m_helpLabel2 = new wxStaticText( this, wxID_ANY, _("Set color to transparent to use Schematic Editor colors."), wxDefaultPosition, wxDefaultSize, 0 ); + m_helpLabel2->Wrap( -1 ); + mainSizer->Add( m_helpLabel2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + mainSizer->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerApply = new wxButton( this, wxID_APPLY ); + m_sdbSizer->AddButton( m_sdbSizerApply ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + mainSizer->Add( m_sdbSizer, 0, wxALL|wxALIGN_RIGHT, 5 ); + + + this->SetSizer( mainSizer ); + this->Layout(); + mainSizer->Fit( this ); + + this->Centre( wxBOTH ); +} + +DIALOG_WIRE_BUS_PROPERTIES_BASE::~DIALOG_WIRE_BUS_PROPERTIES_BASE() +{ +} diff --git a/eeschema/dialogs/dialog_wire_bus_properties_base.fbp b/eeschema/dialogs/dialog_wire_bus_properties_base.fbp new file mode 100644 index 0000000000..7817308db8 --- /dev/null +++ b/eeschema/dialogs/dialog_wire_bus_properties_base.fbp @@ -0,0 +1,985 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + table + dialog_wire_bus_properties_base + 1000 + none + + 1 + dialog_wire_bus_properties + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_WIRE_BUS_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Wire & Bus Properties + + + + + + + mainSizer + wxVERTICAL + none + + 10 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 1 + + 3 + wxBOTH + 1 + + 0 + + fgSizerGeneral + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 3 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Wire/bus width: + 0 + + 0 + + + 0 + + 1 + m_staticTextWidth + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + -1,-1 + 0 + -1,-1 + 1 + m_lineWidth + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + 40,-1 + 1 + m_staticWidthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Color: + 0 + + 0 + + + 0 + + 1 + m_staticTextColor + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; Not forward_declare + 0 + + + + + -1 + + + + 2 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panel1 + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer2 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_colorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Style: + 0 + + 0 + + + 0 + + 1 + m_staticTextStyle + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 240,-1 + 1 + m_typeCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + Combo! + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Junction size: + 0 + + 0 + + + 0 + + 1 + m_dotSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_dotSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 3 + wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_dotSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 10 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Set width to 0 to use Netclass wire/bus widths. + 0 + + 0 + + + 0 + + 1 + m_helpLabel1 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + 333 + + + + 10 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Set color to transparent to use Schematic Editor colors. + 0 + + 0 + + + 0 + + 1 + m_helpLabel2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + 5 + wxALL|wxALIGN_RIGHT + 0 + + 1 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + resetDefaults + + + + + + diff --git a/eeschema/dialogs/dialog_wire_bus_properties_base.h b/eeschema/dialogs/dialog_wire_bus_properties_base.h new file mode 100644 index 0000000000..27fc5625eb --- /dev/null +++ b/eeschema/dialogs/dialog_wire_bus_properties_base.h @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class COLOR_SWATCH; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_WIRE_BUS_PROPERTIES_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_WIRE_BUS_PROPERTIES_BASE : public DIALOG_SHIM +{ + DECLARE_EVENT_TABLE() + private: + + // Private event handlers + void _wxFB_resetDefaults( wxCommandEvent& event ){ resetDefaults( event ); } + + + protected: + wxStaticText* m_staticTextWidth; + wxTextCtrl* m_lineWidth; + wxStaticText* m_staticWidthUnits; + wxStaticText* m_staticTextColor; + wxPanel* m_panel1; + COLOR_SWATCH* m_colorSwatch; + wxStaticText* m_staticTextStyle; + wxBitmapComboBox* m_typeCombo; + wxStaticText* m_dotSizeLabel; + wxTextCtrl* m_dotSizeCtrl; + wxStaticText* m_dotSizeUnits; + wxStaticText* m_helpLabel1; + wxStaticText* m_helpLabel2; + wxStaticLine* m_staticline; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerApply; + wxButton* m_sdbSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void resetDefaults( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_WIRE_BUS_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Wire & Bus Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_WIRE_BUS_PROPERTIES_BASE(); + +}; + diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index f37e7d3cb2..ffdd2a94ae 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -191,6 +191,20 @@ COLOR4D SCH_BUS_ENTRY_BASE::GetBusEntryColor() const } +void SCH_BUS_ENTRY_BASE::SetPenWidth( int aWidth ) +{ + m_stroke.SetWidth( aWidth ); + m_lastResolvedWidth = aWidth; +} + + +void SCH_BUS_ENTRY_BASE::SetBusEntryColor( const COLOR4D& aColor ) +{ + m_stroke.SetColor( aColor ); + m_lastResolvedColor = aColor; +} + + PLOT_DASH_TYPE SCH_BUS_ENTRY_BASE::GetLineStyle() const { if( m_stroke.GetPlotStyle() != PLOT_DASH_TYPE::DEFAULT ) @@ -209,6 +223,13 @@ PLOT_DASH_TYPE SCH_BUS_ENTRY_BASE::GetLineStyle() const } +void SCH_BUS_ENTRY_BASE::SetLineStyle( PLOT_DASH_TYPE aStyle ) +{ + m_stroke.SetPlotStyle( aStyle ); + m_lastResolvedLineStyle = aStyle; +} + + int SCH_BUS_WIRE_ENTRY::GetPenWidth() const { if( m_stroke.GetWidth() > 0 ) diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index a0d1c83575..215036526a 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -71,15 +71,17 @@ public: wxSize GetSize() const { return m_size; } void SetSize( const wxSize& aSize ) { m_size = aSize; } - void SetPenWidth( int aWidth ) { m_stroke.SetWidth( aWidth ); } + void SetPenWidth( int aWidth ); virtual bool HasLineStroke() const override { return true; } virtual STROKE_PARAMS GetStroke() const override { return m_stroke; } virtual void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; } PLOT_DASH_TYPE GetLineStyle() const; + void SetLineStyle( PLOT_DASH_TYPE aStyle ); COLOR4D GetBusEntryColor() const; + void SetBusEntryColor( const COLOR4D& aColor ); void SwapData( SCH_ITEM* aItem ) override; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 3ff744642f..d5c09223d9 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -687,9 +687,10 @@ public: * @param aItemToCopy is the schematic item modified by the command to undo. * @param aTypeCommand is the command type (see enum UNDO_REDO). * @param aAppend set to true to add the item to the previous undo list. + * @param aDirtyConnectivity set to true if the change can affect connectivity. */ void SaveCopyInUndoList( SCH_SCREEN* aScreen, SCH_ITEM* aItemToCopy, UNDO_REDO aTypeCommand, - bool aAppend ); + bool aAppend, bool aDirtyConnectivity = true ); /** * Create a new entry in undo list of commands. @@ -697,9 +698,10 @@ public: * @param aItemsList is the list of items modified by the command to undo/ * @param aTypeCommand is the command type (see enum UNDO_REDO). * @param aAppend set to true to add the item to the previous undo list. + * @param aDirtyConnectivity set to true if the change can affect connectivity. */ void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand, - bool aAppend ); + bool aAppend, bool aDirtyConnectivity = true ); /** * Restore an undo or redo command to put data pointed by \a aList in the previous state. diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index e0acd8e40e..8547e32043 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -173,6 +173,13 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) const #endif +void SCH_JUNCTION::SetDiameter( int aDiameter ) +{ + m_diameter = aDiameter; + m_lastResolvedDiameter = aDiameter; +} + + COLOR4D SCH_JUNCTION::GetJunctionColor() const { if( m_color != COLOR4D::UNSPECIFIED ) @@ -191,6 +198,13 @@ COLOR4D SCH_JUNCTION::GetJunctionColor() const } +void SCH_JUNCTION::SetColor( const COLOR4D& aColor ) +{ + m_color = aColor; + m_lastResolvedColor = aColor; +} + + int SCH_JUNCTION::GetEffectiveDiameter() const { return getEffectiveShape().GetRadius() * 2; diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 8974595eb5..de1022cd2a 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -107,12 +107,12 @@ public: int GetEffectiveDiameter() const; int GetDiameter() const { return m_diameter; } - void SetDiameter( int aDiameter ) { m_diameter = aDiameter; } + void SetDiameter( int aDiameter ); COLOR4D GetJunctionColor() const; COLOR4D GetColor() const { return m_color; } - void SetColor( const COLOR4D& aColor ) { m_color = aColor; } + void SetColor( const COLOR4D& aColor ); bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 2eab7941f8..c66cbaf480 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -215,6 +215,7 @@ double SCH_LINE::GetLength() const void SCH_LINE::SetLineColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); + m_lastResolvedColor = GetLineColor(); } @@ -281,6 +282,8 @@ void SCH_LINE::SetLineStyle( const PLOT_DASH_TYPE aStyle ) m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); else m_stroke.SetPlotStyle( aStyle ); + + m_lastResolvedLineStyle = GetLineStyle(); } @@ -321,6 +324,7 @@ PLOT_DASH_TYPE SCH_LINE::GetEffectiveLineStyle() const void SCH_LINE::SetLineWidth( const int aSize ) { m_stroke.SetWidth( aSize ); + m_lastResolvedWidth = GetPenWidth(); } diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index faf4d204c8..a02bb7eb16 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -103,17 +103,16 @@ void SCH_EDIT_FRAME::StartNewUndo() } -void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen, - SCH_ITEM* aItem, - UNDO_REDO aCommandType, - bool aAppend ) +void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen, SCH_ITEM* aItem, + UNDO_REDO aCommandType, bool aAppend, + bool aDirtyConnectivity ) { PICKED_ITEMS_LIST* commandToUndo = nullptr; wxCHECK( aItem, /* void */ ); - // Connectivity may change - aItem->SetConnectivityDirty(); + if( aDirtyConnectivity ) + aItem->SetConnectivityDirty(); PICKED_ITEMS_LIST* lastUndo = PopCommandFromUndoList(); @@ -168,8 +167,8 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen, void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, - UNDO_REDO aTypeCommand, - bool aAppend ) + UNDO_REDO aTypeCommand, bool aAppend, + bool aDirtyConnectivity ) { PICKED_ITEMS_LIST* commandToUndo = nullptr; @@ -209,8 +208,8 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, if( !sch_item ) continue; - // Connectivity may change - sch_item->SetConnectivityDirty(); + if( aDirtyConnectivity ) + sch_item->SetConnectivityDirty(); UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii ); diff --git a/eeschema/tools/ee_selection.cpp b/eeschema/tools/ee_selection.cpp index dad9f22739..d22ad7b2d8 100644 --- a/eeschema/tools/ee_selection.cpp +++ b/eeschema/tools/ee_selection.cpp @@ -124,17 +124,3 @@ void EE_SELECTION::GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, aSelectionPath.AppendMultiUnitSymbol( aRefList, symbol, aIncludePowerSymbols ); } } - - -bool EE_SELECTION::AllItemsHaveLineStroke() const -{ - for( const EDA_ITEM* item : m_items ) - { - const SCH_ITEM* schItem = dynamic_cast( item ); - - if( !schItem || !schItem->HasLineStroke() ) - return false; - } - - return true; -} diff --git a/eeschema/tools/ee_selection.h b/eeschema/tools/ee_selection.h index ca4b86b2b3..f1d081342f 100644 --- a/eeschema/tools/ee_selection.h +++ b/eeschema/tools/ee_selection.h @@ -76,13 +76,6 @@ public: void GetMultiUnitSymbols( SCH_MULTI_UNIT_REFERENCE_MAP& aRefList, const SCH_SHEET_PATH& aSelectionPath, bool aIncludePowerSymbols = true ); - - /** - * Checks if all items in the selection support line strokes - * - * @return True if all items support line strokes - */ - bool AllItemsHaveLineStroke() const; }; #endif // EE_SELECTION_H diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index 6be5eb3178..a5e9518ff6 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -131,7 +131,8 @@ protected: ///< Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their ///< parents. - void saveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aType, bool aAppend = false ) + void saveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aType, bool aAppend = false, + bool aDirtyConnectivity = true ) { KICAD_T itemType = aItem->Type(); bool selected = aItem->IsSelected(); @@ -157,13 +158,13 @@ protected: { editFrame->SaveCopyInUndoList( editFrame->GetScreen(), static_cast( aItem->GetParent() ), - UNDO_REDO::CHANGED, aAppend ); + UNDO_REDO::CHANGED, aAppend, aDirtyConnectivity ); } else { editFrame->SaveCopyInUndoList( editFrame->GetScreen(), - static_cast( aItem ), - aType, aAppend ); + static_cast( aItem ), aType, aAppend, + aDirtyConnectivity ); } } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index e5b8d9b0b0..a23eda248f 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include @@ -814,7 +814,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) std::deque strokeItems; strokeItems.push_back( previewItem ); - DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems ); + DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems ); if( dlg.ShowModal() == wxID_OK ) { diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 4b51c8f20a..a294d52c28 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -56,7 +56,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -263,10 +264,37 @@ bool SCH_EDIT_TOOL::Init() case SCH_LINE_T: case SCH_BUS_WIRE_ENTRY_T: - return eeSelection->AllItemsHaveLineStroke(); - case SCH_JUNCTION_T: - return eeSelection->AreAllItemsIdentical(); + if( std::all_of( aSel.Items().begin(), aSel.Items().end(), + [&]( const EDA_ITEM* item ) + { + return item->Type() == SCH_LINE_T + && static_cast( item )->IsGraphicLine(); + } ) ) + { + return true; + } + else if( std::all_of( aSel.Items().begin(), aSel.Items().end(), + [&]( const EDA_ITEM* item ) + { + return item->Type() == SCH_JUNCTION_T; + } ) ) + { + return true; + } + else if( std::all_of( aSel.Items().begin(), aSel.Items().end(), + [&]( const EDA_ITEM* item ) + { + const SCH_ITEM* schItem = dynamic_cast( item ); + + return ( schItem->HasLineStroke() && schItem->IsConnectable() ) + || item->Type() == SCH_JUNCTION_T; + } ) ) + { + return true; + } + + return false; default: return false; @@ -1259,7 +1287,7 @@ int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent ) SCH_ITEM* sch_item = static_cast( selection.GetItem( ii ) ); if( !moving && !sch_item->IsNew() ) - saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED, ii > 0 ); + saveCopyInUndoList( sch_item, UNDO_REDO::CHANGED, ii > 0, false ); if( sch_item->IsType( EE_COLLECTOR::FieldOwners ) ) sch_item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true ); @@ -1370,15 +1398,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) { case SCH_LINE_T: case SCH_BUS_WIRE_ENTRY_T: - if( !selection.AllItemsHaveLineStroke() ) - return 0; - - break; - case SCH_JUNCTION_T: - if( !selection.AreAllItemsIdentical() ) - return 0; - break; default: @@ -1556,7 +1576,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) { // save old image in undo list if not already in edit if( bitmap->GetEditFlags() == 0 ) - saveCopyInUndoList( bitmap, UNDO_REDO::CHANGED ); + saveCopyInUndoList( bitmap, UNDO_REDO::CHANGED, false, false ); dlg.TransferToImage( bitmap->GetImage() ); @@ -1570,50 +1590,73 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) case SCH_LINE_T: case SCH_BUS_WIRE_ENTRY_T: - { - std::deque strokeItems; - - for( EDA_ITEM* selItem : selection.Items() ) - { - SCH_ITEM* schItem = dynamic_cast( selItem ); - - if( schItem && schItem->HasLineStroke() ) - strokeItems.push_back( schItem ); - else - return 0; - } - - DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems ); - - if( dlg.ShowModal() == wxID_OK ) - { - m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); - m_frame->OnModify(); - } - } - break; - case SCH_JUNCTION_T: - { - std::deque junctions; - - for( EDA_ITEM* selItem : selection.Items() ) + if( std::all_of( selection.Items().begin(), selection.Items().end(), + [&]( const EDA_ITEM* item ) + { + return item->Type() == SCH_LINE_T + && static_cast( item )->IsGraphicLine(); + } ) ) { - SCH_JUNCTION* junction = dynamic_cast( selItem ); + std::deque lines; - wxCHECK( junction, 0 ); + for( EDA_ITEM* selItem : selection.Items() ) + lines.push_back( static_cast( selItem ) ); - junctions.push_back( junction ); + DIALOG_LINE_PROPERTIES dlg( m_frame, lines ); + + if( dlg.ShowModal() == wxID_OK ) + { + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); + m_frame->OnModify(); + } + } + else if( std::all_of( selection.Items().begin(), selection.Items().end(), + [&]( const EDA_ITEM* item ) + { + return item->Type() == SCH_JUNCTION_T; + } ) ) + { + std::deque junctions; + + for( EDA_ITEM* selItem : selection.Items() ) + junctions.push_back( static_cast( selItem ) ); + + DIALOG_JUNCTION_PROPS dlg( m_frame, junctions ); + + if( dlg.ShowModal() == wxID_OK ) + { + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); + m_frame->OnModify(); + } + } + else if( std::all_of( selection.Items().begin(), selection.Items().end(), + [&]( const EDA_ITEM* item ) + { + const SCH_ITEM* schItem = dynamic_cast( item ); + + return ( schItem->HasLineStroke() && schItem->IsConnectable() ) + || item->Type() == SCH_JUNCTION_T; + } ) ) + { + std::deque items; + + for( EDA_ITEM* selItem : selection.Items() ) + items.push_back( static_cast( selItem ) ); + + DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, items ); + + if( dlg.ShowModal() == wxID_OK ) + { + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); + m_frame->OnModify(); + } + } + else + { + return 0; } - DIALOG_JUNCTION_PROPS dlg( m_frame, junctions ); - - if( dlg.ShowModal() == wxID_OK ) - { - m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); - m_frame->OnModify(); - } - } break; case SCH_MARKER_T: // These items have no properties to edit diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 8d922fb689..cfe40685eb 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -127,7 +127,7 @@ int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS ); undoCmd.PushItem( wrapper ); - m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false ); + m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false, false ); DIALOG_EESCHEMA_PAGE_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_MILS, MAX_PAGE_SIZE_MILS ) ); dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName ); diff --git a/include/tool/selection.h b/include/tool/selection.h index ac8236fcd4..f040bfb200 100644 --- a/include/tool/selection.h +++ b/include/tool/selection.h @@ -190,6 +190,11 @@ public: return m_items; } + const std::deque& Items() const + { + return m_items; + } + template T* FirstOfKind() const {