From f324c47a3b0af92ea46047777401f4a125eae27f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 20 Jul 2015 10:53:39 +0200 Subject: [PATCH 01/53] Waypoints and landmarks are back in. Changed the process of editing lines --- src/GraphicView.cpp | 164 ++++++++++++++++++++++++++++---------------- src/GraphicView.h | 1 + src/datamanager.cpp | 12 ++-- 3 files changed, 113 insertions(+), 64 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index b98f0cc..ccecbaa 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -68,6 +68,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) this->scale(1/gl_scale_f,-1/gl_scale_f); _currentTrackedPoint=nullptr; _statLineEdit=false; + intersection_point=nullptr; lines_collided=false; _assoDef=false; @@ -241,7 +242,13 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) void jpsGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button()==Qt::LeftButton) + { /// To avoid deleting of edited line + if (line_tracked==1) + { + current_line=nullptr; + } emit no_drawing(); + } } @@ -495,6 +502,13 @@ void jpsGraphicsView::catch_points() // range chosen: 10 (-5:5) (has to be changed soon) if (line_vector[i]->get_line()->line().x1()>=(translated_pos.x()-catch_radius) && line_vector[i]->get_line()->line().x1()<=(translated_pos.x()+catch_radius) && line_vector[i]->get_line()->line().y1()>=(translated_pos.y()-catch_radius) && line_vector[i]->get_line()->line().y1()<=(translated_pos.y()+catch_radius)){ /// in this case the cursor is working with global coordinates. So the method 'mapToGlobal' must be used + + ///to avoid the tracking of the coords of an edited line + if (line_vector[i]->get_line()==current_line) + { + continue; + } + translated_pos.setX(line_vector[i]->get_line()->line().x1()); translated_pos.setY(line_vector[i]->get_line()->line().y1()); //cursor.setPos(mapToGlobal(QPoint(translate_back_x(line_vector[i].x1()),translate_back_y(line_vector[i].y1())))); @@ -512,6 +526,14 @@ void jpsGraphicsView::catch_points() ///Searching for endpoints of all lines near the current cursor position else if (line_vector[i]->get_line()->line().x2()>=(translated_pos.x()-catch_radius) && line_vector[i]->get_line()->line().x2()<=(translated_pos.x()+catch_radius) && line_vector[i]->get_line()->line().y2()>=(translated_pos.y()-catch_radius) && line_vector[i]->get_line()->line().y2()<=(translated_pos.y()+catch_radius)){ // see above + + ///to avoid the tracking of the coords of an edited line + if (line_vector[i]->get_line()==current_line) + { + continue; + } + + translated_pos.setX(line_vector[i]->get_line()->line().x2()); translated_pos.setY(line_vector[i]->get_line()->line().y2()); //cursor.setPos(mapToGlobal(QPoint(translate_back_x(line_vector[i].x2()),translate_back_y(line_vector[i].y2())))); @@ -572,18 +594,18 @@ void jpsGraphicsView::catch_lines() line_tracked=-1; if (currentSelectRect->rect().width()<0) { - for (auto &item:line_vector) - { - if (currentSelectRect->contains(item->get_line()->line().p1()) - && currentSelectRect->contains(item->get_line()->line().p2())) + for (auto &item:line_vector) { - select_line(item); - line_tracked=1; + if (currentSelectRect->contains(item->get_line()->line().p1()) + && currentSelectRect->contains(item->get_line()->line().p2())) + { + select_line(item); + line_tracked=1; + } } } - } /// if current rect was build up moving the cursor to the right -> /// throwing the select rect only over a part of a line is sufficent to select it else if (currentSelectRect->rect().width()>0) @@ -617,37 +639,43 @@ void jpsGraphicsView::drawLine() // if the mouse was pressed secondly of two times else { - jpsLineItem* lineItem= new jpsLineItem(current_line); - - // if there is already a drawn line - if (line_vector.size()>=1) - { - // Searching for intersection of the current line with all already drawn lines - for (int i=0; iset_type(statWall,statDoor,statExit); - line_vector.push_back(lineItem); - - ///reset pointer - current_line=nullptr; - + /// If line is edited currently if (_statLineEdit) { - select_line(lineItem); + //select_line(lineItem); + current_line=nullptr; _statLineEdit=false; line_tracked=1; emit no_drawing(); } + else + { + + jpsLineItem* lineItem= new jpsLineItem(current_line); + + // if there is already a drawn line + if (line_vector.size()>=1) + { + // Searching for intersection of the current line with all already drawn lines + for (int i=0; iset_type(statWall,statDoor,statExit); + line_vector.push_back(lineItem); + + ///reset pointer + current_line=nullptr; + drawLine(); + } } @@ -797,19 +825,29 @@ void jpsGraphicsView::EditLine(QPointF* point) if (marked_lines.size()==1) { + delete current_rect; + current_rect=nullptr; + + point_tracked=false; + if (marked_lines.first()->get_line()->line().p1()==*point) { - current_line=Scene->addLine(marked_lines[0]->get_line()->line().p2().x(), - marked_lines[0]->get_line()->line().p2().y(),translated_pos.x(),translated_pos.y(),QPen(Qt::red,0)); - current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); + current_line=marked_lines[0]->get_line(); + marked_lines[0]->get_line()->setLine(marked_lines[0]->get_line()->line().x2(),marked_lines[0]->get_line()->line().y2(),translated_pos.x(),translated_pos.y()); + //current_line=Scene->addLine(marked_lines[0]->get_line()->line().p2().x(), + // marked_lines[0]->get_line()->line().p2().y(),translated_pos.x(),translated_pos.y(),QPen(Qt::red,0)); + //current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); emit set_focus_textedit(); } else if (marked_lines.first()->get_line()->line().p2()==*point) { - current_line=Scene->addLine(marked_lines[0]->get_line()->line().p1().x(), - marked_lines[0]->get_line()->line().p1().y(),translated_pos.x(),translated_pos.y(),QPen(Qt::red,0)); - current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); + current_line=marked_lines[0]->get_line(); + marked_lines[0]->get_line()->setLine(marked_lines[0]->get_line()->line().x1(),marked_lines[0]->get_line()->line().y1(),translated_pos.x(),translated_pos.y()); + + //->get_line()->line().p1().x(), + //marked_lines[0]->get_line()->line().p1().y(),translated_pos.x(),translated_pos.y(),QPen(Qt::red,0); + //current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); emit set_focus_textedit(); } @@ -817,8 +855,9 @@ void jpsGraphicsView::EditLine(QPointF* point) return; //line_tracked=1; + RemoveIntersections(marked_lines.first()); _statLineEdit=true; - delete_marked_lines(); + //delete_marked_lines(); en_disableWall(); } @@ -1019,6 +1058,11 @@ void jpsGraphicsView::translations(QPointF old_pos) for (int i=0; iget_line()->translate(pos.x()-old_pos.x(),pos.y()-old_pos.y()); + /// To avoid double sized translation of edited line + if (current_line==line_vector[i]->get_line()) + { + continue; + } line_vector[i]->get_line()->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); } @@ -1166,31 +1210,9 @@ void jpsGraphicsView::delete_marked_lines() for (int i=0; i points = marked_lines[i]->get_intersectionVector(); - - for (int j=0; jget_intersectLineVector().size(); ++k) - { - // removing the intersectionPoint pointer from all lines which includes the point - marked_lines[i]->get_intersectLineVector()[k]->remove_intersectionPoint(points[j]); - - // as marked_lines is removed it is has no intersections with any other line anymore - // so pointers of possible intersectionsLine have to be removed - } - - - } - - - for (int k=0; kget_intersectLineVector().size(); ++k) - { - marked_lines[i]->get_intersectLineVector()[k]->remove_interLine(marked_lines[i]); - } + RemoveIntersections(marked_lines[i]); delete marked_lines[i]->get_line(); //marked_lines[i]->set_line(nullptr); @@ -1209,6 +1231,32 @@ void jpsGraphicsView::delete_marked_lines() } +void jpsGraphicsView::RemoveIntersections(jpsLineItem *lineItem) +{ + QList points = lineItem->get_intersectionVector(); + + for (int j=0; jget_intersectLineVector().size(); ++k) + { + // removing the intersectionPoint pointer from all lines which includes the point + lineItem->get_intersectLineVector()[k]->remove_intersectionPoint(points[j]); + + // as marked_lines is removed it has no intersections with any other line anymore + // so pointers of possible intersectionsLine have to be removed + + } + } + + + for (int k=0; kget_intersectLineVector().size(); ++k) + { + lineItem->get_intersectLineVector()[k]->remove_interLine(lineItem); + } +} + void jpsGraphicsView::delete_landmark() { if (markedLandmark!=nullptr) diff --git a/src/GraphicView.h b/src/GraphicView.h index 6e2d468..3500d5c 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -76,6 +76,7 @@ class jpsGraphicsView: public QGraphicsView { void drawLine(); qreal calc_d_point(const QLineF &line, const qreal &x, const qreal &y); void delete_marked_lines(); + void RemoveIntersections(jpsLineItem* lineItem); /// Landmark void delete_landmark(); diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 45ed66c..a0850ed 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -257,9 +257,9 @@ void jpsDatamanager::writeXML(QFile &file) exitList.clear(); stream->writeEndElement();//transitions - //stream->writeStartElement("landmarks"); - //writeLandmarks(stream,landmarks); - //stream->writeEndElement();//landmarks + stream->writeStartElement("landmarks"); + writeLandmarks(stream,landmarks); + stream->writeEndElement();//landmarks stream->writeEndElement();//geometry @@ -284,9 +284,9 @@ void jpsDatamanager::AutoSaveXML(QFile &file) exitList.clear(); stream->writeEndElement();//transitions - //stream->writeStartElement("landmarks"); - //writeLandmarks(stream,landmarks); - //stream->writeEndElement();//landmarks + stream->writeStartElement("landmarks"); + writeLandmarks(stream,landmarks); + stream->writeEndElement();//landmarks stream->writeEndElement();//geometry From ec0d57145e75a964c492eab8b383aa9f5be355ed Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 29 Jul 2015 16:25:41 +0200 Subject: [PATCH 02/53] first attempts to establish a backgroundgrid --- forms/backgroundgrid.png | Bin 0 -> 35014 bytes forms/backgroundgridpoints.png | Bin 0 -> 6785 bytes src/GraphicView.cpp | 210 +++++++++++++++++++-------------- src/GraphicView.h | 62 +++++----- src/mainWindow.cpp | 6 +- src/mainWindow.h | 2 +- 6 files changed, 154 insertions(+), 126 deletions(-) create mode 100644 forms/backgroundgrid.png create mode 100644 forms/backgroundgridpoints.png diff --git a/forms/backgroundgrid.png b/forms/backgroundgrid.png new file mode 100644 index 0000000000000000000000000000000000000000..e98e2c8f36f2322e2e1b1e29b9b6ac9c2a5ed081 GIT binary patch literal 35014 zcmeI5e{2)y8OPlQ;ueBKs|o^jX3?sf(9j&prZ|g|OEA#T6|%9a6-%{C#g9@^>VzoDP1UJ1{R$?4G*k_;b?fc%5 z!2VmPC(r5=$%_0+uiv{@&-;Cz_j#Ys-JgHG`Kd(7LREsv2t=pnf&BLGj^B>5> zEf;>ve2xFzSF`1*wW`y-S|9#0@1@dBr7G1K`$F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!it=od^flB*671ea znu$-19X2qDK@Z+0@NB&x{KLceTS#Hc)xW%=l)2*)`Z?FTtpDl;E?RkKpIlKh=d2C$ zIMHC_8I~*dW(HT!=6oL5qr~O7?jDywn)?cs!hX3>$N1I#R--NgJ>{JX%n(=ttd+FV z1SY0Keq7tmGZtw|cUiy%lS)~7aw-{_m>x}I>WO2JgYN!lF)vqT;u@MHxt64a?st`H zYC--%#6iSC#M4T|Blmo@Of1;upo$qO(evaDG03r$6m&7>Bn9T>9y7Yc=~?O4SkIzr zDb~p{qR+($NrI>nub=oFm(Ksxr*N?|8TbDZ%Dsp-kl-D$T>z;9#tXPIhS&k70|>qLlfZ*!18;c!EW~hqzaHK zK&k+#0;Ku_dq*-rssO11nwVy2A|SPZ)Dp1#`@9P}o$*%m2Wi5K=C3?{Wx4z5(`FU^ O+qi!7y3=bb|M(sGPFv+DPq8*OT4YF3(e^~RMOS9XRb2PX$V59{^q zMVI*eY1!HHAgdV|BvjUbX$BXVVWR@z0Kp88;KZkS>p$ZSSdXiC+8RyD;1okdND&T8+$u(sGB}hm^Efs0>1a|OP0GL!plu?Ln4jiomN9#ah w%bL+rnb?q`qz)V{mFZ9_!y{height(); - gridmode=false; + anglesnap=false; gl_scale_f=.01; //scale(10,10); catch_radius=10*gl_scale_f; @@ -56,6 +56,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) line_tracked=-1; current_rect=nullptr; currentSelectRect=nullptr; + gridmap=nullptr; objectsnap=false; statWall=false; statDoor=false; @@ -98,7 +99,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) setScene(Scene); setSceneRect(0, 0, 1920, 1080); - //create_grid(); + create_grid(); ///Origin @@ -128,18 +129,18 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) pos=mapToScene(mouseEvent->pos()); - if (gridmode==true) + if (anglesnap==true) { if (current_line!=nullptr) { - use_gridmode(current_line,5); + use_anglesnap(current_line,5); } } if (_currentVLine!=nullptr) { /// vline will be deleted if it is not thrown horizontally or vertically - if(!use_gridmode(_currentVLine,15)) + if(!use_anglesnap(_currentVLine,15)) { delete _currentVLine; _currentVLine=nullptr; @@ -162,10 +163,14 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) translated_pos.setX(pos.x()-translation_x); translated_pos.setY(pos.y()-translation_y); + if (objectsnap) { + catch_points(); + use_gridmode(); + ///VLine if (point_tracked && (statWall==true || statDoor==true || statExit==true)) { @@ -205,7 +210,20 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) if (statWall==true || statDoor==true || statExit==true) { - drawLine(); + /// If line is edited currently + if (_statLineEdit) + { + for (jpsLineItem* line:line_vector) + { + locate_intersection(marked_lines.first(),line); + } + current_line=nullptr; + _statLineEdit=false; + line_tracked=1; + emit no_drawing(); + } + else + drawLine(); } else if (statLandmark==true) { @@ -462,7 +480,7 @@ void jpsGraphicsView::delete_all(bool final) update(); } -bool jpsGraphicsView::use_gridmode(QGraphicsLineItem* currentline, int accuracy) +bool jpsGraphicsView::use_anglesnap(QGraphicsLineItem* currentline, int accuracy) { // if a current line is in the drawing procedure (i. e. starting point is determined but not the ending point) @@ -494,6 +512,21 @@ bool jpsGraphicsView::use_gridmode(QGraphicsLineItem* currentline, int accuracy) return false; } +void jpsGraphicsView::use_gridmode() +{ + if ((std::fmod(translated_pos.x(),1.0)<=0.1 || std::fmod(translated_pos.x(),1.0)>=0.9) && + (std::fmod(translated_pos.y(),1.0)<=0.1 || std::fmod(translated_pos.y(),1.0)>=0.9)) + { + translated_pos.setX(int(translated_pos.x()+0.5)); + translated_pos.setY(int(translated_pos.y()+0.5)); + current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); + point_tracked=true; + _currentTrackedPoint= &translated_pos; + } + else + point_tracked=false; +} + void jpsGraphicsView::catch_points() { ///Searching for startpoints of all lines near the current cursor position @@ -639,43 +672,30 @@ void jpsGraphicsView::drawLine() // if the mouse was pressed secondly of two times else { - /// If line is edited currently - if (_statLineEdit) - { - //select_line(lineItem); - current_line=nullptr; - _statLineEdit=false; - line_tracked=1; - emit no_drawing(); - } + jpsLineItem* lineItem= new jpsLineItem(current_line); - else + // if there is already a drawn line + if (line_vector.size()>=1) { - - jpsLineItem* lineItem= new jpsLineItem(current_line); - - // if there is already a drawn line - if (line_vector.size()>=1) + // Searching for intersection of the current line with all already drawn lines + for (int i=0; iset_type(statWall,statDoor,statExit); - line_vector.push_back(lineItem); + lineItem->set_type(statWall,statDoor,statExit); + line_vector.push_back(lineItem); - ///reset pointer - current_line=nullptr; + ///reset pointer + current_line=nullptr; + + drawLine(); - drawLine(); - } } @@ -939,7 +959,14 @@ void jpsGraphicsView::create_grid() /// FIX ME!!!! //{ // delete gridpoint; //} - grid_point_vector.clear(); + //grid_point_vector.clear(); + + QPixmap pixmap("../jupedsim/forms/backgroundgridpoints.png"); + + gridmap = Scene->addPixmap(pixmap); + + gridmap->setScale(0.0269); + gridmap->setTransform(QTransform::fromTranslate(-0.96,-0.05), true); //std::cout << rect.bottomRight().y() << std::endl; @@ -947,30 +974,30 @@ void jpsGraphicsView::create_grid() /// FIX ME!!!! //QPointF leftup = mapToScene(Scene->sceneRect().bottomLeft().x(),Scene->sceneRect().bottomLeft().y()); //std::cout << leftup.x()-translation_x << std::endl; - qreal rightx = translated_pos.x()+1920*gl_scale_f; - qreal upy = translated_pos.y()+1080*gl_scale_f; - qreal leftx = translated_pos.x()-1920*gl_scale_f; - qreal downy = translated_pos.y()-1080*gl_scale_f; - //QGraphicsEllipseItem* point = Scene->addEllipse(0,0,10,10,QPen(Qt::red)); - //point->setTransform(Scene->sceneRect().); - //point->setTransform(QTransform::fromTranslate(translation_x,translation_y)); - //grid_point_vector.push_back(point); - //std::cout << translation_y << std::endl; - //std::cout << this->height() << std::endl; - //qreal leftdownx = leftdown.x();//+translation_x; - //qreal leftdowny = leftdown.y();//+translation_y; - - //QPointF topRight = mapToScene(this->sceneRect().topRight().x(),this->sceneRect().topRight().y()); - //qreal rightupx = topRight.x();//+translation_x; - //qreal rightupy = topRight.y();//+translation_y; - - //std::cout << rightupx << std::endl; - //std::cout << rightupy << std::endl; - int intervall=100*gl_scale_f; - int ileftx = leftx/intervall; - ileftx*=intervall; - int idowny = downy/intervall; - idowny*=intervall; +// qreal rightx = translated_pos.x()+1920*gl_scale_f; +// qreal upy = translated_pos.y()+1080*gl_scale_f; +// qreal leftx = translated_pos.x()-1920*gl_scale_f; +// qreal downy = translated_pos.y()-1080*gl_scale_f; +// //QGraphicsEllipseItem* point = Scene->addEllipse(0,0,10,10,QPen(Qt::red)); +// //point->setTransform(Scene->sceneRect().); +// //point->setTransform(QTransform::fromTranslate(translation_x,translation_y)); +// //grid_point_vector.push_back(point); +// //std::cout << translation_y << std::endl; +// //std::cout << this->height() << std::endl; +// //qreal leftdownx = leftdown.x();//+translation_x; +// //qreal leftdowny = leftdown.y();//+translation_y; + +// //QPointF topRight = mapToScene(this->sceneRect().topRight().x(),this->sceneRect().topRight().y()); +// //qreal rightupx = topRight.x();//+translation_x; +// //qreal rightupy = topRight.y();//+translation_y; + +// //std::cout << rightupx << std::endl; +// //std::cout << rightupy << std::endl; +// int intervall=100*gl_scale_f; +// int ileftx = leftx/intervall; +// ileftx*=intervall; +// int idowny = downy/intervall; +// idowny*=intervall; //int ileftdowny = std::floor(leftdowny); //int irightupx = std::floor(rightupx); //int irightupy = std::floor(rightupy); @@ -982,23 +1009,23 @@ void jpsGraphicsView::create_grid() /// FIX ME!!!! //std::cout << ileftdownx << std::endl; //std::cout << irightupy << std::endl; - for (int i=ileftx; iaddLine(i,j-5*gl_scale_f,i,j+5*gl_scale_f,QPen(Qt::red,0)); - line1->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); - grid_point_vector.push_back(line1); - QGraphicsLineItem* line2 = Scene->addLine(i-5*gl_scale_f,j,i+5*gl_scale_f,j,QPen(Qt::red,0)); - line2->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); - grid_point_vector.push_back(line2); - */ - QPointF gridpoint(i,j); - grid_point_vector.push_back(gridpoint); - } - } +// for (int i=ileftx; iaddLine(i,j-5*gl_scale_f,i,j+5*gl_scale_f,QPen(Qt::red,0)); +// line1->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); +// grid_point_vector.push_back(line1); +// QGraphicsLineItem* line2 = Scene->addLine(i-5*gl_scale_f,j,i+5*gl_scale_f,j,QPen(Qt::red,0)); +// line2->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); +// grid_point_vector.push_back(line2); +// */ +// QPointF gridpoint(i,j); +// grid_point_vector.push_back(gridpoint); +// } +// } //std::cout << leftup-translation_x << std::endl; } @@ -1075,13 +1102,13 @@ void jpsGraphicsView::translations(QPointF old_pos) caption_list[i]->setTransform(QTransform::fromScale(scalef,scalef),true); } - for (int i=0; iget_line()->translate(pos.x()-old_pos.x(),pos.y()-old_pos.y()); - //grid_point_vector[i]->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); - grid_point_vector[i].setX(pos.x()); - grid_point_vector[i].setY(pos.y()); - } +// for (int i=0; iget_line()->translate(pos.x()-old_pos.x(),pos.y()-old_pos.y()); +// //grid_point_vector[i]->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); +// grid_point_vector[i].setX(pos.x()); +// grid_point_vector[i].setY(pos.y()); +// } for (jpsLandmark* landmark:LLandmarks) { @@ -1092,6 +1119,10 @@ void jpsGraphicsView::translations(QPointF old_pos) { currentLandmarkRect->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); } + if (gridmap!=nullptr) + { + gridmap->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); + } for (QGraphicsEllipseItem* ellipse:_waypoints) { ellipse->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); @@ -1196,9 +1227,6 @@ qreal jpsGraphicsView::calc_d_point(const QLineF &line,const qreal &x, const qre } - - - // Delete single line void jpsGraphicsView::delete_marked_lines() @@ -1376,14 +1404,14 @@ bool jpsGraphicsView::statusWall() return statWall; } -void jpsGraphicsView::change_gridmode() +void jpsGraphicsView::change_stat_anglesnap() { - gridmode=!gridmode; + anglesnap=!anglesnap; } -bool jpsGraphicsView::get_gridmode() +bool jpsGraphicsView::get_stat_anglesnap() { - return gridmode; + return anglesnap; } void jpsGraphicsView::en_disableDoor() diff --git a/src/GraphicView.h b/src/GraphicView.h index 3500d5c..76145a7 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -48,9 +48,8 @@ class jpsGraphicsView: public QGraphicsView { ~jpsGraphicsView(); ///Change modes - void change_gridmode(); - bool get_gridmode(); - bool use_gridmode(QGraphicsLineItem *currentline, int accuracy); + void change_stat_anglesnap(); + bool get_stat_anglesnap(); void change_objectsnap(); bool get_objectsnap(); bool statusWall(); @@ -62,21 +61,42 @@ class jpsGraphicsView: public QGraphicsView { bool statusLandmark(); void en_disableLandmark(); + /// global functions + qreal get_scale_f(); + void take_l_from_lineEdit(const qreal &length); + void disable_drawing(); + bool use_anglesnap(QGraphicsLineItem *currentline, int accuracy); + void use_gridmode(); + ///View + void zoom(int delta); + void translations(QPointF old_pos); + void AutoZoom(); + ///Pos QPointF return_Pos(); - ///Catch points + ///Catch lines, points and intersections void catch_points(); + void locate_intersection(jpsLineItem* item1, jpsLineItem* item2); + void line_collision(); + void catch_lines(); ///Delete all void delete_all(bool final=false); ///Line operations - void catch_lines(); void drawLine(); qreal calc_d_point(const QLineF &line, const qreal &x, const qreal &y); void delete_marked_lines(); void RemoveIntersections(jpsLineItem* lineItem); + /// lines read from dxf-file + jpsLineItem *addLineItem(const qreal &x1, const qreal &y1, const qreal &x2, const qreal &y2, const QString &type=""); + QList get_markedLines(); + QList get_line_vector(); + void unmark_all_lines(); + void select_line(jpsLineItem *mline); + void SetVLine(); + void EditLine(QPointF* point); /// Landmark void delete_landmark(); @@ -90,30 +110,13 @@ class jpsGraphicsView: public QGraphicsView { QGraphicsRectItem* GetCurrentSelectRect(); void ShowWaypoints(QList waypoints); - - /// Lines - void take_l_from_lineEdit(const qreal &length); - QList get_markedLines(); - QList get_line_vector(); - qreal get_scale_f(); - void unmark_all_lines(); - void select_line(jpsLineItem *mline); - void disable_drawing(); - jpsLineItem *addLineItem(const qreal &x1, const qreal &y1, const qreal &x2, const qreal &y2, const QString &type=""); - void locate_intersection(jpsLineItem* item1, jpsLineItem* item2); - void SetVLine(); - void EditLine(QPointF* point); - ///RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); - void line_collision(); + ///backgroundgrid void create_grid(); - ///View - void zoom(int delta); - void translations(QPointF old_pos); - void AutoZoom(); + public slots: ///Waypoints @@ -122,6 +125,7 @@ public slots: protected: + ///Mouse events virtual void mouseMoveEvent(QMouseEvent * mouseEvent); //void paintEvent(QPaintEvent* event); virtual void mousePressEvent(QMouseEvent *event); @@ -133,7 +137,7 @@ public slots: QGraphicsLineItem* current_line; //std::vector line_vector; QList intersect_point_vector; - QList grid_point_vector; + //QList grid_point_vector; QList line_vector; QList origin; //QList *> mainlist; @@ -145,7 +149,7 @@ public slots: qreal translation_x; qreal translation_y; QPointF translated_pos; - bool gridmode; + bool anglesnap; bool statWall; bool statDoor; bool statExit; @@ -169,9 +173,8 @@ public slots: QList _waypoints; QGraphicsLineItem* _currentVLine; QPointF* _currentTrackedPoint; - + QGraphicsPixmapItem* gridmap; bool _statLineEdit; - bool lines_collided; bool _assoDef; @@ -189,9 +192,6 @@ public slots: void AssoDefCompleted(); //void DoubleClick(); - - - }; diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 5456168..c4fc190 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -92,7 +92,7 @@ MWindow :: MWindow() { /// Tab Help connect(action_ber,SIGNAL(triggered(bool)),this,SLOT(info())); /// Tab Tools - connect(actionanglesnap,SIGNAL(triggered(bool)),this,SLOT(gridmode())); + connect(actionanglesnap,SIGNAL(triggered(bool)),this,SLOT(anglesnap())); 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())); @@ -265,9 +265,9 @@ void MWindow::info(){ 0,tr("About..."),tr("JuPedSim; Interface for generating and editing geometry(XML)-files necessary for using JPScore; Manual and tutorial coming soon!")); } -void MWindow::gridmode() +void MWindow::anglesnap() { - mview->change_gridmode(); + mview->change_stat_anglesnap(); } void MWindow::en_disableWall() diff --git a/src/mainWindow.h b/src/mainWindow.h index 3d76676..e44ded3 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -70,7 +70,7 @@ protected slots: void saveFile(); void saveAsDXF(); void info(); - void gridmode(); + void anglesnap(); void en_disableWall(); void en_disableDoor(); void en_disableExit(); From 5be72cfee37080b5383438b4bc7fe195a34523b7 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 30 Jul 2015 16:09:23 +0200 Subject: [PATCH 03/53] procedure to establish backgroundgrid changed again. Grid now will be painted using QGraphicsScene::drawBackground. Performance is OK --- jpseditor.pro | 6 ++- src/GraphicView.cpp | 97 +++++++------------------------------------- src/GraphicView.h | 10 ++--- src/graphicscene.cpp | 59 +++++++++++++++++++++++++++ src/graphicscene.h | 31 ++++++++++++++ src/mainWindow.cpp | 3 +- 6 files changed, 116 insertions(+), 90 deletions(-) create mode 100644 src/graphicscene.cpp create mode 100644 src/graphicscene.h diff --git a/jpseditor.pro b/jpseditor.pro index 71f932d..f2d6466 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -52,7 +52,8 @@ HEADERS += \ dxflib/src/dl_codes.h \ dxflib/src/dl_attributes.h \ src/jpswaypoint.h \ - src/widgetlandmark.h + src/widgetlandmark.h \ + src/graphicscene.h SOURCES += \ @@ -70,7 +71,8 @@ SOURCES += \ dxflib/src/dl_writer_ascii.cpp \ dxflib/src/dl_dxf.cpp \ src/jpswaypoint.cpp \ - src/widgetlandmark.cpp + src/widgetlandmark.cpp \ + src/graphicscene.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 5cd5e96..0d9939a 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -58,6 +58,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) currentSelectRect=nullptr; gridmap=nullptr; objectsnap=false; + _gridmode=false; statWall=false; statDoor=false; statExit=false; @@ -79,7 +80,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //m_graphView->setFixedSize(1600, 900); //m_graphView->setScene(m_graphScen); - setCacheMode(QGraphicsView::CacheBackground); + //setCacheMode(QGraphicsView::CacheBackground); setViewportUpdateMode(QGraphicsView::FullViewportUpdate); @@ -95,11 +96,12 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //Set-up the scene - Scene = new QGraphicsScene(this); + Scene = new GraphicScene(this); + setScene(Scene); setSceneRect(0, 0, 1920, 1080); - create_grid(); + //create_grid(); ///Origin @@ -950,85 +952,6 @@ void jpsGraphicsView::line_collision() ///FIX ME!!! } } -void jpsGraphicsView::create_grid() /// FIX ME!!!! -{ - //QPointF sceneViewBottomLeft = mapToScene(QPoint(this->sceneRect().bottomLeft())); - //QPointF sceneViewTopRight = mapToScene(QPoint(this->sceneRect().topRight())); - //QRectF rect = this->sceneRect(); - //for (QGraphicsLineItem *gridpoint: grid_point_vector) - //{ - // delete gridpoint; - //} - //grid_point_vector.clear(); - - QPixmap pixmap("../jupedsim/forms/backgroundgridpoints.png"); - - gridmap = Scene->addPixmap(pixmap); - - gridmap->setScale(0.0269); - gridmap->setTransform(QTransform::fromTranslate(-0.96,-0.05), true); - - //std::cout << rect.bottomRight().y() << std::endl; - - //QPointF leftdown = mapToScene(this->sceneRect().bottomLeft().x(),this->sceneRect().bottomLeft().y()); - - //QPointF leftup = mapToScene(Scene->sceneRect().bottomLeft().x(),Scene->sceneRect().bottomLeft().y()); - //std::cout << leftup.x()-translation_x << std::endl; -// qreal rightx = translated_pos.x()+1920*gl_scale_f; -// qreal upy = translated_pos.y()+1080*gl_scale_f; -// qreal leftx = translated_pos.x()-1920*gl_scale_f; -// qreal downy = translated_pos.y()-1080*gl_scale_f; -// //QGraphicsEllipseItem* point = Scene->addEllipse(0,0,10,10,QPen(Qt::red)); -// //point->setTransform(Scene->sceneRect().); -// //point->setTransform(QTransform::fromTranslate(translation_x,translation_y)); -// //grid_point_vector.push_back(point); -// //std::cout << translation_y << std::endl; -// //std::cout << this->height() << std::endl; -// //qreal leftdownx = leftdown.x();//+translation_x; -// //qreal leftdowny = leftdown.y();//+translation_y; - -// //QPointF topRight = mapToScene(this->sceneRect().topRight().x(),this->sceneRect().topRight().y()); -// //qreal rightupx = topRight.x();//+translation_x; -// //qreal rightupy = topRight.y();//+translation_y; - -// //std::cout << rightupx << std::endl; -// //std::cout << rightupy << std::endl; -// int intervall=100*gl_scale_f; -// int ileftx = leftx/intervall; -// ileftx*=intervall; -// int idowny = downy/intervall; -// idowny*=intervall; - //int ileftdowny = std::floor(leftdowny); - //int irightupx = std::floor(rightupx); - //int irightupy = std::floor(rightupy); - //std::cout << ileftupx << std::endl; - //std::cout << rightdownx << std::endl; - //QGraphicsTextItem* point = Scene->addText("Hallo Welt"); - //point->setX(ileftupx); - //point->setY(ileftupy); - //std::cout << ileftdownx << std::endl; - //std::cout << irightupy << std::endl; - -// for (int i=ileftx; iaddLine(i,j-5*gl_scale_f,i,j+5*gl_scale_f,QPen(Qt::red,0)); -// line1->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); -// grid_point_vector.push_back(line1); -// QGraphicsLineItem* line2 = Scene->addLine(i-5*gl_scale_f,j,i+5*gl_scale_f,j,QPen(Qt::red,0)); -// line2->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); -// grid_point_vector.push_back(line2); -// */ -// QPointF gridpoint(i,j); -// grid_point_vector.push_back(gridpoint); -// } -// } - - //std::cout << leftup-translation_x << std::endl; -} void jpsGraphicsView::zoom(int delta) { @@ -1069,6 +992,9 @@ void jpsGraphicsView::translations(QPointF old_pos) translation_x+=pos.x()-old_pos.x(); translation_y+=pos.y()-old_pos.y(); + /// translate the background grid + Scene->ChangeTranslation(translation_x,translation_y); + if (current_line!=nullptr) { //current_line->translate(pos.x()-old_pos.x(),pos.y()-old_pos.y()); @@ -1382,6 +1308,13 @@ bool jpsGraphicsView::get_objectsnap() return objectsnap; } +void jpsGraphicsView::change_gridmode() +{ + _gridmode=!_gridmode; + Scene->ChangeGridmode(_gridmode); + Scene->update(); +} + void jpsGraphicsView::en_disableWall() { statWall=!statWall; diff --git a/src/GraphicView.h b/src/GraphicView.h index 76145a7..d1729f5 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -30,7 +30,8 @@ #include -#include +//#include +#include "graphicscene.h" #include #include "jpsLineItem.h" #include "jpslandmark.h" @@ -52,6 +53,7 @@ class jpsGraphicsView: public QGraphicsView { bool get_stat_anglesnap(); void change_objectsnap(); bool get_objectsnap(); + void change_gridmode(); bool statusWall(); void en_disableWall(); bool statusDoor(); @@ -113,9 +115,6 @@ class jpsGraphicsView: public QGraphicsView { ///RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); - ///backgroundgrid - void create_grid(); - public slots: @@ -143,7 +142,7 @@ public slots: //QList *> mainlist; QPointF pos; //QPointF* intersection_point; - QGraphicsScene* Scene; + GraphicScene* Scene; bool midbutton_hold; bool leftbutton_hold; qreal translation_x; @@ -177,6 +176,7 @@ public slots: bool _statLineEdit; bool lines_collided; bool _assoDef; + bool _gridmode; //qreal gl_min_x; //qreal gl_min_y; diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp new file mode 100644 index 0000000..98c22ae --- /dev/null +++ b/src/graphicscene.cpp @@ -0,0 +1,59 @@ +#include "graphicscene.h" +#include + +GraphicScene::GraphicScene() +{ + +} + +GraphicScene::GraphicScene(QObject *parent) : QGraphicsScene(parent) +{ + _translationX=0.0; + _translationY=0.0; + _gridmode=false; +} + +GraphicScene::~GraphicScene() +{ + +} + +void GraphicScene::ChangeGridmode(const bool &stat) +{ + _gridmode=stat; +} + +bool GraphicScene::GetGridmode() const +{ + return _gridmode; +} + +void GraphicScene::ChangeTranslation(qreal x, qreal y) +{ + _translationX=x; + _translationY=y; +} + +void GraphicScene::drawBackground(QPainter *painter, const QRectF &rect) +{ + if (_gridmode) + { + const int gridSize = 1; + + qreal left = int(rect.left()-_translationX) - (int(rect.left()-_translationX) % gridSize); + qreal top = int(rect.top()-_translationY) - (int(rect.top()-_translationY) % gridSize); + + QVarLengthArray lines; + + for (qreal x = left; x < rect.right()-_translationX; x += gridSize) + lines.append(QLineF(x+_translationX, rect.top(), x+_translationX, rect.bottom())); + for (qreal y = top; y < rect.bottom()-_translationY; y += gridSize) + lines.append(QLineF(rect.left(), y+_translationY, rect.right(), y+_translationY)); + + //qDebug() << lines.size(); + painter->setPen(QPen(Qt::gray,0)); + painter->drawLines(lines.data(), lines.size()); + } + +} + diff --git a/src/graphicscene.h b/src/graphicscene.h new file mode 100644 index 0000000..f0257cc --- /dev/null +++ b/src/graphicscene.h @@ -0,0 +1,31 @@ +#ifndef GRAPHICSCENE_H +#define GRAPHICSCENE_H + +#include +#include + +class GraphicScene : public QGraphicsScene +{ + Q_OBJECT + +public: + GraphicScene(); + GraphicScene(QObject* parent=0); + GraphicScene(qreal x, qreal y, qreal w, qreal h) + : QGraphicsScene(x, y, w, h) + { } + ~GraphicScene(); + void ChangeGridmode(const bool& stat); + bool GetGridmode() const; + void ChangeTranslation(qreal x, qreal y); + +protected: + void drawBackground(QPainter *painter, const QRectF &rect); +private: + bool _gridmode; + qreal _translationX; + qreal _translationY; + +}; + +#endif // GRAPHICSCENE_H diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index c4fc190..8b0f62d 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -310,7 +310,8 @@ void MWindow::disableDrawing() void MWindow::objectsnap() { - mview->change_objectsnap(); + //mview->change_objectsnap(); + mview->change_gridmode(); } void MWindow::show_coords() From 95750f25f924a0bff1bdb27d9bbe81f7c8d48e61 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 30 Jul 2015 16:12:11 +0200 Subject: [PATCH 04/53] not necessary any more since grid will be painted by QPainter --- forms/backgroundgridpoints.png | Bin 6785 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 forms/backgroundgridpoints.png diff --git a/forms/backgroundgridpoints.png b/forms/backgroundgridpoints.png deleted file mode 100644 index d73d4234aa8971f2c83210c7a8c7ad05436a8dbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6785 zcmeAS@N?(olHy`uVBq!ia0y~yU<+elU|Pq)1{ArxSMeo~Vk{1FcVbv~P6otbNq6*h zWMJ6X&;2Kn70Bl-@Q5sCU=S(+Va9uD@)ZmWQevJijv*CsZ*OkoWpLyFv+DPq8*OT4YF3(e^~RMOS9XRb2PX$V59{^q zMVI*eY1!HHAgdV|BvjUbX$BXVVWR@z0Kp88;KZkS>p$ZSSdXiC+8RyD;1okdND&T8+$u(sGB}hm^Efs0>1a|OP0GL!plu?Ln4jiomN9#ah w%bL+rnb?q`qz)V{mFZ9_!y{ Date: Thu, 30 Jul 2015 16:12:30 +0200 Subject: [PATCH 05/53] not necessary any more since grid will be painted by QPainter --- forms/backgroundgrid.png | Bin 35014 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 forms/backgroundgrid.png diff --git a/forms/backgroundgrid.png b/forms/backgroundgrid.png deleted file mode 100644 index e98e2c8f36f2322e2e1b1e29b9b6ac9c2a5ed081..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35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ih-=pOoOJXG(;evnl_z6>@T=0Uy|^ z$%(5*Dc>RWH;H3sKOJ#%MbMKtSC}EN1XwHSr3rUxD9^rO_#f6!3VV%BtTYk8+k_CE zq@+*{dTd8EJ}`aymvTkToNF)H<3zoY$s|`p&J^2NXDc`VbY70jGw@MwcBZY{m#b_U z|9`mz!G4s#8aRNR3h5v(m5z3?O0YVMZF#!it=od^flB*671ea znu$-19X2qDK@Z+0@NB&x{KLceTS#Hc)xW%=l)2*)`Z?FTtpDl;E?RkKpIlKh=d2C$ zIMHC_8I~*dW(HT!=6oL5qr~O7?jDywn)?cs!hX3>$N1I#R--NgJ>{JX%n(=ttd+FV z1SY0Keq7tmGZtw|cUiy%lS)~7aw-{_m>x}I>WO2JgYN!lF)vqT;u@MHxt64a?st`H zYC--%#6iSC#M4T|Blmo@Of1;upo$qO(evaDG03r$6m&7>Bn9T>9y7Yc=~?O4SkIzr zDb~p{qR+($NrI>nub=oFm(Ksxr*N?|8TbDZ%Dsp-kl-D$T>z;9#tXPIhS&k70|>qLlfZ*!18;c!EW~hqzaHK zK&k+#0;Ku_dq*-rssO11nwVy2A|SPZ)Dp1#`@9P}o$*%m2Wi5K=C3?{Wx4z5(`FU^ O+qi!7y3=bb|M(sGP Date: Fri, 31 Jul 2015 15:35:30 +0200 Subject: [PATCH 06/53] background established. However, it is not adaptive yet. --- forms/Ressource.qrc | 1 + forms/anglesnap.PNG | Bin 0 -> 18685 bytes forms/mainwindow.ui | 33 ++++++++++++++++++++++++++++----- src/GraphicView.cpp | 27 +++++++++++++++++++-------- src/mainWindow.cpp | 7 ++++++- src/mainWindow.h | 1 + 6 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 forms/anglesnap.PNG diff --git a/forms/Ressource.qrc b/forms/Ressource.qrc index 04ae408..c9b94b3 100644 --- a/forms/Ressource.qrc +++ b/forms/Ressource.qrc @@ -38,5 +38,6 @@ jupedsim.png statue.jpg statue_specs.jpg + anglesnap.PNG diff --git a/forms/anglesnap.PNG b/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X-%$DAe?JD);Qz6IJLmRq b6Crp0{B&&J-|ruymKyCb)qlLp@z4JQML{ZI literal 0 HcmV?d00001 diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 855d0bc..60112e6 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -53,7 +53,7 @@ - + @@ -87,10 +87,12 @@ - + + + @@ -156,7 +158,7 @@ F1 - + true @@ -168,10 +170,10 @@ :/Grid.png:/Grid.png - Angle snap + Gridmode - Angle snap + Gridmode Ctrl+G @@ -422,6 +424,27 @@ LandmarkSpecs + + + true + + + true + + + + :/anglesnap.PNG:/anglesnap.PNG + + + Orthomode + + + Orthomode + + + Ctrl+H + + diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0d9939a..32efea8 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -165,13 +165,15 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) translated_pos.setX(pos.x()-translation_x); translated_pos.setY(pos.y()-translation_y); + if (_gridmode) + use_gridmode(); if (objectsnap) { catch_points(); - use_gridmode(); + ///VLine if (point_tracked && (statWall==true || statDoor==true || statExit==true)) @@ -516,11 +518,17 @@ bool jpsGraphicsView::use_anglesnap(QGraphicsLineItem* currentline, int accuracy void jpsGraphicsView::use_gridmode() { - if ((std::fmod(translated_pos.x(),1.0)<=0.1 || std::fmod(translated_pos.x(),1.0)>=0.9) && - (std::fmod(translated_pos.y(),1.0)<=0.1 || std::fmod(translated_pos.y(),1.0)>=0.9)) + if ((std::fmod(std::fabs(translated_pos.x()),1.0)<=0.1 || std::fmod(std::fabs(translated_pos.x()),1.0)>=0.9) && + (std::fmod(std::fabs(translated_pos.y()),1.0)<=0.1 || std::fmod(std::fabs(translated_pos.y()),1.0)>=0.9)) { - translated_pos.setX(int(translated_pos.x()+0.5)); - translated_pos.setY(int(translated_pos.y()+0.5)); + if (translated_pos.x()<0) + translated_pos.setX(int(translated_pos.x()-0.5)); + else + translated_pos.setX(int(translated_pos.x()+0.5)); + if (translated_pos.y()<0) + translated_pos.setY(int(translated_pos.y()-0.5)); + else + translated_pos.setY(int(translated_pos.y()+0.5)); current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); point_tracked=true; _currentTrackedPoint= &translated_pos; @@ -552,7 +560,8 @@ void jpsGraphicsView::catch_points() _currentTrackedPoint= &translated_pos; //QPen pen; //pen.setColor('red'); - current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); + if (current_rect==nullptr) + current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); /// if a point was tracked there is no need to look for further points ( only one point can be tracked) return; @@ -573,7 +582,8 @@ void jpsGraphicsView::catch_points() translated_pos.setY(line_vector[i]->get_line()->line().y2()); //cursor.setPos(mapToGlobal(QPoint(translate_back_x(line_vector[i].x2()),translate_back_y(line_vector[i].y2())))); point_tracked=true; - current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); + if (current_rect==nullptr) + current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); _currentTrackedPoint= &translated_pos; return; } @@ -587,8 +597,9 @@ void jpsGraphicsView::catch_points() { translated_pos.setX(intersect_point_vector[j]->x()); translated_pos.setY(intersect_point_vector[j]->y()); + if (current_rect==nullptr) current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); - point_tracked=true; + point_tracked=true; return; } } diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 8b0f62d..ac24fd3 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -93,6 +93,7 @@ MWindow :: MWindow() { connect(action_ber,SIGNAL(triggered(bool)),this,SLOT(info())); /// Tab Tools connect(actionanglesnap,SIGNAL(triggered(bool)),this,SLOT(anglesnap())); + connect(actiongridmode,SIGNAL(triggered(bool)),this,SLOT(gridmode())); 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())); @@ -310,7 +311,11 @@ void MWindow::disableDrawing() void MWindow::objectsnap() { - //mview->change_objectsnap(); + mview->change_objectsnap(); +} + +void MWindow::gridmode() +{ mview->change_gridmode(); } diff --git a/src/mainWindow.h b/src/mainWindow.h index e44ded3..3e0629d 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -77,6 +77,7 @@ protected slots: void en_disableLandmark(); void disableDrawing(); void objectsnap(); + void gridmode(); void show_coords(); void delete_lines(); void delete_marked_lines(); From 6915239dab3d81c628e10f2d236ef6c95a65ae44 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 3 Aug 2015 13:20:56 +0200 Subject: [PATCH 07/53] remove (redundant) constructor --- src/GraphicView.cpp | 2 +- src/graphicscene.cpp | 4 ---- src/graphicscene.h | 6 +++--- src/jpsobstacle.cpp | 1 + 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 32efea8..f9868af 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -96,7 +96,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //Set-up the scene - Scene = new GraphicScene(this); + Scene = new GraphicScene(qobject_cast(this)); setScene(Scene); setSceneRect(0, 0, 1920, 1080); diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index 98c22ae..db83022 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -1,10 +1,6 @@ #include "graphicscene.h" #include -GraphicScene::GraphicScene() -{ - -} GraphicScene::GraphicScene(QObject *parent) : QGraphicsScene(parent) { diff --git a/src/graphicscene.h b/src/graphicscene.h index f0257cc..3d2cac4 100644 --- a/src/graphicscene.h +++ b/src/graphicscene.h @@ -9,8 +9,8 @@ class GraphicScene : public QGraphicsScene Q_OBJECT public: - GraphicScene(); - GraphicScene(QObject* parent=0); + + GraphicScene(QObject* parent=nullptr); GraphicScene(qreal x, qreal y, qreal w, qreal h) : QGraphicsScene(x, y, w, h) { } @@ -20,7 +20,7 @@ class GraphicScene : public QGraphicsScene void ChangeTranslation(qreal x, qreal y); protected: - void drawBackground(QPainter *painter, const QRectF &rect); + void drawBackground(QPainter *painter, const QRectF &rect) override; private: bool _gridmode; qreal _translationX; diff --git a/src/jpsobstacle.cpp b/src/jpsobstacle.cpp index 3b4d710..2b8b52e 100644 --- a/src/jpsobstacle.cpp +++ b/src/jpsobstacle.cpp @@ -44,3 +44,4 @@ jpsRoom* jpsObstacle::get_room() { return _room; } + From 26797cc938fb9838d9186a6104afc4bf4daff451 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 3 Aug 2015 14:25:13 +0200 Subject: [PATCH 08/53] remove qObjectcast --- src/GraphicView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index f9868af..32efea8 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -96,7 +96,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //Set-up the scene - Scene = new GraphicScene(qobject_cast(this)); + Scene = new GraphicScene(this); setScene(Scene); setSceneRect(0, 0, 1920, 1080); From 57545d40d174192d8eabad04811e0d3237524856 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 3 Aug 2015 15:57:11 +0200 Subject: [PATCH 09/53] setScene qobject_cast --- src/GraphicView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 32efea8..0eb41a6 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -98,7 +98,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //Set-up the scene Scene = new GraphicScene(this); - setScene(Scene); + setScene(qobject_cast(Scene)); setSceneRect(0, 0, 1920, 1080); //create_grid(); From 4d0af02faa018d27eae737da82d629d6731a1904 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 3 Aug 2015 16:04:24 +0200 Subject: [PATCH 10/53] minor modifications --- src/GraphicView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0eb41a6..32efea8 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -98,7 +98,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //Set-up the scene Scene = new GraphicScene(this); - setScene(qobject_cast(Scene)); + setScene(Scene); setSceneRect(0, 0, 1920, 1080); //create_grid(); From ec049f6fba72e1cf99366d54dd9d0d744d92f7f4 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 4 Aug 2015 07:59:24 +0200 Subject: [PATCH 11/53] Add graphicscene to CMakeLists.txt --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa6befb..b635b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ set( SRCS src/mainWindow.cpp src/main.cpp src/GraphicView.cpp + src/graphicscene.cpp src/roomwidget.cpp src/rooms.cpp src/datamanager.cpp @@ -101,6 +102,7 @@ set( SRCS set( HDR src/mainWindow.h src/GraphicView.h + src/graphicscene.h src/roomwidget.h src/rooms.h src/datamanager.h From ac788db017ee2a17e592dc7a922853a3b2b32166 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 4 Aug 2015 08:04:44 +0200 Subject: [PATCH 12/53] #include QVarLengthArray --- src/graphicscene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index db83022..f88f5be 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -1,5 +1,5 @@ #include "graphicscene.h" -#include +#include GraphicScene::GraphicScene(QObject *parent) : QGraphicsScene(parent) From 29d0e4434a0ec8300a79645944e43244eaa5dc0a Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 4 Aug 2015 15:08:05 +0200 Subject: [PATCH 13/53] Adaptive grid (point- and line-grid can be selected via Settings) --- .idea/vcs.xml | 6 +++ CMakeLists.txt | 3 ++ forms/mainwindow.ui | 57 ++++++++++++++--------- forms/widgetsettings.ui | 100 ++++++++++++++++++++++++++++++++++++++++ jpseditor.pro | 9 ++-- src/GraphicView.cpp | 70 ++++++++++++++++++++++------ src/GraphicView.h | 9 +++- src/graphicscene.cpp | 63 ++++++++++++++++++++----- src/graphicscene.h | 6 +++ src/mainWindow.cpp | 63 ++++++++++++++++++------- src/mainWindow.h | 3 ++ src/widgetsettings.cpp | 31 +++++++++++++ src/widgetsettings.h | 29 ++++++++++++ 13 files changed, 382 insertions(+), 67 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 forms/widgetsettings.ui create mode 100644 src/widgetsettings.cpp create mode 100644 src/widgetsettings.h diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b635b72..1ac4a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,7 @@ set( SRCS src/jpslandmark.cpp src/jpswaypoint.cpp src/widgetlandmark.cpp + src/widgetsettings.cpp dxflib/src/dl_writer_ascii.cpp dxflib/src/dl_dxf.cpp ) @@ -113,6 +114,7 @@ set( HDR src/jpslandmark.h src/jpswaypoint.h src/widgetlandmark.h + src/widgetsettings.h dxflib/src/dl_writer_ascii.h dxflib/src/dl_writer.h dxflib/src/dl_global.h @@ -132,6 +134,7 @@ set( UIS forms/mainwindow.ui forms/roomwidget.ui forms/widgetlandmark.ui + forms/widgetsettings.ui ) # and finally a resource file diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 60112e6..41cc955 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -14,7 +14,7 @@ JuPedSim - + :/jupedsim.png:/jupedsim.png @@ -36,6 +36,8 @@ + + @@ -55,6 +57,7 @@ + @@ -104,7 +107,7 @@ - + :/open.png:/open.png @@ -119,7 +122,7 @@ - + :/filesave.png:/filesave.png @@ -134,7 +137,7 @@ - + :/man-gimp1.png:/man-gimp1.png @@ -166,7 +169,7 @@ true - + :/Grid.png:/Grid.png @@ -187,7 +190,7 @@ true - + :/Wall.png:/Wall.png @@ -208,7 +211,7 @@ true - + :/snap.png:/snap.png @@ -223,7 +226,7 @@ - + :/DeleteAll.png:/DeleteAll.png @@ -238,7 +241,7 @@ true - + :/Delete.png:/Delete.png @@ -259,7 +262,7 @@ true - + :/Door.png:/Door.png @@ -283,7 +286,7 @@ true - + :/Exit.png:/Exit.png @@ -307,7 +310,7 @@ true - + :/Room.png:/Room.png @@ -334,7 +337,7 @@ true - + :/basicCursor.png:/basicCursor.png @@ -352,7 +355,7 @@ - + :/filesave.png:/filesave.png @@ -367,7 +370,7 @@ - + :/open.png:/open.png @@ -396,7 +399,7 @@ true - + :/statue.jpg:/statue.jpg @@ -414,7 +417,7 @@ true - + :/statue_specs.jpg:/statue_specs.jpg @@ -432,7 +435,7 @@ true - + :/anglesnap.PNG:/anglesnap.PNG @@ -445,9 +448,21 @@ Ctrl+H + + + true + + + Settings + + + Settings + + + Ctrl+E + + - - - + diff --git a/forms/widgetsettings.ui b/forms/widgetsettings.ui new file mode 100644 index 0000000..1eabe5a --- /dev/null +++ b/forms/widgetsettings.ui @@ -0,0 +1,100 @@ + + + WidgetSettings + + + + 0 + 0 + 400 + 330 + + + + TabWidget + + + + View Settings + + + + + 10 + 10 + 171 + 241 + + + + Grid Settings + + + + + 10 + 30 + 95 + 20 + + + + Point Grid + + + false + + + + + + 10 + 60 + 95 + 20 + + + + Line Grid + + + true + + + + + + 0 + 90 + 171 + 16 + + + + Qt::Horizontal + + + + + + + 150 + 260 + 101 + 28 + + + + Apply and Close + + + + + + Tab 2 + + + + + + diff --git a/jpseditor.pro b/jpseditor.pro index f2d6466..d5095fc 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -27,7 +27,8 @@ QMAKE_CXXFLAGS += -std=c++11 FORMS += \ forms/mainwindow.ui \ forms/roomwidget.ui \ - forms/widgetlandmark.ui + forms/widgetlandmark.ui \ + forms/widgetsettings.ui HEADERS += \ src/mainWindow.h \ @@ -53,7 +54,8 @@ HEADERS += \ dxflib/src/dl_attributes.h \ src/jpswaypoint.h \ src/widgetlandmark.h \ - src/graphicscene.h + src/graphicscene.h \ + src/widgetsettings.h SOURCES += \ @@ -72,7 +74,8 @@ SOURCES += \ dxflib/src/dl_dxf.cpp \ src/jpswaypoint.cpp \ src/widgetlandmark.cpp \ - src/graphicscene.cpp + src/graphicscene.cpp \ + src/widgetsettings.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 32efea8..707ef19 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -46,7 +46,9 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) translation_x=0; translation_y=0;//this->height(); anglesnap=false; - gl_scale_f=.01; + _scaleFactor=1.0; + _gridSize=1.0; + gl_scale_f=.01*_scaleFactor; //scale(10,10); catch_radius=10*gl_scale_f; catch_line_distance=10*gl_scale_f; @@ -170,11 +172,8 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) if (objectsnap) { - catch_points(); - - ///VLine if (point_tracked && (statWall==true || statDoor==true || statExit==true)) { @@ -355,6 +354,18 @@ void jpsGraphicsView::ClearWaypoints() } +void jpsGraphicsView::ActivateLineGrid() +{ + Scene->SetGrid("Line"); + +} + +void jpsGraphicsView::ActivatePointGrid() +{ + Scene->SetGrid("Point"); + +} + void jpsGraphicsView::wheelEvent(QWheelEvent *event) { @@ -518,17 +529,20 @@ bool jpsGraphicsView::use_anglesnap(QGraphicsLineItem* currentline, int accuracy void jpsGraphicsView::use_gridmode() { - if ((std::fmod(std::fabs(translated_pos.x()),1.0)<=0.1 || std::fmod(std::fabs(translated_pos.x()),1.0)>=0.9) && - (std::fmod(std::fabs(translated_pos.y()),1.0)<=0.1 || std::fmod(std::fabs(translated_pos.y()),1.0)>=0.9)) + if ((std::fmod(std::fabs(translated_pos.x()),_gridSize)<=_gridSize*0.1 || std::fmod(std::fabs(translated_pos.x()),_gridSize)>=_gridSize*0.9) && + (std::fmod(std::fabs(translated_pos.y()),_gridSize)<=_gridSize*0.1 || std::fmod(std::fabs(translated_pos.y()),_gridSize)>=_gridSize*0.9)) { - if (translated_pos.x()<0) - translated_pos.setX(int(translated_pos.x()-0.5)); + if (std::fmod(std::fabs(translated_pos.x()),_gridSize)<=_gridSize*0.1) + translated_pos.setX(translated_pos.x()-std::fmod(translated_pos.x(),_gridSize)); else - translated_pos.setX(int(translated_pos.x()+0.5)); - if (translated_pos.y()<0) - translated_pos.setY(int(translated_pos.y()-0.5)); + translated_pos.setX(translated_pos.x()+(_gridSize-std::fmod(translated_pos.x(),_gridSize))); + + if (std::fmod(std::fabs(translated_pos.y()),_gridSize)<=_gridSize*0.1) + translated_pos.setY(translated_pos.y()-std::fmod(translated_pos.y(),_gridSize)); else - translated_pos.setY(int(translated_pos.y()+0.5)); + translated_pos.setY(translated_pos.y()+(_gridSize-std::fmod(translated_pos.y(),_gridSize))); + + current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); point_tracked=true; _currentTrackedPoint= &translated_pos; @@ -540,7 +554,7 @@ void jpsGraphicsView::use_gridmode() void jpsGraphicsView::catch_points() { ///Searching for startpoints of all lines near the current cursor position - for (signed int i=0; iget_line()->line().x1()>=(translated_pos.x()-catch_radius) && line_vector[i]->get_line()->line().x1()<=(translated_pos.x()+catch_radius) && line_vector[i]->get_line()->line().y1()>=(translated_pos.y()-catch_radius) && line_vector[i]->get_line()->line().y1()<=(translated_pos.y()+catch_radius)){ @@ -979,20 +993,24 @@ void jpsGraphicsView::zoom(int delta) // { // caption_list[i]->setTransform(QTransform::fromScale(1/gl_scale_f,1/gl_scale_f)); //} + _scaleFactor*=1/1.15; gl_scale_f*=1/1.15; scale(scaleFactor, scaleFactor); catch_radius=10*gl_scale_f; catch_line_distance=10*gl_scale_f; + Scene->ChangeGridSize(this->CalcGridSize()); //create_grid(); } else { // Zooming out + _scaleFactor*=1.15; gl_scale_f*=1.15; scale(1.0 / scaleFactor, 1.0 / scaleFactor); catch_radius=10*gl_scale_f; catch_line_distance=10*gl_scale_f; + Scene->ChangeGridSize(this->CalcGridSize()); //create_grid(); } @@ -1138,6 +1156,32 @@ void jpsGraphicsView::AutoZoom() } +qreal jpsGraphicsView::CalcGridSize() +{ + int cFactor; + if (_scaleFactor<1.0) + { + cFactor = std::round(1/_scaleFactor);//std::round(_scaleFactor); + } + else + cFactor = std::round(_scaleFactor); + + int n=0; + while (cFactor>std::pow(2,n)) + { + n++; + } + qreal gridSize; + if (_scaleFactor<1.0) + gridSize=1/std::pow(2,n); + else + gridSize=std::pow(2,n); + + _gridSize=gridSize; + return gridSize; + +} + void jpsGraphicsView::StatAssoDef() { _assoDef=!_assoDef; diff --git a/src/GraphicView.h b/src/GraphicView.h index d1729f5..a704b1f 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -69,10 +69,12 @@ class jpsGraphicsView: public QGraphicsView { void disable_drawing(); bool use_anglesnap(QGraphicsLineItem *currentline, int accuracy); void use_gridmode(); + ///View void zoom(int delta); void translations(QPointF old_pos); void AutoZoom(); + qreal CalcGridSize(); ///Pos QPointF return_Pos(); @@ -118,9 +120,12 @@ class jpsGraphicsView: public QGraphicsView { public slots: - ///Waypoints + //Waypoints void StatAssoDef(); void ClearWaypoints(); + //GridSettings + void ActivateLineGrid(); + void ActivatePointGrid(); protected: @@ -154,7 +159,9 @@ public slots: bool statExit; bool statLandmark; qreal catch_radius; + qreal _scaleFactor; qreal gl_scale_f; + qreal _gridSize; bool point_tracked; QGraphicsItem* current_rect; QGraphicsRectItem* currentSelectRect; diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index f88f5be..941c685 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -7,6 +7,8 @@ GraphicScene::GraphicScene(QObject *parent) : QGraphicsScene(parent) _translationX=0.0; _translationY=0.0; _gridmode=false; + _statgrid="Line"; + _gridSize=1.0; } GraphicScene::~GraphicScene() @@ -30,26 +32,63 @@ void GraphicScene::ChangeTranslation(qreal x, qreal y) _translationY=y; } +void GraphicScene::SetGrid(QString grid) +{ + _statgrid=grid; +} + +void GraphicScene::ChangeGridSize(const qreal &gridSize) +{ + _gridSize=gridSize; +} + void GraphicScene::drawBackground(QPainter *painter, const QRectF &rect) { if (_gridmode) { - const int gridSize = 1; + if (_statgrid=="Line") + DrawLineGrid(painter,rect); + else + DrawPointGrid(painter,rect); + } +} - qreal left = int(rect.left()-_translationX) - (int(rect.left()-_translationX) % gridSize); - qreal top = int(rect.top()-_translationY) - (int(rect.top()-_translationY) % gridSize); +void GraphicScene::DrawLineGrid(QPainter *painter, const QRectF &rect) +{ + //gridSize=1.0; + qreal left = int(rect.left()-_translationX) - std::fmod(int(rect.left()-_translationX), _gridSize); + qreal top = int(rect.top()-_translationY)- std::fmod(int(rect.top()-_translationY) , _gridSize); - QVarLengthArray lines; + QVarLengthArray lines; - for (qreal x = left; x < rect.right()-_translationX; x += gridSize) - lines.append(QLineF(x+_translationX, rect.top(), x+_translationX, rect.bottom())); - for (qreal y = top; y < rect.bottom()-_translationY; y += gridSize) - lines.append(QLineF(rect.left(), y+_translationY, rect.right(), y+_translationY)); + for (qreal x = left; x < rect.right()-_translationX; x += _gridSize) + lines.append(QLineF(x+_translationX, rect.top(), x+_translationX, rect.bottom())); + for (qreal y = top; y < rect.bottom()-_translationY; y += _gridSize) + lines.append(QLineF(rect.left(), y+_translationY, rect.right(), y+_translationY)); + + //qDebug() << lines.size(); + painter->setPen(QPen(Qt::gray,0)); + painter->drawLines(lines.data(), lines.size()); +} + +void GraphicScene::DrawPointGrid(QPainter *painter, const QRectF &rect) +{ - //qDebug() << lines.size(); - painter->setPen(QPen(Qt::gray,0)); - painter->drawLines(lines.data(), lines.size()); - } + qreal left = int(rect.left()-_translationX) - std::fmod(int(rect.left()-_translationX), _gridSize); + qreal top = int(rect.top()-_translationY)- std::fmod(int(rect.top()-_translationY) , _gridSize); + + QVarLengthArray points; + + for (qreal x = left; x < rect.right()-_translationX; x += _gridSize) + { + for (qreal y = top; y < rect.bottom()-_translationY; y += _gridSize) + { + points.append(QPointF(x+_translationX, y+_translationY)); + } + } + //qDebug() << lines.size(); + painter->setPen(QPen(Qt::black,0)); + painter->drawPoints(points.data(), points.size()); } diff --git a/src/graphicscene.h b/src/graphicscene.h index 3d2cac4..91da5da 100644 --- a/src/graphicscene.h +++ b/src/graphicscene.h @@ -18,13 +18,19 @@ class GraphicScene : public QGraphicsScene void ChangeGridmode(const bool& stat); bool GetGridmode() const; void ChangeTranslation(qreal x, qreal y); + void SetGrid(QString grid); + void ChangeGridSize(const qreal& factor); protected: void drawBackground(QPainter *painter, const QRectF &rect) override; + void DrawLineGrid(QPainter *painter, const QRectF &rect); + void DrawPointGrid(QPainter *painter, const QRectF &rect); private: bool _gridmode; qreal _translationX; qreal _translationY; + QString _statgrid; + qreal _gridSize; }; diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index ac24fd3..eb2a5c4 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -47,10 +47,12 @@ MWindow :: MWindow() { mview = new jpsGraphicsView(this); dmanager = new jpsDatamanager(this,mview); - ///Roomwidget + //Roomwidget rwidget=nullptr; - ///Landmarkwidget + //Landmarkwidget lwidget=nullptr; + //WidgetSettings + _settings=nullptr; length_edit = new QLineEdit(); length_edit->setMaximumWidth(55); @@ -63,7 +65,7 @@ MWindow :: MWindow() { infoLabel= new QLabel(); infoLabel->setMinimumWidth(135); - ///filename of saved project + //filename of saved project _filename=""; @@ -75,23 +77,24 @@ MWindow :: MWindow() { statusBar()->addPermanentWidget(length_edit); statusBar()->addPermanentWidget(label2); - ///Timer needed for autosave function - /// timer will trigger autosave every 5th minute + //Timer needed for autosave function + // timer will trigger autosave every 5th minute timer = new QTimer(this); timer->setInterval(300000); timer->start(); - ///Signals and Slots - /// Tab File + //Signals and Slots + // Tab File connect(actionBeenden, SIGNAL(triggered(bool)),qApp,SLOT(quit())); connect(action_ffnen,SIGNAL(triggered(bool)),this,SLOT(openFile())); connect(action_ffnen_xml,SIGNAL(triggered(bool)),this,SLOT(openFileXML())); connect(actionSpeichern,SIGNAL(triggered(bool)),this,SLOT(saveFile())); connect(actionSpeichern_dxf,SIGNAL(triggered(bool)),this,SLOT(saveAsDXF())); - /// Tab Help + connect(actionSettings,SIGNAL(triggered(bool)),this,SLOT(Settings())); + // Tab Help connect(action_ber,SIGNAL(triggered(bool)),this,SLOT(info())); - /// Tab Tools + // Tab Tools connect(actionanglesnap,SIGNAL(triggered(bool)),this,SLOT(anglesnap())); connect(actiongridmode,SIGNAL(triggered(bool)),this,SLOT(gridmode())); connect(actionWall,SIGNAL(triggered(bool)),this,SLOT(en_disableWall())); @@ -105,11 +108,11 @@ MWindow :: MWindow() { connect(actionWall,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())); - /// Tab View + // Tab View connect(actionRotate_90_deg_clockwise,SIGNAL(triggered(bool)),this,SLOT(rotate())); - /// Length edit + // Length edit connect(length_edit,SIGNAL(returnPressed()),this,SLOT(send_length())); - /// mview + // mview connect(mview,SIGNAL(no_drawing()),this,SLOT(en_selectMode())); connect(mview,SIGNAL(remove_marked_lines()),this,SLOT(lines_deleted())); connect(mview,SIGNAL(remove_all()),this,SLOT(remove_all_lines())); @@ -117,14 +120,19 @@ MWindow :: MWindow() { connect(mview,SIGNAL(mouse_moved()),this,SLOT(show_coords())); connect(mview,SIGNAL(landmark_added()),this,SLOT(add_landmark())); //connect(mview,SIGNAL(DoubleClick()),this,SLOT(en_selectMode())); - ///Autosave + // Autosave connect(timer, SIGNAL(timeout()), this, SLOT(AutoSave())); ///Landmarks connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(en_disableLandmark())); connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode())); - ///Landmark specifications + // Landmark specifications connect(actionLandmarkWidget,SIGNAL(triggered(bool)),this,SLOT(define_landmark())); + + + + + } MWindow::~MWindow() @@ -169,6 +177,24 @@ void MWindow::add_landmark() dmanager->new_landmark(landmark); } +void MWindow::Settings() +{ + if (_settings==nullptr) + { + _settings = new WidgetSettings(this,mview); + _settings->setAttribute(Qt::WA_DeleteOnClose); + _settings->setGeometry(QRect(QPoint(5,75), _settings->size())); + _settings->show(); + } + + else + { + _settings->close(); + _settings=nullptr; + } + +} + void MWindow::openFile(){ QString fileName=QFileDialog::getOpenFileName(this,tr("Open DXF"),"",tr("DXF-Drawings (*.dxf)")); @@ -351,26 +377,29 @@ void MWindow::send_length() void MWindow::define_room() { - if (rwidget==0L) + if (rwidget==nullptr) { rwidget = new roomWidget(this,this->dmanager,this->mview); rwidget->setGeometry(QRect(QPoint(5,75), rwidget->size())); + rwidget->setAttribute(Qt::WA_DeleteOnClose); rwidget->show(); + } else { rwidget->close(); - rwidget=0L; + rwidget=nullptr; actionRoom->setChecked(false); } } void MWindow::define_landmark() { - if (lwidget==0L) + if (lwidget==nullptr) { lwidget = new widgetLandmark(this,this->dmanager,this->mview); lwidget->setGeometry(QRect(QPoint(5,75), lwidget->size())); + lwidget->setAttribute(Qt::WA_DeleteOnClose); lwidget->show(); } else diff --git a/src/mainWindow.h b/src/mainWindow.h index 3e0629d..3ae5f04 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -37,6 +37,7 @@ #include "ui_mainwindow.h" #include "roomwidget.h" #include "widgetlandmark.h" +#include "widgetsettings.h" #include "GraphicView.h" #include "datamanager.h" #include "rooms.h" @@ -53,6 +54,7 @@ class MWindow : public QMainWindow, private Ui::MainWindow { private: roomWidget* rwidget; widgetLandmark* lwidget; + WidgetSettings* _settings; jpsDatamanager* dmanager; jpsGraphicsView* mview; //QVBoxLayout* VBox; @@ -91,6 +93,7 @@ protected slots: void rotate(); void AutoSave(); void add_landmark(); + void Settings(); }; diff --git a/src/widgetsettings.cpp b/src/widgetsettings.cpp new file mode 100644 index 0000000..7c556e9 --- /dev/null +++ b/src/widgetsettings.cpp @@ -0,0 +1,31 @@ +#include "widgetsettings.h" +#include "ui_widgetsettings.h" + +WidgetSettings::WidgetSettings(QWidget *parent, jpsGraphicsView *view) : + QTabWidget(parent), + ui(new Ui::WidgetSettings) +{ + ui->setupUi(this); + _view=view; + connect(ui->pushButtoncloseSettings,SIGNAL(clicked(bool)),QTabWidget::parent(),SLOT(Settings())); + connect(ui->en_lineGrid,SIGNAL(toggled(bool)),this,SLOT(changeGridRadio(bool))); + connect(ui->en_pointGrid,SIGNAL(toggled(bool)),this,SLOT(changeGridRadio(bool))); + +} + +WidgetSettings::~WidgetSettings() +{ + delete ui; +} + +void WidgetSettings::changeGridRadio(bool status) +{ + if (status) + { + if (ui->en_lineGrid->isChecked()) + _view->ActivateLineGrid(); + + else + _view->ActivatePointGrid(); + } +} diff --git a/src/widgetsettings.h b/src/widgetsettings.h new file mode 100644 index 0000000..604d8cf --- /dev/null +++ b/src/widgetsettings.h @@ -0,0 +1,29 @@ +#ifndef WIDGETSETTINGS_H +#define WIDGETSETTINGS_H + +#include +#include "GraphicView.h" + +namespace Ui { +class WidgetSettings; +} + +class WidgetSettings : public QTabWidget +{ + Q_OBJECT + +public: + explicit WidgetSettings(QWidget *parent = nullptr, jpsGraphicsView* view = nullptr); + ~WidgetSettings(); + +public slots: + void changeGridRadio(bool status); + +private: + Ui::WidgetSettings *ui; + jpsGraphicsView* _view; + + +}; + +#endif // WIDGETSETTINGS_H From d55eba1075c4d83653b8e9ac7e40a369da03f852 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 4 Aug 2015 15:16:53 +0200 Subject: [PATCH 14/53] debugging --- src/GraphicView.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 707ef19..0f1442e 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -532,20 +532,41 @@ void jpsGraphicsView::use_gridmode() if ((std::fmod(std::fabs(translated_pos.x()),_gridSize)<=_gridSize*0.1 || std::fmod(std::fabs(translated_pos.x()),_gridSize)>=_gridSize*0.9) && (std::fmod(std::fabs(translated_pos.y()),_gridSize)<=_gridSize*0.1 || std::fmod(std::fabs(translated_pos.y()),_gridSize)>=_gridSize*0.9)) { - if (std::fmod(std::fabs(translated_pos.x()),_gridSize)<=_gridSize*0.1) + bool posx_positiv=true; + bool posy_positiv=true; + if (translated_pos.x()<0) + { + translated_pos.setX(std::fabs(translated_pos.x())); + posx_positiv=false; + } + + if (translated_pos.y()<0) + { + translated_pos.setY(std::fabs(translated_pos.y())); + posy_positiv=false; + } + + if (std::fmod(translated_pos.x(),_gridSize)<=_gridSize*0.1) translated_pos.setX(translated_pos.x()-std::fmod(translated_pos.x(),_gridSize)); else translated_pos.setX(translated_pos.x()+(_gridSize-std::fmod(translated_pos.x(),_gridSize))); - if (std::fmod(std::fabs(translated_pos.y()),_gridSize)<=_gridSize*0.1) + if (std::fmod(translated_pos.y(),_gridSize)<=_gridSize*0.1) translated_pos.setY(translated_pos.y()-std::fmod(translated_pos.y(),_gridSize)); else translated_pos.setY(translated_pos.y()+(_gridSize-std::fmod(translated_pos.y(),_gridSize))); + if (!posx_positiv) + translated_pos.setX(translated_pos.x()*(-1)); + + if (!posy_positiv) + translated_pos.setY(translated_pos.y()*(-1)); current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); point_tracked=true; _currentTrackedPoint= &translated_pos; + + } else point_tracked=false; From dea7d97e9be23b15c0add1a6140a0f2ab178194c Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 5 Aug 2015 10:10:27 +0200 Subject: [PATCH 15/53] add include cmath in graphicscene --- src/graphicscene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index 941c685..4bf1630 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -1,5 +1,6 @@ #include "graphicscene.h" #include +#include GraphicScene::GraphicScene(QObject *parent) : QGraphicsScene(parent) From ee1dbddbfb6f70b4c1d82d27e64919a0283160c3 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 28 Aug 2015 13:46:18 +0200 Subject: [PATCH 16/53] stuff for visualisation of cognitive map --- forms/mainwindow.ui | 68 ++++++++++---- jpseditor.pro | 6 +- src/GraphicView.cpp | 66 +++++++++++-- src/GraphicView.h | 38 ++++---- src/datamanager.cpp | 205 +++++++++++++++++++++++++++++++++++++++++ src/datamanager.h | 43 ++++++--- src/jpslandmark.h | 6 +- src/jpswaypoint.cpp | 149 ++++++++++++++++++++++++++++-- src/jpswaypoint.h | 52 +++++++++-- src/jpsyahpointer.cpp | 77 ++++++++++++++++ src/jpsyahpointer.h | 39 ++++++++ src/mainWindow.cpp | 67 ++++++++++++-- src/mainWindow.h | 33 ++++++- src/widgetlandmark.cpp | 5 +- src/widgetlandmark.h | 1 + 15 files changed, 766 insertions(+), 89 deletions(-) create mode 100644 src/jpsyahpointer.cpp create mode 100644 src/jpsyahpointer.h diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 41cc955..a73684a 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -14,7 +14,7 @@ JuPedSim - + :/jupedsim.png:/jupedsim.png @@ -36,6 +36,7 @@ + @@ -69,10 +70,18 @@ + + + Cognitive Map + + + + + @@ -102,12 +111,12 @@ - + - + :/open.png:/open.png @@ -122,7 +131,7 @@ - + :/filesave.png:/filesave.png @@ -137,7 +146,7 @@ - + :/man-gimp1.png:/man-gimp1.png @@ -169,7 +178,7 @@ true - + :/Grid.png:/Grid.png @@ -190,7 +199,7 @@ true - + :/Wall.png:/Wall.png @@ -211,7 +220,7 @@ true - + :/snap.png:/snap.png @@ -226,7 +235,7 @@ - + :/DeleteAll.png:/DeleteAll.png @@ -241,7 +250,7 @@ true - + :/Delete.png:/Delete.png @@ -262,7 +271,7 @@ true - + :/Door.png:/Door.png @@ -286,7 +295,7 @@ true - + :/Exit.png:/Exit.png @@ -310,7 +319,7 @@ true - + :/Room.png:/Room.png @@ -337,7 +346,7 @@ true - + :/basicCursor.png:/basicCursor.png @@ -355,7 +364,7 @@ - + :/filesave.png:/filesave.png @@ -370,7 +379,7 @@ - + :/open.png:/open.png @@ -399,7 +408,7 @@ true - + :/statue.jpg:/statue.jpg @@ -417,7 +426,7 @@ true - + :/statue_specs.jpg:/statue_specs.jpg @@ -435,7 +444,7 @@ true - + :/anglesnap.PNG:/anglesnap.PNG @@ -462,7 +471,26 @@ Ctrl+E + + + + :/open.png:/open.png + + + Load CognitiveMap + + + Load CognitiveMap + + + + + Run visualisation + + - + + + diff --git a/jpseditor.pro b/jpseditor.pro index d5095fc..ae202ad 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -55,7 +55,8 @@ HEADERS += \ src/jpswaypoint.h \ src/widgetlandmark.h \ src/graphicscene.h \ - src/widgetsettings.h + src/widgetsettings.h \ + src/jpsyahpointer.h SOURCES += \ @@ -75,7 +76,8 @@ SOURCES += \ src/jpswaypoint.cpp \ src/widgetlandmark.cpp \ src/graphicscene.cpp \ - src/widgetsettings.cpp + src/widgetsettings.cpp \ + src/jpsyahpointer.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0f1442e..0de9147 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -76,8 +76,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) lines_collided=false; _assoDef=false; - //gl_min_x=1e6; - //gl_min_y=1e6; + //m_graphView->setFixedSize(1600, 900); //m_graphView->setScene(m_graphScen); @@ -334,24 +333,62 @@ void jpsGraphicsView::ShowWaypoints(QList waypoints) { QGraphicsEllipseItem* ellipse = Scene->addEllipse(waypoint->GetRect(),QPen(Qt::blue,0)); ellipse->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); + QString string = waypoint->GetCaption()+ "\n" + waypoint->GetText(); + QGraphicsTextItem* text = Scene->addText(string); + text->setPos(waypoint->GetPos().x()+translation_x,waypoint->GetPos().y()+translation_y); + //text->setScale(gl_scale_f); + text->setData(0,gl_scale_f); + text->setTransform(QTransform::fromScale(gl_scale_f,-gl_scale_f),true); _waypoints.push_back(ellipse); + _waypointLabels.push_back(text); + } + + +} + +void jpsGraphicsView::ShowYAHPointer(const QPointF &pos, const qreal &dir) +{ + for (QGraphicsLineItem* lineItem:_yahPointer) + { + delete lineItem; + } + _yahPointer.clear(); + + _yahPointer.push_back(Scene->addLine(pos.x(),pos.y(),pos.x()+0.5*std::cos(dir),pos.y()+0.5*std::sin(dir),QPen(Qt::blue,0))); + _yahPointer.push_back(Scene->addLine(pos.x()+0.5*std::cos(dir),pos.y()+0.5*std::sin(dir),pos.x()+0.2*std::cos(dir+M_PI/4.0),pos.y()+0.2*std::sin(dir+M_PI/4.0),QPen(Qt::blue,0))); + _yahPointer.push_back(Scene->addLine(pos.x()+0.5*std::cos(dir),pos.y()+0.5*std::sin(dir),pos.x()+0.2*std::cos(dir-M_PI/4.0),pos.y()+0.2*std::sin(dir-M_PI/4.0),QPen(Qt::blue,0))); + + for (QGraphicsLineItem* lineItem:_yahPointer) + { + lineItem->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); } } +void jpsGraphicsView::ClearWaypointLabels() +{ + for (QGraphicsTextItem* label:_waypointLabels) + { + delete label; + } + _waypointLabels.clear(); +} + void jpsGraphicsView::ClearWaypoints() { - ///Waypoints + //Waypoints for (QGraphicsEllipseItem* old_waypoint:_waypoints) { delete old_waypoint; } _waypoints.clear(); + ClearWaypointLabels(); + } void jpsGraphicsView::ActivateLineGrid() @@ -381,7 +418,7 @@ void jpsGraphicsView::mouseReleaseEvent(QMouseEvent *event) if (event->button() == Qt::LeftButton) { - /// Select lines that are located within the rectangle + // Select lines that are located within the rectangle if (!(statWall==true || statDoor==true || statExit==true || statLandmark==true)) { leftbutton_hold=false; @@ -390,17 +427,17 @@ void jpsGraphicsView::mouseReleaseEvent(QMouseEvent *event) { if (_assoDef) { - ///Waypoint definition + //Waypoint definition emit AssoDefCompleted(); } else { - /// Select lines by creating a rect with the cursor + // Select lines by creating a rect with the cursor catch_lines(); - /// unmark Landmark is possible + // unmark Landmark is possible unmarkLandmark(); - /// Look for landmarks with position in the currentSelectRect + // Look for landmarks with position in the currentSelectRect catch_landmark(); } delete currentSelectRect; @@ -408,7 +445,7 @@ void jpsGraphicsView::mouseReleaseEvent(QMouseEvent *event) } - ///unmark selected line(s) + //unmark selected line(s) if (line_tracked==-1) { unmark_all_lines(); @@ -1103,6 +1140,17 @@ void jpsGraphicsView::translations(QPointF old_pos) { ellipse->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); } + for (QGraphicsLineItem* lineItem:_yahPointer) + { + lineItem->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); + } + for (QGraphicsTextItem* item:_waypointLabels) + { + qreal scalef = item->data(0).toReal(); + item->setTransform(QTransform::fromScale(1.0/scalef,1.0/scalef),true); // without this line translations won't work + item->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),-pos.y()+old_pos.y()), true); + item->setTransform(QTransform::fromScale(scalef,scalef),true); + } } diff --git a/src/GraphicView.h b/src/GraphicView.h index a704b1f..441748a 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -42,13 +42,13 @@ class jpsGraphicsView: public QGraphicsView { Q_OBJECT public: - ///Constructor + //Constructor jpsGraphicsView(QWidget* parent = nullptr); - ///Destructor + //Destructor ~jpsGraphicsView(); - ///Change modes + //Change modes void change_stat_anglesnap(); bool get_stat_anglesnap(); void change_objectsnap(); @@ -63,37 +63,37 @@ class jpsGraphicsView: public QGraphicsView { bool statusLandmark(); void en_disableLandmark(); - /// global functions + // global functions qreal get_scale_f(); void take_l_from_lineEdit(const qreal &length); void disable_drawing(); bool use_anglesnap(QGraphicsLineItem *currentline, int accuracy); void use_gridmode(); - ///View + //View void zoom(int delta); void translations(QPointF old_pos); void AutoZoom(); qreal CalcGridSize(); - ///Pos + //Pos QPointF return_Pos(); - ///Catch lines, points and intersections + //Catch lines, points and intersections void catch_points(); void locate_intersection(jpsLineItem* item1, jpsLineItem* item2); void line_collision(); void catch_lines(); - ///Delete all + //Delete all void delete_all(bool final=false); - ///Line operations + //Line operations void drawLine(); qreal calc_d_point(const QLineF &line, const qreal &x, const qreal &y); void delete_marked_lines(); void RemoveIntersections(jpsLineItem* lineItem); - /// lines read from dxf-file + // lines read from dxf-file jpsLineItem *addLineItem(const qreal &x1, const qreal &y1, const qreal &x2, const qreal &y2, const QString &type=""); QList get_markedLines(); QList get_line_vector(); @@ -102,7 +102,7 @@ class jpsGraphicsView: public QGraphicsView { void SetVLine(); void EditLine(QPointF* point); - /// Landmark + // Landmark void delete_landmark(); void catch_landmark(); void select_landmark(jpsLandmark *landmark); @@ -110,11 +110,13 @@ class jpsGraphicsView: public QGraphicsView { void unmarkLandmark(); QList get_landmarks(); - ///Waypoints + //Waypoints and YAHPointer QGraphicsRectItem* GetCurrentSelectRect(); void ShowWaypoints(QList waypoints); + void ShowYAHPointer(const QPointF& pos, const qreal& dir); + void ClearWaypointLabels(); - ///RoomCaption + //RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); @@ -129,7 +131,7 @@ public slots: protected: - ///Mouse events + //Mouse events virtual void mouseMoveEvent(QMouseEvent * mouseEvent); //void paintEvent(QPaintEvent* event); virtual void mousePressEvent(QMouseEvent *event); @@ -173,10 +175,15 @@ public slots: QList marked_lines; QGraphicsTextItem* current_caption; QList caption_list; + + //Landmark and waypoints QList LLandmarks; jpsLandmark* markedLandmark; QGraphicsRectItem* currentLandmarkRect; QList _waypoints; + QList _yahPointer; + QList _waypointLabels; + QGraphicsLineItem* _currentVLine; QPointF* _currentTrackedPoint; QGraphicsPixmapItem* gridmap; @@ -185,9 +192,6 @@ public slots: bool _assoDef; bool _gridmode; - //qreal gl_min_x; - //qreal gl_min_y; - signals: void mouse_moved(); void set_focus_textedit(); diff --git a/src/datamanager.cpp b/src/datamanager.cpp index a0850ed..1a970c3 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -38,6 +38,8 @@ jpsDatamanager::jpsDatamanager(QWidget *parent, jpsGraphicsView *view) mView=view; room_id_counter=0; obs_id_counter=0; + _yahPointer=nullptr; + _frameRate=0; } @@ -1441,6 +1443,209 @@ QString jpsDatamanager::check_printAbility() return ""; } +bool jpsDatamanager::ParseCogMap(QFile &file) +{ + QXmlStreamReader xmlReader(&file); + + while(!xmlReader.atEnd() && !xmlReader.hasError()) + { + /* Read next element.*/ + QXmlStreamReader::TokenType token = xmlReader.readNext(); + /* If token is just StartDocument, we'll go to next.*/ + if(token == QXmlStreamReader::StartDocument) + { + continue; + } + + /* If token is StartElement, we'll see if we can read it.*/ + if(token == QXmlStreamReader::StartElement) + { + /* If it's named rooms, we'll go to the next.*/ + if(xmlReader.name() == "cognitiveMap") + { + continue; + } + if(xmlReader.name() == "header") + { + continue; + } + if(xmlReader.name() == "frameRate") + { + _frameRate=xmlReader.readElementText().toFloat(); + } + if(xmlReader.name() == "frame") + { + ParseFrames(xmlReader); + } + } + } + /* Error handling. */ + if(xmlReader.hasError()) + { + QMessageBox::critical(mView, + "QXSRExample::parseXML", + xmlReader.errorString(), + QMessageBox::Ok); + return false; + } + /* Removes any device() or data from the reader + * and resets its internal state to the initial state. */ + + + xmlReader.clear(); + return true; +} + +void jpsDatamanager::ParseFrames(QXmlStreamReader &xmlReader) +{ + int frameID= xmlReader.attributes().value("ID").toInt(); + + while(!(xmlReader.tokenType() == QXmlStreamReader::EndElement && + xmlReader.name() == "frame")) + { + if (xmlReader.tokenType()==QXmlStreamReader::StartElement && + xmlReader.name() == "YAHPointer") + { + ParseYAHPointer(xmlReader, frameID); + } + else if (xmlReader.tokenType()==QXmlStreamReader::StartElement && + xmlReader.name() == "landmark") + { + ParseLandmarksInCMap(xmlReader, frameID); + } + else if (xmlReader.tokenType()==QXmlStreamReader::StartElement && + xmlReader.name() == "waypoint") + { + ParseWaypointInCMap(xmlReader, frameID); + } + xmlReader.readNext(); + } + + _lastCMapFrame=frameID; +} + +void jpsDatamanager::ParseYAHPointer(QXmlStreamReader &xmlReader, const int& frame) +{ + qreal x = xmlReader.attributes().value("x").toFloat(); + qreal y = xmlReader.attributes().value("y").toFloat(); + qreal angle = xmlReader.attributes().value("dir").toFloat(); + if (_yahPointer==nullptr) + { + _yahPointer = new jpsYAHPointer(x,y,angle); + _yahPointer->SetFirstFrame(frame); + _yahPointer->SetLastFrame(frame); + } + else + { + _yahPointer->SetPos(QPointF(x,y)); + _yahPointer->SetDirection(angle); + _yahPointer->SetLastFrame(frame); + } + +} + +void jpsDatamanager::ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int& frame) +{ + + bool wayPInList=false; + + int id = xmlReader.attributes().value("ID").toInt(); + qreal x = xmlReader.attributes().value("x").toFloat(); + qreal y = xmlReader.attributes().value("y").toFloat(); + qreal rA = xmlReader.attributes().value("rA").toFloat(); + qreal rB = xmlReader.attributes().value("rB").toFloat(); + + for (jpsWaypoint* waypoint:_waypointsInCMap) + { + if (waypoint->GetId()==id && waypoint->GetCaption()=="Landmark") + { + wayPInList = true; + waypoint->SetLastFrame(frame); + } + } + + if (!wayPInList) + { + _waypointsInCMap.push_back(new jpsWaypoint(QPointF(x,y),rA,rB,id,"Landmark")); + _waypointsInCMap.back()->SetFirstFrame(frame); + _waypointsInCMap.back()->SetLastFrame(frame); + } +} + +void jpsDatamanager::ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int& frame) +{ + bool wayPInList=false; + + int id = xmlReader.attributes().value("ID").toInt(); + qreal x = xmlReader.attributes().value("x").toFloat(); + qreal y = xmlReader.attributes().value("y").toFloat(); + qreal rA = xmlReader.attributes().value("rA").toFloat(); + qreal rB = xmlReader.attributes().value("rB").toFloat(); + bool current = xmlReader.attributes().value("current").toInt(); + + for (jpsWaypoint* waypoint:_waypointsInCMap) + { + if (waypoint->GetId()==id && waypoint->GetCaption()=="Waypoint") + { + wayPInList = true; + waypoint->SetLastFrame(frame); + + if (current!=waypoint->IsCurrent()) + { + waypoint->ChangeCurrentness(frame); + + } + + } + } + + + if (!wayPInList) + { + _waypointsInCMap.push_back(new jpsWaypoint(QPointF(x,y),rA,rB,id,"Waypoint")); + _waypointsInCMap.back()->SetFirstFrame(frame); + _waypointsInCMap.back()->SetLastFrame(frame); + _waypointsInCMap.back()->SetCurrentness(current,frame); + + } +} + +void jpsDatamanager::ShowCMapFrame(const int& frame) const +{ + mView->ShowYAHPointer(_yahPointer->GetPosWhenFrame(frame),_yahPointer->GetDirWhenFrame(frame)); + + QList wayPCandidates; + + for (jpsWaypoint* waypoint:_waypointsInCMap) + { + if (waypoint->OccursInFrame(frame)) + { + wayPCandidates.push_back(waypoint); + + if (waypoint->IsCurrentInFrame(frame)) + waypoint->SetText("Next target"); + else if (waypoint->Visited(frame)) + waypoint->SetText("Already visited"); + else + waypoint->SetText(""); + + } + } + mView->ShowWaypoints(wayPCandidates); + +} + + +const double &jpsDatamanager::GetCMapFrameRate() const +{ + return _frameRate; +} + +const int &jpsDatamanager::GetLastCMapFrame() const +{ + return _lastCMapFrame; +} + diff --git a/src/datamanager.h b/src/datamanager.h index d5e77e0..a82f8b9 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -40,6 +40,7 @@ #include "jpsexit.h" #include "jpsobstacle.h" #include "GraphicView.h" +#include "jpsyahpointer.h" #include "../dxflib/src/dl_creationadapter.h" @@ -51,51 +52,51 @@ class jpsDatamanager: public DL_CreationAdapter public: jpsDatamanager(QWidget* parent=0L, jpsGraphicsView* view=0L); ~jpsDatamanager(); - ///Room + //Room QList get_roomlist(); void new_room(); void remove_room(jpsRoom* room); void change_roomName(jpsRoom* room, QString name); void remove_all_rooms(); - ///Obstacle + //Obstacle QList get_obstaclelist(); void new_obstacle(); void remove_obstacle(jpsObstacle* obs); void change_obstacleName(jpsObstacle* obs, QString name); void remove_all_obstacles(); - ///Crossing + //Crossing QList get_crossingList(); void new_crossing(QList newCrossing); void new_crossing(jpsLineItem* newCrossing); void remove_crossing(jpsCrossing* crossing); void change_crossingName(jpsCrossing* crossing, QString name); void remove_all_crossings(); - ///Exit + //Exit QList get_exitList(); void new_exit(QList newExits); void new_exit(jpsLineItem* newExit); void remove_exit(jpsExit* exit); void change_exitName(jpsExit* exit, QString name); void remove_all_exits(); - ///Landmark + //Landmark QList get_landmarks(); void new_landmark(jpsLandmark * newlandmark); void remove_landmark(jpsLandmark* landmark); void change_LandmarkName(jpsLandmark* landmark, QString name); void remove_all_landmarks(); - /// + // void remove_all(); void remove_marked_lines(); void set_view(jpsGraphicsView* view); jpsGraphicsView* get_view(); - /// Auto Assign + // Auto Assign void AutoAssignCrossings(); void AutoAssignExits(); - /// Read XML + // Read XML bool readXML(QFile &file); void parseSubRoom(QXmlStreamReader &xmlReader); void parseWalls(QXmlStreamReader &xmlReader,jpsRoom* room); @@ -104,7 +105,7 @@ class jpsDatamanager: public DL_CreationAdapter void parseTransitions(QXmlStreamReader &xmlReader); void parseObstacles(QXmlStreamReader &xmlReader, jpsRoom *room); - /// Write XML + // Write XML void writeXML(QFile &file); void AutoSaveXML(QFile &file); void writeHeader(QXmlStreamWriter *stream); @@ -118,10 +119,10 @@ class jpsDatamanager: public DL_CreationAdapter void writeNotAssignedExits(QXmlStreamWriter *stream, QList& lines); void writeLandmarks(QXmlStreamWriter *stream, QList &landmarks); - /// Read DXF + // Read DXF bool readDXF(std::string filename); virtual void addLine(const DL_LineData& d); - /// write DXF + // write DXF void writeDXF(std::string filename); void writeDXFHeader(DL_Dxf* dxf, DL_WriterA *dw); void writeDXFTables(DL_Dxf* dxf, DL_WriterA *dw); @@ -131,7 +132,20 @@ class jpsDatamanager: public DL_CreationAdapter QString check_printAbility(); + //Parse Cognitive Map + bool ParseCogMap(QFile &file); + void ParseFrames(QXmlStreamReader &xmlReader); + void ParseYAHPointer(QXmlStreamReader &xmlReader, const int &frame); + void ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int &frame); + void ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int &frame); + + //Show Cognitive Map + void ShowCMapFrame(const int& frame) const; + const double& GetCMapFrameRate() const; + const int& GetLastCMapFrame() const; + private: + //Geometry QList roomlist; QList obstaclelist; QList crossingList; @@ -142,7 +156,12 @@ class jpsDatamanager: public DL_CreationAdapter QWidget* parent_widget; jpsGraphicsView* mView; - + //CognitiveMap + QList _landmarksInCMap; + QList _waypointsInCMap; + jpsYAHPointer* _yahPointer; + double _frameRate; + int _lastCMapFrame; }; diff --git a/src/jpslandmark.h b/src/jpslandmark.h index 9b3306f..3cff6d3 100644 --- a/src/jpslandmark.h +++ b/src/jpslandmark.h @@ -39,19 +39,19 @@ class jpsLandmark jpsLandmark(); jpsLandmark(QGraphicsPixmapItem* pixmap, QString name, QPointF point); ~jpsLandmark(); - ///Setter + //Setter void set_pixmap(QGraphicsPixmapItem* pixmap); void set_name(QString name); void set_pos(QPointF pos); void set_room(jpsRoom* room); void set_visibility(int visibility); - ///Getter + //Getter QGraphicsPixmapItem* get_pixmap(); QString get_name(); const QPointF& get_pos(); jpsRoom *get_room(); int get_visibility(); - ///Waypoint handling + //Waypoint handling void AddWaypoint(jpsWaypoint* waypoint); void RemoveWaypoint(jpsWaypoint* waypoint); QList GetWaypoints(); diff --git a/src/jpswaypoint.cpp b/src/jpswaypoint.cpp index f9778cd..aa8fa49 100644 --- a/src/jpswaypoint.cpp +++ b/src/jpswaypoint.cpp @@ -28,27 +28,55 @@ #include "jpswaypoint.h" #include +#include jpsWaypoint::jpsWaypoint() { } -jpsWaypoint::jpsWaypoint(QRectF rect) +jpsWaypoint::jpsWaypoint(const QPointF &point, const qreal &rA, const qreal &rB, const int &id, const QString &caption) +{ + _pos=point; + _a=rA; + _b=rB; + _id=id; + _caption=caption; + _rect=QRectF(point.x()-rA,point.y()-rB,rA*2,rB*2); + _currentness=false; + _FFcurrentness=-1; + _LFcurrentness=-1; + _lastFrame=-1; + _firstFrame=-1; +} + +jpsWaypoint::jpsWaypoint(QRectF rect, const int &id) { _rect=rect; _pos=_rect.center(); _a=std::abs(_rect.width()/2.0); _b=std::abs(_rect.height()/2.0); _ellipseItem=nullptr; + _id=id; + _currentness=false; + _FFcurrentness=-1; + _LFcurrentness=-1; + _lastFrame=-1; + _firstFrame=-1; } -jpsWaypoint::jpsWaypoint(QGraphicsEllipseItem* ellipseItem) +jpsWaypoint::jpsWaypoint(QGraphicsEllipseItem* ellipseItem, const int &id) { _ellipseItem=ellipseItem; _rect=_ellipseItem->rect(); _pos=_rect.center(); _a=_rect.width(); _b=_rect.height(); + _id=id; + _currentness=false; + _FFcurrentness=-1; + _LFcurrentness=-1; + _lastFrame=-1; + _firstFrame=-1; } jpsWaypoint::~jpsWaypoint() @@ -56,32 +84,42 @@ jpsWaypoint::~jpsWaypoint() } -const QPointF &jpsWaypoint::GetPos() +const QPointF &jpsWaypoint::GetPos() const { return _pos; } -const QRectF &jpsWaypoint::GetRect() +const QRectF &jpsWaypoint::GetRect() const { return _rect; } -double jpsWaypoint::GetA() +const double& jpsWaypoint::GetA() const { return _a; } -double jpsWaypoint::GetB() +const double& jpsWaypoint::GetB() const { return _b; } +const int &jpsWaypoint::GetId() const +{ + return _id; +} + QGraphicsEllipseItem *jpsWaypoint::GetEllipseItem() { return _ellipseItem; } +const QString &jpsWaypoint::GetCaption() const +{ + return _caption; +} + void jpsWaypoint::SetPos(QPointF point) { @@ -102,6 +140,105 @@ void jpsWaypoint::SetEllipseItem(QGraphicsEllipseItem *ellipseItem) _ellipseItem=ellipseItem; } +void jpsWaypoint::SetId(const int &id) +{ + _id=id; +} + +void jpsWaypoint::SetCaption(const QString &string) +{ + _caption=string; +} + +const int &jpsWaypoint::GetFirstFrame() const +{ + return _firstFrame; +} + +const int &jpsWaypoint::GetLastFrame() const +{ + return _lastFrame; +} + +void jpsWaypoint::SetFirstFrame(const int &frame) +{ + _firstFrame=frame; +} + +void jpsWaypoint::SetLastFrame(const int &frame) +{ + _lastFrame=frame; +} + +bool jpsWaypoint::OccursInFrame(const int &frame) const +{ + if (frame>=_firstFrame && frame<=_lastFrame) + { + return true; + } + return false; +} + +bool jpsWaypoint::IsCurrent() const +{ + return _currentness; +} + +bool jpsWaypoint::IsCurrentInFrame(const int &frameID) +{ + if (_FFcurrentness<= frameID && _LFcurrentness>=frameID) + return true; + else + return false; +} + +void jpsWaypoint::SetCurrentness(bool stat, const int& frameID) +{ + _currentness=stat; + if (stat) + _FFcurrentness=frameID; +} + +const int &jpsWaypoint::GetFirstFrameCurrent() const +{ + return _FFcurrentness; +} + +const int &jpsWaypoint::GetLastFrameCurrent() const +{ + return _LFcurrentness; +} + +void jpsWaypoint::ChangeCurrentness(const int& frameID) +{ + _currentness=!_currentness; + if (_currentness) + _FFcurrentness=frameID; + else + _LFcurrentness=frameID; +} + +const QString &jpsWaypoint::GetText() +{ + return _text; +} + +void jpsWaypoint::SetText(const QString &text) +{ + _text=text; +} + +bool jpsWaypoint::Visited(const int &frameID) const +{ + if (frameID > _LFcurrentness && _lastFrame!=-1) + return true; + + else + return false; +} + + + diff --git a/src/jpswaypoint.h b/src/jpswaypoint.h index fda1f7d..bce2d2f 100644 --- a/src/jpswaypoint.h +++ b/src/jpswaypoint.h @@ -35,20 +35,44 @@ class jpsWaypoint { public: jpsWaypoint(); - jpsWaypoint(QRectF rect); - jpsWaypoint(QGraphicsEllipseItem* ellipseItem); + jpsWaypoint(const QPointF& point,const qreal& rA, const qreal& rB, const int& id=0, const QString& caption="Waypoint"); + jpsWaypoint(QRectF rect, const int& id=0); + jpsWaypoint(QGraphicsEllipseItem* ellipseItem, const int& id=0); ~jpsWaypoint(); - ///Getter - const QPointF& GetPos(); - const QRectF &GetRect(); - double GetA(); - double GetB(); + //Getter + const QPointF& GetPos() const; + const QRectF &GetRect() const; + const double& GetA() const; + const double& GetB() const; + const int& GetId() const; QGraphicsEllipseItem* GetEllipseItem(); + const QString& GetCaption() const; - ///Setter + //Setter void SetPos(QPointF point); void SetRect(QRect rect); void SetEllipseItem(QGraphicsEllipseItem* ellipseItem); + void SetId(const int& id); + void SetCaption(const QString& string); + + //Occurence + const int& GetFirstFrame() const; + const int& GetLastFrame() const; + void SetFirstFrame(const int& frame); + void SetLastFrame(const int& frame); + bool OccursInFrame(const int& frame) const; + + //Currency + bool IsCurrent() const; + bool IsCurrentInFrame(const int& frameID); + void SetCurrentness(bool stat, const int &frameID=1); + const int& GetFirstFrameCurrent() const; + const int& GetLastFrameCurrent() const; + void ChangeCurrentness(const int& frameID); + const QString& GetText(); + void SetText(const QString& text); + + bool Visited(const int& frameID) const; private: @@ -57,6 +81,18 @@ class jpsWaypoint QRectF _rect; double _a; double _b; + int _id; + QString _caption; + + //Occurence + int _firstFrame; + int _lastFrame; + + //Currentness + int _FFcurrentness; + int _LFcurrentness; + bool _currentness; + QString _text; }; diff --git a/src/jpsyahpointer.cpp b/src/jpsyahpointer.cpp new file mode 100644 index 0000000..4c0b90f --- /dev/null +++ b/src/jpsyahpointer.cpp @@ -0,0 +1,77 @@ +#include "jpsyahpointer.h" + +jpsYAHPointer::jpsYAHPointer(const QPointF &point, const qreal &angle) +{ + _cPos=point; + _cDirection=angle; + _allPos.push_back(point); + _allDir.push_back(angle); +} + +jpsYAHPointer::jpsYAHPointer(const qreal &x, const qreal &y, const qreal &angle) +{ + _cPos.setX(x); + _cPos.setY(y); + _cDirection=angle; + _allPos.push_back(_cPos); + _allDir.push_back(angle); +} + +jpsYAHPointer::~jpsYAHPointer() +{ + +} + +const QPointF &jpsYAHPointer::GetPos() const +{ + return _cPos; +} + +const qreal &jpsYAHPointer::GetDirection() const +{ + return _cDirection; +} + +void jpsYAHPointer::SetPos(const QPointF &point) +{ + _cPos=point; + _allPos.push_back(point); +} + +void jpsYAHPointer::SetDirection(const qreal &angle) +{ + _cDirection=angle; + _allDir.push_back(angle); +} + + +const int &jpsYAHPointer::GetFirstFrame() const +{ + return _firstFrame; +} + +const int &jpsYAHPointer::GetLastFrame() const +{ + return _lastFrame; +} + +void jpsYAHPointer::SetFirstFrame(const int &frame) +{ + _firstFrame=frame; +} + +void jpsYAHPointer::SetLastFrame(const int &frame) +{ + _lastFrame=frame; +} + +const QPointF &jpsYAHPointer::GetPosWhenFrame(const int &frame) +{ + return _allPos[frame-1]; +} + +const qreal &jpsYAHPointer::GetDirWhenFrame(const int &frame) +{ + return _allDir[frame-1]; +} + diff --git a/src/jpsyahpointer.h b/src/jpsyahpointer.h new file mode 100644 index 0000000..ad61057 --- /dev/null +++ b/src/jpsyahpointer.h @@ -0,0 +1,39 @@ +#ifndef JPSYAHPOINTER_H +#define JPSYAHPOINTER_H +#include + +class jpsYAHPointer +{ +public: + jpsYAHPointer(const QPointF& point, const qreal& angle=0.0); + jpsYAHPointer(const qreal& x, const qreal& y, const qreal& angle=0.0); + ~jpsYAHPointer(); + + const QPointF& GetPos() const; + const qreal& GetDirection() const; + + void SetPos(const QPointF& point); + void SetDirection(const qreal& angle); + + //Occurence + const int& GetFirstFrame() const; + const int& GetLastFrame() const; + void SetFirstFrame(const int& frame); + void SetLastFrame(const int& frame); + + // + const QPointF& GetPosWhenFrame(const int& frame); + const qreal& GetDirWhenFrame(const int& frame); + +private: + QPointF _cPos; + qreal _cDirection; + std::vector _allPos; + std::vector _allDir; + + //Occurence + int _firstFrame; + int _lastFrame; +}; + +#endif // JPSYAHPOINTER_H diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index eb2a5c4..bc7e99e 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -83,6 +83,8 @@ MWindow :: MWindow() { timer->setInterval(300000); timer->start(); + _cMapTimer = new QTimer(this); + //_cMapTimer=nullptr; //Signals and Slots // Tab File @@ -92,6 +94,7 @@ MWindow :: MWindow() { connect(actionSpeichern,SIGNAL(triggered(bool)),this,SLOT(saveFile())); connect(actionSpeichern_dxf,SIGNAL(triggered(bool)),this,SLOT(saveAsDXF())); connect(actionSettings,SIGNAL(triggered(bool)),this,SLOT(Settings())); + connect(action_ffnen_CogMap,SIGNAL(triggered(bool)),this,SLOT(openFileCMap())); // Tab Help connect(action_ber,SIGNAL(triggered(bool)),this,SLOT(info())); // Tab Tools @@ -122,16 +125,14 @@ MWindow :: MWindow() { //connect(mview,SIGNAL(DoubleClick()),this,SLOT(en_selectMode())); // Autosave connect(timer, SIGNAL(timeout()), this, SLOT(AutoSave())); - ///Landmarks + //Landmarks connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(en_disableLandmark())); connect(actionLandmark,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode())); // Landmark specifications connect(actionLandmarkWidget,SIGNAL(triggered(bool)),this,SLOT(define_landmark())); - - - - - + //CMap + connect(actionRun_visualisation,SIGNAL(triggered(bool)),this,SLOT(RunCMap())); + connect(_cMapTimer,SIGNAL(timeout()),this,SLOT(UpdateCMap())); } @@ -144,6 +145,7 @@ MWindow::~MWindow() delete label2; delete infoLabel; delete timer; + delete _cMapTimer; } void MWindow::AutoSave() @@ -171,6 +173,32 @@ void MWindow::AutoSave() } } +void MWindow::RunCMap() +{ + + double frameRate = dmanager->GetCMapFrameRate(); + _cMapFrame=1; + if (frameRate==0) + { + statusBar()->showMessage(tr("No cognitive map has been loaded!"),10000); + return; + } + _cMapTimer->setInterval(1/frameRate*1000); + _cMapTimer->start(); +} + +void MWindow::UpdateCMap() +{ + _cMapFrame++; + if (_cMapFrame>dmanager->GetLastCMapFrame()) + { + _cMapTimer->stop(); + dmanager->ShowCMapFrame(1); + return; + } + dmanager->ShowCMapFrame(_cMapFrame); +} + void MWindow::add_landmark() { jpsLandmark* landmark = mview->get_landmarks().last(); @@ -243,6 +271,33 @@ void MWindow::openFileXML() } +void MWindow::openFileCMap() +{ + QString fileName=QFileDialog::getOpenFileName(this,tr("Open XML"),"",tr("XML-Files (*.xml)")); + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QMessageBox::critical(this, + "OpenFileXML", + "Couldn't open xml-file", + QMessageBox::Ok); + return; + } + + + if (!dmanager->ParseCogMap(file)) + { + statusBar()->showMessage("XML-File could not be parsed!",10000); + } + + else + { + + statusBar()->showMessage("Cognitive map successfully loaded!",10000); + dmanager->ShowCMapFrame(1); + } +} + void MWindow::saveFile(){ QString fileName = QFileDialog::getSaveFileName(this,tr("Save XML"),"",tr("XML-Files (*.xml)")); _filename=fileName; diff --git a/src/mainWindow.h b/src/mainWindow.h index 3ae5f04..1215430 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -65,13 +65,24 @@ class MWindow : public QMainWindow, private Ui::MainWindow { QString _filename; QTimer *timer; + //CMap + QTimer *_cMapTimer; + int _cMapFrame; + protected slots: + + //parseFiles void openFile(); void openFileXML(); + void openFileCMap(); void saveFile(); void saveAsDXF(); + + //about void info(); + + //drawing options void anglesnap(); void en_disableWall(); void en_disableDoor(); @@ -79,21 +90,33 @@ protected slots: void en_disableLandmark(); void disableDrawing(); void objectsnap(); - void gridmode(); + + //Line operations void show_coords(); void delete_lines(); void delete_marked_lines(); void send_length(); - void define_room(); - void define_landmark(); void en_selectMode(); void dis_selectMode(); void lines_deleted(); void remove_all_lines(); - void rotate(); - void AutoSave(); + + //Room and landmark def + void define_room(); + void define_landmark(); void add_landmark(); + + //view options + void gridmode(); + void rotate(); void Settings(); + + //autosave + void AutoSave(); + + //CMap + void RunCMap(); + void UpdateCMap(); }; diff --git a/src/widgetlandmark.cpp b/src/widgetlandmark.cpp index 4dcf877..72041ce 100644 --- a/src/widgetlandmark.cpp +++ b/src/widgetlandmark.cpp @@ -40,6 +40,7 @@ widgetLandmark::widgetLandmark(QWidget *parent, jpsDatamanager *dmanager, jpsGra ui->setupUi(this); _dmanager=dmanager; _gview=gview; + _waypointIDCounter=0; show_landmarks(); @@ -162,8 +163,10 @@ void widgetLandmark::AddAssociation() { int cLanRow=ui->list_landmarks->currentIndex(); - _dmanager->get_landmarks()[cLanRow]->AddWaypoint(new jpsWaypoint(_gview->GetCurrentSelectRect()->rect())); + _dmanager->get_landmarks()[cLanRow]->AddWaypoint(new jpsWaypoint(_gview->GetCurrentSelectRect()->rect(),_waypointIDCounter)); + ShowAssociations(); + _waypointIDCounter++; } } diff --git a/src/widgetlandmark.h b/src/widgetlandmark.h index b4f678d..71369c7 100644 --- a/src/widgetlandmark.h +++ b/src/widgetlandmark.h @@ -60,6 +60,7 @@ protected slots: Ui::widgetLandmark *ui; jpsDatamanager* _dmanager; jpsGraphicsView* _gview; + int _waypointIDCounter; }; #endif // WIDGETLANDMARK_H From 9b3fa467068ff696c578bd69a4edd6282cdda196 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 28 Aug 2015 13:49:23 +0200 Subject: [PATCH 17/53] update of CMakeLists.txt --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac4a45..2c899e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ set( SRCS src/jpswaypoint.cpp src/widgetlandmark.cpp src/widgetsettings.cpp + src/jpsyahpointer.cpp dxflib/src/dl_writer_ascii.cpp dxflib/src/dl_dxf.cpp ) @@ -115,6 +116,7 @@ set( HDR src/jpswaypoint.h src/widgetlandmark.h src/widgetsettings.h + src/jpsyahpointer.h dxflib/src/dl_writer_ascii.h dxflib/src/dl_writer.h dxflib/src/dl_global.h From a497c91b36a818c0a79a2aee1871164c40dc057e Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 28 Aug 2015 14:17:16 +0200 Subject: [PATCH 18/53] landmark selection fixed --- src/GraphicView.cpp | 9 +++++---- src/GraphicView.h | 4 +++- src/widgetlandmark.cpp | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0de9147..4c0a9be 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -104,7 +104,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) //create_grid(); - ///Origin + //Origin //origin.push_back(Scene->addLine(1,1,1/gl_scale_f*0.02,1,QPen(Qt::black,0))); //origin.push_back(Scene->addLine(1,1,1,1/gl_scale_f*0.02,QPen(Qt::black,0))); @@ -142,7 +142,7 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) if (_currentVLine!=nullptr) { - /// vline will be deleted if it is not thrown horizontally or vertically + // vline will be deleted if it is not thrown horizontally or vertically if(!use_anglesnap(_currentVLine,15)) { delete _currentVLine; @@ -173,7 +173,7 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) { catch_points(); - ///VLine + //VLine if (point_tracked && (statWall==true || statDoor==true || statExit==true)) { SetVLine(); @@ -195,7 +195,7 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) _currentVLine->setLine(_currentVLine->line().x1(),_currentVLine->line().y1(),translated_pos.x(),translated_pos.y()); } - /// see if two lines collided FIX ME!!! + // see if two lines collided FIX ME!!! //line_collision(); emit mouse_moved(); @@ -429,6 +429,7 @@ void jpsGraphicsView::mouseReleaseEvent(QMouseEvent *event) { //Waypoint definition emit AssoDefCompleted(); + _assoDef=false; } else { diff --git a/src/GraphicView.h b/src/GraphicView.h index 441748a..a147cf7 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -107,7 +107,7 @@ class jpsGraphicsView: public QGraphicsView { void catch_landmark(); void select_landmark(jpsLandmark *landmark); void addLandmark(); - void unmarkLandmark(); + // unmark Landmarks see slots QList get_landmarks(); //Waypoints and YAHPointer @@ -128,6 +128,8 @@ public slots: //GridSettings void ActivateLineGrid(); void ActivatePointGrid(); + //Landmarks + void unmarkLandmark(); protected: diff --git a/src/widgetlandmark.cpp b/src/widgetlandmark.cpp index 72041ce..daf2308 100644 --- a/src/widgetlandmark.cpp +++ b/src/widgetlandmark.cpp @@ -48,6 +48,7 @@ widgetLandmark::widgetLandmark(QWidget *parent, jpsDatamanager *dmanager, jpsGra connect(ui->apply_name_button,SIGNAL(clicked(bool)),this,SLOT(change_name())); connect(ui->closeButton,SIGNAL(clicked(bool)),this->parentWidget(),SLOT(define_landmark())); connect(ui->list_landmarks,SIGNAL(activated(int)),this,SLOT(enable_room_selection())); + connect(ui->list_landmarks,SIGNAL(currentIndexChanged(int)),_gview,SLOT(unmarkLandmark())); connect(ui->roomBox_landmarks,SIGNAL(activated(int)),this,SLOT(add_room_to_landmark())); connect(ui->add_button,SIGNAL(clicked(bool)),_gview,SLOT(StatAssoDef())); connect(_gview,SIGNAL(AssoDefCompleted()),this,SLOT(AddAssociation())); @@ -167,6 +168,7 @@ void widgetLandmark::AddAssociation() ShowAssociations(); _waypointIDCounter++; + ui->add_button->setChecked(false); } } From aa69768945313d825b4212ac99881144a363539d Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 31 Aug 2015 08:41:38 +0200 Subject: [PATCH 19/53] Roomtype definition --- forms/roomwidget.ui | 51 ++++++++++++++++++++++++++++++++++++--------- src/datamanager.cpp | 10 +++++---- src/rooms.cpp | 1 + src/roomwidget.cpp | 47 ++++++++++++++++++++++++++++++++++------- src/roomwidget.h | 6 +++++- 5 files changed, 92 insertions(+), 23 deletions(-) diff --git a/forms/roomwidget.ui b/forms/roomwidget.ui index 6810467..e1225f7 100644 --- a/forms/roomwidget.ui +++ b/forms/roomwidget.ui @@ -7,7 +7,7 @@ 0 0 320 - 678 + 725 @@ -42,7 +42,7 @@ 20 - 510 + 560 291 31 @@ -55,7 +55,7 @@ 10 - 330 + 380 291 171 @@ -65,7 +65,7 @@ 110 - 610 + 660 93 28 @@ -78,7 +78,7 @@ 30 - 550 + 600 112 34 @@ -91,7 +91,7 @@ 170 - 550 + 600 112 34 @@ -117,7 +117,7 @@ 10 - 290 + 340 191 31 @@ -199,7 +199,7 @@ -10 - 270 + 320 341 20 @@ -212,7 +212,7 @@ 10 - 240 + 280 121 28 @@ -225,7 +225,7 @@ 202 - 240 + 280 101 28 @@ -234,6 +234,37 @@ Highlight Room + + + true + + + + 100 + 240 + 111 + 21 + + + + + + + 10 + 240 + 91 + 16 + + + + + 9 + + + + Roomtype: + + diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 1a970c3..fd07518 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -322,7 +322,7 @@ void jpsDatamanager::writeRooms(QXmlStreamWriter *stream, QList & stream->writeStartElement("subroom"); stream->writeAttribute("id",QString::number(roomlist[i]->get_id())); stream->writeAttribute("caption",roomlist[i]->get_name()); - stream->writeAttribute("class","subroom"); + stream->writeAttribute("class",roomlist[i]->get_type()); //walls QList wallList=roomlist[i]->get_listWalls(); @@ -668,7 +668,7 @@ void jpsDatamanager::writeLandmarks(QXmlStreamWriter *stream, QListwriteAttribute("px",QString::number(landmark->get_pos().x())); stream->writeAttribute("py",QString::number(landmark->get_pos().y())); stream->writeStartElement("associations"); - m=0; + for (jpsWaypoint* waypoint:landmark->GetWaypoints()) { stream->writeStartElement("association"); @@ -937,8 +937,10 @@ void jpsDatamanager::parseSubRoom(QXmlStreamReader &xmlReader) if(attributes.hasAttribute("class")) { - /* We'll add it to the room. */ - roomlist.last()->set_type(attributes.value("class").toString()); + if (attributes.value("class").toString()=="subroom") + roomlist.last()->set_type("Not specified"); + else + roomlist.last()->set_type(attributes.value("class").toString()); } this->parseWalls(xmlReader,roomlist.last()); this->parseObstacles(xmlReader,roomlist.last()); diff --git a/src/rooms.cpp b/src/rooms.cpp index a373338..f58763c 100644 --- a/src/rooms.cpp +++ b/src/rooms.cpp @@ -38,6 +38,7 @@ jpsRoom::jpsRoom(int id_room) QString string="Room "; name=string.append(QString::number(id)); highlighted=false; + _type="Not specified"; } diff --git a/src/roomwidget.cpp b/src/roomwidget.cpp index 221a45a..4ac0f82 100644 --- a/src/roomwidget.cpp +++ b/src/roomwidget.cpp @@ -47,11 +47,16 @@ roomWidget::roomWidget(QWidget *parent, jpsDatamanager *dmanager, jpsGraphicsVie show_exits(); show_obstacles(); - ///temporary uncommented + //temporary uncommented ui->auto_assign_doors->setVisible(false); //ui->auto_assign_exits->setVisible(false); - + // roomClasses + ui->classBox->addItem("Not specified"); + ui->classBox->addItem("Corridor"); + ui->classBox->addItem("Office"); + ui->classBox->addItem("Lobby"); + ui->classBox->addItem("Entrance"); //SIGNALS AND SLOTS @@ -65,12 +70,14 @@ roomWidget::roomWidget(QWidget *parent, jpsDatamanager *dmanager, jpsGraphicsVie connect(ui->delete_room,SIGNAL(clicked(bool)),this,SLOT(delete_room())); connect(ui->apply_name_button,SIGNAL(clicked(bool)),this,SLOT(change_roomname())); connect(ui->add_button,SIGNAL(clicked(bool)),this,SLOT(addWall())); - connect(ui->list_rooms,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(showWalls())); - connect(ui->list_rooms,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(showWalls())); + connect(ui->list_rooms,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(showWallsAndType())); + connect(ui->list_rooms,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(showWallsAndType())); connect(ui->listWalls,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(selectWall())); connect(ui->remove_button,SIGNAL(clicked(bool)),this,SLOT(removeWall())); connect(ui->caption,SIGNAL(clicked(bool)),this,SLOT(shhi_roomCaption())); connect(ui->highlight,SIGNAL(clicked(bool)),this,SLOT(highlight_room())); + connect(ui->classBox,SIGNAL(activated(int)),this,SLOT(ChangeRoomType())); + connect(ui->classBox,SIGNAL(currentIndexChanged(int)),this,SLOT(ChangeRoomType())); //tab crossing connect(ui->addCrossingButton,SIGNAL(clicked(bool)),this,SLOT(new_crossing())); connect(ui->crossingList,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(enable_roomSelectionCrossings())); @@ -244,7 +251,7 @@ void roomWidget::addWall() int crow=ui->list_rooms->currentRow(); datamanager->get_roomlist()[crow]->addWall(graphview->get_markedLines()); - this->showWalls(); + this->showWallsAndType(); } } @@ -259,12 +266,12 @@ void roomWidget::removeWall() int crow=ui->list_rooms->currentRow(); datamanager->get_roomlist()[crow]->removeWall(graphview->get_markedLines()); - this->showWalls(); + this->showWallsAndType(); } } } -void roomWidget::showWalls() +void roomWidget::showWallsAndType() { ui->listWalls->clear(); @@ -285,6 +292,8 @@ void roomWidget::showWalls() string.append(" y2:"+QString::number(walllist[i]->get_line()->line().y2())); ui->listWalls->addItem(string); } + + ShowRoomType(crow); } } } @@ -558,7 +567,7 @@ void roomWidget::show_all() show_crossings(); show_exits(); show_obstacles(); - showWalls(); + showWallsAndType(); showWallsObs(); } @@ -773,6 +782,28 @@ void roomWidget::autoAssignExits() } +void roomWidget::ChangeRoomType() +{ + if (ui->list_rooms->currentItem()!=0L) + { + int cRoomRow=ui->list_rooms->currentRow(); + int cClassRow=ui->classBox->currentIndex(); + if (cClassRow!=-1) + { + datamanager->get_roomlist()[cRoomRow]->set_type(ui->classBox->currentText()); + } + } + +} + +void roomWidget::ShowRoomType(int& cRow) const +{ + QString type = datamanager->get_roomlist()[cRow]->get_type(); + + ui->classBox->setCurrentText(type); + +} + diff --git a/src/roomwidget.h b/src/roomwidget.h index e37ae17..7c8b072 100644 --- a/src/roomwidget.h +++ b/src/roomwidget.h @@ -57,7 +57,7 @@ protected slots: void change_roomname(); void addWall(); void removeWall(); - void showWalls(); + void showWallsAndType(); void selectWall(); void new_crossing(); void enable_roomSelectionCrossings(); @@ -87,6 +87,7 @@ protected slots: void highlight_obs(); void autoAssignDoors(); void autoAssignExits(); + void ChangeRoomType(); private: @@ -94,6 +95,9 @@ protected slots: jpsDatamanager *datamanager; jpsGraphicsView *graphview; + // + void ShowRoomType(int &cRow) const; + }; #endif // ROOMWIDGET_H From ad2fd8cc4e31bc5e86eb0bf0a1631a0d8ce984e5 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 9 Sep 2015 10:40:56 +0200 Subject: [PATCH 20/53] connection and waypoint stuff --- CMakeLists.txt | 2 + forms/mainwindow.ui | 13 ++++++- jpseditor.pro | 6 ++- src/GraphicView.cpp | 35 ++++++++++++++++-- src/GraphicView.h | 10 +++-- src/datamanager.cpp | 83 ++++++++++++++++++++++++++++++++++++------ src/datamanager.h | 9 ++++- src/jpsconnection.cpp | 61 +++++++++++++++++++++++++++++++ src/jpsconnection.h | 33 +++++++++++++++++ src/jpslandmark.cpp | 12 +++--- src/jpslandmark.h | 10 +++-- src/jpswaypoint.cpp | 19 ++++++++-- src/jpswaypoint.h | 5 ++- src/widgetlandmark.cpp | 6 +-- 14 files changed, 265 insertions(+), 39 deletions(-) create mode 100644 src/jpsconnection.cpp create mode 100644 src/jpsconnection.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c899e8..567275f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ set( SRCS src/widgetlandmark.cpp src/widgetsettings.cpp src/jpsyahpointer.cpp + src/jpsconnection.cpp dxflib/src/dl_writer_ascii.cpp dxflib/src/dl_dxf.cpp ) @@ -117,6 +118,7 @@ set( HDR src/widgetlandmark.h src/widgetsettings.h src/jpsyahpointer.h + src/jpsconnection.h dxflib/src/dl_writer_ascii.h dxflib/src/dl_writer.h dxflib/src/dl_global.h diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index a73684a..2dff77d 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -71,6 +71,9 @@ + + true + Cognitive Map @@ -405,7 +408,7 @@ true - true + false @@ -417,13 +420,16 @@ Landmark + + false + true - true + false @@ -435,6 +441,9 @@ LandmarkSpecs + + false + diff --git a/jpseditor.pro b/jpseditor.pro index ae202ad..4a77643 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -56,7 +56,8 @@ HEADERS += \ src/widgetlandmark.h \ src/graphicscene.h \ src/widgetsettings.h \ - src/jpsyahpointer.h + src/jpsyahpointer.h \ + src/jpsconnection.h SOURCES += \ @@ -77,7 +78,8 @@ SOURCES += \ src/widgetlandmark.cpp \ src/graphicscene.cpp \ src/widgetsettings.cpp \ - src/jpsyahpointer.cpp + src/jpsyahpointer.cpp \ + src/jpsconnection.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 4c0a9be..5400ad2 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -325,15 +325,15 @@ QGraphicsRectItem *jpsGraphicsView::GetCurrentSelectRect() return currentSelectRect; } -void jpsGraphicsView::ShowWaypoints(QList waypoints) +void jpsGraphicsView::ShowWaypoints(QList waypoints) { ClearWaypoints(); - for (jpsWaypoint* waypoint:waypoints) + for (ptrWaypoint waypoint:waypoints) { QGraphicsEllipseItem* ellipse = Scene->addEllipse(waypoint->GetRect(),QPen(Qt::blue,0)); ellipse->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); - QString string = waypoint->GetCaption()+ "\n" + waypoint->GetText(); + QString string = waypoint->GetType() + "\n" + waypoint->GetCaption()+ "\n" + waypoint->GetText(); QGraphicsTextItem* text = Scene->addText(string); text->setPos(waypoint->GetPos().x()+translation_x,waypoint->GetPos().y()+translation_y); //text->setScale(gl_scale_f); @@ -375,6 +375,30 @@ void jpsGraphicsView::ClearWaypointLabels() _waypointLabels.clear(); } +void jpsGraphicsView::ShowConnections(QList cons) +{ + ClearConnections(); + for (ptrConnection con:cons) + { + QGraphicsLineItem* line = Scene->addLine(QLineF(con->GetWaypoints().first->GetPos(),con->GetWaypoints().second->GetPos()),QPen(Qt::blue,0)); + _connections.push_back(line); + + + line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); + + + } +} + +void jpsGraphicsView::ClearConnections() +{ + for (QGraphicsLineItem* line:_connections) + { + delete line; + } + _connections.clear(); +} + void jpsGraphicsView::ClearWaypoints() @@ -1153,6 +1177,11 @@ void jpsGraphicsView::translations(QPointF old_pos) item->setTransform(QTransform::fromScale(scalef,scalef),true); } + for (QGraphicsLineItem* lineItem:_connections) + { + lineItem->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); + } + } void jpsGraphicsView::AutoZoom() diff --git a/src/GraphicView.h b/src/GraphicView.h index a147cf7..7fd798c 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -35,7 +35,8 @@ #include #include "jpsLineItem.h" #include "jpslandmark.h" - +#include "jpsconnection.h" +using ptrConnection = std::shared_ptr; class jpsGraphicsView: public QGraphicsView { @@ -110,11 +111,13 @@ class jpsGraphicsView: public QGraphicsView { // unmark Landmarks see slots QList get_landmarks(); - //Waypoints and YAHPointer + //Waypoints/Connections and YAHPointer QGraphicsRectItem* GetCurrentSelectRect(); - void ShowWaypoints(QList waypoints); + void ShowWaypoints(QList waypoints); void ShowYAHPointer(const QPointF& pos, const qreal& dir); void ClearWaypointLabels(); + void ShowConnections(QList cons); + void ClearConnections(); //RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); @@ -183,6 +186,7 @@ public slots: jpsLandmark* markedLandmark; QGraphicsRectItem* currentLandmarkRect; QList _waypoints; + QList _connections; QList _yahPointer; QList _waypointLabels; diff --git a/src/datamanager.cpp b/src/datamanager.cpp index fd07518..32bac34 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -29,6 +29,7 @@ #include "datamanager.h" #include +#include @@ -669,7 +670,7 @@ void jpsDatamanager::writeLandmarks(QXmlStreamWriter *stream, QListwriteAttribute("py",QString::number(landmark->get_pos().y())); stream->writeStartElement("associations"); - for (jpsWaypoint* waypoint:landmark->GetWaypoints()) + for (ptrWaypoint waypoint:landmark->GetWaypoints()) { stream->writeStartElement("association"); stream->writeAttribute("id",QString::number(m)); @@ -1520,7 +1521,13 @@ void jpsDatamanager::ParseFrames(QXmlStreamReader &xmlReader) { ParseWaypointInCMap(xmlReader, frameID); } + else if (xmlReader.tokenType()==QXmlStreamReader::StartElement && + xmlReader.name() == "connection") + { + ParseConnectionsInCMap(xmlReader, frameID); + } xmlReader.readNext(); + } _lastCMapFrame=frameID; @@ -1556,10 +1563,11 @@ void jpsDatamanager::ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int qreal y = xmlReader.attributes().value("y").toFloat(); qreal rA = xmlReader.attributes().value("rA").toFloat(); qreal rB = xmlReader.attributes().value("rB").toFloat(); + QString caption = xmlReader.attributes().value("caption").toString(); - for (jpsWaypoint* waypoint:_waypointsInCMap) + for (ptrWaypoint waypoint:_waypointsInCMap) { - if (waypoint->GetId()==id && waypoint->GetCaption()=="Landmark") + if (waypoint->GetId()==id && waypoint->GetType()=="Landmark") { wayPInList = true; waypoint->SetLastFrame(frame); @@ -1568,9 +1576,10 @@ void jpsDatamanager::ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int if (!wayPInList) { - _waypointsInCMap.push_back(new jpsWaypoint(QPointF(x,y),rA,rB,id,"Landmark")); + _waypointsInCMap.push_back(std::make_shared(QPointF(x,y),rA,rB,id,"Landmark")); _waypointsInCMap.back()->SetFirstFrame(frame); _waypointsInCMap.back()->SetLastFrame(frame); + _waypointsInCMap.back()->SetCaption(caption); } } @@ -1583,11 +1592,12 @@ void jpsDatamanager::ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int& qreal y = xmlReader.attributes().value("y").toFloat(); qreal rA = xmlReader.attributes().value("rA").toFloat(); qreal rB = xmlReader.attributes().value("rB").toFloat(); + QString caption = xmlReader.attributes().value("caption").toString(); bool current = xmlReader.attributes().value("current").toInt(); - for (jpsWaypoint* waypoint:_waypointsInCMap) + for (ptrWaypoint waypoint:_waypointsInCMap) { - if (waypoint->GetId()==id && waypoint->GetCaption()=="Waypoint") + if (waypoint->GetId()==id && waypoint->GetType()=="Waypoint") { wayPInList = true; waypoint->SetLastFrame(frame); @@ -1601,24 +1611,66 @@ void jpsDatamanager::ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int& } } - if (!wayPInList) { - _waypointsInCMap.push_back(new jpsWaypoint(QPointF(x,y),rA,rB,id,"Waypoint")); + _waypointsInCMap.push_back(std::make_shared(QPointF(x,y),rA,rB,id,"Waypoint")); _waypointsInCMap.back()->SetFirstFrame(frame); _waypointsInCMap.back()->SetLastFrame(frame); _waypointsInCMap.back()->SetCurrentness(current,frame); + _waypointsInCMap.back()->SetCaption(caption); + } + +} + +void jpsDatamanager::ParseConnectionsInCMap(QXmlStreamReader &xmlReader, const int &frame) +{ + int id1 = xmlReader.attributes().value("Landmark_WaypointID1").toInt(); + int id2 = xmlReader.attributes().value("Landmark_WaypointID2").toInt(); + std::shared_ptr waypoint1 = nullptr; + std::shared_ptr waypoint2 = nullptr; + + + for (ptrWaypoint waypoint:_waypointsInCMap) + { + if (waypoint->GetId()==id1) + { + waypoint1=waypoint; + + } + else if (waypoint->GetId()==id2) + { + waypoint2=waypoint; + + } } + + ptrConnection con = std::make_shared(waypoint1,waypoint2,frame); + if (waypoint1!=nullptr && waypoint2!=nullptr) + { + for (ptrConnection conInMap : _connectionsInCMap) + { + if (con->operator ==(conInMap)) + { + conInMap->SetLastFrame(frame); + + return; + } + } + + _connectionsInCMap.push_back(con); + } + + } void jpsDatamanager::ShowCMapFrame(const int& frame) const { mView->ShowYAHPointer(_yahPointer->GetPosWhenFrame(frame),_yahPointer->GetDirWhenFrame(frame)); - QList wayPCandidates; + QList wayPCandidates; - for (jpsWaypoint* waypoint:_waypointsInCMap) + for (ptrWaypoint waypoint:_waypointsInCMap) { if (waypoint->OccursInFrame(frame)) { @@ -1630,9 +1682,18 @@ void jpsDatamanager::ShowCMapFrame(const int& frame) const waypoint->SetText("Already visited"); else waypoint->SetText(""); - } } + QList conCandidates; + for (ptrConnection connection:_connectionsInCMap) + { + if (connection->OccursInFrame(frame)) + { + conCandidates.push_back(connection); + } + } + + mView->ShowConnections(conCandidates); mView->ShowWaypoints(wayPCandidates); } diff --git a/src/datamanager.h b/src/datamanager.h index a82f8b9..fc10a4e 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -41,12 +41,17 @@ #include "jpsobstacle.h" #include "GraphicView.h" #include "jpsyahpointer.h" +#include "jpsconnection.h" #include "../dxflib/src/dl_creationadapter.h" #include "../dxflib/src/dl_dxf.h" +using ptrConnection = std::shared_ptr; +using ptrWaypoint = std::shared_ptr; + + class jpsDatamanager: public DL_CreationAdapter { public: @@ -138,6 +143,7 @@ class jpsDatamanager: public DL_CreationAdapter void ParseYAHPointer(QXmlStreamReader &xmlReader, const int &frame); void ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int &frame); void ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int &frame); + void ParseConnectionsInCMap(QXmlStreamReader &xmlReader, const int &frame); //Show Cognitive Map void ShowCMapFrame(const int& frame) const; @@ -158,7 +164,8 @@ class jpsDatamanager: public DL_CreationAdapter //CognitiveMap QList _landmarksInCMap; - QList _waypointsInCMap; + QList _waypointsInCMap; + QList _connectionsInCMap; jpsYAHPointer* _yahPointer; double _frameRate; int _lastCMapFrame; diff --git a/src/jpsconnection.cpp b/src/jpsconnection.cpp new file mode 100644 index 0000000..a2ccecc --- /dev/null +++ b/src/jpsconnection.cpp @@ -0,0 +1,61 @@ +#include "jpsconnection.h" + +jpsConnection::jpsConnection(ptrWaypoint waypoint1, ptrWaypoint waypoint2, const int &frameID) +{ + _waypoint1=waypoint1; + _waypoint2=waypoint2; + _firstFrame=frameID; + _lastFrame=frameID; +} + +jpsConnection::~jpsConnection() +{ + +} + +std::pair jpsConnection::GetWaypoints() const +{ + return std::make_pair(_waypoint1,_waypoint2); +} + +bool jpsConnection::OccursInFrame(const int& frameID) const +{ + if (frameID>=_firstFrame && frameID<=_lastFrame) + { + return true; + } + else + return false; +} + +void jpsConnection::SetFirstFrame(const int &frameID) +{ + _firstFrame=frameID; +} + +void jpsConnection::SetLastFrame(const int &frameID) +{ + _lastFrame=frameID; +} + +const int &jpsConnection::GetFirstFrame() const +{ + return _firstFrame; +} + +const int &jpsConnection::GetLastFrame() const +{ + return _lastFrame; +} + +bool jpsConnection::operator == (const ptrConnection con2) const +{ + if ((con2->GetWaypoints().first==_waypoint1 && con2->GetWaypoints().second==_waypoint2) + || (con2->GetWaypoints().second==_waypoint1 && con2->GetWaypoints().first==_waypoint2)) + { + return true; + } + else + return false; +} + diff --git a/src/jpsconnection.h b/src/jpsconnection.h new file mode 100644 index 0000000..8359d4e --- /dev/null +++ b/src/jpsconnection.h @@ -0,0 +1,33 @@ +#ifndef JPSCONNECTION_H +#define JPSCONNECTION_H + +#include +#include +#include "jpswaypoint.h" + +using ptrWaypoint = std::shared_ptr; + + +class jpsConnection +{ +using ptrConnection = std::shared_ptr; +public: + jpsConnection(ptrWaypoint waypoint1, ptrWaypoint waypoint2, const int& frameID=-1); + ~jpsConnection(); + std::pair GetWaypoints() const; + //Occurence + bool OccursInFrame(const int &frameID) const; + void SetFirstFrame(const int &frameID); + void SetLastFrame(const int &frameID); + const int& GetFirstFrame() const; + const int& GetLastFrame() const; + // Operator overload + bool operator ==(const ptrConnection con2) const; +private: + ptrWaypoint _waypoint1; + ptrWaypoint _waypoint2; + int _firstFrame; + int _lastFrame; +}; + +#endif // JPSCONNECTION_H diff --git a/src/jpslandmark.cpp b/src/jpslandmark.cpp index 637b737..b109cf3 100644 --- a/src/jpslandmark.cpp +++ b/src/jpslandmark.cpp @@ -100,27 +100,27 @@ int jpsLandmark::get_visibility() return _visibility; } -void jpsLandmark::AddWaypoint(jpsWaypoint *waypoint) +void jpsLandmark::AddWaypoint(ptrWaypoint waypoint) { _waypoints.push_back(waypoint); } -void jpsLandmark::RemoveWaypoint(jpsWaypoint *waypoint) +void jpsLandmark::RemoveWaypoint(ptrWaypoint waypoint) { - delete waypoint; + delete waypoint.get(); _waypoints.removeOne(waypoint); } -QList jpsLandmark::GetWaypoints() +QList jpsLandmark::GetWaypoints() { return _waypoints; } void jpsLandmark::RemoveAllWaypoints() { - for (jpsWaypoint* waypoint:_waypoints) + for (ptrWaypoint waypoint:_waypoints) { - delete waypoint; + delete waypoint.get(); } _waypoints.clear(); } diff --git a/src/jpslandmark.h b/src/jpslandmark.h index 3cff6d3..8bbf20f 100644 --- a/src/jpslandmark.h +++ b/src/jpslandmark.h @@ -29,9 +29,11 @@ #ifndef JPSLANDMARK_H #define JPSLANDMARK_H #include +#include #include "rooms.h" #include "jpswaypoint.h" +using ptrWaypoint = std::shared_ptr; class jpsLandmark { @@ -52,9 +54,9 @@ class jpsLandmark jpsRoom *get_room(); int get_visibility(); //Waypoint handling - void AddWaypoint(jpsWaypoint* waypoint); - void RemoveWaypoint(jpsWaypoint* waypoint); - QList GetWaypoints(); + void AddWaypoint(ptrWaypoint waypoint); + void RemoveWaypoint(ptrWaypoint waypoint); + QList GetWaypoints(); void RemoveAllWaypoints(); @@ -64,7 +66,7 @@ class jpsLandmark jpsRoom* _room; int _visibility; QGraphicsPixmapItem* _pixmapItem; - QList _waypoints; + QList _waypoints; }; diff --git a/src/jpswaypoint.cpp b/src/jpswaypoint.cpp index aa8fa49..109c26b 100644 --- a/src/jpswaypoint.cpp +++ b/src/jpswaypoint.cpp @@ -34,19 +34,20 @@ jpsWaypoint::jpsWaypoint() } -jpsWaypoint::jpsWaypoint(const QPointF &point, const qreal &rA, const qreal &rB, const int &id, const QString &caption) +jpsWaypoint::jpsWaypoint(const QPointF &point, const qreal &rA, const qreal &rB, const int &id, const QString &type) { _pos=point; _a=rA; _b=rB; _id=id; - _caption=caption; + _type=type; _rect=QRectF(point.x()-rA,point.y()-rB,rA*2,rB*2); _currentness=false; _FFcurrentness=-1; _LFcurrentness=-1; _lastFrame=-1; _firstFrame=-1; + _caption=""; } jpsWaypoint::jpsWaypoint(QRectF rect, const int &id) @@ -120,6 +121,11 @@ const QString &jpsWaypoint::GetCaption() const return _caption; } +const QString &jpsWaypoint::GetType() const +{ + return _type; +} + void jpsWaypoint::SetPos(QPointF point) { @@ -150,6 +156,11 @@ void jpsWaypoint::SetCaption(const QString &string) _caption=string; } +void jpsWaypoint::SetType(const QString &type) +{ + _type=type; +} + const int &jpsWaypoint::GetFirstFrame() const { return _firstFrame; @@ -163,11 +174,13 @@ const int &jpsWaypoint::GetLastFrame() const void jpsWaypoint::SetFirstFrame(const int &frame) { _firstFrame=frame; + } void jpsWaypoint::SetLastFrame(const int &frame) { _lastFrame=frame; + } bool jpsWaypoint::OccursInFrame(const int &frame) const @@ -230,7 +243,7 @@ void jpsWaypoint::SetText(const QString &text) bool jpsWaypoint::Visited(const int &frameID) const { - if (frameID > _LFcurrentness && _lastFrame!=-1) + if (frameID > _LFcurrentness && _LFcurrentness!=-1) return true; else diff --git a/src/jpswaypoint.h b/src/jpswaypoint.h index bce2d2f..39bb917 100644 --- a/src/jpswaypoint.h +++ b/src/jpswaypoint.h @@ -35,7 +35,7 @@ class jpsWaypoint { public: jpsWaypoint(); - jpsWaypoint(const QPointF& point,const qreal& rA, const qreal& rB, const int& id=0, const QString& caption="Waypoint"); + jpsWaypoint(const QPointF& point,const qreal& rA, const qreal& rB, const int& id=0, const QString& type="Waypoint"); jpsWaypoint(QRectF rect, const int& id=0); jpsWaypoint(QGraphicsEllipseItem* ellipseItem, const int& id=0); ~jpsWaypoint(); @@ -47,6 +47,7 @@ class jpsWaypoint const int& GetId() const; QGraphicsEllipseItem* GetEllipseItem(); const QString& GetCaption() const; + const QString& GetType() const; //Setter void SetPos(QPointF point); @@ -54,6 +55,7 @@ class jpsWaypoint void SetEllipseItem(QGraphicsEllipseItem* ellipseItem); void SetId(const int& id); void SetCaption(const QString& string); + void SetType(const QString& type); //Occurence const int& GetFirstFrame() const; @@ -83,6 +85,7 @@ class jpsWaypoint double _b; int _id; QString _caption; + QString _type; //Occurence int _firstFrame; diff --git a/src/widgetlandmark.cpp b/src/widgetlandmark.cpp index daf2308..6e2ce75 100644 --- a/src/widgetlandmark.cpp +++ b/src/widgetlandmark.cpp @@ -164,7 +164,7 @@ void widgetLandmark::AddAssociation() { int cLanRow=ui->list_landmarks->currentIndex(); - _dmanager->get_landmarks()[cLanRow]->AddWaypoint(new jpsWaypoint(_gview->GetCurrentSelectRect()->rect(),_waypointIDCounter)); + _dmanager->get_landmarks()[cLanRow]->AddWaypoint(std::make_shared(_gview->GetCurrentSelectRect()->rect(),_waypointIDCounter)); ShowAssociations(); _waypointIDCounter++; @@ -178,9 +178,9 @@ void widgetLandmark::ShowAssociations() if (ui->list_landmarks->currentIndex()!=-1) { int cLanRow=ui->list_landmarks->currentIndex(); - QList waypoints = _dmanager->get_landmarks()[cLanRow]->GetWaypoints(); + QList waypoints = _dmanager->get_landmarks()[cLanRow]->GetWaypoints(); - for (jpsWaypoint* waypoint:waypoints) + for (ptrWaypoint waypoint:waypoints) { QPointF pos = waypoint->GetPos(); QString name = "Waypoint: x: "+QString::number(pos.x())+"y: "+QString::number(pos.y()); From 901448364b5821555479f2a557b42f884996f709 Mon Sep 17 00:00:00 2001 From: Mohcine Chraibi Date: Wed, 4 Nov 2015 13:16:32 +0100 Subject: [PATCH 21/53] Add missing include in jpsyahpointer.h - silence some cmake warnings (policy stuff) - FIXME: The code does NOT compile with Qt4. --- CMakeLists.txt | 40 ++++++++++++++++++++++------------------ src/jpsyahpointer.h | 2 +- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 567275f..b09c304 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,13 +7,17 @@ #================ # 1. CMAKE_BUILD_TYPE=Release (default Debug) # 2. DESIRED_QT_VERSION=5 (default 4) +# example: >> cmake -DDESIRED_QT_VERSION=5 -DCMAKE_PREFIX_PATH=~/Qt/5.5/clang_64 .. +cmake_minimum_required(VERSION 2.8.9) IF (POLICY CMP0048) # in CMake 3.0.0+ CMAKE_POLICY (SET CMP0048 OLD) # keep PROJECT() from clearing VERSION variables ENDIF (POLICY CMP0048) - +IF (POLICY CMP0043) # in CMake 3.0.0+ + CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables +ENDIF (POLICY CMP0043) project(JPSeditor) -cmake_minimum_required(VERSION 2.8.9) + set(README_FILE "${CMAKE_SOURCE_DIR}/README.md") @@ -84,7 +88,7 @@ set( SRCS src/mainWindow.cpp src/main.cpp src/GraphicView.cpp - src/graphicscene.cpp + src/graphicscene.cpp src/roomwidget.cpp src/rooms.cpp src/datamanager.cpp @@ -92,12 +96,12 @@ set( SRCS src/jpsLineItem.cpp src/jpsexit.cpp src/jpsobstacle.cpp - src/jpslandmark.cpp - src/jpswaypoint.cpp - src/widgetlandmark.cpp - src/widgetsettings.cpp - src/jpsyahpointer.cpp - src/jpsconnection.cpp + src/jpslandmark.cpp + src/jpswaypoint.cpp + src/widgetlandmark.cpp + src/widgetsettings.cpp + src/jpsyahpointer.cpp + src/jpsconnection.cpp dxflib/src/dl_writer_ascii.cpp dxflib/src/dl_dxf.cpp ) @@ -105,7 +109,7 @@ set( SRCS set( HDR src/mainWindow.h src/GraphicView.h - src/graphicscene.h + src/graphicscene.h src/roomwidget.h src/rooms.h src/datamanager.h @@ -113,12 +117,12 @@ set( HDR src/jpsLineItem.h src/jpsexit.h src/jpsobstacle.h - src/jpslandmark.h - src/jpswaypoint.h - src/widgetlandmark.h - src/widgetsettings.h - src/jpsyahpointer.h - src/jpsconnection.h + src/jpslandmark.h + src/jpswaypoint.h + src/widgetlandmark.h + src/widgetsettings.h + src/jpsyahpointer.h + src/jpsconnection.h dxflib/src/dl_writer_ascii.h dxflib/src/dl_writer.h dxflib/src/dl_global.h @@ -137,8 +141,8 @@ set( HDR set( UIS forms/mainwindow.ui forms/roomwidget.ui - forms/widgetlandmark.ui - forms/widgetsettings.ui + forms/widgetlandmark.ui + forms/widgetsettings.ui ) # and finally a resource file diff --git a/src/jpsyahpointer.h b/src/jpsyahpointer.h index ad61057..ef1e002 100644 --- a/src/jpsyahpointer.h +++ b/src/jpsyahpointer.h @@ -1,7 +1,7 @@ #ifndef JPSYAHPOINTER_H #define JPSYAHPOINTER_H #include - +#include class jpsYAHPointer { public: From 072c17f7227bde3800daff7b4625ebb8cf4309b1 Mon Sep 17 00:00:00 2001 From: Mohcine Chraibi Date: Wed, 4 Nov 2015 13:54:01 +0100 Subject: [PATCH 22/53] fix ticket #34 - todo: check how to replace ui->classBox->setCurrentText in Qt4 --- forms/widgetsettings.ui | 2 +- src/datamanager.cpp | 34 +++++++++++++++++----------------- src/datamanager.h | 2 +- src/roomwidget.cpp | 3 +-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/forms/widgetsettings.ui b/forms/widgetsettings.ui index 1eabe5a..95e275b 100644 --- a/forms/widgetsettings.ui +++ b/forms/widgetsettings.ui @@ -89,7 +89,7 @@ - + Tab 2 diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 32bac34..7135fbf 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -1501,7 +1501,7 @@ bool jpsDatamanager::ParseCogMap(QFile &file) void jpsDatamanager::ParseFrames(QXmlStreamReader &xmlReader) { - int frameID= xmlReader.attributes().value("ID").toInt(); + int frameID= xmlReader.attributes().value("ID").toString().toInt(); while(!(xmlReader.tokenType() == QXmlStreamReader::EndElement && xmlReader.name() == "frame")) @@ -1535,9 +1535,9 @@ void jpsDatamanager::ParseFrames(QXmlStreamReader &xmlReader) void jpsDatamanager::ParseYAHPointer(QXmlStreamReader &xmlReader, const int& frame) { - qreal x = xmlReader.attributes().value("x").toFloat(); - qreal y = xmlReader.attributes().value("y").toFloat(); - qreal angle = xmlReader.attributes().value("dir").toFloat(); + qreal x = xmlReader.attributes().value("x").toString().toFloat(); + qreal y = xmlReader.attributes().value("y").toString().toFloat(); + qreal angle = xmlReader.attributes().value("dir").toString().toFloat(); if (_yahPointer==nullptr) { _yahPointer = new jpsYAHPointer(x,y,angle); @@ -1558,11 +1558,11 @@ void jpsDatamanager::ParseLandmarksInCMap(QXmlStreamReader &xmlReader, const int bool wayPInList=false; - int id = xmlReader.attributes().value("ID").toInt(); - qreal x = xmlReader.attributes().value("x").toFloat(); - qreal y = xmlReader.attributes().value("y").toFloat(); - qreal rA = xmlReader.attributes().value("rA").toFloat(); - qreal rB = xmlReader.attributes().value("rB").toFloat(); + int id = xmlReader.attributes().value("ID").toString().toInt(); + qreal x = xmlReader.attributes().value("x").toString().toFloat(); + qreal y = xmlReader.attributes().value("y").toString().toFloat(); + qreal rA = xmlReader.attributes().value("rA").toString().toFloat(); + qreal rB = xmlReader.attributes().value("rB").toString().toFloat(); QString caption = xmlReader.attributes().value("caption").toString(); for (ptrWaypoint waypoint:_waypointsInCMap) @@ -1587,13 +1587,13 @@ void jpsDatamanager::ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int& { bool wayPInList=false; - int id = xmlReader.attributes().value("ID").toInt(); - qreal x = xmlReader.attributes().value("x").toFloat(); - qreal y = xmlReader.attributes().value("y").toFloat(); - qreal rA = xmlReader.attributes().value("rA").toFloat(); - qreal rB = xmlReader.attributes().value("rB").toFloat(); + int id = xmlReader.attributes().value("ID").toString().toInt(); + qreal x = xmlReader.attributes().value("x").toString().toFloat(); + qreal y = xmlReader.attributes().value("y").toString().toFloat(); + qreal rA = xmlReader.attributes().value("rA").toString().toFloat(); + qreal rB = xmlReader.attributes().value("rB").toString().toFloat(); QString caption = xmlReader.attributes().value("caption").toString(); - bool current = xmlReader.attributes().value("current").toInt(); + bool current = xmlReader.attributes().value("current").toString().toInt(); for (ptrWaypoint waypoint:_waypointsInCMap) { @@ -1624,8 +1624,8 @@ void jpsDatamanager::ParseWaypointInCMap(QXmlStreamReader &xmlReader, const int& void jpsDatamanager::ParseConnectionsInCMap(QXmlStreamReader &xmlReader, const int &frame) { - int id1 = xmlReader.attributes().value("Landmark_WaypointID1").toInt(); - int id2 = xmlReader.attributes().value("Landmark_WaypointID2").toInt(); + int id1 = xmlReader.attributes().value("Landmark_WaypointID1").toString().toInt(); + int id2 = xmlReader.attributes().value("Landmark_WaypointID2").toString().toInt(); std::shared_ptr waypoint1 = nullptr; std::shared_ptr waypoint2 = nullptr; diff --git a/src/datamanager.h b/src/datamanager.h index fc10a4e..86f0fc4 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -30,7 +30,7 @@ #ifndef DATAMANAGER_H #define DATAMANAGER_H -#include +#include #include #include #include diff --git a/src/roomwidget.cpp b/src/roomwidget.cpp index 4ac0f82..793e55f 100644 --- a/src/roomwidget.cpp +++ b/src/roomwidget.cpp @@ -800,8 +800,7 @@ void roomWidget::ShowRoomType(int& cRow) const { QString type = datamanager->get_roomlist()[cRow]->get_type(); - ui->classBox->setCurrentText(type); - + // ui->classBox->setCurrentText(type); } From dbf613d619524f0f8e56b7778874a588255f2fad Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 25 Nov 2015 10:52:59 +0100 Subject: [PATCH 23/53] working on issue: confirm before close window --- forms/mainwindow.ui | 8 ++++---- src/mainWindow.cpp | 11 ++++++++++- src/mainWindow.h | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 2dff77d..e3be1b6 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -408,7 +408,7 @@ true - false + true @@ -421,7 +421,7 @@ Landmark - false + true @@ -429,7 +429,7 @@ true - false + true @@ -442,7 +442,7 @@ LandmarkSpecs - false + true diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index bc7e99e..16967f1 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -88,7 +88,7 @@ MWindow :: MWindow() { //Signals and Slots // Tab File - connect(actionBeenden, SIGNAL(triggered(bool)),qApp,SLOT(quit())); + connect(actionBeenden, SIGNAL(triggered(bool)),this,SLOT(quit()));//qApp,SLOT(quit())); connect(action_ffnen,SIGNAL(triggered(bool)),this,SLOT(openFile())); connect(action_ffnen_xml,SIGNAL(triggered(bool)),this,SLOT(openFileXML())); connect(actionSpeichern,SIGNAL(triggered(bool)),this,SLOT(saveFile())); @@ -199,6 +199,15 @@ void MWindow::UpdateCMap() dmanager->ShowCMapFrame(_cMapFrame); } +void MWindow::quit() +{ + //MessageBox + //Wenn ja. + qApp->quit(); + //Wenn nein + //return to app +} + void MWindow::add_landmark() { jpsLandmark* landmark = mview->get_landmarks().last(); diff --git a/src/mainWindow.h b/src/mainWindow.h index 1215430..b0258a9 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -118,6 +118,9 @@ protected slots: void RunCMap(); void UpdateCMap(); + //quit + void quit(); + }; From dda2691e2b0c52db67f9d8d2dfb14198f1dea7ed Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 1 Dec 2015 16:00:42 +0100 Subject: [PATCH 24/53] working on the visulization of the origing --- forms/mainwindow.ui | 6 ++++ src/GraphicView.cpp | 68 +++++++++++++++++++++++++++++++++++---------- src/GraphicView.h | 3 +- src/mainWindow.cpp | 6 ++++ src/mainWindow.h | 1 + 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index e3be1b6..e67b2c0 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -69,6 +69,7 @@ View + @@ -497,6 +498,11 @@ Run visualisation + + + Show Point of Origin + + diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 5400ad2..47b3d69 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -102,12 +102,6 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) setScene(Scene); setSceneRect(0, 0, 1920, 1080); - //create_grid(); - - //Origin - - //origin.push_back(Scene->addLine(1,1,1/gl_scale_f*0.02,1,QPen(Qt::black,0))); - //origin.push_back(Scene->addLine(1,1,1,1/gl_scale_f*0.02,QPen(Qt::black,0))); } jpsGraphicsView::~jpsGraphicsView() @@ -1066,6 +1060,9 @@ void jpsGraphicsView::zoom(int delta) setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + //exclude origin from scaling + ShowOrigin(); + // Scale the view / do the zoom double scaleFactor = 1.15; if(delta > 0) @@ -1097,6 +1094,9 @@ void jpsGraphicsView::zoom(int delta) //create_grid(); } + //set origin back to the scene + ShowOrigin(); + } void jpsGraphicsView::translations(QPointF old_pos) @@ -1182,6 +1182,10 @@ void jpsGraphicsView::translations(QPointF old_pos) lineItem->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); } + for (QGraphicsLineItem* lineItem:_origin) + { + lineItem->setTransform(QTransform::fromTranslate(pos.x()-old_pos.x(),pos.y()-old_pos.y()), true); + } } void jpsGraphicsView::AutoZoom() @@ -1192,8 +1196,8 @@ void jpsGraphicsView::AutoZoom() line_vector[0]->get_line()->line().p1().y()); for (jpsLineItem* line:line_vector) { - ///x - ///p1 + //x + //p1 if (line->get_line()->line().p1().x()get_line()->line().p1().x()); @@ -1203,7 +1207,7 @@ void jpsGraphicsView::AutoZoom() max.setX(line->get_line()->line().p1().x()); } - ///p2 + //p2 if (line->get_line()->line().p2().x()get_line()->line().p2().x()); @@ -1213,8 +1217,8 @@ void jpsGraphicsView::AutoZoom() max.setX(line->get_line()->line().p2().x()); } - ///y - ///p1 + //y + //p1 if (line->get_line()->line().p1().y()get_line()->line().p1().y()); @@ -1237,17 +1241,17 @@ void jpsGraphicsView::AutoZoom() //QPointF center((min.x()+max.x())/2.0,(min.y()+max.y())/2.0); - ///scaling + //scaling qreal width = (max.x()-min.x()); qreal height = (max.y()-min.y()); - /// To ensure the functionality of fitInView + // To ensure the functionality of fitInView this->setSceneRect(min.x(),min.y(),width,height); this->fitInView(min.x(),min.y(),width,height,Qt::KeepAspectRatio); - ///adapting gl_scale_f + //adapting gl_scale_f gl_scale_f=1/this->transform().m11(); - ///translations + //translations QPointF old_pos; old_pos.setX(pos.x()+translation_x); old_pos.setY(pos.y()+translation_y); @@ -1281,6 +1285,40 @@ qreal jpsGraphicsView::CalcGridSize() } +void jpsGraphicsView::ShowOrigin() +{ + if (_origin.isEmpty()) + { + _origin.push_back(Scene->addLine(1,1,1/gl_scale_f*0.02,1,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1,1,1,1/gl_scale_f*0.02,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1,1/gl_scale_f*0.02,1-1/gl_scale_f*0.001,1/gl_scale_f*0.02-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1,1/gl_scale_f*0.02,1+1/gl_scale_f*0.001,1/gl_scale_f*0.02-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1+1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1+1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + //Y + _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0005,1/gl_scale_f*0.0155,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0015,1/gl_scale_f*0.0155,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.001,1/gl_scale_f*0.014,QPen(Qt::black,0.025))); + //X + _origin.push_back(Scene->addLine(1/gl_scale_f*0.014,1-1/gl_scale_f*0.0017,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0005,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(1/gl_scale_f*0.015,1-1/gl_scale_f*0.0017,1/gl_scale_f*0.014,1-1/gl_scale_f*0.0005,QPen(Qt::black,0.025))); + + for (QGraphicsLineItem* lineItem:_origin) + { + lineItem->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); + } + } + else + { + for (QGraphicsLineItem* line:_origin) + { + delete line; + } + _origin.clear(); + } +} + void jpsGraphicsView::StatAssoDef() { _assoDef=!_assoDef; diff --git a/src/GraphicView.h b/src/GraphicView.h index 7fd798c..8fa7cfd 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -76,6 +76,7 @@ class jpsGraphicsView: public QGraphicsView { void translations(QPointF old_pos); void AutoZoom(); qreal CalcGridSize(); + void ShowOrigin(); //Pos QPointF return_Pos(); @@ -150,7 +151,7 @@ public slots: QList intersect_point_vector; //QList grid_point_vector; QList line_vector; - QList origin; + QList _origin; //QList *> mainlist; QPointF pos; //QPointF* intersection_point; diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 16967f1..c1ac7a9 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -113,6 +113,7 @@ MWindow :: MWindow() { connect(actionExit,SIGNAL(triggered(bool)),this,SLOT(dis_selectMode())); // Tab View 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())); // mview @@ -232,6 +233,11 @@ void MWindow::Settings() } +void MWindow::ShowOrigin() +{ + mview->ShowOrigin(); +} + void MWindow::openFile(){ QString fileName=QFileDialog::getOpenFileName(this,tr("Open DXF"),"",tr("DXF-Drawings (*.dxf)")); diff --git a/src/mainWindow.h b/src/mainWindow.h index b0258a9..d20fd4f 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -110,6 +110,7 @@ protected slots: void gridmode(); void rotate(); void Settings(); + void ShowOrigin(); //autosave void AutoSave(); From 4ce2180610550f67f6befed27ad6d2dd8ef547eb Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 2 Dec 2015 11:51:38 +0100 Subject: [PATCH 25/53] length of current line will be displayed; debugging --- src/GraphicView.cpp | 7 +++++++ src/GraphicView.h | 2 ++ src/datamanager.cpp | 6 ++++++ src/mainWindow.cpp | 8 +++++++- src/mainWindow.h | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 47b3d69..5095a71 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -182,6 +182,8 @@ void jpsGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) current_line->setLine(current_line->line().x1(),current_line->line().y1(),translated_pos.x(),translated_pos.y()); //} + //As line length has changed + emit LineLengthChanged(); } if (_currentVLine!=nullptr) { @@ -987,6 +989,11 @@ void jpsGraphicsView::EditLine(QPointF* point) } } +qreal jpsGraphicsView::ReturnLineLength() +{ + return current_line->line().length(); +} + bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) { // if caption exits, it is supposed to be hided: diff --git a/src/GraphicView.h b/src/GraphicView.h index 8fa7cfd..6b009b5 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -103,6 +103,7 @@ class jpsGraphicsView: public QGraphicsView { void select_line(jpsLineItem *mline); void SetVLine(); void EditLine(QPointF* point); + qreal ReturnLineLength(); // Landmark void delete_landmark(); @@ -208,6 +209,7 @@ public slots: void remove_all(); void landmark_added(); void AssoDefCompleted(); + void LineLengthChanged(); //void DoubleClick(); }; diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 7135fbf..d731d70 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -60,8 +60,14 @@ void jpsDatamanager::remove_room(jpsRoom *room) { //if (roomlist.size()>0) //{ + int roomID=room->get_id(); roomlist.removeOne(room); delete room; + //change IDs of other room with ID greater than roomID + for (jpsRoom* otherroom:roomlist) + if (otherroom->get_id()>roomID) + otherroom->set_id(otherroom->get_id()-1); + room_id_counter-=1; //} } diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index c1ac7a9..53fdeab 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -55,7 +55,7 @@ MWindow :: MWindow() { _settings=nullptr; length_edit = new QLineEdit(); - length_edit->setMaximumWidth(55); + length_edit->setMaximumWidth(75); label1 = new QLabel(); label1->setMinimumWidth(90); label1->setText("Length of Line :"); @@ -123,6 +123,7 @@ MWindow :: MWindow() { connect(mview,SIGNAL(set_focus_textedit()),length_edit,SLOT(setFocus())); connect(mview,SIGNAL(mouse_moved()),this,SLOT(show_coords())); connect(mview,SIGNAL(landmark_added()),this,SLOT(add_landmark())); + connect(mview,SIGNAL(LineLengthChanged()),this,SLOT(ShowLineLength())); //connect(mview,SIGNAL(DoubleClick()),this,SLOT(en_selectMode())); // Autosave connect(timer, SIGNAL(timeout()), this, SLOT(AutoSave())); @@ -512,6 +513,11 @@ void MWindow::remove_all_lines() dmanager->remove_all(); } +void MWindow::ShowLineLength() +{ + length_edit->setText(QString::number(mview->ReturnLineLength())); +} + void MWindow::rotate() { mview->rotate(-90); diff --git a/src/mainWindow.h b/src/mainWindow.h index d20fd4f..d22ce94 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -100,6 +100,7 @@ protected slots: void dis_selectMode(); void lines_deleted(); void remove_all_lines(); + void ShowLineLength(); //Room and landmark def void define_room(); From 7c818bcd7e02e7226db86377c041eb54ab85084d Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 4 Dec 2015 11:17:44 +0100 Subject: [PATCH 26/53] show and catch the origin --- src/GraphicView.cpp | 55 ++++++++++++++++++++++++++------------------ src/GraphicView.h | 3 --- src/graphicscene.cpp | 4 +++- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 5095a71..0bb0925 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -632,14 +632,14 @@ void jpsGraphicsView::use_gridmode() void jpsGraphicsView::catch_points() { - ///Searching for startpoints of all lines near the current cursor position + //Searching for startpoints of all lines near the current cursor position for (int i=0; iget_line()->line().x1()>=(translated_pos.x()-catch_radius) && line_vector[i]->get_line()->line().x1()<=(translated_pos.x()+catch_radius) && line_vector[i]->get_line()->line().y1()>=(translated_pos.y()-catch_radius) && line_vector[i]->get_line()->line().y1()<=(translated_pos.y()+catch_radius)){ - /// in this case the cursor is working with global coordinates. So the method 'mapToGlobal' must be used + // in this case the cursor is working with global coordinates. So the method 'mapToGlobal' must be used - ///to avoid the tracking of the coords of an edited line + //to avoid the tracking of the coords of an edited line if (line_vector[i]->get_line()==current_line) { continue; @@ -648,23 +648,23 @@ void jpsGraphicsView::catch_points() translated_pos.setX(line_vector[i]->get_line()->line().x1()); translated_pos.setY(line_vector[i]->get_line()->line().y1()); //cursor.setPos(mapToGlobal(QPoint(translate_back_x(line_vector[i].x1()),translate_back_y(line_vector[i].y1())))); - ///bool is used to tell paint device to draw a red rect if a point was tracked + //bool is used to tell paint device to draw a red rect if a point was tracked point_tracked=true; _currentTrackedPoint= &translated_pos; //QPen pen; //pen.setColor('red'); if (current_rect==nullptr) current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); - /// if a point was tracked there is no need to look for further points ( only one point can be tracked) + // if a point was tracked there is no need to look for further points ( only one point can be tracked) return; } - ///Searching for endpoints of all lines near the current cursor position + //Searching for endpoints of all lines near the current cursor position else if (line_vector[i]->get_line()->line().x2()>=(translated_pos.x()-catch_radius) && line_vector[i]->get_line()->line().x2()<=(translated_pos.x()+catch_radius) && line_vector[i]->get_line()->line().y2()>=(translated_pos.y()-catch_radius) && line_vector[i]->get_line()->line().y2()<=(translated_pos.y()+catch_radius)){ // see above - ///to avoid the tracking of the coords of an edited line + //to avoid the tracking of the coords of an edited line if (line_vector[i]->get_line()==current_line) { continue; @@ -681,9 +681,9 @@ void jpsGraphicsView::catch_points() return; } } - /// if no start- or endpoint was tracked it is searched for intersections- Points + // if no start- or endpoint was tracked it is searched for intersections- Points - /// see above + // see above for (int j=0; jx()>=(translated_pos.x()-catch_radius) && intersect_point_vector[j]->x()<=(translated_pos.x()+catch_radius) && intersect_point_vector[j]->y()>=(translated_pos.y()-catch_radius) && intersect_point_vector[j]->y()<=(translated_pos.y()+catch_radius)) @@ -696,6 +696,17 @@ void jpsGraphicsView::catch_points() return; } } + + // Catch origin + if (!_origin.isEmpty()) + if (std::fabs(translated_pos.x())<=catch_radius && std::fabs(translated_pos.y())<=catch_radius) + { + translated_pos.setX(0); + translated_pos.setY(0); + if (current_rect==nullptr) + current_rect=Scene->addRect(translated_pos.x()+translation_x-10*gl_scale_f,translated_pos.y()+translation_y-10*gl_scale_f,20*gl_scale_f,20*gl_scale_f,QPen(Qt::red,0)); + + } //Look for gridpoints // for (auto &gridpoint: grid_point_vector) @@ -720,7 +731,7 @@ void jpsGraphicsView::catch_points() // } // } - /// if no point was tracked bool is set back to false + // if no point was tracked bool is set back to false point_tracked=false; return; } @@ -1296,20 +1307,20 @@ void jpsGraphicsView::ShowOrigin() { if (_origin.isEmpty()) { - _origin.push_back(Scene->addLine(1,1,1/gl_scale_f*0.02,1,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1,1,1,1/gl_scale_f*0.02,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1,1/gl_scale_f*0.02,1-1/gl_scale_f*0.001,1/gl_scale_f*0.02-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1,1/gl_scale_f*0.02,1+1/gl_scale_f*0.001,1/gl_scale_f*0.02-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1-1/gl_scale_f*0.001,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1+1/gl_scale_f*0.001,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1/gl_scale_f*0.02,1,1/gl_scale_f*0.02-1/gl_scale_f*0.001,1+1/gl_scale_f*0.001,QPen(Qt::black,0.025))); + //Scene->DrawOrigin(); + _origin.push_back(Scene->addLine(0,0,0,0+gl_scale_f*100,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0-gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0+gl_scale_f*100,0+gl_scale_f*10,0+gl_scale_f*100-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0,0,0+gl_scale_f*100,0,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,-gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0+gl_scale_f*100,0,gl_scale_f*100-gl_scale_f*10,+gl_scale_f*10,QPen(Qt::black,gl_scale_f*2))); //Y - _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0005,1/gl_scale_f*0.0155,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0015,1/gl_scale_f*0.0155,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1-1/gl_scale_f*0.001,1/gl_scale_f*0.015,1-1/gl_scale_f*0.001,1/gl_scale_f*0.014,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*50,0-gl_scale_f*5,gl_scale_f*100-gl_scale_f*45,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*50,0-gl_scale_f*15,gl_scale_f*100-gl_scale_f*45,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*50,0-gl_scale_f*10,gl_scale_f*100-gl_scale_f*60,QPen(Qt::black,gl_scale_f*2))); //X - _origin.push_back(Scene->addLine(1/gl_scale_f*0.014,1-1/gl_scale_f*0.0017,1/gl_scale_f*0.015,1-1/gl_scale_f*0.0005,QPen(Qt::black,0.025))); - _origin.push_back(Scene->addLine(1/gl_scale_f*0.015,1-1/gl_scale_f*0.0017,1/gl_scale_f*0.014,1-1/gl_scale_f*0.0005,QPen(Qt::black,0.025))); + _origin.push_back(Scene->addLine(0+gl_scale_f*40,0-gl_scale_f*15,gl_scale_f*50,-gl_scale_f*5,QPen(Qt::black,gl_scale_f*2))); + _origin.push_back(Scene->addLine(0+gl_scale_f*40,0-gl_scale_f*5,gl_scale_f*50,-gl_scale_f*15,QPen(Qt::black,gl_scale_f*2))); for (QGraphicsLineItem* lineItem:_origin) { diff --git a/src/GraphicView.h b/src/GraphicView.h index 6b009b5..b1fe579 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -124,8 +124,6 @@ class jpsGraphicsView: public QGraphicsView { //RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); - - public slots: //Waypoints void StatAssoDef(); @@ -136,7 +134,6 @@ public slots: //Landmarks void unmarkLandmark(); - protected: //Mouse events virtual void mouseMoveEvent(QMouseEvent * mouseEvent); diff --git a/src/graphicscene.cpp b/src/graphicscene.cpp index 4bf1630..3600b99 100644 --- a/src/graphicscene.cpp +++ b/src/graphicscene.cpp @@ -51,7 +51,7 @@ void GraphicScene::drawBackground(QPainter *painter, const QRectF &rect) DrawLineGrid(painter,rect); else DrawPointGrid(painter,rect); - } + } } void GraphicScene::DrawLineGrid(QPainter *painter, const QRectF &rect) @@ -93,3 +93,5 @@ void GraphicScene::DrawPointGrid(QPainter *painter, const QRectF &rect) painter->drawPoints(points.data(), points.size()); } + + From 4289fcfda4c80600e1ac7484d2b88c462b72a601 Mon Sep 17 00:00:00 2001 From: "M.Osterkamp" Date: Tue, 8 Dec 2015 13:17:57 +0100 Subject: [PATCH 27/53] added to v0.8: mark all lines with str+a confirm before close window --- src/GraphicView.cpp | 9 +++++++++ src/GraphicView.h | 2 ++ src/mainWindow.cpp | 34 ++++++++++++++++++++++++---------- src/mainWindow.h | 2 +- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0bb0925..a0e6008 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -1421,6 +1421,15 @@ void jpsGraphicsView::RemoveIntersections(jpsLineItem *lineItem) } } +void jpsGraphicsView::SelectAllLines() +{ + marked_lines.clear(); + for (jpsLineItem* line:line_vector) + { + select_line(line); + } +} + void jpsGraphicsView::delete_landmark() { if (markedLandmark!=nullptr) diff --git a/src/GraphicView.h b/src/GraphicView.h index b1fe579..f687b4f 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -133,6 +133,8 @@ public slots: void ActivatePointGrid(); //Landmarks void unmarkLandmark(); + //Line operations + void SelectAllLines(); protected: //Mouse events diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 53fdeab..8bd928f 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -36,6 +36,7 @@ #include #include +#include MWindow :: MWindow() { @@ -88,7 +89,7 @@ MWindow :: MWindow() { //Signals and Slots // Tab File - connect(actionBeenden, SIGNAL(triggered(bool)),this,SLOT(quit()));//qApp,SLOT(quit())); + connect(actionBeenden, SIGNAL(triggered(bool)),this,SLOT(close())); connect(action_ffnen,SIGNAL(triggered(bool)),this,SLOT(openFile())); connect(action_ffnen_xml,SIGNAL(triggered(bool)),this,SLOT(openFileXML())); connect(actionSpeichern,SIGNAL(triggered(bool)),this,SLOT(saveFile())); @@ -124,6 +125,11 @@ MWindow :: MWindow() { connect(mview,SIGNAL(mouse_moved()),this,SLOT(show_coords())); connect(mview,SIGNAL(landmark_added()),this,SLOT(add_landmark())); connect(mview,SIGNAL(LineLengthChanged()),this,SLOT(ShowLineLength())); + // Mark all lines + QAction *str_a = new QAction(this); + str_a->setShortcut(Qt::Key_A | Qt::CTRL); + connect(str_a, SIGNAL(triggered(bool)), mview, SLOT(SelectAllLines())); + this->addAction(str_a); //connect(mview,SIGNAL(DoubleClick()),this,SLOT(en_selectMode())); // Autosave connect(timer, SIGNAL(timeout()), this, SLOT(AutoSave())); @@ -201,15 +207,6 @@ void MWindow::UpdateCMap() dmanager->ShowCMapFrame(_cMapFrame); } -void MWindow::quit() -{ - //MessageBox - //Wenn ja. - qApp->quit(); - //Wenn nein - //return to app -} - void MWindow::add_landmark() { jpsLandmark* landmark = mview->get_landmarks().last(); @@ -523,6 +520,23 @@ void MWindow::rotate() mview->rotate(-90); } +void MWindow::closeEvent(QCloseEvent *event) +{ + int ret = QMessageBox::warning( + this, "Quit?", + "Do you really want to quit?", + QMessageBox::Yes | QMessageBox::No ); + + if (ret == QMessageBox::Yes) + { + QMainWindow::closeEvent(event); + } + else + { + event->ignore(); + } +} + diff --git a/src/mainWindow.h b/src/mainWindow.h index d22ce94..cec9493 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -121,7 +121,7 @@ protected slots: void UpdateCMap(); //quit - void quit(); + void closeEvent(QCloseEvent *event); }; From 6184cce499f5bc7240a22dd95c696f9b30508492 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 8 Dec 2015 15:24:36 +0100 Subject: [PATCH 28/53] debugging delete marked lines --- src/GraphicView.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index a0e6008..8113632 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -738,9 +738,9 @@ void jpsGraphicsView::catch_points() void jpsGraphicsView::catch_lines() { - ///catch lines (only possible if wall is disabled) - /// if current rect was build up moving the cursor to the left -> - /// whole line has to be within the rect to select the line + //catch lines (only possible if wall is disabled) + // if current rect was build up moving the cursor to the left -> + // whole line has to be within the rect to select the line line_tracked=-1; if (currentSelectRect->rect().width()<0) { @@ -750,14 +750,14 @@ void jpsGraphicsView::catch_lines() && currentSelectRect->contains(item->get_line()->line().p2())) { select_line(item); - line_tracked=1; + } } } - /// if current rect was build up moving the cursor to the right -> - /// throwing the select rect only over a part of a line is sufficent to select it + // if current rect was build up moving the cursor to the right -> + // throwing the select rect only over a part of a line is sufficent to select it else if (currentSelectRect->rect().width()>0) { for (auto &item:line_vector) @@ -832,6 +832,7 @@ void jpsGraphicsView::select_line(jpsLineItem *mline) { mline->get_line()->setPen(QPen(Qt::red,0)); marked_lines.push_back(mline); + line_tracked=1; } else { From 6cc6e922df6cdc2f24ef1a2dbb0b1e26aa90a46b Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 15 Dec 2015 11:51:45 +0100 Subject: [PATCH 29/53] add CHANGELOG.md --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b6521f6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Change Log +All notable changes to this project will be documented in this file. + + +## v0.8.0 [Unreleased] + + +### Added +#### JPSEditor + +- Point Grid +- Line Grid +- Select all lines +- Edit Room Type +- Show and snap the origin \ No newline at end of file From dcea232773212e6dc3408d431409f9808b8df152 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 7 Jan 2016 14:51:50 +0100 Subject: [PATCH 30/53] Get ready for VS and changing window title --- CMakeLists.txt | 8 +++++--- forms/mainwindow.ui | 2 +- src/main.cpp | 8 ++++++++ src/mainWindow.cpp | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b09c304..66a2b08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ # 1. CMAKE_BUILD_TYPE=Release (default Debug) # 2. DESIRED_QT_VERSION=5 (default 4) # example: >> cmake -DDESIRED_QT_VERSION=5 -DCMAKE_PREFIX_PATH=~/Qt/5.5/clang_64 .. +# Flags for VS: -G "Visual Studio ..." -DCMAKE_PREFIX_PATH=... -DCMAKE_C_FLAGS="-mwindows" cmake_minimum_required(VERSION 2.8.9) IF (POLICY CMP0048) # in CMake 3.0.0+ @@ -70,6 +71,7 @@ message(STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}") #-------------------- +if (NOT MSVC) include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) @@ -81,7 +83,7 @@ else() message(AUTHOR_WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() message(STATUS "Checking for C++11 compiler - available") - +endif() #--------------------- set( SRCS @@ -166,7 +168,7 @@ ENDIF (WIN32) message(STATUS "QT_Qmake_executable " ${QT_QMAKE_EXECUTABLE}) if($QT_QMAKE_EXECUTABLE STREQUAL "") FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake) - if (NOT QT_QMAKE_EXECUTABL) + if (NOT QT_QMAKE_EXECUTABLE) message(WARNING "QT not found - abort.") endif() endif() @@ -199,7 +201,7 @@ elseif("${DESIRED_QT_VERSION}" STREQUAL "4") # QT4_INSTALLED is set to TRUE if qt4 is found and # QT3_INSTALLED is set to TRUE if qt3 is found. FIND_PACKAGE(Qt COMPONENTS QtXml QT_USE_QTNETWORK QtXmlPatterns REQUIRED) - + set(QT4_INSTALLED TRUE) endif() diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index e67b2c0..94eb76f 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -11,7 +11,7 @@ - JuPedSim + JPSeditor diff --git a/src/main.cpp b/src/main.cpp index 047ade3..9b8c61f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,14 @@ //main.cpp +#ifdef _MSC_VER +# ifdef NDEBUG +# pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") +# else +# pragma comment(linker, "/SUBSYSTEM:CONSOLE") +# endif +#endif + #include "mainWindow.h" #include "GraphicView.h" #include diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 8bd928f..a35ec68 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -69,6 +69,8 @@ MWindow :: MWindow() { //filename of saved project _filename=""; + //WindowTitle + this->setWindowTitle("JPSeditor"); setCentralWidget(mview); //this->setMaximumSize(1920,1080); From 6e3d1d6f77d5cc34c363154cde76944a430d363e Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 7 Jan 2016 15:45:32 +0100 Subject: [PATCH 31/53] removing the pragma comment --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 9b8c61f..b76ab58 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ //main.cpp - +/* for compiling a standalone windows exe with VS #ifdef _MSC_VER # ifdef NDEBUG # pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") @@ -35,6 +35,8 @@ # pragma comment(linker, "/SUBSYSTEM:CONSOLE") # endif #endif +*/ + #include "mainWindow.h" #include "GraphicView.h" From b7b910d5ca5363fed239bc58225cc5cf3819e1c8 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 8 Jan 2016 11:55:35 +0100 Subject: [PATCH 32/53] Fixed function ShowRoomType --- src/roomwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/roomwidget.cpp b/src/roomwidget.cpp index 793e55f..57d8a33 100644 --- a/src/roomwidget.cpp +++ b/src/roomwidget.cpp @@ -799,8 +799,9 @@ void roomWidget::ChangeRoomType() void roomWidget::ShowRoomType(int& cRow) const { QString type = datamanager->get_roomlist()[cRow]->get_type(); + int itemindex = ui->classBox->findText(type); + ui->classBox->setCurrentIndex(itemindex); - // ui->classBox->setCurrentText(type); } From 9051f0cf1b8dc204defc8cb6f7172653661600b0 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 8 Jan 2016 14:02:27 +0100 Subject: [PATCH 33/53] change cmake policy --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66a2b08..014574d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ ENDIF (POLICY CMP0048) IF (POLICY CMP0043) # in CMake 3.0.0+ CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables ENDIF (POLICY CMP0043) +CMAKE_POLICY (SET CMP0020 OLD) # keep old POLICY (2.8.10 and lower) The OLD behavior for this policy is not to link executables to + #qtmain.lib automatically when they link to the QtCore IMPORTEDtarget project(JPSeditor) From c370089c43a98395af4aba4c21782b8693560066 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 8 Jan 2016 14:07:21 +0100 Subject: [PATCH 34/53] if statement concerning cmake policy --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 014574d..69f0f49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,9 @@ ENDIF (POLICY CMP0048) IF (POLICY CMP0043) # in CMake 3.0.0+ CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables ENDIF (POLICY CMP0043) +IF (POLICY CMP0020) CMAKE_POLICY (SET CMP0020 OLD) # keep old POLICY (2.8.10 and lower) The OLD behavior for this policy is not to link executables to - #qtmain.lib automatically when they link to the QtCore IMPORTEDtarget +ENDIF (POLICY CMP0020) #qtmain.lib automatically when they link to the QtCore IMPORTEDtarget project(JPSeditor) From 7e236c6b45ddaa491d68ffb72e42c9292149a85e Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 8 Jan 2016 14:32:27 +0100 Subject: [PATCH 35/53] fix open xml --- src/datamanager.cpp | 8 ++++++++ src/mainWindow.cpp | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/datamanager.cpp b/src/datamanager.cpp index d731d70..d00d14c 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -860,6 +860,14 @@ bool jpsDatamanager::readXML(QFile &file) QXmlStreamReader xmlReader(&file); + // skip header + xmlReader.readNext(); + xmlReader.readNext(); + + // see if file starts with geometry + if (xmlReader.name() != "geometry") + return false; + while(!xmlReader.atEnd() && !xmlReader.hasError()) { /* Read next element.*/ diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index a35ec68..65a1742 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -265,16 +265,17 @@ void MWindow::openFileXML() QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QMessageBox::critical(this, - "OpenFileXML", - "Couldn't open xml-file", - QMessageBox::Ok); + return; } if (!dmanager->readXML(file)) { + QMessageBox::critical(this, + "OpenFileXML", + "Couldn't open xml-file", + QMessageBox::Ok); statusBar()->showMessage("XML-File could not be parsed!",10000); } From 3291695c88013c83a24bf19ea2bae09c997d5944 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 12 Jan 2016 11:41:50 +0100 Subject: [PATCH 36/53] dxf import with layers (Wall and Door) --- src/GraphicView.cpp | 1 + src/GraphicView.h | 4 ++++ src/datamanager.cpp | 8 +++++--- src/datamanager.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 8113632..531a296 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -1039,6 +1039,7 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } + void jpsGraphicsView::line_collision() ///FIX ME!!! { /// if no lines collided yet diff --git a/src/GraphicView.h b/src/GraphicView.h index f687b4f..2f6eddc 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -124,6 +124,8 @@ class jpsGraphicsView: public QGraphicsView { //RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); + + public slots: //Waypoints void StatAssoDef(); @@ -199,6 +201,8 @@ public slots: bool _assoDef; bool _gridmode; + + signals: void mouse_moved(); void set_focus_textedit(); diff --git a/src/datamanager.cpp b/src/datamanager.cpp index d00d14c..86cd8cb 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -1200,9 +1200,11 @@ bool jpsDatamanager::readDXF(std::string filename) void jpsDatamanager::addLine(const DL_LineData &d) { - - mView->addLineItem(d.x1,d.y1,d.x2,d.y2); - + DL_Attributes attributes = DL_CreationInterface::getAttributes(); + if (attributes.getLayer()=="Wall" || attributes.getLayer()=="Door") + mView->addLineItem(d.x1,d.y1,d.x2,d.y2,QString::fromStdString(attributes.getLayer())); + else + mView->addLineItem(d.x1,d.y1,d.x2,d.y2); } diff --git a/src/datamanager.h b/src/datamanager.h index 86f0fc4..cf9a036 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -170,6 +170,8 @@ class jpsDatamanager: public DL_CreationAdapter double _frameRate; int _lastCMapFrame; + + }; From 59f2ae9089623dbdf202302723aedd3ae2d4fcf3 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 12 Jan 2016 13:15:04 +0100 Subject: [PATCH 37/53] - layernames wall and door in upper and lower case is now possible (dxf import) - creating actionstack --- jpseditor.pro | 8 ++++++-- src/datamanager.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/jpseditor.pro b/jpseditor.pro index 4a77643..f065215 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -57,7 +57,9 @@ HEADERS += \ src/graphicscene.h \ src/widgetsettings.h \ src/jpsyahpointer.h \ - src/jpsconnection.h + src/jpsconnection.h \ + src/UndoFramework/actionstack.h \ + src/UndoFramework/paintaction.h SOURCES += \ @@ -79,7 +81,9 @@ SOURCES += \ src/graphicscene.cpp \ src/widgetsettings.cpp \ src/jpsyahpointer.cpp \ - src/jpsconnection.cpp + src/jpsconnection.cpp \ + src/UndoFramework/actionstack.cpp \ + src/UndoFramework/paintaction.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 86cd8cb..117bb25 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -1201,8 +1201,12 @@ bool jpsDatamanager::readDXF(std::string filename) void jpsDatamanager::addLine(const DL_LineData &d) { DL_Attributes attributes = DL_CreationInterface::getAttributes(); - if (attributes.getLayer()=="Wall" || attributes.getLayer()=="Door") - mView->addLineItem(d.x1,d.y1,d.x2,d.y2,QString::fromStdString(attributes.getLayer())); + std::string layername = attributes.getLayer(); + std::transform(layername.begin(), layername.end(), layername.begin(), ::tolower); + if (layername=="wall") + mView->addLineItem(d.x1,d.y1,d.x2,d.y2,"Wall"); + else if (layername=="door") + mView->addLineItem(d.x1,d.y1,d.x2,d.y2,"Door"); else mView->addLineItem(d.x1,d.y1,d.x2,d.y2); } From fc8af57cb13c20ef5f97726d1b358a01b48caa48 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 18 Jan 2016 17:32:01 +0100 Subject: [PATCH 38/53] add (copied) changelog and contribution guide --- CHANGELOG.md | 96 ++++++++++++++++++-- CONTRIBUTING.md | 228 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+), 6 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CHANGELOG.md b/CHANGELOG.md index b6521f6..bab618f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,94 @@ All notable changes to this project will be documented in this file. ### Added -#### JPSEditor +#### JPSCORE +- CI with travis and Gitlab CI +- Compilation checked on Visual Studio 12 2013 +- Added more validation tests +- Added statistics (calculate exit usage) for all exits +- Added voronoi based algorithm for inserting agents coming from the source or from matsim +- New option for the quickest path router. Sample options are: + `````` + `````` + ``` +``` +- New model with the generic name `Tordeux2015` and `id=3`. For use check the ini-files in the Utest-validation tests. +- Tests are sorted in `rimea_tests`, `juelich_tests` and `validation_tests`. +- Periodic boundary conditions with the option `1`.Works only with model 3. +- Added Floorfield to all exits, providing direction to target, direction to closest wall and cost estimates. Parameter to control wall-avoidance included. + +#### JPSVIS +- Added option to load vtk files. Need to add the line ``` +``` in the header of the trajectory file. Alternatively drag and drop a vtk file on JPSvis. + +- Fixed error displaying the total number of frames when using the scroolbar + +#### JPSREPORT +- Added geometry information while plotting the voronoi cells +- Added option to disable plotting +- Issue a warning when the voronoi cell cannot be calculated +- Fixed error where all trajectories were colinear -- Point Grid -- Line Grid -- Select all lines -- Edit Room Type -- Show and snap the origin \ No newline at end of file +#### JPSEDITOR + + +## v0.7.0 [2015-07-15] + +### New Module +- JuPedSim: Editor for the geometry + +### Added + +- Risk tolerance factor (value in [0 1]) for pedestrian. Pedestrians with high values are likely to take more risks. +- Added pre-movement time of the agents. Only after this time, the concerned agents will start moving. +- Sources for generating agents at runtime. Parameter are frequency (agents per seconds) and maximum number +- Option to color the pedestrians by group, spotlight, velocity, group, knowledge, router, final\_goal, intermediate\_goal. Usage: ( +``` ```) +- More control over the triangulation specially to avoid skinny triangles. Usage: `````` +- Improved statistics. The flow curve for the different exits can be computed at runtime. +- Changelog file +- Rimea testcases +- Unit tests are now based on the Boost testing engine +#### JPSVIS +- Display the geometry structure individual room/subroom. +- Now build on OSX/Linux/Windows + +### Changed +- +- + +### Fixed +- Visiblity in 3D +- Numerous geometrical operations + + +## v0.6.0 - 2015-01-31 +### Added +- Steering the simulation with predefined events (closing or opening doors during the simulation) +- Information sharing between the pedestrians. The agents now share their knowledge about closed doors. +- Pre evacuation time for groups of agents. +- Adjustable velocities on stairs and even terrain for group of agents. +- Stability and performance improvement. The simulation is approx 40% faster for larger scenarios and you will notice it +- New route choice model, cognitive map, giving agents the possibility to explore the environment and discover doors for instance. +- Different sensors for improving the navigation of pedestrians (smoke/jam sensor). +- New verification and validation tests. +- General statistics over the evacuation (for instance areas egress time and door usage) +- Support for Visual Studio and Xcode compilers. + + +### Changed +- refactor NumCPU and ExitCrossingStrategy tags to `num_threads and exit_crossing_strategy` + + + +## v0.5.0 - 2014-08-05 +First release of the the Juelich Pedestrian Simulator. Most noteworthy features: + +- Simulate pedestrians movement in a space continuous geometry +- Forces based models for describing the pedestrians interactions +- Shortest and quickest path route choice strategies +- Loading and visualizing trajectories and geometries +- Easy to use visualization interface +- Making high quality videos directly from the visualization interface or generating png sequences +- XML based input files \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d0e607c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,228 @@ +Contributing to JuPedSim +======================== + +This project is mainly developed by a small group of researchers and students from [Jülich Research Center](http://www.fz-juelich.de/en) and [BUW](http://www.uni-wuppertal.de/). +However you are kindly invited not only to use JuPedSim but also contributing to our open-source-project. +It does not matter if you are a researcher, student or just interested in pedestrian dynamics. +There are only a few rules and advices we want to give to you: + +- [Advice for new contributors](#advice-for-new-contributors) + - [First steps](#first-steps) + - [Guidelines](#guidelines) + - [FAQ](#faq) + +- [Reporting bugs and requesting features](#reporting-bugs-and-requesting-features) + - [Using the issue tracker](#using-the-issue-tracker) + - [Reporting bugs](#reporting-bugs) + - [Requesting features](#requesting-features) + +- [Writing code](#writing-code) + - [Coding style](#coding-style) + - Unit tests + +- [Writing documentation](#wrinting-documentation) + - [Comments](#comments) + - Documenting new features + +- [Committing code](#commiting-code) + - Handling pull/merge requests + - [Committing guidelines](#commiting-guidelines) + - Reverting commits + +## Advice for new contributors + +### First steps + +### Guidelines + +### FAQ + +## Reporting bugs and requesting features +If you got a question or a problem and need support from our team feel free to contact us. +You can do this via [email](mailto:dev@jupedsim.org). + +If you think you found an issue or bug in JuPedSim please use our issue tracker. + +### Using the issue tracker + +The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests, but please respect the following restrictions: + +- Please do not use the issue tracker for personal support requests. [Mail us](mailto:dev@jupedsim.org) if you need personal support. + +- Please do not derail or troll issues. Keep the discussion on topic and respect the opinions of others. + +If you use the issue tracker we have a list of labels you should use. + +### Reporting bugs + +If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue to our repository. +Even better you can submit a pull or merge request with a fix. Please use the following template and make sure you provide us as much information as possible: + +~~~.md +[Short description of problem here] + +**Reproduction Steps:** + +1. [First Step] +2. [Second Step] +3. [Other Steps...] + +**Expected behavior:** + +[Describe expected behavior here] + +**Observed behavior:** + +[Describe observed behavior here] + +**Screenshots and GIFs** + +![Screenshots and GIFs which follow reproduction steps to demonstrate the problem](url) + +**JuPedSim version:** [Enter JuPedSim version here] +**OS and version:** [Enter OS name and version here] +**Compiler and version:** [Enter compiler name and version here] + +**Installed Libraries:** +[Enter Boost version here] +[Enter Vtk version here] +[Enter Qt version here] + +**Additional information:** + +* Problem started happening recently, didn't happen in an older version of JuPedSim: [Yes/No] +* Problem can be reliably reproduced, doesn't happen randomly: [Yes/No] +* Problem happens with all files and projects, not only some files or projects: [Yes/No] +* Problem happens with the attached ini and geometry files: [Yes/No] +~~~ + +### Requesting features + +Enhancement suggestions are tracked as issues. After you've determined which repository your enhancement suggestions is related to, create an issue on that repository and provide the following information: + + * Use a clear and descriptive title for the issue to identify the suggestion. + * Provide a step-by-step description of the suggested enhancement in as many details as possible. + * Provide specific examples to demonstrate the steps. Include copy/pasteable snippets which you use in those examples, as Markdown code blocks. + * Describe the current behavior and explain which behavior you expected to see instead and why. + +If you want to support us by writing the enhancement yourself consider what kind of change it is: + +- **Major changes** that you wish to contribute to the project should be discussed first on our **dev mailing list** so that we can better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. +- **Small changes** can be crafted and submitted to our repository as a **pull or merge request**. + +Nevertheless open an issue for documentation purposes with the following template: + +~~~.md +[Short description of suggestion] + +**Steps which explain the enhancement** + +1. [First Step] +2. [Second Step] +3. [Other Steps...] + +**Current and suggested behavior** + +[Describe current and suggested behavior here] + +**Why would the enhancement be useful to most users** + +[Explain why the enhancement would be useful to most users] + +[List some other text editors or applications where this enhancement exists] + +**Screenshots and GIFs** + +![Screenshots and GIFs which demonstrate the steps or part of JuPedSim the enhancement suggestion is related to](url) + +**JuPedSim Version:** [Enter JuPedSim version here] +**OS and Version:** [Enter OS name and version here]~ + +~~~ + +## Writing Code + +### Coding style + +In JuPedSim we try to code according to the *Stroustrup* style of formatting/indenting. +If you want (or have) to write code in JuPedSim you really **need** to respect that style. +This is important not just aesthetically but also practically. Diff commits are much more clearer and cleaner. + +The code is formated using the automatic formatter [astyle](http://astyle.sourceforge.net/astyle.html) with the option `--style=stroustrup`: + +> Stroustrup style formatting/indenting uses stroustrup brackets. +> Brackets are broken from function definitions only. +> Brackets are attached to everything else including +> namespaces, classes, and statements within a function, arrays, structs, and enums. +> This style frequently is used with an indent of 5 spaces. + +Here is an **example:** + +```c++ +int Foo(bool isBar) +{ + if (isBar) { + bar(); + return 1; + } else + return 0; +} +``` + +#### Tabs vs Spaces +This can be a long and religious discussion, to make it short *DO NOT* use tabs, just spaces please. + +Here are some hints to configure your editor in order to use the *stroustrup* style + +- **Emacs**: + Add this to your ```.emacs``` +```lisp +(setq c-default-style "stroustrup" c-basic-offset 5) +(setq indent-tabs-mode nil) +``` +- **Vim**: + Set in your config file these variables +```javascript +:set autoindent +:set cindent +:set expandtab +:set shiftwidth=5 +:set softtabstop=5 +``` + +- **Eclipse**: + Here is a [plugin](http://astyleclipse.sourceforge.net/) for astyle in eclipse. + Read also + [How to change indentation width in eclipse?](https://superuser.com/questions/462221/how-do-i-reliably-change-the-indentation-width-in-eclipse) + +- **Clion** + + + +## Writing Documentation + +### Comments +Comments have to be written in **English** everywhere. Please use markdown where applicable. + +## Commiting Code + +### Commiting guidelines +Please write clear and concise commit messages so that +your co-developers can directly grasp what changes on the code are you committing/pushing. Please do this with respect +to the following points: +- Name every class (file if you only change a single file) you changed and right after that a brief description of your +change. +- Use markdown if you want do make a longer description than two sentences. +- Reference issues and pull requests liberally if your commit is connected to one. +- When only changing documentation start with `:memo:` +- Consider starting the commit message with an applicable emoji: + - :art: `:art:` when improving the format/structure of the code + - :racehorse: `:racehorse:` when improving performance + - :memo: `:memo:` when writing docs + - :penguin: `:penguin:` when fixing something on Linux + - :apple: `:apple:` when fixing something on Mac OS + - :checkered_flag: `:checkered_flag:` when fixing something on Windows + - :bug: `:bug:` when fixing a bug + - :fire: `:fire:` when removing code or files + - :green_heart: `:green_heart:` when fixing the CI build + - :white_check_mark: `:white_check_mark:` when adding tests \ No newline at end of file From c9703fcc4105462443fa184e0b820345aa5c0ab9 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Tue, 19 Jan 2016 15:09:38 +0100 Subject: [PATCH 39/53] working on undo framework (issue #25) --- jpseditor.pro | 6 ++++-- src/GraphicView.cpp | 18 ++++++++++++++++++ src/GraphicView.h | 9 ++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/jpseditor.pro b/jpseditor.pro index f065215..9562618 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -59,7 +59,8 @@ HEADERS += \ src/jpsyahpointer.h \ src/jpsconnection.h \ src/UndoFramework/actionstack.h \ - src/UndoFramework/paintaction.h + src/UndoFramework/paintaction.h \ + src/UndoFramework/action.h SOURCES += \ @@ -83,7 +84,8 @@ SOURCES += \ src/jpsyahpointer.cpp \ src/jpsconnection.cpp \ src/UndoFramework/actionstack.cpp \ - src/UndoFramework/paintaction.cpp + src/UndoFramework/paintaction.cpp \ + src/UndoFramework/action.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 531a296..6bf33a1 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -1039,6 +1039,24 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } +void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLine &oldLine) +{ + _undoStack.PushNewAction(LineAction(name,type,oldLine)); +} + +void jpsGraphicsView::Undo() +{ + const LineAction recentAction = _undoStack.GetRecentAction(); + + + if (recentAction.GetName()=="LineDeleted") + addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), + recentAction.GetOldLine().p2().y(),recentAction.GetType()); + + _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLine(0,0,0,0))); + +} + void jpsGraphicsView::line_collision() ///FIX ME!!! { diff --git a/src/GraphicView.h b/src/GraphicView.h index 2f6eddc..3d939af 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -36,6 +36,8 @@ #include "jpsLineItem.h" #include "jpslandmark.h" #include "jpsconnection.h" +#include "./UndoFramework/actionstack.h" + using ptrConnection = std::shared_ptr; class jpsGraphicsView: public QGraphicsView { @@ -124,7 +126,9 @@ class jpsGraphicsView: public QGraphicsView { //RoomCaption bool show_hide_roomCaption(QString name, qreal x, qreal y); - + //Undo Framework + void RecordLineAction(const QString &name, const QString &type, const QLine& oldLine); + void Undo(); public slots: //Waypoints @@ -201,6 +205,9 @@ public slots: bool _assoDef; bool _gridmode; + //Undo/Redo + ActionStack _undoStack; + ActionStack _redoStack; signals: From 1dfc94d0aa1730c6028851da733624218441d542 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 20 Jan 2016 09:46:07 +0100 Subject: [PATCH 40/53] Adding :new: --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0e607c..67245f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -216,6 +216,7 @@ change. - Reference issues and pull requests liberally if your commit is connected to one. - When only changing documentation start with `:memo:` - Consider starting the commit message with an applicable emoji: + - :new: `:new:` when adding a new feature - :art: `:art:` when improving the format/structure of the code - :racehorse: `:racehorse:` when improving performance - :memo: `:memo:` when writing docs From dc028ef8ab03f86e26699b2154c8191f1dcf854f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 20 Jan 2016 14:20:00 +0100 Subject: [PATCH 41/53] :new: Start Undo Framework --- .idea/.name | 1 + forms/Ressource.qrc | 1 + forms/Undo-icon.png | Bin 0 -> 23524 bytes forms/mainwindow.ui | 23 +++++++++++++++++++++++ src/GraphicView.cpp | 10 ++++++++-- src/GraphicView.h | 6 ++++-- src/UndoFramework/action.cpp | 30 ++++++++++++++++++++++++++++++ src/UndoFramework/action.h | 23 +++++++++++++++++++++++ src/UndoFramework/actionstack.cpp | 23 +++++++++++++++++++++++ src/UndoFramework/actionstack.h | 20 ++++++++++++++++++++ src/UndoFramework/paintaction.cpp | 22 ++++++++++++++++++++++ src/UndoFramework/paintaction.h | 19 +++++++++++++++++++ src/mainWindow.cpp | 3 ++- 13 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 .idea/.name create mode 100644 forms/Undo-icon.png create mode 100644 src/UndoFramework/action.cpp create mode 100644 src/UndoFramework/action.h create mode 100644 src/UndoFramework/actionstack.cpp create mode 100644 src/UndoFramework/actionstack.h create mode 100644 src/UndoFramework/paintaction.cpp create mode 100644 src/UndoFramework/paintaction.h diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..d2398cc --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +jupedsim \ No newline at end of file diff --git a/forms/Ressource.qrc b/forms/Ressource.qrc index c9b94b3..647c8bb 100644 --- a/forms/Ressource.qrc +++ b/forms/Ressource.qrc @@ -39,5 +39,6 @@ statue.jpg statue_specs.jpg anglesnap.PNG + Undo-icon.png diff --git a/forms/Undo-icon.png b/forms/Undo-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b9994fc9040a3c99b19e61b291f6f5bcaf3c62d3 GIT binary patch literal 23524 zcmZ5{XEnpU!@sbIx=2-fQi5t@W<=L>cI5U8CZl0s!FJ18w#H0049~1OYJe ztBd8Uug?L%qUeFTs*&&HRv-nMt25jLcTakkPRYis#;txz;(L4^GOyD4zI=>pGLtET-V z+AOZ7yRBIC*+iZ9Y3`U^~n~iRxs}| zdqFT+;88gtYu@!(5R`~l=aat0K;HrdtHPk|Ys!G?{=dBlXlo88K76k86Fs%xVN7*P z&9h_t$Y(esN)#r8v9`4agn$vA=h|)$ni4pJxBW3YPtKeo_Y0`*F=)9{3)J5CGh<+8 zS*GsjQtysXodr7lxDylE(ir19!UK=x%~_*`%b4V>RQwV7TrQKn&jxEUKBDAftRZ(;uQWQYA79V^;K{%i^iTG)1*#Cc4PWBO-D&ZdvhrYzF#&P|oxU~|0!4Y<o!YGrV!~4D-#K!Qa^n6&Q{%w-#<#c#){WH9{yt9xr$*Nh0b`s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cJ(06A3IW{mq}$g~j@89B>< zuYb>K`}iu~SSnt2LP=CiWTGvfG}97a<1RHYT2k-ZsSQY3;4CP-#N%Fr;W@Sqn7yU; zDr1I7RKxckO)fbYx*4+!eeL;aWwGUiqhL>n>+Gc8Z%LQi3QKe^`f6{8`WMAx<-Z&B zrNNST=p^lAuM&h+i2d);_nE<7+S7gSzPc`=3B zPe-tpxW$yzQm|#h%SJYT+`nV37I&wgHo?m)Q`#tF#(_UIkJ^_f`|s$td#>ecq?Vt_ zHbs(Z1;RvO&7Ce}TSxGs-Cd1lnxQ+$pS8V~sxp=Akr6uXjC{LSTu}RPvCY(pi5owZ z{Uy$Gnc3}cto=;-B{lg1VEJ}6_6TWnAMe?;X$YJo)oi296{!59W5&KC#Z2SqY2lkQ zm`{E$h6A0%cHg7O(8+X)n1c5h#M1MW)%YJ_yq@&sg;Z@B%$@k?&jLU*rNfzG$O~ac zJG1Cl=ev?>W^Zc=E)Q*0-R>nAgc#n{cn^p{)Jeb*^}nKWfc)C=`qM9x$pv zgQ&lhAcfZp;Q0-;#Z*i3|L^;3ag-y?@!HZ1e%+9HDP?7`=VMX6l#4o-cch=~P3c1L z)`zuUW(4IP-HB79B&xQNz0QPn?_8aTYT8Qmhk|*1=~l0?C>c_Js*|0XC3<~4>S%Qj uHzZSH5&M75OMtNNB5(XH=;^C4F&@XGxMhEDm_q2?z~zhA^a^zB!u}6yr3otl literal 0 HcmV?d00001 diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 94eb76f..4258bd9 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -100,6 +100,8 @@ + + @@ -503,6 +505,27 @@ Show Point of Origin + + + true + + + + Undo-icon.pngUndo-icon.png + + + Undo + + + Undo + + + Ctrl+Z + + + true + + diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 6bf33a1..f5a0d46 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -1039,7 +1039,7 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } -void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLine &oldLine) +void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLineF &oldLine) { _undoStack.PushNewAction(LineAction(name,type,oldLine)); } @@ -1053,7 +1053,7 @@ void jpsGraphicsView::Undo() addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), recentAction.GetOldLine().p2().y(),recentAction.GetType()); - _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLine(0,0,0,0))); + _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0))); } @@ -1405,6 +1405,12 @@ void jpsGraphicsView::delete_marked_lines() } + QString type; + if (marked_lines.back()->is_Door()) + type = "Door"; + else + type = "Wall"; + RecordLineAction("LineDeleted",type,marked_lines.back()->get_line()->line()); marked_lines.clear(); //intersect_point_vector.clear(); diff --git a/src/GraphicView.h b/src/GraphicView.h index 3d939af..aead041 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -127,8 +127,8 @@ class jpsGraphicsView: public QGraphicsView { bool show_hide_roomCaption(QString name, qreal x, qreal y); //Undo Framework - void RecordLineAction(const QString &name, const QString &type, const QLine& oldLine); - void Undo(); + void RecordLineAction(const QString &name, const QString &type, const QLineF &oldLine); + public slots: //Waypoints @@ -141,6 +141,8 @@ public slots: void unmarkLandmark(); //Line operations void SelectAllLines(); + //Undo Redo + void Undo(); protected: //Mouse events diff --git a/src/UndoFramework/action.cpp b/src/UndoFramework/action.cpp new file mode 100644 index 0000000..43f7b4b --- /dev/null +++ b/src/UndoFramework/action.cpp @@ -0,0 +1,30 @@ +#include "action.h" + +Action::Action() +{ + +} + +Action::Action(const QString &name, const QString &type) +{ + _name=name; + _type=type; + + +} + +Action::~Action() +{ + +} + +const QString &Action::GetName() const +{ + return _name; + +} + +const QString &Action::GetType() const +{ + return _type; +} diff --git a/src/UndoFramework/action.h b/src/UndoFramework/action.h new file mode 100644 index 0000000..c38c6d6 --- /dev/null +++ b/src/UndoFramework/action.h @@ -0,0 +1,23 @@ +#ifndef ACTION_H +#define ACTION_H +#include + +class Action +{ +public: + Action(); + Action(const QString& name, const QString& type); + ~Action(); + //Getter + const QString& GetName() const; + const QString& GetType() const; + + +private: + QString _name; + QString _type; + + +}; + +#endif // ACTION_H diff --git a/src/UndoFramework/actionstack.cpp b/src/UndoFramework/actionstack.cpp new file mode 100644 index 0000000..420c9c1 --- /dev/null +++ b/src/UndoFramework/actionstack.cpp @@ -0,0 +1,23 @@ +#include "actionstack.h" + +ActionStack::ActionStack() +{ + +} + +ActionStack::~ActionStack() +{ + +} + +LineAction ActionStack::GetRecentAction() +{ + return _actionstack.pop(); +} + +void ActionStack::PushNewAction(const LineAction &action) +{ + _actionstack.push_back(action); + +} + diff --git a/src/UndoFramework/actionstack.h b/src/UndoFramework/actionstack.h new file mode 100644 index 0000000..3a677f1 --- /dev/null +++ b/src/UndoFramework/actionstack.h @@ -0,0 +1,20 @@ +#ifndef ACTIONSTACK_H +#define ACTIONSTACK_H + +#include +#include "action.h" +#include "paintaction.h" + +class ActionStack +{ +public: + ActionStack(); + ~ActionStack(); + + LineAction GetRecentAction(); + void PushNewAction(const LineAction& action); +private: + QStack _actionstack; +}; + +#endif // ACTIONSTACK_H diff --git a/src/UndoFramework/paintaction.cpp b/src/UndoFramework/paintaction.cpp new file mode 100644 index 0000000..d40877c --- /dev/null +++ b/src/UndoFramework/paintaction.cpp @@ -0,0 +1,22 @@ +#include "paintaction.h" + +LineAction::LineAction() +{ + +} + +LineAction::LineAction(const QString &name, const QString &type, const QLineF &oldLine) : Action(name,type) +{ + _oldLine=oldLine; +} + +LineAction::~LineAction() +{ + +} + +QLineF LineAction::GetOldLine() const +{ + return _oldLine; +} + diff --git a/src/UndoFramework/paintaction.h b/src/UndoFramework/paintaction.h new file mode 100644 index 0000000..d87f0a3 --- /dev/null +++ b/src/UndoFramework/paintaction.h @@ -0,0 +1,19 @@ +#ifndef PAINTACTION_H +#define PAINTACTION_H + +#include "action.h" +#include + +class LineAction : public Action +{ +public: + LineAction(); + LineAction(const QString& name, const QString& type, const QLineF& oldLine); + ~LineAction(); + + QLineF GetOldLine() const; +private: + QLineF _oldLine; +}; + +#endif // PAINTACTION_H diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 65a1742..7b1d525 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -143,7 +143,8 @@ MWindow :: MWindow() { //CMap connect(actionRun_visualisation,SIGNAL(triggered(bool)),this,SLOT(RunCMap())); connect(_cMapTimer,SIGNAL(timeout()),this,SLOT(UpdateCMap())); - + //Undo + //connect(actionUndo,SIGNAL(triggered(bool)),mview,SLOT(Undo())); } MWindow::~MWindow() From 4967cb59fed4758add03dec1df47ff97acbf552c Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 20 Jan 2016 15:03:24 +0100 Subject: [PATCH 42/53] Take out Undo Framework again since the code is not compiling on mac --- forms/mainwindow.ui | 4 ++-- src/GraphicView.cpp | 30 +++++++++++++++--------------- src/GraphicView.h | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 4258bd9..6a1b77b 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -510,8 +510,8 @@ true - - Undo-icon.pngUndo-icon.png + + :/Undo-icon.png:/Undo-icon.png Undo diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index f5a0d46..2f8e26b 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -229,7 +229,7 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) } else { - ///LineEdit + //LineEdit if (_currentTrackedPoint!=nullptr && line_tracked==1) { EditLine(_currentTrackedPoint); @@ -238,7 +238,7 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) } else { - ///Select_mode + //Select_mode currentSelectRect=Scene->addRect(translated_pos.x(),translated_pos.y(),0,0,QPen(Qt::blue,0)); currentSelectRect->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); leftbutton_hold=true; @@ -1039,23 +1039,23 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } -void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLineF &oldLine) -{ - _undoStack.PushNewAction(LineAction(name,type,oldLine)); -} +//void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLineF &oldLine) +//{ +// _undoStack.PushNewAction(LineAction(name,type,oldLine)); +//} -void jpsGraphicsView::Undo() -{ - const LineAction recentAction = _undoStack.GetRecentAction(); +//void jpsGraphicsView::Undo() +//{ +// const LineAction recentAction = _undoStack.GetRecentAction(); - if (recentAction.GetName()=="LineDeleted") - addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), - recentAction.GetOldLine().p2().y(),recentAction.GetType()); +// if (recentAction.GetName()=="LineDeleted") +// addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), +// recentAction.GetOldLine().p2().y(),recentAction.GetType()); - _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0))); +// _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0))); -} +//} void jpsGraphicsView::line_collision() ///FIX ME!!! @@ -1410,7 +1410,7 @@ void jpsGraphicsView::delete_marked_lines() type = "Door"; else type = "Wall"; - RecordLineAction("LineDeleted",type,marked_lines.back()->get_line()->line()); + //RecordLineAction("LineDeleted",type,marked_lines.back()->get_line()->line()); marked_lines.clear(); //intersect_point_vector.clear(); diff --git a/src/GraphicView.h b/src/GraphicView.h index aead041..5466f7c 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -127,7 +127,7 @@ class jpsGraphicsView: public QGraphicsView { bool show_hide_roomCaption(QString name, qreal x, qreal y); //Undo Framework - void RecordLineAction(const QString &name, const QString &type, const QLineF &oldLine); + //void RecordLineAction(const QString &name, const QString &type, const QLineF &oldLine); public slots: @@ -142,7 +142,7 @@ public slots: //Line operations void SelectAllLines(); //Undo Redo - void Undo(); + //void Undo(); protected: //Mouse events From a6ed6651b31fc888564446659112a38d4593849f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Wed, 20 Jan 2016 15:19:16 +0100 Subject: [PATCH 43/53] Forgot to remove Actionstack in GRAPHICVIEW_H --- src/GraphicView.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GraphicView.h b/src/GraphicView.h index 5466f7c..5f8d6be 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -208,8 +208,8 @@ public slots: bool _gridmode; //Undo/Redo - ActionStack _undoStack; - ActionStack _redoStack; + //ActionStack _undoStack; + //ActionStack _redoStack; signals: From 5fdcfa449c57b1ddca7b1e3d470335cc937b17e7 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 28 Jan 2016 11:27:29 +0100 Subject: [PATCH 44/53] :new: Creation of HLines (automatic detection of belonging room) :memo: edit changelog, authors and readme --- AUTHORS | 12 ++ CHANGELOG.md | 104 +++------------- README.md | 71 +++-------- forms/Ressource.qrc | 1 + forms/mainwindow.ui | 41 ++++++ jpseditor.pro | 8 +- src/GraphicView.cpp | 155 ++++++++++++++++++----- src/GraphicView.h | 18 ++- src/UndoFramework/actionstack.cpp | 7 +- src/UndoFramework/actionstack.h | 3 +- src/UndoFramework/paintaction.cpp | 22 ---- src/UndoFramework/paintaction.h | 19 --- src/datamanager.cpp | 200 ++++++++++++++++++++++-------- src/datamanager.h | 8 +- src/jpsLineItem.cpp | 32 ++++- src/jpsLineItem.h | 6 +- src/jpscrossing.cpp | 2 + src/mainWindow.cpp | 22 +++- src/mainWindow.h | 1 + src/rooms.cpp | 52 +++++--- src/rooms.h | 10 +- src/roomwidget.cpp | 26 ++-- src/roomwidget.h | 4 +- 23 files changed, 513 insertions(+), 311 deletions(-) delete mode 100644 src/UndoFramework/paintaction.cpp delete mode 100644 src/UndoFramework/paintaction.h diff --git a/AUTHORS b/AUTHORS index 89b7a4a..a56f59a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,11 +1,23 @@ JuPedSim contributors: +(Date: 27.01.2016) Erik Andresen Mohcine Chraibi +Arne Graf David Haensel +Weichen Liao Ulrich Kemloh +Maximilian Osterkamp Andrea Portz Oliver Schmidts +Benjamin Schröder Denis Shhikhalev +Antoine Tordeux Jun Zhang +JPSeditor contributors: +(Date: 27.01.2016) + +Erik Andresen +Maximilian Osterkamp + diff --git a/CHANGELOG.md b/CHANGELOG.md index bab618f..e9318ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,94 +6,18 @@ All notable changes to this project will be documented in this file. ### Added -#### JPSCORE -- CI with travis and Gitlab CI -- Compilation checked on Visual Studio 12 2013 -- Added more validation tests -- Added statistics (calculate exit usage) for all exits -- Added voronoi based algorithm for inserting agents coming from the source or from matsim -- New option for the quickest path router. Sample options are: - `````` - `````` - ``` -``` -- New model with the generic name `Tordeux2015` and `id=3`. For use check the ini-files in the Utest-validation tests. -- Tests are sorted in `rimea_tests`, `juelich_tests` and `validation_tests`. -- Periodic boundary conditions with the option `1`.Works only with model 3. -- Added Floorfield to all exits, providing direction to target, direction to closest wall and cost estimates. Parameter to control wall-avoidance included. - -#### JPSVIS -- Added option to load vtk files. Need to add the line ``` -``` in the header of the trajectory file. Alternatively drag and drop a vtk file on JPSvis. - -- Fixed error displaying the total number of frames when using the scroolbar - -#### JPSREPORT -- Added geometry information while plotting the voronoi cells -- Added option to disable plotting -- Issue a warning when the voronoi cell cannot be calculated -- Fixed error where all trajectories were colinear - #### JPSEDITOR - - -## v0.7.0 [2015-07-15] - -### New Module -- JuPedSim: Editor for the geometry - -### Added - -- Risk tolerance factor (value in [0 1]) for pedestrian. Pedestrians with high values are likely to take more risks. -- Added pre-movement time of the agents. Only after this time, the concerned agents will start moving. -- Sources for generating agents at runtime. Parameter are frequency (agents per seconds) and maximum number -- Option to color the pedestrians by group, spotlight, velocity, group, knowledge, router, final\_goal, intermediate\_goal. Usage: ( -``` ```) -- More control over the triangulation specially to avoid skinny triangles. Usage: `````` -- Improved statistics. The flow curve for the different exits can be computed at runtime. -- Changelog file -- Rimea testcases -- Unit tests are now based on the Boost testing engine -#### JPSVIS -- Display the geometry structure individual room/subroom. -- Now build on OSX/Linux/Windows - -### Changed -- -- - -### Fixed -- Visiblity in 3D -- Numerous geometrical operations - - -## v0.6.0 - 2015-01-31 -### Added -- Steering the simulation with predefined events (closing or opening doors during the simulation) -- Information sharing between the pedestrians. The agents now share their knowledge about closed doors. -- Pre evacuation time for groups of agents. -- Adjustable velocities on stairs and even terrain for group of agents. -- Stability and performance improvement. The simulation is approx 40% faster for larger scenarios and you will notice it -- New route choice model, cognitive map, giving agents the possibility to explore the environment and discover doors for instance. -- Different sensors for improving the navigation of pedestrians (smoke/jam sensor). -- New verification and validation tests. -- General statistics over the evacuation (for instance areas egress time and door usage) -- Support for Visual Studio and Xcode compilers. - - -### Changed -- refactor NumCPU and ExitCrossingStrategy tags to `num_threads and exit_crossing_strategy` - - - -## v0.5.0 - 2014-08-05 -First release of the the Juelich Pedestrian Simulator. Most noteworthy features: - -- Simulate pedestrians movement in a space continuous geometry -- Forces based models for describing the pedestrians interactions -- Shortest and quickest path route choice strategies -- Loading and visualizing trajectories and geometries -- Easy to use visualization interface -- Making high quality videos directly from the visualization interface or generating png sequences -- XML based input files \ No newline at end of file +- First approaches of an undo/redo framework + - Undo/Redo working when line added or deleted +- DXF import with different layers - Not working properly with AutoCAD ?! +- Bug fixes +- CAD features + - Point and line grid + - object snap + - Orthomode + - Zooming + - Line editing + - Length of line is displayed + - ... +- Room and door declarations + diff --git a/README.md b/README.md index 4c04dd7..c99fd77 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,33 @@ -JuPedSim v0.6 alpha +JuPedSim v0.8 alpha +JPSeditor v0.8 alpha ==================== -Ulrich Kemloh drafted this on 25 Jun 2014 +Erik Andresen drafted this on 27 Jun 2016 -We are proud to announce the first alpha release of our software JuPedSim for simulating pedestrians evacuations. Please note that it is a pre release version for developers only. We are working hard towards the final release for this version. Two modules are shipped with this pre-release: +We are proud to announce the first alpha release of our software JPSeditor (part of JuPedSim for simulating pedestrians evacuations). Please note that it is a pre release version for developers only. We are working hard towards the final release for this version. + +JPSeditor is a graphical user interface to create the geometry of a scenario simulated by JuPedSim. It comes with set of CAD- and further tools to simplify the creation of proper xml-files +incorporating information about the scenario' geometry. -- *jpscore*: command line simulation core -- *jpsvis*: visualization module Features ======== -- Simulate pedestrians movement in a space continuous geometry -- Forces-based models for describing the pedestrians interactions -- Shortest and quickest path route choice strategies -- Loading and visualizing trajectories and geometries -- Easy to use visualization interface -- Making high quality videos directly from the visualization interface or generating png screenshots -- XML based input files +- DXF Import / Export +- CAD features + - Point and line grid + - object snap + - Orthomode + - Zooming + - Line editing + - ... +- Tools for room and door declarations -Showcase +Tutorial ======== -To highlight some features of JuPedSim we have uploaded some videos on our [YouTube channel](https://www.youtube.com/user/JuPedSim). +To highlight some features of JuPedSim we have uploaded some videos on our [YouTube channel](https://www.youtube.com/user/JuPedSim) including a tutorial showing how to use the editor. Installing @@ -39,39 +43,7 @@ As JuPedSim comes with no installer, you just need to delete the unziped directo Running ======= - jpscore.exe my_simulation_ini.xml - -from the command line (or also dropping the file on the executable) will generate a trajectory file, which you can visualize with `jpsvis`. -You will find some projects samples in the downloaded files and further information in the manual. - -Compiling from sources -====================== - -You can compile the simulation core for your specific platform with the supplied cmake script. -The only requirement is a compiler supporting the new standard c++11. - -Windows (tested on Win7 with MinGW 4.8) ---------------------------------------- - - cmake -G "MinGW Makefiles" CMakeList.txt - make-mingw32.exe - -Linux (tested on Ubuntu 14.04 with gcc 4.8) ---------------- - - cmake CMakeList.txt - make - -OSX (tested on OSX Maverick with clang 5.1 and Yosemite with clang 6.1) ---------------------- - - cmake CMakeList.txt - make - -Note that the OpenMP acceleration might be missing under OSX - -For the visualization module (`jpsvis`) at least Qt version 4.5 and VTK version 4.8 are required. -You can download the latest version of QT [here](https://www.qt.io/download/) and the latest version of VTK [here](http://www.vtk.org/download/). +Start the application by clicking on the binary file. (For example .exe) System Requirements ============== @@ -79,11 +51,6 @@ System Requirements There is no special hardware/software requirements for running JuPedSim. The distributed binaries however, are only available for windows at the moment. For compiling from sources you need a compiler with c++11 support is needed for the core. Qt version >=4.5 and VTK >5.8 are needed for the visualization. -Known Issues -============ - -Some verification tests are still failing. The actual cdash-board can be found [here](http://my.cdash.org/index.php?project=JuPedSim) -Occasionaly jpscore crashes if the input file is not valid. Make sure to validate your XML input files with the supplied XSD files. Frequently Asked Questions =========================== diff --git a/forms/Ressource.qrc b/forms/Ressource.qrc index 647c8bb..ecefdd3 100644 --- a/forms/Ressource.qrc +++ b/forms/Ressource.qrc @@ -40,5 +40,6 @@ statue_specs.jpg anglesnap.PNG Undo-icon.png + Redo-Icon.png diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 6a1b77b..97af0c1 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -101,9 +101,11 @@ + + @@ -526,6 +528,45 @@ true + + + + :/Redo-Icon.png:/Redo-Icon.png + + + Redo + + + Redo + + + Ctrl+U + + + + + true + + + true + + + + :/Wall.png:/Wall.png + + + HLine + + + HLine + + + H + + + true + + diff --git a/jpseditor.pro b/jpseditor.pro index 9562618..7186b31 100644 --- a/jpseditor.pro +++ b/jpseditor.pro @@ -59,8 +59,8 @@ HEADERS += \ src/jpsyahpointer.h \ src/jpsconnection.h \ src/UndoFramework/actionstack.h \ - src/UndoFramework/paintaction.h \ - src/UndoFramework/action.h + src/UndoFramework/action.h \ + src/UndoFramework/lineaction.h SOURCES += \ @@ -84,8 +84,8 @@ SOURCES += \ src/jpsyahpointer.cpp \ src/jpsconnection.cpp \ src/UndoFramework/actionstack.cpp \ - src/UndoFramework/paintaction.cpp \ - src/UndoFramework/action.cpp + src/UndoFramework/action.cpp \ + src/UndoFramework/lineaction.cpp RESOURCES += forms/Ressource.qrc diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 2f8e26b..1bbc9fb 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -64,6 +64,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) statWall=false; statDoor=false; statExit=false; + _statHLine=false; statLandmark=false; markedLandmark=nullptr; currentLandmarkRect=nullptr; @@ -206,9 +207,9 @@ void jpsGraphicsView::mousePressEvent(QMouseEvent *mouseEvent) if (mouseEvent->button() == Qt::LeftButton) { - if (statWall==true || statDoor==true || statExit==true) + if (statWall || statDoor || statExit || _statHLine) { - /// If line is edited currently + // If line is edited currently if (_statLineEdit) { for (jpsLineItem* line:line_vector) @@ -774,11 +775,11 @@ void jpsGraphicsView::catch_lines() void jpsGraphicsView::drawLine() { - if (current_line==nullptr) /// if the mouse was pressed first of two times + if (current_line==nullptr) // if the mouse was pressed first of two times { - ///Determining first point of line + //Determining first point of line - /// all two points of the line are inited with the cursorcoordinates + // all two points of the line are inited with the cursorcoordinates current_line = Scene->addLine(translated_pos.x(),translated_pos.y(),translated_pos.x(),translated_pos.y(),currentPen); //current_line->translate(translation_x,translation_y); current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); @@ -804,19 +805,22 @@ void jpsGraphicsView::drawLine() } } - lineItem->set_type(statWall,statDoor,statExit); + lineItem->set_type(statWall,statDoor,statExit,_statHLine); line_vector.push_back(lineItem); - ///reset pointer + //reset pointer current_line=nullptr; + //Undo + RecordUndoLineAction("LineAdded",lineItem->GetType(),lineItem->get_line()->line()); + drawLine(); } - ///Vline + //Vline if (_currentVLine!=nullptr) { delete _currentVLine; @@ -849,16 +853,16 @@ void jpsGraphicsView::disable_drawing() statExit=false; statLandmark=false; _statLineEdit=false; - /// if drawing was canceled by pushing ESC + // if drawing was canceled by pushing ESC if (current_line!=nullptr) { - ///not completed line will be deleted + //not completed line will be deleted delete current_line; current_line=nullptr; } if (_currentVLine!=nullptr) { - ///VLine will be deleted + //VLine will be deleted delete _currentVLine; _currentVLine=nullptr; } @@ -910,6 +914,11 @@ jpsLineItem* jpsGraphicsView::addLineItem(const qreal &x1,const qreal &y1,const } +jpsLineItem *jpsGraphicsView::addLineItem(const QLineF &line, const QString &type) +{ + return addLineItem(line.p1().x(),line.p1().y(),line.p2().x(),line.p2().y(),type); +} + void jpsGraphicsView::locate_intersection(jpsLineItem *item1, jpsLineItem *item2) { @@ -1039,26 +1048,65 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } -//void jpsGraphicsView::RecordLineAction(const QString& name, const QString& type, const QLineF &oldLine) -//{ -// _undoStack.PushNewAction(LineAction(name,type,oldLine)); -//} +void jpsGraphicsView::RecordUndoLineAction(const QString& name, const QString& type, const QLineF &oldLine) +{ + _undoStack.PushNewAction(LineAction(name,type,oldLine)); +} + +void jpsGraphicsView::RecordRedoLineAction(const QString &name, const QString &type, const QLineF &oldLine) +{ + _redoStack.PushNewAction(LineAction(name,type,oldLine)); +} + +void jpsGraphicsView::Undo() +{ + if (!_undoStack.IsEmpty()) + { + const LineAction recentAction = _undoStack.GetRecentAction(); + + if (recentAction.GetName()=="LineDeleted") + { + addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), + recentAction.GetOldLine().p2().y(),recentAction.GetType()); + + RecordRedoLineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0)); + } + else if (recentAction.GetName()=="LineAdded") + { + RecordRedoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_line()->line()); + RemoveLineItem(line_vector.back()); + } + } + +} + +void jpsGraphicsView::Redo() +{ + if (!_redoStack.IsEmpty()) + { + const LineAction recentAction = _redoStack.GetRecentAction(); + + if (recentAction.GetName()=="LineDeleted") + { + addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), + recentAction.GetOldLine().p2().y(),recentAction.GetType()); -//void jpsGraphicsView::Undo() -//{ -// const LineAction recentAction = _undoStack.GetRecentAction(); + RecordUndoLineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0)); + } + else if (recentAction.GetName()=="LineAdded") + { + RecordUndoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_line()->line()); + RemoveLineItem(line_vector.back()); -// if (recentAction.GetName()=="LineDeleted") -// addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), -// recentAction.GetOldLine().p2().y(),recentAction.GetType()); + } -// _redoStack.PushNewAction(LineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0))); -//} + } +} -void jpsGraphicsView::line_collision() ///FIX ME!!! +void jpsGraphicsView::line_collision() //FIX ME!!! { /// if no lines collided yet if (!lines_collided && current_line!=nullptr) @@ -1395,22 +1443,20 @@ void jpsGraphicsView::delete_marked_lines() for (int i=0; iGetType(),marked_lines[i]->get_line()->line()); RemoveIntersections(marked_lines[i]); + delete marked_lines[i]->get_line(); //marked_lines[i]->set_line(nullptr); delete marked_lines[i]; line_vector.removeOne(marked_lines[i]); + } - QString type; - if (marked_lines.back()->is_Door()) - type = "Door"; - else - type = "Wall"; - //RecordLineAction("LineDeleted",type,marked_lines.back()->get_line()->line()); + marked_lines.clear(); //intersect_point_vector.clear(); @@ -1421,6 +1467,30 @@ void jpsGraphicsView::delete_marked_lines() } +void jpsGraphicsView::RemoveLineItem(jpsLineItem *mline) +{ + RemoveIntersections(mline); + line_vector.removeOne(mline); + delete mline->get_line(); + delete mline; + emit lines_deleted(); + +} + +void jpsGraphicsView::RemoveLineItem(const QLineF &line) +{ + for (jpsLineItem* lineItem:line_vector) + { + if (lineItem->get_line()->line()==line) + { + unmark_all_lines(); + select_line(lineItem); + delete_marked_lines(); + } + } + +} + void jpsGraphicsView::RemoveIntersections(jpsLineItem *lineItem) { QList points = lineItem->get_intersectionVector(); @@ -1565,6 +1635,7 @@ void jpsGraphicsView::en_disableWall() statWall=!statWall; statDoor=false; statExit=false; + _statHLine=false; statLandmark=false; if (statWall==false) { @@ -1598,6 +1669,7 @@ void jpsGraphicsView::en_disableDoor() statExit=false; statWall=false; statLandmark=false; + _statHLine=false; if (statDoor==false) { emit no_drawing(); @@ -1619,6 +1691,7 @@ void jpsGraphicsView::en_disableExit() statExit=!statExit; statDoor=false; statWall=false; + _statHLine=false; statLandmark=false; if (statExit==false) { @@ -1630,6 +1703,28 @@ void jpsGraphicsView::en_disableExit() } } +bool jpsGraphicsView::statusHLine() +{ + return _statHLine; +} + +void jpsGraphicsView::en_disableHLine() +{ + _statHLine=!_statHLine; + statExit=false; + statDoor=false; + statWall=false; + statLandmark=false; + if (_statHLine==false) + { + emit no_drawing(); + } + else + { + currentPen.setColor(Qt::darkCyan); + } +} + bool jpsGraphicsView::statusLandmark() { return statLandmark; diff --git a/src/GraphicView.h b/src/GraphicView.h index 5f8d6be..06be9be 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -63,6 +63,8 @@ class jpsGraphicsView: public QGraphicsView { void en_disableDoor(); bool statusExit(); void en_disableExit(); + bool statusHLine(); + void en_disableHLine(); bool statusLandmark(); void en_disableLandmark(); @@ -96,9 +98,12 @@ class jpsGraphicsView: public QGraphicsView { void drawLine(); qreal calc_d_point(const QLineF &line, const qreal &x, const qreal &y); void delete_marked_lines(); + void RemoveLineItem(jpsLineItem *mline); + void RemoveLineItem(const QLineF &line); void RemoveIntersections(jpsLineItem* lineItem); // lines read from dxf-file jpsLineItem *addLineItem(const qreal &x1, const qreal &y1, const qreal &x2, const qreal &y2, const QString &type=""); + jpsLineItem *addLineItem(const QLineF &line, const QString &type=""); QList get_markedLines(); QList get_line_vector(); void unmark_all_lines(); @@ -127,8 +132,8 @@ class jpsGraphicsView: public QGraphicsView { bool show_hide_roomCaption(QString name, qreal x, qreal y); //Undo Framework - //void RecordLineAction(const QString &name, const QString &type, const QLineF &oldLine); - + void RecordUndoLineAction(const QString &name, const QString &type, const QLineF &oldLine); + void RecordRedoLineAction(const QString &name, const QString &type, const QLineF &oldLine); public slots: //Waypoints @@ -142,7 +147,8 @@ public slots: //Line operations void SelectAllLines(); //Undo Redo - //void Undo(); + void Undo(); + void Redo(); protected: //Mouse events @@ -155,6 +161,7 @@ public slots: private: QGraphicsLineItem* current_line; + QPolygonF polygon; //std::vector line_vector; QList intersect_point_vector; //QList grid_point_vector; @@ -174,6 +181,7 @@ public slots: bool statDoor; bool statExit; bool statLandmark; + bool _statHLine; qreal catch_radius; qreal _scaleFactor; qreal gl_scale_f; @@ -208,8 +216,8 @@ public slots: bool _gridmode; //Undo/Redo - //ActionStack _undoStack; - //ActionStack _redoStack; + ActionStack _undoStack; + ActionStack _redoStack; signals: diff --git a/src/UndoFramework/actionstack.cpp b/src/UndoFramework/actionstack.cpp index 420c9c1..84bf454 100644 --- a/src/UndoFramework/actionstack.cpp +++ b/src/UndoFramework/actionstack.cpp @@ -11,7 +11,7 @@ ActionStack::~ActionStack() } LineAction ActionStack::GetRecentAction() -{ +{ return _actionstack.pop(); } @@ -21,3 +21,8 @@ void ActionStack::PushNewAction(const LineAction &action) } +bool ActionStack::IsEmpty() +{ + return _actionstack.isEmpty(); +} + diff --git a/src/UndoFramework/actionstack.h b/src/UndoFramework/actionstack.h index 3a677f1..364f7f5 100644 --- a/src/UndoFramework/actionstack.h +++ b/src/UndoFramework/actionstack.h @@ -3,7 +3,7 @@ #include #include "action.h" -#include "paintaction.h" +#include "lineaction.h" class ActionStack { @@ -13,6 +13,7 @@ class ActionStack LineAction GetRecentAction(); void PushNewAction(const LineAction& action); + bool IsEmpty(); private: QStack _actionstack; }; diff --git a/src/UndoFramework/paintaction.cpp b/src/UndoFramework/paintaction.cpp deleted file mode 100644 index d40877c..0000000 --- a/src/UndoFramework/paintaction.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "paintaction.h" - -LineAction::LineAction() -{ - -} - -LineAction::LineAction(const QString &name, const QString &type, const QLineF &oldLine) : Action(name,type) -{ - _oldLine=oldLine; -} - -LineAction::~LineAction() -{ - -} - -QLineF LineAction::GetOldLine() const -{ - return _oldLine; -} - diff --git a/src/UndoFramework/paintaction.h b/src/UndoFramework/paintaction.h deleted file mode 100644 index d87f0a3..0000000 --- a/src/UndoFramework/paintaction.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef PAINTACTION_H -#define PAINTACTION_H - -#include "action.h" -#include - -class LineAction : public Action -{ -public: - LineAction(); - LineAction(const QString& name, const QString& type, const QLineF& oldLine); - ~LineAction(); - - QLineF GetOldLine() const; -private: - QLineF _oldLine; -}; - -#endif // PAINTACTION_H diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 117bb25..da93a7b 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -277,6 +277,32 @@ void jpsDatamanager::writeXML(QFile &file) delete stream; } +void jpsDatamanager::writeRoutingXML(QFile &file) // Construction side +{ + QXmlStreamWriter* stream = new QXmlStreamWriter(&file); + QList hLines; + + for (jpsLineItem* line:mView->get_line_vector()) + { + if (line->IsHLine()) + { + hLines.push_back(line); + } + } + + + writeRoutingHeader(stream); + + stream->writeStartElement("Hlines"); + writeHLines(stream,hLines); + stream->writeEndElement();//Hlines + + stream->writeEndDocument(); + + delete stream; + +} + void jpsDatamanager::AutoSaveXML(QFile &file) { QXmlStreamWriter* stream = new QXmlStreamWriter(&file); @@ -310,13 +336,87 @@ void jpsDatamanager::writeHeader(QXmlStreamWriter *stream) stream->writeStartDocument("1.0",true); stream->writeStartElement("geometry"); - stream->writeAttribute("version", "0.5"); + stream->writeAttribute("version", "0.8"); stream->writeAttribute("caption","corner"); stream->writeAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); stream->writeAttribute("xsi:noNamespaceSchemaLocation","http://xsd.jupedsim.org/jps_geometry.xsd"); stream->writeAttribute("unit","m"); } +void jpsDatamanager::writeRoutingHeader(QXmlStreamWriter *stream) +{ + stream->setAutoFormatting(true); + stream->writeStartDocument("1.0",true); + + stream->writeStartElement("routing"); + stream->writeAttribute("version", "0.8"); + //stream->writeAttribute("caption","corner"); + stream->writeAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); + stream->writeAttribute("xsi:noNamespaceSchemaLocation","http://xsd.jupedsim.org/jps_routing.xsd"); + stream->writeAttribute("unit","m"); +} + +void jpsDatamanager::writeHLines(QXmlStreamWriter *stream, QList &hLines) +{ + for (jpsLineItem *lineItem:hLines) + { + stream->writeStartElement("Hline"); + stream->writeAttribute("room_id","0"); + QString rid = RoomIDHLine(lineItem); + if (rid.contains("Warning")) + { + QMessageBox::critical(mView, + "WriteHLines", + rid, + QMessageBox::Ok); + } + stream->writeAttribute("subroom_id",rid); + + //Vertices + stream->writeStartElement("vertex"); + stream->writeAttribute("px",QString::number(lineItem->get_line()->line().p1().x())); + stream->writeAttribute("py",QString::number(lineItem->get_line()->line().p1().y())); + stream->writeEndElement(); //vertex + + stream->writeStartElement("vertex"); + stream->writeAttribute("px",QString::number(lineItem->get_line()->line().p2().x())); + stream->writeAttribute("py",QString::number(lineItem->get_line()->line().p2().y())); + stream->writeEndElement(); //vertex + + stream->writeEndElement(); //Hline + } +} + +QString jpsDatamanager::RoomIDHLine(jpsLineItem *lineItem) +{ + + for (jpsRoom* room:roomlist) + { + QPolygonF rPolygon = room->RoomAsPolygon(); + if (rPolygon.containsPoint(lineItem->get_line()->line().p1(),Qt::OddEvenFill) || + rPolygon.contains(lineItem->get_line()->line().p1())) + { + if (rPolygon.containsPoint(lineItem->get_line()->line().p2(),Qt::OddEvenFill)|| + rPolygon.contains(lineItem->get_line()->line().p2())) + return QString::number(room->get_id()); + else + return "Warning! HLine intersects walls"; + } + else if (rPolygon.containsPoint(lineItem->get_line()->line().p2(),Qt::OddEvenFill)|| + rPolygon.contains(lineItem->get_line()->line().p2())) + { + if (rPolygon.containsPoint(lineItem->get_line()->line().p1(),Qt::OddEvenFill)|| + rPolygon.contains(lineItem->get_line()->line().p1())) + return QString::number(room->get_id()); + else + return "Warning! HLine intersects walls"; + } + + } + return "Warning! HLine outside geometry"; + +} + void jpsDatamanager::writeRooms(QXmlStreamWriter *stream, QList &lines) { ///rooms @@ -365,7 +465,7 @@ void jpsDatamanager::writeRooms(QXmlStreamWriter *stream, QList & } - ///Crossings + //Crossings writeCrossings(stream,lines); stream->writeEndElement();//crossings @@ -756,29 +856,29 @@ jpsGraphicsView * jpsDatamanager::get_view() return mView; } -void jpsDatamanager::AutoAssignCrossings() -{ - QList crossings = crossingList; +//void jpsDatamanager::AutoAssignCrossings() +//{ +// QList crossings = crossingList; - for (jpsCrossing *crossing: crossings) - { - int roomCounter=0; - for (jpsRoom *room : roomlist) - { - if (room->ContainsDoor(crossing->get_cLine()) && roomCounter==0) - { - crossing->add_rooms(room); - roomCounter++; +// for (jpsCrossing *crossing: crossings) +// { +// int roomCounter=0; +// for (jpsRoom *room : roomlist) +// { +// if (room->ContainsDoor(crossing->get_cLine()) && roomCounter==0) +// { +// crossing->add_rooms(room); +// roomCounter++; - } - else if (room->ContainsDoor(crossing->get_cLine()) && roomCounter==1) - { - crossing->add_rooms(crossing->get_roomList()[0],room); - crossings.removeOne(crossing); - break; - } - } - } +// } +// else if (room->ContainsDoor(crossing->get_cLine()) && roomCounter==1) +// { +// crossing->add_rooms(crossing->get_roomList()[0],room); +// crossings.removeOne(crossing); +// break; +// } +// } +// } @@ -822,38 +922,38 @@ void jpsDatamanager::AutoAssignCrossings() -} +//} -void jpsDatamanager::AutoAssignExits() -{ - for (jpsExit *exit: exitList) - { - for (jpsRoom *room: roomlist) - { - QList walls = room->get_listWalls(); +//void jpsDatamanager::AutoAssignExits() +//{ +// for (jpsExit *exit: exitList) +// { +// for (jpsRoom *room: roomlist) +// { +// QList walls = room->get_listWalls(); - int pointCounter = 0; +// int pointCounter = 0; - for (jpsLineItem* wall: walls) - { - if (wall->get_line()->line().p1()==exit->get_cLine()->get_line()->line().p1() || - wall->get_line()->line().p1()==exit->get_cLine()->get_line()->line().p2() || - wall->get_line()->line().p2()==exit->get_cLine()->get_line()->line().p1() || - wall->get_line()->line().p2()==exit->get_cLine()->get_line()->line().p2()) - { - pointCounter++; - } - } +// for (jpsLineItem* wall: walls) +// { +// if (wall->get_line()->line().p1()==exit->get_cLine()->get_line()->line().p1() || +// wall->get_line()->line().p1()==exit->get_cLine()->get_line()->line().p2() || +// wall->get_line()->line().p2()==exit->get_cLine()->get_line()->line().p1() || +// wall->get_line()->line().p2()==exit->get_cLine()->get_line()->line().p2()) +// { +// pointCounter++; +// } +// } - if (pointCounter==2) - { - exit->add_rooms(room); - break; - } - } - } +// if (pointCounter==2) +// { +// exit->add_rooms(room); +// break; +// } +// } +// } -} +//} bool jpsDatamanager::readXML(QFile &file) { diff --git a/src/datamanager.h b/src/datamanager.h index cf9a036..fd35fa6 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -97,8 +97,8 @@ class jpsDatamanager: public DL_CreationAdapter // Auto Assign - void AutoAssignCrossings(); - void AutoAssignExits(); +// void AutoAssignCrossings(); +// void AutoAssignExits(); // Read XML @@ -112,8 +112,12 @@ class jpsDatamanager: public DL_CreationAdapter // Write XML void writeXML(QFile &file); + void writeRoutingXML(QFile &file); void AutoSaveXML(QFile &file); void writeHeader(QXmlStreamWriter *stream); + void writeRoutingHeader(QXmlStreamWriter *stream); + void writeHLines(QXmlStreamWriter *stream, QList& hLines); + QString RoomIDHLine(jpsLineItem* lineItem); void writeRooms(QXmlStreamWriter *stream, QList& lines); void AutoSaveRooms(QXmlStreamWriter *stream, QList& lines); void writeCrossings(QXmlStreamWriter *stream, QList& lines); diff --git a/src/jpsLineItem.cpp b/src/jpsLineItem.cpp index 2089667..10301c4 100644 --- a/src/jpsLineItem.cpp +++ b/src/jpsLineItem.cpp @@ -58,6 +58,16 @@ QString jpsLineItem::get_name() return mName; } +QString jpsLineItem::GetType() +{ + if (is_Door()) + return "Door"; + else if (is_Wall()) + return "Wall"; + else if (IsHLine()) + return "HLine"; +} + void jpsLineItem::set_id(int id) { mId=id; @@ -68,7 +78,7 @@ void jpsLineItem::set_name(QString name) mName=name; } -void jpsLineItem::set_type(bool wall, bool door, bool exit) +void jpsLineItem::set_type(bool wall, bool door, bool exit, bool hline) { if (wall==true) { @@ -82,6 +92,8 @@ void jpsLineItem::set_type(bool wall, bool door, bool exit) { set_Exit(); } + else + SetHLine(); } void jpsLineItem::set_Wall() @@ -89,6 +101,7 @@ void jpsLineItem::set_Wall() wall=true; door=false; exit=false; + _hLine=false; defaultColor="black"; } @@ -97,6 +110,7 @@ void jpsLineItem::set_Door() door=true; wall=false; exit=false; + _hLine=false; defaultColor="blue"; } @@ -105,10 +119,21 @@ void jpsLineItem::set_Exit() exit=true; wall=false; door=false; + _hLine=false; defaultColor="darkMagenta"; } +void jpsLineItem::SetHLine() +{ + exit=false; + wall=false; + door=false; + _hLine=true; + defaultColor="darkCyan"; + +} + void jpsLineItem::set_defaultColor(QString color) { defaultColor=color; @@ -129,6 +154,11 @@ bool jpsLineItem::is_Exit() return exit; } +bool jpsLineItem::IsHLine() +{ + return _hLine; +} + void jpsLineItem::add_intersectionPoint(QPointF *point) { intersectionVector.push_back(point); diff --git a/src/jpsLineItem.h b/src/jpsLineItem.h index d381b61..3ebb525 100644 --- a/src/jpsLineItem.h +++ b/src/jpsLineItem.h @@ -42,16 +42,19 @@ class jpsLineItem int get_id(); QString get_defaultColor(); QString get_name(); + QString GetType(); void set_id(int id); void set_name(QString name); - void set_type(bool wall, bool door, bool exit); + void set_type(bool wall, bool door, bool exit, bool hline=false); void set_Wall(); void set_Door(); void set_Exit(); + void SetHLine(); void set_defaultColor(QString color); bool is_Wall(); bool is_Door(); bool is_Exit(); + bool IsHLine(); void add_intersectionPoint(QPointF *point); void remove_intersectionPoint(QPointF *point); QList get_intersectionVector(); @@ -70,6 +73,7 @@ class jpsLineItem bool wall; bool door; bool exit; + bool _hLine; QList intersectionVector; QList intersectLineVector; /* diff --git a/src/jpscrossing.cpp b/src/jpscrossing.cpp index 9fb5198..a5f7e9a 100644 --- a/src/jpscrossing.cpp +++ b/src/jpscrossing.cpp @@ -70,9 +70,11 @@ void jpsCrossing::add_rooms(jpsRoom *room1, jpsRoom *room2) { roomList.clear(); roomList.push_back(room1); + room1->AddDoor(this); if (room2!=0L) { roomList.push_back(room2); + room2->AddDoor(this); } diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 7b1d525..153e93f 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -106,6 +106,7 @@ MWindow :: MWindow() { 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(actionObjectsnap,SIGNAL(triggered(bool)),this,SLOT(objectsnap())); connect(actionDelete_lines,SIGNAL(triggered(bool)),this,SLOT(delete_lines())); connect(actionDelete_single_line,SIGNAL(triggered(bool)),this,SLOT(delete_marked_lines())); @@ -143,8 +144,9 @@ MWindow :: MWindow() { //CMap connect(actionRun_visualisation,SIGNAL(triggered(bool)),this,SLOT(RunCMap())); connect(_cMapTimer,SIGNAL(timeout()),this,SLOT(UpdateCMap())); - //Undo - //connect(actionUndo,SIGNAL(triggered(bool)),mview,SLOT(Undo())); + //Undo Redo + connect(actionUndo,SIGNAL(triggered(bool)),mview,SLOT(Undo())); + connect(actionRedo,SIGNAL(triggered(bool)),mview,SLOT(Redo())); } MWindow::~MWindow() @@ -335,6 +337,13 @@ void MWindow::saveFile(){ return; } dmanager->writeXML(file); + + //routing (hlines) + QString fileNameRouting = fileName+"routing.xml"; + QFile routingFile(fileNameRouting); + if (routingFile.open(QIODevice::WriteOnly|QIODevice::Text)) + dmanager->writeRoutingXML(routingFile); + //file.write(coord_string.toUtf8());//textEdit->toPlainText().toUtf8()); statusBar()->showMessage(tr("XML-File successfully saved!"),10000); } @@ -399,12 +408,20 @@ void MWindow::en_disableLandmark() mview->en_disableLandmark(); } +void MWindow::en_disableHLine() +{ + this->disableDrawing(); + actionHLine->setChecked(true); + 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); } void MWindow::objectsnap() @@ -517,6 +534,7 @@ void MWindow::remove_all_lines() void MWindow::ShowLineLength() { length_edit->setText(QString::number(mview->ReturnLineLength())); + length_edit->selectAll(); } void MWindow::rotate() diff --git a/src/mainWindow.h b/src/mainWindow.h index cec9493..75e99c3 100644 --- a/src/mainWindow.h +++ b/src/mainWindow.h @@ -88,6 +88,7 @@ protected slots: void en_disableDoor(); void en_disableExit(); void en_disableLandmark(); + void en_disableHLine(); void disableDrawing(); void objectsnap(); diff --git a/src/rooms.cpp b/src/rooms.cpp index f58763c..19f533f 100644 --- a/src/rooms.cpp +++ b/src/rooms.cpp @@ -30,6 +30,7 @@ #include #include #include +#include "jpscrossing.h" jpsRoom::jpsRoom(int id_room) @@ -88,9 +89,9 @@ void jpsRoom::activate() } } -QList jpsRoom::get_vertices() +QVector jpsRoom::get_vertices() const { - QList vertices; + QVector vertices; for (int i=0; i jpsRoom::get_vertices() vertices.push_back(item_list[i]->get_line()->line().p2()); } } + for (jpsCrossing* crossing:_doorList) + { + if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false) + { + vertices.push_back(crossing->get_cLine()->get_line()->line().p1()); + } + + if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false) + { + vertices.push_back(crossing->get_cLine()->get_line()->line().p1()); + } + + } return vertices; } QPointF jpsRoom::get_center() { - QList vertices = get_vertices(); + QVector vertices = get_vertices(); qreal sum_x=0; qreal sum_y=0; @@ -198,21 +212,31 @@ QList jpsRoom::GetDoorVertices() const return vertices; } -bool jpsRoom::ContainsDoor(jpsLineItem *lineItem) const +void jpsRoom::AddDoor(jpsCrossing *door) { - QList vertices = GetDoorVertices(); - - for (QPointF vertex:vertices) - { - if (lineItem->get_line()->contains(vertex)) - { - return true; - } - } - return false; + _doorList.push_back(door); +} +QPolygonF jpsRoom::RoomAsPolygon() const +{ + return QPolygonF(get_vertices()); } +//bool jpsRoom::ContainsDoor(jpsLineItem *lineItem) const +//{ +// QList vertices = GetDoorVertices(); + +// for (QPointF vertex:vertices) +// { +// if (lineItem->get_line()->contains(vertex)) +// { +// return true; +// } +// } +// return false; + +//} + void jpsRoom::set_id(int id_room) diff --git a/src/rooms.h b/src/rooms.h index f39baba..33f8d03 100644 --- a/src/rooms.h +++ b/src/rooms.h @@ -32,6 +32,8 @@ #include #include "jpsLineItem.h" +class jpsCrossing; + class jpsRoom { @@ -45,7 +47,7 @@ class jpsRoom void change_name(QString name); QList get_listWalls(); void activate(); - QList get_vertices(); + QVector get_vertices() const; void set_id(int id_room); int get_id(); QPointF get_center(); @@ -53,7 +55,9 @@ class jpsRoom QString get_type(); void set_type(const QString &string); QList GetDoorVertices() const; - bool ContainsDoor(jpsLineItem* lineItem) const; + //bool ContainsDoor(jpsLineItem* lineItem) const; + void AddDoor(jpsCrossing *door); + QPolygonF RoomAsPolygon() const; private: @@ -62,6 +66,8 @@ class jpsRoom QString name; QList item_list; QString _type; + QList _doorList; + }; diff --git a/src/roomwidget.cpp b/src/roomwidget.cpp index 57d8a33..2b705cd 100644 --- a/src/roomwidget.cpp +++ b/src/roomwidget.cpp @@ -85,7 +85,7 @@ roomWidget::roomWidget(QWidget *parent, jpsDatamanager *dmanager, jpsGraphicsVie connect(ui->roomBox2,SIGNAL(activated(int)),this,SLOT(add_rooms_to_crossing())); connect(ui->removeCrossingButton,SIGNAL(clicked(bool)),this,SLOT(delete_crossing())); connect(ui->crossingList,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(select_crossing())); - connect(ui->auto_assign_doors,SIGNAL(clicked(bool)),this,SLOT(autoAssignDoors())); + //connect(ui->auto_assign_doors,SIGNAL(clicked(bool)),this,SLOT(autoAssignDoors())); //tab exit // connect(ui->addExitButton,SIGNAL(clicked(bool)),this,SLOT(new_exit())); // connect(ui->exitList,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(enable_roomSelectionExits())); @@ -767,20 +767,20 @@ void roomWidget::highlight_obs() } -void roomWidget::autoAssignDoors() -{ - datamanager->AutoAssignCrossings(); - show_all(); - enable_roomSelectionCrossings(); -} +//void roomWidget::autoAssignDoors() +//{ +// datamanager->AutoAssignCrossings(); +// show_all(); +// enable_roomSelectionCrossings(); +//} -void roomWidget::autoAssignExits() -{ - datamanager->AutoAssignExits(); - show_all(); - enable_roomSelectionExits(); +//void roomWidget::autoAssignExits() +//{ +// datamanager->AutoAssignExits(); +// show_all(); +// enable_roomSelectionExits(); -} +//} void roomWidget::ChangeRoomType() { diff --git a/src/roomwidget.h b/src/roomwidget.h index 7c8b072..ba13658 100644 --- a/src/roomwidget.h +++ b/src/roomwidget.h @@ -85,8 +85,8 @@ protected slots: bool shhi_roomCaption(); void highlight_room(); void highlight_obs(); - void autoAssignDoors(); - void autoAssignExits(); +// void autoAssignDoors(); +// void autoAssignExits(); void ChangeRoomType(); From b7ba70b29344bb5235b53679e799d042a15be8d6 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 28 Jan 2016 12:47:31 +0100 Subject: [PATCH 45/53] Upload missing files --- forms/Redo-Icon.png | Bin 0 -> 11609 bytes src/UndoFramework/lineaction.cpp | 22 ++++++++++++++++++++++ src/UndoFramework/lineaction.h | 19 +++++++++++++++++++ src/mainWindow.cpp | 1 + 4 files changed, 42 insertions(+) create mode 100644 forms/Redo-Icon.png create mode 100644 src/UndoFramework/lineaction.cpp create mode 100644 src/UndoFramework/lineaction.h diff --git a/forms/Redo-Icon.png b/forms/Redo-Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6d9e0d48c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73yn`aapyzSUhvhYff@jwt8lsufaQt&OmEH^X?!x!ykU1J6i&G5X>if$ ziqG}_zhCC&N9lcIISOFfV52ef)&pl>1E<{ps0q%w7ymF3?0&^DPqgigevjKza(Ws| z{@DJRgZCaJdVMi?_Hkaa#M5m6=+!t}QwM(jVtm6jMOUcdihwWRDAG%YqmTW|uZYI$ z02o5uonsB0ZUf-vzzCe<`|o+8VauCayutVm`dxuG`gO7UXfas%({h}r?w + +class LineAction : public Action +{ +public: + LineAction(); + LineAction(const QString& name, const QString& type, const QLineF& oldLine); + ~LineAction(); + + QLineF GetOldLine() const; +private: + QLineF _oldLine; +}; + +#endif // PAINTACTION_H diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 153e93f..e063547 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -508,6 +508,7 @@ void MWindow::en_selectMode() actionWall->setChecked(false); actionDoor->setChecked(false); actionExit->setChecked(false); + actionHLine->setChecked(false); actionLandmark->setChecked(false); length_edit->clearFocus(); } From 3dae851c3b19418775be91526be6d7284eb7e145 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 28 Jan 2016 15:36:15 +0100 Subject: [PATCH 46/53] bugfixes --- src/datamanager.cpp | 20 ++++++++++---------- src/rooms.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/rooms.h | 5 +++++ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/datamanager.cpp b/src/datamanager.cpp index da93a7b..ab537bb 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -392,7 +392,7 @@ QString jpsDatamanager::RoomIDHLine(jpsLineItem *lineItem) for (jpsRoom* room:roomlist) { - QPolygonF rPolygon = room->RoomAsPolygon(); + QPolygonF rPolygon = room->RoomAsSortedPolygon(); if (rPolygon.containsPoint(lineItem->get_line()->line().p1(),Qt::OddEvenFill) || rPolygon.contains(lineItem->get_line()->line().p1())) { @@ -402,15 +402,15 @@ QString jpsDatamanager::RoomIDHLine(jpsLineItem *lineItem) else return "Warning! HLine intersects walls"; } - else if (rPolygon.containsPoint(lineItem->get_line()->line().p2(),Qt::OddEvenFill)|| - rPolygon.contains(lineItem->get_line()->line().p2())) - { - if (rPolygon.containsPoint(lineItem->get_line()->line().p1(),Qt::OddEvenFill)|| - rPolygon.contains(lineItem->get_line()->line().p1())) - return QString::number(room->get_id()); - else - return "Warning! HLine intersects walls"; - } +// else if (rPolygon.containsPoint(lineItem->get_line()->line().p2(),Qt::OddEvenFill)|| +// rPolygon.contains(lineItem->get_line()->line().p2())) +// { +// if (rPolygon.containsPoint(lineItem->get_line()->line().p1(),Qt::OddEvenFill)|| +// rPolygon.contains(lineItem->get_line()->line().p1())) +// return QString::number(room->get_id()); +// else +// return "Warning! HLine intersects walls"; +// } } return "Warning! HLine outside geometry"; diff --git a/src/rooms.cpp b/src/rooms.cpp index 19f533f..8500dba 100644 --- a/src/rooms.cpp +++ b/src/rooms.cpp @@ -219,9 +219,54 @@ void jpsRoom::AddDoor(jpsCrossing *door) QPolygonF jpsRoom::RoomAsPolygon() const { + return QPolygonF(get_vertices()); } +QPolygonF jpsRoom::RoomAsSortedPolygon() const +{ + QList lines = item_list; + for (jpsCrossing* crossing:_doorList) + { + lines.push_back(crossing->get_cLine()); + } +// std::cout << lines.size() << std::endl; + QVector points; + + points.push_back(lines.first()->get_line()->line().p1()); + points.push_back(lines.first()->get_line()->line().p2()); + + lines.pop_front(); + + for (int i=0; iget_line()->line().p1() == points.last()) + { + //points.push_back(line->get_line()->line().p1()); + points.push_back(lines[i]->get_line()->line().p2()); + lines.removeOne(lines[i]); + i=-1; + } + else if (lines[i]->get_line()->line().p2() == points.last()) + { + //points.push_back(line->get_line()->line().p1()); + points.push_back(lines[i]->get_line()->line().p1()); + lines.removeOne(lines[i]); + i=-1; + } + } + + +// for (QPointF point:points) +// { +// std::cout << point.x() << " " << point.y() << std::endl; + +// } +// std::cout << "----------------------------" << std::endl; + + return QPolygonF(points); +} + //bool jpsRoom::ContainsDoor(jpsLineItem *lineItem) const //{ // QList vertices = GetDoorVertices(); diff --git a/src/rooms.h b/src/rooms.h index 33f8d03..88f2be0 100644 --- a/src/rooms.h +++ b/src/rooms.h @@ -58,6 +58,11 @@ class jpsRoom //bool ContainsDoor(jpsLineItem* lineItem) const; void AddDoor(jpsCrossing *door); QPolygonF RoomAsPolygon() const; + /** + * @brief RoomAsSortedPolygon + * @return SortedPolygon: QPolygonF + */ + QPolygonF RoomAsSortedPolygon() const; private: From 1ed508689d1a616f46e3621899fb0ac04051244e Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 28 Jan 2016 15:57:40 +0100 Subject: [PATCH 47/53] write ids of hlines. start with 1000 --- src/GraphicView.cpp | 2 +- src/datamanager.cpp | 3 +++ src/rooms.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 1bbc9fb..352e1c7 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -814,7 +814,7 @@ void jpsGraphicsView::drawLine() //Undo RecordUndoLineAction("LineAdded",lineItem->GetType(),lineItem->get_line()->line()); - drawLine(); + //drawLine(); diff --git a/src/datamanager.cpp b/src/datamanager.cpp index ab537bb..3b699f9 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -358,9 +358,11 @@ void jpsDatamanager::writeRoutingHeader(QXmlStreamWriter *stream) void jpsDatamanager::writeHLines(QXmlStreamWriter *stream, QList &hLines) { + int id=1000; for (jpsLineItem *lineItem:hLines) { stream->writeStartElement("Hline"); + stream->writeAttribute("id",QString::number(id)); stream->writeAttribute("room_id","0"); QString rid = RoomIDHLine(lineItem); if (rid.contains("Warning")) @@ -384,6 +386,7 @@ void jpsDatamanager::writeHLines(QXmlStreamWriter *stream, QList stream->writeEndElement(); //vertex stream->writeEndElement(); //Hline + id++; } } diff --git a/src/rooms.cpp b/src/rooms.cpp index 8500dba..146555e 100644 --- a/src/rooms.cpp +++ b/src/rooms.cpp @@ -257,12 +257,12 @@ QPolygonF jpsRoom::RoomAsSortedPolygon() const } -// for (QPointF point:points) -// { -// std::cout << point.x() << " " << point.y() << std::endl; + for (QPointF point:points) + { + std::cout << point.x() << " " << point.y() << std::endl; -// } -// std::cout << "----------------------------" << std::endl; + } + std::cout << "----------------------------" << std::endl; return QPolygonF(points); } From 68abac4181be61dd73169d996602a9a7cdb9f6fb Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 12:21:38 +0100 Subject: [PATCH 48/53] Issue #25 Undo/Redo LineEdit --- CHANGELOG.md | 3 +- forms/HLine.png | Bin 0 -> 1634 bytes forms/Ressource.qrc | 1 + forms/mainwindow.ui | 12 ++++-- src/GraphicView.cpp | 67 ++++++++++++++++++++++++++----- src/GraphicView.h | 7 +++- src/UndoFramework/lineaction.cpp | 8 +++- src/UndoFramework/lineaction.h | 4 +- src/datamanager.cpp | 1 + src/mainWindow.cpp | 10 ++++- 10 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 forms/HLine.png diff --git a/CHANGELOG.md b/CHANGELOG.md index e9318ad..1af4217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ All notable changes to this project will be documented in this file. ## v0.8.0 [Unreleased] - ### Added #### JPSEDITOR +- 1.2.16 Create and save HLines - First approaches of an undo/redo framework - Undo/Redo working when line added or deleted - DXF import with different layers - Not working properly with AutoCAD ?! @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - Zooming - Line editing - Length of line is displayed + - Show origin - ... - Room and door declarations diff --git a/forms/HLine.png b/forms/HLine.png new file mode 100644 index 0000000000000000000000000000000000000000..81b9f3dce14be3bb072beb30858f16af605a42ff GIT binary patch literal 1634 zcmXw4dpJ~i7#^9Xjt<7L)ln&G4*7|GHdoix{uKNof%!Aw@E`!lhwqilB6yAu47oE;v zU>WpB?~el;au|%I?*e?d{G7Pyp_q!{4inGacVlYiN>{tal?{aTo;G{b^wX`27Ueb0 z6UAn)>{Ig@o$+>6sa@@-1RsFjJlP{!Qnn^uW#= zj(x+$SoehMCu^3={NF!!QfO;to#aZH)-$AiKyu|di|p$QkN5YG6{NgAJK`kUs*d$y z>mOH#0|u$10nOF%fMbR>mL&zx{3_X6Pl5iI%Y}-|Ed-MceWb$*@urDVK+bqQ9lui3 z@ymWX9-X4&1TTb(ChcgHSg^usBf%{9;TABfx2gg&zZo#IxIlne`Tffv=Oqbfd5emc zN5z4Baz6*;cPiv;Z5NeGEf*%#@Il_}rviDD1ucJY_6Eoss2GsXB-w#HpaR^x(0{>w zB!hsWk=O_teTrz@(njNFV}J?j6JX{L^&6PsKc;{g8h#7RdYb6o`c8E3>^U0STj?7N zWNrprz0DSI&n%6NZS*=58CwCZo#^KNb2JvW+5^sK(Y3DI>DrioXte((0-Oh?=~L`E z90j;xn!a@B5WREW&`m(2T6+8!uyQ_TBpkee~wfJ%yY=BvGc^OrX}% z3b}|y_SZ?ylqhlHygypW8RZK(-pD~yZ$qlu6J5#?7?DYhlCQMo=dc5qcN|q6hz8gQ z+{vVR385`Ng+-cp+fh+GRK^i(C6knrF>QGv=E&9@p?F^CNgGRJ@@l<=uWc^HuA6Aq zP&^*Gf@5h-K4_4%Y8@&uM^nu%iWiKY;aGZ*4-^tiD{>+DmeO<^C7V3YL)uD4w@@5^ zv@z7nSBQrozA}LW(N9QE%R|rM(%oK}LfjiMEDSqo{ljna@*`yv-gMl-2HeyDwz zmxnN?2-}Nk9?SbG@r!km9<7c^%vwqPZIo{0E+52|tvOB&O7PdA-R@e^Nldj-YHuUh zA?yf7)?%8K)ZiK1J*-=$)vYC_0?|&6AYJIp(IXdv5GKhf(7XotL3N6YEIhsqq4D0%^v8avv zfUJxKvIx7QU_QMEU8C$^U<>gake{#mMZtUanglesnap.PNG Undo-icon.png Redo-Icon.png + HLine.png diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 97af0c1..803f47c 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -53,8 +53,12 @@ + + + + @@ -519,7 +523,7 @@ Undo - Undo + Undo PaintEvent Ctrl+Z @@ -537,10 +541,10 @@ Redo - Redo + Redo PaintEvent - Ctrl+U + Ctrl+Y @@ -552,7 +556,7 @@ - :/Wall.png:/Wall.png + :/HLine.png:/HLine.png HLine diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 352e1c7..0d8e51c 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -46,6 +46,7 @@ jpsGraphicsView::jpsGraphicsView(QWidget* parent):QGraphicsView(parent) translation_x=0; translation_y=0;//this->height(); anglesnap=false; + id_counter=0; _scaleFactor=1.0; _gridSize=1.0; gl_scale_f=.01*_scaleFactor; @@ -792,6 +793,8 @@ void jpsGraphicsView::drawLine() { jpsLineItem* lineItem= new jpsLineItem(current_line); + lineItem->set_id(id_counter); + id_counter++; // if there is already a drawn line if (line_vector.size()>=1) @@ -812,7 +815,7 @@ void jpsGraphicsView::drawLine() current_line=nullptr; //Undo - RecordUndoLineAction("LineAdded",lineItem->GetType(),lineItem->get_line()->line()); + RecordUndoLineAction("LineAdded",lineItem->GetType(),lineItem->get_id(),lineItem->get_line()->line()); //drawLine(); @@ -875,6 +878,8 @@ jpsLineItem* jpsGraphicsView::addLineItem(const qreal &x1,const qreal &y1,const current_line=Scene->addLine(x1,y1,x2,y2); current_line->setTransform(QTransform::fromTranslate(translation_x,translation_y), true); jpsLineItem* newLine = new jpsLineItem(current_line); + newLine->set_id(id_counter); + id_counter++; if (type=="Door") { @@ -979,6 +984,7 @@ void jpsGraphicsView::EditLine(QPointF* point) if (marked_lines.first()->get_line()->line().p1()==*point) { + RecordUndoLineAction("LineEdited",marked_lines.first()->GetType(),marked_lines.first()->get_id(),marked_lines.first()->get_line()->line()); current_line=marked_lines[0]->get_line(); marked_lines[0]->get_line()->setLine(marked_lines[0]->get_line()->line().x2(),marked_lines[0]->get_line()->line().y2(),translated_pos.x(),translated_pos.y()); //current_line=Scene->addLine(marked_lines[0]->get_line()->line().p2().x(), @@ -989,6 +995,7 @@ void jpsGraphicsView::EditLine(QPointF* point) else if (marked_lines.first()->get_line()->line().p2()==*point) { + RecordUndoLineAction("LineEdited",marked_lines.first()->GetType(),marked_lines.first()->get_id(),marked_lines.first()->get_line()->line()); current_line=marked_lines[0]->get_line(); marked_lines[0]->get_line()->setLine(marked_lines[0]->get_line()->line().x1(),marked_lines[0]->get_line()->line().y1(),translated_pos.x(),translated_pos.y()); @@ -1004,6 +1011,7 @@ void jpsGraphicsView::EditLine(QPointF* point) //line_tracked=1; RemoveIntersections(marked_lines.first()); _statLineEdit=true; + //delete_marked_lines(); en_disableWall(); @@ -1048,14 +1056,40 @@ bool jpsGraphicsView::show_hide_roomCaption(QString name, qreal x, qreal y) return true; } -void jpsGraphicsView::RecordUndoLineAction(const QString& name, const QString& type, const QLineF &oldLine) +void jpsGraphicsView::RecordUndoLineAction(const QString& name, const QString& type, const int& itemID, const QLineF &oldLine) +{ + _undoStack.PushNewAction(LineAction(name,type,itemID,oldLine)); +} + +void jpsGraphicsView::RecordRedoLineAction(const QString &name, const QString &type, const int& itemID, const QLineF &oldLine) { - _undoStack.PushNewAction(LineAction(name,type,oldLine)); + _redoStack.PushNewAction(LineAction(name,type,itemID,oldLine)); +} + +void jpsGraphicsView::UndoLineEdit(const int& lineID, const QLineF& old_line) +{ + for (jpsLineItem* lineItem:line_vector) + { + if (lineItem->get_id()==lineID) + { + RecordRedoLineAction("LineEdited",lineItem->GetType(),lineItem->get_id(),lineItem->get_line()->line()); + lineItem->get_line()->setLine(old_line); + break; + } + } } -void jpsGraphicsView::RecordRedoLineAction(const QString &name, const QString &type, const QLineF &oldLine) +void jpsGraphicsView::RedoLineEdit(const int &lineID, const QLineF &old_line) { - _redoStack.PushNewAction(LineAction(name,type,oldLine)); + for (jpsLineItem* lineItem:line_vector) + { + if (lineItem->get_id()==lineID) + { + RecordUndoLineAction("LineEdited",lineItem->GetType(),lineItem->get_id(),lineItem->get_line()->line()); + lineItem->get_line()->setLine(old_line); + break; + } + } } void jpsGraphicsView::Undo() @@ -1069,13 +1103,18 @@ void jpsGraphicsView::Undo() addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), recentAction.GetOldLine().p2().y(),recentAction.GetType()); - RecordRedoLineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0)); + RecordRedoLineAction("LineAdded",recentAction.GetType(),id_counter-1,QLineF(0,0,0,0)); } else if (recentAction.GetName()=="LineAdded") { - RecordRedoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_line()->line()); + RecordRedoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_id(), + line_vector.back()->get_line()->line()); RemoveLineItem(line_vector.back()); } + else if (recentAction.GetName()=="LineEdited") + { + UndoLineEdit(recentAction.GetItemID(),recentAction.GetOldLine()); + } } } @@ -1091,15 +1130,21 @@ void jpsGraphicsView::Redo() addLineItem(recentAction.GetOldLine().p1().x(),recentAction.GetOldLine().p1().y(),recentAction.GetOldLine().p2().x(), recentAction.GetOldLine().p2().y(),recentAction.GetType()); - RecordUndoLineAction("LineAdded",recentAction.GetType(),QLineF(0,0,0,0)); + RecordUndoLineAction("LineAdded",recentAction.GetType(),id_counter-1,QLineF(0,0,0,0)); } else if (recentAction.GetName()=="LineAdded") { - RecordUndoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_line()->line()); + RecordUndoLineAction("LineDeleted",line_vector.back()->GetType(),line_vector.back()->get_id(), + line_vector.back()->get_line()->line()); RemoveLineItem(line_vector.back()); } + else if (recentAction.GetName()=="LineEdited") + { + RedoLineEdit(recentAction.GetItemID(),recentAction.GetOldLine()); + + } } @@ -1443,7 +1488,7 @@ void jpsGraphicsView::delete_marked_lines() for (int i=0; iGetType(),marked_lines[i]->get_line()->line()); + RecordUndoLineAction("LineDeleted",marked_lines[i]->GetType(),marked_lines[i]->get_id(),marked_lines[i]->get_line()->line()); RemoveIntersections(marked_lines[i]); @@ -1571,6 +1616,8 @@ void jpsGraphicsView::take_l_from_lineEdit(const qreal &length) line.setLength(length); current_line->setLine(line); jpsLineItem* jpsline = new jpsLineItem(current_line); + jpsline->set_id(id_counter); + id_counter++; jpsline->set_type(statWall,statDoor,statExit); line_vector.push_back(jpsline); current_line=nullptr; diff --git a/src/GraphicView.h b/src/GraphicView.h index 06be9be..e72eb84 100644 --- a/src/GraphicView.h +++ b/src/GraphicView.h @@ -132,8 +132,10 @@ class jpsGraphicsView: public QGraphicsView { bool show_hide_roomCaption(QString name, qreal x, qreal y); //Undo Framework - void RecordUndoLineAction(const QString &name, const QString &type, const QLineF &oldLine); - void RecordRedoLineAction(const QString &name, const QString &type, const QLineF &oldLine); + void RecordUndoLineAction(const QString &name, const QString &type, const int &itemID, const QLineF &oldLine); + void RecordRedoLineAction(const QString &name, const QString &type, const int &itemID, const QLineF &oldLine); + void UndoLineEdit(const int &lineID, const QLineF &old_line); + void RedoLineEdit(const int &lineID, const QLineF &old_line); public slots: //Waypoints @@ -197,6 +199,7 @@ public slots: QList marked_lines; QGraphicsTextItem* current_caption; QList caption_list; + int id_counter; //Landmark and waypoints QList LLandmarks; diff --git a/src/UndoFramework/lineaction.cpp b/src/UndoFramework/lineaction.cpp index a8cca4b..9bc9523 100644 --- a/src/UndoFramework/lineaction.cpp +++ b/src/UndoFramework/lineaction.cpp @@ -5,9 +5,10 @@ LineAction::LineAction() } -LineAction::LineAction(const QString &name, const QString &type, const QLineF &oldLine) : Action(name,type) +LineAction::LineAction(const QString &name, const QString &type, const int &itemID, const QLineF &oldLine) : Action(name,type) { _oldLine=oldLine; + _itemID=itemID; } LineAction::~LineAction() @@ -20,3 +21,8 @@ QLineF LineAction::GetOldLine() const return _oldLine; } +int LineAction::GetItemID() const +{ + return _itemID; +} + diff --git a/src/UndoFramework/lineaction.h b/src/UndoFramework/lineaction.h index 63e0cb7..e61f266 100644 --- a/src/UndoFramework/lineaction.h +++ b/src/UndoFramework/lineaction.h @@ -8,12 +8,14 @@ class LineAction : public Action { public: LineAction(); - LineAction(const QString& name, const QString& type, const QLineF& oldLine); + LineAction(const QString& name, const QString& type, const int& itemID, const QLineF& oldLine); ~LineAction(); QLineF GetOldLine() const; + int GetItemID() const; private: QLineF _oldLine; + int _itemID; }; #endif // PAINTACTION_H diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 3b699f9..3b58cea 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -358,6 +358,7 @@ void jpsDatamanager::writeRoutingHeader(QXmlStreamWriter *stream) void jpsDatamanager::writeHLines(QXmlStreamWriter *stream, QList &hLines) { + // to be sure that id is unique (considering crossings, transitions) int id=1000; for (jpsLineItem *lineItem:hLines) { diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index e063547..7d9317f 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -183,6 +183,13 @@ void MWindow::AutoSave() dmanager->AutoSaveXML(file); //file.write(coord_string.toUtf8());//textEdit->toPlainText().toUtf8()); statusBar()->showMessage(tr("Backup file generated!"),10000); + + //routing (hlines) + QString fileNameRouting = file.fileName(); + fileNameRouting=fileNameRouting.split(".").first()+"_routing.xml"; + QFile routingFile(fileNameRouting); + if (routingFile.open(QIODevice::WriteOnly|QIODevice::Text)) + dmanager->writeRoutingXML(routingFile); } } @@ -339,7 +346,8 @@ void MWindow::saveFile(){ dmanager->writeXML(file); //routing (hlines) - QString fileNameRouting = fileName+"routing.xml"; + QString fileNameRouting=fileName.split(".").first()+"_routing.xml"; + QFile routingFile(fileNameRouting); if (routingFile.open(QIODevice::WriteOnly|QIODevice::Text)) dmanager->writeRoutingXML(routingFile); From 4112bb6b7bfceaf306c2ab2a48aa31f2d27a293f Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 13:29:24 +0100 Subject: [PATCH 49/53] :new: Read HLines (<>routing.xml) --- src/GraphicView.cpp | 4 +++ src/datamanager.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++-- src/datamanager.h | 2 ++ src/mainWindow.cpp | 13 +++++-- 4 files changed, 98 insertions(+), 5 deletions(-) diff --git a/src/GraphicView.cpp b/src/GraphicView.cpp index 0d8e51c..dcb7784 100644 --- a/src/GraphicView.cpp +++ b/src/GraphicView.cpp @@ -889,6 +889,10 @@ jpsLineItem* jpsGraphicsView::addLineItem(const qreal &x1,const qreal &y1,const { newLine->set_Exit(); } + else if (type=="HLine") + { + newLine->SetHLine(); + } else { newLine->set_Wall(); diff --git a/src/datamanager.cpp b/src/datamanager.cpp index 3b58cea..5f35521 100644 --- a/src/datamanager.cpp +++ b/src/datamanager.cpp @@ -1034,12 +1034,92 @@ bool jpsDatamanager::readXML(QFile &file) * and resets its internal state to the initial state. */ xmlReader.clear(); - ///AutoZoom to drawing - mView->AutoZoom(); + return true; +} + +bool jpsDatamanager::readRoutingXML(QFile &file) +{ + QXmlStreamReader xmlReader(&file); + + // skip header + xmlReader.readNext(); + xmlReader.readNext(); + + // see if file starts with geometry + if (xmlReader.name() != "routing") + return false; + + while(!xmlReader.atEnd() && !xmlReader.hasError()) + { + /* Read next element.*/ + QXmlStreamReader::TokenType token = xmlReader.readNext(); + /* If token is just StartDocument, we'll go to next.*/ + if(token == QXmlStreamReader::StartDocument) + { + continue; + } + + /* If token is StartElement, we'll see if we can read it.*/ + if(token == QXmlStreamReader::StartElement) + { + /* If it's named Hlines, we'll go to the next.*/ + if(xmlReader.name() == "Hlines") + { + continue; + } + + if(xmlReader.name() == "Hline") + { + this->parseHline(xmlReader); + } + } + } + /* Error handling. */ + if(xmlReader.hasError()) + { + QMessageBox::critical(mView, + "QXSRExample::parseXML", + xmlReader.errorString(), + QMessageBox::Ok); + return false; + } + /* Removes any device() or data from the reader + * and resets its internal state to the initial state. */ + xmlReader.clear(); return true; } +void jpsDatamanager::parseHline(QXmlStreamReader &xmlReader) +{ + + while(!(xmlReader.tokenType() == QXmlStreamReader::EndElement && + xmlReader.name() == "Hline")) + { + xmlReader.readNext(); + + if (xmlReader.tokenType()==QXmlStreamReader::StartElement && + xmlReader.name() == "vertex") + { + + // get coords from vertices + qreal x1=xmlReader.attributes().value("px").toString().toFloat(); + qreal y1=xmlReader.attributes().value("py").toString().toFloat(); + + // go to next vertex + xmlReader.readNext(); + xmlReader.readNext(); + xmlReader.readNext(); + + qreal x2=xmlReader.attributes().value("px").toString().toFloat(); + qreal y2=xmlReader.attributes().value("py").toString().toFloat(); + // add Line to graphview + mView->addLineItem(x1,y1,x2,y2,"HLine"); + } + + } +} + void jpsDatamanager::parseSubRoom(QXmlStreamReader &xmlReader) { // new subroom diff --git a/src/datamanager.h b/src/datamanager.h index fd35fa6..d1a14ca 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -103,6 +103,8 @@ class jpsDatamanager: public DL_CreationAdapter // Read XML bool readXML(QFile &file); + bool readRoutingXML(QFile &file); + void parseHline(QXmlStreamReader &xmlReader); void parseSubRoom(QXmlStreamReader &xmlReader); void parseWalls(QXmlStreamReader &xmlReader,jpsRoom* room); void parseWalls(QXmlStreamReader &xmlReader,jpsObstacle* room); diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 7d9317f..bc0f325 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -275,12 +275,18 @@ void MWindow::openFileXML() QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - return; } + //RoutingFile + QString fileNameRouting= fileName.split(".").first()+"_routing.xml"; + QFile fileRouting(fileNameRouting); + if (!fileRouting.open(QIODevice::ReadOnly | QIODevice::Text)) + { + return; + } - if (!dmanager->readXML(file)) + if (!dmanager->readXML(file) || !dmanager->readRoutingXML(fileRouting)) { QMessageBox::critical(this, "OpenFileXML", @@ -291,7 +297,8 @@ void MWindow::openFileXML() else { - + //AutoZoom to drawing + mview->AutoZoom(); statusBar()->showMessage("XML-File successfully loaded!",10000); } From f2ee2ee6e3e399982e61a3060b0996810acc9799 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 15:14:38 +0100 Subject: [PATCH 50/53] change info text --- src/mainWindow.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index bc0f325..6828809 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -384,8 +384,27 @@ void MWindow::saveAsDXF() void MWindow::info(){ - QMessageBox::information( - 0,tr("About..."),tr("JuPedSim; Interface for generating and editing geometry(XML)-files necessary for using JPScore; Manual and tutorial coming soon!")); + + + QString info = "JuPedSim v0.8 alpha\n\ + JPSeditor v0.8 alpha\n\ + ====================\n\ + \n\ + Erik Andresen drafted this on 27 Jun 2016\n\ + \n\ + We are proud to announce the first alpha release of our software JPSeditor (part of JuPedSim for simulating pedestrians evacuations). Please note that it is a pre release version for developers only. We are working hard towards the final release for this version.\n\ + \n\ + JPSeditor is a graphical user interface to create the geometry of a scenario simulated by JuPedSim. It comes with set of CAD- and further tools to simplify the creation of proper xml-files\n \ + incorporating information about the scenario' geometry.\n\ + \n\ + Tutorial\n\ + ========\n\ + \n\ + To highlight some features of JuPedSim we have uploaded some videos on our [YouTube channel](https://www.youtube.com/user/JuPedSim) including a tutorial showing how to use the editor."; + + QMessageBox messageBox; + messageBox.information(0,tr("About..."),info); + } void MWindow::anglesnap() From db2d6f1b51f4377e0a4b567ea4d5b02b505fadb5 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 15:15:54 +0100 Subject: [PATCH 51/53] fix infotext --- src/mainWindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mainWindow.cpp b/src/mainWindow.cpp index 6828809..39293e9 100644 --- a/src/mainWindow.cpp +++ b/src/mainWindow.cpp @@ -394,8 +394,7 @@ void MWindow::info(){ \n\ We are proud to announce the first alpha release of our software JPSeditor (part of JuPedSim for simulating pedestrians evacuations). Please note that it is a pre release version for developers only. We are working hard towards the final release for this version.\n\ \n\ - JPSeditor is a graphical user interface to create the geometry of a scenario simulated by JuPedSim. It comes with set of CAD- and further tools to simplify the creation of proper xml-files\n \ - incorporating information about the scenario' geometry.\n\ + JPSeditor is a graphical user interface to create the geometry of a scenario simulated by JuPedSim. It comes with set of CAD- and further tools to simplify the creation of proper xml-files incorporating information about the scenario' geometry.\n\ \n\ Tutorial\n\ ========\n\ From 6186654e8682077c640b3e6ad018bc320270c1a5 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 15:21:06 +0100 Subject: [PATCH 52/53] hide cognitive map buttons --- forms/mainwindow.ui | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 803f47c..8e958db 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -75,21 +75,10 @@ - - - true - - - Cognitive Map - - - - - @@ -417,7 +406,7 @@ true - true + false @@ -430,7 +419,7 @@ Landmark - true + false @@ -438,7 +427,7 @@ true - true + false @@ -451,7 +440,7 @@ LandmarkSpecs - true + false From 9631cf8f31bb4b6d11d78c5666260f420f2ce0fb Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 1 Feb 2016 16:17:12 +0100 Subject: [PATCH 53/53] Update Changelog --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af4217..c624c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file. ### Added #### JPSEDITOR +- 1.2.16 Undo/Redo when Line was edited +- 1.2.16 Change Info Text +- 1.2.16 Load HLines - 1.2.16 Create and save HLines - First approaches of an undo/redo framework - Undo/Redo working when line added or deleted @@ -20,5 +23,4 @@ All notable changes to this project will be documented in this file. - Length of line is displayed - Show origin - ... -- Room and door declarations - +- Room and door declarations \ No newline at end of file