Commit eabf8f5c authored by Tao Zhong's avatar Tao Zhong

Refactoring router choice in inifile

parent cea2b391
......@@ -3906,7 +3906,7 @@
<property name="geometry">
<rect>
<x>340</x>
<y>20</y>
<y>50</y>
<width>111</width>
<height>21</height>
</rect>
......@@ -3919,7 +3919,7 @@
<property name="geometry">
<rect>
<x>240</x>
<y>20</y>
<y>50</y>
<width>97</width>
<height>16</height>
</rect>
......@@ -3932,20 +3932,20 @@
<property name="geometry">
<rect>
<x>340</x>
<y>60</y>
<y>90</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>1</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_05">
<property name="geometry">
<rect>
<x>240</x>
<y>60</y>
<y>90</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -3958,20 +3958,20 @@
<property name="geometry">
<rect>
<x>580</x>
<y>60</y>
<y>90</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Room2Corridor</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_06">
<property name="geometry">
<rect>
<x>480</x>
<y>60</y>
<y>90</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -3984,33 +3984,33 @@
<property name="geometry">
<rect>
<x>580</x>
<y>100</y>
<y>130</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Smoke</string>
<string/>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_route_choice_07">
<property name="geometry">
<rect>
<x>340</x>
<y>100</y>
<y>130</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>2</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_08">
<property name="geometry">
<rect>
<x>480</x>
<y>100</y>
<y>130</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4023,7 +4023,7 @@
<property name="geometry">
<rect>
<x>240</x>
<y>100</y>
<y>130</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4036,7 +4036,7 @@
<property name="geometry">
<rect>
<x>480</x>
<y>180</y>
<y>210</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4049,20 +4049,20 @@
<property name="geometry">
<rect>
<x>340</x>
<y>180</y>
<y>210</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>3</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_12">
<property name="geometry">
<rect>
<x>240</x>
<y>180</y>
<y>210</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4075,20 +4075,20 @@
<property name="geometry">
<rect>
<x>580</x>
<y>180</y>
<y>210</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>LastDestination</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_09">
<property name="geometry">
<rect>
<x>720</x>
<y>100</y>
<y>130</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4101,20 +4101,20 @@
<property name="geometry">
<rect>
<x>820</x>
<y>100</y>
<y>130</y>
<width>291</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>.../JuPedSim/jpscore/inputfiles/cognitive_map/pFields/</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_10">
<property name="geometry">
<rect>
<x>480</x>
<y>140</y>
<y>170</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4127,20 +4127,20 @@
<property name="geometry">
<rect>
<x>580</x>
<y>140</y>
<y>170</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>30</string>
<string/>
</property>
</widget>
<widget class="QLabel" name="label_route_choice_11">
<property name="geometry">
<rect>
<x>720</x>
<y>140</y>
<y>170</y>
<width>91</width>
<height>21</height>
</rect>
......@@ -4153,13 +4153,13 @@
<property name="geometry">
<rect>
<x>820</x>
<y>140</y>
<y>170</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>300</string>
<string/>
</property>
</widget>
<widget class="QComboBox" name="comboBox_Router">
......@@ -4191,7 +4191,7 @@
<property name="geometry">
<rect>
<x>460</x>
<y>15</y>
<y>45</y>
<width>114</width>
<height>32</height>
</rect>
......@@ -4200,6 +4200,42 @@
<string>Choose</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>240</x>
<y>20</y>
<width>59</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>ID</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_ID">
<property name="geometry">
<rect>
<x>340</x>
<y>20</y>
<width>111</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_VTK">
<property name="geometry">
<rect>
<x>470</x>
<y>20</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Write VTK files</string>
</property>
</widget>
</widget>
</widget>
<widget class="QLabel" name="label_warning">
......
......@@ -53,6 +53,7 @@ InifileWidget::InifileWidget(QWidget *parent, jpsDatamanager *dmanager) :
ui->lineEdit_GoalFile->setReadOnly(true);
ui->lineEdit_SourceFile->setReadOnly(true);
ui->lineEdit_TrafficFile->setReadOnly(true);
connect(ui->pushButton_Geometry, SIGNAL(clicked(bool)), this, SLOT(pushButton_GeomeryClicked()));
connect(ui->pushButton_Goal, SIGNAL(clicked(bool)), this, SLOT(pushButton_GoalClicked()));
connect(ui->pushButton_Source, SIGNAL(clicked(bool)), this, SLOT(pushButton_SourceClicked()));
......@@ -1501,86 +1502,71 @@ void InifileWidget::writeRouteChoiceData(QXmlStreamWriter *stream, QFile &file)
stream->writeComment("route chice model");
stream->writeStartElement("route_choice_models");
stream->writeStartElement("router");
// stream->writeAttribute("router_id",ui->lineEdit_route_choice_01->text());
int router = ui->comboBox_Router->currentIndex();
// QString choi_line_2 = "\t<route_choice_models>\n";
//
// QString choi_line_3 = "\t\t<!-- ff global shortest model -->\n";
//
// QString choi_line_4 = "\t\t<router router_id=\"" +
// ui->lineEdit_route_choice_01->text() +
// "\" description=\"ff_global_shortest\">\n";
//
// QString choi_line_5 = "\t\t</router>\n";
//
// QString choi_line_6 = "\t\t<!-- global shortest model -->\n";
//
// QString choi_line_7 = "\t\t<router router_id=\"" +
// ui->lineEdit_route_choice_02->text() +
// "\" description=\"global_shortest\">\n";
//
// QString choi_line_8 = "\t\t\t<parameters>\n";
//
// QString choi_line_9 = "\t\t\t\t<navigation_lines file=\"" +
// ui->lineEdit_route_choice_03->text() +
// "\" />\n";
//
// QString choi_line_10 = "\t\t\t</parameters>\n";
//
// QString choi_line_11 = "\t\t</router>\n";
//
// QString choi_line_12 = "\t\t<!-- cognitive map model -->\n";
//
// QString choi_line_13 = "\t\t<router router_id=\"" +
// ui->lineEdit_route_choice_04->text() +
// "\" description=\"cognitive_map\">\n";
//
// QString choi_line_14 = "\t\t\t<sensors>\n";
//
// QString choi_line_15 = "\t\t\t\t<sensor sensor_id=\"" +
// ui->lineEdit_route_choice_05->text() +
// "\" description=\"" +
// ui->lineEdit_route_choice_06->text() +
// "\" />\n";
//
// QString choi_line_16 = "\t\t\t\t<sensor sensor_id=\"" +
// ui->lineEdit_route_choice_07->text() +
// "\" description=\"" +
// ui->lineEdit_route_choice_08->text() +
// "\" p_field_path=\"" +
// ui->lineEdit_route_choice_09->text() +
// "\" update_time=\"" +
// ui->lineEdit_route_choice_10->text() +
// "\" final_time=\"" +
// ui->lineEdit_route_choice_11->text() +
// "\" />\n";
//
// QString choi_line_17 = "\t\t\t\t<sensor sensor_id=\"" +
// ui->lineEdit_route_choice_12->text() +
// "\" description=\"" +
// ui->lineEdit_route_choice_13->text() +
// "\" />\n";
//
// QString choi_line_18 = "\t\t\t</sensors>\n";
//
// QString choi_line_19 = "\t\t\t<cognitive_map status=\"complete\" />\n";
//
// QString choi_line_20 = "\t\t</router>\n";
//
// QString choi_line_21 = "\t</route_choice_models>\n\n";
//
//
// QString choi_lines = choi_line_1 + choi_line_2 + choi_line_3 + choi_line_4 + choi_line_5 +
// choi_line_6 + choi_line_7 + choi_line_8 + choi_line_9 + choi_line_10 +
// choi_line_11 + choi_line_12 + choi_line_13 + choi_line_14 + choi_line_15 +
// choi_line_16 + choi_line_17 + choi_line_18 + choi_line_19 + choi_line_20 +
// choi_line_21;
switch(router){
case 0:
writeFFGlobalShortestModel(stream, file);
break;
case 1:
writeGlobalShortestModel(stream, file);
break;
case 2:
writeCognitiveMap(stream, file);
break;
default:
break;
}
stream->writeEndElement();
return ;
}
void InifileWidget::writeFFGlobalShortestModel(QXmlStreamWriter *stream, QFile &file)
{
stream->writeStartElement("router");
stream->writeAttribute("router_id", ui->lineEdit_ID->text());
stream->writeAttribute("description","ff_global_shortest");
if(ui->radioButton_VTK->isChecked())
stream->writeTextElement("write_VTK_files", "true");
else
stream->writeTextElement("write_VTK_files", "false");
stream->writeEndElement();
}
void InifileWidget::writeGlobalShortestModel(QXmlStreamWriter *stream, QFile &file)
{
stream->writeStartElement("router");
stream->writeAttribute("router_id", ui->lineEdit_ID->text());
stream->writeAttribute("description","global_shortest");
stream->writeStartElement("parameters");
stream->writeStartElement("navigation_lines");
stream->writeAttribute("file", ui->lineEdit_route_choice_03->text());
stream->writeEndElement(); //end navigation lines
stream->writeEndElement(); //end patameters
stream->writeEndElement(); //end router
}
void InifileWidget::writeCognitiveMap(QXmlStreamWriter *stream, QFile &file)
{
stream->writeStartElement("router");
stream->writeAttribute("router_id", ui->lineEdit_ID->text());
stream->writeAttribute("description","cognitive_map");
stream->writeStartElement("sensors");
//TODO: finish sensors
stream->writeEndElement();//end sensors
stream->writeStartElement("cognitive_map");
stream->writeAttribute("status", "complete");
stream->writeEndElement(); //end cognitive map
stream->writeEndElement(); //router
}
// Create ini.xml on button push
void InifileWidget::on_pushButton_write_clicked()
{
......@@ -1735,7 +1721,8 @@ void InifileWidget::on_pushButton_write_clicked()
// krau_lines.toUtf8() +
// choi_lines.toUtf8());
stream->writeEndElement();
writeRouteChoiceData(stream, file);
stream->writeEndElement(); //end JuPedSim
stream->writeEndDocument();
delete stream;
stream = nullptr;
......
......@@ -66,6 +66,9 @@ private:
void writeHeaderData(QXmlStreamWriter *stream, QFile &file);
void writeRoutingData(QXmlStreamWriter *stream, QFile &file);
void writeFFGlobalShortestModel(QXmlStreamWriter *stream, QFile &file);
void writeGlobalShortestModel(QXmlStreamWriter *stream, QFile &file);
void writeCognitiveMap(QXmlStreamWriter *stream, QFile &file);
void writeTrafficData(QXmlStreamWriter *stream, QFile &file);
void writeSourceData(QXmlStreamWriter *stream, QFile &file);
void writeAgentData(QXmlStreamWriter *stream, QFile &file);
......
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