allpy
changeset 37:fc9b69af4400
timer. other impovements
author | boris (netbook) <bnagaev@gmail.com> |
---|---|
date | Wed, 15 Sep 2010 15:20:53 +0400 |
parents | fc5d6d498f7d |
children | e59421ec23de |
files | blocks3d-wt-widget.C blocks3d-wt-widget.h config.h |
diffstat | 3 files changed, 54 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/blocks3d-wt-widget.C Wed Sep 15 12:47:19 2010 +0400 1.2 +++ b/blocks3d-wt-widget.C Wed Sep 15 15:20:53 2010 +0400 1.3 @@ -74,7 +74,11 @@ 1.4 1.5 1.6 new Wt::WBreak(this); 1.7 - Wt::WPushButton *go_button = new Wt::WPushButton("Run", this); 1.8 + Wt::WPushButton *go_button = new Wt::WPushButton("Run", this); 1.9 + 1.10 + new Wt::WBreak(this); 1.11 + results_panel = new Wt::WContainerWidget(); 1.12 + 1.13 go_button->clicked().connect(this, &Blocks3DWidget::go_button_click); 1.14 alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded); 1.15 conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded); 1.16 @@ -83,6 +87,10 @@ 1.17 1.18 alignment_upload->changed().connect(alignment_upload, &Wt::WFileUpload::upload); 1.19 conformity_upload->changed().connect(conformity_upload, &Wt::WFileUpload::upload); 1.20 + 1.21 + timer = new Wt::WTimer(this); 1.22 + timer->timeout()->(this, &Blocks3DWidget::timeout) 1.23 + timer->setInterval(Malakite::refresh_period); 1.24 } 1.25 1.26 void Blocks3DWidget::go_button_click() 1.27 @@ -203,9 +211,44 @@ 1.28 1.29 // security??? 1.30 system(str(boost::format("sh %s &") % tempfile_sh.c_str()).c_str()); 1.31 + new Wt::WBreak(this); 1.32 + new Wt::Wtext("Task start", results_panel); 1.33 1.34 - 1.35 - Wt::WMessageBox::show("Ok", "Ok", Wt::Ok); 1.36 + timer->start(); 1.37 1.38 } 1.39 1.40 +void Blocks3DWidget::timeout() 1.41 +{ 1.42 + // FIXME: check status of task 1.43 + std::ifstream check_file; 1.44 + check_file.open(tempfile_check); 1.45 + if (!check_file) 1.46 + { 1.47 + return; 1.48 + } 1.49 + check_file.close(); 1.50 + 1.51 + timer->stop(); 1.52 + 1.53 + std::ifstream tempfile_html_file; 1.54 + tempfile_html_file.open(tempfile_html); 1.55 + if (!tempfile_html_file) 1.56 + { 1.57 + //~ Wt::WMessageBox::show("Ok", "Ok", Wt::Ok); 1.58 + new Wt::WBreak(this); 1.59 + new Wt::Wtext("Task failed. Please contact developer", results_panel); 1.60 + return; 1.61 + } 1.62 + tempfile_html_file.close(); 1.63 + 1.64 + new Wt::WBreak(this); 1.65 + new Wt::Wtext("Task finished", results_panel); 1.66 + 1.67 + 1.68 + 1.69 + // FIXME Anchor 1.70 + 1.71 +} 1.72 + 1.73 +
2.1 --- a/blocks3d-wt-widget.h Wed Sep 15 12:47:19 2010 +0400 2.2 +++ b/blocks3d-wt-widget.h Wed Sep 15 15:20:53 2010 +0400 2.3 @@ -12,7 +12,7 @@ 2.4 #include <Wt/WTextArea> 2.5 #include <Wt/WPushButton> 2.6 #include <Wt/WLineEdit> 2.7 - 2.8 +#include <Wt/WTimer> 2.9 2.10 class Blocks3DWidget : public Wt::WContainerWidget 2.11 { 2.12 @@ -34,11 +34,15 @@ 2.13 Wt::WIntValidator *timeout_validator; 2.14 Wt::WIntValidator *timeout2_validator; 2.15 2.16 + Wt::WContainerWidget* results_panel; 2.17 + Wt::WTimer* timer; 2.18 + 2.19 void textarea_from_file(Wt::WTextArea* ta, const char* file); 2.20 void go_button_click(); 2.21 void alignment_uploaded(); 2.22 void conformity_uploaded(); 2.23 void fileTooLarge(); 2.24 void try_to_run(); 2.25 + void timeout(); 2.26 //~ void execute(); 2.27 };
3.1 --- a/config.h Wed Sep 15 12:47:19 2010 +0400 3.2 +++ b/config.h Wed Sep 15 15:20:53 2010 +0400 3.3 @@ -3,6 +3,9 @@ 3.4 namespace Malakite 3.5 { 3.6 3.7 +extern const int refresh_period = 5*1000; 3.8 + 3.9 + 3.10 extern const char* python_path; 3.11 extern const char* blocks3d_path; 3.12 extern const char* temp_path;