Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D & 3D Data Visualization #70

Draft
wants to merge 36 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9312420
Update CMakeLists.txt
Pranavya-Vivek Aug 14, 2023
fbe9bb5
Create 2d file
Pranavya-Vivek Aug 14, 2023
97b1485
Rename 2d to 2d.cpp
Pranavya-Vivek Aug 14, 2023
a80eeff
Update 2d
Pranavya-Vivek Aug 14, 2023
13f1424
Update main.cpp
Pranavya-Vivek Aug 14, 2023
1987366
Create CMakeLists.txt
Pranavya-Vivek Aug 14, 2023
9aefb99
Create mainwindow_funcs.cpp
Pranavya-Vivek Aug 15, 2023
4e81b75
Create mainwindow.h
Pranavya-Vivek Aug 15, 2023
2acf307
Create mainwindow.ui
Pranavya-Vivek Aug 15, 2023
25580d9
Create CMakeLists.txt
Pranavya-Vivek Aug 15, 2023
1d09c54
Create main.cpp
Pranavya-Vivek Aug 15, 2023
8b0e753
Create mainwindow_funcs.cpp
Pranavya-Vivek Aug 15, 2023
a5be5eb
Create mainwindow.h
Pranavya-Vivek Aug 15, 2023
215f076
Create mainwindow.ui
Pranavya-Vivek Aug 15, 2023
1aa825b
Update CMakeLists.txt
Pranavya-Vivek Aug 15, 2023
4d4b993
Update widget.cpp
Pranavya-Vivek Aug 15, 2023
ddcd043
Update widget.h
Pranavya-Vivek Aug 15, 2023
8b379e2
Update data2d.cpp
Pranavya-Vivek Aug 15, 2023
d25db0c
Update data2d.h
Pranavya-Vivek Aug 15, 2023
fc35897
Update data3d.cpp
Pranavya-Vivek Aug 15, 2023
3036b9d
Update data3d.h
Pranavya-Vivek Aug 15, 2023
ef7c035
Update CMakeLists.txt
Pranavya-Vivek Aug 15, 2023
9419fc3
Create base.h
Pranavya-Vivek Aug 15, 2023
40bda84
Create CMakeLists.txt
Pranavya-Vivek Aug 15, 2023
6e0b691
Create line.cpp
Pranavya-Vivek Aug 15, 2023
06affea
Create line.h
Pranavya-Vivek Aug 15, 2023
4c378c9
Create stylefactory.cpp
Pranavya-Vivek Aug 15, 2023
73615fc
Create stylefactory.h
Pranavya-Vivek Aug 15, 2023
2d752b6
Create base.h
Pranavya-Vivek Aug 15, 2023
842d7d1
Create CMakeLists.txt
Pranavya-Vivek Aug 15, 2023
898f87f
Create contours.cpp
Pranavya-Vivek Aug 15, 2023
b39d9ea
Create contours.h
Pranavya-Vivek Aug 15, 2023
7fa2ffe
Create line.cpp
Pranavya-Vivek Aug 15, 2023
9d70d40
Create line.h
Pranavya-Vivek Aug 15, 2023
32bb735
Create stylefactory.cpp
Pranavya-Vivek Aug 15, 2023
0ccb324
Create stylefactory.h
Pranavya-Vivek Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions examples/2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set(target_name 2d)

# Meta-Objects
set(${target_name}_MOC_HDRS mainwindow.h)
qt6_wrap_cpp(${target_name}_MOC_SRCS ${${target_name}_MOC_HDRS})

# Add executable target(s)
add_executable(${target_name} main.cpp mainwindow.ui ${${target_name}_MOC_SRCS}
mainwindow_funcs.cpp)

# Set project-local include directories for target
target_include_directories(
${target_name}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src
${PROJECT_BINARY_DIR}/examples/${target_name}
${PROJECT_SOURCE_DIR}/examples/${target_name}
${Qt6Core_INCLUDE_DIRS}
${Qt6Gui_INCLUDE_DIRS}
${Qt6OpenGL_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS})

