feat: qwidget layout

This commit is contained in:
Djairo Hougee 2024-05-26 03:03:21 +02:00
parent 4a5b7c4712
commit 7d7e1a5b95
8 changed files with 801 additions and 268 deletions

View File

@ -5,6 +5,7 @@ project(ParticleTrackTrace)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
@ -77,9 +78,10 @@ add_executable(ParticleTrackTrace MACOSX_BUNDLE main.cpp
advection/Vel.h advection/Vel.h
advection/kernel/SnapBoundaryConditionKernel.h advection/kernel/SnapBoundaryConditionKernel.h
advection/kernel/SnapBoundaryConditionKernel.cpp advection/kernel/SnapBoundaryConditionKernel.cpp
# QT/MainWindow.h QT/MainWindow.h
# QT/MainWindow.cpp QT/MainWindow.cpp
# QT/MainWindow.ui QT/MainWindow.ui
QT/ui_mainwindow.h
) )
execute_process( execute_process(

View File

@ -51,17 +51,17 @@ void Program::setupCameraCallback() {
this->interact->AddObserver(vtkCommand::KeyPressEvent, callback); this->interact->AddObserver(vtkCommand::KeyPressEvent, callback);
} }
Program::Program(int timerDT, vtkSmartPointer<vtkGenericOpenGLRenderWindow> win) { Program::Program(QWidget *parent): QVTKOpenGLNativeWidget(parent) {
// this->win = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New(); this->win = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
this->win = win;
// this->interact = vtkSmartPointer<vtkRenderWindowInteractor>::New(); // this->interact = vtkSmartPointer<vtkRenderWindowInteractor>::New();
// this->interact = vtkSmartPointer<QVTKInteractor>::New(); // this->interact = vtkSmartPointer<QVTKInteractor>::New();
setRenderWindow(this->win);
this->interact = win->GetInteractor(); this->interact = win->GetInteractor();
this->cam = createNormalisedCamera(); this->cam = createNormalisedCamera();
this->win->SetNumberOfLayers(0); this->win->SetNumberOfLayers(0);
setWinProperties(); setWinProperties();
setupTimer(timerDT); setupTimer(60 * 60); // FIXME: manually tracking this variable is a little stupid.
setupCameraCallback(); setupCameraCallback();
} }
@ -103,3 +103,7 @@ void Program::render() {
win->Render(); win->Render();
interact->Start(); interact->Start();
} }
Program::~Program() {
cout << "deleting program" << endl;
}

View File

