Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/1edfb7e96cb4
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 07:20:33 2012
Кодировка:

# HG changeset patch
# User boris
# Date 1284494253 -14400
# Node ID 1edfb7e96cb4933e003f7328ff05cb0003fd4b8c
# Parent 18abe8f33d37cbc0e7a4bc792ce7ac7306a8ca41
form
file uploading contrl

diff -r 18abe8f33d37 -r 1edfb7e96cb4 blocks3d-wt-widget.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d-wt-widget.C Tue Sep 14 23:57:33 2010 +0400
@@ -0,0 +1,121 @@
+
+#include "config.h"
+#include "blocks3d-wt-widget.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+Blocks3DWidget::Blocks3DWidget(WContainerWidget *parent) :
+ WContainerWidget(parent)
+{
+ alignment_upload = new Wt::WFileUpload();
+ alignment_textarea = new Wt::WTextArea();
+ conformity_upload = new Wt::WFileUpload();
+ conformity_textarea = new Wt::WTextArea();
+
+ Wt::WLabel *alignment_label = new Wt::WLabel("Alignment:");
+ alignment_label->setBuddy(alignment_textarea);
+
+ Wt::WLabel *conformity_label = new Wt::WLabel("Confiomity file:");
+ conformity_label->setBuddy(alignment_textarea);
+
+ Wt::WTable *table = new Wt::WTable(this);
+ table->elementAt(0, 0)->addWidget(alignment_label);
+ table->elementAt(0, 1)->addWidget(conformity_label);
+ table->elementAt(2, 0)->addWidget(alignment_upload);
+ table->elementAt(1, 1)->addWidget(conformity_textarea);
+ table->elementAt(2, 1)->addWidget(conformity_upload);
+
+ new Wt::WBreak(this);
+ delta_input = new Wt::WLineEdit(Malakite::default::delta, this);
+ Wt::WDoubleValidator *delta_validator = new Wt::WDoubleValidator(0.0, 10.0);
+ delta_input->setValidator(delta_validator);
+ Wt::WLabel *delta_label = new Wt::WLabel("Distance spreading", this);
+ delta_label->setBuddy(delta_input);
+
+ new Wt::WBreak(this);
+ min_block_width_input = new Wt::WLineEdit(Malakite::default::min_block_width, this);
+ Wt::WIntValidator *min_block_width_validator = new Wt::WIntValidator(3, 9999);
+ min_block_width_input->setValidator(min_block_width_validator);
+ Wt::WLabel *min_block_width_label = new Wt::WLabel("Min block width", this);
+ min_block_width_label->setBuddy(min_block_width_input);
+
+ new Wt::WBreak(this);
+ timeout_input = new Wt::WLineEdit(Malakite::default::timeout, this);
+ Wt::WIntValidator *timeout_validator = new Wt::WIntValidator(-1, 30*24*3600);
+ timeout_input->setValidator(timeout_validator);
+ Wt::WLabel *timeout_label = new Wt::WLabel(
+ "Bron-Kerbosh (couple cores) timeout", this);
+ timeout_label->setBuddy(timeout_input);
+
+ new Wt::WBreak(this);
+ timeout2_input = new Wt::WLineEdit(Malakite::default::timeout2, this);
+ Wt::WIntValidator *timeout2_validator = new Wt::WIntValidator(-1, 30*24*3600);
+ timeout2_input->setValidator(timeout2_validator);
+ Wt::WLabel *timeout2_label = new Wt::WLabel(
+ "Bron-Kerbosh (blocks) timeout", this);
+ timeout2_label->setBuddy(timeout2_input);
+
+
+ new Wt::WBreak(this);
+ Wt::WPushButton *go_button = new Wt::WPushButton("Run", this);
+ go_button->clicked().connect(go_button, &Blocks3DWidget::go_button_click);
+ //~ go_button->clicked().connect(go_button, &Wt::WPushButton::disable);
+ go_button->clicked().connect(alignment_upload, Wt::WFileUpload::upload);
+ go_button->clicked().connect(conformity_upload, Wt::WFileUpload::upload);
+ alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded);
+ conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded);
+ alignment_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
+ conformity_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
+
+
+}
+
+void Blocks3DWidget::fileTooLarge()
+{
+ Wt::WMessageBox::show("Error", "File too large", Wt::Ok);
+}
+
+void Blocks3DWidget::textarea_from_file(Wt::WTextArea* ta, char* file)
+{
+ std::string temp("");
+ std::string total("");
+ ifstream uploaded_file;
+
+ uploaded_file.open(file);
+ if (!inFile)
+ {
+ return;
+ }
+ while (uploaded_file >> temp)
+ {
+ total += temp;
+ }
+ uploaded_file.close();
+
+ ta->setText(total);
+}
+
+void Blocks3DWidget::alignment_uploaded()
+{
+ textarea_from_file(alignment_textarea, alignment_upload->spoolFileName());
+}
+
+void Blocks3DWidget::conformity_uploaded()
+{
+ textarea_from_file(conformity_textarea, conformity_upload->spoolFileName());
+}
+
+void Blocks3DWidget::try_to_run()
+{
+ textarea_from_file(conformity_textarea, conformity_upload->spoolFileName());
+}
+
diff -r 18abe8f33d37 -r 1edfb7e96cb4 blocks3d-wt-widget.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d-wt-widget.h Tue Sep 14 23:57:33 2010 +0400
@@ -0,0 +1,41 @@
+
+#include "config.h"
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+class Blocks3DWidget : public WContainerWidget
+{
+public:
+ Blocks3DWidget(WContainerWidget *parent=0);
+private:
+ Wt::WFileUpload* alignment_upload;
+ Wt::WTextArea* alignment_textarea;
+ Wt::WFileUpload* conformity_upload;
+ Wt::WTextArea* conformity_textarea;
+
+ Wt::WLineEdit* delta_input;
+ Wt::WLineEdit* min_block_width_input;
+ Wt::WLineEdit* timeout_input;
+ Wt::WLineEdit* timeout2_input;
+
+ void textarea_from_file(Wt::WTextArea* ta, char* file);
+ void go_button_click();
+ void alignment_uploaded();
+ void conformity_uploaded();
+ void try_to_run();
+ void fileTooLarge();
+};
diff -r 18abe8f33d37 -r 1edfb7e96cb4 blocks3d-wt.C
--- a/blocks3d-wt.C Tue Sep 14 22:32:55 2010 +0400
+++ b/blocks3d-wt.C Tue Sep 14 23:57:33 2010 +0400
@@ -1,26 +1,28 @@

