1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include "NumericalExample.h"
#include "CategoryExample.h"
#include "ColorMapTest.h"
#include <Wt/WApplication>
#include <Wt/WBootstrapTheme>
#include <Wt/WComboBox>
#include <Wt/WContainerWidget>
#include <Wt/WEnvironment>
#include <Wt/WStackedWidget>
using namespace Wt;
class TestApp : public WApplication
{
public:
TestApp(const WEnvironment& env);
private:
WStackedWidget *stack_;
WComboBox *chartExPicker_;
NumericalExample *numEx_;
CategoryExample *categoryEx_;
ColorMapTest *colormap_;
void switchExamples();
};
TestApp::TestApp(const WEnvironment& env)
: WApplication(env)
{
setTitle("3D Charts Demo");
setTheme(new WBootstrapTheme(this));
//require("WebGL-Inspector/core/embed.js");
messageResourceBundle().use(appRoot() + "configTemplates");
WContainerWidget *wrapper = new WContainerWidget(root());
wrapper->setContentAlignment(AlignCenter);
wrapper->addWidget(new WText("<h1>3D Charts Demo</h1>", wrapper));
chartExPicker_ = new WComboBox(wrapper);
chartExPicker_->addItem("Numerical Grid-Based Data");
chartExPicker_->addItem("Categorical Data");
chartExPicker_->addItem("Colormap Example");
chartExPicker_->changed().connect(this, &TestApp::switchExamples);
stack_ = new WStackedWidget(wrapper);
numEx_ = new NumericalExample(stack_);
categoryEx_ = new CategoryExample(stack_);
colormap_ = new ColorMapTest(stack_);
chartExPicker_->setCurrentIndex(0);
stack_->setCurrentWidget(numEx_);
}
void TestApp::switchExamples()
{
switch (chartExPicker_->currentIndex()) {
case 0:
stack_->setCurrentWidget(numEx_);
break;
case 1:
stack_->setCurrentWidget(categoryEx_);
break;
case 2:
stack_->setCurrentWidget(colormap_);
break;
}
}
WApplication *createApplication(const WEnvironment& env)
{
return new TestApp(env);
}
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, &createApplication);
}
|