graphic openglwidget create only when realy switch to opengl
This commit is contained in:
@@ -4,7 +4,7 @@ cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
|||||||
project(qad)
|
project(qad)
|
||||||
set(qad_MAJOR 2)
|
set(qad_MAJOR 2)
|
||||||
set(qad_MINOR 2)
|
set(qad_MINOR 2)
|
||||||
set(qad_REVISION 1)
|
set(qad_REVISION 2)
|
||||||
set(qad_SUFFIX )
|
set(qad_SUFFIX )
|
||||||
set(qad_COMPANY SHS)
|
set(qad_COMPANY SHS)
|
||||||
set(qad_DOMAIN org.SHS)
|
set(qad_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -105,12 +105,6 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
|||||||
connect(&line_y_max, SIGNAL(valueChanged(double)), this, SLOT(lineYMaxChanged(double)));
|
connect(&line_y_max, SIGNAL(valueChanged(double)), this, SLOT(lineYMaxChanged(double)));
|
||||||
connect(ui->canvas_raster, SIGNAL(paintEvent(QPaintEvent * )), this, SLOT(canvasPaintEvent()));
|
connect(ui->canvas_raster, SIGNAL(paintEvent(QPaintEvent * )), this, SLOT(canvasPaintEvent()));
|
||||||
prepareCanvas(ui->canvas_raster);
|
prepareCanvas(ui->canvas_raster);
|
||||||
#ifdef HAS_GL
|
|
||||||
canvas_gl = new UGLWidget();
|
|
||||||
ui->layoutCanvas->addWidget(canvas_gl);
|
|
||||||
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
|
||||||
prepareCanvas(canvas_gl);
|
|
||||||
#endif
|
|
||||||
icon_exp_x = QIcon(":/icons/expand_x.png");
|
icon_exp_x = QIcon(":/icons/expand_x.png");
|
||||||
icon_exp_y = QIcon(":/icons/expand_y.png");
|
icon_exp_y = QIcon(":/icons/expand_y.png");
|
||||||
icon_exp_sx = QIcon(":/icons/expand_s_x.png");
|
icon_exp_sx = QIcon(":/icons/expand_s_x.png");
|
||||||
@@ -870,11 +864,18 @@ void Graphic::setOpenGL(bool on) {
|
|||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
isOGL = on;
|
isOGL = on;
|
||||||
if (on) {
|
if (on) {
|
||||||
|
if (!canvas_gl) {
|
||||||
|
canvas_gl = new UGLWidget();
|
||||||
|
ui->layoutCanvas->addWidget(canvas_gl);
|
||||||
|
connect(canvas_gl, SIGNAL(paintSignal()), this, SLOT(canvasPaintEvent()));
|
||||||
|
prepareCanvas(canvas_gl);
|
||||||
|
}
|
||||||
ui->canvas_raster->hide();
|
ui->canvas_raster->hide();
|
||||||
canvas_gl->show();
|
canvas_gl->show();
|
||||||
canvas = canvas_gl;
|
canvas = canvas_gl;
|
||||||
} else {
|
} else {
|
||||||
canvas_gl->hide();
|
if (canvas_gl)
|
||||||
|
canvas_gl->hide();
|
||||||
ui->canvas_raster->show();
|
ui->canvas_raster->show();
|
||||||
canvas = ui->canvas_raster;
|
canvas = ui->canvas_raster;
|
||||||
}
|
}
|
||||||
@@ -1460,7 +1461,8 @@ void Graphic::setCurrentAction(GraphicAction action) {
|
|||||||
void Graphic::setCanvasCursor(QCursor cursor) {
|
void Graphic::setCanvasCursor(QCursor cursor) {
|
||||||
ui->canvas_raster->setCursor(cursor);
|
ui->canvas_raster->setCursor(cursor);
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
canvas_gl->setCursor(cursor);
|
if (canvas_gl)
|
||||||
|
canvas_gl->setCursor(cursor);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1476,7 +1478,7 @@ void Graphic::setGuidesCursor() {
|
|||||||
void Graphic::swapToBuffer() {
|
void Graphic::swapToBuffer() {
|
||||||
QImage timg;
|
QImage timg;
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
if (isOGL) {
|
if (isOGL && canvas_gl) {
|
||||||
timg = canvas_gl->grabFrameBuffer();
|
timg = canvas_gl->grabFrameBuffer();
|
||||||
QPainter p(buffer);
|
QPainter p(buffer);
|
||||||
p.drawImage(0, 0, timg);
|
p.drawImage(0, 0, timg);
|
||||||
|
|||||||
Reference in New Issue
Block a user