Une nouvelle version du portail de gestion des comptes externes sera mise en production lundi 09 août. Elle permettra d'allonger la validité d'un compte externe jusqu'à 3 ans. Pour plus de détails sur cette version consulter : https://doc-si.inria.fr/x/FCeS

Commit 826f073d authored by VAN TOLL Wouter's avatar VAN TOLL Wouter
Browse files

Started adding a Qt GUI application:

- Added a project with the necessary files.
- Updated CMake settings.
- Added 3rd-party code for polygon triangulation.
- Added tools/Color and tools/HelperFunctions.
- Vector2D: Added code for disk approximation.
- Renamed WorldBase::Type values, due to naming conflicts with Qt.
- Moved some code to Library and ConsoleApplication subfolders.
parent aafd9369
ISC License
Copyright (c) 2015, Mapbox
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
\ No newline at end of file
This diff is collapsed.
......@@ -34,6 +34,10 @@ include_directories(./3rd-party/tinyxml/ ./3rd-party/nanoflann/ ./3rd-party/ORCA
file( GLOB_RECURSE source_files src/* include/*)
file( GLOB_RECURSE 3rd_party 3rd-party/*)
# === include the GUI application (which requires Qt)?
option(UMANS_USE_GUI_APPLICATION "Include a GUI demo application (which relies on Qt)" OFF)
# === Use multithreading?
option(UMANS_USE_MULTITHREADING "Allow the program to use multiple parallel threads" ON)
......@@ -58,18 +62,50 @@ add_library(Engine STATIC ${source_files} ${3rd_party})
# === Console application
if (WIN32)
add_executable(UMANS_ConsoleApplication_Windows main.cpp)
add_executable(UMANS_ConsoleApplication_Windows ConsoleApplication/main.cpp)
target_link_libraries(UMANS_ConsoleApplication_Windows Engine)
else()
add_executable(UMANS_ConsoleApplication_Linux main.cpp)
add_executable(UMANS_ConsoleApplication_Linux ConsoleApplication/main.cpp)
target_link_libraries(UMANS_ConsoleApplication_Linux Engine)
endif()
# === Dynamic library (e.g. a DLL on Windows) to include into other programs
add_library(UMANS_Library SHARED "APIFunctions.h" "APIFunctions.cpp")
add_library(UMANS_Library SHARED Library/APIFunctions.h Library/APIFunctions.cpp)
target_link_libraries(UMANS_Library Engine)
# === Qt demo project (if enabled)
if (UMANS_USE_GUI_APPLICATION)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
# --- NOTE: To let this line work, add the following environment variable:
# CMAKE_PREFIX_PATH
# with a value such as C:\Qt\5.12.0\msvc2017_64 (depending on your Qt installation)
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
# --- include the Qt resources, so that the application icon gets shown
set(UI_RESOURCES QtDemo/UMANSQtGuiApplication.qrc )
qt5_add_resources(UI_RESOURCES_RCC ${UI_RESOURCES})
# --- define the project itself
file( GLOB_RECURSE src_QtDemo QtDemo/*)
add_executable(UMANS_QtDemo QtDemo/main.cpp ${src_QtDemo} ${UI_RESOURCES_RCC})
# --- the project depends on some libraries
target_link_libraries(UMANS_QtDemo Engine Qt5::Widgets opengl32.lib glu32.lib)
# --- post-build command: copy the required Qt DLLs, to prevent runtime errors
add_custom_command(TARGET UMANS_QtDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:UMANS_QtDemo>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:UMANS_QtDemo>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:UMANS_QtDemo>
)
endif (UMANS_USE_GUI_APPLICATION)
# === Clean up the project's directory structure
foreach(_source IN ITEMS ${source_files})
......
......@@ -104,7 +104,7 @@ int main( int argc, char * argv[] )
if (cs != nullptr)
{
if (outputFolder != "")
cs->SetCSVOutputDirectory(outputFolder);
cs->StartCSVOutput(outputFolder);
cs->RunSimulationUntilEnd();
}
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "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 Qt Company Ltd 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 COPYRIGHT
** OWNER OR CONTRIBUTORS 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."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLShaderProgram>
#include "VisualizationData.h"
#include <core/crowdSimulator.h>
class UMANSQtGuiApplication;
class UMANSOpenGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
UMANSOpenGLWidget(QWidget *parent = nullptr);
~UMANSOpenGLWidget();
public slots:
void PlaySimulation();
void PauseSimulation();
void ResetSimulation();
void SetPlaybackMultiplier(int value);
void OpenScenarioFileDialog();
void ToggleCSVOutput();
void ZoomToFit();
void ToggleScreenshots();
void MakeScreenshot();
private slots:
void updateSimulation();
protected:
void initializeGL() override;
void paintGL() override;
void resizeGL(int width, int height) override;
// events
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
private:
void startNewSimulation(const std::string& scenarioFilename);
void resetVisualization(bool deleteCurrentVisualization);
Vector2D screenToWorld(const QPoint& screenPoint) const;
QSizeF getScreenToWorldScale() const;
void drawSimulation();
void drawAgent(const Agent& agent);
void drawScene(const bool refresh=false);
void addPointsToBuffer(const std::vector<Vector2D>& points, const QColor& color, const std::string& target, const double depth);
void addSegmentsToBuffer(const std::vector<LineSegment2D>& segments, const QColor& color, const std::string& target, const double depth);
void updateCursor();
void updateSimulationTimerText();
void setActiveAgent(Agent* agent);
void checkActiveAgent();
private:
std::map<std::string, VisualizationData*> visualizationData;
QOpenGLShaderProgram program;
QOpenGLFunctions *f;
QTimer *simulationTimer;
UMANSQtGuiApplication* mainApplication;
CrowdSimulator* simulator;
Agent* activeAgent;
size_t activeAgentID;
std::vector<std::string> settingsFiles;
bool inAgentSelectMode;
bool panning;
bool simulationRunning;
int playbackMultiplier;
bool makeScreenshotsPerFrame;
bool writeCSVOutput;
/// <summary>
/// The part of the world that is currently being shown in the OpenGL widget.
/// </summary>
QRectF viewBounds;
/// <summary>The width and height of theis OpenGL widget, in pixels.</summary>
QSizeF windowSize;
/// <summary>The last screen position of the mouse.</summary>
QPoint m_lastPos;
int matrixLocationInShader;
};
#endif
#include "UMANSQtGuiApplication.h"
UMANSQtGuiApplication::UMANSQtGuiApplication(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
simulationView = ui.SimulationView;
}
#pragma once
#include <QtWidgets/QWidget>
#include "ui_UMANSQtGuiApplication.h"
class OGLWidget;
class UMANSQtGuiApplication : public QWidget
{
Q_OBJECT
private:
Ui::Application ui;
UMANSOpenGLWidget* simulationView;
public:
UMANSQtGuiApplication(QWidget *parent = Q_NULLPTR);
inline Ui::Application& GetUI() { return ui; }
};
<RCC>
<qresource prefix="QtDemo">
<file>Resources/ApplicationIcon.png</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Application</class>
<widget class="QWidget" name="Application">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1250</width>
<height>1000</height>
</rect>
</property>
<property name="windowTitle">
<string>UMANS: Unified Microscopic Agent Navigation Simulator</string>
</property>
<property name="windowIcon">
<iconset resource="UMANSQtGuiApplication.qrc">
<normaloff>:/QtDemo/Resources/ApplicationIcon.png</normaloff>:/QtDemo/Resources/ApplicationIcon.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="UMANSOpenGLWidget" name="SimulationView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="SettingsPanel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QGroupBox" name="Group_Playback">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>231</width>
<height>191</height>
</rect>
</property>
<property name="title">
<string>Playback</string>
</property>
<widget class="QPushButton" name="Button_Play">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>61</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Play/resume the simulation.</string>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
<widget class="QPushButton" name="Button_Pause">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>70</y>
<width>71</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Pause the simulation.</string>
</property>
<property name="text">
<string>Pause</string>
</property>
</widget>
<widget class="QLabel" name="Title_Speed">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Desired speed (x real-time)</string>
</property>
</widget>
<widget class="QLabel" name="Title_SimulationTime">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Current simulation time</string>
</property>
</widget>
<widget class="QLabel" name="Label_SimulationTime">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>201</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Consolas</family>
<pointsize>18</pointsize>
<weight>50</weight>
<bold>false</bold>
<kerning>true</kerning>
</font>
</property>
<property name="toolTip">
<string>The time (in seconds) that has passed in the simulation.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">color: #6699FF;</string>
</property>
<property name="text">
<string>00:00.000</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QSlider" name="Slider_Speed">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>211</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>The speed-up factor used for running/showing the simulation. Use 1 to run in real-time.</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="sliderPosition">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
<widget class="QLabel" name="Label_SpeedSlider_A">
<property name="geometry">
<rect>
<x>0</x>
<y>160</y>
<width>31</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="Label_SpeedSlider_D">
<property name="geometry">
<rect>
<x>200</x>
<y>160</y>
<width>31</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="Label_SpeedSlider_B">
<property name="geometry">
<rect>
<x>66</x>
<y>160</y>
<width>31</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>4</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="Label_SpeedSlider_C">
<property name="geometry">
<rect>
<x>133</x>
<y>160</y>
<width>31</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>7</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="Button_Reset">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>160</x>
<y>70</y>
<width>61</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Reset the simulation.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="Group_Simulation">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>231</width>
<height>101</height>
</rect>
</property>
<property name="title">