Commit b08ffbac authored by Tao Zhong's avatar Tao Zhong

Add property for door

parent c001c91f
......@@ -41,7 +41,7 @@
<attribute name="title">
<string>General</string>
</attribute>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
......@@ -165,7 +165,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>270</x>
......@@ -244,7 +244,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
......@@ -300,7 +300,7 @@
<item>
<widget class="QLineEdit" name="lineEdit_general_12">
<property name="text">
<string>../output_name.xml</string>
<string/>
</property>
</widget>
</item>
......@@ -370,13 +370,13 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>270</x>
<y>20</y>
<width>451</width>
<height>151</height>
<height>162</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
......@@ -4284,8 +4284,8 @@
<widget class="QLabel" name="label_warning">
<property name="geometry">
<rect>
<x>320</x>
<y>10</y>
<x>40</x>
<y>450</y>
<width>571</width>
<height>21</height>
</rect>
......@@ -4300,7 +4300,7 @@
<string/>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
......
......@@ -383,6 +383,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......@@ -527,7 +534,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLineEdit" name="OutflowLineEdit"/>
<widget class="QLineEdit" name="outflowLineEdit"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
......
......@@ -30,7 +30,6 @@
#include <iostream>
#include <QDebug>
jpsCrossing::jpsCrossing(jpsLineItem *line)
{
cLine=line;
......@@ -68,6 +67,30 @@ void jpsCrossing::change_name(QString name)
cName=name;
}
bool jpsCrossing::isState() const {
return state;
}
void jpsCrossing::setState(bool state) {
jpsCrossing::state = state;
}
QString jpsCrossing::getMaxAgents() const {
return max_agents;
}
void jpsCrossing::setMaxAgents(QString maxAgents) {
max_agents = maxAgents;
}
QString jpsCrossing::getOutflow() const {
return outflow;
}
void jpsCrossing::setOutflow(QString outflow) {
jpsCrossing::outflow = outflow;
}
void jpsCrossing::add_rooms(jpsRoom *room1, jpsRoom *room2)
{
qDebug("Enter jpsCrossing::add_rooms");
......
......@@ -34,6 +34,9 @@ class jpsCrossing
{
public:
jpsCrossing(jpsLineItem *line);
jpsCrossing(jpsLineItem *cLine, bool isExit, float elevation);
~jpsCrossing(){}
QList<jpsRoom *> get_roomList();
QString get_name();
......@@ -49,6 +52,18 @@ public:
float get_elevation();
void set_elevation(float elevation);
QString getMaxAgents() const;
void setMaxAgents(QString maxAgents);
QString getOutflow() const;
void setOutflow(QString outflow);
bool isState() const;
void setState(bool state);
private:
QList<jpsRoom *> roomList;
......@@ -57,6 +72,9 @@ private:
int cId;
bool _isExit;
float _elevation;
bool state;
QString max_agents;
QString outflow;
};
#endif // JPSCROSSING_H
......@@ -21,8 +21,8 @@
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* This class is representing an exit to the outside. This class will vanish in the nearer future since the class
* jpscrossing will overtake the objectives of this class.
* This class is representing an exit to the outside.
* This class will vanish in the nearer future since the class jpscrossing will overtake the objectives of this class.
*
**/
......
......@@ -183,7 +183,10 @@ bool InifileWidget::CheckHeaderData()
if(ui->lineEdit_general_07->text() == "")
{
ui->label_warning->setText("<font color='red'>General incomplete.</font>");
QMessageBox::critical(this,
"Saving Inifile",
"Please chooses geometry file",
QMessageBox::Ok);
return 0;
}
......@@ -211,11 +214,40 @@ bool InifileWidget::CheckHeaderData()
bool InifileWidget::CheckTrafficData()
{
if(ui->lineEdit_TrafficFile->text().isEmpty())
{
QMessageBox::critical(this,
"Save Inifile",
"Please choose traffic file!",
QMessageBox::Ok);
return false;
}
return true;
}
bool InifileWidget::CheckRoutingData()
{
if(ui->lineEdit_GoalFile->text().isEmpty())
{
QMessageBox::critical(this,
"Save Inifile",
"Please choose goal file!",
QMessageBox::Ok);
return false;
}
return true;
}
bool InifileWidget::CheckSourceData()
{
if(ui->lineEdit_SourceFile->text().isEmpty())
{
QMessageBox::critical(this,
"Save Inifile",
"Please choose source file!",
QMessageBox::Ok);
return false;
}
return true;
}
......@@ -816,7 +848,22 @@ QString InifileWidget::WriteHeaderData()
return head_lines;
}
//TODO: writeTrafficData
/*
<routing>
<goals>
<goal id="0" final="false" caption="goal 1">
<polygon>
<vertex px="-5.0" py="-5.0" />
<vertex px="-5.0" py="-2.0" />
<vertex px="-3.0" py="-2.0" />
<vertex px="-3.0" py="-5.0" />
<vertex px="-5.0" py="-5.0" />
</polygon>
</goal>
<file>goals.xml</file>
</goals>
</routing>
*/
void InifileWidget::WriteRoutingData(QFile &file)
{
......@@ -1597,11 +1644,17 @@ void InifileWidget::on_pushButton_write_clicked()
return;
}
//check traffic_constraints
if (CheckTrafficData() == 0)
{
//goal
if (CheckRoutingData() == false)
return;
//source
if (CheckSourceData() == false)
return;
//traffic(door)
if (CheckTrafficData() == false)
return;
}
//check agents information and distribution
if (CheckAgentData() == 0)
......@@ -1675,13 +1728,9 @@ void InifileWidget::on_pushButton_write_clicked()
return;
}
//header
QString head_lines = WriteHeaderData();
//traffic_constraints
//agents information and distribution
QString agen_lines = WriteAgentData();
......@@ -1704,7 +1753,10 @@ void InifileWidget::on_pushButton_write_clicked()
QString choi_lines = WriteRouteChoiceData();
//save to file
QString file_name = QFileDialog::getSaveFileName(this,tr("Create ini"),"",tr("XML-Files (*.xml)"));
QString file_name = QFileDialog::getSaveFileName(this,
tr("Create ini"),
"",
tr("XML-Files (*.xml)"));
QFile file(file_name);
......@@ -3417,9 +3469,6 @@ void InifileWidget::on_pushButton_read_clicked()
//header
ReadHeaderData(JuPedSim);
//traffic_constraints
//agents information and distribution
ReadAgentData(JuPedSim);
......
......@@ -49,6 +49,7 @@ private:
bool CheckHeaderData();
bool CheckTrafficData();
bool CheckRoutingData();
bool CheckSourceData();
bool CheckAgentData();
bool CheckModelGcfmData();
bool CheckAgentGcfmData();
......
......@@ -90,6 +90,7 @@ roomWidget::roomWidget(QWidget *parent, jpsDatamanager *dmanager, jpsGraphicsVie
connect(ui->classBox,SIGNAL(activated(int)),this,SLOT(ChangeRoomType()));
connect(ui->classBox,SIGNAL(currentIndexChanged(int)),this,SLOT(ChangeRoomType()));
//tab crossing
connect(ui->pushButton_apply, SIGNAL(clicked(bool)), this, SLOT(applyCrossing()));
connect(ui->addCrossingButton,SIGNAL(clicked(bool)),this,SLOT(new_crossing()));
connect(ui->crossingList,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(enable_roomSelectionCrossings()));
connect(ui->roomBox_from,SIGNAL(activated(int)),this,SLOT(add_rooms_to_crossing()));
......@@ -390,7 +391,7 @@ void roomWidget::new_crossing()
void roomWidget::enable_roomSelectionCrossings()
{
qDebug("Enter roomWidget::enable_roomSelectionCrossings");
qDebug("Enter roomWidget::enable_roomSelectionCrossings");
if (datamanager->get_crossingList().size()>0)
{
ui->roomBox_from->setEnabled(true);
......@@ -435,6 +436,16 @@ void roomWidget::enable_roomSelectionCrossings()
{
add_rooms_to_crossing();
}
//show parameters
if(datamanager->get_crossingList()[cCrossingRow]->isState())
ui->stateComboBox->setCurrentIndex(0);
else
ui->stateComboBox->setCurrentIndex(1);
ui->maxAgentsLineEdit->setText(datamanager->get_crossingList()[cCrossingRow]->getMaxAgents());
ui->outflowLineEdit->setText(datamanager->get_crossingList()[cCrossingRow]->getOutflow());
}
}
}
......@@ -457,7 +468,7 @@ void roomWidget::disable_roomSelectionCrossings()
void roomWidget::add_rooms_to_crossing()
{
qDebug("Enter roomWidget::add_rooms_to_crossing");
qDebug("Enter roomWidget::add_rooms_to_crossing");
if (ui->crossingList->currentItem() != nullptr)
{
int cCrossingRow=ui->crossingList->currentRow();
......@@ -523,7 +534,6 @@ void roomWidget::new_exit()
datamanager->new_exit(graphview->get_markedLines());
}
show_exits();
}
void roomWidget::enable_roomSelectionExits()
......@@ -1210,3 +1220,33 @@ void roomWidget::showLayersInfo()
}
qDebug("Layer ListWidget is updated!");
}
/*
Since v0.8.8
Save crossing data
*/
void roomWidget::applyCrossing()
{
qDebug("Enter roomWidget::applyCrossing");
if (ui->crossingList->currentItem() != nullptr)
{
int cCrossingRow=ui->crossingList->currentRow();
QString state = ui->stateComboBox->currentText();
QString max_agents = ui->maxAgentsLineEdit->text();
QString outflow = ui->outflowLineEdit->text();
if(state == "Open")
{
datamanager->get_crossingList()[cCrossingRow]->setState(true);
} else
{
datamanager->get_crossingList()[cCrossingRow]->setState(false);
}
datamanager->get_crossingList()[cCrossingRow]->setMaxAgents(max_agents);
datamanager->get_crossingList()[cCrossingRow]->setOutflow(outflow);
}
qDebug("Leave roomWidget::applyCrossing");
}
......@@ -102,6 +102,8 @@ protected slots:
// void autoAssignExits();
void ChangeRoomType();
void applyCrossing();
......
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