target_link_libraries(${target_name} PRIVATE # External libs
mildred)

set_target_properties(${target_name} PROPERTIES RUNTIME ${target_name})

install(TARGETS ${target_name} RUNTIME)
12 changes: 12 additions & 0 deletions examples/2d/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <QApplication>

#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;

mainWindow.show();
return app.exec();
}
43 changes: 43 additions & 0 deletions examples/2d/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include "entities/data2d.h"
#include "ui_mainwindow.h"

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();
~MainWindow() = default;

/*
* UI
*/

private:
// Main form declaration
Ui::MainWindow ui_;

/*
* Data
*/
private:
// Data limits
double dataMin_{-5.0}, dataMax_{5.0};
// Data granularity
int nPoints_{1000};
// Test data
std::vector<double> x_, y_, values_;
// Entity for data
Mildred::Data2DEntity *dataEntity_{nullptr};

public:
// Function Types
enum Test2DFunctions
{
AckleyFunction
};
// Generate specified function
void generateFunction(Test2DFunctions function);
};
260 changes: 260 additions & 0 deletions examples/2d/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>956</width>
<height>713</height>
</rect>
</property>
<property name="windowTitle">
<string>Basic Test</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Mildred::MildredWidget" name="TestingWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>View</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QPushButton" name="ResetViewButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="FlatViewCheck">
<property name="text">
<string>Flat (2D)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ShowSceneCuboidCheck">
<property name="text">
<string>Show scene bounding cuboid</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Axes</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="ZTitleEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="XTitleEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="YTitleEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="XVisibleCheck">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="YVisibleCheck">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="ZVisibleCheck">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Mouse Coordinates</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mouseCoordStyleCombo"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="externalMouseCoordLabel">
<property name="text">
<string>External</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>956</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>Mildred::MildredWidget</class>
<extends>QWidget</extends>
<header>widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
51 changes: 51 additions & 0 deletions examples/2d/mainwindow_funcs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "mainwindow.h"
#include "material.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow() : QMainWindow()
{
ui_.setupUi(this);

generateFunction(Test2DFunctions::AckleyFunction);
dataEntity_ = ui_.TestingWidget->addData2D("2D Function");
dataEntity_->setData(x_, y_, values_);

ui_.TestingWidget->zAxis()->setEnabled(true);
ui_.TestingWidget->zAxis()->setType(Mildred::AxisEntity::AxisType::Vertical);
//ui_.TestingWidget->yAxis()->setType(Mildred::AxisEntity::AxisType::Depth);

ui_.TestingWidget->showAllData();
};

// Generate specified function
void MainWindow::generateFunction(Test2DFunctions function)
{
// Initialise the data and calculate the delta
// Data, all bounded to [-5,5] in x and y
const auto axisMin = -50.0, axisMax = 50.0, delta = (axisMax - axisMin) / (nPoints_ - 1);

x_.reserve(nPoints_);
x_.clear();
values_.reserve(nPoints_ * nPoints_);
values_.clear();

// Generate x axis and duplicate as y
for (auto n = 0; n <= nPoints_; ++n)
x_.push_back(n * delta);
y_ = x_;

switch (function)
{
case (Test2DFunctions::AckleyFunction):
/*
* Ackley's Function
* f(x,y) = -20.0 * exp(-0.2 * sqrt(0.5 * (x^2 + y^2))) - exp(0.5 * (cos(2 * M_PI * x) + cos(2 * M_PI * y))) + e +
* 20
*/
for (const auto x : x_)
for (const auto y : y_)
values_.push_back(-20.0 * exp(-0.2 * sqrt(0.5 * (x * x + y * y))) -
exp(0.5 * (cos(2 * M_PI * x) + cos(2 * M_PI * y))) + M_E + 20);
break;
}
}
Loading