00001 00002 // MathGUI = a WYSIWYG equation editor + a powerful math engine // 00003 // Copyright (C) 2003 by Francesco Montorsi // 00004 // // 00005 // This library is free software; you can redistribute it and/or // 00006 // modify it under the terms of the GNU Lesser General Public // 00007 // License as published by the Free Software Foundation; either // 00008 // version 2.1 of the License, or (at your option) any later // 00009 // version. // 00010 // // 00011 // This library is distributed in the hope that it will be useful, // 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00014 // GNU Lesser General Public License for more details. // 00015 // // 00016 // You should have received a copy of the GNU Lesser General Public // 00017 // License along with this program; if not, write to the Free // 00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, // 00019 // MA 02111-1307, USA. // 00020 // // 00021 // For any comment, suggestion or feature request, please contact // 00022 // the administrator of the project at frm@users.sourceforge.net // 00023 // // 00025 // \file SolveDlg.cpp 00026 // \brief Implements the mgSolvePanel and mgSolveDlg classes. 00027 // \author Francesco Montorsi 00028 // \date 26-3-2004 00030 00031 00032 // optimization for GCC compiler 00033 #ifdef __GNUG__ 00034 #pragma implementation "SolveDlg.h" 00035 #endif 00036 00037 // includes 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 // event table for mgSolvePanel 00048 IMPLEMENT_CLASS(mgSolvePanel, wxPanel) 00049 BEGIN_EVENT_TABLE(mgSolvePanel, wxPanel) 00050 00051 // buttons 00052 EVT_BUTTON( IDC_SOLVEPANEL_SOLVER_OPTION, mgSolvePanel::OnSolverOption ) 00053 EVT_BUTTON( IDC_SOLVEPANEL_SOLVE, mgSolvePanel::OnSolve ) 00054 00055 END_EVENT_TABLE() 00056 00057 // event table for mgSolveDlg 00058 IMPLEMENT_CLASS(mgSolveDlg, wxDialog) 00059 BEGIN_EVENT_TABLE(mgSolveDlg, wxDialog) 00060 00061 // buttons 00062 EVT_BUTTON( IDC_SOLVEPANEL_SOLVE, mgSolveDlg::OnPanelDismiss ) 00063 00064 END_EVENT_TABLE() 00065 00066 00067 00068 00069 00070 00071 00072 // ----------------- 00073 // mgSOLVEPANEL 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 // build everything in this panel... 00083 BuildCtrls(); 00084 BuildAll(); 00085 } 00086 00087 void mgSolvePanel::BuildCtrls() 00088 { 00089 // create the listbox with the description of the solvers 00090 m_pListBox = new wxListBox(this, -1); 00091 UpdateSolverList(); 00092 } 00093 00094 void mgSolvePanel::BuildAll() 00095 { 00096 wxBoxSizer *main = new wxBoxSizer(wxVERTICAL); 00097 00098 // make the classification string in bold 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 // create the upper part of the panel 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 // add the listbox 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 // add the buttons 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 // get a pointer to the selected solver 00133 int n = m_pListBox->GetSelection(); 00134 if (n < 0) return; 00135 mcSolver *p = mcMathCore::arrSolvers.data_Get(n); 00136 00137 // run the solver... 00138 mcSystemStepArray steps; 00139 p->math_Solve(GetBox()->GetMathObj(), steps); 00140 } 00141 00142 void mgSolvePanel::OnSolverOption(wxCommandEvent &) 00143 { 00144 // create a dialog containing the solver options' panel 00145 } 00146 00147 void mgSolvePanel::UpdateSolverList() 00148 { 00149 mcSolverArray *p = &mcMathCore::arrSolvers; 00150 00151 // replace old contents 00152 m_pListBox->Clear(); 00153 m_pListBox->Set(p->io_GetDescArray()); 00154 00155 // search items to delete 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 // mgSOLVEDLG 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 // create our main sizer 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 // our panel has been dismissed.... close this dialog 00186 EndModal(wxID_OK); 00187 } 00188 00189
[ Top ] |