PeriDyno 1.2.1
Loading...
Searching...
No Matches
QtApp.cpp
Go to the documentation of this file.
1#include <QMap>
2#include <QDebug>
3#include <QFile>
4#include "QtApp.h"
5#include "PMainWindow.h"
6#include "POpenGLWidget.h"
7#include "Log.h"
8
9#include "SceneGraphFactory.h"
11
12#include <OrbitCamera.h>
13
14namespace dyno {
15 QtApp::QtApp(int argc, char **argv)
16 : AppBase()
17 {
18#ifdef CUDA_BACKEND
19 auto status = cudaSetDevice(0);
20 if (status != cudaSuccess) {
21 fprintf(stderr, "CUDA initialization failed! Do you have a CUDA-capable GPU installed?");
22 exit(0);
23 }
24 cudaFree(0);
25#endif // CUDA_BACKEND
26
27 mMainWindow = nullptr;
28
29 //To fix the displace scaling issue
30 QApplication::setAttribute(Qt::AA_Use96Dpi);
31 qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
32
33 mQApp = std::make_shared<QApplication>(argc, argv);
34
35 //Set default GUI style
36 QFile file(":/dyno/DarkStyle.qss");
37 file.open(QIODevice::ReadOnly);
38
39 QString style = file.readAll();
40 mQApp->setStyleSheet(style);
41
42 //To resolver the error "Cannot queue arguments of type of Log::Message" for multi-thread applications
43 qRegisterMetaType<Log::Message>("Log::Message");
44 }
45
47 {
48
49 }
50
51 void QtApp::initialize(int width, int height, bool usePlugin)
52 {
53 //A hack to address the slow launching problem
54
55 if (usePlugin)
56 {
57#ifdef NDEBUG
58 PluginManager::instance()->loadPluginByPath(getPluginPath() + "Release");
59#else
60 PluginManager::instance()->loadPluginByPath(getPluginPath() + "Debug");
61#endif // DEBUG
62 }
63
64 mMainWindow = std::make_shared<PMainWindow>(this);
65 mMainWindow->resize(width, height);
66 mMainWindow->show();
67 }
68
70 {
71 mQApp->exec();
72 }
73
74 void QtApp::setSceneGraph(std::shared_ptr<SceneGraph> scn)
75 {
78 }
79
80 void QtApp::setWindowTitle(const std::string& str)
81 {
82 mMainWindow->setWindowTitle(QString::fromStdString(str));
83 }
84
86 {
87 return dynamic_cast<RenderWindow*>(mMainWindow->openglWidget());
88 }
89
90}
91
virtual void setSceneGraph(std::shared_ptr< SceneGraph > scene)
Definition AppBase.h:25
static PluginManager * instance()
void loadPluginByPath(const std::string &pathName)
void setSceneGraph(std::shared_ptr< SceneGraph > scn)
Definition QtApp.cpp:74
RenderWindow * renderWindow() override
Definition QtApp.cpp:85
std::shared_ptr< PMainWindow > mMainWindow
Definition QtApp.h:33
void mainLoop() override
Definition QtApp.cpp:69
std::shared_ptr< QApplication > mQApp
Definition QtApp.h:32
QtApp(int argc=0, char **argv=NULL)
Definition QtApp.cpp:15
void initialize(int width, int height, bool usePlugin=true) override
Definition QtApp.cpp:51
void setWindowTitle(const std::string &str)
Definition QtApp.cpp:80
static SceneGraphFactory * instance()
void pushScene(std::shared_ptr< SceneGraph > scn)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25