PeriDyno 1.2.1
Loading...
Searching...
No Matches
WMainApp.cpp
Go to the documentation of this file.
1#include "WMainApp.h"
2#include "WMainWindow.h"
3#include "WSimulationCanvas.h"
4
5#include "SceneGraphFactory.h"
6
7#include <Wt/WEnvironment.h>
8#include <Wt/WHBoxLayout.h>
9#include <Wt/WBootstrap3Theme.h>
10
11// for test data
12//#include <SceneGraphFactory.h>
13
14using namespace dyno;
15
16WMainApp::WMainApp(const Wt::WEnvironment& env) : Wt::WApplication(env)
17{
18 // ace editor
19 this->require("lib/ace.js");
20
21 // use default bootstrap theme
22 auto bootstrapTheme = std::make_shared<Wt::WBootstrap3Theme>();
23 this->setTheme(bootstrapTheme);
24
25 this->setTitle("PeriDyno: An AI-targeted physics simulation platform");
26 //this->addMetaHeader("icon", "/logo-favicon.ico", "image/x-icon");
27
28 // style sheet for the canvas
29 this->styleSheet().addRule(
30 ".remote-framebuffer",
31 // flip
32 "transform: scaleY(-1) !important;"
33 // disable drag...
34 "-webkit-user-drag: none !important;"
35 "-khtml-user-drag: none !important;"
36 "-moz-user-drag: none !important;"
37 "-o-user-drag: none !important;"
38 "user-drag: none !important;"
39 // hack for brightness
40 "filter: brightness(2);"
41 );
42
43 // override internal padding for panel...
44 this->styleSheet().addRule(
45 ".panel-body",
46 "padding: 0!important;"
47 );
48
49 this->styleSheet().addRule(
50 ".sample-item",
51 "border-radius: 5px;"
52 );
53
54 // add logo to navbar
55 this->styleSheet().addRule(
56 ".navbar-header",
57 "background-image: url(\"logo.png\");"
58 "background-repeat: no-repeat;"
59 "background-size: 36px 36px;"
60 "background-position: 12px 6px;"
61 "padding-left: 36px;"
62 );
63
64 // color picker button style
65 this->styleSheet().addRule(
66 ".color-picker",
67 "border: 0!important;"
68 "padding: 0!important;"
69 );
70
71 // scrollable style
72 this->styleSheet().addRule(
73 ".scrollable-content",
74 "overflow: auto;"
75 "max-height: 250px;"
76 "border: 1px solid #ccc;"
77 "padding: 10px;"
78 "box-sizing: border-box;"
79 );
80
81 this->styleSheet().addRule(
82 ".scrollable-content-sample",
83 "overflow: auto;"
84 "max-height: auto;"
85 "border: 1px solid #ccc;"
86 "padding: 10px;"
87 "box-sizing: border-box;"
88 );
89
90 // set layout and add main window
91 auto layout = this->root()->setLayout(std::make_unique<Wt::WHBoxLayout>());
92 layout->setContentsMargins(0, 0, 0, 0);
93
94 window = layout->addWidget(std::make_unique<WMainWindow>());
95
96 window->setScene(dyno::SceneGraphFactory::instance()->createDefaultScene());
97
98 window->createRightPanel();
99
100 this->globalKeyWentDown().connect(window->simCanvas(), &WSimulationCanvas::onKeyWentDown);
101 this->globalKeyWentUp().connect(window->simCanvas(), &WSimulationCanvas::onKeyWentUp);
102 this->globalKeyWentDown().connect(window, &WMainWindow::onKeyWentDown);
103}
104
106{
107 Wt::log("warning") << "stop WApplication";
108}
WMainApp(const Wt::WEnvironment &env)
Definition WMainApp.cpp:16
WMainWindow * window
Definition WMainApp.h:15
void onKeyWentDown(const Wt::WKeyEvent &event)
void onKeyWentUp(const Wt::WKeyEvent &evt)
void onKeyWentDown(const Wt::WKeyEvent &evt)
static SceneGraphFactory * instance()
Definition guid.cpp:5
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25