fix: unified dt
This commit is contained in:
@@ -9,68 +9,74 @@
|
||||
|
||||
#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 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) {
|
||||
// Note the use of reinterpret_cast to cast the caller to the expected type.
|
||||
auto interactor = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
||||
// Note the use of reinterpret_cast to cast the caller to the expected type.
|
||||
auto interactor = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
||||
|
||||
if (evId == vtkCommand::LeftButtonPressEvent) {
|
||||
dragging = true;
|
||||
}
|
||||
if (evId == vtkCommand::LeftButtonReleaseEvent) {
|
||||
dragging = false;
|
||||
}
|
||||
if (!dragging) {
|
||||
return;
|
||||
}
|
||||
if (evId == vtkCommand::LeftButtonPressEvent) {
|
||||
dragging = true;
|
||||
}
|
||||
if (evId == vtkCommand::LeftButtonReleaseEvent) {
|
||||
dragging = false;
|
||||
}
|
||||
if (!dragging) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x, y;
|
||||
interactor->GetEventPosition(x, y);
|
||||
int x, y;
|
||||
interactor->GetEventPosition(x, y);
|
||||
|
||||
double worldPos[4] = {2, 0 ,0, 0};
|
||||
double displayPos[3] = {static_cast<double>(x), static_cast<double>(y), 0.0};
|
||||
ren->SetDisplayPoint(displayPos);
|
||||
ren->DisplayToWorld();
|
||||
ren->GetWorldPoint(worldPos);
|
||||
inverseCartographicProjection->MultiplyPoint(worldPos, worldPos);
|
||||
cout << "clicked on lon = " << worldPos[0] << " and lat = " << worldPos[1] << endl;
|
||||
double worldPos[4] = {2, 0, 0, 0};
|
||||
double displayPos[3] = {static_cast<double>(x), static_cast<double>(y), 0.0};
|
||||
ren->SetDisplayPoint(displayPos);
|
||||
ren->DisplayToWorld();
|
||||
ren->GetWorldPoint(worldPos);
|
||||
inverseCartographicProjection->MultiplyPoint(worldPos, worldPos);
|
||||
cout << "clicked on lon = " << worldPos[0] << " and lat = " << worldPos[1] << endl;
|
||||
|
||||
vtkIdType id = points->InsertNextPoint(worldPos[0], worldPos[1], 0);
|
||||
data->SetPoints(points);
|
||||
vtkIdType id = points->InsertNextPoint(worldPos[0], worldPos[1], 0);
|
||||
data->SetPoints(points);
|
||||
|
||||
vtkSmartPointer<vtkVertex> vertex = vtkSmartPointer<vtkVertex>::New();
|
||||
vertex->GetPointIds()->SetId(0, id);
|
||||
vtkSmartPointer<vtkVertex> vertex = vtkSmartPointer<vtkVertex>::New();
|
||||
vertex->GetPointIds()->SetId(0, id);
|
||||
|
||||
vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
|
||||
vertices->InsertNextCell(vertex);
|
||||
data->SetVerts(vertices);
|
||||
ren->GetRenderWindow()->Render();
|
||||
vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
|
||||
vertices->InsertNextCell(vertex);
|
||||
data->SetVerts(vertices);
|
||||
ren->GetRenderWindow()->Render();
|
||||
}
|
||||
|
||||
|
||||
SpawnPointCallback::SpawnPointCallback() : data(nullptr), points(nullptr), inverseCartographicProjection(nullptr) {
|
||||
inverseCartographicProjection = getCartographicTransformMatrix();
|
||||
inverseCartographicProjection->Invert();
|
||||
}
|
||||
SpawnPointCallback::SpawnPointCallback() : data(nullptr),
|
||||
points(nullptr),
|
||||
inverseCartographicProjection(nullptr),
|
||||
uvGrid(nullptr) { }
|
||||
|
||||
SpawnPointCallback *SpawnPointCallback::New() {
|
||||
return new SpawnPointCallback;
|
||||
}
|
||||
|
||||
void SpawnPointCallback::setData(const vtkSmartPointer<vtkPolyData> &data) {
|
||||
this->data = data;
|
||||
this->data = data;
|
||||
}
|
||||
|
||||
void SpawnPointCallback::setPoints(const vtkSmartPointer<vtkPoints> &points) {
|
||||
this->points = points;
|
||||
this->points = points;
|
||||
}
|
||||
|
||||
void SpawnPointCallback::setRen(const vtkSmartPointer<vtkRenderer> &ren) {
|
||||
this->ren = ren;
|
||||
this->ren = ren;
|
||||
}
|
||||
|
||||
void SpawnPointCallback::setUVGrid(const std::shared_ptr<UVGrid> &uvGrid) {
|
||||
this->uvGrid = uvGrid;
|
||||
inverseCartographicProjection = getCartographicTransformMatrix(uvGrid);
|
||||
inverseCartographicProjection->Invert();
|
||||
}
|
||||
|
||||
@@ -7,26 +7,33 @@
|
||||
#include <vtkPoints.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkMatrix4x4.h>
|
||||
#include "../advection/UVGrid.h"
|
||||
|
||||
class SpawnPointCallback : public vtkCallbackCommand {
|
||||
|
||||
public:
|
||||
static SpawnPointCallback *New();
|
||||
SpawnPointCallback();
|
||||
static SpawnPointCallback *New();
|
||||
|
||||
void setPoints(const vtkSmartPointer<vtkPoints> &points);
|
||||
SpawnPointCallback();
|
||||
|
||||
void setData(const vtkSmartPointer<vtkPolyData> &data);
|
||||
void setPoints(const vtkSmartPointer<vtkPoints> &points);
|
||||
|
||||
void setData(const vtkSmartPointer<vtkPolyData> &data);
|
||||
|
||||
void setRen(const vtkSmartPointer<vtkRenderer> &ren);
|
||||
|
||||
void setUVGrid(const std::shared_ptr<UVGrid> &uvGrid);
|
||||
|
||||
void setRen(const vtkSmartPointer<vtkRenderer> &ren);
|
||||
private:
|
||||
vtkSmartPointer<vtkPolyData> data;
|
||||
vtkSmartPointer<vtkPoints> points;
|
||||
vtkSmartPointer<vtkRenderer> ren;
|
||||
vtkSmartPointer<vtkMatrix4x4> inverseCartographicProjection;
|
||||
vtkSmartPointer<vtkPolyData> data;
|
||||
vtkSmartPointer<vtkPoints> points;
|
||||
vtkSmartPointer<vtkRenderer> ren;
|
||||
std::shared_ptr<UVGrid> uvGrid;
|
||||
vtkSmartPointer<vtkMatrix4x4> inverseCartographicProjection;
|
||||
|
||||
void Execute(vtkObject *caller, unsigned long evId, void *callData) override;
|
||||
bool dragging = false;
|
||||
void Execute(vtkObject *caller, unsigned long evId, void *callData) override;
|
||||
|
||||
bool dragging = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,3 +38,7 @@ void TimerCallbackCommand::setProgram(Program *program) {
|
||||
void TimerCallbackCommand::setPaused(const bool val) {
|
||||
this->paused = val;
|
||||
}
|
||||
|
||||
void TimerCallbackCommand::setDt(int dt) {
|
||||
this->dt = dt;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ public:
|
||||
void setProgram(Program *program);
|
||||
void setPaused(const bool val);
|
||||
|
||||
void setDt(int dt);
|
||||
|
||||
private:
|
||||
int time;
|
||||
int dt;
|
||||
|
||||
Reference in New Issue
Block a user