00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025
00026
00027
00028
00030
00031
00032
00033 #ifdef __GNUG__
00034 #pragma implementation "SolveDlg.h"
00035 #endif
00036
00037
00038 #include "mg/mgprec.h"
00039
00040 #ifndef mgPRECOMP
00041 #include "mc/Solver.h"
00042 #include "mg/SolveDlg.h"
00043 #endif
00044
00045
00046
00047
00048 IMPLEMENT_CLASS(mgSolvePanel, wxPanel)
00049 BEGIN_EVENT_TABLE(mgSolvePanel, wxPanel)
00050
00051
00052 EVT_BUTTON( IDC_SOLVEPANEL_SOLVER_OPTION, mgSolvePanel::OnSolverOption )
00053 EVT_BUTTON( IDC_SOLVEPANEL_SOLVE, mgSolvePanel::OnSolve )
00054
00055 END_EVENT_TABLE()
00056
00057
00058 IMPLEMENT_CLASS(mgSolveDlg, wxDialog)
00059 BEGIN_EVENT_TABLE(mgSolveDlg, wxDialog)
00060
00061
00062 EVT_BUTTON( IDC_SOLVEPANEL_SOLVE, mgSolveDlg::OnPanelDismiss )
00063
00064 END_EVENT_TABLE()
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 mgSolvePanel::mgSolvePanel(wxWindow *parent, mgMathWnd *pWnd, mgMathBox *pBox,
00077 wxWindowID id, const wxPoint& pos, const wxSize& size,
00078 long style, const wxString& name) :
00079 wxPanel(parent, id, pos, size, style, name),
00080 mgMathBoxWndUser(pWnd, pBox)
00081 {
00082
00083 BuildCtrls();
00084 BuildAll();
00085 }
00086
00087 void mgSolvePanel::BuildCtrls()
00088 {
00089
00090 m_pListBox = new wxListBox(this, -1);
00091 UpdateSolverList();
00092 }
00093
00094 void mgSolvePanel::BuildAll()
00095 {
00096 wxBoxSizer *main = new wxBoxSizer(wxVERTICAL);
00097
00098
00099 wxStaticText *info = new wxStaticText(this, -1,
00100 GetBox()->GetMathObj().data_GetDescString().MakeUpper());
00101 wxFont infofnt = info->GetFont();
00102 infofnt.SetWeight(wxBOLD);
00103 info->SetFont(infofnt);
00104
00105
00106 main->Add(new wxStaticText(this, -1, wxT("With this panel, you can choose the algorithm yo use to solve the selected data.")),
00107 0, wxALIGN_LEFT | wxALL, 5);
00108 main->Add(new wxStaticText(this, -1, wxT("The current math data is classified as:")),
00109 0, wxALIGN_LEFT | wxALL, 5);
00110 main->Add(info, 0, wxALIGN_CENTER | wxALL, 5);
00111
00112
00113 wxBoxSizer *mainhz = new wxBoxSizer(wxHORIZONTAL);
00114 mainhz->Add(m_pListBox, 5, wxGROW | wxALL, 5);
00115 mainhz->Add(new wxButton(this, IDC_SOLVEPANEL_SOLVER_OPTION, wxT("Solver options")),
00116 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5);
00117 main->Add(mainhz, 3, wxGROW);
00118
00119
00120 wxBoxSizer *hz = new wxBoxSizer(wxHORIZONTAL);
00121 hz->Add(10, 10, 4, wxGROW);
00122 hz->Add(new wxButton(this, wxID_CANCEL, wxT("Cancel")), 1, wxGROW | wxALL, 5);
00123 hz->Add(new wxButton(this, wxID_OK, wxT("Solve...")), 1, wxGROW | wxTOP | wxBOTTOM | wxLEFT, 5);
00124 main->Add(hz, 1, wxGROW | wxALL, 5);
00125
00126 SetSizer(main);
00127 main->SetSizeHints(this);
00128 }
00129
00130 void mgSolvePanel::OnSolve(wxCommandEvent &event)
00131 {
00132
00133 int n = m_pListBox->GetSelection();
00134 if (n < 0) return;
00135 mcSolver *p = mcMathCore::arrSolvers.data_Get(n);
00136
00137
00138 mcSystemStepArray steps;
00139 p->math_Solve(GetBox()->GetMathObj(), steps);
00140 }
00141
00142 void mgSolvePanel::OnSolverOption(wxCommandEvent &)
00143 {
00144
00145 }
00146
00147 void mgSolvePanel::UpdateSolverList()
00148 {
00149 mcSolverArray *p = &mcMathCore::arrSolvers;
00150
00151
00152 m_pListBox->Clear();
00153 m_pListBox->Set(p->io_GetDescArray());
00154
00155
00156 for (int i=0, c=0; i < p->data_GetCount(); i++, c++) {
00157 if (!p->data_Get(c)->math_WorksOn(GetBox()->GetMathObj())) {
00158 m_pListBox->Delete(c--);
00159 }
00160 }
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170 mgSolveDlg::mgSolveDlg(wxWindow *parent, mgMathWnd *pWnd, mgMathBox *pBox,
00171 wxWindowID id, const wxString& title, const wxPoint& pos,
00172 const wxSize& size, long style, const wxString& name) :
00173 wxDialog(parent, id, title, pos, size, style, name)
00174 {
00175
00176 wxBoxSizer *main = new wxBoxSizer(wxHORIZONTAL);
00177 main->Add(new mgSolvePanel(this, pWnd, pBox), 1, wxGROW);
00178
00179 SetSizer(main);
00180 main->SetSizeHints(this);
00181 }
00182
00183 void mgSolveDlg::OnPanelDismiss(wxCommandEvent &)
00184 {
00185
00186 EndModal(wxID_OK);
00187 }
00188
00189