viewer.h 5.33 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
/*******************************************************************************
David Cazier's avatar
David Cazier committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
 * version 0.1                                                                  *
 * Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg                *
 *                                                                              *
 * This library is free software; you can redistribute it and/or modify it      *
 * under the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation; either version 2.1 of the License, or (at your     *
 * option) any later version.                                                   *
 *                                                                              *
 * This library is distributed in the hope that it will be useful, but WITHOUT  *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
 * for more details.                                                            *
 *                                                                              *
 * You should have received a copy of the GNU Lesser General Public License     *
 * along with this library; if not, write to the Free Software Foundation,      *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
 *                                                                              *
 * Web site: https://iggservis.u-strasbg.fr/CGoGN/                              *
 * Contact information: cgogn@unistra.fr                                        *
 *                                                                              *
 *******************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
24 25

#include <iostream>
David Cazier's avatar
David Cazier committed
26
#include <sys/time.h>
Pierre Kraemer's avatar
Pierre Kraemer committed
27

Pierre Kraemer's avatar
Pierre Kraemer committed
28
#include "Utils/Qt/qtSimple.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
29
#include "ui_socialAgents.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30
#include "Utils/Qt/qtui.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
31 32 33

#include "simulator.h"
#include "env_render.h"
Thomas's avatar
Thomas committed
34
#include "exportObstacles.h"
35
#include "gl2ps.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
36

Pierre Kraemer's avatar
Pierre Kraemer committed
37
#include "Algo/Geometry/boundingbox.h"
38

Pierre Kraemer's avatar
Pierre Kraemer committed
39
#include "Algo/Export/exportPov.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
40
#include "Utils/GLSLShader.h"
Pierre Kraemer's avatar
yeah  
Pierre Kraemer committed
41
#include "Utils/colorMaps.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
42 43 44 45 46
#include "Algo/Render/GL1/map_glRender.h"
#include "Algo/Render/GL1/topo_render.h"

using namespace CGoGN ;

David Cazier's avatar
David Cazier committed
47
typedef PFP::MAP MAP ;
Pierre Kraemer's avatar
Pierre Kraemer committed
48

Pierre Kraemer's avatar
Pierre Kraemer committed
49
class SocialAgents : public Utils::QT::SimpleQT
Pierre Kraemer's avatar
Pierre Kraemer committed
50
{
Pierre Kraemer's avatar
Pierre Kraemer committed
51 52
	Q_OBJECT

Pierre Kraemer's avatar
Pierre Kraemer committed
53
public:
54
	SocialAgents(unsigned int config, unsigned int minSize, unsigned int nbAgent , unsigned int nbObst , unsigned int iterations) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
55

Pierre Kraemer's avatar
Pierre Kraemer committed
56 57 58 59
	void initGUI() ;

	void cb_initGL() ;
	void cb_redraw() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
60

Pierre Kraemer's avatar
Pierre Kraemer committed
61
#ifndef SPATIAL_HASHING
David Cazier's avatar
David Cazier committed
62 63 64 65 66
	void exportInfoFace(std::ofstream& out, Dart d) ;
	bool exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std::string& filename,
	                    PFP::VEC3 cameraPos, PFP::VEC3 cameraLook, PFP::VEC3 translate,
	                    float angle_X, float angle_Y, float angle_Z,
	                    const FunctorSelect& good = SelectorTrue()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
67
#endif
David Cazier's avatar
David Cazier committed
68

Pierre Kraemer's avatar
Pierre Kraemer committed
69 70
	void cb_keyPress(int keycode) ;

David Cazier's avatar
David Cazier committed
71
	Utils::QT::uiDockInterface dock ;
Pierre Kraemer's avatar
Pierre Kraemer committed
72

David Cazier's avatar
David Cazier committed
73
	QTimer* timer ;
Pierre Kraemer's avatar
Pierre Kraemer committed
74

David Cazier's avatar
David Cazier committed
75 76 77 78 79 80 81
	/* nbIterations counts the current number of iterations
	 * When maxIterations is reached the simulation is stopped
	 * If maxIterations is set to 0 the simulation is never stopped (interactive)
	 */
	unsigned int nbIterations ;
	unsigned int maxIterations ;

Thomas Jund's avatar
Thomas Jund committed
82 83
	unsigned int nbGeneratedPov;

