More header clean up.

This commit is contained in:
Wayne Stambaugh 2021-06-08 15:39:47 -04:00
parent e6346e3103
commit 6b5d512b9f
14 changed files with 439 additions and 505 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -60,35 +60,6 @@ typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
*/ */
class CVPCB_MAINFRAME : public KIWAY_PLAYER class CVPCB_MAINFRAME : public KIWAY_PLAYER
{ {
friend struct CV::IFACE;
NETLIST m_netlist;
int m_filteringOptions;
ACTION_TOOLBAR* m_mainToolBar;
FOOTPRINTS_LISTBOX* m_footprintListBox;
LIBRARY_LISTBOX* m_librariesListBox;
COMPONENTS_LISTBOX* m_symbolsListBox;
wxTextCtrl* m_tcFilterString;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
wxStaticText* m_statusLine3;
wxButton* m_saveAndContinue;
public:
FOOTPRINT_LIST* m_FootprintsList;
protected:
bool m_modified;
bool m_skipComponentSelect; // skip component selection event during
// automatic selection/deletion of
// associations
bool m_initialized;
CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
void setupUIConditions() override;
public: public:
~CVPCB_MAINFRAME(); ~CVPCB_MAINFRAME();
@ -107,7 +78,7 @@ public:
}; };
/** /**
* The type of the controls present in the application * The type of the controls present in the application.
*/ */
enum CONTROL_TYPE enum CONTROL_TYPE
{ {
@ -118,7 +89,7 @@ public:
}; };
/** /**
* Directions to rotate the focus through the listboxes is * Directions to rotate the focus through the listboxes is.
*/ */
enum FOCUS_DIR enum FOCUS_DIR
{ {
@ -127,7 +98,7 @@ public:
}; };
/** /**
* Directions to move when selecting items * Directions to move when selecting items.
*/ */
enum ITEM_DIR enum ITEM_DIR
{ {
@ -155,7 +126,7 @@ public:
/** /**
* Find out which control currently has focus. * Find out which control currently has focus.
* *
* @return the contorl that currently has focus * @return the control that currently has focus
*/ */
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const; CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const;
@ -169,13 +140,12 @@ public:
/** /**
* Set the focus to a specific control. * Set the focus to a specific control.
* *
* @param aControl the contorl to set focus to * @param aControl the control to set focus to
*/ */
void SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aControl ); void SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aControl );
/** /**
* Function OnSelectComponent * Called when clicking on a component in component list window:
* Called when clicking on a component in component list window
* * Updates the filtered footprint list, if the filtered list option is selected * * Updates the filtered footprint list, if the filtered list option is selected
* * Updates the current selected footprint in footprint list * * Updates the current selected footprint in footprint list
* * Updates the footprint shown in footprint display window (if opened) * * Updates the footprint shown in footprint display window (if opened)
@ -204,29 +174,26 @@ public:
void AutomaticFootprintMatching(); void AutomaticFootprintMatching();
/** /**
* Function SetFootprintFilter
* Set a filter criteria to either on/off or toggle the criteria. * Set a filter criteria to either on/off or toggle the criteria.
* *
* @param aFilter The filter to modify * @param aFilter The filter to modify
* @param aAction What action (on, off or toggle) to take * @param aAction What action (on, off or toggle) to take
*/ */
void SetFootprintFilter( void SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter,
FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction ); CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction );
/** /**
* Function OnEnterFilteringText * Called each time the text of m_tcFilterString is changed.
* Is called each time the text of m_tcFilterString is changed.
*/ */
void OnEnterFilteringText( wxCommandEvent& event ); void OnEnterFilteringText( wxCommandEvent& event );
/** /**
* Undo the most recent associations that were performed. * Undo the most recent associations that were performed.
*/ */
void UndoAssociation(); void UndoAssociation();
/** /**
* Redo the most recently undone association * Redo the most recently undone association.
*/ */
void RedoAssociation(); void RedoAssociation();
@ -262,26 +229,25 @@ public:
void BuildLibrariesListBox(); void BuildLibrariesListBox();
/** /**
* Function SaveFootprintAssociation * Save the edits that the user has done by sending them back to Eeschema via the kiway.
* saves the edits that the user has done by sending them back to eeschema *
* via the kiway.
* Optionally saves the schematic to disk as well. * Optionally saves the schematic to disk as well.
*/ */
bool SaveFootprintAssociation( bool doSaveSchematic ); bool SaveFootprintAssociation( bool doSaveSchematic );
/** /**
* Function ReadNetListAndFpFiles * Load the netlist file built on the fly by Eeschema and loads footprint libraries from
* loads the netlist file built on the fly by Eeschema and loads * fp lib tables.
* footprint libraries from fp lib tables. *
* @param aNetlist is the netlist from eeschema in kicad s-expr format. * @param aNetlist is the netlist from Eeschema in KiCad s-expr format.
* (see CVPCB_MAINFRAME::KiwayMailIn() to know how to get this netlist) * (see CVPCB_MAINFRAME::KiwayMailIn() to know how to get this netlist)
*/ */
bool ReadNetListAndFpFiles( const std::string& aNetlist ); bool ReadNetListAndFpFiles( const std::string& aNetlist );
/** /**
* Function ReadSchematicNetlist * Read the netlist (.net) file built on the fly by Eeschema.
* read the netlist (.net) file built on the fly by Eeschema. *
* @param aNetlist is the netlist buffer filled by eeschema, in kicad s-expr format. * @param aNetlist is the netlist buffer filled by Eeschema, in KiCad s-expr format.
* It is the same netlist as the .net file created by Eeschema. * It is the same netlist as the .net file created by Eeschema.
* (This method is called by ReadNetListAndFpFiles) * (This method is called by ReadNetListAndFpFiles)
*/ */
@ -292,8 +258,7 @@ public:
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
/** /**
* Function DisplayStatus * Update the information displayed on the status bar at bottom of the main frame.
* updates the information displayed on the status bar at bottom of the main frame.
* *
* When the library or component list controls have the focus, the footprint assignment * When the library or component list controls have the focus, the footprint assignment
* status of the components is displayed in the first status bar pane and the list of * status of the components is displayed in the first status bar pane and the list of
@ -306,24 +271,25 @@ public:
void DisplayStatus(); void DisplayStatus();
/** /**
* Function LoadFootprintFiles * Read the list of footprint (*.mod files) and generate the list of footprints.
* reads the list of footprint (*.mod files) and generate the list of footprints. *
* for each footprint are stored * For each footprint the following items are stored:
* the footprint name * - the footprint name
* documentation string * - documentation string
* associated keywords * - associated keywords
* fills m_footprints *
* @return true if libraries are found, false otherwise. * @return true if libraries are found, false otherwise.
*/ */
bool LoadFootprintFiles(); bool LoadFootprintFiles();
/** /**
* Function SendMessageToEESCHEMA
* Send a remote command to Eeschema via a socket, * Send a remote command to Eeschema via a socket,
* Commands are *
* Commands are:
* $PART: "reference" put cursor on component anchor * $PART: "reference" put cursor on component anchor
* @param aClearHighligntOnly = true if the message to send is only "clear highlight" *
* (used when exiting Cvpcb) * @param aClearHighligntOnly use true if the message to send is only "clear highlight"
* (used when exiting CvPcb)
*/ */
void SendMessageToEESCHEMA( bool aClearHighligntOnly = false ); void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
@ -371,6 +337,11 @@ public:
void SetStatusText( const wxString& aText, int aNumber = 0 ) override; void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
protected:
CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
void setupUIConditions() override;
private: private:
/** /**
* Setup the tool system for the CVPCB main frame. * Setup the tool system for the CVPCB main frame.
@ -383,16 +354,44 @@ private:
void setupEventHandlers(); void setupEventHandlers();
/** /**
* read the .equ files and populate the list of equvalents * Read the .equ files and populate the list of equivalents.
*
* @param aList the list to populate * @param aList the list to populate
* @param aErrorMessages is a pointer to a wxString to store error messages * @param aErrorMessages is a pointer to a wxString to store error messages
* (can be NULL) * (can be NULL)
* @return the error count ( 0 = no error) * @return the error count ( 0 = no error)
*/ */
int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages = NULL ); int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList,
wxString* aErrorMessages = nullptr );
void refreshAfterSymbolSearch( COMPONENT* aSymbol ); void refreshAfterSymbolSearch( COMPONENT* aSymbol );
public:
FOOTPRINT_LIST* m_FootprintsList;
protected:
bool m_modified;
bool m_skipComponentSelect; // skip component selection event during
// automatic selection/deletion of
// associations
bool m_initialized;
private:
friend struct CV::IFACE;
NETLIST m_netlist;
int m_filteringOptions;
ACTION_TOOLBAR* m_mainToolBar;
FOOTPRINTS_LISTBOX* m_footprintListBox;
LIBRARY_LISTBOX* m_librariesListBox;
COMPONENTS_LISTBOX* m_symbolsListBox;
wxTextCtrl* m_tcFilterString;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
wxStaticText* m_statusLine3;
wxButton* m_saveAndContinue;
// Tool dispatcher // Tool dispatcher
TOOL_DISPATCHER* m_toolDispatcher; TOOL_DISPATCHER* m_toolDispatcher;

