From d4e41c4f97ee33def3bf06765453241da867ebae Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 8 May 2017 12:41:46 +0200 Subject: [PATCH] Component table improvements --- eeschema/bom_table_column.h | 9 +- eeschema/bom_table_model.cpp | 100 +- eeschema/bom_table_model.h | 18 +- eeschema/dialogs/dialog_bom_editor.cpp | 207 ++- eeschema/dialogs/dialog_bom_editor.h | 17 +- eeschema/dialogs/dialog_bom_editor_base.cpp | 114 +- eeschema/dialogs/dialog_bom_editor_base.fbp | 1513 ++++++++++--------- eeschema/dialogs/dialog_bom_editor_base.h | 42 +- 8 files changed, 1171 insertions(+), 849 deletions(-) diff --git a/eeschema/bom_table_column.h b/eeschema/bom_table_column.h index 3e297566e3..bf82927699 100644 --- a/eeschema/bom_table_column.h +++ b/eeschema/bom_table_column.h @@ -88,13 +88,16 @@ protected: bool m_Show; ///< Is this column visible? bool m_ReadOnly; ///< Is this column read only? + bool m_sort; ///< Is this column used for sorting? + public: - BOM_COLUMN( unsigned int aId, BOM_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false ) : + BOM_COLUMN( unsigned int aId, BOM_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false, bool aSort = true ) : m_id( aId ), m_Type( aType ), m_Title( aTitle.Strip( wxString::both ) ), m_Show( aShow ), - m_ReadOnly( aReadOnly ) + m_ReadOnly( aReadOnly ), + m_sort( aSort ) { } @@ -103,11 +106,13 @@ public: wxString Title() const { return m_Title; } bool IsVisible() const { return m_Show; } bool IsReadOnly() const { return m_ReadOnly; } + bool IsUsedToSort() const { return m_sort; } //TODO - Should renaming of columns be allowed? //bool SetTitle( const wxString aTitle ); void SetVisible( bool aShow = true ) { m_Show = aShow; } void SetReadOnly( bool aReadOnly = true ) { m_ReadOnly = aReadOnly; } + void SetUsedToSort( bool aSort = true ) { m_sort = aSort; } }; diff --git a/eeschema/bom_table_model.cpp b/eeschema/bom_table_model.cpp index f22022a632..a9a247bfb1 100644 --- a/eeschema/bom_table_model.cpp +++ b/eeschema/bom_table_model.cpp @@ -53,7 +53,9 @@ static BOM_TABLE_ROW const* ItemToRow( wxDataViewItem aItem ) } } -BOM_FIELD_VALUES::BOM_FIELD_VALUES( wxString aRefDes ) : m_refDes( aRefDes ) +BOM_FIELD_VALUES::BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate ) : + m_refDes( aRefDes ), + m_templateValues( aTemplate ) { } @@ -87,6 +89,24 @@ bool BOM_FIELD_VALUES::GetBackupValue( unsigned int aFieldId, wxString& aValue ) return true; } +/** + * Return the template value for a provided field ID (if it exists) + */ +bool BOM_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const +{ + if( !m_templateValues ) + return false; + + auto search = m_templateValues->find( aFieldId ); + + if( search == m_templateValues->end() ) + return false; + + aValue = search->second; + + return true; +} + /** * Set the value for the provided field ID * Field value is set under any of the following conditions: @@ -102,18 +122,6 @@ void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, wxString aValue, bo } } -/** - * Set the backup value for the provided field ID - * If the backup value is already set, new value is ignored - */ -void BOM_FIELD_VALUES::SetBackupValue( unsigned int aFieldId, wxString aValue ) -{ - if( m_backupValues.count( aFieldId ) == 0 || m_backupValues[aFieldId].IsEmpty() ) - { - m_backupValues[aFieldId] = aValue; - } -} - bool BOM_FIELD_VALUES::HasValueChanged( unsigned int aFieldId) const { wxString currentValue, backupValue; @@ -133,6 +141,14 @@ void BOM_FIELD_VALUES::RevertChanges( unsigned int aFieldId ) SetFieldValue( aFieldId, backupValue, true ); } +void BOM_FIELD_VALUES::SetBackupPoint() +{ + for( auto it = m_currentValues.begin(); it != m_currentValues.end(); ++it ) + { + m_backupValues[it->first] = it->second; + } +} + BOM_TABLE_ROW::BOM_TABLE_ROW() : m_columnList( nullptr ) { } @@ -317,6 +333,10 @@ bool BOM_TABLE_GROUP::AddComponent( BOM_TABLE_COMPONENT* aComponent ) for( auto* column : m_columnList->Columns ) { + // Ignore any columns marked as "not used for sorting" + if( !column->IsUsedToSort() ) + continue; + match = TestField( column, aComponent ); // Escape on first mismatch @@ -554,7 +574,6 @@ bool BOM_TABLE_COMPONENT::AddUnit( SCH_REFERENCE aUnit ) } m_fieldValues->SetFieldValue( column->Id(), value ); - m_fieldValues->SetBackupValue( column->Id(), value ); } return true; @@ -563,6 +582,7 @@ bool BOM_TABLE_COMPONENT::AddUnit( SCH_REFERENCE aUnit ) return false; } + /** * Return the value associated with a particular field * If no field is found, return an empty string @@ -582,8 +602,15 @@ wxString BOM_TABLE_COMPONENT::GetFieldValue( unsigned int aFieldId ) const } if( m_fieldValues ) + { m_fieldValues->GetFieldValue( aFieldId, value ); + if( value.IsEmpty() ) + { + m_fieldValues->GetTemplateValue( aFieldId, value ); + } + } + return value; } @@ -966,9 +993,9 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) continue; ColumnList.AddColumn( new BOM_COLUMN( ColumnList.NextFieldId(), - BOM_COL_TYPE_USER, - field->GetName(), - true, false ) ); + BOM_COL_TYPE_USER, + field->GetName(), + true, false ) ); } } @@ -976,8 +1003,9 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) * Add a list of component items to the BOM manager * Creates consolidated groups of components as required */ -void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs ) +void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields ) { + // Add default columns AddDefaultColumns(); @@ -993,10 +1021,33 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs ) } } + // Add template fields if they are not already added + for( auto field : aTemplateFields ) + { + BOM_COLUMN* col; + + col = ColumnList.GetColumnByTitle( field.m_Name ); + + if( !col ) + { + col = new BOM_COLUMN( ColumnList.NextFieldId(), + BOM_COL_TYPE_USER, + field.m_Name, + true, false ); + + ColumnList.AddColumn( col ); + } + + // Add template value for that field + m_fieldTemplates[col->Id()] = field.m_Value; + } + // Group multi-unit components together m_components.clear(); m_fieldValues.clear(); + + // Iterate through each unique component for( unsigned int ii=0; ii( values ) ); } @@ -1043,6 +1094,17 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs ) m_components.push_back( std::unique_ptr( newComponent ) ); } } + + SetBackupPoint(); +} + +void BOM_TABLE_MODEL::SetBackupPoint() +{ + // Mark backup locations for all values + for( auto& vals : m_fieldValues ) + { + vals->SetBackupPoint(); + } } /** diff --git a/eeschema/bom_table_model.h b/eeschema/bom_table_model.h index 933db5c880..e011b1eb8f 100644 --- a/eeschema/bom_table_model.h +++ b/eeschema/bom_table_model.h @@ -58,13 +58,13 @@ typedef std::map FIELD_VALUE_MAP; class BOM_FIELD_VALUES { public: - BOM_FIELD_VALUES(wxString aRefDes); + BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate ); bool GetFieldValue( unsigned int aFieldId, wxString& aValue ) const; bool GetBackupValue( unsigned int aFieldId, wxString& aValue ) const; + bool GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const; void SetFieldValue( unsigned int aFieldId, wxString aValue, bool aOverwrite = false ); - void SetBackupValue( unsigned int aFieldId, wxString aValue ); wxString GetReference() const { return m_refDes; } @@ -72,6 +72,8 @@ public: void RevertChanges( unsigned int aFieldId ); + void SetBackupPoint(); + protected: //! The RefDes to which these values correspond wxString m_refDes; @@ -81,6 +83,9 @@ protected: //! Backup values for each column FIELD_VALUE_MAP m_backupValues; + + //! Template values for each column + FIELD_VALUE_MAP* m_templateValues; }; /** @@ -140,7 +145,7 @@ public: BOM_TABLE_GROUP( BOM_COLUMN_LIST* aColumnList ); virtual ~BOM_TABLE_GROUP() {} - // Set display properties for + // Set display properties for a group row virtual bool GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const override; // Get group row value @@ -231,6 +236,9 @@ protected: // Vector of field values mapped to field IDs std::vector> m_fieldValues; + // Template field values + FIELD_VALUE_MAP m_fieldTemplates; + // BOM Preferences //! Group components based on values bool m_groupColumns = true; @@ -307,7 +315,7 @@ public: wxArrayString GetRowData( unsigned int aRow, std::vector aColumns ) const; - void SetComponents( SCH_REFERENCE_LIST aRefs ); + void SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields ); void AddComponentFields( SCH_COMPONENT* aCmp ); void RevertFieldChanges(); @@ -315,6 +323,8 @@ public: bool HaveFieldsChanged() const; + void SetBackupPoint(); + std::vector GetChangedComponents(); unsigned int CountChangedComponents(); }; diff --git a/eeschema/dialogs/dialog_bom_editor.cpp b/eeschema/dialogs/dialog_bom_editor.cpp index 1924cd24d9..e5114e5339 100644 --- a/eeschema/dialogs/dialog_bom_editor.cpp +++ b/eeschema/dialogs/dialog_bom_editor.cpp @@ -63,6 +63,12 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) : wxDATAVIEW_CELL_ACTIVATABLE, 100 ); + auto sortColumn = m_columnListCtrl->AppendToggleColumn( + _( "Sort" ), + wxDATAVIEW_CELL_ACTIVATABLE, + 100 ); + + // Resize the columns appropriately m_columnListCtrl->Update(); @@ -75,6 +81,11 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) : nameColumn->SetWidth( wxCOL_WIDTH_AUTOSIZE ); nameColumn->SetResizeable( true ); + sortColumn->SetWidth( wxCOL_WIDTH_AUTOSIZE ); + sortColumn->SetResizeable( true ); + + m_columnListCtrl->Update(); + // Read all components LoadComponents(); @@ -109,6 +120,44 @@ DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR() //TODO } +void DIALOG_BOM_EDITOR::OnCloseButton( wxCommandEvent& event ) +{ + CloseDialog(); +} + +bool DIALOG_BOM_EDITOR::CloseDialog() +{ + if( !m_bom->HaveFieldsChanged() ) + { + Destroy(); + return true; + } + + int result = DisplayExitDialog( this, _( "Changes exist in component table" ) ); + + switch( result ) + { + case wxID_CANCEL: + return false; + case wxID_NO: + break; + case wxID_YES: + ApplyAllChanges(); + break; + } + + Destroy(); + return true; +} + +void DIALOG_BOM_EDITOR::OnDialogClosed( wxCloseEvent& event ) +{ + if( !CloseDialog() ) + { + event.Veto(); + } +} + /* Struct for keeping track of schematic sheet changes * Stores: * SHEET_PATH - Schematic to apply changes to @@ -121,90 +170,85 @@ typedef struct PICKED_ITEMS_LIST items; } SheetUndoList; -/** - * When the component table dialog is closed, - * work out if we need to save any changed. - * If so, capture those changes and push them to the undo stack. - */ -bool DIALOG_BOM_EDITOR::TransferDataFromWindow() +void DIALOG_BOM_EDITOR::ApplyAllChanges() { - if( m_bom->HaveFieldsChanged() ) + if( !m_bom->HaveFieldsChanged() ) + return; + + /** + * As we may be saving changes across multiple sheets, + * we need to first determine which changes need to be made to which sheet. + * To this end, we perform the following: + * 1. Save the "path" of the currently displayed sheet + * 2. Create a MAP of changes that need to be made + * 3. Push UNDO actions to appropriate sheets + * 4. Perform all the update actions + * 5. Reset the view to the current sheet + */ + + auto currentSheet = m_parent->GetCurrentSheet(); + + //! Create a map of changes required for each sheet + std::map undoSheetMap; + + // List of components that have changed + auto changed = m_bom->GetChangedComponents(); + + ITEM_PICKER picker; + + // Iterate through each of the components that were changed + for( auto ref : changed ) { - /** - * As we may be saving changes across multiple sheets, - * we need to first determine which changes need to be made to which sheet. - * To this end, we perform the following: - * 1. Save the "path" of the currently displayed sheet - * 2. Create a MAP of changes that need to be made - * 3. Push UNDO actions to appropriate sheets - * 4. Perform all the update actions - * 5. Reset the view to the current sheet + // Extract the SCH_COMPONENT* object + auto cmp = ref.GetComp(); + + wxString path = ref.GetSheetPath().Path(); + + // Push the component into the picker list + picker = ITEM_PICKER( cmp, UR_CHANGED ); + picker.SetFlags( cmp->GetFlags() ); + + /* + * If there is not currently an undo list for the given sheet, + * create an empty one */ - auto currentSheet = m_parent->GetCurrentSheet(); - - //! Create a map of changes required for each sheet - std::map undoSheetMap; - - // List of components that have changed - auto changed = m_bom->GetChangedComponents(); - - ITEM_PICKER picker; - - // Iterate through each of the components that were changed - for( auto ref : changed ) + if( undoSheetMap.count( path ) == 0 ) { - // Extract the SCH_COMPONENT* object - auto cmp = ref.GetComp(); + SheetUndoList newList; - wxString path = ref.GetSheetPath().Path(); + newList.path = ref.GetSheetPath(); - // Push the component into the picker list - picker = ITEM_PICKER( cmp, UR_CHANGED ); - picker.SetFlags( cmp->GetFlags() ); - - /* - * If there is not currently an undo list for the given sheet, - * create an empty one - */ - - if( undoSheetMap.count( path ) == 0 ) - { - SheetUndoList newList; - - newList.path = ref.GetSheetPath(); - - undoSheetMap[path] = newList; - } - - auto& pickerList = undoSheetMap[path]; - - pickerList.items.PushItem( picker ); + undoSheetMap[path] = newList; } - // Iterate through each sheet that needs updating - for( auto it = undoSheetMap.begin(); it != undoSheetMap.end(); ++it ) - { - auto undo = it->second; - - m_parent->SetCurrentSheet( undo.path ); - m_parent->SaveCopyInUndoList( undo.items, UR_CHANGED ); - m_parent->OnModify(); - } - - // Make all component changes - m_bom->ApplyFieldChanges(); - - // Redraw the current sheet and mark as dirty - m_parent->Refresh(); - m_parent->OnModify(); - - // Reset the view to where we left the user - m_parent->SetCurrentSheet(currentSheet); + auto& pickerList = undoSheetMap[path]; + pickerList.items.PushItem( picker ); } - return true; + // Iterate through each sheet that needs updating + for( auto it = undoSheetMap.begin(); it != undoSheetMap.end(); ++it ) + { + auto undo = it->second; + + m_parent->SetCurrentSheet( undo.path ); + m_parent->SaveCopyInUndoList( undo.items, UR_CHANGED ); + m_parent->OnModify(); + } + + // Make all component changes + m_bom->ApplyFieldChanges(); + + // Redraw the current sheet and mark as dirty + m_parent->Refresh(); + m_parent->OnModify(); + + // Reset the view to where we left the user + m_parent->SetCurrentSheet(currentSheet); + + // Instruct the table to set the current values as the new backup values + m_bom->SetBackupPoint(); } /** @@ -252,7 +296,7 @@ void DIALOG_BOM_EDITOR::LoadComponents() sheets.GetComponents( m_parent->Prj().SchLibs(), refs, false ); // Pass the references through to the model - m_bom->SetComponents( refs ); + m_bom->SetComponents( refs, m_parent->GetTemplateFieldNames() ); } /** @@ -273,6 +317,7 @@ void DIALOG_BOM_EDITOR::LoadColumnNames() data.push_back( wxVariant( col->Title() ) ); // Column title (string) data.push_back( wxVariant( col->IsVisible() ) ); // Column visibility (bool) + data.push_back( wxVariant( col->IsUsedToSort() ) ); // Column is used to sort m_columnListCtrl->AppendItem( data ); } @@ -318,6 +363,10 @@ void DIALOG_BOM_EDITOR::OnColumnItemToggled( wxDataViewEvent& event ) m_bom->RemoveColumn( bomColumn ); } break; + case 2: // Column used to sort + bomColumn->SetUsedToSort( bValue ); + m_bom->ReloadTable(); + break; } } @@ -337,7 +386,11 @@ void DIALOG_BOM_EDITOR::OnGroupComponentsToggled( wxCommandEvent& event ) void DIALOG_BOM_EDITOR::OnUpdateUI( wxUpdateUIEvent& event ) { m_regroupComponentsButton->Enable( m_bom->GetColumnGrouping() ); - m_reloadTableButton->Enable( m_bom->HaveFieldsChanged() ); + + bool changes = m_bom->HaveFieldsChanged(); + + m_applyChangesButton->Enable( changes ); + m_revertChangesButton->Enable( changes ); UpdateTitle(); } @@ -353,6 +406,12 @@ void DIALOG_BOM_EDITOR::OnRegroupComponents( wxCommandEvent& event ) Update(); } +void DIALOG_BOM_EDITOR::OnApplyFieldChanges( wxCommandEvent& event ) +{ + ApplyAllChanges(); + Update(); +} + void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event ) { if( m_bom->HaveFieldsChanged() ) diff --git a/eeschema/dialogs/dialog_bom_editor.h b/eeschema/dialogs/dialog_bom_editor.h index 90a18ff045..c9d089604e 100644 --- a/eeschema/dialogs/dialog_bom_editor.h +++ b/eeschema/dialogs/dialog_bom_editor.h @@ -57,13 +57,12 @@ private: BOM_TABLE_MODEL::MODEL_PTR m_bom; - void LoadComponents( void ); + void LoadComponents(); - void LoadColumnNames( void ); - void ReloadColumns( void ); + void LoadColumnNames(); + void ReloadColumns(); - // Called when the OK button is pressed - virtual bool TransferDataFromWindow() override; + void ApplyAllChanges(); // Checkbox event callbacks virtual void OnColumnItemToggled( wxDataViewEvent& event ) override; @@ -71,6 +70,8 @@ private: virtual void OnRevertFieldChanges( wxCommandEvent& event ) override; + virtual void OnApplyFieldChanges( wxCommandEvent& event ) override; + virtual void OnRegroupComponents( wxCommandEvent& event ) override; // Called after a value in the table has changed @@ -82,6 +83,12 @@ private: // Called when a cell is right-clicked virtual void OnTableItemContextMenu( wxDataViewEvent& event ) override; + // Called when the dialog is closed + virtual void OnDialogClosed( wxCloseEvent& event ) override; + virtual void OnCloseButton( wxCommandEvent& event ) override; + + bool CloseDialog(); + void UpdateTitle( void ); virtual void OnUpdateUI( wxUpdateUIEvent& event ) override; diff --git a/eeschema/dialogs/dialog_bom_editor_base.cpp b/eeschema/dialogs/dialog_bom_editor_base.cpp index 3eeecc583a..1636e5241d 100644 --- a/eeschema/dialogs/dialog_bom_editor_base.cpp +++ b/eeschema/dialogs/dialog_bom_editor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 19 2017) +// C++ code generated with wxFormBuilder (version Apr 1 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -10,10 +10,10 @@ /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM ) + EVT_CLOSE( DIALOG_BOM_EDITOR_BASE::_wxFB_OnDialogClosed ) EVT_UPDATE_UI( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnUpdateUI ) EVT_CHECKBOX( OPT_GROUP_COMPONENTS, DIALOG_BOM_EDITOR_BASE::_wxFB_OnGroupComponentsToggled ) EVT_BUTTON( ID_BUTTON_REGROUP, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRegroupComponents ) - EVT_BUTTON( ID_BUTTON_REVERT_CHANGES, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges ) EVT_DATAVIEW_ITEM_VALUE_CHANGED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnColumnItemToggled ) EVT_DATAVIEW_COLUMN_REORDERED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnBomColumReordered ) EVT_DATAVIEW_COLUMN_SORTED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnBomColumnSorted ) @@ -21,110 +21,116 @@ BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM ) EVT_DATAVIEW_ITEM_CONTEXT_MENU( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnTableItemContextMenu ) EVT_DATAVIEW_ITEM_EDITING_DONE( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnTableValueChanged ) EVT_DATAVIEW_SELECTION_CHANGED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnSelectionChanged ) + EVT_BUTTON( ID_BUTTON_APPLY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnApplyFieldChanges ) + EVT_BUTTON( ID_BUTTON_REVERT, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges ) + EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_EDITOR_BASE::_wxFB_OnCloseButton ) END_EVENT_TABLE() DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_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* bHorizontalSizer; bHorizontalSizer = new wxBoxSizer( wxVERTICAL ); - + + wxBoxSizer* bSizer61; + bSizer61 = new wxBoxSizer( wxVERTICAL ); + m_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); - + m_splitter1 = new wxSplitterWindow( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D ); m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_BOM_EDITOR_BASE::m_splitter1OnIdle ), NULL, this ); m_splitter1->SetMinimumPaneSize( 120 ); - + m_leftPanel = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer6; bSizer6 = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbSizer1; sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_leftPanel, wxID_ANY, _("Options") ), wxVERTICAL ); - + m_groupComponentsBox = new wxCheckBox( sbSizer1->GetStaticBox(), OPT_GROUP_COMPONENTS, _("Group components"), wxDefaultPosition, wxDefaultSize, 0 ); - m_groupComponentsBox->SetValue(true); + m_groupComponentsBox->SetValue(true); m_groupComponentsBox->SetToolTip( _("Group components together based on common properties") ); - + sbSizer1->Add( m_groupComponentsBox, 0, wxALL|wxEXPAND, 5 ); - + m_regroupComponentsButton = new wxButton( sbSizer1->GetStaticBox(), ID_BUTTON_REGROUP, _("Regroup components"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer1->Add( m_regroupComponentsButton, 0, wxALL|wxEXPAND, 5 ); - - m_reloadTableButton = new wxButton( sbSizer1->GetStaticBox(), ID_BUTTON_REVERT_CHANGES, _("Revert all changes"), wxDefaultPosition, wxDefaultSize, 0 ); - m_reloadTableButton->Enable( false ); - m_reloadTableButton->SetToolTip( _("Reload table (reverts component field changes)") ); - - sbSizer1->Add( m_reloadTableButton, 0, wxALL|wxEXPAND, 5 ); - - + + bSizer6->Add( sbSizer1, 0, wxEXPAND, 5 ); - + wxBoxSizer* bSizer9; bSizer9 = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* m_fieldListSizer; m_fieldListSizer = new wxStaticBoxSizer( new wxStaticBox( m_leftPanel, wxID_ANY, _("Fields") ), wxVERTICAL ); - + m_columnListCtrl = new wxDataViewListCtrl( m_fieldListSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_columnListCtrl->SetMinSize( wxSize( -1,250 ) ); - + m_fieldListSizer->Add( m_columnListCtrl, 1, wxALL|wxEXPAND, 5 ); - - + + bSizer9->Add( m_fieldListSizer, 1, wxEXPAND, 5 ); - - + + bSizer6->Add( bSizer9, 5, wxEXPAND, 5 ); - - wxStaticBoxSizer* sbSizer4; - sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_leftPanel, wxID_ANY, _("Apply changes") ), wxVERTICAL ); - - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( sbSizer4->GetStaticBox(), wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( sbSizer4->GetStaticBox(), wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); - - sbSizer4->Add( m_sdbSizer1, 1, wxEXPAND, 5 ); - - - bSizer6->Add( sbSizer4, 0, wxEXPAND, 10 ); - - + + m_leftPanel->SetSizer( bSizer6 ); m_leftPanel->Layout(); bSizer6->Fit( m_leftPanel ); m_panel4 = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxVERTICAL ); - + m_bomView = new wxDataViewCtrl( m_panel4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE|wxDV_ROW_LINES|wxDV_VERT_RULES ); m_bomView->SetMinSize( wxSize( 450,250 ) ); - + bSizer5->Add( m_bomView, 1, wxALL|wxEXPAND, 5 ); - - + + m_panel4->SetSizer( bSizer5 ); m_panel4->Layout(); bSizer5->Fit( m_panel4 ); m_splitter1->SplitVertically( m_leftPanel, m_panel4, 231 ); bSizer7->Add( m_splitter1, 1, wxEXPAND, 5 ); - - + + m_panel->SetSizer( bSizer7 ); m_panel->Layout(); bSizer7->Fit( m_panel ); - bHorizontalSizer->Add( m_panel, 1, wxEXPAND | wxALL, 5 ); - - + bSizer61->Add( m_panel, 1, wxEXPAND | wxALL, 5 ); + + wxBoxSizer* bSizer71; + bSizer71 = new wxBoxSizer( wxHORIZONTAL ); + + m_applyChangesButton = new wxButton( this, ID_BUTTON_APPLY, _("Apply Changes"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer71->Add( m_applyChangesButton, 0, wxALL, 5 ); + + m_revertChangesButton = new wxButton( this, ID_BUTTON_REVERT, _("Revert Changes"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer71->Add( m_revertChangesButton, 0, wxALL, 5 ); + + + bSizer71->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_closeButton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer71->Add( m_closeButton, 0, wxALL, 5 ); + + + bSizer61->Add( bSizer71, 0, wxEXPAND, 5 ); + + + bHorizontalSizer->Add( bSizer61, 1, wxEXPAND, 5 ); + + this->SetSizer( bHorizontalSizer ); this->Layout(); - + this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_bom_editor_base.fbp b/eeschema/dialogs/dialog_bom_editor_base.fbp index 442b8d78de..d78537dbce 100644 --- a/eeschema/dialogs/dialog_bom_editor_base.fbp +++ b/eeschema/dialogs/dialog_bom_editor_base.fbp @@ -44,8 +44,8 @@ DIALOG_BOM_EDITOR_BASE - 1047,471 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + 775,654 + wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h BOM editor @@ -61,7 +61,7 @@ - + OnDialogClosed @@ -95,177 +95,101 @@ none 5 - wxEXPAND | wxALL + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + - 1 - m_panel - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bSizer7 - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 120 - - 0 + bSizer61 + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panel + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + - 1 - m_splitter1 - 1 - - - protected - 1 - - Resizable - 0.0 - 231 - -1 - 1 - - wxSPLIT_VERTICAL - wxSP_3D - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bSizer7 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + 1 1 1 @@ -296,11 +220,12 @@ 0 + 120 0 1 - m_leftPanel + m_splitter1 1 @@ -308,14 +233,19 @@ 1 Resizable + 0.0 + 231 + -1 1 + wxSPLIT_VERTICAL + wxSP_3D 0 - wxTAB_TRAVERSAL + @@ -338,309 +268,100 @@ + + + + - - - bSizer6 - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - wxID_ANY - Options - - sbSizer1 - wxVERTICAL - 1 - none - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - OPT_GROUP_COMPONENTS - Group components - - 0 - - - 0 - - 1 - m_groupComponentsBox - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Group components together based on common properties - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnGroupComponentsToggled - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_BUTTON_REGROUP - Regroup components - - 0 - - - 0 - - 1 - m_regroupComponentsButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnRegroupComponents - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 0 - - 1 - - 0 - 0 - ID_BUTTON_REVERT_CHANGES - Revert all changes - - 0 - - - 0 - - 1 - m_reloadTableButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Reload table (reverts component field changes) - - wxFILTER_NONE - wxDefaultValidator - - - - - OnRevertFieldChanges - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 5 + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_leftPanel + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + - bSizer9 + bSizer6 wxVERTICAL none 5 wxEXPAND - 1 + 0 wxID_ANY - Fields + Options - m_fieldListSizer + sbSizer1 wxVERTICAL 1 none @@ -648,47 +369,155 @@ 5 wxALL|wxEXPAND - 1 - + 0 + + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 - wxID_ANY + OPT_GROUP_COMPONENTS + Group components + + 0 - -1,250 - m_columnListCtrl + + 0 + + 1 + m_groupComponentsBox + 1 + + protected + 1 + Resizable + 1 - + 0 + Group components together based on common properties + + wxFILTER_NONE + wxDefaultValidator + - - - - - - - - - - - - - - - - - OnColumnItemToggled - + OnGroupComponentsToggled + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_BUTTON_REGROUP + Regroup components + + 0 + + + 0 + + 1 + m_regroupComponentsButton + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRegroupComponents + @@ -715,45 +544,249 @@ - - - - 10 - wxEXPAND - 0 - - wxID_ANY - Apply changes - - sbSizer4 - wxVERTICAL - 1 - none - 5 wxEXPAND - 1 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + 5 + - m_sdbSizer1 + bSizer9 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Fields + + m_fieldListSizer + wxVERTICAL + 1 + none + + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + -1,250 + m_columnListCtrl + protected + + + + + + + + + + + + + + + + + + + + + + + + + + OnColumnItemToggled + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panel4 + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer5 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + 450,250 + m_bomView protected - - - - - - - - + + + wxDV_MULTIPLE|wxDV_ROW_LINES|wxDV_VERT_RULES + + + + + + + + + OnBomColumReordered + OnBomColumnSorted + OnTableItemActivated + + + + OnTableItemContextMenu + + + OnTableValueChanged + + + + + + OnSelectionChanged + + + + + + + + + + + + + + + + + + + + + + @@ -761,156 +794,290 @@ - - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panel4 - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bSizer5 - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - - - 1 - 1 - - - 0 - wxID_ANY - - 450,250 - m_bomView - protected - - - wxDV_MULTIPLE|wxDV_ROW_LINES|wxDV_VERT_RULES - - - - - - - - - OnBomColumReordered - OnBomColumnSorted - OnTableItemActivated - - - - OnTableItemContextMenu - - - OnTableValueChanged - - - - - - OnSelectionChanged - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + 5 + wxEXPAND + 0 + + + bSizer71 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_BUTTON_APPLY + Apply Changes + + 0 + + + 0 + + 1 + m_applyChangesButton + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnApplyFieldChanges + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_BUTTON_REVERT + Revert Changes + + 0 + + + 0 + + 1 + m_revertChangesButton + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRevertFieldChanges + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Close + + 0 + + + 0 + + 1 + m_closeButton + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCloseButton + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_bom_editor_base.h b/eeschema/dialogs/dialog_bom_editor_base.h index 4a56c1b16a..d5b204d4a1 100644 --- a/eeschema/dialogs/dialog_bom_editor_base.h +++ b/eeschema/dialogs/dialog_bom_editor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 19 2017) +// C++ code generated with wxFormBuilder (version Apr 1 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -32,7 +32,8 @@ class DIALOG_SHIM; #define OPT_GROUP_COMPONENTS 1000 #define ID_BUTTON_REGROUP 1001 -#define ID_BUTTON_REVERT_CHANGES 1002 +#define ID_BUTTON_APPLY 1002 +#define ID_BUTTON_REVERT 1003 /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_BOM_EDITOR_BASE @@ -41,12 +42,12 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM { DECLARE_EVENT_TABLE() private: - + // Private event handlers + void _wxFB_OnDialogClosed( wxCloseEvent& event ){ OnDialogClosed( event ); } void _wxFB_OnUpdateUI( wxUpdateUIEvent& event ){ OnUpdateUI( event ); } void _wxFB_OnGroupComponentsToggled( wxCommandEvent& event ){ OnGroupComponentsToggled( event ); } void _wxFB_OnRegroupComponents( wxCommandEvent& event ){ OnRegroupComponents( event ); } - void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); } void _wxFB_OnColumnItemToggled( wxDataViewEvent& event ){ OnColumnItemToggled( event ); } void _wxFB_OnBomColumReordered( wxDataViewEvent& event ){ OnBomColumReordered( event ); } void _wxFB_OnBomColumnSorted( wxDataViewEvent& event ){ OnBomColumnSorted( event ); } @@ -54,27 +55,29 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM void _wxFB_OnTableItemContextMenu( wxDataViewEvent& event ){ OnTableItemContextMenu( event ); } void _wxFB_OnTableValueChanged( wxDataViewEvent& event ){ OnTableValueChanged( event ); } void _wxFB_OnSelectionChanged( wxDataViewEvent& event ){ OnSelectionChanged( event ); } - - + void _wxFB_OnApplyFieldChanges( wxCommandEvent& event ){ OnApplyFieldChanges( event ); } + void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); } + void _wxFB_OnCloseButton( wxCommandEvent& event ){ OnCloseButton( event ); } + + protected: wxPanel* m_panel; wxSplitterWindow* m_splitter1; wxPanel* m_leftPanel; wxCheckBox* m_groupComponentsBox; wxButton* m_regroupComponentsButton; - wxButton* m_reloadTableButton; wxDataViewListCtrl* m_columnListCtrl; - wxStdDialogButtonSizer* m_sdbSizer1; - wxButton* m_sdbSizer1OK; - wxButton* m_sdbSizer1Cancel; wxPanel* m_panel4; wxDataViewCtrl* m_bomView; - + wxButton* m_applyChangesButton; + wxButton* m_revertChangesButton; + wxButton* m_closeButton; + // Virtual event handlers, overide them in your derived class + virtual void OnDialogClosed( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnGroupComponentsToggled( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegroupComponents( wxCommandEvent& event ) { event.Skip(); } - virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); } virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); } virtual void OnBomColumReordered( wxDataViewEvent& event ) { event.Skip(); } virtual void OnBomColumnSorted( wxDataViewEvent& event ) { event.Skip(); } @@ -82,19 +85,22 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM virtual void OnTableItemContextMenu( wxDataViewEvent& event ) { event.Skip(); } virtual void OnTableValueChanged( wxDataViewEvent& event ) { event.Skip(); } virtual void OnSelectionChanged( wxDataViewEvent& event ) { event.Skip(); } - - + virtual void OnApplyFieldChanges( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCloseButton( wxCommandEvent& event ) { event.Skip(); } + + public: - - DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,471 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 775,654 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); ~DIALOG_BOM_EDITOR_BASE(); - + void m_splitter1OnIdle( wxIdleEvent& ) { m_splitter1->SetSashPosition( 231 ); m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_BOM_EDITOR_BASE::m_splitter1OnIdle ), NULL, this ); } - + }; #endif //__DIALOG_BOM_EDITOR_BASE_H__