git-svn-id: svn://db.shs.com.ru/libs@536 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -19,27 +19,15 @@
|
||||
#ifndef QGLVIEW_H
|
||||
#define QGLVIEW_H
|
||||
|
||||
#include "openglwindow.h"
|
||||
#include "glframebuffer.h"
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QGLFramebufferObject>
|
||||
#include <QVector3D>
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QApplication>
|
||||
#include "glprimitives.h"
|
||||
#include "glparticles_system.h"
|
||||
#include "glrendererbase.h"
|
||||
#include <QTime>
|
||||
|
||||
|
||||
class QGLView: public QGraphicsView, public QGLViewBase
|
||||
#if QT_VERSION >= 0x050600
|
||||
, protected QOpenGLExtraFunctions
|
||||
#endif
|
||||
class QGLView: public OpenGLWindow, public QGLViewBase
|
||||
{
|
||||
friend class GLRendererBase;
|
||||
friend class GLObjectBase;
|
||||
@@ -67,15 +55,12 @@ class QGLView: public QGraphicsView, public QGLViewBase
|
||||
Q_PROPERTY (bool selectionHalo READ isSelectionHaloEnabled WRITE setSelectionHaloEnabled)
|
||||
Q_PROPERTY (QColor selectionHaloColor READ selectionHaloColor WRITE setSelectionHaloColor)
|
||||
Q_PROPERTY (double selectionHaloFillAlpha READ selectionHaloFillAlpha WRITE setSelectionHaloFillAlpha)
|
||||
//Q_PROPERTY (LightingMode lightingMode READ lightingMode WRITE setLightingMode)
|
||||
Q_PROPERTY (Qt::MouseButton selectionButton READ selectionButton WRITE setSelectionButton)
|
||||
Q_PROPERTY (Qt::KeyboardModifier selectionModifier READ selectionModifier WRITE setSelectionModifier)
|
||||
Q_PROPERTY (SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
|
||||
Q_PROPERTY (QPen selectionRectPen READ selectionRectPen WRITE setSelectionRectPen)
|
||||
Q_PROPERTY (QBrush selectionRectBrush READ selectionRectBrush WRITE setSelectionRectBrush)
|
||||
|
||||
public:
|
||||
QGLView(QWidget * parent = 0);
|
||||
QGLView();
|
||||
virtual ~QGLView();
|
||||
|
||||
enum FogMode {Linear = GL_LINEAR, Exp = GL_EXP, Exp2 = GL_EXP2};
|
||||
@@ -112,21 +97,12 @@ public:
|
||||
|
||||
Q_ENUMS (FogMode)
|
||||
Q_ENUMS (SelectionMode)
|
||||
//enum LightingMode {Simple, PerPixel, DeferredShading};
|
||||
//Q_ENUMS (LightingMode)
|
||||
|
||||
void stop() {if (timer) killTimer(timer);}
|
||||
void start(double freq = 40.) {timer = startTimer(freq <= 0. ? 0 : 1000. / freq);}
|
||||
void stop();
|
||||
void start(double freq = 40.);
|
||||
|
||||
GLRendererBase * renderer() {return renderer_;}
|
||||
void setRenderer(GLRendererBase * r, GLRendererBase ** prev = 0) {if (prev != 0) *prev = renderer_; renderer_ = r;}
|
||||
|
||||
#if QT_VERSION >= 0x050600
|
||||
__GLContext__ * context() {return ((__GLWidget__ * )viewport())->context();}
|
||||
#else
|
||||
const __GLContext__ * context() const {return ((const __GLWidget__ * )viewport())->context();}
|
||||
#endif
|
||||
void makeCurrent() {((__GLWidget__ * )viewport())->makeCurrent();}
|
||||
GLRendererBase * renderer();
|
||||
void setRenderer(GLRendererBase * r, GLRendererBase ** prev = nullptr);
|
||||
|
||||
QColor backColor() const {return backColor_;}
|
||||
double lineWidth() const {return lineWidth_;}
|
||||
@@ -142,7 +118,6 @@ public:
|
||||
double fogStart() const {return fogStart_;}
|
||||
double fogEnd() const {return fogEnd_;}
|
||||
FogMode fogMode() const {return fogMode_;}
|
||||
//LightingMode lightingMode() const {return lmode;}
|
||||
bool isFogEnabled() const {return fogEnabled_;}
|
||||
bool isLightEnabled() const {return lightEnabled_;}
|
||||
bool isGrabMouseEnabled() const {return grabMouse_;}
|
||||
@@ -163,7 +138,6 @@ public:
|
||||
int renderMode() const {return (int)rmode;}
|
||||
void setRenderMode(int mode) {rmode = (GLObjectBase::RenderMode)mode;}
|
||||
|
||||
void addObject(QGraphicsItem * o) {scene()->addItem(o);}
|
||||
void addObject(QWidget * o, Qt::WindowFlags f = Qt::Widget);
|
||||
void addObject(GLObjectBase * o);
|
||||
void addObject(GLObjectBase & o) {addObject(&o);}
|
||||
@@ -189,8 +163,6 @@ public:
|
||||
Light * light(int index) {return lights_[index];}
|
||||
Light * light(const QString & name) {foreach (Light * i, lights_) if (i->name_ == name) return i; return 0;}
|
||||
|
||||
QPen selectionRectPen() const {return sel_pen;}
|
||||
QBrush selectionRectBrush() const {return sel_brush;}
|
||||
SelectionMode selectionMode() const {return sel_mode;}
|
||||
Qt::MouseButton selectionButton() const {return sel_button;}
|
||||
Qt::KeyboardModifier selectionModifier() const {return sel_mod;}
|
||||
@@ -198,31 +170,28 @@ public:
|
||||
void setSelectionMode(SelectionMode v) {sel_mode = v;}
|
||||
void setSelectionButton(Qt::MouseButton v) {sel_button = v;}
|
||||
void setSelectionModifier(Qt::KeyboardModifier v) {sel_mod = v;}
|
||||
void setSelectionRectPen(const QPen & v) {sel_pen = v;}
|
||||
void setSelectionRectBrush(const QBrush & v) {sel_brush = v;}
|
||||
void selectObject(GLObjectBase * o);
|
||||
GLObjectBase * selectedObject() const {return sel_obj;}
|
||||
|
||||
GLdouble aspect, iaspect;
|
||||
QMatrix4x4 cur_mvpm;
|
||||
//__GLShaderProgram__ * shader_rope;
|
||||
|
||||
protected:
|
||||
virtual void drawBackground(QPainter * painter, const QRectF & rect);
|
||||
virtual void resizeEvent(QResizeEvent * e) {resizeGL(viewport()->width(), viewport()->height()); QGraphicsView::resizeEvent(e);}
|
||||
void render();
|
||||
void resizeEvent(QResizeEvent * e);
|
||||
|
||||
void timerEvent(QTimerEvent * ) {/*globMutex.lock();*/ processKeys(); viewport()->repaint(); /*globMutex.unlock();*/}
|
||||
void initializeGL();
|
||||
void paintGL();
|
||||
void timerEvent(QTimerEvent * );
|
||||
void initialize();
|
||||
void resizeGL(int width, int height);
|
||||
void mousePressEvent(QMouseEvent * e);
|
||||
void mouseMoveEvent(QMouseEvent * e);
|
||||
void mouseReleaseEvent(QMouseEvent * e);
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
void leaveEvent(QEvent * );
|
||||
void keyPressEvent(QKeyEvent * e) {emit glKeyPressEvent(e); if (e->key() > 0) keys_.insert(e->key());}
|
||||
void keyReleaseEvent(QKeyEvent * e) {emit glKeyReleaseEvent(e); keys_.remove(e->key());}
|
||||
void focusOutEvent(QFocusEvent *) {keys_.clear();}
|
||||
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
void keyReleaseEvent(QKeyEvent * e);
|
||||
void focusOutEvent(QFocusEvent *);
|
||||
|
||||
void applyFog();
|
||||
void renderSelection();
|
||||
@@ -237,46 +206,38 @@ private:
|
||||
void removeObjectInternal(GLObjectBase * o, GLObjectBase * where);
|
||||
void renderSingleSelection(GLObjectBase & o);
|
||||
//void renderSingleShadow(GLObjectBase & o);
|
||||
void renderHalo(const GLObjectBase * obj, const int iid, const QColor & color, const double & fill);
|
||||
QList<QGraphicsItem * > collectGraphicItems();
|
||||
void collectGraphicItems(QList<QGraphicsItem * > & list, QGraphicsItem * o);
|
||||
void renderHalo(const GLObjectBase * obj, const uint iid, const QColor & color, const double & fill);
|
||||
void reloadThisShaders();
|
||||
void processKeys();
|
||||
bool setupViewport();
|
||||
|
||||
QPoint lastPos, downPos;
|
||||
QMutex v_mutex;
|
||||
GLTextureManager textures_manager;
|
||||
GLObjectBase objects_;
|
||||
QList<Light * > lights_;
|
||||
uint cid;
|
||||
QMap<uint, GLObjectBase * > ids;
|
||||
// uint cid;
|
||||
QHash<uint, GLObjectBase * > ids;
|
||||
QSet<int> keys_;
|
||||
FogMode fogMode_;
|
||||
QColor backColor_, fogColor_, ambientColor_, hoverHaloColor_, selectionHaloColor_;
|
||||
QPainter * painter_;
|
||||
QTime time, ktm_;
|
||||
QPen sel_pen;
|
||||
QBrush sel_brush;
|
||||
GLint max_anisotropic, max_texture_chanels;
|
||||
GLObjectBase::RenderMode rmode;
|
||||
//LightingMode lmode;
|
||||
GLObjectBase * sel_obj, * hov_obj;
|
||||
GLFramebuffer fbo_selection;
|
||||
__GLShaderProgram__ * shader_select, * shader_halo;
|
||||
QOpenGLShaderProgram * shader_select, * shader_halo;
|
||||
GLRendererBase * renderer_;
|
||||
SelectionMode sel_mode;
|
||||
Qt::MouseButton sel_button;
|
||||
Qt::KeyboardModifier sel_mod;
|
||||
GLRendererBase::RenderingParameters start_rp;
|
||||
QHash<int, QVariant> features_;
|
||||
__GLWidget__ * _w;
|
||||
double lineWidth_;
|
||||
double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
|
||||
int timer, fps_cnt, sh_id_loc;
|
||||
bool is_first_draw, is_init, fogEnabled_, lightEnabled_, grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_;
|
||||
bool shaders_supported, changed_, cameraOrbit_, need_init_;
|
||||
bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_;
|
||||
bool hoverHalo_, selectionHalo_, shaders_bind, selecting_;
|
||||
|
||||
public slots:
|
||||
void setBackColor(const QColor & arg) {backColor_ = arg;}
|
||||
@@ -303,11 +264,9 @@ public slots:
|
||||
void setSelectionHaloEnabled(const bool & arg) {selectionHalo_ = arg;}
|
||||
void setSelectionHaloColor(const QColor & arg) {selectionHaloColor_ = arg;}
|
||||
void setSelectionHaloFillAlpha(const double & arg) {selectionHaloFill_ = arg;}
|
||||
//void setLightingMode(const LightingMode & arg) {lmode = arg;}
|
||||
|
||||
void reloadShaders() {if (renderer_ != 0) renderer_->reloadShaders(); reloadThisShaders();}
|
||||
void deselect() {sel_obj = 0;}
|
||||
void glCleanup();
|
||||
|
||||
signals:
|
||||
void glBeforePaint();
|
||||
|
||||
Reference in New Issue
Block a user