feat: date legend
This commit is contained in:
parent
039163e8f0
commit
c825e63762
|
|
@ -61,6 +61,8 @@ add_executable(ParticleTrackTrace MACOSX_BUNDLE main.cpp
|
||||||
layers/enums.h
|
layers/enums.h
|
||||||
layers/LegendLayer.h
|
layers/LegendLayer.h
|
||||||
layers/LegendLayer.cpp
|
layers/LegendLayer.cpp
|
||||||
|
layers/TimeLayer.h
|
||||||
|
layers/TimeLayer.cpp
|
||||||
layers/luts.cpp
|
layers/luts.cpp
|
||||||
layers/luts.h
|
layers/luts.h
|
||||||
Program.cpp
|
Program.cpp
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include "../layers/LGlyphLayer.h"
|
#include "../layers/LGlyphLayer.h"
|
||||||
#include "../layers/enums.h"
|
#include "../layers/enums.h"
|
||||||
#include "../layers/LegendLayer.h"
|
#include "../layers/LegendLayer.h"
|
||||||
|
#include "../layers/TimeLayer.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -57,6 +58,11 @@ void MainWindow::setupTechniques() {
|
||||||
technique1->addLayer(new LegendLayer(dataPath + "/legends", "COLGLYPH"));
|
technique1->addLayer(new LegendLayer(dataPath + "/legends", "COLGLYPH"));
|
||||||
technique2->addLayer(new LegendLayer(dataPath + "/legends", "GLYPHCOL"));
|
technique2->addLayer(new LegendLayer(dataPath + "/legends", "GLYPHCOL"));
|
||||||
|
|
||||||
|
// add date/time layer
|
||||||
|
auto tm = new TimeLayer();
|
||||||
|
technique1->addLayer(tm);
|
||||||
|
technique1->addLayer(tm);
|
||||||
|
|
||||||
// add Euler layers
|
// add Euler layers
|
||||||
technique1->addLayer(new EColLayer(uvGrid));
|
technique1->addLayer(new EColLayer(uvGrid));
|
||||||
technique2->addLayer(new EGlyphLayer(uvGrid));
|
technique2->addLayer(new EGlyphLayer(uvGrid));
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,6 @@
|
||||||
|
|
||||||
#include "../CartographicTransformation.h"
|
#include "../CartographicTransformation.h"
|
||||||
|
|
||||||
void convertDisplayToWorld(vtkRenderer *renderer, int x, int y, double *worldPos) {
|
|
||||||
double displayPos[3] = {static_cast<double>(x), static_cast<double>(y), 0.0};
|
|
||||||
renderer->SetDisplayPoint(displayPos);
|
|
||||||
renderer->DisplayToWorld();
|
|
||||||
renderer->GetWorldPoint(worldPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpawnPointCallback::Execute(vtkObject *caller, unsigned long evId, void *callData) {
|
void SpawnPointCallback::Execute(vtkObject *caller, unsigned long evId, void *callData) {
|
||||||
// Note the use of reinterpret_cast to cast the caller to the expected type.
|
// Note the use of reinterpret_cast to cast the caller to the expected type.
|
||||||
auto interactor = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
auto interactor = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "TimeLayer.h"
|
||||||
|
#include <vtkTextProperty.h>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
TimeLayer::TimeLayer() {
|
||||||
|
this->ren = vtkSmartPointer<vtkRenderer>::New();
|
||||||
|
this->ren->SetLayer(4);
|
||||||
|
|
||||||
|
this->years = 0;
|
||||||
|
this->lastT = 0;
|
||||||
|
|
||||||
|
this->textActor = vtkSmartPointer<vtkTextActor>::New();
|
||||||
|
this->textActor->SetDisplayPosition(10, 10);
|
||||||
|
vtkSmartPointer<vtkTextProperty> textProp = this->textActor->GetTextProperty();
|
||||||
|
textProp->SetFontFamilyToArial();
|
||||||
|
textProp->BoldOn();
|
||||||
|
textProp->SetFontSize(16);
|
||||||
|
textProp->ShadowOff();
|
||||||
|
textProp->SetColor(0,0,0);
|
||||||
|
|
||||||
|
ren->AddActor(this->textActor);
|
||||||
|
}
|
||||||
|
|
||||||
|
string TimeLayer::secondsToDate(int t) {
|
||||||
|
if (t < lastT) this->years++;
|
||||||
|
|
||||||
|
int hours = t /3600;
|
||||||
|
int days = hours / 24;
|
||||||
|
|
||||||
|
this->lastT = t;
|
||||||
|
return string("year " + std::to_string(years) + ", day " + std::to_string(days));
|
||||||
|
// return string("seconds " + std::to_string(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TimeLayer::updateData(int t) {
|
||||||
|
this->textActor->SetInput(secondsToDate(t).c_str());
|
||||||
|
this->textActor->Modified();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef TIMELAYER_H
|
||||||
|
#define TIMELAYER_H
|
||||||
|
|
||||||
|
#include "Layer.h"
|
||||||
|
#include <vtkTextActor.h>
|
||||||
|
|
||||||
|
class TimeLayer : public Layer {
|
||||||
|
private:
|
||||||
|
std::string secondsToDate(int t);
|
||||||
|
int years;
|
||||||
|
int lastT;
|
||||||
|
vtkSmartPointer<vtkTextActor> textActor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TimeLayer();
|
||||||
|
void updateData(int t) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -196,16 +196,16 @@ vtkSmartPointer<vtkLookupTable> buildDensityComplementary() {
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
||||||
lut->SetTableValue(idx++, 0.0, 0.27058823529411763, 0.1607843137254902, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.0, 0.3911572472126105, 0.20901191849288736, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.10388312187620147, 0.4909496347558632, 0.2513033448673587, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.21568627450980393, 0.6196078431372549, 0.330718954248366, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.3724721261053441, 0.7283044982698962, 0.424559784698193, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.5651364859669358, 0.8175009611687812, 0.5119723183391004, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.7359477124183007, 0.8915032679738563, 0.5843137254901961, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.8795847750865051, 0.9526182237600923, 0.6601922337562476, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.9724413687043445, 0.9896655132641292, 0.7464667435601692, opacity);
|
|
||||||
lut->SetTableValue(idx++, 1.0, 1.0, 0.8980392156862745, opacity);
|
lut->SetTableValue(idx++, 1.0, 1.0, 0.8980392156862745, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.9724413687043445, 0.9896655132641292, 0.7464667435601692, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.8795847750865051, 0.9526182237600923, 0.6601922337562476, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.7359477124183007, 0.8915032679738563, 0.5843137254901961, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.5651364859669358, 0.8175009611687812, 0.5119723183391004, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.3724721261053441, 0.7283044982698962, 0.424559784698193, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.21568627450980393, 0.6196078431372549, 0.330718954248366, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.10388312187620147, 0.4909496347558632, 0.2513033448673587, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.0, 0.3911572472126105, 0.20901191849288736, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.0, 0.27058823529411763, 0.1607843137254902, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
lut->UseBelowRangeColorOn();
|
lut->UseBelowRangeColorOn();
|
||||||
|
|
@ -225,16 +225,16 @@ vtkSmartPointer<vtkLookupTable> buildDensityContrasting() {
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
||||||
lut->SetTableValue(idx++, 0.267004, 0.004874, 0.329415, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.281412, 0.155834, 0.469201, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.244972, 0.287675, 0.53726, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.190631, 0.407061, 0.556089, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.147607, 0.511733, 0.557049, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.119699, 0.61849, 0.536347, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.20803, 0.718701, 0.472873, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.430983, 0.808473, 0.346476, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.709898, 0.868751, 0.169257, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.993248, 0.906157, 0.143936, opacity);
|
lut->SetTableValue(idx++, 0.993248, 0.906157, 0.143936, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.709898, 0.868751, 0.169257, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.430983, 0.808473, 0.346476, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.20803, 0.718701, 0.472873, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.119699, 0.61849, 0.536347, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.147607, 0.511733, 0.557049, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.190631, 0.407061, 0.556089, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.244972, 0.287675, 0.53726, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.281412, 0.155834, 0.469201, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.267004, 0.004874, 0.329415, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
lut->UseBelowRangeColorOn();
|
lut->UseBelowRangeColorOn();
|
||||||
|
|
@ -254,16 +254,16 @@ vtkSmartPointer<vtkLookupTable> buildDensityMonochromatic() {
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
for (double opacity=0.5; opacity <= 1.0; opacity+=0.05) {
|
||||||
lut->SetTableValue(idx++, 0.0, 0.26666666666666666, 0.10588235294117647, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.0, 0.4079046520569012, 0.16444444444444445, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.10388312187620147, 0.5164936562860438, 0.2467512495194156, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.21568627450980393, 0.6287581699346405, 0.3333333333333333, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.36392156862745095, 0.7240292195309497, 0.4181468665897732, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.5351787773933102, 0.8060899653979239, 0.5287504805843906, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.681045751633987, 0.8718954248366013, 0.6562091503267974, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.8089965397923875, 0.9251672433679354, 0.7834525182622069, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.9066205305651672, 0.9641214917339485, 0.8884429065743944, opacity);
|
|
||||||
lut->SetTableValue(idx++, 0.9686274509803922, 0.9882352941176471, 0.9607843137254902, opacity);
|
lut->SetTableValue(idx++, 0.9686274509803922, 0.9882352941176471, 0.9607843137254902, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.9066205305651672, 0.9641214917339485, 0.8884429065743944, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.8089965397923875, 0.9251672433679354, 0.7834525182622069, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.681045751633987, 0.8718954248366013, 0.6562091503267974, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.5351787773933102, 0.8060899653979239, 0.5287504805843906, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.36392156862745095, 0.7240292195309497, 0.4181468665897732, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.21568627450980393, 0.6287581699346405, 0.3333333333333333, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.10388312187620147, 0.5164936562860438, 0.2467512495194156, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.0, 0.4079046520569012, 0.16444444444444445, opacity);
|
||||||
|
lut->SetTableValue(idx++, 0.0, 0.26666666666666666, 0.10588235294117647, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
lut->UseBelowRangeColorOn();
|
lut->UseBelowRangeColorOn();
|
||||||
|
|
@ -283,8 +283,8 @@ vtkSmartPointer<vtkLookupTable> buildDensityDesaturated() {
|
||||||
lut->Build();
|
lut->Build();
|
||||||
|
|
||||||
vtkNew<vtkColorTransferFunction> colorTransferFunction;
|
vtkNew<vtkColorTransferFunction> colorTransferFunction;
|
||||||
colorTransferFunction->AddRGBPoint(0, 0.313725, 0.313725, 0.313725);
|
colorTransferFunction->AddRGBPoint(0, 0.909804, 0.909804, 0.909804);
|
||||||
colorTransferFunction->AddRGBPoint(9, 0.909804, 0.909804, 0.909804);
|
colorTransferFunction->AddRGBPoint(9, 0.313725, 0.313725, 0.313725);
|
||||||
double c[3];
|
double c[3];
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,8 @@
|
||||||
#include <QVTKOpenGLNativeWidget.h>
|
#include <QVTKOpenGLNativeWidget.h>
|
||||||
#include "QT/MainWindow.h"
|
#include "QT/MainWindow.h"
|
||||||
|
|
||||||
// TODO: add a widget to act as legend. This is fourfold: LCol-density, Lcol-age, ECol-strength?
|
|
||||||
// TODO: add text widget showing simulation time (in days/weeks/months from 0).
|
|
||||||
// TODO: make Lagrangian Layers share one vtkPoints for seemless technique switching
|
|
||||||
// TODO: make LColLayer use a modified spawnpointCallback to spawn multiple particles per interaction
|
// TODO: make LColLayer use a modified spawnpointCallback to spawn multiple particles per interaction
|
||||||
|
// TODO: make Lagrangian Layers share one vtkPoints for seemless technique swiching
|
||||||
// TODO: add text gui explaining the above?
|
// TODO: add text gui explaining the above?
|
||||||
// TODO: yoink Robin's isNearestNeighbourZero function to improve beaching
|
// TODO: yoink Robin's isNearestNeighbourZero function to improve beaching
|
||||||
// TODO: add a button to reset the simulation - set time=0 and reset points array of particles.
|
// TODO: add a button to reset the simulation - set time=0 and reset points array of particles.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue