Graphic patch - new UGLWidget creates only on first show or when visible
This commit is contained in:
@@ -216,6 +216,21 @@ void Graphic::resizeEvent(QResizeEvent *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Graphic::showEvent(QShowEvent *) {
|
||||||
|
if (need_createGL && !canvas_gl) {
|
||||||
|
//qDebug() << "create GL on show";
|
||||||
|
canvas_gl = new UGLWidget();
|
||||||
|
ui->layoutCanvas->addWidget(canvas_gl);
|
||||||
|
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
||||||
|
prepareCanvas(canvas_gl);
|
||||||
|
ui->canvas_raster->hide();
|
||||||
|
canvas_gl->show();
|
||||||
|
canvas = canvas_gl;
|
||||||
|
}
|
||||||
|
need_createGL = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::timerEvent(QTimerEvent * ) {
|
void Graphic::timerEvent(QTimerEvent * ) {
|
||||||
pause_phase += 0.02;
|
pause_phase += 0.02;
|
||||||
if (pause_phase > 1.)
|
if (pause_phase > 1.)
|
||||||
@@ -930,16 +945,24 @@ void Graphic::exportGraphics(QString filename) {
|
|||||||
void Graphic::setOpenGL(bool on) {
|
void Graphic::setOpenGL(bool on) {
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
isOGL = on;
|
isOGL = on;
|
||||||
|
need_createGL = false;
|
||||||
if (on && !m_fakeGL) {
|
if (on && !m_fakeGL) {
|
||||||
if (!canvas_gl) {
|
if (!canvas_gl) {
|
||||||
canvas_gl = new UGLWidget();
|
if (!isVisible())
|
||||||
ui->layoutCanvas->addWidget(canvas_gl);
|
need_createGL = true;
|
||||||
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
else {
|
||||||
prepareCanvas(canvas_gl);
|
//qDebug() << "create GL on setter";
|
||||||
|
canvas_gl = new UGLWidget();
|
||||||
|
ui->layoutCanvas->addWidget(canvas_gl);
|
||||||
|
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
||||||
|
prepareCanvas(canvas_gl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (canvas_gl) {
|
||||||
|
ui->canvas_raster->hide();
|
||||||
|
canvas_gl->show();
|
||||||
|
canvas = canvas_gl;
|
||||||
}
|
}
|
||||||
ui->canvas_raster->hide();
|
|
||||||
canvas_gl->show();
|
|
||||||
canvas = canvas_gl;
|
|
||||||
} else {
|
} else {
|
||||||
if (canvas_gl)
|
if (canvas_gl)
|
||||||
canvas_gl->hide();
|
canvas_gl->hide();
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
virtual void changeEvent(QEvent * e);
|
virtual void changeEvent(QEvent * e);
|
||||||
virtual void resizeEvent(QResizeEvent * );
|
virtual void resizeEvent(QResizeEvent * );
|
||||||
|
virtual void showEvent(QShowEvent * );
|
||||||
virtual QSize sizeHint() const {return QSize(400, 300);}
|
virtual QSize sizeHint() const {return QSize(400, 300);}
|
||||||
virtual void timerEvent(QTimerEvent * );
|
virtual void timerEvent(QTimerEvent * );
|
||||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||||
@@ -415,7 +416,7 @@ protected:
|
|||||||
double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10;
|
double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10;
|
||||||
double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle;
|
double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle;
|
||||||
int lastw, lasth, min_repaint_int, timer_pause, thick;
|
int lastw, lasth, min_repaint_int, timer_pause, thick;
|
||||||
bool aalias, aupdate, grid, guides, isFit, isOGL, isHover, bufferActive, cancel, pause_, gestures, m_LODOptimization, m_fakeGL;
|
bool aalias, aupdate, grid, guides, isFit, isOGL, isHover, bufferActive, cancel, pause_, gestures, m_LODOptimization, m_fakeGL, need_createGL;
|
||||||
bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr, need_mouse_pan;
|
bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr, need_mouse_pan;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user