Skip to content
Snippets Groups Projects
Commit 9c66d8f8 authored by Jan Burle's avatar Jan Burle
Browse files

a rough demo of a square lattice

parent dca7cd60
No related branches found
No related tags found
No related merge requests found
Showing
with 321 additions and 21 deletions
......@@ -18,7 +18,7 @@ include_directories(${include_dirs})
set (CMAKE_AUTOMOC ON)
add_subdirectory (ba3d)
# add_subdirectory (main)
add_subdirectory (showcase)
add_subdirectory (demo)
set(library_name ba3d)
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.2, 2017-05-19T13:38:16. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{8299bc76-dc32-4b71-a112-72e972822756}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">1</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">5.8.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">5.8.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{4dd9a07a-5f97-4a99-a8d3-ff4705d6ae0d}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">CMAKE_BUILD_TYPE:STRING=Debug</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jan/C/+dev/gh/BornAgain/GUI/build-ba3d-5_8_0-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<valuelist type="QVariantList" key="CMake.Configuration">
<value type="QString">CMAKE_BUILD_TYPE:STRING=Release</value>
</valuelist>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jan/C/+dev/gh/BornAgain/GUI/build-ba3d-5_8_0-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString"></value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">ba3d_app</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">/private/var/folders/mm/wk5dmrls1cj2cmysz7mnjsw40000gn/T/qtc-cmake-FMKlRG/demo</value>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ba3d_app</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.ba3d_app</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>
......@@ -8,7 +8,7 @@
namespace ba3d {
//------------------------------------------------------------------------------
Object::Object(geometry::key gky_) : color(Qt::gray)
Object::Object(geometry::key gky_) : color(Qt::black)
, isNull(false), model(nullptr), gky(gky_) {
}
......
......@@ -34,9 +34,7 @@ void Widget3D::setModel(Model* model) {
disconnect(modelUpdated);
canvas->setModel(model);
connect(model, &Model::updated, [this]() {
update();
});
connect(model, &Model::updated, this, &Widget3D::update);
}
Model* Widget3D::getModel() {
......
set (app ba3d_app)
set (app ba3d_demo)
find_package (Qt5Core REQUIRED)
find_package (Qt5Gui REQUIRED)
find_package (Qt5Widgets REQUIRED)
find_package (Qt5Core REQUIRED)
find_package (Qt5Gui REQUIRED)
find_package (Qt5Widgets REQUIRED)
find_package (OpenGL)
file (GLOB_RECURSE files *)
......
// GPL3; https://github.com/jburle/ba3d
#include "demo_model.h"
#include <ba3d/model/layer.h>
#include "lattice.h"
#include <ba3d/model/layer.h>
#include <QApplication>
#include <thread>
#include <qmath.h>
//------------------------------------------------------------------------------
using namespace ba3d;
DemoModel::DemoModel() {
flt const sz = 80; //0;
spacing = 20; // of particles
DemoModel::DemoModel() : busy(0) {
flt const sz = 1200;
spacing = 20; // of particles
defEye = xyz(10, 10, sz);
defCtr = xyz(0, 0, -20);
......@@ -35,6 +37,8 @@ DemoModel::DemoModel() {
}
void DemoModel::calc(float sigma) {
++busy;
auto mesh = squareLattice(n, sigma);
for (auto& m: mesh)
m = m * spacing + xyz(0, 0, -20);
......@@ -68,11 +72,36 @@ void DemoModel::calc(float sigma) {
}
p->transform(xyz::_0, pos);
}
// emit updated(); TODO async
emit updated();
qApp->processEvents();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
emit updated();
--busy;
}
void DemoModel::flip() {
++busy;
if (!activeMesh.empty()) {
for (int deg=0; deg <=360; deg += 5) {
for (uint i=0; i < ps.count(); ++i) {
auto& p = ps.at(i);
auto& pos = activeMesh[i];
p->transform(xyz(0,deg,0), pos);
}
emit updated();
qApp->processEvents();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
emit updated();
--busy;
}
//------------------------------------------------------------------------------
......
......@@ -5,6 +5,7 @@
#include <ba3d/model/model.h>
#include <ba3d/model/particles.h>
#include <QAtomicInteger>
//------------------------------------------------------------------------------
......@@ -12,11 +13,17 @@ class DemoModel : public ba3d::Model {
public:
DemoModel();
void calc(float sigma);
void flip();
bool ready() {
return 0 == busy;
}
private:
uint n; float spacing;
QVector<ba3d::particle::Particle*> ps;
QVector<ba3d::xyz> activeMesh;
QAtomicInteger<int> busy;
};
//------------------------------------------------------------------------------
......
......@@ -8,6 +8,7 @@
#include <QSlider>
#include <QSettings>
#include <QPushButton>
#include <QKeyEvent>
//------------------------------------------------------------------------------
......@@ -26,6 +27,15 @@ void MainWin::closeEvent(QCloseEvent*) {
s.setValue(MAINWIN_GEOMETRY, saveGeometry());
}
void MainWin::keyPressEvent(QKeyEvent* e) {
if ("q" == e->text())
close();
}
void MainWin::mouseDoubleClickEvent(QMouseEvent*) {
}
void MainWin::createLayout() {
setCentralWidget(new QWidget);
......@@ -39,7 +49,8 @@ void MainWin::createLayout() {
vb->addLayout(hb);
sigmaSlider = new QSlider(Qt::Horizontal);
auto recalcButton = new QPushButton("Recalc");
auto calcButton = new QPushButton("Calc");
auto flipButton = new QPushButton("Flip");
sigmaSlider->setRange(0,30);
sigmaSlider->setSingleStep(5);
......@@ -48,12 +59,29 @@ void MainWin::createLayout() {
hb->addStretch();
hb->addWidget(sigmaSlider);
hb->addWidget(recalcButton);
hb->addWidget(calcButton);
hb->addWidget(flipButton);
connect(recalcButton, &QPushButton::clicked, [this]() {
auto calc = [this]() {
auto model = dynamic_cast<DemoModel*>(w3d->getModel());
if (model)
if (model && model->ready()) {
model->calc(sigmaSlider->value() / 100.f);
}
};
auto flip = [this]() {
auto model = dynamic_cast<DemoModel*>(w3d->getModel());
if (model) {
model->flip();
}
};
connect(calcButton, &QPushButton::clicked, [calc]() {
calc();
});
connect(flipButton, &QPushButton::clicked, [flip]() {
flip();
});
}
......
......@@ -22,12 +22,13 @@ public:
private:
void closeEvent(QCloseEvent*);
void keyPressEvent(QKeyEvent*);
void mouseDoubleClickEvent(QMouseEvent*);
void createLayout();
ba3d::Widget3D *w3d;
QWidget *controls;
QSlider *sigmaSlider;
void createLayout();
};
//------------------------------------------------------------------------------
......
set (app ba3d_app)
set (app ba3d_showcase)
find_package (Qt5Core REQUIRED)
find_package (Qt5Gui REQUIRED)
......
File moved
......@@ -27,6 +27,11 @@ void MainWin::closeEvent(QCloseEvent*) {
s.setValue(MAINWIN_GEOMETRY, saveGeometry());
}
void MainWin::keyPressEvent(QKeyEvent* e) {
if ("q" == e->text())
close();
}
void MainWin::createLayout() {
setCentralWidget(new QWidget);
......
......@@ -33,6 +33,7 @@ signals:
private:
void closeEvent(QCloseEvent*);
void keyPressEvent(QKeyEvent*);
ba3d::Widget3D *w3d_1, *w3d_2, *w3d_3;
QComboBox *combo;
......
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment