KiCad PCB EDA Suite
sim_workbook.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 MikoĊ‚aj Wielgus <[email protected]>
5 * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <sim/sim_workbook.h>
26
27
28SIM_WORKBOOK::SIM_WORKBOOK() : wxAuiNotebook()
29{
30 m_modified = false;
31}
32
33
34SIM_WORKBOOK::SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, const wxSize&
35 aSize, long aStyle ) :
36 wxAuiNotebook( aParent, aId, aPos, aSize, aStyle )
37{
38 m_modified = false;
39}
40
41
42bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& caption, bool select, const wxBitmap& bitmap )
43{
44 if( wxAuiNotebook::AddPage( page, caption, select, bitmap ) )
45 {
47 return true;
48 }
49
50 return false;
51}
52
53
54bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& text, bool select, int imageId )
55{
56 if( wxAuiNotebook::AddPage( page, text, select, imageId ) )
57 {
59 return true;
60 }
61
62 return false;
63}
64
65
67{
68 if( wxAuiNotebook::DeleteAllPages() )
69 {
71 return true;
72 }
73
74 return false;
75}
76
77
78bool SIM_WORKBOOK::DeletePage( size_t page )
79{
80 if( wxAuiNotebook::DeletePage( page ) )
81 {
83 return true;
84 }
85
86 return false;
87}
88
89
90bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
91 const wxString& aName, int aPoints, const double* aX, const double* aY,
92 SIM_PLOT_TYPE aType )
93{
94 if( aPoints && aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType ) )
95 {
97 return true;
98 }
99
100 return false;
101}
102
103
104bool SIM_WORKBOOK::DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName )
105{
106 if( aPlotPanel->deleteTrace( aName ) )
107 {
108 setModified();
109 return true;
110 }
111
112 return false;
113}
114
115
117{
118 m_modified = false;
119 wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_CLR_MODIFIED ) );
120}
121
122
124{
125 m_modified = true;
126 wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_MODIFIED ) );
127}
128
129
130wxDEFINE_EVENT( EVT_WORKBOOK_MODIFIED, wxCommandEvent );
131wxDEFINE_EVENT( EVT_WORKBOOK_CLR_MODIFIED, wxCommandEvent );
bool addTrace(const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType)
bool deleteTrace(const wxString &aName)
bool AddTrace(SIM_PLOT_PANEL *aPlotPanel, const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType)
bool DeleteAllPages() override
void ClrModified()
bool DeleteTrace(SIM_PLOT_PANEL *aPlotPanel, const wxString &aName)
bool DeletePage(size_t aPage) override
void setModified()
Dirty bit, indicates something in the workbook has changed.
bool AddPage(wxWindow *aPage, const wxString &aCaption, bool aSelect=false, const wxBitmap &aBitmap=wxNullBitmap)
SIM_PLOT_TYPE
Definition: sim_types.h:47
wxDEFINE_EVENT(EVT_WORKBOOK_MODIFIED, wxCommandEvent)