View File

@ -6,7 +6,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2010-2015 Jean-Pierre Charras jp.charras at wanadoo.fr * Copyright (C) 2010-2015 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 Kicad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2021 Kicad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -33,11 +33,9 @@
class DIALOG_CONFIG_EQUFILES : public DIALOG_CONFIG_EQUFILES_BASE class DIALOG_CONFIG_EQUFILES : public DIALOG_CONFIG_EQUFILES_BASE
{ {
private: public:
CVPCB_MAINFRAME* m_Parent; DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* parent );
wxString m_UserLibDirBufferImg; ~DIALOG_CONFIG_EQUFILES() {};
bool m_ListChanged;
private: private:
void Init(); void Init();
@ -61,9 +59,10 @@ private:
return m_rbPathOptionChoice->GetSelection() == 1; return m_rbPathOptionChoice->GetSelection() == 1;
} }
public: CVPCB_MAINFRAME* m_Parent;
DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* parent ); wxString m_UserLibDirBufferImg;
~DIALOG_CONFIG_EQUFILES() {};
bool m_ListChanged;
}; };
#endif // _DIALOG_CONFIG_EQUFILES_H_ #endif // _DIALOG_CONFIG_EQUFILES_H_

View File

@ -6,7 +6,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2010-2014 Jean-Pierre Charras <jp.charras at wanadoo.fr> * Copyright (C) 2010-2014 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2014 Kicad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2021 Kicad Developers, see CHANGELOG.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,38 +31,28 @@
class DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR : public DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR_BASE class DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR : public DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR_BASE
{ {
private: public:
enum COL_ID
{
COL_REF, COL_FPSCH, COL_SELSCH, COL_SELCMP, COL_FPCMP,
COL_COUNT
};
int m_lineCount;
public:
DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR( wxWindow* parent ); DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR( wxWindow* parent );
/** /**
* Add a line to the selection list. * Add a line to the selection list.
* @param aRef = component reference text *
* @param aFpSchName = fpid text from the netlist * @param aRef is the component reference text.
* @param aFpCmpName = fpid text from the .cmp file * @param aFpSchName is the fpid text from the netlist.
* @param aFpCmpName is the fpid text from the .cmp file.
*/ */
void Add( const wxString& aRef, const wxString& aFpSchName, void Add( const wxString& aRef, const wxString& aFpSchName, const wxString& aFpCmpName );
const wxString& aFpCmpName );
/** /**
* @param aReference is the compoent schematic reference.
* @return the selection option: * @return the selection option:
* 0 for fpid text from the netlist * 0 for fpid text from the netlist
* 1 for fpid text from the cmp file * 1 for fpid text from the cmp file
* -1 on error * -1 on error
* @param aReference = the compoent schematic reference
*/ */
int GetSelection( const wxString& aReference ); int GetSelection( const wxString& aReference );
private: private:
void OnSize( wxSizeEvent& event ) override; void OnSize( wxSizeEvent& event ) override;
// Virtual: called when clicking on the column title: // Virtual: called when clicking on the column title:
@ -76,4 +66,11 @@ class DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR : public DIALOG_FP_CONFLICT_ASSIGNM
void recalculateColumns(); void recalculateColumns();
enum COL_ID
{
COL_REF, COL_FPSCH, COL_SELSCH, COL_SELCMP, COL_FPCMP,
COL_COUNT
};
int m_lineCount;
}; };

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -35,9 +35,6 @@ class FOOTPRINT_LIST;
#define LISTBOX_STYLE ( wxBORDER_NONE | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \ #define LISTBOX_STYLE ( wxBORDER_NONE | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
wxVSCROLL | wxHSCROLL ) wxVSCROLL | wxHSCROLL )
/*********************************************************************/
/* ListBox (base class) to display lists of components or footprints */
/*********************************************************************/
class ITEMS_LISTBOX_BASE : public wxListView class ITEMS_LISTBOX_BASE : public wxListView
{ {
public: public:
@ -60,8 +57,7 @@ public:
virtual CVPCB_MAINFRAME* GetParent() const; virtual CVPCB_MAINFRAME* GetParent() const;
/* Function UpdateWidth /**
*
* Update the width of the column based on its contents. * Update the width of the column based on its contents.
* *
* @param aLine is the line to calculate the width from. If positive, the * @param aLine is the line to calculate the width from. If positive, the
@ -77,16 +73,9 @@ private:
}; };
/******************************************/
/* ListBox showing the list of footprints */
/******************************************/
class FOOTPRINTS_LISTBOX : public ITEMS_LISTBOX_BASE class FOOTPRINTS_LISTBOX : public ITEMS_LISTBOX_BASE
{ {
private:
wxArrayString m_footprintList;
public: public:
/** /**
* Filter setting constants. The filter type is a bitwise OR of these flags, * Filter setting constants. The filter type is a bitwise OR of these flags,
* and only footprints matching all selected filter types are shown. * and only footprints matching all selected filter types are shown.
@ -109,15 +98,14 @@ public:
void AppendLine( const wxString& text ); void AppendLine( const wxString& text );
/** /**
* Function SetFootprints * Populate the wxListCtrl with the footprints from \a aList that meet the filter
* populates the wxListCtrl with the footprints from \a aList that meet the filter
* criteria defined by \a aFilterType. * criteria defined by \a aFilterType.
* *
* @param aList is a #FOOTPRINT_LIST item containing the footprints. * @param aList is a #FOOTPRINT_LIST item containing the footprints.
* @param aLibName is wxString containing the name of the selected library. Can be * @param aLibName is wxString containing the name of the selected library. Can be
* wxEmptyString. * wxEmptyString.
* @param aComponent is the #COMPONENT used by the filtering criteria. Can be NULL. * @param aComponent is the #COMPONENT used by the filtering criteria. Can be NULL.
* @param aFootPrintFilterPattern = a filter used to filter list by names * @param aFootPrintFilterPattern is the filter used to filter list by names.
* @param aFilterType defines the criteria to filter \a aList. * @param aFilterType defines the criteria to filter \a aList.
*/ */
void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent, void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent,
@ -126,9 +114,8 @@ public:
wxString GetSelectedFootprint(); wxString GetSelectedFootprint();
/** /**
* Function OnGetItemText * This overloaded function MUST be provided for the wxLC_VIRTUAL mode
* this overloaded function MUST be provided for the wxLC_VIRTUAL mode * because real data is not handled by ITEMS_LISTBOX_BASE.
* because real data is not handled by ITEMS_LISTBOX_BASE
*/ */
wxString OnGetItemText( long item, long column ) const override; wxString OnGetItemText( long item, long column ) const override;
@ -137,17 +124,15 @@ public:
void OnLeftDClick( wxListEvent& event ); void OnLeftDClick( wxListEvent& event );
void OnChar( wxKeyEvent& event ); void OnChar( wxKeyEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE();
private:
wxArrayString m_footprintList;
}; };
/******************************************/
/* ListBox showing the list of library */
/******************************************/
class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE
{ {
wxArrayString m_libraryList;
public: public:
LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ); LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~LIBRARY_LISTBOX(); ~LIBRARY_LISTBOX();
@ -167,33 +152,28 @@ public:
void OnSelectLibrary( wxListEvent& event ); void OnSelectLibrary( wxListEvent& event );
/** /**
* Function OnChar * Called on a key press.
* called on a key pressed *
* Call default handler for some special keys, * Call default handler for some special keys, and for "ascii" keys, select the first
* and for "ascii" keys, select the first footprint * footprint that the name starts by the letter.
* that the name starts by the letter. *
* This is the defaut behaviour of a listbox, but because we use * This is the default behavior of a listbox, but because we use virtual lists, the
* virtual lists, the listbox does not know anything to what is displayed, * listbox does not know anything to what is displayed, we must handle this behavior
* we must handle this behaviour here. * here. Furthermore the footprint name is not at the beginning of displayed lines
* Furthermore the footprint name is not at the beginning of * (the first word is the line number).
* displayed lines (the first word is the line number)
*/ */
void OnChar( wxKeyEvent& event ); void OnChar( wxKeyEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE();
private:
wxArrayString m_libraryList;
}; };
/****************************************************/
/* ListBox showing the list of schematic components */
/****************************************************/
class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE
{ {
public: public:
wxArrayString m_ComponentList;
public:
COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ); COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~COMPONENTS_LISTBOX(); ~COMPONENTS_LISTBOX();
@ -202,9 +182,8 @@ public:
int GetCount(); int GetCount();
/** /**
* Function OnGetItemText * This overloaded function MUST be provided for the wxLC_VIRTUAL mode
* this overloaded function MUST be provided for the wxLC_VIRTUAL mode * because real data is not handled by #ITEMS_LISTBOX_BASE.
* because real data is not handled by ITEMS_LISTBOX_BASE
*/ */
wxString OnGetItemText( long item, long column ) const override; wxString OnGetItemText( long item, long column ) const override;
@ -218,22 +197,24 @@ public:
// Events functions: // Events functions:
/** /**
* Function OnChar * Called on a key press.
* called on a key pressed *
* Call default handler for some special keys, * Call default handler for some special keys, and for "ascii" keys, select the first
* and for "ascii" keys, select the first component * component that the name starts by the letter.
* that the name starts by the letter. *
* This is the default behavior of a listbox, but because we use * This is the default behavior of a listbox, but because we use virtual lists, the
* virtual lists, the listbox does not know anything to what is displayed, * listbox does not know anything to what is displayed, we must handle this behavior
* we must handle this behavior here. * here. Furthermore the reference of components is not at the beginning of displayed
* Furthermore the reference of components is not at the beginning of * lines (the first word is the line number).
* displayed lines (the first word is the line number)
*/ */
void OnChar( wxKeyEvent& event ); void OnChar( wxKeyEvent& event );
void OnSelectComponent( wxListEvent& event ); void OnSelectComponent( wxListEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE();
public:
wxArrayString m_ComponentList;
}; };

View File

@ -85,11 +85,11 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ), EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ), KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ),
m_propertiesPagelayout( nullptr ),
m_propertiesFrameWidth( 200 ), m_propertiesFrameWidth( 200 ),
m_originSelectBox( nullptr ), m_originSelectBox( nullptr ),
m_originSelectChoice( 0 ), m_originSelectChoice( 0 ),
m_pageSelectBox( nullptr ), m_pageSelectBox( nullptr )
m_propertiesPagelayout( nullptr )
{ {
m_maximizeByDefault = true; m_maximizeByDefault = true;
m_userUnits = EDA_UNITS::MILLIMETRES; m_userUnits = EDA_UNITS::MILLIMETRES;
@ -202,7 +202,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
#if 0 //start with empty layout #if 0 //start with empty layout
DS_DATA_MODEL::GetTheInstance().AllowVoidList( true ); DS_DATA_MODEL::GetTheInstance().AllowVoidList( true );
DS_DATA_MODEL::GetTheInstance().ClearList(); DS_DATA_MODEL::GetTheInstance().ClearList();
#else // start with the default Kicad layout #else // start with the default KiCad layout
DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet(); DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet();
#endif #endif
OnNewDrawingSheet(); OnNewDrawingSheet();
@ -283,17 +283,25 @@ void PL_EDITOR_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) ); mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) );
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); mgr->SetConditions( ACTIONS::zoomTool,
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) ); CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
mgr->SetConditions( ACTIONS::deleteTool, CHECK( cond.CurrentTool( ACTIONS::deleteTool ) ) ); mgr->SetConditions( ACTIONS::selectionTool,
CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
mgr->SetConditions( ACTIONS::deleteTool,
CHECK( cond.CurrentTool( ACTIONS::deleteTool ) ) );
mgr->SetConditions( PL_ACTIONS::drawLine, CHECK( cond.CurrentTool( PL_ACTIONS::drawLine ) ) ); mgr->SetConditions( PL_ACTIONS::drawLine,
mgr->SetConditions( PL_ACTIONS::drawRectangle, CHECK( cond.CurrentTool( PL_ACTIONS::drawRectangle ) ) ); CHECK( cond.CurrentTool( PL_ACTIONS::drawLine ) ) );
mgr->SetConditions( PL_ACTIONS::placeText, CHECK( cond.CurrentTool( PL_ACTIONS::placeText ) ) ); mgr->SetConditions( PL_ACTIONS::drawRectangle,
mgr->SetConditions( PL_ACTIONS::placeImage, CHECK( cond.CurrentTool( PL_ACTIONS::placeImage ) ) ); CHECK( cond.CurrentTool( PL_ACTIONS::drawRectangle ) ) );
mgr->SetConditions( PL_ACTIONS::placeText,
CHECK( cond.CurrentTool( PL_ACTIONS::placeText ) ) );
mgr->SetConditions( PL_ACTIONS::placeImage,
CHECK( cond.CurrentTool( PL_ACTIONS::placeImage ) ) );
// Not a tool, just a way to activate the action // Not a tool, just a way to activate the action
mgr->SetConditions( PL_ACTIONS::appendImportedDrawingSheet, CHECK( SELECTION_CONDITIONS::ShowNever ) ); mgr->SetConditions( PL_ACTIONS::appendImportedDrawingSheet,
CHECK( SELECTION_CONDITIONS::ShowNever ) );
auto titleBlockNormalMode = auto titleBlockNormalMode =
[] ( const SELECTION& ) [] ( const SELECTION& )
@ -392,8 +400,6 @@ void PL_EDITOR_FRAME::doCloseWindow()
} }
/* Handles the selection of tools, menu, and popup menu commands.
*/
void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event ) void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event )
{ {
KIGFX::VIEW* view = GetCanvas()->GetView(); KIGFX::VIEW* view = GetCanvas()->GetView();
@ -403,9 +409,6 @@ void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event )
} }
/* called when the user select one of the 4 page corner as corner
* reference (or the left top paper corner)
*/
void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event ) void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
{ {
m_originSelectChoice = m_originSelectBox->GetSelection(); m_originSelectChoice = m_originSelectBox->GetSelection();
@ -423,7 +426,7 @@ void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
const PAGE_INFO& pageInfo = GetPageSettings(); const PAGE_INFO& pageInfo = GetPageSettings();
if( s_PrintData == NULL ) // First print if( s_PrintData == nullptr ) // First print
{ {
s_PrintData = new wxPrintData(); s_PrintData = new wxPrintData();
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH; s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
@ -435,7 +438,7 @@ void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
return; return;
} }
if( s_pageSetupData == NULL ) if( s_pageSetupData == nullptr )
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
@ -474,7 +477,8 @@ void PL_EDITOR_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) ); book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
book->AddSubPage( new PANEL_PL_EDITOR_COLOR_SETTINGS( this, aParent->GetTreebook() ), _( "Colors" ) ); book->AddSubPage( new PANEL_PL_EDITOR_COLOR_SETTINGS( this, aParent->GetTreebook() ),
_( "Colors" ) );
aHotkeysPanel->AddHotKeys( GetToolManager() ); aHotkeysPanel->AddHotKeys( GetToolManager() );
} }
@ -653,9 +657,6 @@ wxPoint PL_EDITOR_FRAME::ReturnCoordOriginCorner() const
} }
/*
* Display the grid status.
*/
void PL_EDITOR_FRAME::DisplayGridMsg() void PL_EDITOR_FRAME::DisplayGridMsg()
{ {
wxString line; wxString line;
@ -810,7 +811,7 @@ void PL_EDITOR_FRAME::HardRedraw()
DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType ) DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
{ {
DS_DATA_ITEM * item = NULL; DS_DATA_ITEM * item = nullptr;
switch( aType ) switch( aType )
{ {
@ -837,7 +838,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
wxFD_OPEN ); wxFD_OPEN );
if( fileDlg.ShowModal() != wxID_OK ) if( fileDlg.ShowModal() != wxID_OK )
return NULL; return nullptr;
wxString fullFilename = fileDlg.GetPath(); wxString fullFilename = fileDlg.GetPath();
@ -856,15 +857,15 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
break; break;
} }
// Set the scale factor for pl_editor (it is set for eeschema by default) // Set the scale factor for pl_editor (it is set for Eeschema by default)
image->SetPixelSizeIu( IU_PER_MILS * 1000.0 / image->GetPPI() ); image->SetPixelSizeIu( IU_PER_MILS * 1000.0 / image->GetPPI() );
item = new DS_DATA_ITEM_BITMAP( image ); item = new DS_DATA_ITEM_BITMAP( image );
} }
break; break;
} }
if( item == NULL ) if( item == nullptr )
return NULL; return nullptr;
DS_DATA_MODEL::GetTheInstance().Append( item ); DS_DATA_MODEL::GetTheInstance().Append( item );
item->SyncDrawItems( nullptr, GetCanvas()->GetView() ); item->SyncDrawItems( nullptr, GetCanvas()->GetView() );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 CERN * Copyright (C) 2013 CERN
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -40,29 +40,10 @@ class wxChoice;
/** /**
* PL_EDITOR_FRAME * The main window used in the drawing sheet editor.
* is the main window used in the drawing sheet editor.
*/ */
class PL_EDITOR_FRAME : public EDA_DRAW_FRAME class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
{ {
PL_EDITOR_LAYOUT m_pageLayout;
int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
wxChoice* m_originSelectBox; // Corner origin choice for coordinates
int m_originSelectChoice; // the last choice for m_originSelectBox
wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
// usefull when there are some items which are
// only on page 1, not on page 1
wxPoint m_grid_origin;
protected:
/// The last filename chosen to be proposed to the user
PROPERTIES_FRAME* m_propertiesPagelayout;
void setupUIConditions() override;
public: public:
PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ); PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
~PL_EDITOR_FRAME(); ~PL_EDITOR_FRAME();
@ -77,23 +58,23 @@ public:
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override; bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
/** /**
* Function LoadDrawingSheetFile * Load a .kicad_wks drawing sheet file.
* Loads a .kicad_wks drawing sheet file *
* @param aFullFileName = the filename. * @param aFullFileName is the filename.
*/ */
bool LoadDrawingSheetFile( const wxString& aFullFileName ); bool LoadDrawingSheetFile( const wxString& aFullFileName );
/** /**
* Function SaveDrawingSheetFile * Save the current layout in a .kicad_wks drawing sheet file.
* Save the current layout in a .kicad_wks drawing sheet file *
* @param aFullFileName = the filename. * @param aFullFileName is the filename.
*/ */
bool SaveDrawingSheetFile( const wxString& aFullFileName ); bool SaveDrawingSheetFile( const wxString& aFullFileName );
/** /**
* Function InsertDrawingSheetFile * Load a .kicad_wks drawing sheet file, and add items to the current layout list.
* Loads a .kicad_wks drawing sheet file, and add items to the current layout list *
* @param aFullFileName = the filename. * @param aFullFileName is the filename.
*/ */
bool InsertDrawingSheetFile( const wxString& aFullFileName ); bool InsertDrawingSheetFile( const wxString& aFullFileName );
@ -104,16 +85,15 @@ public:
*/ */
bool IsContentModified() const override; bool IsContentModified() const override;
/* /**
* Function OnExit * Event handler for the wxID_EXIT and wxID_CLOSE events.
* Event handler for the wxID_EXIT and wxID_CLOSE events
*/ */
void OnExit( wxCommandEvent& aEvent ); void OnExit( wxCommandEvent& aEvent );
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override; bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
void doCloseWindow() override; void doCloseWindow() override;
// The Tool Framework initalization // The Tool Framework initialization
void setupTools(); void setupTools();
// Virtual basic functions: // Virtual basic functions:
@ -131,8 +111,8 @@ public:
void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; } void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; }
/** /**
* calculate the position (in page, in iu) of the corner used as coordinate origin * Calculate the position (in page, in iu) of the corner used as coordinate origin
* of items * of items.
*/ */
wxPoint ReturnCoordOriginCorner() const; wxPoint ReturnCoordOriginCorner() const;
@ -151,12 +131,13 @@ public:
void OnNewDrawingSheet(); void OnNewDrawingSheet();
/** /**
* creates or updates the right vertical toolbar. * Create or update the right vertical toolbar.
*/ */
void ReCreateVToolbar() override; void ReCreateVToolbar() override;
/** /**
* Create or update the left vertical toolbar (option toolbar * Create or update the left vertical toolbar.
*
* @note This is currently not used. * @note This is currently not used.
*/ */
void ReCreateOptToolbar() override; void ReCreateOptToolbar() override;
@ -170,14 +151,16 @@ public:
/** /**
* Drawing sheet editor can show the title block using a page number 1 or another number. * Drawing sheet editor can show the title block using a page number 1 or another number.
*
* This is because some items can be shown (or not) only on page 1 (a feature which * This is because some items can be shown (or not) only on page 1 (a feature which
* looks like word processing option "page 1 differs from other pages"). * looks like word processing option "page 1 differs from other pages").
* @return true if the page 1 is selected, and false if not *
* @return true if the page 1 is selected, and false if not.
*/ */
bool GetPageNumberOption() const; bool GetPageNumberOption() const;
/** /**
* Displays the short filename (if exists) loaded file on the caption of the main window * Display the short filename (if exists) loaded file on the caption of the main window.
*/ */
void UpdateTitleAndInfo(); void UpdateTitleAndInfo();
@ -190,8 +173,8 @@ public:
void OnSelectPage( wxCommandEvent& event ); void OnSelectPage( wxCommandEvent& event );
/** /**
* called when the user select one of the 4 page corner as corner reference (or the * Called when the user select one of the 4 page corner as corner reference (or the
* left top paper corner) * left top paper corner).
*/ */
void OnSelectCoordOriginCorner( wxCommandEvent& event ); void OnSelectCoordOriginCorner( wxCommandEvent& event );
@ -205,16 +188,16 @@ public:
void OnSelectTitleBlockDisplayMode( wxCommandEvent& event ); void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
/** /**
* Function ToPrinter * Open a dialog frame to print layers.
* Open a dialog frame to print layers
*/ */
void ToPrinter( bool doPreview ); void ToPrinter( bool doPreview );
void Files_io( wxCommandEvent& event ); void Files_io( wxCommandEvent& event );
/** Virtual function PrintPage /**
* used to print a page * Print a page.
* @param aDC = wxDC given by the calling print function *
* @param aDC is the device context used by the print function.
*/ */
virtual void PrintPage( const RENDER_SETTINGS* aSettings ) override; virtual void PrintPage( const RENDER_SETTINGS* aSettings ) override;
@ -223,33 +206,33 @@ public:
/** /**
* @return the filename of the current layout descr file * @return the filename of the current layout descr file
* If this is the default (no loaded file) returns a emtpy name * If this is the default (no loaded file) returns a empty name
* or a new design. * or a new design.
*/ */
wxString GetCurrentFileName() const override; wxString GetCurrentFileName() const override;
/** /**
* Stores the current layout descr file filename * Store the current layout description file filename.
*/ */
void SetCurrentFileName( const wxString& aName ); void SetCurrentFileName( const wxString& aName );
/** /**
* Refresh the library tree and redraw the window * Refresh the library tree and redraw the window.
*/ */
void HardRedraw() override; void HardRedraw() override;
/** /**
* Function AddDrawingSheetItem
* Add a new item to the drawing sheet item list. * Add a new item to the drawing sheet item list.
* @param aType = the type of item: *
* @param aType is the type of item:
* DS_TEXT, DS_SEGMENT, DS_RECT, DS_POLYPOLYGON * DS_TEXT, DS_SEGMENT, DS_RECT, DS_POLYPOLYGON
* @param aIdx = the position in list to insert the new item. * @param aIdx is the position in list to insert the new item.
* @return a reference to the new item * @return a reference to the new item.
*/ */
DS_DATA_ITEM* AddDrawingSheetItem( int aType ); DS_DATA_ITEM* AddDrawingSheetItem( int aType );
/** /**
* Must be called after a change in order to set the "modify" flag * Must be called after a change in order to set the "modify" flag.
*/ */
void OnModify() void OnModify()
{ {
@ -261,33 +244,49 @@ public:
*/ */
void SaveCopyInUndoList(); void SaveCopyInUndoList();
/** Redo the last edit: /**
* - Place the current edited layout in undo list * Redo the last edit:
* - Get the previous version of the current edited layput * - Place the current edited layout in undo list.
* - Get the previous version of the current edited layout.
*/ */
void GetLayoutFromRedoList(); void GetLayoutFromRedoList();
/** Undo the last edit: /**
* - Place the current layout in Redo list * Undo the last edit:
* - Get the previous version of the current edited layout * - Place the current layout in Redo list.
* - Get the previous version of the current edited layout.
*/ */
void GetLayoutFromUndoList(); void GetLayoutFromUndoList();
/** /**
* Apply the last command in Undo List without stacking a Redo. Used to clean the * Apply the last command in Undo List without stacking a Redo. Used to clean the
* Undo stack after cancelling a command. * Undo stack after canceling a command.
*/ */
void RollbackFromUndo(); void RollbackFromUndo();
/**
* Function ClearUndoORRedoList
*/
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override; void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
protected: protected:
bool saveCurrentPageLayout(); bool saveCurrentPageLayout();
DECLARE_EVENT_TABLE() void setupUIConditions() override;
DECLARE_EVENT_TABLE();
/// The last filename chosen to be proposed to the user
PROPERTIES_FRAME* m_propertiesPagelayout;
private:
PL_EDITOR_LAYOUT m_pageLayout;
int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
wxChoice* m_originSelectBox; // Corner origin choice for coordinates
int m_originSelectChoice; // the last choice for m_originSelectBox
wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
// useful when there are some items which are
// only on page 1, not on page 1
wxPoint m_grid_origin;
}; };
#endif /* _PL_EDITOR_FRAME_H */ #endif /* _PL_EDITOR_FRAME_H */

