working ver with QT

This commit is contained in:
2024-05-25 14:35:54 +02:00
parent 7d6b9cb047
commit 4a5b7c4712
7 changed files with 397 additions and 20 deletions

View File

@@ -18,11 +18,58 @@
#include "advection/kernel/RK4AdvectionKernel.h"
#include "advection/kernel/SnapBoundaryConditionKernel.h"
#include <QApplication>
#include <QVTKOpenGLNativeWidget.h>
#include <QDockWidget>
#include <QGridLayout>
#include <vtkGenericOpenGLRenderWindow.h>
#include <QLabel>
#include <QMainWindow>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
#include "QT/MainWindow.h"
using namespace std;
#define DT 60 * 60 // 60 sec/min * 60 mins
int main() {
int main(int argc, char* argv[]) {
QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());
QApplication app(argc, argv);
// Main window.
QMainWindow mainWindow;
mainWindow.resize(1200, 900);
// Control area.
QDockWidget controlDock;
mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &controlDock);
QLabel controlDockTitle("Control Dock");
controlDockTitle.setMargin(20);
controlDock.setTitleBarWidget(&controlDockTitle);
QPointer<QVBoxLayout> dockLayout = new QVBoxLayout();
QWidget layoutContainer;
layoutContainer.setLayout(dockLayout);
controlDock.setWidget(&layoutContainer);
QPushButton randomizeButton;
randomizeButton.setText("Randomize");
dockLayout->addWidget(&randomizeButton);
// Render area.
QPointer<QVTKOpenGLNativeWidget> vtkRenderWidget =
new QVTKOpenGLNativeWidget();
mainWindow.setCentralWidget(vtkRenderWidget);
// VTK part.
vtkNew<vtkGenericOpenGLRenderWindow> window;
vtkRenderWidget->setRenderWindow(window.Get());
cout << "Reading data..." << endl;
string dataPath = "../../../../data";
shared_ptr<UVGrid> uvGrid = make_shared<UVGrid>(dataPath);
@@ -31,19 +78,31 @@ int main() {
cout << "Starting vtk..." << endl;
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4BoundaryChecked));
l->spoofPoints();
// l->spoofPoints();
l->setDt(DT);
// TODO: implement feature to call this function on widget
l->cycleGlyphStyle();
// l->cycleGlyphStyle();
unique_ptr<Program> program = make_unique<Program>(DT);
unique_ptr<Program> program = make_unique<Program>(DT, window);
program->addLayer(new BackgroundImage(dataPath + "/map_qgis_1035.png"));
// program->addLayer(new EGlyphLayer(uvGrid));
// TODO: implement feature to cycle between layers thru QT
program->addLayer(new EGlyphLayer(uvGrid));
program->addLayer(new EColLayer(uvGrid));
program->addLayer(l);
program->render();
program->setupInteractions();
return EXIT_SUCCESS;
// program->render();
// Setup initial status.
// std::mt19937 randEng(0);
// ::Randomize(sphere, mapper, window, randEng);
// connect the buttons
// QObject::connect(&randomizeButton, &QPushButton::released,
// [&]() { ::Randomize(sphere, mapper, window, randEng); });
mainWindow.show();
return app.exec();
}