Commit 6b32259c authored by Tao Zhong's avatar Tao Zhong

Remove traffic from inifilewidget

parent e12509a1
......@@ -305,45 +305,6 @@
<string>1000</string>
</property>
</widget>
<widget class="QLabel" name="label_general_d">
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<width>151</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Goals and Constraints&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_general_14">
<property name="geometry">
<rect>
<x>250</x>
<y>320</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Edit Constraints</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_general_2">
<property name="geometry">
<rect>
<x>350</x>
<y>320</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="comboBox_general_02">
<property name="geometry">
<rect>
......@@ -3934,142 +3895,6 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_constraints">
<property name="enabled">
<bool>true</bool>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<attribute name="title">
<string>Constraints</string>
</attribute>
<widget class="QLabel" name="label_constraints_a">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>101</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Door constraints&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_constraints_1">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Number of doors</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBox_constraints_1">
<property name="geometry">
<rect>
<x>130</x>
<y>50</y>
<width>111</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_constraints_b">
<property name="geometry">
<rect>
<x>430</x>
<y>10</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Room constraints&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBox_constraints_2">
<property name="geometry">
<rect>
<x>550</x>
<y>50</y>
<width>111</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_constraints_2">
<property name="geometry">
<rect>
<x>430</x>
<y>50</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Number of rooms</string>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget_constraints_1">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>331</width>
<height>251</height>
</rect>
</property>
<column>
<property name="text">
<string>Door ID</string>
</property>
</column>
<column>
<property name="text">
<string>Caption</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
<widget class="QTableWidget" name="tableWidget_constraints_2">
<property name="geometry">
<rect>
<x>430</x>
<y>90</y>
<width>331</width>
<height>251</height>
</rect>
</property>
<column>
<property name="text">
<string>Room ID</string>
</property>
</column>
<column>
<property name="text">
<string>Caption</string>
</property>
</column>
<column>
<property name="text">
<string>State</string>
</property>
</column>
</widget>
</widget>
<widget class="QWidget" name="tab_route_choice">
<attribute name="title">
<string>Route choice</string>
......@@ -4566,7 +4391,6 @@
<tabstop>lineEdit_general_10</tabstop>
<tabstop>comboBox_general_03</tabstop>
<tabstop>lineEdit_general_12</tabstop>
<tabstop>checkBox_general_2</tabstop>
<tabstop>spinBox_groups_1</tabstop>
<tabstop>comboBox_groups_1</tabstop>
<tabstop>tableWidget_groups_1</tabstop>
......@@ -4641,10 +4465,6 @@
<tabstop>lineEdit_model_krausz_13</tabstop>
<tabstop>spinBox_agents_krausz_1</tabstop>
<tabstop>tableWidget_agents_krausz_1</tabstop>
<tabstop>spinBox_constraints_1</tabstop>
<tabstop>tableWidget_constraints_1</tabstop>
<tabstop>spinBox_constraints_2</tabstop>
<tabstop>tableWidget_constraints_2</tabstop>
<tabstop>lineEdit_route_choice_01</tabstop>
<tabstop>lineEdit_route_choice_02</tabstop>
<tabstop>lineEdit_route_choice_03</tabstop>
......
......@@ -316,7 +316,7 @@
<attribute name="title">
<string>Door</string>
</attribute>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
......@@ -494,7 +494,20 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="stateComboBox"/>
<widget class="QComboBox" name="stateComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
......
......@@ -661,7 +661,7 @@ void jpsDatamanager::AutoSaveXML(QFile &file)
void jpsDatamanager::writeHeader(QXmlStreamWriter *stream)
{
qDebug("Enter jpsDatamanager::writeHeader");
qDebug("Enter jpsDatamanager::writeHeader");
stream->setAutoFormatting(true);
stream->writeStartDocument("1.0",true);
......@@ -676,7 +676,7 @@ void jpsDatamanager::writeHeader(QXmlStreamWriter *stream)
void jpsDatamanager::writeRoutingHeader(QXmlStreamWriter *stream)
{
qDebug("Enter jpsDatamanager::writeRoutingHeader");
qDebug("Enter jpsDatamanager::writeRoutingHeader");
stream->setAutoFormatting(true);
stream->writeStartDocument("1.0",true);
......@@ -942,11 +942,12 @@ void jpsDatamanager::AutoSaveRooms(QXmlStreamWriter *stream, QList<jpsLineItem *
void jpsDatamanager::writeCrossings(QXmlStreamWriter *stream, QList<jpsLineItem *> &lines)
{
qDebug("Enter jpsDatamanager::writeCrossings");
qDebug("Enter jpsDatamanager::writeCrossings");
stream->writeStartElement("crossings");
for (int i=0; i<crossingList.size(); i++)
{
if (crossingList[i]->IsExit()==false && crossingList[i]->get_roomList()[0]->get_type()!="Stair" && crossingList[i]->get_roomList()[1]->get_type()!="Stair")
if (!crossingList[i]->IsExit() && crossingList[i]->get_roomList()[0]->get_type()!="Stair" &&
crossingList[i]->get_roomList()[1]->get_type()!="Stair")
{
stream->writeStartElement("crossing");
stream->writeAttribute("id",QString::number(i));
......
......@@ -115,7 +115,7 @@ MWindow :: MWindow()
//Timer needed for autosaving function
// timer will trigger autosave every 5th minute
timer = new QTimer(this);
timer->setInterval(60000);
timer->setInterval(600000);
timer->start();
_cMapTimer = new QTimer(this);
......
......@@ -91,30 +91,6 @@ void InifileWidget::on_spinBox_agents_krausz_1_valueChanged(int)
{
ui->tableWidget_agents_krausz_1->setRowCount(ui->spinBox_agents_krausz_1->value());
}
// Add rows to tablewidgets by inserting a number into a spinbox
void InifileWidget::on_spinBox_constraints_1_valueChanged(int)
{
ui->tableWidget_constraints_1->setRowCount(ui->spinBox_constraints_1->value());
}
// Add rows to tablewidgets by inserting a number into a spinbox
void InifileWidget::on_spinBox_constraints_2_valueChanged(int)
{
ui->tableWidget_constraints_2->setRowCount(ui->spinBox_constraints_2->value());
}
// Set constraints tab visible or invisible
void InifileWidget::on_checkBox_general_2_clicked()
{
if (ui->checkBox_general_2->isChecked())
{
ui->tabWidget->insertTab(6, ui->tab_constraints, "Constraints");
}
else
{
}
}
// Set models and agents visible or invisible
void InifileWidget::on_comboBox_groups_1_currentIndexChanged(int index)
......@@ -227,46 +203,7 @@ bool InifileWidget::CheckHeaderData()
bool InifileWidget::CheckTrafficData()
{
for(int i = 0; i < ui->spinBox_constraints_1->value(); i++)
{
if (!ui->tableWidget_constraints_1->item(i,0) || ui->tableWidget_constraints_1->item(i,0)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Door constraints incomplete.</font>");
return 0;
}
if (!ui->tableWidget_constraints_1->item(i,1) || ui->tableWidget_constraints_1->item(i,1)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Door constraints incomplete.</font>");
return 0;
}
if (!ui->tableWidget_constraints_1->item(i,2) || ui->tableWidget_constraints_1->item(i,2)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Door constraints incomplete.</font>");
return 0;
}
}
for(int i = 0; i < ui->spinBox_constraints_2->value(); i++)
{
if (!ui->tableWidget_constraints_2->item(i,0) || ui->tableWidget_constraints_2->item(i,0)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Room constraints incomplete.</font>");
return 0;
}
if (!ui->tableWidget_constraints_2->item(i,1) || ui->tableWidget_constraints_2->item(i,1)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Room constraints incomplete.</font>");
return 0;
}
if (!ui->tableWidget_constraints_2->item(i,2) || ui->tableWidget_constraints_2->item(i,2)->text().isEmpty())
{
ui->label_warning->setText("<font color='red'>Room constraints incomplete.</font>");
return 0;
}
}
ui->label_warning->setText("");
return 1;
return true;
}
bool InifileWidget::CheckRoutingData()
......@@ -871,52 +808,7 @@ QString InifileWidget::WriteHeaderData()
return head_lines;
}
QString InifileWidget::WriteTrafficData()
{
//traffic_constraints
QString traf_line_1 = "\t<!-- traffic constraints -->\n";
QString traf_line_2 = "\t<traffic_constraints>\n";
QString traf_line_3 = "\t\t<doors>\n";
QString traf_line_4 = "";
for(int i = 0; i < ui->spinBox_constraints_1->value(); i++)
{
traf_line_4 = traf_line_4 + "\t\t\t<door trans_id=\"" +
ui->tableWidget_constraints_1->item(i,0)->text() +
"\" caption=\"" +
ui->tableWidget_constraints_1->item(i,1)->text() +
"\" state=\"" +
ui->tableWidget_constraints_1->item(i,2)->text() +
"\" />\n";
}
QString traf_line_5 = "\t\t</doors>\n";
QString traf_line_6 = "\t\t<rooms>\n";
QString traf_line_7 = "";
for(int i = 0; i < ui->spinBox_constraints_2->value(); i++)
{
traf_line_7 = traf_line_7 + "\t\t\t<room room_id=\"" +
ui->tableWidget_constraints_2->item(i,0)->text() +
"\" caption=\"" +
ui->tableWidget_constraints_2->item(i,1)->text() +
"\" state=\"" +
ui->tableWidget_constraints_2->item(i,2)->text() +
"\" />\n";
}
QString traf_line_8 = "\t\t</rooms>\n";
QString traf_line_9 = "\t</traffic_constraints>\n\n";
QString traf_lines = traf_line_1 + traf_line_2 + traf_line_3 + traf_line_4 + traf_line_5 +
traf_line_6 + traf_line_7 + traf_line_8 + traf_line_9;
return traf_lines;
}
//TODO: writeTrafficData
void InifileWidget::WriteRoutingData(QFile &file)
{
......@@ -1780,7 +1672,7 @@ void InifileWidget::on_pushButton_write_clicked()
QString head_lines = WriteHeaderData();
//traffic_constraints
QString traf_lines = WriteTrafficData();
//agents information and distribution
QString agen_lines = WriteAgentData();
......@@ -1810,8 +1702,7 @@ void InifileWidget::on_pushButton_write_clicked()
if (file.open(QIODevice::WriteOnly|QIODevice::Text))
{
file.write(head_lines.toUtf8() +
traf_lines.toUtf8());
file.write(head_lines.toUtf8());
WriteRoutingData(file);
......@@ -1957,92 +1848,6 @@ void InifileWidget::ReadHeaderData(TiXmlElement *JuPedSim)
}
}
void InifileWidget::ReadTrafficData(TiXmlElement *JuPedSim)
{
//traffic_constraints
if (JuPedSim->FirstChild("traffic_constraints"))
{
if (JuPedSim->FirstChild("traffic_constraints")->FirstChild("doors"))
{
if (JuPedSim->FirstChild("traffic_constraints")->FirstChild("doors")->FirstChildElement("door"))
{
int counter = 0;
for (TiXmlElement* door = JuPedSim->FirstChild("traffic_constraints")->FirstChild("doors")->FirstChildElement("door");
door; door = door->NextSiblingElement("door"))
{
if (counter+1 == 1)
{
if (!ui->checkBox_general_2->isChecked())
{
ui->checkBox_general_2->setChecked(true);
ui->tabWidget->insertTab(6, ui->tab_constraints, "Constraints");
}
}
ui->spinBox_constraints_1->setValue(counter+1);
if (door->Attribute("trans_id"))
{
QString value = door->Attribute("trans_id");
ui->tableWidget_constraints_1->setItem(counter, 0, new QTableWidgetItem(value));
}
if (door->Attribute("caption"))
{
QString value = door->Attribute("caption");
ui->tableWidget_constraints_1->setItem(counter, 1, new QTableWidgetItem(value));
}
if (door->Attribute("state"))
{
QString value = door->Attribute("state");
ui->tableWidget_constraints_1->setItem(counter, 2, new QTableWidgetItem(value));
}
counter = counter + 1;
}
}
}
if (JuPedSim->FirstChild("traffic_constraints")->FirstChild("rooms"))
{
if (JuPedSim->FirstChild("traffic_constraints")->FirstChild("rooms")->FirstChildElement("room"))
{
int counter = 0;
for (TiXmlElement* room = JuPedSim->FirstChild("traffic_constraints")->FirstChild("rooms")->FirstChildElement("room");
room; room = room->NextSiblingElement("room"))
{
if (counter+1 == 1)
{
if (!ui->checkBox_general_2->isChecked())
{
ui->checkBox_general_2->setChecked(true);
ui->tabWidget->insertTab(6, ui->tab_constraints, "Constraints");
}
}
ui->spinBox_constraints_2->setValue(counter+1);
if (room->Attribute("room_id"))
{
QString value = room->Attribute("room_id");
ui->tableWidget_constraints_2->setItem(counter, 0, new QTableWidgetItem(value));
}
if (room->Attribute("caption"))
{
QString value = room->Attribute("caption");
ui->tableWidget_constraints_2->setItem(counter, 1, new QTableWidgetItem(value));
}
if (room->Attribute("state"))
{
QString value = room->Attribute("state");
ui->tableWidget_constraints_2->setItem(counter, 2, new QTableWidgetItem(value));
}
counter = counter + 1;
}
}
}
}
}
void InifileWidget::ReadRoutingData(TiXmlElement *JuPedSim)
{
}
void InifileWidget::ReadAgentData(TiXmlElement *JuPedSim)
{
......@@ -3605,7 +3410,7 @@ void InifileWidget::on_pushButton_read_clicked()
ReadHeaderData(JuPedSim);
//traffic_constraints
ReadTrafficData(JuPedSim);
//agents information and distribution
ReadAgentData(JuPedSim);
......
......@@ -17,16 +17,12 @@ public:
explicit InifileWidget(QWidget *parent = nullptr, jpsDatamanager* dmanager = nullptr);
~InifileWidget();
void writeRouting(QFile &file);
private slots:
//Inside Inifilewidget
void on_pushButton_write_clicked();
void on_pushButton_read_clicked();
//Inside Tab General
void on_checkBox_general_2_clicked();
//Inside Tab Groups
void on_spinBox_groups_1_valueChanged(int);
......@@ -39,10 +35,6 @@ private slots:
void on_spinBox_agents_gradnav_1_valueChanged(int);
void on_spinBox_agents_krausz_1_valueChanged(int);
//Inside Tab Constraints
void on_spinBox_constraints_1_valueChanged(int);
void on_spinBox_constraints_2_valueChanged(int);
private:
Ui::InifileWidget *ui;
......@@ -65,7 +57,6 @@ private:
bool CheckRouteChoiceData();
QString WriteHeaderData();
QString WriteTrafficData();
void WriteRoutingData(QFile &file);
QString WriteAgentData();
QString WriteModelGcfmData();
......@@ -77,8 +68,6 @@ private:
void ReadJuPedSimData(TiXmlElement* JuPedSim);
void ReadHeaderData(TiXmlElement* JuPedSim);
void ReadTrafficData(TiXmlElement* JuPedSim);
void ReadRoutingData(TiXmlElement* JuPedSim);
void ReadAgentData(TiXmlElement* JuPedSim);
void ReadModelData(TiXmlElement* JuPedSim);
void ReadRouteChoiceData(TiXmlElement* JuPedSim);
......
......@@ -458,7 +458,7 @@ void roomWidget::disable_roomSelectionCrossings()
void roomWidget::add_rooms_to_crossing()
{
qDebug("Enter roomWidget::add_rooms_to_crossing");
if (ui->crossingList->currentItem()!=0L)
if (ui->crossingList->currentItem() != nullptr)
{
int cCrossingRow=ui->crossingList->currentRow();
qDebug("\t cCrossingRow = %d", cCrossingRow);
......@@ -499,7 +499,6 @@ void roomWidget::delete_crossing()
datamanager->remove_crossing(datamanager->get_crossingList()[index]);
ui->crossingList->setCurrentRow(-1);
this->show_crossings();
}
}
......
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