2012-07-13 12:23:58 +00:00
|
|
|
#ifndef _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
|
|
|
|
#define _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
|
|
|
|
|
|
|
|
#include <QGLWidget>
|
2012-07-24 14:59:06 +00:00
|
|
|
#include <QDateTime>
|
2013-05-05 13:37:06 +00:00
|
|
|
#include "terrain/paintingbrush.h"
|
2013-11-14 17:47:03 +00:00
|
|
|
#include "CameraDefinition.h"
|
2013-11-12 20:34:35 +00:00
|
|
|
#include "tools/euclid.h"
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "terrain/public.h"
|
2012-07-13 12:23:58 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Vector3 point;
|
|
|
|
Vector3 normal;
|
2013-02-07 16:06:26 +00:00
|
|
|
int painted;
|
2012-07-15 14:42:50 +00:00
|
|
|
} _VertexInfo;
|
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
class WidgetHeightMap : public QGLWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-05-05 13:37:06 +00:00
|
|
|
WidgetHeightMap(QWidget* parent);
|
2012-07-13 12:23:58 +00:00
|
|
|
~WidgetHeightMap();
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2013-05-05 13:37:06 +00:00
|
|
|
void setTerrain(TerrainDefinition* terrain);
|
|
|
|
void setBrush(PaintingBrush* brush);
|
2013-02-03 21:18:32 +00:00
|
|
|
|
2012-07-13 21:24:19 +00:00
|
|
|
public slots:
|
2012-07-16 20:34:01 +00:00
|
|
|
void revert();
|
2013-05-10 15:40:49 +00:00
|
|
|
void toggleWater(bool enabled);
|
|
|
|
void toggleGrid(bool enabled);
|
2013-06-20 15:38:23 +00:00
|
|
|
void togglePaintedArea(bool enabled);
|
2012-07-13 12:23:58 +00:00
|
|
|
|
2013-02-03 21:18:32 +00:00
|
|
|
signals:
|
|
|
|
void heightmapChanged();
|
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
protected:
|
2013-04-28 13:32:10 +00:00
|
|
|
void keyPressEvent(QKeyEvent* event);
|
2012-07-13 12:23:58 +00:00
|
|
|
void mousePressEvent(QMouseEvent* event);
|
2012-07-16 20:34:01 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
2012-07-13 12:23:58 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2013-04-27 21:40:31 +00:00
|
|
|
void wheelEvent(QWheelEvent* event);
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-16 20:34:01 +00:00
|
|
|
void timerEvent(QTimerEvent* event);
|
2012-07-13 12:23:58 +00:00
|
|
|
|
|
|
|
void initializeGL();
|
|
|
|
void resizeGL(int w, int h);
|
|
|
|
void paintGL();
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
private:
|
2013-04-28 13:32:10 +00:00
|
|
|
void scrollTopCamera(double dx, double dz);
|
|
|
|
void zoomTopCamera(double dzoom);
|
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
void updateVertexInfo();
|
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
private:
|
2012-12-10 22:05:53 +00:00
|
|
|
TerrainDefinition* _terrain;
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2012-08-08 13:30:40 +00:00
|
|
|
_VertexInfo* _vertices;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
bool _dirty;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2013-04-27 21:40:31 +00:00
|
|
|
double _water_height;
|
|
|
|
bool _water;
|
|
|
|
bool _wireframe;
|
2013-06-20 15:38:23 +00:00
|
|
|
bool _painted_area;
|
2013-04-27 21:40:31 +00:00
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
double _average_frame_time;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-16 20:34:01 +00:00
|
|
|
int _last_brush_action;
|
2012-07-13 12:23:58 +00:00
|
|
|
int _last_mouse_x;
|
|
|
|
int _last_mouse_y;
|
2012-07-24 14:59:06 +00:00
|
|
|
QDateTime _last_time;
|
2012-07-23 09:58:06 +00:00
|
|
|
bool _mouse_moved;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2013-04-28 13:32:10 +00:00
|
|
|
double _target_x;
|
|
|
|
double _target_z;
|
2013-04-28 19:34:35 +00:00
|
|
|
int _last_update_x;
|
|
|
|
int _last_update_z;
|
|
|
|
|
2013-04-27 19:41:57 +00:00
|
|
|
CameraDefinition* _top_camera;
|
|
|
|
CameraDefinition* _temp_camera;
|
|
|
|
CameraDefinition* _current_camera;
|
2013-04-27 21:40:31 +00:00
|
|
|
double _zoom;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2013-05-05 13:37:06 +00:00
|
|
|
PaintingBrush* _brush;
|
2012-07-15 14:42:50 +00:00
|
|
|
double _brush_x;
|
|
|
|
double _brush_z;
|
2012-07-13 12:23:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|