...
 
Commits (2)
......@@ -1773,23 +1773,18 @@ bool SaxParser::LoadTrainTimetable(std::string Filename, std::map<int, std::shar
for (TiXmlElement* e = xTTT->FirstChildElement("train"); e;
e = e->NextSiblingElement("train")) {
std::shared_ptr<TrainTimeTable> TTT = parseTrainTimeTableNode(e);
std::cout << "SI BEFORE" << trainTimeTables.size() << "\n";
if (TTT) { // todo: maybe get pointer to train
if (trainTimeTables.count(TTT->id)!=0) {
Debug::Messages("WARNING: Duplicate id for train time table found [%d]",TTT->id);
exit(EXIT_FAILURE);
}
std::cout << "parse " << TTT->id << "\n";
trainTimeTables[TTT->id] = TTT;
}
else {
std:cout << "HHH\n" ;
std:cout << "too bad! \n" ;
}
std::cout << "SI AFTER" << trainTimeTables.size() << "\n";
}
}
return true;
}
......@@ -1880,6 +1875,9 @@ std::shared_ptr<TrainTimeTable> SaxParser::parseTrainTimeTableNode(TiXmlElement
platform_id,
false,
false,
vtkSmartPointer<vtkPolyDataMapper>::New(),
vtkSmartPointer<vtkActor>::New(),
vtkSmartPointer<vtkTextActor3D>::New(),
});
return trainTimeTab;
......
......@@ -106,6 +106,9 @@
using namespace std;
static int once=1;
TimerCallback* TimerCallback::New()
{
TimerCallback *cb = new TimerCallback;
......@@ -163,10 +166,17 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId,
double now = frameNumber*iren->GetTimerDuration(tid)/1000;
// {
// for (auto tab: extern_trainTimeTables)
// {
// VTK_CREATE(vtkPolyDataMapper, mapper);
// VTK_CREATE(vtkActor, actor);
// }
// }
int countTrains = 0;
for (auto tab: extern_trainTimeTables)
{
VTK_CREATE(vtkPolyDataMapper, mapper);
VTK_CREATE(vtkActor, actor);
// VTK_CREATE(vtkTextActor, textActor);
VTK_CREATE(vtkTextActor3D, textActor);
auto trainType = tab.second->type;
......@@ -178,43 +188,62 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId,
auto train = extern_trainTypes[trainType];
auto doors = train->doors;
std::vector<Point> doorPoints;
auto mapper = tab.second->mapper;
auto actor = tab.second->actor;
auto txtActor = tab.second->textActor;
for(auto door: doors)
{
doorPoints.push_back(door.GetPoint1());
doorPoints.push_back(door.GetPoint2());
}//doors
auto data = getTrainData(trainStart, trainEnd, doorPoints);
mapper->SetInputData(data);
actor->SetMapper(mapper);
actor->GetProperty()->SetLineWidth(10);
actor->GetProperty()->SetOpacity(0.1);//feels cool!
// text
textActor->GetTextProperty()->SetOpacity(0.1);
double pos_x = mapper->GetInput()->GetPoint(0)[0];
double pos_y = mapper->GetInput()->GetPoint(0)[1];
textActor->SetPosition (pos_x, pos_y+2, 20);
textActor->SetInput (trainType.c_str());
textActor->GetTextProperty()->SetFontSize (30);
textActor->SetVisibility(false);
if(once)
{
auto data = getTrainData(trainStart, trainEnd, doorPoints);
mapper->SetInputData(data);
actor->SetMapper(mapper);
actor->GetProperty()->SetLineWidth(10);
actor->GetProperty()->SetOpacity(0.1);//feels cool!
actor->GetProperty()->SetColor(
std::abs(0.9-renderer->GetBackground()[0]),
std::abs(0.9-renderer->GetBackground()[1]),
std::abs(1.0-renderer->GetBackground()[2])
);
// text
txtActor->GetTextProperty()->SetOpacity(0.7);
double pos_x = 50*(trainStart._x + trainEnd._x);
double pos_y = 50*(trainStart._y + trainEnd._y);
txtActor->SetPosition (pos_x, pos_y+2, 20);
txtActor->SetInput (trainType.c_str());
txtActor->GetTextProperty()->SetFontSize (30);
txtActor->GetTextProperty()->SetBold (true);
txtActor->GetTextProperty()->SetColor (
std::abs(0.9-renderer->GetBackground()[0]),
std::abs(0.9-renderer->GetBackground()[1]),
std::abs(0.5-renderer->GetBackground()[2])
);
txtActor->SetVisibility(false);
}
if((now >= tab.second->tin) && (now <= tab.second->tout))
{
actor->GetProperty()->SetColor(0.1,.1,0.0);
textActor->GetTextProperty()->SetColor (1.0,0.0,0.0);
textActor->SetVisibility(true);
actor->SetVisibility(true);
txtActor->SetVisibility(true);
}
else
{
actor->GetProperty()->SetColor(renderer->GetBackground());
textActor->GetTextProperty()->SetColor(renderer->GetBackground());
actor->SetVisibility(false);
txtActor->SetVisibility(false);
}
if(once)
{
renderer->AddActor(actor);
renderer->AddActor(txtActor);
if(countTrains == extern_trainTimeTables.size())
once = 0;
}
renderer->AddActor(actor);
renderer->AddActor(textActor);
mapper=nullptr;
actor=nullptr;
textActor=nullptr;
countTrains++;
}// time table
......
......@@ -3,6 +3,8 @@
#include "geometry/Point.h"
#include "geometry/Transition.h"
#include <vtkPolyDataMapper.h>
#include <vtkTextActor3D.h>
struct TrainTimeTable
{
......@@ -19,6 +21,9 @@ struct TrainTimeTable
int pid; // Platform id
bool arrival;
bool departure;
vtkSmartPointer<vtkPolyDataMapper> mapper;
vtkSmartPointer<vtkActor> actor;
vtkSmartPointer<vtkTextActor3D> textActor;
};
struct TrainType
{
......