31 std::map<int, wxString>* aSignals ) :
39 wxGridCellAttr* attr =
new wxGridCellAttr;
41 m_grid->SetColAttr( 1, attr );
43 for(
const auto& [
id, signal ] : *
m_signals )
60 m_grid->PopEventHandler(
true );
69 int row =
m_grid->GetNumberRows();
72 m_grid->SetCellValue( row, 0, aText );
73 m_grid->SetCellValue( row, 1, wxString::Format( wxS(
"%d" ), aId ) );
75 wxGridCellAttr* attr =
new wxGridCellAttr;
81 m_grid->SetAttr( row, 0, attr );
88 [&]() -> std::pair<int, int>
92 for(
int ii = 0; ii <
m_grid->GetNumberRows(); ++ii )
95 m_grid->GetCellValue( ii, 1 ).ToLong( &usedId );
102 return {
m_grid->GetNumberRows() - 1, 0 };
112 m_grid->DeleteRows( row, 1 );
119 wxStyledTextCtrl* textCtrl = aTricks->
Scintilla();
120 wxArrayString tokens;
122 for(
const wxString& signal :
m_frame->SimPlotVectors() )
123 tokens.push_back( signal );
125 tokens.push_back( wxS(
"sqrt(x)" ) );
126 tokens.push_back( wxS(
"sin(x)" ) );
127 tokens.push_back( wxS(
"cos(x)" ) );
128 tokens.push_back( wxS(
"tan(x)" ) );
129 tokens.push_back( wxS(
"sinh(x)" ) );
130 tokens.push_back( wxS(
"cosh(x)" ) );
131 tokens.push_back( wxS(
"tanh(x)" ) );
132 tokens.push_back( wxS(
"asin(x)" ) );
133 tokens.push_back( wxS(
"acos(x)" ) );
134 tokens.push_back( wxS(
"atan(x)" ) );
135 tokens.push_back( wxS(
"asinh(x)" ) );
136 tokens.push_back( wxS(
"acosh(x)" ) );
137 tokens.push_back( wxS(
"atanh(x)" ) );
138 tokens.push_back( wxS(
"arctan(x)" ) );
139 tokens.push_back( wxS(
"exp(x)" ) );
140 tokens.push_back( wxS(
"ln(x)" ) );
141 tokens.push_back( wxS(
"log(x)" ) );
142 tokens.push_back( wxS(
"abs(x)" ) );
143 tokens.push_back( wxS(
"nint(x)" ) );
144 tokens.push_back( wxS(
"int(x)" ) );
145 tokens.push_back( wxS(
"floor(x)" ) );
146 tokens.push_back( wxS(
"ceil(x)" ) );
147 tokens.push_back( wxS(
"pow(x,y)" ) );
148 tokens.push_back( wxS(
"pwr(x,y)" ) );
149 tokens.push_back( wxS(
"min(x,y)" ) );
150 tokens.push_back( wxS(
"max(x,y)" ) );
151 tokens.push_back( wxS(
"sgn(x)" ) );
152 tokens.push_back( wxS(
"ternary_fcn(x,y,z)" ) );
153 tokens.push_back( wxS(
"gauss(nom,rvar,sigma)" ) );
154 tokens.push_back( wxS(
"agauss(nom,avar,sigma)" ) );
155 tokens.push_back( wxS(
"unif(nom,rvar)" ) );
156 tokens.push_back( wxS(
"aunif(nom,avar)" ) );
157 tokens.push_back( wxS(
"limit(nom,avar)" ) );
159 int text_pos = textCtrl->GetCurrentPos();
160 int start = textCtrl->WordStartPosition( text_pos,
true );
163 for( start = text_pos - 1; start > 0; start-- )
165 wxUniChar c = textCtrl->GetCharAt( start );
179 else if( wxIsalpha( c ) && parenCount )
183 else if( !wxIsalnum( c ) && c !=
'/' )
192 wxString partial = textCtrl->GetRange( start, text_pos );
196 textCtrl->SetFocus();
202 if( !wxDialog::TransferDataFromWindow() )
205 if( !
m_grid->CommitPendingChanges() )
210 for(
int ii = 0; ii <
m_grid->GetNumberRows(); ++ii )
212 wxString signal =
m_grid->GetCellValue( ii, 0 );
214 if( !signal.IsEmpty() )
217 m_grid->GetCellValue( ii, 1 ).ToLong( &
id );
218 (*m_signals)[ (int)
id ] = signal;
234 wxSize sz( 320, 320 );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_USER_DEFINED_SIGNALS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("User-defined Signals"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
STD_BITMAP_BUTTON * m_addButton
STD_BITMAP_BUTTON * m_deleteButton
void onAddSignal(wxCommandEvent &event) override
DIALOG_USER_DEFINED_SIGNALS(SIMULATOR_FRAME *parent, std::map< int, wxString > *aSignals)
void onDeleteSignal(wxCommandEvent &event) override
bool TransferDataFromWindow() override
SIMULATOR_FRAME * m_frame
HTML_MESSAGE_BOX * m_helpWindow
void addGridRow(const wxString &aValue, int aId)
void onScintillaCharAdded(wxStyledTextEvent &aEvent, SCINTILLA_TRICKS *aTricks)
~DIALOG_USER_DEFINED_SIGNALS()
std::map< int, wxString > * m_signals
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
wxStyledTextCtrl * Scintilla() const
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
The SIMULATOR_FRAME holds the main user-interface for running simulations.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)