View File

@ -5,6 +5,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 CERN * Copyright (C) 2013 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -33,18 +34,8 @@
#include <drawing_sheet/ds_draw_item.h> #include <drawing_sheet/ds_draw_item.h>
/**
* PL_EDITOR_LAYOUT
*/
class PL_EDITOR_LAYOUT class PL_EDITOR_LAYOUT
{ {
private:
EDA_RECT m_boundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
DS_DRAW_ITEM_LIST m_drawItemList;
public: public:
PL_EDITOR_LAYOUT(); PL_EDITOR_LAYOUT();
~PL_EDITOR_LAYOUT(); ~PL_EDITOR_LAYOUT();
@ -69,15 +60,14 @@ public:
} }
/** /**
* Function ComputeBoundingBox * Calculate the bounding box containing all Gerber items.
* calculates the bounding box containing all Gerber items. *
* @return EDA_RECT - the full item list bounding box * @return the full item list bounding box.
*/ */
EDA_RECT ComputeBoundingBox(); EDA_RECT ComputeBoundingBox();
/** /**
* Function GetBoundingBox * Called soon after ComputeBoundingBox() to return the same EDA_RECT,
* may be called soon after ComputeBoundingBox() to return the same EDA_RECT,
* as long as the CLASS_PL_EDITOR_LAYOUT has not changed. * as long as the CLASS_PL_EDITOR_LAYOUT has not changed.
*/ */
const EDA_RECT GetBoundingBox() const { return m_boundingBox; } const EDA_RECT GetBoundingBox() const { return m_boundingBox; }
@ -89,6 +79,13 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; void Show( int nestLevel, std::ostream& os ) const;
#endif #endif
private:
EDA_RECT m_boundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
DS_DRAW_ITEM_LIST m_drawItemList;
}; };
#endif // #ifndef CLASS_PL_EDITOR_LAYOUT_H #endif // #ifndef CLASS_PL_EDITOR_LAYOUT_H

View File

@ -35,6 +35,10 @@ public:
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
protected:
virtual std::string getLegacyFrameName() const override { return "PlEditorFrame"; }
public:
int m_CornerOrigin; int m_CornerOrigin;
int m_PropertiesFrameWidth; int m_PropertiesFrameWidth;
wxString m_LastPaperSize; wxString m_LastPaperSize;
@ -42,10 +46,6 @@ public:
int m_LastCustomHeight; int m_LastCustomHeight;
bool m_LastWasPortrait; bool m_LastWasPortrait;
bool m_BlackBackground; bool m_BlackBackground;
protected:
virtual std::string getLegacyFrameName() const override { return "PlEditorFrame"; }
}; };

View File

@ -6,7 +6,7 @@
* Attenuator Synthesis * Attenuator Synthesis
* *
* From Qucs * From Qucs
* Modified for Kicad * Modified for KiCad
*/ */
#ifndef ATTENUATORFUNC_H #ifndef ATTENUATORFUNC_H
@ -24,18 +24,40 @@ enum ATTENUATORS_TYPE {
class ATTENUATOR class ATTENUATOR
{ {
protected:
ATTENUATORS_TYPE m_Topology;
public: public:
wxString m_Name; // Identifier for config virtual ~ATTENUATOR();
/**
* Calculates the values of components in attenuator.
*
* @return true if OK, false if some values cannot be calculated.
*/
virtual bool Calculate();
/**
* Read values stored in config for this attenuator.
*/
void ReadConfig();
/**
* Read values stored in config for this attenuator.
*/
void WriteConfig();
protected:
// The constructor is protected, because this class is not intended to be instanciated.
ATTENUATOR( ATTENUATORS_TYPE Topology );
public:
wxString m_Name; // Identifier for configuration.
int m_ResultCount; // Number of value to calculate, and therefore display int m_ResultCount; // Number of value to calculate, and therefore display
bool m_Error; // Set to true if values acnnot be calculated bool m_Error; // Set to true if values cannot be calculated
double m_Zin; // Impedance of source double m_Zin; // Impedance of source
bool m_Zin_Enable; // Set to true when impedance of source has meaning bool m_Zin_Enable; // Set to true when impedance of source has meaning
double m_Zout; // Impedance of load double m_Zout; // Impedance of load
double m_Attenuation; // Attenuation in dB double m_Attenuation; // Attenuation in dB
bool m_Attenuation_Enable; // Set to true when Attenuatiopn has meaning bool m_Attenuation_Enable; // Set to true when Attenuation has meaning
double m_MinimumATT; // Minimun attenuation in dB from parameters double m_MinimumATT; // Minimum attenuation in dB from parameters
double m_R1; // value of R1 double m_R1; // value of R1
double m_R2; // value of R2 double m_R2; // value of R2
double m_R3; // value of R3 (if any) double m_R3; // value of R3 (if any)
@ -43,33 +65,8 @@ public:
wxString* m_FormulaName; // The HTML/markdown text name of the formula wxString* m_FormulaName; // The HTML/markdown text name of the formula
protected: protected:
ATTENUATORS_TYPE m_Topology;
double Lmin, L, A; // internal variable for temporary use double Lmin, L, A; // internal variable for temporary use
protected:
// The constructor is protected, because this class is not intended to be instancied
ATTENUATOR( ATTENUATORS_TYPE Topology );
public:
virtual ~ATTENUATOR();
/**
* Function Calculate
* calculates the values of components in attenuator
* @return true if ok, false if some values cannot be calculated
*/
virtual bool Calculate();
/**
* Function ReadConfig
* Read values stored in config for this attenuator
*/
void ReadConfig();
/**
* Function WriteConfig
* Read values stored in config for this attenuator
*/
void WriteConfig();
}; };
class ATTENUATOR_PI : public ATTENUATOR class ATTENUATOR_PI : public ATTENUATOR

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 1992-2011 jean-pierre.charras * Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2021 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,13 +39,6 @@
// Helper class to store parameters for a regulator // Helper class to store parameters for a regulator
class REGULATOR_DATA class REGULATOR_DATA
{ {
public:
wxString m_Name; // Regulator name
int m_Type; // type: with separate sense pin (normal) (=0)
// or adjustable 3 pins reg (=1)
double m_Vref; // Vreference in volt
double m_Iadj; // 3 pin type only: I adjust in micro amp
public: public:
REGULATOR_DATA( const wxString& aName, double aVref, int aType, double aIadj = 0) REGULATOR_DATA( const wxString& aName, double aVref, int aType, double aIadj = 0)
{ {
@ -54,14 +47,18 @@ public:
m_Name = aName; m_Name = aName;
m_Iadj = aIadj; m_Iadj = aIadj;
} }
public:
wxString m_Name; // Regulator name
int m_Type; // type: with separate sense pin (normal) (=0)
// or adjustable 3 pins reg (=1)
double m_Vref; // Vreference in volt
double m_Iadj; // 3 pin type only: I adjust in micro amp
}; };
// Helper class to store the list of known regulators // Helper class to store the list of known regulators
class REGULATOR_LIST class REGULATOR_LIST
{ {
public:
std::vector <REGULATOR_DATA*> m_List;
public: public:
REGULATOR_LIST() {}; REGULATOR_LIST() {};
~REGULATOR_LIST() ~REGULATOR_LIST()
@ -142,6 +139,8 @@ public:
return list; return list;
} }
std::vector <REGULATOR_DATA*> m_List;
}; };
#endif // CLASS_REGULATOR_DATA_H #endif // CLASS_REGULATOR_DATA_H

View File

@ -3,7 +3,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -30,22 +30,23 @@ class PCB_CALCULATOR_DATAFILE_PARSER;
*/ */
class PCB_CALCULATOR_DATAFILE class PCB_CALCULATOR_DATAFILE
{ {
friend class PCB_CALCULATOR_DATAFILE_PARSER;
protected:
REGULATOR_LIST * m_list;
public: public:
PCB_CALCULATOR_DATAFILE( REGULATOR_LIST * aList ); PCB_CALCULATOR_DATAFILE( REGULATOR_LIST * aList );
int WriteHeader( OUTPUTFORMATTER* aFormatter ) const ; int WriteHeader( OUTPUTFORMATTER* aFormatter ) const ;
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel ) const ; void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel ) const ;
void Parse( PCB_CALCULATOR_DATAFILE_PARSER* aParser ); void Parse( PCB_CALCULATOR_DATAFILE_PARSER* aParser );
private:
friend class PCB_CALCULATOR_DATAFILE_PARSER;
protected:
REGULATOR_LIST* m_list;
}; };
/** /**
* PCB_CALCULATOR_DATAFILE_PARSER * Parser for PCB_CALCULATOR_DATAFILE.
* is the parser class for PCB_CALCULATOR_DATAFILE.
*/ */
class PCB_CALCULATOR_DATAFILE_PARSER : public PCB_CALCULATOR_DATAFILE_LEXER class PCB_CALCULATOR_DATAFILE_PARSER : public PCB_CALCULATOR_DATAFILE_LEXER
{ {

View File

@ -34,18 +34,62 @@ class KIWAY;
class PCB_CALCULATOR_SETTINGS; class PCB_CALCULATOR_SETTINGS;
/* /**
* Class PCB_CALCULATOR_FRAME_BASE * PCB calculator the main frame.
* This is the main frame for this application
*/ */
class PCB_CALCULATOR_FRAME : public PCB_CALCULATOR_FRAME_BASE class PCB_CALCULATOR_FRAME : public PCB_CALCULATOR_FRAME_BASE
{ {
public: public:
REGULATOR_LIST m_RegulatorList; // the list of known regulator
PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ); PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
~PCB_CALCULATOR_FRAME(); ~PCB_CALCULATOR_FRAME();
/**
* Read/write params values and results.
*
* @param aPrmId is the parameter id to write.
* @param aValue is the value to write.
*/
void SetPrmValue( enum PRMS_ID aPrmId, double aValue );
/**
* Put the text into the given result line.
*
* @param aLineNumber is the line (0 to 5) where to display the text.
* @param aText is the text to display.
*/
void SetResult( int aLineNumber, const wxString& aText );
/**
* Set the background color of a parameter.
*
* @param aPrmId is the parameter id to set.
* @param aCol is the new color.
*/
void SetPrmBgColor( enum PRMS_ID aPrmId, const KIGFX::COLOR4D* aCol );
/**
* Return a param value.
*
* @param aPrmId is the parameter id to write.
* @return the value always in normalized unit (meter, Hz, Ohm, radian).
*/
double GetPrmValue( enum PRMS_ID aPrmId ) const;
/**
* @return true if the parameter aPrmId is selected.
*/
bool IsPrmSelected( enum PRMS_ID aPrmId ) const;
// Board classes panel:
void OnBoardClassesUnitsSelection( wxCommandEvent& event ) override;
void BoardClassesUpdateData( double aUnitScale );
// Calculator doesn't host a tool framework
wxWindow* GetToolCanvas() const override
{
return nullptr;
}
private: private:
// Event handlers // Event handlers
void OnClosePcbCalc( wxCloseEvent& event ) override; void OnClosePcbCalc( wxCloseEvent& event ) override;
@ -67,8 +111,9 @@ private:
/** /**
* Initialize the full filename of the selected pcb_calculator data file * Initialize the full filename of the selected pcb_calculator data file
* force the standard extension of the file (.pcbcalc) * force the standard extension of the file (.pcbcalc).
* @param aFilename = the full filename, with or without extension *
* @param aFilename is the full filename, with or without extension.
*/ */
void SetDataFilename( const wxString& aFilename ); void SetDataFilename( const wxString& aFilename );
@ -86,117 +131,93 @@ private:
void OnCalculateESeries( wxCommandEvent& event ) override; void OnCalculateESeries( wxCommandEvent& event ) override;
/** /**
* Radio Buttons to select the E-serie for the resistor calculator * Radio Buttons to select the E-serie for the resistor calculator.
* @param event contains the radio button state *
* @param event contains the radio button state.
*/ */
void OnESeriesSelection( wxCommandEvent& event ) override; void OnESeriesSelection( wxCommandEvent& event ) override;
/** /**
* Function writeTrackWidthConfig * Write track width parameters in configuration.
* Write Track width parameters in config
*/ */
void writeTrackWidthConfig(); void writeTrackWidthConfig();
/** /**
* Function OnTWParametersChanged * Update the calculations the user changes the general parameters.
* Called when the user changes the general parameters (i.e., anything that
* is not one of the controlling values). This update the calculations.
*/ */
void OnTWParametersChanged( wxCommandEvent& event ) override; void OnTWParametersChanged( wxCommandEvent& event ) override;
/** /**
* Function OnTWCalculateFromCurrent * Update the calculations when the user changes the desired maximum current.
* Called when the user changes the desired maximum current. This sets the
* current as the controlling value and performs the calculations.
*/ */
void OnTWCalculateFromCurrent( wxCommandEvent& event ) override; void OnTWCalculateFromCurrent( wxCommandEvent& event ) override;
/** /**
* Function OnTWCalculateFromExtWidth * Update the calculations when the user changes the desired external trace width.
* Called when the user changes the desired external trace width. This sets
* the external width as the controlling value and performs the calculations.
*/ */
void OnTWCalculateFromExtWidth( wxCommandEvent& event ) override; void OnTWCalculateFromExtWidth( wxCommandEvent& event ) override;
/** /**
* Function OnTWCalculateFromIntWidth * Update the calculations when the user changes the desired internal trace width.
* Called when the user changes the desired internal trace width. This sets
* the internal width as the controlling value and performs the calculations.
*/ */
void OnTWCalculateFromIntWidth( wxCommandEvent& event ) override; void OnTWCalculateFromIntWidth( wxCommandEvent& event ) override;
/** /**
* Function OnTWResetButtonClick * Update the calculations when the user clicks the reset button.
* Called when the user clicks the reset button. This sets
* the parameters to their default values.
*/ */
void OnTWResetButtonClick( wxCommandEvent& event ) override; void OnTWResetButtonClick( wxCommandEvent& event ) override;
/** /**
* Function TWCalculateWidth
* Calculate track width required based on given current and temperature rise. * Calculate track width required based on given current and temperature rise.
*/ */
double TWCalculateWidth( double aCurrent, double aThickness, double aDeltaT_C, double TWCalculateWidth( double aCurrent, double aThickness, double aDeltaT_C,
bool aUseInternalLayer ); bool aUseInternalLayer );
/** /**
* Function TWCalculateCurrent
* Calculate maximum current based on given width and temperature rise. * Calculate maximum current based on given width and temperature rise.
*/ */
double TWCalculateCurrent( double aWidth, double aThickness, double aDeltaT_C, double TWCalculateCurrent( double aWidth, double aThickness, double aDeltaT_C,
bool aUseInternalLayer ); bool aUseInternalLayer );
/** /**
* Function TWDisplayValues * Display the results of a calculation (including resulting values such
* Displays the results of a calculation (including resulting values such
* as the resistance and power loss). * as the resistance and power loss).
*/ */
void TWDisplayValues( double aCurrent, double aExtWidth, double aIntWidth, void TWDisplayValues( double aCurrent, double aExtWidth, double aIntWidth,
double aExtThickness, double aIntThickness ); double aExtThickness, double aIntThickness );
/** /**
* Function TWUpdateModeDisplay * Update the fields to show whether the maximum current, external trace
* Updates the fields to show whether the maximum current, external trace
* width, or internal trace width is currently the controlling parameter. * width, or internal trace width is currently the controlling parameter.
*/ */
void TWUpdateModeDisplay(); void TWUpdateModeDisplay();
/** /**
* Function writeViaSizeConfig * Write via size parameters in configuration.
* Write Via Size parameters in config
*/ */
void writeViaSizeConfig(); void writeViaSizeConfig();
/** /**
* Function OnViaCalculate * Called when the user changes any value in the via calculator.
* Called when the user changes any value in the via calcultor.
*/ */
void OnViaCalculate( wxCommandEvent& event ) override; void OnViaCalculate( wxCommandEvent& event ) override;
/**
* Function OnViaEpsilonR_Button
*/
void OnViaEpsilonR_Button( wxCommandEvent& event ) override; void OnViaEpsilonR_Button( wxCommandEvent& event ) override;
/**
* Function OnViaRho_Button
*/
void OnViaRho_Button( wxCommandEvent& event ) override; void OnViaRho_Button( wxCommandEvent& event ) override;
/** /**
* Update the Error message in Via calculation panel * Update the Error message in via calculation panel.
*/ */
void onUpdateViaCalcErrorText( wxUpdateUIEvent& event ) override; void onUpdateViaCalcErrorText( wxUpdateUIEvent& event ) override;
/** /**
* Function OnViaResetButtonClick
* Called when the user clicks the reset button; sets the parameters to their default values. * Called when the user clicks the reset button; sets the parameters to their default values.
*/ */
void OnViaResetButtonClick( wxCommandEvent& event ) override; void OnViaResetButtonClick( wxCommandEvent& event ) override;
/** /**
* Function VSDisplayValues * Display the results of the calculation.
* Displays the results of the calculation.
*/ */
void VSDisplayValues( double aViaResistance, double aVoltageDrop, double aPowerLoss, void VSDisplayValues( double aViaResistance, double aVoltageDrop, double aPowerLoss,
double aEstimatedAmpacity, double aThermalResistance, double aEstimatedAmpacity, double aThermalResistance,
@ -209,64 +230,58 @@ private:
void ElectricalSpacingUpdateData( double aUnitScale ); void ElectricalSpacingUpdateData( double aUnitScale );
/** /**
* Function OnTranslineSelection * Called on new transmission line selection.
* Called on new transmission line selection
*/ */
void OnTranslineSelection( wxCommandEvent& event ) override; void OnTranslineSelection( wxCommandEvent& event ) override;
/** /**
* Function OnTransLineResetButtonClick
* Called when the user clicks the reset button; sets the parameters to their default values. * Called when the user clicks the reset button; sets the parameters to their default values.
*/ */
void OnTransLineResetButtonClick( wxCommandEvent& event ) override; void OnTransLineResetButtonClick( wxCommandEvent& event ) override;
/** /**
* Function OnTranslineAnalyse * Run a new analyze for the current transline with current parameters and displays the
* Run a new analyse for the current transline with current parameters and displays the * electrical parameters.
* electrical parameters
*/ */
void OnTranslineAnalyse( wxCommandEvent& event ) override; void OnTranslineAnalyse( wxCommandEvent& event ) override;
/** /**
* Function OnTranslineSynthetize * Run a new synthesis for the current transline with current parameters and displays the
* Run a new synthezis for the current transline with current parameters and displays the * geometrical parameters.
* geometrical parameters
*/ */
void OnTranslineSynthetize( wxCommandEvent& event ) override; void OnTranslineSynthetize( wxCommandEvent& event ) override;
/** /**
* Function OnTranslineEpsilonR_Button
* Shows a list of current relative dielectric constant(Er) and set the selected value in * Shows a list of current relative dielectric constant(Er) and set the selected value in
* main dialog frame * main dialog frame.
*/ */
void OnTranslineEpsilonR_Button( wxCommandEvent& event ) override; void OnTranslineEpsilonR_Button( wxCommandEvent& event ) override;
/** /**
* Function OnTranslineTanD_Button * Show a list of current dielectric loss factor (tangent delta) and set the selected value
* Shows a list of current dielectric loss factor (tangent delta) and set the selected value * in main dialog frame.
* in main dialog frame
*/ */
void OnTranslineTanD_Button( wxCommandEvent& event ) override; void OnTranslineTanD_Button( wxCommandEvent& event ) override;
/** /**
* Function OnTranslineRho_Button * Show a list of current Specific resistance list (rho) and set the selected value in main
* Shows a list of current Specific resistance list (rho) and set the selected value in main * dialog frame.
* dialog frame
*/ */
void OnTranslineRho_Button( wxCommandEvent& event ) override; void OnTranslineRho_Button( wxCommandEvent& event ) override;
/** /**
* Function TranslineTypeSelection * Must be called after selection of a new transline.
* Must be called after selection of a new transline. Update all values, labels and tool *
* tips of parameters needed by the new transline; irrelevant parameters are blanked. * Update all values, labels and tool tips of parameters needed by the new transline;
* @param aType = the TRANSLINE_TYPE_ID of the new selected transline * irrelevant parameters are blanked.
*
* @param aType is the #TRANSLINE_TYPE_ID of the new selected transmission line.
*/ */
void TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType ); void TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType );
/** /**
* Function TransfDlgDataToTranslineParams * Read values entered in dialog frame, and transfer these values in current transline
* Read values entered in dialog frame, and transfert these values in current transline * parameters, converted in normalized units.
* parameters, converted in normalized units
*/ */
void TransfDlgDataToTranslineParams(); void TransfDlgDataToTranslineParams();
@ -293,14 +308,13 @@ private:
void OnRemoveRegulator( wxCommandEvent& event ) override; void OnRemoveRegulator( wxCommandEvent& event ) override;
/** /**
* Function RegulatorPageUpdate: * Update the regulator page dialog display.
* Update the regulator page dialog display: *
* enable the current regulator drawings and the formula used for calculations * Enable the current regulator drawings and the formula used for calculations.
*/ */
void RegulatorPageUpdate(); void RegulatorPageUpdate();
/** /**
* Function SelectLastSelectedRegulator
* If m_lastSelectedRegulatorName is empty, just calls RegulatorPageUpdate() * If m_lastSelectedRegulatorName is empty, just calls RegulatorPageUpdate()
*/ */
void SelectLastSelectedRegulator(); void SelectLastSelectedRegulator();
@ -308,63 +322,17 @@ private:
void RegulatorsSolve(); void RegulatorsSolve();
/** /**
* Write regulators parameters in config * Write regulators parameters in configuration.
* @param aCfg is the config settings *
* @param aCfg is the configuration settings.
*/ */
void Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg ); void Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg );
public: public:
// Read/write params values and results REGULATOR_LIST m_RegulatorList; // the list of known regulator
/**
* Function SetPrmValue
* Read/write params values and results
* @param aPrmId = param id to write
* @param aValue = valmue to write
*/
void SetPrmValue( enum PRMS_ID aPrmId, double aValue );
/**
* Function SetResult
* Puts the text into the given result line.
* @param aLineNumber = the line (0 to 5) wher to display the text
* @param aText = the text to display
*/
void SetResult( int aLineNumber, const wxString& aText );
/** Function SetPrgmBgColor
* Set the background color of a parameter
* @param aPrmId = param id to set
* @param aCol = new color
*/
void SetPrmBgColor( enum PRMS_ID aPrmId, const KIGFX::COLOR4D* aCol );
/**
* Function GetPrmValue
* Returns a param value.
* @param aPrmId = param id to write
* @return the value always in normalized unit (meter, Hz, Ohm, radian)
*/
double GetPrmValue( enum PRMS_ID aPrmId ) const;
/**
* Function IsPrmSelected
* @return true if the param aPrmId is selected
* Has meaning only for params that have a radio button
*/
bool IsPrmSelected( enum PRMS_ID aPrmId ) const;
// Board classes panel:
void OnBoardClassesUnitsSelection( wxCommandEvent& event ) override;
void BoardClassesUpdateData( double aUnitScale );
// Calculator doesn't host a tool framework
wxWindow* GetToolCanvas() const override
{
return nullptr;
}
private: private:
bool m_RegulatorListChanged; // Set when m_RegulatorList is modified and the corresponging file bool m_RegulatorListChanged; // Set when m_RegulatorList is modified and the corresponding file
// must be rewritten // must be rewritten
enum // Which dimension is controlling the track width / current enum // Which dimension is controlling the track width / current

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -123,6 +123,10 @@ public:
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
protected:
virtual std::string getLegacyFrameName() const override { return "pcb_calculator"; }
public:
ATTENUATORS m_Attenuators; ATTENUATORS m_Attenuators;
int m_BoardClassUnits; int m_BoardClassUnits;
@ -140,10 +144,6 @@ public:
TRANSMISSION_LINE m_TransLine; TRANSMISSION_LINE m_TransLine;
VIA_SIZE m_ViaSize; VIA_SIZE m_ViaSize;
protected:
virtual std::string getLegacyFrameName() const override { return "pcb_calculator"; }
}; };
#endif #endif

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2011-2014 Jean-Pierre Charras * Copyright (C) 2011-2014 Jean-Pierre Charras
* Copyright (C) 2004-2014 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -56,6 +56,22 @@ enum PRM_TYPE {
class TRANSLINE_PRM class TRANSLINE_PRM
{ {
public: public:
/**
* @param aKeywordCfg is the keyword used in config to identify the parameter
* only ASCII7 keyword is valid.
* @param aDlgLabel is a I18n string used to identify the parameter in dialog.
* usually aDlgLabel is same as aKeywordCfg, but translatable.
*/
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
const char* aKeywordCfg = "",
const wxString& aDlgLabel = wxEmptyString,
const wxString& aToolTip = wxEmptyString,
double aValue = 0.0,
bool aConvUnit = false );
double ToUserUnit();
double FromUserUnit();
PRM_TYPE m_Type; // Type of parameter: substr, physical, elect PRM_TYPE m_Type; // Type of parameter: substr, physical, elect
PRMS_ID m_Id; // Id of parameter ( link to transline functions ) PRMS_ID m_Id; // Id of parameter ( link to transline functions )
std::string m_KeyWord; // keyword for this parameter in json config file in ASCII7 only std::string m_KeyWord; // keyword for this parameter in json config file in ASCII7 only
@ -67,42 +83,13 @@ public:
void* m_ValueCtrl; // The text ctrl containing the value in dialog void* m_ValueCtrl; // The text ctrl containing the value in dialog
void* m_UnitCtrl; // The UNIT_SELECTOR containing the unit in dialog void* m_UnitCtrl; // The UNIT_SELECTOR containing the unit in dialog
int m_UnitSelection; // last selection for units int m_UnitSelection; // last selection for units
public:
/**
* TRANSLINE_PRM ctor.
* @param aKeywordCfg is the keyword used in config to identify the parameter
* only ASCII7 keyword is valid
* @param aDlgLabel is a I18n string used to identify the parameter in dialog.
* usually aDlgLabel is same as aKeywordCfg, but translatable
*/
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
const char* aKeywordCfg = "",
const wxString& aDlgLabel = wxEmptyString,
const wxString& aToolTip = wxEmptyString,
double aValue = 0.0,
bool aConvUnit = false );
double ToUserUnit();
double FromUserUnit();
}; };
// A class to handle the list of availlable transm. lines // A class to handle the list of available transm. lines
// with messages, tooptips ... // with messages, tooptips ...
class TRANSLINE_IDENT class TRANSLINE_IDENT
{ {
public:
enum TRANSLINE_TYPE_ID m_Type; // The type of transline handled
wxBitmap * m_Icon; // An icon to display in dialogs
TRANSLINE* m_TLine; // The TRANSLINE itself
wxArrayString m_Messages; // messages for results
bool m_HasPrmSelection; // true if selection of parameters must be enabled in dialog menu
private:
std::vector <TRANSLINE_PRM*> m_prms_List;
public: public:
TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ); TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType );
~TRANSLINE_IDENT(); ~TRANSLINE_IDENT();
@ -113,7 +100,6 @@ public:
m_prms_List.push_back( aParam ); m_prms_List.push_back( aParam );
} }
TRANSLINE_PRM* GetPrm( unsigned aIdx ) const TRANSLINE_PRM* GetPrm( unsigned aIdx ) const
{ {
if( aIdx < m_prms_List.size() ) if( aIdx < m_prms_List.size() )
@ -122,15 +108,25 @@ public:
return NULL; return NULL;
} }
unsigned GetPrmsCount() const unsigned GetPrmsCount() const
{ {
return m_prms_List.size(); return m_prms_List.size();
} }
void ReadConfig(); void ReadConfig();
void WriteConfig(); void WriteConfig();
public:
enum TRANSLINE_TYPE_ID m_Type; // The type of transline handled
wxBitmap * m_Icon; // An icon to display in dialogs
TRANSLINE* m_TLine; // The TRANSLINE itself
wxArrayString m_Messages; // messages for results
// true if selection of parameters must be enabled in dialog menu.
bool m_HasPrmSelection;
private:
std::vector <TRANSLINE_PRM*> m_prms_List;
}; };
#endif // TRANSLINE_IDENT_H #endif // TRANSLINE_IDENT_H