-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from gfgit/new_station_graph
Initial commit Station Graph
- Loading branch information
Showing
30 changed files
with
1,490 additions
and
12 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(TRAINTIMETABLE_SOURCES | ||
${TRAINTIMETABLE_SOURCES} | ||
graph/model/linegraphmanager.h | ||
graph/model/linegraphscene.h | ||
graph/model/stationgraphobject.h | ||
|
||
graph/model/linegraphmanager.cpp | ||
graph/model/linegraphscene.cpp | ||
graph/model/stationgraphobject.cpp | ||
PARENT_SCOPE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include "linegraphmanager.h" | ||
|
||
#include "linegraphscene.h" | ||
|
||
#include "app/session.h" | ||
|
||
LineGraphManager::LineGraphManager(QObject *parent) : | ||
QObject(parent) | ||
{ | ||
auto session = Session; | ||
connect(session, &MeetingSession::stationNameChanged, this, &LineGraphManager::onStationNameChanged); | ||
connect(session, &MeetingSession::stationPlanChanged, this, &LineGraphManager::onStationPlanChanged); | ||
connect(session, &MeetingSession::segmentNameChanged, this, &LineGraphManager::onSegmentNameChanged); | ||
connect(session, &MeetingSession::segmentStationsChanged, this, &LineGraphManager::onSegmentStationsChanged); | ||
connect(session, &MeetingSession::lineNameChanged, this, &LineGraphManager::onLineNameChanged); | ||
connect(session, &MeetingSession::lineSegmentsChanged, this, &LineGraphManager::onLineSegmentsChanged); | ||
|
||
connect(&AppSettings, &TrainTimetableSettings::jobGraphOptionsChanged, this, &LineGraphManager::updateGraphOptions); | ||
} | ||
|
||
void LineGraphManager::registerScene(LineGraphScene *scene) | ||
{ | ||
Q_ASSERT(!scenes.contains(scene)); | ||
|
||
scenes.append(scene); | ||
|
||
connect(scene, &LineGraphScene::destroyed, this, &LineGraphManager::onSceneDestroyed); | ||
} | ||
|
||
void LineGraphManager::unregisterScene(LineGraphScene *scene) | ||
{ | ||
Q_ASSERT(scenes.contains(scene)); | ||
|
||
scenes.removeOne(scene); | ||
|
||
disconnect(scene, &LineGraphScene::destroyed, this, &LineGraphManager::onSceneDestroyed); | ||
} | ||
|
||
void LineGraphManager::clearAllGraphs() | ||
{ | ||
for(LineGraphScene *scene : qAsConst(scenes)) | ||
{ | ||
scene->loadGraph(0, LineGraphType::NoGraph); | ||
} | ||
} | ||
|
||
void LineGraphManager::onSceneDestroyed(QObject *obj) | ||
{ | ||
LineGraphScene *scene = static_cast<LineGraphScene *>(obj); | ||
unregisterScene(scene); | ||
} | ||
|
||
void LineGraphManager::onStationNameChanged(db_id stationId) | ||
{ | ||
onStationPlanChanged(stationId); //FIXME: update only labels | ||
} | ||
|
||
void LineGraphManager::onStationPlanChanged(db_id stationId) | ||
{ | ||
//FIXME: speed up with threads??? | ||
for(LineGraphScene *scene : qAsConst(scenes)) | ||
{ | ||
if(scene->stations.contains(stationId)) | ||
scene->reload(); | ||
} | ||
} | ||
|
||
void LineGraphManager::onSegmentNameChanged(db_id segmentId) | ||
{ | ||
onSegmentStationsChanged(segmentId); //FIXME: update only labels | ||
} | ||
|
||
void LineGraphManager::onSegmentStationsChanged(db_id segmentId) | ||
{ | ||
//FIXME: speed up with threads??? | ||
for(LineGraphScene *scene : qAsConst(scenes)) | ||
{ | ||
if(scene->graphType == LineGraphType::RailwaySegment && scene->graphObjectId == segmentId) | ||
scene->reload(); | ||
else if(scene->graphType == LineGraphType::RailwayLine) | ||
scene->reload(); //FIXME: only if inside this line | ||
//Single stations are not affected | ||
} | ||
} | ||
|
||
void LineGraphManager::onLineNameChanged(db_id lineId) | ||
{ | ||
onLineSegmentsChanged(lineId); //FIXME: update only labels | ||
} | ||
|
||
void LineGraphManager::onLineSegmentsChanged(db_id lineId) | ||
{ | ||
//FIXME: speed up with threads??? | ||
for(LineGraphScene *scene : qAsConst(scenes)) | ||
{ | ||
if(scene->graphType == LineGraphType::RailwayLine && scene->graphObjectId == lineId) | ||
scene->reload(); | ||
} | ||
} | ||
|
||
void LineGraphManager::updateGraphOptions() | ||
{ | ||
for(LineGraphScene *scene : qAsConst(scenes)) | ||
{ | ||
scene->reload(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef LINEGRAPHMANAGER_H | ||
#define LINEGRAPHMANAGER_H | ||
|
||
#include <QObject> | ||
|
||
#include <QVector> | ||
|
||
#include "utils/types.h" | ||
|
||
class LineGraphScene; | ||
|
||
class LineGraphManager : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit LineGraphManager(QObject *parent = nullptr); | ||
|
||
void registerScene(LineGraphScene *scene); | ||
void unregisterScene(LineGraphScene *scene); | ||
|
||
void clearAllGraphs(); | ||
|
||
private slots: | ||
void onSceneDestroyed(QObject *obj); | ||
|
||
void onStationNameChanged(db_id stationId); | ||
void onStationPlanChanged(db_id stationId); | ||
void onSegmentNameChanged(db_id segmentId); | ||
void onSegmentStationsChanged(db_id segmentId); | ||
void onLineNameChanged(db_id lineId); | ||
void onLineSegmentsChanged(db_id lineId); | ||
|
||
void updateGraphOptions(); | ||
|
||
private: | ||
QVector<LineGraphScene *> scenes; | ||
}; | ||
|
||
#endif // LINEGRAPHMANAGER_H |
Oops, something went wrong.