chart3D.C 1.9 KB

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