pcb_calculator: Move calculator panels to a registration architecture

This simplifies operations that touch every panel and is a bit neater.
This commit is contained in:
Ian McInerney 2021-10-08 18:13:41 +01:00
parent fb588da875
commit 0a1a181798
7 changed files with 126 additions and 628 deletions

View File

@ -20,8 +20,9 @@
#include <wx/msgdlg.h>
#include "class_regulator_data.h"
#include "pcb_calculator_frame.h"
#include <calculator_panels/panel_regulator.h>
#include <class_regulator_data.h>
#include <pcb_calculator_frame.h>
#include "dialog_regulator_form.h"

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -20,24 +20,6 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
bmainFrameSizer = new wxBoxSizer( wxVERTICAL );
m_Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_panelRegulators = new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelRegulators, _("Regulators"), true );
m_panelAttenuators = new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelAttenuators, _("RF Attenuators"), false );
m_panelESeries = new PANEL_E_SERIE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelESeries, _("E-Series"), false );
m_panelColorCode = new PANEL_COLOR_CODE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelColorCode, _("Color Code"), false );
m_panelTransline = new PANEL_TRANSLINE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelTransline, _("TransLine"), false );
m_panelViaSize = new PANEL_VIA_SIZE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelViaSize, _("Via Size"), false );
m_panelTrackWidth = new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelTrackWidth, _("Track Width"), false );
m_panelElectricalSpacing = new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelElectricalSpacing, _("Electrical Spacing"), false );
m_panelBoardClass = new PANEL_BOARD_CLASS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Notebook->AddPage( m_panelBoardClass, _("Board Classes"), false );
bmainFrameSizer->Add( m_Notebook, 1, wxEXPAND, 5 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">pcb_calculator_frame_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">pcb_calculator_frame_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
@ -50,6 +52,7 @@
<property name="subclass">KIWAY_PLAYER; kiway_player.h</property>
<property name="title">PCB Calculator</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name">pcb_calculator</property>
<property name="window_style">wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL</property>
@ -65,7 +68,6 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">MenuBar</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_menubar</property>
@ -141,519 +143,6 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Regulators</property>
<property name="select">1</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelRegulators</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_REGULATOR; calculator_panels/panel_regulator.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">RF Attenuators</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelAttenuators</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_ATTENUATORS; calculator_panels/panel_attenuators.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">E-Series</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelESeries</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_E_SERIE; calculator_panels/panel_eserie.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Color Code</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelColorCode</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_COLOR_CODE; calculator_panels/panel_color_code.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">TransLine</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelTransline</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_TRANSLINE; calculator_panels/panel_transline.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Via Size</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelViaSize</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_VIA_SIZE; calculator_panels/panel_via_size.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Track Width</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelTrackWidth</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_TRACK_WIDTH; calculator_panels/panel_track_width.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Electrical Spacing</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelElectricalSpacing</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_ELECTRICAL_SPACING; calculator_panels/panel_electrical_spacing.h; ...</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">wxTAB_TRAVERSAL</property>
</object>
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Board Classes</property>
<property name="select">0</property>
<object class="wxPanel" 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="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">0</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="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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"></property>
<property name="moveable">1</property>
<property name="name">m_panelBoardClass</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="show">1</property>
<property name="size"></property>
<property name="subclass">PANEL_BOARD_CLASS; calculator_panels/panel_board_class.h; Not 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">wxTAB_TRAVERSAL</property>
</object>
</object>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -10,26 +10,13 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "calculator_panels/panel_regulator.h"
#include "calculator_panels/panel_attenuators.h"
#include "calculator_panels/panel_eserie.h"
#include "calculator_panels/panel_color_code.h"
#include "calculator_panels/panel_transline.h"
#include "calculator_panels/panel_via_size.h"
#include "calculator_panels/panel_track_width.h"
#include "calculator_panels/panel_electrical_spacing.h"
#include "calculator_panels/panel_board_class.h"
#include "kiway_player.h"
#include <wx/string.h>
#include <wx/menu.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/string.h>
#include <wx/notebook.h>
#include <wx/sizer.h>
#include <wx/frame.h>
@ -47,17 +34,8 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
protected:
wxMenuBar* m_menubar;
wxNotebook* m_Notebook;
PANEL_REGULATOR* m_panelRegulators;
PANEL_ATTENUATORS* m_panelAttenuators;
PANEL_E_SERIE* m_panelESeries;
PANEL_COLOR_CODE* m_panelColorCode;
PANEL_TRANSLINE* m_panelTransline;
PANEL_VIA_SIZE* m_panelViaSize;
PANEL_TRACK_WIDTH* m_panelTrackWidth;
PANEL_ELECTRICAL_SPACING* m_panelElectricalSpacing;
PANEL_BOARD_CLASS* m_panelBoardClass;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }

View File

