no real OpenGL in Graphic in Qt Designer
This commit is contained in:
@@ -61,7 +61,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
|||||||
canvas_gl = 0;
|
canvas_gl = 0;
|
||||||
gesture_angle = 45.;
|
gesture_angle = 45.;
|
||||||
leg_update = true;
|
leg_update = true;
|
||||||
visible_update = fullscr = need_mouse_pan = false;
|
visible_update = fullscr = need_mouse_pan = m_fakeGL = false;
|
||||||
gestures =
|
gestures =
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
true;
|
true;
|
||||||
@@ -334,7 +334,7 @@ void Graphic::canvasPaintEvent() {
|
|||||||
}
|
}
|
||||||
QPainter p;
|
QPainter p;
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
if (isOGL) {
|
if (isOGL && !m_fakeGL) {
|
||||||
p.fillRect(canvas->rect(), Qt::black);
|
p.fillRect(canvas->rect(), Qt::black);
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
p.begin(canvas);
|
p.begin(canvas);
|
||||||
@@ -358,7 +358,7 @@ void Graphic::canvasPaintEvent() {
|
|||||||
drawGrid();
|
drawGrid();
|
||||||
p.setRenderHint(QPainter::Antialiasing, aalias);
|
p.setRenderHint(QPainter::Antialiasing, aalias);
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
if (isOGL) {
|
if (isOGL && !m_fakeGL) {
|
||||||
if (aalias) glEnable(GL_MULTISAMPLE);
|
if (aalias) glEnable(GL_MULTISAMPLE);
|
||||||
else glDisable(GL_MULTISAMPLE);
|
else glDisable(GL_MULTISAMPLE);
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ void Graphic::canvasPaintEvent() {
|
|||||||
if (pause_) drawPause();
|
if (pause_) drawPause();
|
||||||
emit graphicPaintEvent(painter);
|
emit graphicPaintEvent(painter);
|
||||||
p.end();
|
p.end();
|
||||||
if (isOGL) return;
|
if (isOGL && !m_fakeGL) return;
|
||||||
p.begin(canvas);
|
p.begin(canvas);
|
||||||
p.drawImage(0, 0, *buffer);
|
p.drawImage(0, 0, *buffer);
|
||||||
p.end();
|
p.end();
|
||||||
@@ -863,7 +863,7 @@ 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;
|
||||||
if (on) {
|
if (on && !m_fakeGL) {
|
||||||
if (!canvas_gl) {
|
if (!canvas_gl) {
|
||||||
canvas_gl = new UGLWidget();
|
canvas_gl = new UGLWidget();
|
||||||
ui->layoutCanvas->addWidget(canvas_gl);
|
ui->layoutCanvas->addWidget(canvas_gl);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace Ui {
|
|||||||
|
|
||||||
|
|
||||||
class UGLWidget;
|
class UGLWidget;
|
||||||
|
class GraphicPlugin;
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QVector<QPointF>)
|
Q_DECLARE_METATYPE(QVector<QPointF>)
|
||||||
@@ -119,6 +120,8 @@ class QAD_GRAPHIC_EXPORT Graphic: public QFrame
|
|||||||
Q_PROPERTY(Graphic::GraphicsData graphicsData READ graphicsData WRITE setGraphicsData)
|
Q_PROPERTY(Graphic::GraphicsData graphicsData READ graphicsData WRITE setGraphicsData)
|
||||||
Q_PROPERTY(QByteArray graphicsDataRaw READ graphicsDataRaw WRITE setGraphicsDataRaw)
|
Q_PROPERTY(QByteArray graphicsDataRaw READ graphicsDataRaw WRITE setGraphicsDataRaw)
|
||||||
|
|
||||||
|
friend class GraphicPlugin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Graphic(QWidget * parent = 0);
|
Graphic(QWidget * parent = 0);
|
||||||
virtual ~Graphic();
|
virtual ~Graphic();
|
||||||
@@ -406,7 +409,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;
|
bool aalias, aupdate, grid, guides, isFit, isOGL, isHover, bufferActive, cancel, pause_, gestures, m_LODOptimization, m_fakeGL;
|
||||||
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:
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
|
|
||||||
GraphicPlugin::GraphicPlugin(QObject * parent): QObject(parent) {
|
GraphicPlugin::GraphicPlugin(QObject * parent): QObject(parent) {
|
||||||
m_initialized = false;
|
m_initialized = m_designer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
void GraphicPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||||
|
m_designer = true;
|
||||||
if (m_initialized)
|
if (m_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -24,7 +25,10 @@ bool GraphicPlugin::isInitialized() const {
|
|||||||
|
|
||||||
|
|
||||||
QWidget * GraphicPlugin::createWidget(QWidget * parent) {
|
QWidget * GraphicPlugin::createWidget(QWidget * parent) {
|
||||||
return new Graphic(parent);
|
auto ret = new Graphic(parent);
|
||||||
|
if (m_designer)
|
||||||
|
ret->m_fakeGL = true;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
void initialize(QDesignerFormEditorInterface * core);
|
void initialize(QDesignerFormEditorInterface * core);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_initialized;
|
bool m_initialized, m_designer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user