mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Texture cache test with vertical graph titles
This commit is contained in:
parent
75154b091b
commit
ca89b7d9db
@ -1052,6 +1052,8 @@ gGraph::gGraph(gGraphView *graphview,QString title,QString units, int height,sho
|
|||||||
m_selecting_area=m_blockzoom=false;
|
m_selecting_area=m_blockzoom=false;
|
||||||
m_lastx23=0;
|
m_lastx23=0;
|
||||||
|
|
||||||
|
titleImage=QImage();
|
||||||
|
invalidate_VertTextCache=true;
|
||||||
|
|
||||||
m_quad=new gVertexBuffer(64,GL_QUADS);
|
m_quad=new gVertexBuffer(64,GL_QUADS);
|
||||||
m_quad->forceAntiAlias(true);
|
m_quad->forceAntiAlias(true);
|
||||||
@ -1173,9 +1175,50 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
|||||||
left=marginLeft(),right=marginRight(),top=marginTop(),bottom=marginBottom();
|
left=marginLeft(),right=marginRight(),top=marginTop(),bottom=marginBottom();
|
||||||
int x=0,y=0;
|
int x=0,y=0;
|
||||||
if (m_showTitle) {
|
if (m_showTitle) {
|
||||||
GetTextExtent(title(),x,y,mediumfont);
|
int title_x,yh;
|
||||||
int title_x=(float(y)*2);
|
if (titleImage.isNull()) {
|
||||||
renderText(title(),marginLeft()+title_x,originY+height/2,90,Qt::black,mediumfont);
|
// Render the title to a texture so we don't have to draw the vertical text every time..
|
||||||
|
GetTextExtent("Wy@",x,yh,mediumfont);
|
||||||
|
GetTextExtent(title(),x,y,mediumfont);
|
||||||
|
|
||||||
|
y=yh;
|
||||||
|
QPixmap tpm=QPixmap(x+4,y+4);
|
||||||
|
|
||||||
|
tpm.fill(Qt::transparent);
|
||||||
|
QPainter pmp(&tpm);
|
||||||
|
|
||||||
|
QBrush brush2(Qt::black);
|
||||||
|
pmp.setBrush(brush2);
|
||||||
|
|
||||||
|
pmp.setFont(*mediumfont);
|
||||||
|
pmp.drawText(2,y,title());
|
||||||
|
pmp.end();
|
||||||
|
|
||||||
|
titleImage=QGLWidget::convertToGLFormat(tpm.toImage().mirrored(false,true));
|
||||||
|
titleImageTex=m_graphview->bindTexture(titleImage);
|
||||||
|
}
|
||||||
|
y=titleImage.height();
|
||||||
|
x=titleImage.width(); //vertical text
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
title_x=y*2;
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(marginLeft()+4,originY+height/2+x/2, 0);
|
||||||
|
glRotatef(-90,0,0,1);
|
||||||
|
m_graphview->drawTexture(QPoint(0,y/2),titleImageTex);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
//renderText(title(),marginLeft()+title_x,originY+height/2,90,Qt::black,mediumfont);
|
||||||
left+=title_x;
|
left+=title_x;
|
||||||
} else left=0;
|
} else left=0;
|
||||||
|
|
||||||
@ -1887,10 +1930,10 @@ QPixmap gGraph::renderPixmap(int w, int h, bool printing)
|
|||||||
|
|
||||||
//sg->makeCurrent();
|
//sg->makeCurrent();
|
||||||
|
|
||||||
pm=sg->fboRenderPixmap(w,h);
|
pm=sg->renderPixmap(w,h,false);
|
||||||
if (pm.isNull()) {
|
if (pm.isNull()) {
|
||||||
// this one gives nags
|
// this one gives nags
|
||||||
pm=sg->renderPixmap(w,h,false);
|
pm=sg->fboRenderPixmap(w,h);
|
||||||
} else if (pm.isNull()) { // not sure if this will work with printing
|
} else if (pm.isNull()) { // not sure if this will work with printing
|
||||||
qDebug() << "Had to use PixelBuffer for snapshots\n";
|
qDebug() << "Had to use PixelBuffer for snapshots\n";
|
||||||
pm=sg->pbRenderPixmap(w,h);
|
pm=sg->pbRenderPixmap(w,h);
|
||||||
|
@ -548,7 +548,7 @@ public:
|
|||||||
float height() { return m_height; }
|
float height() { return m_height; }
|
||||||
|
|
||||||
//! \brief Set the height element. (relative to the total of all heights)
|
//! \brief Set the height element. (relative to the total of all heights)
|
||||||
void setHeight(float height) { m_height=height; }
|
void setHeight(float height) { m_height=height; invalidate_VertTextCache=true;}
|
||||||
|
|
||||||
int minHeight() { return m_min_height; }
|
int minHeight() { return m_min_height; }
|
||||||
void setMinHeight(int height) { m_min_height=height; }
|
void setMinHeight(int height) { m_min_height=height; }
|
||||||
@ -728,6 +728,9 @@ public:
|
|||||||
Layer * getLineChart();
|
Layer * getLineChart();
|
||||||
QRect m_lastbounds;
|
QRect m_lastbounds;
|
||||||
QTimer * timer;
|
QTimer * timer;
|
||||||
|
QImage titleImage;
|
||||||
|
GLuint titleImageTex;
|
||||||
|
bool invalidate_VertTextCache;
|
||||||
|
|
||||||
//! \brief Returns a Vector reference containing all this graphs layers
|
//! \brief Returns a Vector reference containing all this graphs layers
|
||||||
QVector<Layer *> & layers() { return m_layers; }
|
QVector<Layer *> & layers() { return m_layers; }
|
||||||
|
Loading…
Reference in New Issue
Block a user