@ -83,7 +83,7 @@ double DoubleFromString( const wxString& TextValue )
PANEL_TRANSLINE* getTranslinePanel()
{
PCB_CALCULATOR_FRAME* frame = (PCB_CALCULATOR_FRAME*) wxTheApp->GetTopWindow();
return frame->GetPanelTransline();
return frame->GetCalculator<PANEL_TRANSLINE>();
}

View File

@ -26,6 +26,16 @@
#include "pcb_calculator_frame.h"
#include "pcb_calculator_settings.h"
#include <calculator_panels/panel_attenuators.h>
#include <calculator_panels/panel_board_class.h>
#include <calculator_panels/panel_color_code.h>
#include <calculator_panels/panel_electrical_spacing.h>
#include <calculator_panels/panel_eserie.h>
#include <calculator_panels/panel_regulator.h>
#include <calculator_panels/panel_track_width.h>
#include <calculator_panels/panel_transline.h>
#include <calculator_panels/panel_via_size.h>
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_CALCULATOR_FRAME_BASE( aParent ),
@ -37,9 +47,29 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
// some methods in code and avoid link errors
AddCalculator( new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Regulators" ) );
AddCalculator( new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "RF Attenuators" ) );
AddCalculator( new PANEL_E_SERIE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "E-Series" ) );
AddCalculator( new PANEL_COLOR_CODE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Color Code" ) );
AddCalculator( new PANEL_TRANSLINE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "TransLine ") );
AddCalculator( new PANEL_VIA_SIZE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Via Size" ) );
AddCalculator( new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Track Width" ) );
AddCalculator( new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Electrical Spacing" ) );
AddCalculator( new PANEL_BOARD_CLASS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_("Board Classes") );
LoadSettings( config() );
m_panelRegulators->ReadDataFile();
if( PANEL_REGULATOR* regPanel = GetCalculator<PANEL_REGULATOR>() )
regPanel->ReadDataFile();
// Give an icon
wxIcon icon;
@ -75,20 +105,24 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
}
void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent &aEvent )
void PCB_CALCULATOR_FRAME::AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName )
{
// Update internal structures
m_panels.push_back( aPanel );
m_panelTypes[ typeid( aPanel ).name() ] = aPanel;
m_Notebook->AddPage( aPanel, panelUIName, false );
}
void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent& aEvent )
{
// Force the bitmaps to refresh
GetBitmapStore()->ThemeChanged();
// Update the panels
m_panelTransline->ThemeChanged();
m_panelRegulators->ThemeChanged();
m_panelAttenuators->ThemeChanged();
m_panelColorCode->ThemeChanged();
m_panelViaSize->ThemeChanged();
m_panelTrackWidth->ThemeChanged();
m_panelElectricalSpacing->ThemeChanged();
m_panelBoardClass->ThemeChanged();
for( auto& panel : m_panels )
panel->ThemeChanged();
aEvent.Skip();
}
@ -100,28 +134,38 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
{
// Kick all the things that wxWidgets can't seem to redraw on its own.
// This is getting seriously ridiculous....
wxCommandEvent event2( wxEVT_RADIOBUTTON );
event2.SetEventObject( m_panelTransline->GetTranslineSelector() );
event2.SetInt( m_panelTransline->GetCurrTransLineType() );
m_panelTransline->GetTranslineSelector()->Command( event2 );
for( int i = 0; i < m_panelAttenuators->m_AttenuatorList.size(); ++i )
if( PANEL_TRANSLINE* translinePanel = GetCalculator<PANEL_TRANSLINE>() )
{
if( m_panelAttenuators->m_AttenuatorList[i] == m_panelAttenuators->m_CurrAttenuator )
{
event2.SetEventObject( m_panelAttenuators->GetAttenuatorsSelector() );
event2.SetInt( i );
m_panelAttenuators->GetAttenuatorsSelector()->Command( event2 );
break;
}
wxCommandEvent event2( wxEVT_RADIOBUTTON );
event2.SetEventObject( translinePanel->GetTranslineSelector() );
event2.SetInt( translinePanel->GetCurrTransLineType() );
translinePanel->GetTranslineSelector()->Command( event2 );
}
m_panelAttenuators->UpdateUI();
if( PANEL_ATTENUATORS* attenPanel = GetCalculator<PANEL_ATTENUATORS>() )
{
for( int i = 0; i < attenPanel->m_AttenuatorList.size(); ++i )
{
if( attenPanel->m_AttenuatorList[i] == attenPanel->m_CurrAttenuator )
{
wxCommandEvent event2( wxEVT_RADIOBUTTON );
event2.SetEventObject( attenPanel->GetAttenuatorsSelector() );
event2.SetInt( i );
m_panelViaSize->Layout();
attenPanel->GetAttenuatorsSelector()->Command( event2 );
break;
}
}
m_panelRegulators->Layout();
attenPanel->UpdateUI();
}
if( PANEL_VIA_SIZE* viaSizePanel = GetCalculator<PANEL_VIA_SIZE>() )
viaSizePanel->Layout();
if( PANEL_REGULATOR* regulPanel = GetCalculator<PANEL_REGULATOR>() )
regulPanel->Layout();
// Until it's shown on screen the above won't work; but doing it anyway at least keeps
// putting new OnUpdateUI events into the queue until it *is* shown on screen.
@ -132,17 +176,20 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
#ifdef __WXMAC__
if( m_macHack )
{
wxSize pageSize = m_panelElectricalSpacing->GetSize();
if( PANEL_ELECTRICAL_SPACING* elecSpacingPanel = GetCalculator<PANEL_ELECTRICAL_SPACING>() )
{
wxSize pageSize = elecSpacingPanel->GetSize();
pageSize.x -= 100;
m_panelElectricalSpacing->SetSize( pageSize );
m_panelElectricalSpacing->Layout();
pageSize.x -= 100;
elecSpacingPanel->SetSize( pageSize );
elecSpacingPanel->Layout();
pageSize.x += 100;
m_panelElectricalSpacing->SetSize( pageSize );
m_panelElectricalSpacing->Layout();
pageSize.x += 100;
elecSpacingPanel->SetSize( pageSize );
elecSpacingPanel->Layout();
m_macHack = false;
m_macHack = false;
}
}
#endif
@ -154,12 +201,14 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
{
if( m_panelRegulators->m_RegulatorListChanged )
PANEL_REGULATOR* regPanel = GetCalculator<PANEL_REGULATOR>();
if( regPanel && regPanel->m_RegulatorListChanged )
{
wxString msg;
wxString title = _( "Write Data Failed" );
if( m_panelRegulators->GetDataFilename().IsEmpty() )
if( regPanel->GetDataFilename().IsEmpty() )
{
msg = _( "No data filename to save modifications.\n"
"Do you want to exit and abandon your changes?" );
@ -169,11 +218,11 @@ void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
}
else
{
if( !m_panelRegulators->WriteDataFile() )
if( !regPanel->WriteDataFile() )
{
msg.Printf( _( "Unable to write file '%s'\n"
"Do you want to exit and abandon your changes?"),
m_panelRegulators->GetDataFilename() );
regPanel->GetDataFilename() );
if( wxMessageBox( msg, title, wxYES_NO | wxICON_ERROR ) == wxNO )
return;
@ -196,22 +245,8 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
m_Notebook->ChangeSelection( cfg->m_LastPage );
m_panelTransline->LoadSettings( cfg );
// Attenuators panel config:
m_panelAttenuators->LoadSettings( cfg );
// Regul panel config:
m_panelRegulators->LoadSettings( cfg );
// color panel config:
m_panelColorCode->LoadSettings( cfg );
m_panelViaSize->LoadSettings( cfg );
m_panelTrackWidth->LoadSettings( cfg );
m_panelElectricalSpacing->LoadSettings( cfg );
m_panelBoardClass->LoadSettings( cfg );
m_panelESeries->LoadSettings( cfg );
for( auto& panel : m_panels )
panel->LoadSettings( cfg );
}
@ -229,14 +264,8 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
cfg->m_LastPage = m_Notebook->GetSelection();
m_panelTransline->SaveSettings( cfg );
m_panelRegulators->Regulators_WriteConfig( cfg );
m_panelAttenuators->SaveSettings( cfg );
m_panelColorCode->SaveSettings( cfg );
m_panelViaSize->SaveSettings( cfg );
m_panelTrackWidth->SaveSettings( cfg );
m_panelElectricalSpacing->SaveSettings( cfg );
m_panelBoardClass->SaveSettings( cfg );
for( auto& panel : m_panels )
panel->SaveSettings( cfg );
}
}

View File

@ -20,6 +20,7 @@
#ifndef PCB_CALCULATOR_H
#define PCB_CALCULATOR_H
#include "calculator_panels/calculator_panel.h"
#include "pcb_calculator_frame_base.h"
class APP_SETTINGS_BASE;
@ -42,8 +43,21 @@ public:
return nullptr;
}
// Accessor:
PANEL_TRANSLINE* GetPanelTransline() { return m_panelTransline; }
/*
* Return the panel of given type or nullptr if there is no such panel exists.
*/
template<typename T>
T* GetCalculator()
{
std::map<const char*, CALCULATOR_PANEL*>::iterator panel = m_panelTypes.find( typeid( T ).name() );
if( panel != m_panelTypes.end() )
return static_cast<T*>( panel->second );
return nullptr;
}
void AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName );
private:
// Event handlers
@ -51,7 +65,7 @@ private:
void OnUpdateUI( wxUpdateUIEvent& event ) override;
void onThemeChanged( wxSysColourChangedEvent &aEvent );
void onThemeChanged( wxSysColourChangedEvent& aEvent );
// Config read-write, virtual from EDA_BASE_FRAME
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
@ -60,6 +74,11 @@ private:
private:
int m_lastNotebookPage;
bool m_macHack;
std::vector<CALCULATOR_PANEL*> m_panels;
std::map<const char*, CALCULATOR_PANEL*> m_panelTypes;
};