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 * ) {
|
||||
pause_phase += 0.02;
|
||||
if (pause_phase > 1.)
|
||||
@@ -930,16 +945,24 @@ void Graphic::exportGraphics(QString filename) {
|
||||
void Graphic::setOpenGL(bool on) {
|
||||
#ifdef HAS_GL
|
||||
isOGL = on;
|
||||
need_createGL = false;
|
||||
if (on && !m_fakeGL) {
|
||||
if (!canvas_gl) {
|
||||
canvas_gl = new UGLWidget();
|
||||
ui->layoutCanvas->addWidget(canvas_gl);
|
||||
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
||||
prepareCanvas(canvas_gl);
|
||||
if (!isVisible())
|
||||
need_createGL = true;
|
||||
else {
|
||||
//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 {
|
||||
if (canvas_gl)
|
||||
canvas_gl->hide();
|
||||
|
||||
@@ -346,6 +346,7 @@ public slots:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent * e);
|
||||
virtual void resizeEvent(QResizeEvent * );
|
||||
virtual void showEvent(QShowEvent * );
|
||||
virtual QSize sizeHint() const {return QSize(400, 300);}
|
||||
virtual void timerEvent(QTimerEvent * );
|
||||
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 eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle;
|
||||
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;
|
||||
|
||||
protected slots:
|
||||
|
||||
Reference in New Issue
Block a user