00001
00010 #ifndef BASICMETHODPANEL_H
00011 #define BASICMETHODPANEL_H
00012
00013 #include "DoubleParameterValidator.h"
00014 #include "MethodPanelInfo.h"
00015 #include "MethodPanelFactory.h"
00016 #include "PointControl.h"
00017 #include "StopConditionControl.h"
00018 #include "StopConditionValidator.h"
00019
00020 template <class T>
00021 class BasicMethodPanel: public wxPanel
00022 {
00023 public:
00024
00027 BasicMethodPanel(wxWindow* parent,
00028 int id,
00029 T* pMethod,
00030 const ProblemBase& problem,
00031 const wxPoint& pos=wxDefaultPosition,
00032 const wxSize& size=wxDefaultSize,
00033 long style=0);
00034
00039 static wxPanel* CreatePanel(MethodPanelInfo panelInfo);
00040
00041 private:
00042 void do_layout();
00043
00044 protected:
00045 StopConditionControl* mpStopCondition;
00046 PointControl* mpStartingPoint;
00047 };
00048
00049 template <class T>
00050 BasicMethodPanel<T>::BasicMethodPanel(wxWindow* parent,
00051 int id,
00052 T* pMethod,
00053 const ProblemBase& problem,
00054 const wxPoint& pos,
00055 const wxSize& size,
00056 long style)
00057 : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL)
00058 {
00059
00060 mpStopCondition = new StopConditionControl(this, -1);
00061 mpStartingPoint = new PointControl(this, -1, wxDefaultPosition,
00062 wxDefaultSize, 0, _("Starting point"));
00063
00064 do_layout();
00065
00066
00067 mpStopCondition->SetList(pMethod->AllowedStopConditions());
00068
00069
00070 mpStopCondition->SetValidator(StopConditionValidator(
00071 reinterpret_cast<CountedPtr<const StopConditionBase>&>(
00072 pMethod->mcpStopCondition)));
00073
00074
00075 mpStartingPoint->Init(problem.Variables(),
00076 pMethod->mInitialStartingPoint);
00077
00078 }
00079
00080 template <class T>
00081 wxPanel*
00082 BasicMethodPanel<T>::CreatePanel(MethodPanelInfo panelInfo)
00083 {
00084 return new BasicMethodPanel(
00085 panelInfo.pParent(),
00086 -1,
00087 dynamic_cast<T*>(panelInfo.pMethod()),
00088 *panelInfo.pProblem());
00089
00090 }
00091
00092 template <class T>
00093 void
00094 BasicMethodPanel<T>::do_layout()
00095 {
00096 wxBoxSizer* p_main_sizer = new wxBoxSizer(wxVERTICAL);
00097 p_main_sizer->Add(mpStopCondition, 0, wxEXPAND, 0);
00098 p_main_sizer->Add(mpStartingPoint, 1, wxEXPAND, 0);
00099 SetAutoLayout(true);
00100 SetSizer(p_main_sizer);
00101 p_main_sizer->Fit(this);
00102 p_main_sizer->SetSizeHints(this);
00103 }
00104
00105 #endif // BASICMETHODPANEL_H