Commit ea67dc72 authored by Tao Zhong's avatar Tao Zhong

#145 Clean up jpsexit

parent 6ea8208d
Pipeline #21646 failed with stages
in 6 seconds
Resources/Icons/Exit.png

6.15 KB | W: | H:

Resources/Icons/Exit.png

590 Bytes | W: | H:

Resources/Icons/Exit.png
Resources/Icons/Exit.png
Resources/Icons/Exit.png
Resources/Icons/Exit.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -8,8 +8,7 @@
<file>Icons/DeleteC.png</file>
<file>Icons/Door.png</file>
<file>Icons/DoorC.png</file>
<file>Icons/Exit.png</file>
<file>Icons/ExitC.png</file>
<file>Icons/exit.png</file>
<file>Icons/filesave.png</file>
<file>Icons/filesaveas.png</file>
<file>Icons/jupedsim.png</file>
......@@ -65,5 +64,6 @@
<file>Icons/goal.png</file>
<file>Icons/edit.png</file>
<file>Icons/ruler.png</file>
<file>Icons/draw.png</file>
</qresource>
</RCC>
......@@ -64,6 +64,7 @@
<addaction name="actionGather_data"/>
<addaction name="actionLandmarkWidget"/>
<addaction name="actionNew_Inifile"/>
<addaction name="actionBackground"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
......@@ -128,13 +129,8 @@
<addaction name="actionClear_all_Rooms_and_Doors"/>
<addaction name="separator"/>
<addaction name="actionSelect_Mode"/>
<addaction name="actionDraw"/>
<addaction name="actionMeasureLength"/>
<addaction name="actionWall"/>
<addaction name="actionDoor"/>
<addaction name="actionHLine"/>
<addaction name="actionSource"/>
<addaction name="actionGoal"/>
<addaction name="actionLandmark"/>
<addaction name="separator"/>
<addaction name="actiongridmode"/>
<addaction name="actionObjectsnap"/>
......@@ -330,12 +326,15 @@
</property>
</action>
<action name="actionExit">
<property name="checkable">
<bool>true</bool>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../Resources/resources.qrc">
<normaloff>:/inAppIcons/Icons/Exit.png</normaloff>:/inAppIcons/Icons/Exit.png</iconset>
<normaloff>:/inAppIcons/Icons/exit.png</normaloff>:/inAppIcons/Icons/exit.png</iconset>
</property>
<property name="text">
<string>Exit</string>
......@@ -806,6 +805,23 @@
<string>Measure length</string>
</property>
</action>
<action name="actionDraw">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../Resources/resources.qrc">
<normaloff>:/inAppIcons/Icons/draw.png</normaloff>:/inAppIcons/Icons/draw.png</iconset>
</property>
<property name="text">
<string>Draw</string>
</property>
</action>
<action name="actionBackground">
<property name="text">
<string>Import Backgroud</string>
</property>
</action>
</widget>
<resources>
<include location="../Resources/resources.qrc"/>
......
......@@ -103,7 +103,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent, jpsDatamanager *datamanager):Q
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setCursor(Qt::CrossCursor);
setCursor(Qt::CrossCursor);
//Grid Mode
_translationX=0.0;
......@@ -1101,9 +1101,6 @@ void jpsGraphicsView::drawLine()
case Door:
lineItem->setDoor();
break;
case Exit:
lineItem->setExit();
break;
case HLine:
lineItem->setHLine();
break;
......
......@@ -53,7 +53,6 @@ jpsDatamanager::jpsDatamanager(QWidget *parent, jpsGraphicsView *view)
_generator=std::default_random_engine(seed);
roomlist= QList<jpsRoom *> ();
sourcelist = _mView->getSources();
goallist = _mView->getGoals();
......@@ -78,7 +77,7 @@ void jpsDatamanager::new_room()
void jpsDatamanager::remove_room(jpsRoom *room)
{
qDebug("Enter jpsDatamanager::remove_room. room_id_counter = %d", room_id_counter);
//set room to nullptr in doors
for (jpsCrossing* crossing: get_crossingList())
{
......@@ -86,9 +85,6 @@ void jpsDatamanager::remove_room(jpsRoom *room)
crossing->RemoveRoom(room);
}
qDebug("Enter jpsDatamanager::remove_room. room_id_counter = %d", room_id_counter);
//if (roomlist.size()>0)
//{
int roomID=room->get_id();
......@@ -153,7 +149,7 @@ QList<QString> jpsDatamanager::getElevationList()
void jpsDatamanager::new_obstacle()
{
qDebug("Enter: jpsDatamanager::new_obstacle. obs_id_counter = %d", obs_id_counter);
qDebug("Enter: jpsDatamanager::new_obstacle. obs_id_counter = %d", obs_id_counter);
jpsObstacle* new_obs = new jpsObstacle(this->obs_id_counter);
obstaclelist.push_back(new_obs);
obs_id_counter+=1;
......@@ -207,15 +203,9 @@ void jpsDatamanager::new_crossing(QList <jpsLineItem *> newCrossings)
qDebug("Enter jpsDatamanager::new_crossing QList");
for (int i=0; i<newCrossings.size(); i++)
{
if (newCrossings[i]->is_Door())// only door can be crossing
if ((newCrossings[i]->is_Door() || newCrossings[i]->is_Exit())
&& !isInCrossingList(newCrossings[i]))// only door can be crossing
{
// avoid double crossing
for (jpsCrossing* crossing:crossingList)
{
if (crossing->get_cLine()==newCrossings[i])
break;
}
auto newCrossing = new jpsCrossing(newCrossings[i]);
newCrossing->set_id(_crossingIdCounter);
......@@ -229,16 +219,9 @@ void jpsDatamanager::new_crossing(QList <jpsLineItem *> newCrossings)
void jpsDatamanager::new_crossing(jpsLineItem *newCrossing)
{
qDebug("Enter jpsDatamanager::new_crossing");
if (newCrossing->is_Door())
qDebug("Enter jpsDatamanager::new_crossing");
if (newCrossing->is_Door() && !isInCrossingList(newCrossing))
{
// avoid double crossing
for (jpsCrossing* crossing:crossingList)
{
if (crossing->get_cLine()==newCrossing)
return;
}
jpsCrossing* newCros = new jpsCrossing(newCrossing);
newCros->set_id(_crossingIdCounter);
_crossingIdCounter += 1;
......@@ -247,6 +230,20 @@ void jpsDatamanager::new_crossing(jpsLineItem *newCrossing)
qDebug("Leave jpsDatamanager::new_crossing");
}
bool jpsDatamanager::isInCrossingList(jpsLineItem *markedLine)
{
qDebug("Enter jpsDatamanager::isInCrossingList");
for (jpsCrossing* crossing:crossingList)
{
if (crossing->get_cLine()==markedLine)
{
return true;
}
}
return false;
qDebug("Leave jpsDatamanager::isInCrossingList");
}
void jpsDatamanager::remove_crossing(jpsCrossing *crossing)
{
qDebug("Enter jpsDatamanager::remove_crossing. crossingList.size() = %d", crossingList.size());
......@@ -802,7 +799,7 @@ void jpsDatamanager::writeRooms(QXmlStreamWriter *stream, QList<jpsLineItem *> &
}
}
// write all subrooms in a room with ID 0
// write all subrooms in a room which ID is 0
stream->writeStartElement("room");
stream->writeAttribute("id", "0");
stream->writeAttribute("caption","floor");
......@@ -1151,9 +1148,7 @@ void jpsDatamanager::writeNotAssignedWalls(QXmlStreamWriter *stream, QList<jpsLi
stream->writeEndElement(); //polygon
lines.removeOne(line);
}
stream->writeEndElement();//subroom
qDebug("Leave jpsDatamanager::writeNotAssignedWalls");
}
......@@ -1163,7 +1158,7 @@ void jpsDatamanager::writeNotAssignedDoors(QXmlStreamWriter *stream, QList<jpsLi
qDebug("Enter jpsDatamanager::writeNotAssignedDoors");
for (jpsLineItem* line:lines)
{
if (line->is_Door())
if (line->is_Door() && !isInCrossingList(line))
{
stream->writeStartElement("crossing");
......
......@@ -104,14 +104,13 @@ public:
//Layers
QList<QString> getElevationList();
//Sources TODO: write sources by a writer class
//Sources
void writeSourceXML(QFile &file);
void writeSourceHeader(QXmlStreamWriter *stream);
void writeSources(QXmlStreamWriter *stream, QList<JPSSource *>& sourcelist);
const QList<JPSSource *> &getSourcelist();
//Goals TODO: write goals by a writer class
//Goals
void writeGoalXML(QFile &file);
void writeGoals(QXmlStreamWriter *stream, QList<JPSGoal *>& goallist);
const QList<JPSGoal *> &getGoallist();
......@@ -250,6 +249,8 @@ private:
std::default_random_engine _generator;
bool isInCrossingList(jpsLineItem *markedLine);
};
//check if two lines are equal with certain tolerance; heading direction of line does not matter
......
......@@ -66,6 +66,8 @@ QString jpsLineItem::GetType()
return "Wall";
case door:
return "Door";
case crossing:
return "Crossing";
case exit:
return "Exit";
case hline:
......@@ -120,7 +122,6 @@ void jpsLineItem::setExit()
{
lineType = exit;
defaultColor="darkMagenta";
}
void jpsLineItem::setHLine()
......
......@@ -47,7 +47,7 @@ public:
void set_name(QString name);
// void set_type(bool wall, bool door, bool exit, bool hline=false);
enum LineType{wall, door, exit, hline, undefined};
enum LineType{wall, door, crossing, exit, hline, undefined};
void setType(LineType type);
void setWall();
......
......@@ -34,6 +34,7 @@ jpsCrossing::jpsCrossing(jpsLineItem *line)
{
cLine=line;
_isExit=false;
}
QList<jpsRoom *> jpsCrossing::get_roomList()
......
......@@ -40,7 +40,6 @@ QList<jpsRoom *> jpsExit::get_roomList()
return roomList;
}
QString jpsExit::get_name()
{
return cName;
......
......@@ -45,8 +45,9 @@
MWindow :: MWindow()
{
setupUi(this);
//Signal/Slot
//VBox= new QVBoxLayout;
//WindowTitle
this->setWindowTitle("JPSeditor");
//Set-up view and scene
mview = new jpsGraphicsView;
......@@ -54,12 +55,16 @@ MWindow :: MWindow()
mview->setScene(mscene);
mview->setSceneRect(0, 0, 1920, 1080);
setCentralWidget(mview);
mview->setMaximumSize(1920,1080);
mview->showMaximized();
dmanager = new jpsDatamanager(this,mview);
mview->SetDatamanager(dmanager);
//Setup ToolBar
this->toolBar->setWindowTitle("Main ToolBar");
this->toolBar->setMovable(false);
drawing_toolbar_ = nullptr;
//Roomwidget
rwidget=nullptr;
//Landmarkwidget
......@@ -101,9 +106,6 @@ MWindow :: MWindow()
//filename of saved project
_filename="";
//WindowTitle
this->setWindowTitle("JPSeditor");
statusBar()->addPermanentWidget(infoLabel);
statusBar()->addPermanentWidget(label_x);
statusBar()->addPermanentWidget(x_edit);
......@@ -160,8 +162,6 @@ MWindow :: MWindow()
connect(mview,SIGNAL(mouse_moved()),this,SLOT(show_coords()));
connect(mview,SIGNAL(LineLengthChanged()),this,SLOT(ShowLineLength()));
// QAction *str_escape = new QAction(this);
// str_escape->setShortcut(Qt::Key_Escape);
// connect(str_escape, SIGNAL(triggered(bool)), mview, SLOT(disableDrawing()));
......@@ -190,30 +190,6 @@ MWindow :: MWindow()
// room type data gathering
connect(actionGather_data,SIGNAL(triggered(bool)),this, SLOT(GatherData()));
// drawing actions group
drawingActionGroup = new QActionGroup(this);
drawingActionGroup->addAction(actionSelect_Mode);
drawingActionGroup->addAction(actionDoor);
drawingActionGroup->addAction(actionWall);
drawingActionGroup->addAction(actionExit);
drawingActionGroup->addAction(actionHLine);
drawingActionGroup->addAction(actionLandmark);
drawingActionGroup->addAction(actionSource);
drawingActionGroup->addAction(actionEditMode);
drawingActionGroup->addAction(actionGoal);
drawingActionGroup->addAction(actionMeasureLength);
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()));
connect(actionExit,SIGNAL(triggered(bool)),this,SLOT(en_disableExit()));
connect(actionHLine,SIGNAL(triggered(bool)),this,SLOT(en_disableHLine()));
connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(en_disableLandmark()));
connect(actionSource, SIGNAL(triggered(bool)),this,SLOT(sourceButtonClicked()));
connect(actionEditMode,SIGNAL(triggered(bool)),this,SLOT(editModeButtonClicked()));
connect(actionGoal,SIGNAL(triggered(bool)),this,SLOT(goalButtionClicked()));
connect(actionMeasureLength, SIGNAL(triggered(bool)), this, SLOT(measureLengthButtonClicked()));
// right dock widget
propertyDockWidget = nullptr;
......@@ -228,6 +204,18 @@ MWindow :: MWindow()
objectsnapping.append(Center_point);
objectsnapping.append(SelectedLine_point);
//main toolbar action group
auto main_toolbar_action_group = new QActionGroup(this);
main_toolbar_action_group->addAction(actionSelect_Mode); // select mode
main_toolbar_action_group->addAction(actionMeasureLength); // measure mode
main_toolbar_action_group->addAction(actionDraw); // draw mode
connect(actionMeasureLength, SIGNAL(triggered(bool)), this, SLOT(measureLengthButtonClicked()));
connect(actionSelect_Mode,SIGNAL(triggered(bool)),this,SLOT(en_selectMode()));
connect(actionDraw, SIGNAL(triggered(bool)),this,SLOT(setupDrawingToolBar()));
//set background
connect(actionBackground, SIGNAL(triggered(bool)),this,SLOT(importBackground()));
}
MWindow::~MWindow()
......@@ -242,6 +230,44 @@ MWindow::~MWindow()
delete _cMapTimer;
}
void MWindow::setupDrawingToolBar()
{
if(drawing_toolbar_ == nullptr)
{
drawing_toolbar_ = new QToolBar("Drawing ToolBar", this);
addToolBar(Qt::LeftToolBarArea, drawing_toolbar_);
drawing_toolbar_->setMovable(false);
drawing_toolbar_->setBackgroundRole(QPalette::HighlightedText);
// drawing actions group
drawing_toolbar_->addAction(actionWall);
drawing_toolbar_->addAction(actionDoor);
drawing_toolbar_->addAction(actionHLine);
drawing_toolbar_->addAction(actionLandmark);
drawing_toolbar_->addAction(actionSource);
drawing_toolbar_->addAction(actionGoal);
drawingActionGroup = new QActionGroup(this);
drawingActionGroup->addAction(actionDoor);
drawingActionGroup->addAction(actionWall);
drawingActionGroup->addAction(actionHLine);
drawingActionGroup->addAction(actionLandmark);
drawingActionGroup->addAction(actionSource);
drawingActionGroup->addAction(actionGoal);
connect(actionWall,SIGNAL(triggered(bool)),this,SLOT(en_disableWall()));
connect(actionDoor,SIGNAL(triggered(bool)),this,SLOT(en_disableDoor()));
connect(actionHLine,SIGNAL(triggered(bool)),this,SLOT(en_disableHLine()));
connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(en_disableLandmark()));
connect(actionSource, SIGNAL(triggered(bool)),this,SLOT(sourceButtonClicked()));
connect(actionGoal,SIGNAL(triggered(bool)),this,SLOT(goalButtionClicked()));
} else
{
drawing_toolbar_->close();
drawing_toolbar_ = nullptr;
}
}
void MWindow::AutoSave()
{
QMap<QString, QString> settingsmap = loadSettings();
......@@ -739,11 +765,6 @@ void MWindow::en_disableDoor()
mview->en_disableDoor();
}
void MWindow::en_disableExit()
{
mview->en_disableExit();
}
void MWindow::en_disableLandmark()
{
mview->en_disableLandmark();
......@@ -754,23 +775,12 @@ void MWindow::en_disableHLine()
mview->en_disableHLine();
}
void MWindow::disableDrawing()
{
this->actionWall->setChecked(false);
this->actionDoor->setChecked(false);
this->actionExit->setChecked(false);
this->actionLandmark->setChecked(false);
this->actionHLine->setChecked(false);
this->actionCopy->setChecked(false);//TODO: actionCopy should be managed!
}
void MWindow::objectsnap()
{
if(snappingOptions==nullptr)
{
snappingOptions = new SnappingOptions(this);
snappingOptions->setGeometry(QRect(QPoint(5,75), snappingOptions->size()));
snappingOptions->setGeometry(QRect(QPoint(75,75), snappingOptions->size()));
snappingOptions->setAttribute(Qt::WA_DeleteOnClose);
snappingOptions->setState(objectsnapping);
snappingOptions->show();
......@@ -788,7 +798,6 @@ void MWindow::objectsnap()
snappingOptions=nullptr;
actionObjectsnap->setChecked(false);
}
// mview->change_objectsnap();
}
void MWindow::gridmode()
......@@ -849,7 +858,7 @@ void MWindow::define_room()
if (rwidget==nullptr)
{
rwidget = new roomWidget(this,this->dmanager,this->mview);
rwidget->setGeometry(QRect(QPoint(5,75), rwidget->size()));
rwidget->setGeometry(QRect(QPoint(75,75), rwidget->size()));
rwidget->setAttribute(Qt::WA_DeleteOnClose);
rwidget->show();
}
......@@ -903,11 +912,19 @@ void MWindow::define_landmark()
void MWindow::en_selectMode()
{
actionSelect_Mode->setChecked(true);
actionCopy->setChecked(false);
// actionSelect_Mode->setChecked(true);
// actionCopy->setChecked(false);
mview->disable_drawing();
length_edit->clearFocus();
if(drawing_toolbar_ != nullptr)
{
drawing_toolbar_->close();
drawing_toolbar_ = nullptr;
}
}
void MWindow::dis_selectMode()
......@@ -1087,9 +1104,9 @@ void MWindow::sourceButtonClicked()
propertyDockWidget->setWidget(sourceWidget);
} else if (propertyDockWidget != nullptr && propertyDockWidget->windowTitle() == "Sources")
{
// goal widget on, dockwidget on -> close goal widget
// source widget on, dockwidget on -> close source widget
mview->disable_drawing();
actionSelect_Mode->setChecked(true);
actionSource->setChecked(false);
propertyDockWidget->close(); //close() has deleted pointer
propertyDockWidget = nullptr;
......@@ -1097,7 +1114,7 @@ void MWindow::sourceButtonClicked()
} else if (propertyDockWidget != nullptr && propertyDockWidget->windowTitle() != "Sources")
{
// goal widget off, dockwidget on -> close other widget, open goal widget
// goal widget off, dockwidget on -> close other widget, open source widget
propertyDockWidget->close();
propertyDockWidget = nullptr;
......@@ -1116,11 +1133,6 @@ void MWindow::sourceButtonClicked()
}
}
void MWindow::editModeButtonClicked()
{
mview->enableEditMode();
}
// Goal drawing mode
/*
since 0.8.8
......@@ -1146,7 +1158,7 @@ void MWindow::goalButtionClicked()
{
// goal widget on, dockwidget on -> close goal widget
mview->disable_drawing();
actionSelect_Mode->setChecked(true);
actionGoal->setChecked(false);
propertyDockWidget->close(); //close() has deleted pointer
propertyDockWidget = nullptr;
......@@ -1232,3 +1244,22 @@ void MWindow::msgReceived(QString Msg)
{
statusBar()->showMessage(Msg, 10000);
}
/*
since v0.8.9
Import a image (JPG or PNG) as Background
*/
void MWindow::importBackground()
{
auto image = new QImage();
QString fileName = QFileDialog::getOpenFileName(
this, "open image file",
".",
"Image files (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *.xbm *.xpm);;All files (*.*)");
image->load(fileName);
QPixmap bkgnd(QPixmap::fromImage(*image));
mscene->addPixmap(bkgnd);
}
......@@ -64,6 +64,7 @@ private:
InifileWidget * inifileWidget;
QDockWidget *propertyDockWidget;
QToolBar *drawing_toolbar_;
SnappingOptions* snappingOptions;
// WidgetSettings* _settings;
......@@ -124,16 +125,12 @@ protected slots:
void anglesnap();
void en_disableWall();
void en_disableDoor();
void en_disableExit();
void en_disableLandmark();
void en_disableHLine();
void disableDrawing();
void objectsnap();
void sourceButtonClicked();
void editModeButtonClicked();
void goalButtionClicked();
//Line operations
void show_coords();
void delete_lines();
......@@ -183,6 +180,9 @@ protected slots:
void measureLengthButtonClicked();
void msgReceived(QString Msg);
//Background
void importBackground();
private slots:
void on_actionCopy_triggered();
void on_actionOnline_Help_triggered();
......@@ -195,6 +195,9 @@ private slots:
void on_actionBack_to_Origin_triggered();
void on_actionZoom_Windows_triggered();
void on_actionZoom_Extents_triggered();
//Drawing ToolBar
void setupDrawingToolBar();
};
#endif // MAINWINDOW_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