28 #include <boost/shared_ptr.hpp>
29 #include <boost/make_shared.hpp>
32 #ifdef KJB_HAVE_OPENGL
33 template <
class Model>
34 class Target_plot_recorder
37 Target_plot_recorder(
const Target_plot_recorder&){}
38 Target_plot_recorder& operator=(
const Target_plot_recorder&){
return *
this;}
40 typedef Model Model_type;
41 typedef kjb::gui::Plot Value_type;
42 typedef std::map<double, double> Data_map;
44 const kjb::gui::Plot&
get()
const{
return plot_;}
46 Target_plot_recorder(
size_t width,
size_t height) :
49 plot_(0,0,width, height),
53 typedef kjb::opengl::Glut_window Glut_window;
55 kjb::opengl::Glut::push_current_window();
57 wnd_ = boost::shared_ptr<Glut_window>(
new Glut_window(width, height,
"Target Distribution vs. Iteration"));
60 viewer_ = boost::make_shared<kjb::gui::Viewer>(width,
height);
62 viewer_->attach(*wnd_);
63 viewer_->attach_overlay(&plot_);
64 dataset_ = plot_.add_dataset(Data_map());
65 plot_.auto_axis(
false,
true);
68 kjb::opengl::Glut::pop_current_window();
71 void include_y_origin(
bool b)
73 plot_.auto_axis(
false, b);
85 void set_culling(
size_t cull_begin,
size_t cull_end = 0)
87 cull_begin_ = cull_begin;
89 cull_end_ = cull_begin_;
94 void operator()(
const Model& model,
const Step_log<Model>& step_log)
const
96 typedef Data_map::iterator Iterator;
100 double lt = step_log.back().lt;
103 plot_.append_dataset(
108 if(cull_begin_ && dataset_->data.size() > cull_begin_)
110 Data_map& data = dataset_->data;
112 int remove_count = (int) data.size() - (int) cull_end_;
113 Iterator remove_begin = data.begin();
114 Iterator remove_end = data.begin();
115 std::advance(remove_end, remove_count);
117 Iterator it = remove_begin;
118 while(it != remove_end)
120 dataset_->update_data_range();
130 boost::shared_ptr<kjb::opengl::Glut_window> wnd_;
131 boost::shared_ptr<kjb::gui::Viewer> viewer_;
132 mutable kjb::gui::Plot plot_;
133 kjb::gui::Plot::Data_set_iterator dataset_;
height
Definition: APPgetLargeConnectedEdges.m:33
Definition: sample_base.h:160