#include "config.h"
+#include "blocks3d-wt-widget.h"

#include
#include
-#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+

class Blocks3DApplication : public WApplication
{
public:
Blocks3DApplication(const WEnvironment& env);
+private:
+ Blocks3DWidget* blocks3d_widget;
};

+Blocks3DApplication::Blocks3DApplication(const WEnvironment& env) :
+ WApplication(env)
+{
+ blocks3d_widget = new Blocks3DWidget(this);
+}
+
+
+

Blocks3DApplication* createApplication(const WEnvironment& env)
{
diff -r 18abe8f33d37 -r 1edfb7e96cb4 blocks3d-wt.pro
--- a/blocks3d-wt.pro Tue Sep 14 22:32:55 2010 +0400
+++ b/blocks3d-wt.pro Tue Sep 14 23:57:33 2010 +0400
@@ -2,6 +2,7 @@

SOURCES += config.C
SOURCES += blocks3d-wt.C
+SOURCES += blocks3d-wt-widget.C

CONFIG += debug
CONFIG += precompile_header
diff -r 18abe8f33d37 -r 1edfb7e96cb4 config.C
--- a/config.C Tue Sep 14 22:32:55 2010 +0400
+++ b/config.C Tue Sep 14 23:57:33 2010 +0400
@@ -11,5 +11,18 @@

const char* main_url = "/";

+
+namespace default
+{
+
+const char* delta = "2.0";
+const char* min_block_width_input = "3";
+const char* timeout = "10";
+const char* timeout2 = "10";
+
}

+
+
+}
+
diff -r 18abe8f33d37 -r 1edfb7e96cb4 config.h
--- a/config.h Tue Sep 14 22:32:55 2010 +0400
+++ b/config.h Tue Sep 14 23:57:33 2010 +0400
@@ -9,4 +9,12 @@

extern const char* main_url;

+namespace default
+{
+
+extern const char* delta;
+extern const char* min_block_width_input;
+extern const char* timeout;
+extern const char* timeout2;
+
}