Commit e90d3e15 authored by Tao Zhong's avatar Tao Zhong

[WIP] #134 Update ini file reader

parent ef84e19f
......@@ -128,7 +128,6 @@ set( SRCS
src/XML/goalreader.cpp
src/XML/sourcereader.cpp
dxflib/src/dl_writer_ascii.cpp
dxflib/src/dl_dxf.cpp
src/UndoFramework/action.cpp
......
/***************************************************************
*
* \file inireader.cpp
* \date 2019-05-01
* \version v0.8.8
* \author Tao Zhong
* \copyright <2009-2019> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section Lincense
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
*
* This class is used for read inifile in inifile widget
****************************************************************/
#include "inireader.h"
IniReader::IniReader(InifileWidget *inifileWidget)
{
widget = inifileWidget;
}
bool IniReader::read(QIODevice *device)
{
xml.setDevice(device);
if (xml.readNextStartElement()) {
if (xml.name() == QLatin1String("JuPedSim")
&& xml.attributes().value("version") == QLatin1String("0.8"))
{
readJuPedSim(widget);
} else {
xml.raiseError(QObject::tr("The file is not an JuPedSim version 0.8 file."));
}
}
return !xml.error();
}
QString IniReader::errorString() const
{
return QObject::tr("%1\nLine %2, column %3")
.arg(xml.errorString())
.arg(xml.lineNumber())
.arg(xml.columnNumber());
}
void IniReader::readJuPedSim(InifileWidget *inifileWidget)
{
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("JuPedSim"));
while (xml.readNextStartElement()) {
if (xml.name() == QLatin1String("seed"))
readSeed(widget);
else if (xml.name() == QLatin1String("geometry"))
qDebug("read geometry!");
else if (xml.name() == QLatin1String("max_sim_time"))
qDebug("read max sim time!");
else
xml.skipCurrentElement();
}
}
void IniReader::readSeed(InifileWidget *widget)
{
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("seed"));
QString title = xml.readElementText();
widget.
}
//
// Created by sainho93 on 2019-05-01.
//
#ifndef JPSEDITOR_INIREADER_H
#define JPSEDITOR_INIREADER_H
#include <QXmlStreamWriter>
#include "src/widgets/inifilewidget.h"
class IniReader
{
public:
IniReader(InifileWidget *inifileWidget);
bool read(QIODevice *device);
QString errorString() const;
void readJuPedSim(InifileWidget *widget);
void readSeed(InifileWidget *widget);
private:
QXmlStreamReader xml;
InifileWidget *widget;
};
#endif //JPSEDITOR_INIREADER_H
......@@ -128,7 +128,6 @@ public:
void set_view(jpsGraphicsView* view);
jpsGraphicsView* get_view();
// Auto Assign
// void AutoAssignCrossings();
// void AutoAssignExits();
......
......@@ -108,9 +108,6 @@ MWindow :: MWindow()
statusBar()->addPermanentWidget(x_edit);
statusBar()->addPermanentWidget(label_y);
statusBar()->addPermanentWidget(y_edit);
// statusBar()->addPermanentWidget(label1);
// statusBar()->addPermanentWidget(length_edit);
// statusBar()->addPermanentWidget(label2);
//Timer needed for autosaving function
// timer will trigger autosave every 5th minute
......@@ -150,10 +147,6 @@ MWindow :: MWindow()
connect(actionRotate_90_deg_clockwise,SIGNAL(triggered(bool)),this,SLOT(rotate()));
connect(actionShow_Point_of_Origin,SIGNAL(triggered(bool)),this,SLOT(ShowOrigin()));
// Length edit
// connect(length_edit,SIGNAL(returnPressed()),this,SLOT(send_length()));
// connect(length_edit,SIGNAL(returnPressed()),this,SLOT(ScaleLines()));
// X Y edit
connect(x_edit,SIGNAL(returnPressed()),this,SLOT(send_xy()));
connect(y_edit,SIGNAL(returnPressed()),this,SLOT(send_xy()));
......@@ -206,7 +199,6 @@ MWindow :: MWindow()
drawingActionGroup->addAction(actionEditMode);
drawingActionGroup->addAction(actionGoal);
connect(actionSelect_Mode,SIGNAL(triggered(bool)),this,SLOT(en_selectMode()));
connect(actionWall,SIGNAL(triggered(bool)),this,SLOT(en_disableWall()));
connect(actionDoor,SIGNAL(triggered(bool)),this,SLOT(en_disableDoor()));
......@@ -217,10 +209,7 @@ MWindow :: MWindow()
connect(actionEditMode,SIGNAL(triggered(bool)),this,SLOT(editModeButtonClicked()));
connect(actionGoal,SIGNAL(triggered(bool)),this,SLOT(goalButtionClicked()));
// connect(actionWall,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode()));
// connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode()));
// connect(actionDoor,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode()));
// connect(actionExit,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode()));
// right dock widget
propertyDockWidget = nullptr;
//object snapping
......@@ -233,7 +222,6 @@ MWindow :: MWindow()
objectsnapping.append(Intersections_point);
objectsnapping.append(Center_point);
objectsnapping.append(SelectedLine_point);
}
MWindow::~MWindow()
......@@ -1013,6 +1001,11 @@ QMap<QString, QString> MWindow::loadSettings()
void MWindow::on_actionNew_Inifile_triggered()
{
inifileWidget = new InifileWidget(this, dmanager);
// status bar
connect(inifileWidget, SIGNAL(inifileLoaded(QString, int)),
this, SLOT(showStatusBarMessage(QString, int)));
inifileWidget->show();
qDebug()<< "MWindow::on_actionNew_Inifile_triggered(): inifile widget is showed!";
}
......@@ -1163,3 +1156,13 @@ void MWindow::openTraffic(QString fileName)
{
}
}
/*
since v0.8.8
Receive message from other widgets, show on status bar
*/
void MWindow::showStatusBarMessage(QString msg, int duration)
{
statusBar()->showMessage(tr(msg.toStdString().data()), duration);
}
......@@ -177,7 +177,7 @@ protected slots:
//ESCAPE
void keyPressEvent(QKeyEvent *event);
void showStatusBarMessage(QString msg, int duration);
private slots:
void on_actionCopy_triggered();
......
This diff is collapsed.
......@@ -42,6 +42,26 @@ public slots:
void pushButton_TrafficClicked();
void pushButton_RoutingClicked();
//Read inifile
bool readInifile(QXmlStreamReader *reader);
QString errorString(QXmlStreamReader *reader) const;
void readJuPedSim(QXmlStreamReader *reader);
void readSeed(QXmlStreamReader *reader);
void readGeometry(QXmlStreamReader *reader);
void readMaxSimTime(QXmlStreamReader *reader);
void readTrajectories(QXmlStreamReader *reader);
void readTrajectoriesFile(QXmlStreamReader *reader);
void readLogfile(QXmlStreamReader *reader);
void readTrafficConstraints(QXmlStreamReader *reader);
void readTrafficFile(QXmlStreamReader *reader);
void readRouting(QXmlStreamReader *reader);
void readRoutingFile(QXmlStreamReader *reader);
void readAgents(QXmlStreamReader *reader);
void readAgentsDistribution(QXmlStreamReader *reader);
void readAgentsSources(QXmlStreamReader *reader);
void readGroup(QXmlStreamReader *reader);
void readSourceFile(QXmlStreamReader *reader);
private:
Ui::InifileWidget *ui;
......@@ -83,7 +103,9 @@ private:
void ReadAgentData(TiXmlElement* JuPedSim);
void ReadModelData(TiXmlElement* JuPedSim);
void ReadRouteChoiceData(TiXmlElement* JuPedSim);
void readTrafficFile(QFile &file);
signals:
void inifileLoaded(QString, int);
};
#endif // INIFILEWIDGET_H
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