@ -11,7 +11,9 @@
/** This class manages the upper levels of the vtk pipeline; it has attributes for the vtkrenderWindow and a vector of Layers to represent a variable number of vtkRenderers. /** This class manages the upper levels of the vtk pipeline; it has attributes for the vtkrenderWindow and a vector of Layers to represent a variable number of vtkRenderers.
* It can also set up a vtkTimer by connecting an instance of TimerCallbackCommand with its contained vtkRenderWindowInteractor. * It can also set up a vtkTimer by connecting an instance of TimerCallbackCommand with its contained vtkRenderWindowInteractor.
*/ */
class Program { class Program : public QVTKOpenGLNativeWidget {
Q_OBJECT
private: private:
/** This attribute models a variable number of vtkRenderers, managed through the abstract Layer class. /** This attribute models a variable number of vtkRenderers, managed through the abstract Layer class.
*/ */
@ -48,7 +50,8 @@ private:
public: public:
/** Constructor. /** Constructor.
*/ */
Program(int timerDT, vtkSmartPointer<vtkGenericOpenGLRenderWindow> win); Program(QWidget *parent = nullptr);
~Program() override;
/** This function adds a new layer (and thus vtkRenderer) to the program. /** This function adds a new layer (and thus vtkRenderer) to the program.
* The layer is expected to set its own position in the vtkRenderWindow layer system. * The layer is expected to set its own position in the vtkRenderWindow layer system.

View File

@ -1,4 +1,5 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_mainwindow.h"
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
@ -6,52 +7,144 @@
#include <vtkDataSetReader.h> #include <vtkDataSetReader.h>
#include "../layers/BackgroundImage.h"
#include "../layers/EColLayer.h"
#include "../layers/EGlyphLayer.h"
#include "../layers/LGlyphLayer.h"
#include "../Program.h"
#include "../advection/UVGrid.h"
#include "../advection/kernel/RK4AdvectionKernel.h"
#include "../advection/kernel/SnapBoundaryConditionKernel.h"
using namespace std;
MainWindow::MainWindow(QWidget* parent) MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
cout << "Reading data..." << endl;
string dataPath = "../../../../data";
shared_ptr<UVGrid> uvGrid = make_shared<UVGrid>(dataPath);
auto kernelRK4 = make_unique<RK4AdvectionKernel>(uvGrid);
auto kernelRK4BoundaryChecked = make_unique<SnapBoundaryConditionKernel>(std::move(kernelRK4), uvGrid);
cout << "Starting vtk..." << endl;
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4BoundaryChecked));
// l->spoofPoints();
l->setDt(3600);
// TODO: implement feature to call this function on widget
// l->cycleGlyphStyle();
Program *program = this->ui->getProgram();
program->addLayer(new BackgroundImage(dataPath + "/map_qgis_1035.png"));
// TODO: implement feature to cycle between layers thru QT
program->addLayer(new EGlyphLayer(uvGrid));
program->addLayer(new EColLayer(uvGrid));
program->addLayer(l);
program->setupInteractions();
} }
MainWindow::~MainWindow() { delete ui; } MainWindow::~MainWindow() {
delete ui;
void MainWindow::showAboutDialog()
{
QMessageBox::information(
this, "About",
"interactive particle in-fluid simulation program for surface level advection.");
} }
void MainWindow::showOpenFileDialog()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), "",
"VTK Files (*.vtk)");
// Open file void MainWindow::on_FirstButton_clicked(bool checked) {
QFile file(fileName); if (checked) {
file.open(QIODevice::ReadOnly);
// Return on Cancel
if (!file.exists())
return;
openFile(fileName);
}
void MainWindow::openFile(const QString& fileName)
{
ui->sceneWidget->removeDataSet();
// Create reader
vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New();
reader->SetFileName(fileName.toStdString().c_str());
// Read the file
reader->Update();
// Add data set to 3D view
vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutput();
if (dataSet != nullptr) {
ui->sceneWidget->addDataSet(reader->GetOutput());
} }
} }
void MainWindow::on_SecondButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_ComplentaryButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_ContrastingButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_MonochromaticButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_SaturateButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_DesaturateButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_CircleButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_TriangleButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_SquareButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_HexagonButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_FullySampledButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_RegularlySubsampledButton_clicked(bool checked) {
if (checked) {
}
}
void MainWindow::on_IregularlySampledButton_clicked(bool checked) {
if (checked) {
}}

View File

@ -14,19 +14,21 @@ public:
explicit MainWindow(QWidget* parent = 0); explicit MainWindow(QWidget* parent = 0);
~MainWindow(); ~MainWindow();
public slots: private slots:
//! Show the 'About this application' dialog void on_FirstButton_clicked(bool checked);
void showAboutDialog(); void on_SecondButton_clicked(bool checked);
void on_ComplentaryButton_clicked(bool checked);
//! Show the 'Open file...' dialog void on_ContrastingButton_clicked(bool checked);
void showOpenFileDialog(); void on_MonochromaticButton_clicked(bool checked);
void on_SaturateButton_clicked(bool checked);
protected: void on_DesaturateButton_clicked(bool checked);
//! Open a file void on_CircleButton_clicked(bool checked);
/*! void on_TriangleButton_clicked(bool checked);
\param[in] fileName The name of the file including the path void on_SquareButton_clicked(bool checked);
*/ void on_HexagonButton_clicked(bool checked);
void openFile(const QString& fileName); void on_FullySampledButton_clicked(bool checked);
void on_RegularlySubsampledButton_clicked(bool checked);
void on_IregularlySampledButton_clicked(bool checked);
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;

View File

@ -6,205 +6,350 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>1048</width>
<height>600</height> <height>772</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Qt VTK Viewer</string> <string>Simulation</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <item>
<number>0</number> <widget class="QGroupBox" name="settingsBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="topMargin"> <property name="minimumSize">
<number>0</number> <size>
<width>220</width>
<height>0</height>
</size>
</property> </property>
<property name="rightMargin"> <property name="maximumSize">
<number>0</number> <size>
<width>280</width>
<height>16777215</height>
</size>
</property> </property>
<property name="bottomMargin"> <property name="title">
<number>0</number> <string>Settings</string>
</property> </property>
<property name="spacing"> <layout class="QVBoxLayout" name="verticalLayout_3">
<number>0</number> <item>
<widget class="QGroupBox" name="TechniqueBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<item row="0" column="0"> <property name="minimumSize">
<widget class="SceneWidget" name="sceneWidget"/> <size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>Technique</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="FirstButton">
<property name="text">
<string>ECol + LGlyph</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="SecondButton">
<property name="text">
<string>EGlyph + LCol</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> </item>
<item>
<widget class="QGroupBox" name="ChannelBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>550</height>
</size>
</property>
<property name="title">
<string>Channel Options</string>
</property>
<widget class="QGroupBox" name="ColourBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>30</y>
<width>800</width> <width>300</width>
<height>21</height> <height>120</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>120</height>
</size>
</property>
<property name="title"> <property name="title">
<string>File</string> <string>Color</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QRadioButton" name="ComplementaryButton">
<property name="text">
<string>Complementary </string>
</property> </property>
<addaction name="actionOpenFile"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp"> </item>
<item>
<widget class="QRadioButton" name="ContrastingButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Contrasting</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="MonochromaticButton">
<property name="text">
<string>Monochromatic</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="SaturationBox">
<property name="geometry">
<rect>
<x>0</x>
<y>160</y>
<width>269</width>
<height>100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>100</height>
</size>
</property>
<property name="title"> <property name="title">
<string>Help</string> <string>Saturation</string>
</property> </property>
<addaction name="actionAbout"/> <property name="alignment">
</widget> <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<addaction name="menuFile"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionOpenFile"/>
<addaction name="actionZoomToExtent"/>
</widget>
<action name="actionOpenFile">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/open_file.png</normaloff>:/icons/open_file.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QRadioButton" name="SaturateButton">
<property name="text"> <property name="text">
<string>Open file...</string> <string>Fully saturated</string>
</property> </property>
<property name="toolTip">
<string>Open file...</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="actionZoomToExtent">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/zoom_to.png</normaloff>:/icons/zoom_to.png</iconset>
</property>
<property name="text">
<string>Zoom to extent</string>
</property>
<property name="toolTip">
<string>Zoom to extent</string>
</property>
</action>
<action name="actionQuit">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/quit.png</normaloff>:/icons/quit.png</iconset>
</property>
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/about.png</normaloff>:/icons/about.png</iconset>
</property>
<property name="text">
<string>About</string>
</property>
</action>
</widget> </widget>
</item>
<item>
<widget class="QRadioButton" name="DesaturateButton">
<property name="text">
<string>Desaturated</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="GlyphBox">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>260</width>
<height>150</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>Glyph Shape</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QRadioButton" name="radioButton_10">
<property name="text">
<string>Circle</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_11">
<property name="text">
<string>Triangle</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_12">
<property name="text">
<string>Square</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Hexagon</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="GlyphBox_2">
<property name="geometry">
<rect>
<x>0</x>
<y>430</y>
<width>260</width>
<height>120</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>120</height>
</size>
</property>
<property name="title">
<string>Glyph count</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QRadioButton" name="radioButton_13">
<property name="text">
<string>Fully sampled</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_14">
<property name="text">
<string>Regularly subsampled</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_15">
<property name="text">
<string>Irregularly sampled</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Program" name="program"/>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>SceneWidget</class> <class>MainView</class>
<extends>QOpenGLWidget</extends> <extends>QVTKOpenGLNativeWidget</extends>
<header>scenewidget.h</header> <header location="global">Program.h</header>
<slots>
<slot>zoomToExtent()</slot>
</slots>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources/>
<include location="resources.qrc"/> <connections/>
</resources>
<connections>
<connection>
<sender>actionOpenFile</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>showOpenFileDialog()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionQuit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionZoomToExtent</sender>
<signal>triggered()</signal>
<receiver>sceneWidget</receiver>
<slot>zoomToExtent()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>314</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionAbout</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>showAboutDialog()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>showOpenFileDialog()</slot>
<slot>showAboutDialog()</slot>
</slots>
</ui> </ui>

View File

@ -0,0 +1,282 @@
/********************************************************************************
** Form generated from reading UI file 'MainWindow.ui'
**
** Created by: Qt User Interface Compiler version 5.15.13
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include "../Program.h"
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QHBoxLayout *horizontalLayout;
QGroupBox *settingsBox;
QVBoxLayout *verticalLayout_3;
QGroupBox *TechniqueBox;
QVBoxLayout *verticalLayout_2;
QRadioButton *FirstButton;
QRadioButton *SecondButton;
QGroupBox *ChannelBox;
QGroupBox *ColourBox;
QVBoxLayout *verticalLayout_12;
QRadioButton *ComplementaryButton;
QRadioButton *ContrastingButton;
QRadioButton *MonochromaticButton;
QGroupBox *SaturationBox;
QVBoxLayout *verticalLayout_13;
QRadioButton *SaturateButton;
QRadioButton *DesaturateButton;
QGroupBox *GlyphBox;
QVBoxLayout *verticalLayout_14;
QRadioButton *CircleButton;
QRadioButton *TriangleButton;
QRadioButton *SquareButton;
QRadioButton *HexagonButton;
QGroupBox *GlyphBox_2;
QVBoxLayout *verticalLayout_16;
QRadioButton *FullySampledButton;
QRadioButton *RegularlySubsampledButton;
QRadioButton *IregularlySubsampledButton;
Program *program;
Program* getProgram() {
return program;
}
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(1048, 772);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
horizontalLayout = new QHBoxLayout(centralWidget);
horizontalLayout->setSpacing(6);
horizontalLayout->setContentsMargins(11, 11, 11, 11);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
settingsBox = new QGroupBox(centralWidget);
settingsBox->setObjectName(QString::fromUtf8("settingsBox"));
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(settingsBox->sizePolicy().hasHeightForWidth());
settingsBox->setSizePolicy(sizePolicy);
settingsBox->setMinimumSize(QSize(220, 0));
settingsBox->setMaximumSize(QSize(280, 16777215));
verticalLayout_3 = new QVBoxLayout(settingsBox);
verticalLayout_3->setSpacing(6);
verticalLayout_3->setContentsMargins(11, 11, 11, 11);
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
TechniqueBox = new QGroupBox(settingsBox);
TechniqueBox->setObjectName(QString::fromUtf8("TechniqueBox"));
sizePolicy.setHeightForWidth(TechniqueBox->sizePolicy().hasHeightForWidth());
TechniqueBox->setSizePolicy(sizePolicy);
TechniqueBox->setMinimumSize(QSize(0, 0));
TechniqueBox->setMaximumSize(QSize(500, 100));
verticalLayout_2 = new QVBoxLayout(TechniqueBox);
verticalLayout_2->setSpacing(6);
verticalLayout_2->setContentsMargins(11, 11, 11, 11);
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
FirstButton = new QRadioButton(TechniqueBox);
FirstButton->setObjectName(QString::fromUtf8("FirstButton"));
FirstButton->setChecked(true);
verticalLayout_2->addWidget(FirstButton);
SecondButton = new QRadioButton(TechniqueBox);
SecondButton->setObjectName(QString::fromUtf8("SecondButton"));
SecondButton->setChecked(false);
verticalLayout_2->addWidget(SecondButton);
verticalLayout_3->addWidget(TechniqueBox);
ChannelBox = new QGroupBox(settingsBox);
ChannelBox->setObjectName(QString::fromUtf8("ChannelBox"));
ChannelBox->setMinimumSize(QSize(0, 550));
ColourBox = new QGroupBox(ChannelBox);
ColourBox->setObjectName(QString::fromUtf8("ColourBox"));
ColourBox->setGeometry(QRect(0, 30, 300, 120));
sizePolicy.setHeightForWidth(ColourBox->sizePolicy().hasHeightForWidth());
ColourBox->setSizePolicy(sizePolicy);
ColourBox->setMinimumSize(QSize(250, 0));
ColourBox->setMaximumSize(QSize(500, 120));
ColourBox->setAlignment(Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter);
verticalLayout_12 = new QVBoxLayout(ColourBox);
verticalLayout_12->setSpacing(6);
verticalLayout_12->setContentsMargins(11, 11, 11, 11);
verticalLayout_12->setObjectName(QString::fromUtf8("verticalLayout_12"));
ComplementaryButton = new QRadioButton(ColourBox);
ComplementaryButton->setObjectName(QString::fromUtf8("ComplementaryButton"));
verticalLayout_12->addWidget(ComplementaryButton);
ContrastingButton = new QRadioButton(ColourBox);
ContrastingButton->setObjectName(QString::fromUtf8("ContrastingButton"));
QSizePolicy sizePolicy1(QSizePolicy::Maximum, QSizePolicy::Fixed);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(ContrastingButton->sizePolicy().hasHeightForWidth());
ContrastingButton->setSizePolicy(sizePolicy1);
verticalLayout_12->addWidget(ContrastingButton);
MonochromaticButton = new QRadioButton(ColourBox);
MonochromaticButton->setObjectName(QString::fromUtf8("MonochromaticButton"));
verticalLayout_12->addWidget(MonochromaticButton);
SaturationBox = new QGroupBox(ChannelBox);
SaturationBox->setObjectName(QString::fromUtf8("SaturationBox"));
SaturationBox->setGeometry(QRect(0, 160, 269, 100));
sizePolicy.setHeightForWidth(SaturationBox->sizePolicy().hasHeightForWidth());
SaturationBox->setSizePolicy(sizePolicy);
SaturationBox->setMinimumSize(QSize(260, 0));
SaturationBox->setMaximumSize(QSize(500, 100));
SaturationBox->setAlignment(Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter);
verticalLayout_13 = new QVBoxLayout(SaturationBox);
verticalLayout_13->setSpacing(6);
verticalLayout_13->setContentsMargins(11, 11, 11, 11);
verticalLayout_13->setObjectName(QString::fromUtf8("verticalLayout_13"));
SaturateButton = new QRadioButton(SaturationBox);
SaturateButton->setObjectName(QString::fromUtf8("SaturateButton"));
verticalLayout_13->addWidget(SaturateButton);
DesaturateButton = new QRadioButton(SaturationBox);
DesaturateButton->setObjectName(QString::fromUtf8("DesaturateButton"));
verticalLayout_13->addWidget(DesaturateButton);
GlyphBox = new QGroupBox(ChannelBox);
GlyphBox->setObjectName(QString::fromUtf8("GlyphBox"));
GlyphBox->setGeometry(QRect(0, 270, 260, 150));
sizePolicy.setHeightForWidth(GlyphBox->sizePolicy().hasHeightForWidth());
GlyphBox->setSizePolicy(sizePolicy);
GlyphBox->setMinimumSize(QSize(260, 0));
GlyphBox->setMaximumSize(QSize(500, 150));
GlyphBox->setAlignment(Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter);
verticalLayout_14 = new QVBoxLayout(GlyphBox);
verticalLayout_14->setSpacing(6);
verticalLayout_14->setContentsMargins(11, 11, 11, 11);
verticalLayout_14->setObjectName(QString::fromUtf8("verticalLayout_14"));
CircleButton = new QRadioButton(GlyphBox);
CircleButton->setObjectName(QString::fromUtf8("CircleButton"));
verticalLayout_14->addWidget(CircleButton);
TriangleButton = new QRadioButton(GlyphBox);
TriangleButton->setObjectName(QString::fromUtf8("TriangleButton"));
verticalLayout_14->addWidget(TriangleButton);
SquareButton = new QRadioButton(GlyphBox);
SquareButton->setObjectName(QString::fromUtf8("SquareButton"));
verticalLayout_14->addWidget(SquareButton);
HexagonButton = new QRadioButton(GlyphBox);
HexagonButton->setObjectName(QString::fromUtf8("HexagonButton"));
verticalLayout_14->addWidget(HexagonButton);
GlyphBox_2 = new QGroupBox(ChannelBox);
GlyphBox_2->setObjectName(QString::fromUtf8("GlyphBox_2"));
GlyphBox_2->setGeometry(QRect(0, 430, 260, 120));
QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(GlyphBox_2->sizePolicy().hasHeightForWidth());
GlyphBox_2->setSizePolicy(sizePolicy2);
GlyphBox_2->setMinimumSize(QSize(260, 0));
GlyphBox_2->setMaximumSize(QSize(500, 120));
GlyphBox_2->setAlignment(Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter);
verticalLayout_16 = new QVBoxLayout(GlyphBox_2);
verticalLayout_16->setSpacing(6);
verticalLayout_16->setContentsMargins(11, 11, 11, 11);
verticalLayout_16->setObjectName(QString::fromUtf8("verticalLayout_16"));
FullySampledButton = new QRadioButton(GlyphBox_2);
FullySampledButton->setObjectName(QString::fromUtf8("FullySampledButton"));
verticalLayout_16->addWidget(FullySampledButton);
RegularlySubsampledButton = new QRadioButton(GlyphBox_2);
RegularlySubsampledButton->setObjectName(QString::fromUtf8("RegularlySampledButton"));
verticalLayout_16->addWidget(RegularlySubsampledButton);
IregularlySubsampledButton = new QRadioButton(GlyphBox_2);
IregularlySubsampledButton->setObjectName(QString::fromUtf8("IregularlySubsampledButton"));
verticalLayout_16->addWidget(IregularlySubsampledButton);
verticalLayout_3->addWidget(ChannelBox);
horizontalLayout->addWidget(settingsBox);
program = new Program(centralWidget);
program->setObjectName(QString::fromUtf8("program"));
horizontalLayout->addWidget(program);
MainWindow->setCentralWidget(centralWidget);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "Simulation", nullptr));
settingsBox->setTitle(QCoreApplication::translate("MainWindow", "Settings", nullptr));
TechniqueBox->setTitle(QCoreApplication::translate("MainWindow", "Technique", nullptr));
FirstButton->setText(QCoreApplication::translate("MainWindow", "ECol + LGlyph", nullptr));
SecondButton->setText(QCoreApplication::translate("MainWindow", "EGlyph + LCol", nullptr));
ChannelBox->setTitle(QCoreApplication::translate("MainWindow", "Channel Options", nullptr));
ColourBox->setTitle(QCoreApplication::translate("MainWindow", "Color", nullptr));
ComplementaryButton->setText(QCoreApplication::translate("MainWindow", "Complementary ", nullptr));
ContrastingButton->setText(QCoreApplication::translate("MainWindow", "Contrasting", nullptr));
MonochromaticButton->setText(QCoreApplication::translate("MainWindow", "Monochromatic", nullptr));
SaturationBox->setTitle(QCoreApplication::translate("MainWindow", "Saturation", nullptr));
SaturateButton->setText(QCoreApplication::translate("MainWindow", "Fully saturated", nullptr));
DesaturateButton->setText(QCoreApplication::translate("MainWindow", "Desaturated", nullptr));
GlyphBox->setTitle(QCoreApplication::translate("MainWindow", "Glyph Shape", nullptr));
CircleButton->setText(QCoreApplication::translate("MainWindow", "Circle", nullptr));
TriangleButton->setText(QCoreApplication::translate("MainWindow", "Triangle", nullptr));
SquareButton->setText(QCoreApplication::translate("MainWindow", "Square", nullptr));
HexagonButton->setText(QCoreApplication::translate("MainWindow", "Hexagon", nullptr));
GlyphBox_2->setTitle(QCoreApplication::translate("MainWindow", "Glyph count", nullptr));
FullySampledButton->setText(QCoreApplication::translate("MainWindow", "Fully sampled", nullptr));
RegularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Regularly subsampled", nullptr));
IregularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Irregularly sampled", nullptr));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H

View File

@ -40,35 +40,37 @@ int main(int argc, char* argv[]) {
QApplication app(argc, argv); QApplication app(argc, argv);
// Main window. // Main window.
QMainWindow mainWindow; MainWindow mainWindow;
mainWindow.resize(1200, 900); mainWindow.resize(1200, 900);
mainWindow.show();
return app.exec();
// Control area. // Control area.
QDockWidget controlDock; // QDockWidget controlDock;
mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &controlDock); // mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &controlDock);
//
QLabel controlDockTitle("Control Dock"); // QLabel controlDockTitle("Control Dock");
controlDockTitle.setMargin(20); // controlDockTitle.setMargin(20);
controlDock.setTitleBarWidget(&controlDockTitle); // controlDock.setTitleBarWidget(&controlDockTitle);
//
QPointer<QVBoxLayout> dockLayout = new QVBoxLayout(); // QPointer<QVBoxLayout> dockLayout = new QVBoxLayout();
QWidget layoutContainer; // QWidget layoutContainer;
layoutContainer.setLayout(dockLayout); // layoutContainer.setLayout(dockLayout);
controlDock.setWidget(&layoutContainer); // controlDock.setWidget(&layoutContainer);
//
QPushButton randomizeButton; // QPushButton randomizeButton;
randomizeButton.setText("Randomize"); // randomizeButton.setText("Randomize");
dockLayout->addWidget(&randomizeButton); // dockLayout->addWidget(&randomizeButton);
// Render area. // Render area.
QPointer<QVTKOpenGLNativeWidget> vtkRenderWidget = // QPointer<QVTKOpenGLNativeWidget> vtkRenderWidget =
new QVTKOpenGLNativeWidget(); // new QVTKOpenGLNativeWidget();
mainWindow.setCentralWidget(vtkRenderWidget); // mainWindow.setCentralWidget(vtkRenderWidget);
// VTK part. // VTK part.
vtkNew<vtkGenericOpenGLRenderWindow> window; // vtkNew<vtkGenericOpenGLRenderWindow> window;
vtkRenderWidget->setRenderWindow(window.Get()); // vtkRenderWidget->setRenderWindow(window.Get());
cout << "Reading data..." << endl; cout << "Reading data..." << endl;
string dataPath = "../../../../data"; string dataPath = "../../../../data";
@ -83,7 +85,7 @@ int main(int argc, char* argv[]) {
// TODO: implement feature to call this function on widget // TODO: implement feature to call this function on widget
// l->cycleGlyphStyle(); // l->cycleGlyphStyle();
unique_ptr<Program> program = make_unique<Program>(DT, window); unique_ptr<Program> program = make_unique<Program>();
program->addLayer(new BackgroundImage(dataPath + "/map_qgis_1035.png")); program->addLayer(new BackgroundImage(dataPath + "/map_qgis_1035.png"));
// TODO: implement feature to cycle between layers thru QT // TODO: implement feature to cycle between layers thru QT
program->addLayer(new EGlyphLayer(uvGrid)); program->addLayer(new EGlyphLayer(uvGrid));