Pierre Kraemer's avatar
Pierre Kraemer committed
84
	// to count fps
David Cazier's avatar
David Cazier committed
85
	unsigned int frames ;
David Cazier's avatar
David Cazier committed
86 87
	struct timespec startTime ;
	time_t nextUpdate ;
David Cazier's avatar
David Cazier committed
88

David Cazier's avatar
David Cazier committed
89
	Simulator simulator ;
David Cazier's avatar
David Cazier committed
90 91 92 93
	SelectorTrue allDarts ;

	bool render_anim ;
	int visu ;
Pierre Kraemer's avatar
Pierre Kraemer committed
94

Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97 98
	bool drawEnvLines ;
	bool drawEnvFaces ;
	bool drawEnvTopo ;
	bool drawObstacles ;
pitiot's avatar
pitiot committed
99
	bool drawMovingObstacles ;
Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103
	bool drawAgents ;
	bool drawAgentsNeighborDist ;
	bool drawAgentsObstacleDist ;
	bool drawAgentsPredictionTri ;
104
	bool drawAgentsPath ;
Jund Thomas's avatar
Jund Thomas committed
105
	bool drawObstPredictionTri ;
106
	bool drawObstPath ;
pitiot's avatar
pitiot committed
107
	bool draw_dart;
108
	bool draw_posX;
pitiot's avatar
merging  
pitiot committed
109
	bool draw_elipse;
pitiot's avatar
pitiot committed
110
	unsigned int dartSlider;
111 112
	int posXSlider;
	int posYSlider;
Pierre Kraemer's avatar
Pierre Kraemer committed
113 114 115

public slots:
	void animate() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
116

David Cazier's avatar
David Cazier committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
	void slot_timer(bool b)
	{
		b ? timer->start() : timer->stop() ;
	}
	void slot_drawEnvLines(bool b)
	{
		drawEnvLines = b ;
		updateGL() ;
	}
	void slot_drawEnvFaces(bool b)
	{
		drawEnvFaces = b ;
		updateGL() ;
	}
	void slot_drawEnvTopo(bool b)
	{
		drawEnvTopo = b ;
		updateGL() ;
	}
	void slot_drawObstacles(bool b)
	{
		drawObstacles = b ;
		updateGL() ;
	}
	void slot_drawAgents(bool b)
	{
		drawAgents = b ;
		updateGL() ;
	}
	void slot_drawAgentsPredictionTri(bool b)
	{
		drawAgentsPredictionTri = b ;
		updateGL() ;
	}
Jund Thomas's avatar
Jund Thomas committed
151 152 153 154 155
	void slot_drawObstPredictionTri(bool b)
	{
		drawObstPredictionTri = b ;
		updateGL() ;
	}
David Cazier's avatar
David Cazier committed
156 157 158 159 160 161 162 163 164 165
	void slot_drawAgentsNeighborDist(bool b)
	{
		drawAgentsNeighborDist = b ;
		updateGL() ;
	}
	void slot_drawAgentsObstacleDist(bool b)
	{
		drawAgentsObstacleDist = b ;
		updateGL() ;
	}
166 167 168 169 170
	void slot_drawAgentsPath(bool b)
	{
		drawAgentsPath= b ;
		updateGL() ;
	}
171 172 173 174 175
	void slot_drawMovingObstacles(bool b)
	{
		drawMovingObstacles = b ;
		updateGL() ;
	}
176 177 178 179 180
	void slot_drawObstPath(bool b)
	{
		drawObstPath= b ;
		updateGL() ;
	}
181 182 183 184 185 186 187 188 189 190
	void slot_dart(bool b)
	{
		draw_dart = b ;
		updateGL() ;
	}
	void slot_slide(int i)
	{
		dartSlider = i;
		updateGL();
	}
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
	void slot_posX(bool b)
	{
		draw_posX = b ;
		updateGL() ;
	}
	void slot_slide2(int i)
	{
		posXSlider = i;
		updateGL();
	}
	void slot_slide3(int i)
	{
		posYSlider = i;
		updateGL();
	}
pitiot's avatar
merging  
pitiot committed
206
	void slot_elipse(bool b)
207 208 209 210
	{
		draw_elipse = b;
		updateGL();
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
211
} ;