Commit 19507837 authored by Tao Zhong's avatar Tao Zhong

Refactoring header and traffic

parent 36ee7be9
......@@ -300,7 +300,7 @@
<item>
<widget class="QLineEdit" name="lineEdit_general_12">
<property name="text">
<string/>
<string>trajectories.xml</string>
</property>
</widget>
</item>
......
......@@ -2847,6 +2847,9 @@ bool LineIsEqual(const QLineF& line1, const QLineF& line2, double eps)
*/
void jpsDatamanager::writeSources(QXmlStreamWriter *stream, QList<JPSSource *> &sourcelist) {
sourcelist.clear();
sourcelist = _mView->getSources();
for(JPSSource* source:sourcelist)
{
if(source->isBeSaved())
......@@ -2938,8 +2941,6 @@ void jpsDatamanager::writeGoalXML(QFile &file)
stream->writeAttribute("version", "0.8");
stream->writeStartElement("goals");
goallist.clear();
goallist = _mView->getGoals();
writeGoals(stream, goallist);
stream->writeEndElement(); //end goals
......@@ -2951,6 +2952,9 @@ void jpsDatamanager::writeGoalXML(QFile &file)
void jpsDatamanager::writeGoals(QXmlStreamWriter *stream, QList<JPSGoal *> &goallist)
{
goallist.clear();
goallist = _mView->getGoals();
for(JPSGoal* goal:goallist)
{
if(goal->getBeSaved() == "true")
......@@ -3085,7 +3089,7 @@ void jpsDatamanager::writeTrafficXML(QFile &file)
stream->writeStartElement("doors");
writeTraffics(stream, doorlist);
doorlist.clear();
stream->writeEndElement(); //end
stream->writeEndElement(); //end doors
stream->writeEndDocument();
......@@ -3104,8 +3108,13 @@ void jpsDatamanager::writeTraffics(QXmlStreamWriter *stream, QList<jpsCrossing *
stream->writeAttribute("state", "open");
else
stream->writeAttribute("state", "close");
stream->writeAttribute("outflow", door->getOutflow());
stream->writeAttribute("max_agents", door->getMaxAgents());
if(!door->getOutflow().isEmpty())
stream->writeAttribute("outflow", door->getOutflow());
if(!door->getMaxAgents().isEmpty())
stream->writeAttribute("max_agents", door->getMaxAgents());
stream->writeEndElement(); //end door
}
}
......@@ -3165,3 +3174,7 @@ void jpsDatamanager::readDoor(QXmlStreamReader &xmlReader)
}
}
const QList<JPSSource *> &jpsDatamanager::getSourcelist() const {
return sourcelist;
}
......@@ -108,11 +108,13 @@ public:
void writeSourceXML(QFile &file);
void writeSourceHeader(QXmlStreamWriter *stream);
void writeSources(QXmlStreamWriter *stream, QList<JPSSource *>& sourcelist);
const QList<JPSSource *> &getSourcelist() const;
//Goals TODO: write goals by a writer class
void writeGoalXML(QFile &file);
void writeGoals(QXmlStreamWriter *stream, QList<JPSGoal *>& goallist);
const QList<JPSGoal *> &getGoallist();
//Traffic
void writeTrafficXML(QFile &file);
......@@ -120,6 +122,7 @@ public:
bool readTrafficXML(QFile &file);
void readDoor(QXmlStreamReader &xmlReader);
void remove_all();
void remove_marked_lines();
void set_view(jpsGraphicsView* view);
......@@ -208,7 +211,7 @@ public:
// read line file
bool ReadLineFile(QFile &file);
const QList<JPSGoal *> &getGoallist();
// //Show Cognitive Map
// void ShowCMapFrame(const int& frame) const;
......
This diff is collapsed.
......@@ -63,9 +63,10 @@ private:
bool CheckAgentKrauData();
bool CheckRouteChoiceData();
QString WriteHeaderData();
void WriteRoutingData(QFile &file);
void WriteTrafficData(QFile &file);
void writeHeaderData(QXmlStreamWriter *stream, QFile &file);
void writeRoutingData(QXmlStreamWriter *stream, QFile &file);
void writeTrafficData(QXmlStreamWriter *stream, QFile &file);
void writeSourceData(QXmlStreamWriter *stream, QFile &file);
QString WriteAgentData();
QString WriteModelGcfmData();
QString WriteModelGompData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment