Clean up separation between plugins and app.
This commit is contained in:
parent
16baf6cdaf
commit
941f2d228c
@ -3,8 +3,7 @@
|
|||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
|
||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
||||||
|
|
||||||
Qtk is a Qt OpenGL graphics library created primarily for my own learning
|
Qtk is a Qt OpenGL graphics library that wraps some QOpenGL functionality in convenience classes
|
||||||
purposes. The library wraps some QOpenGL functionality in convenience classes
|
|
||||||
that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
|
that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
|
||||||
|
|
||||||
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
#include "qtkmainwindow.h"
|
#include "qtkmainwindow.h"
|
||||||
#include "ui_qtkmainwindow.h"
|
#include "ui_qtkmainwindow.h"
|
||||||
|
|
||||||
MainWindow * MainWindow::mainWindow_ = Q_NULLPTR;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Constructors / Destructors
|
* Constructors / Destructors
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -27,6 +25,10 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
|
|||||||
// Initialize static container for all active QtkWidgets
|
// Initialize static container for all active QtkWidgets
|
||||||
auto qtkWidgets = findChildren<Qtk::QtkWidget *>();
|
auto qtkWidgets = findChildren<Qtk::QtkWidget *>();
|
||||||
for (auto & qtkWidget : qtkWidgets) {
|
for (auto & qtkWidget : qtkWidgets) {
|
||||||
|
// NOTE: Set a temporary scene for the widget to use for initialization.
|
||||||
|
// This should be replaced by loading a scene, or creating a new (unsaved)
|
||||||
|
// scene when Qtk is opened.
|
||||||
|
qtkWidget->setScene(new EmptyScene);
|
||||||
views_.emplace(qtkWidget->getScene()->getSceneName(), qtkWidget);
|
views_.emplace(qtkWidget->getScene()->getSceneName(), qtkWidget);
|
||||||
|
|
||||||
// Add GUI 'view' toolbar option to show debug console.
|
// Add GUI 'view' toolbar option to show debug console.
|
||||||
@ -36,8 +38,7 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
|
|||||||
&Qtk::Scene::sceneUpdated,
|
&Qtk::Scene::sceneUpdated,
|
||||||
this,
|
this,
|
||||||
&MainWindow::refreshScene);
|
&MainWindow::refreshScene);
|
||||||
connect(qtkWidget,
|
connect(qtkWidget, &Qtk::QtkWidget::objectFocusChanged,
|
||||||
&Qtk::QtkWidget::objectFocusChanged,
|
|
||||||
ui_->qtk__ToolBox,
|
ui_->qtk__ToolBox,
|
||||||
&Qtk::ToolBox::updateFocus);
|
&Qtk::ToolBox::updateFocus);
|
||||||
}
|
}
|
||||||
@ -70,10 +71,8 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
MainWindow * MainWindow::getMainWindow()
|
MainWindow * MainWindow::getMainWindow()
|
||||||
{
|
{
|
||||||
if (mainWindow_ == Q_NULLPTR) {
|
static MainWindow window;
|
||||||
mainWindow_ = new MainWindow;
|
return &window;
|
||||||
}
|
|
||||||
return mainWindow_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qtk::QtkWidget * MainWindow::getQtkWidget(int64_t index)
|
Qtk::QtkWidget * MainWindow::getQtkWidget(int64_t index)
|
||||||
|
@ -22,6 +22,38 @@ namespace Ui
|
|||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty scene used for initializing all QtkWidgets within the MainWindow.
|
||||||
|
* This serves as a temporary placeholder for QtkScene (for example), which is
|
||||||
|
* defined in the separate qtk_gui target. The reason for this separation is to
|
||||||
|
* support the use of QtkWidgets (the qtk_plugins target) within the Qt Designer
|
||||||
|
* application without implementations provided in the Qtk Desktop Application.
|
||||||
|
*
|
||||||
|
* For the Qtk application, this should be replaced by loading the previous
|
||||||
|
* scene or creating a new _unsaved_ scene when the application is opened.
|
||||||
|
* Currently we have essentially hard-coded QtkScene to use as examples for
|
||||||
|
* testing the application. This means that the only way to create or modify a
|
||||||
|
* scene is to write code. Any modifications made in the application, such as
|
||||||
|
* moving or resizing objects, will not persist and cannot be saved.
|
||||||
|
*
|
||||||
|
* For users of Qtk Designer Plugins, this means that installing
|
||||||
|
* the `qtk_plugins` target to Qt Designer allows use all of the designer's
|
||||||
|
* features to build an interface and position or resize a QtkWidget as needed.
|
||||||
|
* The QtkWidget also appears as widget in the IDE's toolbars and can be added
|
||||||
|
* to any new application easily, once the plugins are installed.
|
||||||
|
*
|
||||||
|
* Once the application is designed, you can define a custom scene and use the
|
||||||
|
* Qtk API or Qt OpenGL funtions directly to render to it.
|
||||||
|
*
|
||||||
|
* Any application using a QtkWidget can set a custom scene in their main
|
||||||
|
* function. See the MainWindow::MainWindow constructor as an example.
|
||||||
|
*/
|
||||||
|
class EmptyScene : public Qtk::Scene {
|
||||||
|
void init() override {
|
||||||
|
setSceneName("Empty Scene");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MainWindow class to provide an example of using a QtkWidget within a Qt
|
* MainWindow class to provide an example of using a QtkWidget within a Qt
|
||||||
* window application.
|
* window application.
|
||||||
@ -82,7 +114,6 @@ class MainWindow : public QMainWindow
|
|||||||
MainWindow(const MainWindow &) {};
|
MainWindow(const MainWindow &) {};
|
||||||
|
|
||||||
Ui::MainWindow * ui_ {};
|
Ui::MainWindow * ui_ {};
|
||||||
static MainWindow * mainWindow_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a scene name to the QtkWidget viewing it.
|
* Maps a scene name to the QtkWidget viewing it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user