| @@ -0,0 +1,97 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file RobotManager | ||
| * @date Created: 27-5-2015 | ||
| * | ||
| * @author Rene Keijzer | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
|
|
||
|
|
||
| #ifndef __ROBOTMANAGER__ | ||
| #define __ROBOTMANAGER__ | ||
| #include <vector> | ||
| #include <exception> | ||
| #include <sstream> | ||
| #include "Rosbee.h" | ||
| #include "Lidar.h" | ||
|
|
||
| class CPIUDPSocket; | ||
| class Rosbee; | ||
| class Lidar; | ||
| class RobotManager{ | ||
| public: | ||
| RobotManager(){} | ||
|
|
||
| void createUDPRobot(CPIUDPSocket * s); | ||
|
|
||
|
|
||
| template<typename T> | ||
| T * getRobot(int id){ | ||
| for(auto robot: robots){ | ||
| auto r = dynamic_cast<T *>(robot); | ||
| if(r != nullptr){ | ||
| if(id == r->getId()){ | ||
| return r; | ||
| } | ||
| } | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| template <typename T> | ||
| std::vector<T *> getRobots(){ | ||
| std::vector<T *> list; | ||
|
|
||
| for(auto robot : robots){ | ||
| auto r = dynamic_cast<T *>(robot); | ||
| if(r != nullptr){ | ||
| list.push_back(r); | ||
| } | ||
| } | ||
| return list; | ||
| } | ||
|
|
||
| template <typename T> | ||
| T * createRobot(CPIUDPSocket * s){ | ||
| T * robot= new T(s); | ||
| robots.push_back(robot); | ||
| return robot; | ||
| } | ||
|
|
||
| std::string getDetails(); | ||
|
|
||
| int size(); | ||
| private: | ||
| std::vector<CPIBoundaryObject * > robots; | ||
|
|
||
| }; | ||
| #endif |
| @@ -0,0 +1,68 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file Socket | ||
| * @date Created: 27-5-2015 | ||
| * | ||
| * @author Rene Keijzer | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| #ifndef __SOCKET__ | ||
| #define __SOCKET__ | ||
| #include <queue> | ||
| #include "roborescueV1/mavlink.h" | ||
| class UDPServer; | ||
|
|
||
| /// author@ Rene Keijzer<rene.keijzer@student.hu.nl> | ||
| /// class@ Socket | ||
| /// brief the base class for a socket, this has the virtual function which needs to be overwritten by other sockets like UDPsocket or a RF socket | ||
| class CPISocket{ | ||
| public: | ||
| CPISocket(){} | ||
|
|
||
| /// brief virtual send function which needs to be implemented | ||
| /// param@ pointer to mavlink message | ||
| virtual void send(mavlink_message_t * message) {} | ||
|
|
||
|
|
||
| /// \brief virtual receive function which needs to be implemented | ||
| /// param@ pointer to mavlink message | ||
| virtual void receive(mavlink_message_t * message){} | ||
|
|
||
|
|
||
| /// brief virtual getid function which needs to be implemented, returns 0 on default | ||
| /// return@ uint8_t id of socket | ||
| virtual uint8_t getId(){ return 0; } | ||
| ~CPISocket(){} | ||
| }; | ||
| #endif |
| @@ -0,0 +1,6 @@ | ||
| #include "UDPRobot.h" | ||
| UDPRobot::UDPRobot(CPIUDPSocket * s) : sock(s){ | ||
|
|
||
| encoder = new RALCPEncoder(s, s->getId(), 0, 0, 0); | ||
|
|
||
| } |
| @@ -2,7 +2,7 @@ | ||
| #include "UDPSocket.h" | ||
| #include "RALCPEncoder.h" | ||
| #include "MessageQueue.h" | ||
| #include "roborescueV1/mavlink.h" | ||
|
|
||
| #ifndef __UDPROBOT__ | ||
| #define __UDPROBOT__ | ||
| @@ -0,0 +1,119 @@ | ||
| #include "UDPServer.h" | ||
|
|
||
|
|
||
| UDPServer::UDPServer(RobotManager & manager) : manager(manager){ | ||
| recv = 0; | ||
| sourceAddress = ""; | ||
| sourcePort = 0; | ||
| std::cout << "Created server instance" << std::endl; | ||
| init(); | ||
| connectionThread = std::thread(&UDPServer::start, this); | ||
|
|
||
| } | ||
|
|
||
| void UDPServer::init(){ | ||
| //udpsock = new UDPSocket(8888); | ||
| std::cout << "Initialized socket at: \t 8888" << std::endl; | ||
| } | ||
|
|
||
| void UDPServer::start(){ | ||
| /*try { | ||
| while (!stopped) { | ||
| try{ | ||
| std::cout << "Waiting for message..." << std::endl; | ||
| receive(&msg); | ||
| addConnection(sourceAddress, sourcePort, &msg); | ||
| handleMessage(sourceAddress, sourcePort, &msg); | ||
| } | ||
| catch (SocketException ex){ | ||
| std::cout << "Nothing received : " << ex.what() << std::endl; | ||
| } | ||
| } | ||
| } | ||
| catch (SocketException &e) { | ||
| std::cerr << e.what() << std::endl; | ||
| exit(1); | ||
| }*/ | ||
|
|
||
| std::this_thread::yield(); | ||
| } | ||
|
|
||
| void UDPServer::printCon(){ | ||
| std::cout << "================= connections "<< _connections.size() <<" ==========="<<std::endl; | ||
| for(auto & sock : _connections){ | ||
| sock->print(); | ||
| } | ||
|
|
||
| std::cout << "============== end - connections ==========="<<std::endl; | ||
| } | ||
|
|
||
|
|
||
| void UDPServer::broadcast(mavlink_message_t * message){ | ||
| for (auto & socket : _connections){ | ||
| send(socket, message); | ||
| } | ||
| } | ||
|
|
||
| void UDPServer::send(CPIUDPSocket * socket, mavlink_message_t * message){ | ||
| //udpsock->sendTo(message, sizeof(mavlink_message_t), socket->con.sockaddr, socket->con.port); | ||
| } | ||
|
|
||
| void UDPServer::receive(mavlink_message_t * message){ | ||
| //auto data = udpsock->recvFrom(&msg, sizeof(mavlink_message_t), sourceAddress, sourcePort); | ||
| recv++; | ||
| } | ||
|
|
||
| void UDPServer::handleMessage(std::string con,unsigned short port, mavlink_message_t * msg){ | ||
| for (auto & socket : _connections){ | ||
| if (socket->con.sockaddr == con && socket->con.port == port){ | ||
| socket->receive(msg); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void UDPServer::addConnection(std::string con,unsigned short port, mavlink_message_t * msg){ | ||
| bool found = false; | ||
| for (auto * socket : _connections){ | ||
| if (socket->con.sockaddr == con && socket->con.port == port){ | ||
| found = true; | ||
| return; | ||
| } | ||
| } | ||
| if (!found){ | ||
| /*mavlink_msg_ralcp_decode(msg, &packet); | ||
| Connection connect = Connection(ConId, Connection::UNKNOWN, con,port); | ||
| ConId++; | ||
| Connection::Identifier des = Connection::UNKNOWN; | ||
| switch(packet.Destination){ | ||
| case COMMAND_DESTINATION::ROSBEE: | ||
| des = Connection::ROSBEE; | ||
| break; | ||
| case COMMAND_DESTINATION::LIDAR: | ||
| des = Connection::LIDAR; | ||
| break; | ||
| default: | ||
| std::cerr << "UNKNOWN DEVICE CONNECTION NOT HANDLED\r\n"; | ||
| return; | ||
| } | ||
| connect.type = des; | ||
| CPIUDPSocket * sock = new CPIUDPSocket(connect, this); | ||
| manager.createUDPRobot(sock); | ||
| _connections.push_back(sock); | ||
| sock->receive(msg); | ||
| printCon();*/ | ||
| } | ||
| } | ||
|
|
||
| void UDPServer::stop(){ | ||
| stopped = true; | ||
| } | ||
|
|
||
| UDPServer::~UDPServer(){ | ||
| for(auto * sock : _connections) | ||
| { | ||
| delete sock; | ||
| } | ||
| stop(); | ||
| } |
| @@ -0,0 +1,14 @@ | ||
| #include "UDPSocket.h" | ||
| void CPIUDPSocket::send(mavlink_message_t * message){ | ||
|
|
||
| server->send(this, message); | ||
| } | ||
|
|
||
| void CPIUDPSocket::receive(mavlink_message_t * message){ | ||
| incomming->add(message); | ||
| } | ||
|
|
||
| void CPIUDPSocket::print(){ | ||
| std::cout << "Id: "<< con.id << std::endl; | ||
| std::cout << "IP: " <<con.sockaddr << ":" << con.port << std::endl; | ||
| } |
| @@ -0,0 +1,86 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file UDPSocket | ||
| * @date Created: 27-5-2015 | ||
| * | ||
| * @author Rene Keijzer | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
|
|
||
|
|
||
| // Author@ Rene Keijzer | ||
| // class@ UDPSocket | ||
| // This class is used to make a connection with the client and to send and receive data. | ||
|
|
||
| #ifndef __UDPSOCKET__ | ||
| #define __UDPSOCKET__ | ||
| #include "Socket.h" | ||
| #include "Connection.h" | ||
| #include "UDPServer.h" | ||
| #include "roborescueV1/mavlink.h" | ||
| #include <iostream> | ||
|
|
||
| class CPIUDPSocket : public CPISocket | ||
| { | ||
| public: | ||
|
|
||
| // Constructor to make a socket | ||
| // Param@ Connection this is the connection you want to bind to the socket | ||
| // Param@ UDPServer This is the server where you want to talk with | ||
| CPIUDPSocket(Connection c, UDPServer * serv) : con(c), server(serv){ | ||
| incomming = new MessageQueue<mavlink_message_t *>(); | ||
| } | ||
|
|
||
| // This function sends a messege | ||
| //Param: message this is the message that you are sending | ||
| void send(mavlink_message_t * message) override; | ||
|
|
||
| void receive(mavlink_message_t * message) override; | ||
| // This function returns the connection id | ||
| // Return@ The id of the connection | ||
| uint8_t getId() override { return con.id; } | ||
|
|
||
| void print(); | ||
|
|
||
| // Standard destructor | ||
| ~CPIUDPSocket(){ | ||
| } | ||
| MessageQueue<mavlink_message_t *> * incomming; | ||
| protected: | ||
|
|
||
| private: | ||
| friend class UDPServer; | ||
| friend class RobotManager; | ||
| UDPServer * server; | ||
| Connection con; | ||
|
|
||
| }; | ||
| #endif |
| @@ -0,0 +1,5 @@ | ||
| .PHONY: clean | ||
|
|
||
| clean: | ||
| @echo 'Cleaning GUI' | ||
| rm -f *.o |
| @@ -0,0 +1,31 @@ | ||
| #------------------------------------------------- | ||
| # | ||
| # Project created by QtCreator 2015-05-11T15:18:25 | ||
| # | ||
| #------------------------------------------------- | ||
|
|
||
| QT += core gui | ||
|
|
||
| greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
|
||
| TARGET = Mapping_MapEditor | ||
| TEMPLATE = app | ||
| QMAKE_CXXFLAGS += -std=c++11 | ||
|
|
||
|
|
||
| SOURCES += main.cpp\ | ||
| mainwindow.cpp \ | ||
| composedpolygon.cpp \ | ||
| point.cpp \ | ||
| polyobject.cpp \ | ||
| storage.cpp \ | ||
| square.cpp | ||
|
|
||
| HEADERS += mainwindow.h \ | ||
| composedpolygon.h \ | ||
| point.h \ | ||
| polyobject.h \ | ||
| storage.h \ | ||
| square.h | ||
|
|
||
| FORMS += mainwindow.ui |
| @@ -0,0 +1,22 @@ | ||
| #include "composedpolygon.h" | ||
|
|
||
| composedPolygon::composedPolygon(point p) | ||
| { | ||
| //polygon = std::vector<point>(); | ||
| polygon.push_back(p); | ||
| //std::cout << "composedPolygon constructor\n"; | ||
| } | ||
|
|
||
| composedPolygon::~composedPolygon(){ | ||
| //delete polygon; | ||
| } | ||
|
|
||
| void composedPolygon::nextPoint(point p){ | ||
| polygon.push_back(p); | ||
| //std::cout << "composedPolygon nextPoint\n"; | ||
| } | ||
|
|
||
| std::vector<point> composedPolygon::applyPolygon(){ | ||
| polygon.push_back(polygon.front()); | ||
| return polygon; | ||
| } |
| @@ -0,0 +1,67 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file composedpolygon.h | ||
| * @date Created: 06/16/2015 | ||
| * @brief A class to handle polygons being built | ||
| * | ||
| * @author Jos Bijlenga | ||
| * | ||
| * @version 4.0 | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright � 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef COMPOSEDPOLYGON_H | ||
| #define COMPOSEDPOLYGON_H | ||
|
|
||
| #include "point.h" | ||
| #include <vector> | ||
| #include <iostream> | ||
|
|
||
| class composedPolygon | ||
| { | ||
| public: | ||
| //! Constructor of the polygon | ||
| //! @param The starting point of the polygon | ||
| composedPolygon(point p); | ||
| ~composedPolygon(); | ||
|
|
||
| //! Add a point to the polygon | ||
| //! @param The next point | ||
| void nextPoint(point p); | ||
|
|
||
| //! Finish the polygon shape | ||
| //! @return The complete polygon shape | ||
| std::vector<point> applyPolygon(); | ||
|
|
||
| private: | ||
| std::vector<point> polygon; | ||
| }; | ||
|
|
||
| #endif // COMPOSEDPOLYGON_H |
| @@ -0,0 +1,11 @@ | ||
| #include "mainwindow.h" | ||
| #include <QApplication> | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| QApplication a(argc, argv); | ||
| MainWindow w; | ||
| w.show(); | ||
|
|
||
| return a.exec(); | ||
| } |
| @@ -0,0 +1,154 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file mainwindow.h | ||
| * @date Created: 06/16/2015 | ||
| * @brief A class that handles gui actions | ||
| * | ||
| * @author Jos Bijlenga | ||
| * | ||
| * @version 4.0 | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright � 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef MAINWINDOW_H | ||
| #define MAINWINDOW_H | ||
|
|
||
| #include <QMainWindow> | ||
| #include "composedpolygon.h" | ||
| #include "QMouseEvent" | ||
| #include "point.h" | ||
| #include "storage.h" | ||
| #include "polyobject.h" | ||
| #include <QtCore> | ||
| #include <QtGui> | ||
| #include <QGraphicsScene> | ||
| #include <QGraphicsTextItem> | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include "square.h" | ||
| #include <QMessageBox> | ||
| #include <limits> | ||
|
|
||
| namespace Ui { | ||
| class MainWindow; | ||
| } | ||
|
|
||
| class MainWindow : public QMainWindow | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| explicit MainWindow(QWidget *parent = 0); | ||
| ~MainWindow(); | ||
|
|
||
| protected: | ||
| void mousePressEvent(QMouseEvent * event) Q_DECL_OVERRIDE; | ||
|
|
||
| private slots: | ||
| void on_pushButton_clicked(); | ||
| void on_pushButton_2_clicked(); | ||
| void on_pushButtonUndo_clicked(); | ||
| void on_pushButton_6_clicked(); | ||
| void on_listViewObjects_clicked(const QModelIndex &index); | ||
| void on_pushButtonBegin_clicked(); | ||
| void on_pushButton_7_clicked(); | ||
|
|
||
| private: | ||
| // methods | ||
|
|
||
| //! Undo a the previous drawn line | ||
| void undoLine(); | ||
|
|
||
| //! Draw a line to point p from lastpoint | ||
| //! @param The point to draw to | ||
| void drawLine(point p); | ||
|
|
||
| //! Add the number of a point to the graphicsview | ||
| //! @param The point to draw the point number | ||
| void addingPoint(QPoint p); | ||
|
|
||
| //! Add text to the listview of the unfinished polygon | ||
| //! @param The text to write to the listview | ||
| void addTextToObjects(QString s); | ||
|
|
||
| //! Draw and add an object | ||
| //! @param The position to draw the object | ||
| //! @param The name of the object | ||
| void drawAddObject(QPoint pos, QString object); | ||
|
|
||
| //! Get the index of the selected item | ||
| //! @param The selected item | ||
| int getSelectedItemIndex(int cur); | ||
|
|
||
| //! Extract the index from a string | ||
| //! @param The string to extract the index from | ||
| //! @return The index extracted from the string | ||
| int extractStringIndex(QString qs); | ||
|
|
||
| //! Delete the selected object | ||
| void deleteSelectedObject(); | ||
|
|
||
| QString retrieveSelectedString(int cur); | ||
|
|
||
| // const variables | ||
| const int drawingPanelWidth = 500; | ||
| const int drawingPanelHeight = 500; | ||
|
|
||
| // QT variables | ||
| Ui::MainWindow *ui; | ||
| QGraphicsScene * scene; | ||
| QPen blackPen; | ||
|
|
||
| QStringListModel *modelPoints; | ||
| QStringList listPoints; | ||
|
|
||
| QStringListModel *modelShapes; | ||
| QStringList listShapes; | ||
|
|
||
| QRect windowSize; | ||
|
|
||
| // objects | ||
| composedPolygon * poly; // the unfinished polygon | ||
| point lastPoint; // last point of polygon shape | ||
| storage * myStorage; // pointer to square and polygon storage | ||
|
|
||
| // variables | ||
| bool modifying; // is a shape being currently modified? | ||
| bool allowDrawing; // are you allowed to draw? | ||
|
|
||
| int pointCount; // amount of points | ||
| int shapeCount; // amount of shapes | ||
|
|
||
| int selectedObject; // the selected object in the listview | ||
|
|
||
| int height, width; // real height of the map | ||
| }; | ||
|
|
||
| #endif // MAINWINDOW_H |
| @@ -0,0 +1,29 @@ | ||
| #include "point.h" | ||
|
|
||
| point::point(int mX, int mY) | ||
| { | ||
| x = mX; | ||
| y = mY; | ||
| } | ||
|
|
||
| point::point(){ | ||
| x = 0; | ||
| y = 0; | ||
| } | ||
|
|
||
| point::~point(){} | ||
|
|
||
| std::ostream & operator<< (std::ostream &out, const point &p){ | ||
| return out << "(" << p.x << "," << p.y << ")"; | ||
| } | ||
|
|
||
| /*bool operator==(const point & lhs, const point & rhs){ | ||
| return lhs.x == rhs.x && lhs.y == rhs.y; | ||
| }*/ | ||
|
|
||
| bool point::equals(const point & p){ | ||
| return x == p.x && y == p.y; | ||
| } | ||
|
|
||
| int point::getX(){ return x; } | ||
| int point::getY(){ return y; } |
| @@ -0,0 +1,41 @@ | ||
| #ifndef POINT_H | ||
| #define POINT_H | ||
|
|
||
| #include <iostream> | ||
|
|
||
| class point | ||
| { | ||
| public: | ||
| //! Constructor of the point | ||
| //! @param The X-value of the point | ||
| //! @param The Y-value of the point | ||
| point(int mX, int mY); | ||
| point(); | ||
| ~point(); | ||
|
|
||
| //! Allows the point to be printed to the output stream | ||
| //! @param The standard output stream | ||
| //! @param The point to be printed | ||
| //! @return A standard output stream | ||
| friend std::ostream & operator<<(std::ostream & os, const point & p); | ||
|
|
||
| //friend bool operator==(const point & lhs, const point & rhs); | ||
|
|
||
| //! Compares the current point object with the point parameter | ||
| //! @param The point to compare with | ||
| //! @return The result of the comparison. True if equal, otherwise false. | ||
| bool equals(const point & p); | ||
|
|
||
| //! Get the X-value of the point | ||
| //! @return The X-Value of the point | ||
| int getX(); | ||
|
|
||
| //! Get the Y-value of the point | ||
| //! @return The Y-Value of the point | ||
| int getY(); | ||
|
|
||
| private: | ||
| int x, y; | ||
| }; | ||
|
|
||
| #endif // POINT_H |
| @@ -0,0 +1,21 @@ | ||
| #include "polyobject.h" | ||
|
|
||
| polyObject::polyObject(std::vector<point> p) | ||
| { | ||
| shape = p; | ||
| } | ||
|
|
||
| std::vector<point> polyObject::getShape(){ | ||
| return shape; | ||
| } | ||
|
|
||
| bool polyObject::equals(polyObject & po){ | ||
| if(shape.size() != po.getShape().size()) return false; | ||
|
|
||
| std::vector<point> tmp = po.getShape(); | ||
| for(unsigned int i = 0; i < shape.size(); i++){ | ||
| if(tmp[i].equals(shape[i])) return false; | ||
| } | ||
|
|
||
| return true; | ||
| } |
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file polyobject.h | ||
| * @date Created: 06/16/2015 | ||
| * @brief A class that is a polygon (collection of points) | ||
| * | ||
| * @author Jos Bijlenga | ||
| * | ||
| * @version 4.0 | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright � 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef POLYOBJECT_H | ||
| #define POLYOBJECT_H | ||
|
|
||
| #include "point.h" | ||
| #include <vector> | ||
|
|
||
| class polyObject | ||
| { | ||
| public: | ||
| //! Constructor | ||
| //! @param A vector of points that is the polygon | ||
| polyObject(std::vector<point> p); | ||
|
|
||
| //! Get the complete polygon shape | ||
| std::vector<point> getShape(); | ||
|
|
||
| //! Compare two polyObjects | ||
| //! @param The polygObject to be compared | ||
| bool equals(polyObject & po); | ||
|
|
||
| private: | ||
| std::vector<point> shape; | ||
| }; | ||
|
|
||
| #endif // POLYOBJECT_H |
| @@ -0,0 +1,32 @@ | ||
| #include "square.h" | ||
|
|
||
| square::square(point p, int w, int h, char t) | ||
| : begin{p}, | ||
| width{w}, | ||
| height{h}, | ||
| type{t} | ||
| {} | ||
|
|
||
| bool square::equals(square & s){ | ||
| if(!begin.equals(s.getStart())) return false; | ||
| if(!(width == s.getWidth())) return false; | ||
| if(!(height == s.getHeight())) return false; | ||
| if(!(type == s.getType())) return false; | ||
| return true; | ||
| } | ||
|
|
||
| point square::getStart(){ | ||
| return begin; | ||
| } | ||
|
|
||
| int square::getWidth(){ | ||
| return width; | ||
| } | ||
|
|
||
| int square::getHeight(){ | ||
| return height; | ||
| } | ||
|
|
||
| char square::getType(){ | ||
| return type; | ||
| } |
| @@ -0,0 +1,81 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file square.h | ||
| * @date Created: 06/16/2015 | ||
| * @brief A class that is a square used as object e.g. QR, ATV etc. | ||
| * | ||
| * @author Jos Bijlenga | ||
| * | ||
| * @version 4.0 | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright � 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef SQUARE_H | ||
| #define SQUARE_H | ||
|
|
||
| #include "point.h" | ||
|
|
||
| class square | ||
| { | ||
| public: | ||
| //! Constructor | ||
| //! @param The top-left point of the square | ||
| //! @param The width of the square | ||
| //! @param The height of the square | ||
| //! @param The type of the object (q = QR, c = quadcopter, a = ATV, r = rosbee) | ||
| square(point p, int w, int h, char t); | ||
|
|
||
| //! Get the top-left point of the square | ||
| //! @return The top-left point of the square | ||
| point getStart(); | ||
|
|
||
| //! Get the width of the square object | ||
| //! @return The width of the square object | ||
| int getWidth(); | ||
|
|
||
| //! Get the height of the square object | ||
| //! @return The height of the square object | ||
| int getHeight(); | ||
|
|
||
| //! Get the type of the square object | ||
| //! @return The type of the square object | ||
| char getType(); | ||
|
|
||
|
|
||
| bool equals(square & s); | ||
|
|
||
| private: | ||
| point begin; | ||
| int width; | ||
| int height; | ||
| char type; | ||
| }; | ||
|
|
||
| #endif // SQUARE_H |
| @@ -0,0 +1,52 @@ | ||
| #include "storage.h" | ||
| #include <iostream> | ||
|
|
||
| storage::storage() | ||
| { | ||
| //polyObjects = new std::vector<polyObject>; | ||
| //objects = new std::vector<square>; | ||
| } | ||
|
|
||
| void storage::addPolyObject(polyObject obj){ | ||
| polyObjects.push_back(obj); | ||
| } | ||
|
|
||
| std::vector<polyObject> storage::getPolyObjects(){ | ||
| return polyObjects; | ||
| } | ||
|
|
||
| void storage::addObject(point p, int width, int height, char type){ | ||
| //square tmp = square(p, width, height, type); | ||
| //square tm = square(p, width, height); | ||
| objects.push_back(square(p, width, height, type)); | ||
| } | ||
|
|
||
| std::vector<square> storage::getObjects(){ | ||
| return objects; | ||
| } | ||
|
|
||
| void storage::deletePolyObject(polyObject p){ | ||
| if(polyObjects.size()<= 0) return; | ||
| std::vector<polyObject>::iterator track = polyObjects.begin(); | ||
| while(track != polyObjects.end()){ | ||
| if(track->equals(p)){ | ||
| polyObjects.erase(track); | ||
| break; | ||
| } | ||
| ++track; | ||
| } | ||
| } | ||
|
|
||
| void storage::deleteObject(point p, int width, int height, char type){ | ||
| std::cout << p << ", " << width << ", " << height << ", " << type << std::endl; | ||
| if(objects.size()<=0) return; | ||
| square tmp = square(p, width, height, type); | ||
| std::vector<square>::iterator track = objects.begin(); | ||
| while (track != objects.end()){ | ||
| if(track->equals(tmp)){ | ||
| objects.erase(track); | ||
| break; | ||
| } | ||
| ++track; | ||
| } | ||
| } |
| @@ -0,0 +1,85 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file storage.h | ||
| * @date Created: 06/16/2015 | ||
| * @brief A class that stores polygon shapes and square objects | ||
| * | ||
| * @author Jos Bijlenga | ||
| * | ||
| * @version 4.0 | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright � 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef STORAGE_H | ||
| #define STORAGE_H | ||
|
|
||
| #include "polyobject.h" | ||
| #include <vector> | ||
| #include "square.h" | ||
|
|
||
| class storage | ||
| { | ||
| public: | ||
| //! Constructor | ||
| storage(); | ||
|
|
||
| //! Get all the polygon objects | ||
| //! @return All polygon objects | ||
| std::vector<polyObject> getPolyObjects(); | ||
|
|
||
| //! Get all the square objects | ||
| //! @return All the square objects | ||
| std::vector<square> getObjects(); | ||
|
|
||
| //! Add a polygon object to the storage | ||
| //! @param The polygon object to be added to the storage | ||
| void addPolyObject(polyObject obj); | ||
|
|
||
| //! Add a square object to the storage | ||
| //! @param The square object to be added to the storage | ||
| void addObject(point p, int width, int height, char type); | ||
|
|
||
| //! Delete a polygon object from the storage | ||
| //! @param The polygon object to be deleted | ||
| void deletePolyObject(polyObject p); | ||
|
|
||
| //! Delete a square object from the storage | ||
| //! @param The point of the square | ||
| //! @param The width of the square | ||
| //! @param The height of the square | ||
| //! @param The type of the square object | ||
| void deleteObject(point p, int width, int height, char type); | ||
|
|
||
| private: | ||
| std::vector<polyObject> polyObjects; | ||
| std::vector<square> objects; | ||
| }; | ||
|
|
||
| #endif // STORAGE_H |
| @@ -0,0 +1,10 @@ | ||
| 0 0 0 0 0 0 1 0 0 0 1 | ||
| 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 1 0 1 0 0 1 0 0 1 0 | ||
| 1 0 0 0 0 1 0 0 0 0 0 | ||
| 0 0 0 0 0 0 1 0 0 0 0 | ||
| 0 0 1 1 0 0 0 0 0 1 0 | ||
| 0 0 0 1 0 0 0 0 0 0 0 | ||
| 0 1 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 1 0 0 0 0 1 0 |
| @@ -0,0 +1,10 @@ | ||
| 0 | ||
| 0 0 | ||
| 0:2 | ||
| -1:1 | ||
| 1:1 | ||
| -2:0 | ||
| 2:0 | ||
| -1:-1 | ||
| 1:-1 | ||
| 0:-2 |
| @@ -0,0 +1,27 @@ | ||
| 0 | ||
| 0 0 | ||
| 6:9 | ||
| -7:8 | ||
| -4:8 | ||
| -9:6 | ||
| -3:5 | ||
| 1:5 | ||
| 6:5 | ||
| -7:4 | ||
| -9:3 | ||
| -1:3 | ||
| 4:3 | ||
| -1:2 | ||
| 7:2 | ||
| -2:1 | ||
| 8:1 | ||
| -2:0 | ||
| 4:0 | ||
| 0:-1 | ||
| 1:-1 | ||
| -5:-2 | ||
| -8:-3 | ||
| -4:-3 | ||
| -2:-3 | ||
| -4:-4 | ||
| -2:-4 |
| @@ -0,0 +1,20 @@ | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| @@ -0,0 +1,20 @@ | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| @@ -0,0 +1,20 @@ | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0SSSSS0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 nke0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 111111 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0000 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0efb hsef 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0fbjskf 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 9999 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| @@ -0,0 +1,20 @@ | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| @@ -0,0 +1,38 @@ | ||
| Enviroment Simulator test begin | ||
| Enviroment Simulator test Map from file | ||
| Enviroment Simulator test Map from corrupt file | ||
| Map from corrupt file: Lets see | ||
| Enviroment Simulator test Map not from file | ||
| Enviroment Simulator test Save file | ||
| Enviroment Simulator test Vector abuse | ||
| Vector: Set map content with too small vector | ||
| Vector: Set map content with too big vector | ||
| Enviroment Simulator test Simulate | ||
| addCheckPoint 21 21 | ||
| addCheckPoint -1 -1 | ||
| Simulate: Lest see | ||
| Simulate: Lest see | ||
| Simulate: Lest see | ||
| addObject 5 9 right side from checkpoint | ||
| addObject 5 10 right side from checkpoint | ||
| addObject 5 5 left side from checkpoint | ||
| addObject 5 4 left side from checkpoint | ||
| addObject 3 7 upper side from checkpoint | ||
| addObject 2 7 upper side from checkpoint | ||
| addObject 7 7 lower side from checkpoint | ||
| addObject 8 7 lower side from checkpoint | ||
| addObject 4 6 left up side diagonal checkpoint | ||
| addObject 5 3 left up side diagonal checkpoint | ||
| addObject 6 6 left down side diagonal checkpoint | ||
| addObject 5 7 left down side diagonal checkpoint | ||
| addObject 8 4 right up side diagonal checkpoint | ||
| addObject 9 3 right up side diagonal checkpoint | ||
| addObject 8 6 right down side diagonal checkpoint | ||
| addObject 9 7 right down side diagonal checkpoint | ||
| addCheckPoint 5 7 | ||
| Enviroment Simulator object behind object test PointCloud | ||
| Enviroment Simulator test PointCloud | ||
| Enviroment Simulator test done | ||
| Test Succes! | ||
|
|
||
|
|
| @@ -0,0 +1,20 @@ | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| @@ -0,0 +1,2 @@ | ||
| 0 0 0 0 | ||
| 0 0 0 1 |
| @@ -0,0 +1,3 @@ | ||
| 0 | ||
| 0 0 | ||
| 3:1 |
| @@ -0,0 +1,67 @@ | ||
| /******************************************************************************** | ||
| ** Form generated from reading UI file 'editmapwindow.ui' | ||
| ** | ||
| ** Created by: Qt User Interface Compiler version 5.4.1 | ||
| ** | ||
| ** WARNING! All changes made in this file will be lost when recompiling UI file! | ||
| ********************************************************************************/ | ||
|
|
||
| #ifndef UI_EDITMAPWINDOW_H | ||
| #define UI_EDITMAPWINDOW_H | ||
|
|
||
| #include <QtCore/QVariant> | ||
| #include <QtWidgets/QAction> | ||
| #include <QtWidgets/QApplication> | ||
| #include <QtWidgets/QButtonGroup> | ||
| #include <QtWidgets/QDialog> | ||
| #include <QtWidgets/QHeaderView> | ||
| #include <QtWidgets/QPushButton> | ||
| #include <QtWidgets/QRadioButton> | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class Ui_EditMapWindow | ||
| { | ||
| public: | ||
| QPushButton *saveMapButton; | ||
| QRadioButton *obstacleButton; | ||
| QRadioButton *noneButton; | ||
|
|
||
| void setupUi(QDialog *EditMapWindow) | ||
| { | ||
| if (EditMapWindow->objectName().isEmpty()) | ||
| EditMapWindow->setObjectName(QStringLiteral("EditMapWindow")); | ||
| EditMapWindow->resize(640, 480); | ||
| saveMapButton = new QPushButton(EditMapWindow); | ||
| saveMapButton->setObjectName(QStringLiteral("saveMapButton")); | ||
| saveMapButton->setGeometry(QRect(520, 440, 113, 32)); | ||
| obstacleButton = new QRadioButton(EditMapWindow); | ||
| obstacleButton->setObjectName(QStringLiteral("obstacleButton")); | ||
| obstacleButton->setGeometry(QRect(540, 10, 102, 20)); | ||
| obstacleButton->setChecked(true); | ||
| noneButton = new QRadioButton(EditMapWindow); | ||
| noneButton->setObjectName(QStringLiteral("noneButton")); | ||
| noneButton->setGeometry(QRect(540, 40, 102, 20)); | ||
|
|
||
| retranslateUi(EditMapWindow); | ||
|
|
||
| QMetaObject::connectSlotsByName(EditMapWindow); | ||
| } // setupUi | ||
|
|
||
| void retranslateUi(QDialog *EditMapWindow) | ||
| { | ||
| EditMapWindow->setWindowTitle(QApplication::translate("EditMapWindow", "Dialog", 0)); | ||
| saveMapButton->setText(QApplication::translate("EditMapWindow", "Save Map", 0)); | ||
| obstacleButton->setText(QApplication::translate("EditMapWindow", "Obstacle", 0)); | ||
| noneButton->setText(QApplication::translate("EditMapWindow", "None", 0)); | ||
| } // retranslateUi | ||
|
|
||
| }; | ||
|
|
||
| namespace Ui { | ||
| class EditMapWindow: public Ui_EditMapWindow {}; | ||
| } // namespace Ui | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| #endif // UI_EDITMAPWINDOW_H |
| @@ -0,0 +1,86 @@ | ||
| /******************************************************************************** | ||
| ** Form generated from reading UI file 'mainwindow.ui' | ||
| ** | ||
| ** Created by: Qt User Interface Compiler version 5.4.1 | ||
| ** | ||
| ** WARNING! All changes made in this file will be lost when recompiling UI file! | ||
| ********************************************************************************/ | ||
|
|
||
| #ifndef UI_MAINWINDOW_H | ||
| #define UI_MAINWINDOW_H | ||
|
|
||
| #include <QtCore/QVariant> | ||
| #include <QtWidgets/QAction> | ||
| #include <QtWidgets/QApplication> | ||
| #include <QtWidgets/QButtonGroup> | ||
| #include <QtWidgets/QHeaderView> | ||
| #include <QtWidgets/QMainWindow> | ||
| #include <QtWidgets/QMenuBar> | ||
| #include <QtWidgets/QPushButton> | ||
| #include <QtWidgets/QStatusBar> | ||
| #include <QtWidgets/QToolBar> | ||
| #include <QtWidgets/QWidget> | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class Ui_MainWindow | ||
| { | ||
| public: | ||
| QWidget *centralWidget; | ||
| QPushButton *newMapButton; | ||
| QPushButton *editMapButton; | ||
| QPushButton *simulateButton; | ||
| QMenuBar *menuBar; | ||
| QToolBar *mainToolBar; | ||
| QStatusBar *statusBar; | ||
|
|
||
| void setupUi(QMainWindow *MainWindow) | ||
| { | ||
| if (MainWindow->objectName().isEmpty()) | ||
| MainWindow->setObjectName(QStringLiteral("MainWindow")); | ||
| MainWindow->resize(400, 110); | ||
| centralWidget = new QWidget(MainWindow); | ||
| centralWidget->setObjectName(QStringLiteral("centralWidget")); | ||
| newMapButton = new QPushButton(centralWidget); | ||
| newMapButton->setObjectName(QStringLiteral("newMapButton")); | ||
| newMapButton->setGeometry(QRect(10, 10, 113, 32)); | ||
| editMapButton = new QPushButton(centralWidget); | ||
| editMapButton->setObjectName(QStringLiteral("editMapButton")); | ||
| editMapButton->setGeometry(QRect(150, 10, 113, 32)); | ||
| simulateButton = new QPushButton(centralWidget); | ||
| simulateButton->setObjectName(QStringLiteral("simulateButton")); | ||
| simulateButton->setGeometry(QRect(280, 10, 113, 32)); | ||
| MainWindow->setCentralWidget(centralWidget); | ||
| menuBar = new QMenuBar(MainWindow); | ||
| menuBar->setObjectName(QStringLiteral("menuBar")); | ||
| menuBar->setGeometry(QRect(0, 0, 400, 22)); | ||
| MainWindow->setMenuBar(menuBar); | ||
| mainToolBar = new QToolBar(MainWindow); | ||
| mainToolBar->setObjectName(QStringLiteral("mainToolBar")); | ||
| MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); | ||
| statusBar = new QStatusBar(MainWindow); | ||
| statusBar->setObjectName(QStringLiteral("statusBar")); | ||
| MainWindow->setStatusBar(statusBar); | ||
|
|
||
| retranslateUi(MainWindow); | ||
|
|
||
| QMetaObject::connectSlotsByName(MainWindow); | ||
| } // setupUi | ||
|
|
||
| void retranslateUi(QMainWindow *MainWindow) | ||
| { | ||
| MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0)); | ||
| newMapButton->setText(QApplication::translate("MainWindow", "New map", 0)); | ||
| editMapButton->setText(QApplication::translate("MainWindow", "Edit map", 0)); | ||
| simulateButton->setText(QApplication::translate("MainWindow", "Simulate", 0)); | ||
| } // retranslateUi | ||
|
|
||
| }; | ||
|
|
||
| namespace Ui { | ||
| class MainWindow: public Ui_MainWindow {}; | ||
| } // namespace Ui | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| #endif // UI_MAINWINDOW_H |
| @@ -0,0 +1,77 @@ | ||
| /******************************************************************************** | ||
| ** Form generated from reading UI file 'simulatemapwindow.ui' | ||
| ** | ||
| ** Created by: Qt User Interface Compiler version 5.4.1 | ||
| ** | ||
| ** WARNING! All changes made in this file will be lost when recompiling UI file! | ||
| ********************************************************************************/ | ||
|
|
||
| #ifndef UI_SIMULATEMAPWINDOW_H | ||
| #define UI_SIMULATEMAPWINDOW_H | ||
|
|
||
| #include <QtCore/QVariant> | ||
| #include <QtWidgets/QAction> | ||
| #include <QtWidgets/QApplication> | ||
| #include <QtWidgets/QButtonGroup> | ||
| #include <QtWidgets/QHeaderView> | ||
| #include <QtWidgets/QPushButton> | ||
| #include <QtWidgets/QRadioButton> | ||
| #include <QtWidgets/QWidget> | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class Ui_SimulateMapWindow | ||
| { | ||
| public: | ||
| QPushButton *simulateButton; | ||
| QRadioButton *noneButton; | ||
| QRadioButton *checkpointButton; | ||
| QPushButton *savePcButton; | ||
| QPushButton *savePcWNButton; | ||
|
|
||
| void setupUi(QWidget *SimulateMapWindow) | ||
| { | ||
| if (SimulateMapWindow->objectName().isEmpty()) | ||
| SimulateMapWindow->setObjectName(QStringLiteral("SimulateMapWindow")); | ||
| SimulateMapWindow->resize(673, 475); | ||
| simulateButton = new QPushButton(SimulateMapWindow); | ||
| simulateButton->setObjectName(QStringLiteral("simulateButton")); | ||
| simulateButton->setGeometry(QRect(560, 440, 111, 23)); | ||
| noneButton = new QRadioButton(SimulateMapWindow); | ||
| noneButton->setObjectName(QStringLiteral("noneButton")); | ||
| noneButton->setGeometry(QRect(560, 70, 102, 20)); | ||
| checkpointButton = new QRadioButton(SimulateMapWindow); | ||
| checkpointButton->setObjectName(QStringLiteral("checkpointButton")); | ||
| checkpointButton->setGeometry(QRect(560, 30, 102, 20)); | ||
| checkpointButton->setChecked(true); | ||
| savePcButton = new QPushButton(SimulateMapWindow); | ||
| savePcButton->setObjectName(QStringLiteral("savePcButton")); | ||
| savePcButton->setGeometry(QRect(560, 410, 113, 32)); | ||
| savePcWNButton = new QPushButton(SimulateMapWindow); | ||
| savePcWNButton->setObjectName(QStringLiteral("savePcWNButton")); | ||
| savePcWNButton->setGeometry(QRect(560, 380, 113, 32)); | ||
|
|
||
| retranslateUi(SimulateMapWindow); | ||
|
|
||
| QMetaObject::connectSlotsByName(SimulateMapWindow); | ||
| } // setupUi | ||
|
|
||
| void retranslateUi(QWidget *SimulateMapWindow) | ||
| { | ||
| SimulateMapWindow->setWindowTitle(QApplication::translate("SimulateMapWindow", "Form", 0)); | ||
| simulateButton->setText(QApplication::translate("SimulateMapWindow", "Simulate", 0)); | ||
| noneButton->setText(QApplication::translate("SimulateMapWindow", "None", 0)); | ||
| checkpointButton->setText(QApplication::translate("SimulateMapWindow", "Checkpoints", 0)); | ||
| savePcButton->setText(QApplication::translate("SimulateMapWindow", "Save PC", 0)); | ||
| savePcWNButton->setText(QApplication::translate("SimulateMapWindow", "Save PC with noise", 0)); | ||
| } // retranslateUi | ||
|
|
||
| }; | ||
|
|
||
| namespace Ui { | ||
| class SimulateMapWindow: public Ui_SimulateMapWindow {}; | ||
| } // namespace Ui | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| #endif // UI_SIMULATEMAPWINDOW_H |
| @@ -0,0 +1,233 @@ | ||
|
|
||
| /* | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file PointCloud.cpp | ||
| * @date Created: 22-04-15 | ||
| * | ||
| * @version 1.1 | ||
| * @author Tijmen Bruggeman | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
| #include "PointCloud.h" | ||
|
|
||
| void Pointcloud::setPoint(Point point){ | ||
| removePoint(point.X, point.Y); | ||
| pointCloud->push_back(point); | ||
| } | ||
| void Pointcloud::setPoint(int x, int y){ | ||
| removePoint(x, y); | ||
| Point * point = new Point{ x, y }; | ||
| pointCloud->push_back(*point); | ||
| } | ||
| Pointcloud::Point Pointcloud::getOffset(){ | ||
| return offset; | ||
| } | ||
| void Pointcloud::setOffset(Pointcloud::Point newOffset){ | ||
| offset = newOffset; | ||
| int xOffset = offset.X; | ||
| int yOffset = offset.Y; | ||
| int newX, newY; | ||
| for (Pointcloud::Point p : *this->getPoints()) { | ||
| int oldX = p.X; | ||
| int oldY = p.Y; | ||
| newX = oldX + xOffset; | ||
| newY = oldY + yOffset; | ||
| this->removePoint(oldX,oldY); | ||
| this->setPoint(newX,newY); | ||
| } | ||
| } | ||
| std::vector<Pointcloud::Point> *Pointcloud::getPoints(){ | ||
| return pointCloud; | ||
| } | ||
| void Pointcloud::removePoint(int x, int y){ | ||
| int i = 0; | ||
| for (Point p : *pointCloud){ | ||
| if (p.X == x && p.Y == y){ | ||
| pointCloud->erase(pointCloud->begin()+i); | ||
| break; | ||
| } | ||
| ++i; | ||
| } | ||
| } | ||
| void Pointcloud::removePoint(Point point){ | ||
| int i = 0; | ||
| for (Point p : *pointCloud){ | ||
| if (p.X == point.X && p.Y == point.Y){ | ||
| pointCloud->erase(pointCloud->begin() + i); | ||
| break; | ||
| } | ||
| ++i; | ||
| } | ||
| } | ||
| Pointcloud::Pointcloud(){ | ||
| pointCloud = new std::vector<Point>(); | ||
| offset.X = 0; | ||
| offset.Y = 0; | ||
| orientation = 0; | ||
| } | ||
| Pointcloud::Point Pointcloud::getMinValues(){ | ||
| int minX = 0; | ||
| int minY = 0; | ||
| for (Pointcloud::Point p : *pointCloud){ | ||
| if (p.X < minX){ | ||
| minX = p.X; | ||
| } | ||
| if (p.Y < minY){ | ||
| minY = p.Y; | ||
| } | ||
| } | ||
| return Pointcloud::Point{ minX, minY }; | ||
| } | ||
| int Pointcloud::getCloudHeight(){ | ||
| int maxHeight = 0; | ||
| int minHeight = 0; | ||
| for (Point p : *pointCloud){ | ||
| if (p.Y < minHeight){ | ||
| minHeight = p.Y; | ||
| } | ||
| if (p.Y > maxHeight){ | ||
| maxHeight = p.Y; | ||
| } | ||
| } | ||
| return maxHeight - minHeight; | ||
| } | ||
| int Pointcloud::getCloudWidth(){ | ||
| int maxWidth = 0; | ||
| int minWidth = 0; | ||
| for (Point p : *pointCloud){ | ||
| if (p.X > maxWidth){ | ||
| maxWidth = p.X; | ||
| } | ||
|
|
||
| if (p.X < minWidth){ | ||
| minWidth = p.X; | ||
| } | ||
| } | ||
| return maxWidth - minWidth; | ||
| } | ||
| void Pointcloud::setOrientation(int degrees){ | ||
| orientation = degrees; | ||
| this->rotate((float)orientation); | ||
| } | ||
| int Pointcloud::getOrientation(){ | ||
| return orientation; | ||
| } | ||
|
|
||
| void Pointcloud::savePointsToFile(std::string filename){ | ||
| std::ofstream pCFile; | ||
| pCFile.open(filename); | ||
| if(!pCFile.is_open()) return; | ||
| pCFile << orientation <<'\n' << offset.X << " " << offset.Y << "\n"; | ||
| for(Pointcloud::Point point : *pointCloud){ | ||
| pCFile << point.X << ":" << point.Y << '\n'; | ||
| } | ||
| pCFile.close(); | ||
| } | ||
| void Pointcloud::loadPointsFromFile(std::string filename){ | ||
| std::ifstream pCFile; | ||
| pCFile.open(filename); | ||
| if(!pCFile.is_open()){ | ||
| std::cout << "cant open" << filename << std::endl; | ||
| return; | ||
| } | ||
| if(!pointCloud->empty()){ | ||
| std::cout << "Load on a not empty pointcloud?" << std::endl; | ||
| return; | ||
| } | ||
| std::string line; | ||
| std::string item; | ||
| int result; | ||
| pCFile >> orientation >> offset.X >> offset.Y; | ||
| while(std::getline(pCFile, line)){ | ||
| Pointcloud::Point point; | ||
| std::stringstream ss(line); | ||
| std::getline(ss, item, ':'); | ||
| std::stringstream convertX(item); | ||
| if ( !(convertX >> result) )continue; | ||
| point.X = result; | ||
|
|
||
| std::getline(ss, item, ':'); | ||
| std::stringstream convertY(item); | ||
| if ( !(convertY >> result) )result = 0; | ||
| point.Y = result; | ||
| setPoint(point); | ||
| } | ||
| pCFile.close(); | ||
| } | ||
|
|
||
| void Pointcloud::printPoints(){ | ||
| for (Pointcloud::Point p : *this->getPoints()){ | ||
| std::cout << p << "\n"; | ||
| } | ||
| } | ||
|
|
||
| Pointcloud* Pointcloud::rotate(float angle){ | ||
| const int halfCircle = 180; | ||
| float sn = sin(angle*M_PI/halfCircle); | ||
| float cs = cos(angle*M_PI/halfCircle); | ||
|
|
||
| for (Pointcloud::Point p : *this->getPoints()) { | ||
| int x = p.X; | ||
| int y = p.Y; | ||
| int nx = x * cs - y * sn; | ||
| int ny = x * sn + y * cs; | ||
| this->removePoint(x, y); | ||
| this->setPoint(nx,ny); | ||
| nx = 0; | ||
| ny = 0; | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| //OPERATORS | ||
| std::ostream & operator<<(std::ostream & output, const Pointcloud::Point & s){ | ||
| output << "(" << s.X << "," << s.Y << ")"; | ||
| return output; | ||
| } | ||
| Pointcloud Pointcloud::operator+(Pointcloud & b){ | ||
| Pointcloud pt; | ||
| for (Pointcloud::Point p : *b.getPoints()){ | ||
| pt.setPoint(p); | ||
| } | ||
| for (Pointcloud::Point p : *pointCloud){ | ||
| pt.removePoint(p); | ||
| pt.setPoint(p); | ||
| } | ||
| pt.setOrientation(orientation); | ||
| return pt; | ||
| } | ||
| Pointcloud Pointcloud::operator+=(Pointcloud & b){ | ||
| for (Pointcloud::Point p : *b.getPoints()){ | ||
| setPoint(p); | ||
| } | ||
| return *this; | ||
| } |
| @@ -0,0 +1,176 @@ | ||
|
|
||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file PointCloud.h | ||
| * @date Created: 22-04-15 | ||
| * | ||
| * @version 1.1 | ||
| * @author Tijmen Bruggeman | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #ifndef POINTCLOUD_H | ||
| #define POINTCLOUD_H | ||
| #include <vector> | ||
| #include <stdlib.h> | ||
| #include <ostream> | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <sstream> | ||
| #include <math.h> | ||
| #define M_PI 3.14159265358979323846 | ||
| class Pointcloud{ //! a struct which will contain a single point | ||
| public: | ||
| ~Pointcloud(){ | ||
| std::cout << "POINTCLOUD ESTROYED\n\n"; | ||
| } | ||
| //!The Contructor for the pointcloud | ||
| Pointcloud(); | ||
|
|
||
| //! A object which will contain a single point | ||
| struct Point{ | ||
| int X; //! The x value of a single point | ||
| int Y; //! the Y-value of a single point | ||
| }; | ||
| //! Set a point in the pointcloud | ||
| /*! | ||
| Add a single point to the pointcloud | ||
| @param point: the point object which will be added to the pointcloud | ||
| */ | ||
| void setPoint(Point point); | ||
| //! Set a point in the pointcloud | ||
| /*! | ||
| Add a single point to the pointcloud | ||
| @param x: the x value of the point to be added to the pointcloud | ||
| @param y: the y value of the point to be added to the pointcloud | ||
| */ | ||
| void setPoint(int x, int y); | ||
| //! get all the points of the pointcloud | ||
| /*! | ||
| get all the points of a pointcloud returned in a vector | ||
| @return std::vector<point>: the vector which will contain all the points of the pointcloud | ||
| */ | ||
| std::vector<Point> * getPoints(); | ||
| //! remove a point from the pointcloud | ||
| /*! | ||
| remove a single point from the pointcloud | ||
| @param x: the x value of the point to be removed from the pointcloud | ||
| @param y: the y value of the point to be removed from the pointcloud | ||
| */ | ||
| void removePoint(Point p); | ||
| //! remove a point from the pointcloud | ||
| /*! | ||
| remove a single point from the pointcloud | ||
| @param p: the point to be removed from the pointcloud | ||
| */ | ||
| void removePoint(int x, int y); | ||
| //! get the width of the pointcloud | ||
| /*! | ||
| get the max width of the poincloud, this equals the max negative value + the max positive value | ||
| @return int: the integer with the max width | ||
| */ | ||
| int getCloudWidth(); | ||
| //! get the minimun x and y values of the pointcloud | ||
| /*! | ||
| get the minimun X and Y values of the pointcloud | ||
| @return Point: returns the point with the minimum X and Y value | ||
| */ | ||
| Pointcloud::Point getMinValues(); | ||
| //! get the height of the pointcloud | ||
| /*! | ||
| get the max height of the poincloud, this equals the max negative value + the max positive value | ||
| @return int: the integer with the max height | ||
| */ | ||
| int getCloudHeight(); | ||
|
|
||
| //! set the orientation of the poincloud | ||
| /*! | ||
| set the orientation of the poincloud | ||
| @param int: the integer with the orientation in degrees | ||
| */ | ||
| void setOrientation(int degrees); | ||
| //! get the orientation of the pointcloud | ||
| /*! | ||
| get the orientation of the pointcloud in degrees | ||
| @return int: the integer with the orientation of the pointcloud in degrees | ||
| */ | ||
| int getOrientation(); | ||
| //! set the offset of the pointcloud | ||
| /*! | ||
| set the ofsset of the pointcloud according to the 0.0 point | ||
| @param Point: the point with x and y to be set as offset | ||
| */ | ||
| void setOffset(Point newOffset); | ||
| //! get the offset of the pointcloud | ||
| /*! | ||
| get the ofsset of the pointcloud according to the 0.0 point | ||
| @return Point: returns a point with X and Y value | ||
| */ | ||
| Point getOffset(); | ||
|
|
||
| //! save all the points to a file | ||
| /*! | ||
| Save all the points tot a file, the offset and the orientation to a file | ||
| @param filename: the filename of the file where the points will be written | ||
| */ | ||
| void savePointsToFile(std::string filename); | ||
| //! load all the points from a file | ||
| /*! | ||
| load all the points, the offset and the orientation from a file | ||
| @param filename: the filename of the file with the points. | ||
| */ | ||
| void loadPointsFromFile(std::string filename); | ||
|
|
||
| //! print all points in given cloud | ||
| void printPoints(); | ||
|
|
||
|
|
||
| /*! Rotate a point could | ||
| * @param angle the rotation angle in Degrees | ||
| */ | ||
| Pointcloud* rotate(float angle); | ||
|
|
||
| //OPERATORS | ||
|
|
||
| //! a operator to write a point struct to a ostream | ||
| friend std::ostream & operator<<(std::ostream & output, const Pointcloud::Point & s); | ||
| //! a operator to add a Pointcloud to another pointcloud | ||
| Pointcloud operator+(Pointcloud & b); | ||
| //! a operator to add a Pointcloud to another pointcloud | ||
| Pointcloud operator+=(Pointcloud & b); | ||
| private: | ||
| Point offset; | ||
| std::vector<Point> * pointCloud; //! the vector which contains all the poins of the pointcloud | ||
| int orientation; //! the orientation of the pointcloud | ||
| }; | ||
| #endif |
| @@ -0,0 +1,3 @@ | ||
| # Environment Simulator | ||
| The environment simulator can be used to simulate a lidar scan in a given environment. | ||
| It is a QT-app. |
| @@ -0,0 +1,67 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file Checkpoint.cpp | ||
| * @date Created: 22-04-2015 | ||
| * @version 1.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #include "checkpoint.h" | ||
|
|
||
| checkPoint::checkPoint(int x, int y): | ||
| checkPointx(x), | ||
| checkPointy(y) | ||
| {} | ||
|
|
||
| void checkPoint::setCoordinates(int x, int y){ | ||
| checkPointx = x; | ||
| checkPointy = y; | ||
| } | ||
|
|
||
| void checkPoint::setX(int x){ | ||
| checkPointx = x; | ||
| } | ||
|
|
||
| void checkPoint::setY(int y){ | ||
| checkPointy = y; | ||
| } | ||
|
|
||
| int checkPoint::getX(){ | ||
| return checkPointx; | ||
| } | ||
|
|
||
| int checkPoint::getY(){ | ||
| return checkPointy; | ||
| } | ||
|
|
||
| checkPoint::~checkPoint() | ||
| {} |
| @@ -0,0 +1,96 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file Checkpoint.h | ||
| * @date Created: 15-04-2015 | ||
| * @version 1.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef CHECKPOINT_H | ||
| #define CHECKPOINT_H | ||
|
|
||
|
|
||
| class checkPoint | ||
| { | ||
| private: | ||
| int checkPointx = 0; | ||
| int checkPointy = 0; | ||
| public: | ||
| /*! | ||
| * Default constructor of checkPoint class. | ||
| * \brief Default constructor of checkPoint class. | ||
| */ | ||
| checkPoint(); | ||
| /*! | ||
| * Constructor of checkPoint class containing x and y coordinates. | ||
| * \brief Custom constructor of checkPoint class containing an x and y coordinate where the checkpoint will be put. | ||
| * @param x,y coordinates of the checkpoint inside the 2D-map. | ||
| */ | ||
| checkPoint(int x, int y); | ||
| /*! | ||
| * setCoordinate method sets the coordinates of a checkPoint object. | ||
| * \brief Sets the coordinates of a checkPoint object to the desired x and y coordinates. | ||
| * @param x,y coordinates the checkpoints needs to be set to inside the 2D-map. | ||
| */ | ||
| void setCoordinates(int x, int y); | ||
| /*! | ||
| * Sets the x coordinate. | ||
| * \brief Sets the x coordinate of a given checkPoint object to the desired x coordinate. | ||
| * @param x x-coordinate the checkpoint needs to be set to inside the 2D-map. | ||
| */ | ||
| void setX(int x); | ||
| /*! | ||
| * Sets the y coordinate. | ||
| * \brief Sets the y coordinate of a given checkPoint object to the desired y coordinate. | ||
| * @param y y-coordinate the checkpoint needs to be set to inside the 2D-map. | ||
| */ | ||
| void setY(int y); | ||
| /*! | ||
| * Gets the x coordinate. | ||
| * \brief Gets and returns the current x coordinate of the checkPoint. | ||
| * @return returns an int containing the current x coordinates of the checkPoint object. | ||
| */ | ||
| int getX(); | ||
| /*! | ||
| * Gets the y coordinate. | ||
| * \brief Gets and returns the current y coordinate of the checkPoint. | ||
| * @return returns an int containing the current y coordinates of the checkPoint object. | ||
| */ | ||
| int getY(); | ||
| /*! | ||
| * Default destructor. | ||
| * \brief Default destructor of the checkPoint class. | ||
| */ | ||
| ~checkPoint(); | ||
| }; | ||
|
|
||
| #endif // CHECKPOINT_H |
| @@ -0,0 +1,131 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file EditMapWindow.cpp | ||
| * @date Created: 22-04-2015 | ||
| * @version 1.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #include "editmapwindow.h" | ||
| #include "ui_editmapwindow.h" | ||
| #include "values.h" | ||
| #include <QGraphicsRectItem> | ||
| #include <QMouseEvent> | ||
| #include <vector> | ||
| #include <iostream> | ||
|
|
||
| EditMapWindow::EditMapWindow(Map* map, QWidget *parent) : | ||
| QDialog(parent), | ||
| ui(new Ui::EditMapWindow), | ||
| map(map) | ||
| { | ||
| objectx = (drawWidth / map->width); | ||
| objecty = (drawHeight / map->height); | ||
| ui->setupUi(this); | ||
|
|
||
| } | ||
|
|
||
| EditMapWindow::~EditMapWindow(){ | ||
| delete ui; | ||
| delete map; | ||
| map = NULL; | ||
|
|
||
| } | ||
|
|
||
| void EditMapWindow::on_obstacleButton_clicked(){ | ||
| selected = Values::OBSTACLE; | ||
| } | ||
|
|
||
| void EditMapWindow::on_noneButton_clicked() | ||
| { | ||
| selected = Values::EMPTY; | ||
| } | ||
|
|
||
| void EditMapWindow::on_saveMapButton_clicked(){ | ||
| map->saveMap(); | ||
| } | ||
|
|
||
| void EditMapWindow::mousePressEvent(QMouseEvent * event){ | ||
| if(event->pos().x() < Values::DRAWWIDTH){ | ||
| if(selected < 0){ | ||
| return; | ||
| } | ||
| int positionx = (event->pos().x() - event->pos().x() % objectx) / objectx; | ||
| int positiony = (event->pos().y() - event->pos().y() % objecty) / objecty; | ||
| if(positionx < map->width && positiony < map->height){ | ||
| map->setMapObject(selected, positiony, positionx); | ||
| update(); | ||
| mousePressed = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void EditMapWindow::paintEvent(QPaintEvent * /*UNUSED*/){ | ||
| if(!mousePressed) return; | ||
| mousePressed = false; | ||
| QPainter myPainter(this); | ||
| int y = 0; | ||
| for(std::vector<int> fory : map->getMapContent()){ | ||
| int x = 0; | ||
| for(int forx : fory){ | ||
| if(forx != 0){ | ||
| myPainter.fillRect((x*objectx),(y*objecty),objectx,objecty,QBrush(getColorById(forx))); | ||
| std::cout << (x*objectx) << " " << " " << (y*objecty) << " " << objectx << " " << objecty << std::endl; | ||
| } | ||
| ++x; | ||
| } | ||
| ++y; | ||
| } | ||
| std::cout << "paint event" << std::endl; | ||
| } | ||
|
|
||
| Qt::GlobalColor EditMapWindow::getColorById(int id){ | ||
| Qt::GlobalColor bColor; | ||
| switch (id) { | ||
| case 0: | ||
| bColor = Qt::white; | ||
| break; | ||
| case 1: | ||
| bColor = Qt::red; | ||
| break; | ||
| case 2: | ||
| bColor = Qt::green; | ||
| break; | ||
| case 3: | ||
| bColor = Qt::blue; | ||
| break; | ||
| default: | ||
| bColor = Qt::black; | ||
| break; | ||
| } | ||
| return bColor; | ||
| } |
| @@ -0,0 +1,101 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file EditMapWindow.h | ||
| * @date Created: 08-04-2015 | ||
| * @version 1.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef EDITMAPWINDOW_H | ||
| #define EDITMAPWINDOW_H | ||
|
|
||
| #include <QDialog> | ||
| #include <QGraphicsView> | ||
| #include <QGraphicsScene> | ||
| #include "map.h" | ||
| #include "values.h" | ||
|
|
||
| namespace Ui { | ||
| class EditMapWindow; | ||
| } | ||
|
|
||
| class EditMapWindow : public QDialog | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| /*! | ||
| * Constructor of editMapWindow | ||
| * \brief Constructor with a map object as parameter for drawing the map on the GUI | ||
| * @param map the map object containing the information for the GUI to draw | ||
| */ | ||
| explicit EditMapWindow(Map* map, QWidget *parent = 0); | ||
| /*! | ||
| * Default destructor of editMapWindow | ||
| * \brief Default destructor of editMapWindo. | ||
| */ | ||
| ~EditMapWindow(); | ||
|
|
||
| private slots: | ||
| //! Used when the obstacle button gets clicked | ||
| void on_obstacleButton_clicked(); | ||
| //! Used when the save button gets clicked | ||
| void on_saveMapButton_clicked(); | ||
| //! Used when the none button gets clicked | ||
| void on_noneButton_clicked(); | ||
|
|
||
| private: | ||
| //! A Uipointer used by QT. | ||
| Ui::EditMapWindow *ui; | ||
| //! Used for determining a color. | ||
| Qt::GlobalColor getColorById(int id); | ||
| //! PaintEvent is used for painting the window with it's contents. | ||
| void paintEvent(QPaintEvent *e); | ||
| //! MousePressEvent is used for handling all mouspresses inside the window. | ||
| void mousePressEvent(QMouseEvent * event); | ||
| //! Bool used for checking if a mouse button is clicked. | ||
| bool mousePressed = true; | ||
| //! Pointer to a given map to store the map information in. | ||
| Map *map; | ||
| //! Sets the selected object to the value of an obstacle. | ||
| int selected = Values::OBSTACLE; | ||
| //! Contains the x coordinate of an object. | ||
| int objectx = 0; | ||
| //! Contains the y coordinate of an object. | ||
| int objecty = 0; | ||
| //! Containts the width of the drawing space. | ||
| int drawWidth = Values::DRAWWIDTH; | ||
| //! Containts the height of the drawing space. | ||
| int drawHeight = Values::DRAWHEIGHT; | ||
| }; | ||
|
|
||
| #endif // EDITMAPWINDOW_H |
| @@ -0,0 +1,61 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>EditMapWindow</class> | ||
| <widget class="QDialog" name="EditMapWindow"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>640</width> | ||
| <height>480</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Dialog</string> | ||
| </property> | ||
| <widget class="QPushButton" name="saveMapButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>520</x> | ||
| <y>440</y> | ||
| <width>113</width> | ||
| <height>32</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Save Map</string> | ||
| </property> | ||
| </widget> | ||
| <widget class="QRadioButton" name="obstacleButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>540</x> | ||
| <y>10</y> | ||
| <width>102</width> | ||
| <height>20</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Obstacle</string> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| <widget class="QRadioButton" name="noneButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>540</x> | ||
| <y>40</y> | ||
| <width>102</width> | ||
| <height>20</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>None</string> | ||
| </property> | ||
| </widget> | ||
| </widget> | ||
| <resources/> | ||
| <connections/> | ||
| </ui> |
| @@ -0,0 +1,41 @@ | ||
| #------------------------------------------------- | ||
| # | ||
| # Project created by QtCreator 2015-03-18T11:43:29 | ||
| # | ||
| #------------------------------------------------- | ||
|
|
||
| QT += core gui | ||
|
|
||
| greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
|
||
| TARGET = environment_test | ||
| TEMPLATE = app | ||
| CONFIG += c++11 | ||
|
|
||
|
|
||
| SOURCES += main.cpp\ | ||
| mainwindow.cpp \ | ||
| editmapwindow.cpp \ | ||
| map.cpp \ | ||
| simulatemap.cpp \ | ||
| simulatemapwindow.cpp \ | ||
| test.cpp \ | ||
| checkpoint.cpp \ | ||
| PointCloud.cpp \ | ||
|
|
||
| HEADERS += mainwindow.h \ | ||
| editmapwindow.h \ | ||
| map.h \ | ||
| simulatemap.h \ | ||
| simulatemapwindow.h \ | ||
| test.h \ | ||
| values.h \ | ||
| checkpoint.h \ | ||
| PointCloud.h \ | ||
|
|
||
| FORMS += mainwindow.ui \ | ||
| editmapwindow.ui \ | ||
| simulatemapwindow.ui | ||
|
|
||
| DISTFILES += \ | ||
| README.md |
| @@ -0,0 +1,16 @@ | ||
| #include "mainwindow.h" | ||
| #include <QApplication> | ||
| #include "test.h" | ||
| int main(int argc, char *argv[]) | ||
| { | ||
| if(argc > 1 && strcmp(argv[1], "-test") == 0){ | ||
| //if(true){ | ||
| Test test; | ||
| return test.run(); | ||
| }else{ | ||
| QApplication a(argc, argv); | ||
| MainWindow w; | ||
| w.show(); | ||
| return a.exec(); | ||
| } | ||
| } |
| @@ -0,0 +1,127 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file Mainwindow.cpp | ||
| * @date Created: 12-04-2015 | ||
| * @version 2.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #include "mainwindow.h" | ||
| #include "ui_mainwindow.h" | ||
|
|
||
| MainWindow::MainWindow(QWidget *parent) : | ||
| QMainWindow(parent), | ||
| ui(new Ui::MainWindow) | ||
| { | ||
| ui->setupUi(this); | ||
| } | ||
|
|
||
| MainWindow::~MainWindow() | ||
| { | ||
| delete ui; | ||
| if(map != 0){ | ||
| delete map; | ||
| map = NULL; | ||
| } | ||
| } | ||
|
|
||
| void MainWindow::on_newMapButton_clicked(){ | ||
| bool ok; | ||
| QString fileName = QInputDialog::getText(this, "Create map","Map name:", | ||
| QLineEdit::Normal,"map name", &ok); | ||
| if(!ok) return; | ||
| int height = QInputDialog::getInt(this, "Create map","Map height:", | ||
| newMapBeignSize,newMapMinSize,newMapMaxSize,newMapStepSize, &ok); | ||
| if(!ok) return; | ||
| int width = QInputDialog::getInt(this, "Create map","Map height:", | ||
| newMapBeignSize,newMapMinSize,newMapMaxSize,newMapStepSize, &ok); | ||
|
|
||
| if (ok && !fileName.isEmpty()){ | ||
| map = new Map(fileName.toStdString() + ".map",height,width); | ||
| } | ||
| } | ||
|
|
||
| void MainWindow::on_editMapButton_clicked(){ | ||
| QString fileName = QFileDialog::getOpenFileName(this, "Open File", QString(), "Map Files (*.map *.pcl)"); | ||
| load(fileName, Values::EDIT); | ||
| } | ||
|
|
||
| void MainWindow::on_simulateButton_clicked(){ | ||
| QString fileName = QFileDialog::getOpenFileName(this, "Open File", QString(), "Map Files (*.map .pcl)"); | ||
| load(fileName, Values::SIMULATE); | ||
| } | ||
|
|
||
| void MainWindow::load(QString fileName, char type){ | ||
| if (!fileName.isEmpty()){ | ||
| QStringList fileTypeList = fileName.split('.'); | ||
| QString fileType = fileTypeList[1]; | ||
|
|
||
| if(fileType == "map"){ | ||
| if(type == Values::EDIT){ | ||
| map = new Map(fileName.toStdString()); | ||
| editMapWindow = new EditMapWindow(map); | ||
| editMapWindow->show(); | ||
| } | ||
| else if(type == Values::SIMULATE){ | ||
| map = new Map(fileName.toStdString()); | ||
| SimulateMapWindow *simulateMapWindow = new SimulateMapWindow(map); | ||
| simulateMapWindow->show(); | ||
| } | ||
| } | ||
| else if(fileType == "pcl"){ | ||
| if(type == Values::EDIT){ | ||
| Pointcloud *pcl = new Pointcloud(); | ||
| pcl->loadPointsFromFile(fileName.toStdString()); | ||
|
|
||
| map = new Map(fileName.toStdString(),pcl); | ||
| delete pcl; | ||
|
|
||
| editMapWindow = new EditMapWindow(map); | ||
| editMapWindow->show(); | ||
| } | ||
| else if(type == Values::SIMULATE){ | ||
|
|
||
|
|
||
| map = new Map(fileName.toStdString()); | ||
|
|
||
|
|
||
| SimulateMapWindow *simulateMapWindow = new SimulateMapWindow(map); | ||
| simulateMapWindow->show(); | ||
| } | ||
| } | ||
| else{ | ||
| QMessageBox msgBox; | ||
| msgBox.setText("Unkown filetype"); | ||
| msgBox.exec(); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,100 @@ | ||
| /** | ||
| * __ | ||
| * _________ / /_ ____ ________ ____________ _____ | ||
| * /___/ __ \/ __ \/ __ \/ ___/ _ \/ ___/ ___/ / / / _ \ | ||
| * / / / /_/ / /_/ / /_/ / / / __(__ ) /__/ /_/ / __/ | ||
| * /_/ \____/_.___/\____/_/ \___/____/\___/\__,_/\___/ | ||
| * | ||
| * | ||
| * @file MainWindow.cpp | ||
| * @date Created: 08-04-2015 | ||
| * @version 1.0 | ||
| * | ||
| * @author Danny Horvath, Thomas Fink | ||
| * | ||
| * @section LICENSE | ||
| * License: newBSD | ||
| * | ||
| * Copyright © 2015, HU University of Applied Sciences Utrecht. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
| * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
| * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
| * - Neither the name of the HU University of Applied Sciences Utrecht nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE HU UNIVERSITY OF APPLIED SCIENCES UTRECHT | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| **/ | ||
|
|
||
| #ifndef MAINWINDOW_H | ||
| #define MAINWINDOW_H | ||
|
|
||
| #include <QMainWindow> | ||
| #include <QtCore> | ||
| #include <QFileDialog> | ||
| #include <QMessageBox> | ||
| #include <iostream> | ||
| #include <QInputDialog> | ||
| #include "map.h" | ||
| #include "editmapwindow.h" | ||
| #include "simulatemapwindow.h" | ||
| #include "values.h" | ||
| #include "PointCloud.h" | ||
|
|
||
| namespace Ui { | ||
| class MainWindow; | ||
| } | ||
|
|
||
| class MainWindow : public QMainWindow | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| /*! | ||
| * Default constructor of mainWindow. | ||
| * \brief Default constructor of mainWindow. | ||
| */ | ||
| explicit MainWindow(QWidget *parent = 0); | ||
| /*! | ||
| * Default destructor of mainWindow. | ||
| * \brief Default destructor of mainWindow. | ||
| */ | ||
| ~MainWindow(); | ||
|
|
||
| private slots: | ||
| //! Used when the NewMap button gets clicked | ||
| void on_newMapButton_clicked(); | ||
| //! Used when the editMap button gets clicked | ||
| void on_editMapButton_clicked(); | ||
| //! Used when the Simulate button gets clicked | ||
| void on_simulateButton_clicked(); | ||
|
|
||
| private: | ||
| //! Load the correct window. | ||
| void load(QString fileName, char type); | ||
| //! Ui pointer for use with QT. | ||
| Ui::MainWindow *ui; | ||
| //! Map pointer containing map information. | ||
| Map *map = 0; | ||
| //! Editmapwindow for opening the editMapWindow. | ||
| EditMapWindow* editMapWindow; | ||
| //! Int containing the new map begin size. | ||
| static const int newMapBeignSize = 100; | ||
| //! Int containing minimal map size. | ||
| static const int newMapMinSize = 10; | ||
| //! Int containing maximal map size. | ||
| static const int newMapMaxSize = 100; | ||
| //! Int containing the map step size. | ||
| static const int newMapStepSize = 10; | ||
| }; | ||
|
|
||
| #endif // MAINWINDOW_H |
| @@ -0,0 +1,80 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>MainWindow</class> | ||
| <widget class="QMainWindow" name="MainWindow"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>400</width> | ||
| <height>110</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>MainWindow</string> | ||
| </property> | ||
| <widget class="QWidget" name="centralWidget"> | ||
| <widget class="QPushButton" name="newMapButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>10</x> | ||
| <y>10</y> | ||
| <width>113</width> | ||
| <height>32</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>New map</string> | ||
| </property> | ||
| </widget> | ||
| <widget class="QPushButton" name="editMapButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>150</x> | ||
| <y>10</y> | ||
| <width>113</width> | ||
| <height>32</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Edit map</string> | ||
| </property> | ||
| </widget> | ||
| <widget class="QPushButton" name="simulateButton"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>280</x> | ||
| <y>10</y> | ||
| <width>113</width> | ||
| <height>32</height> | ||
| </rect> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Simulate</string> | ||
| </property> | ||
| </widget> | ||
| </widget> | ||
| <widget class="QMenuBar" name="menuBar"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>400</width> | ||
| <height>22</height> | ||
| </rect> | ||
| </property> | ||
| </widget> | ||
| <widget class="QToolBar" name="mainToolBar"> | ||
| <attribute name="toolBarArea"> | ||
| <enum>TopToolBarArea</enum> | ||
| </attribute> | ||
| <attribute name="toolBarBreak"> | ||
| <bool>false</bool> | ||
| </attribute> | ||
| </widget> | ||
| <widget class="QStatusBar" name="statusBar"/> | ||
| </widget> | ||
| <layoutdefault spacing="6" margin="11"/> | ||
| <resources/> | ||
| <connections/> | ||
| </ui> |