mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 02:30:44 +00:00
Multithread fixes
This commit is contained in:
parent
04de897780
commit
7e14cb978e
@ -16,9 +16,9 @@ gFlagsGroup::gFlagsGroup()
|
||||
static QColor col2=QColor(0xff,0xff,0xff,0xff);
|
||||
static QColor col=Qt::black;
|
||||
|
||||
addGLBuf(quad1=new GLBuffer(col1,2048,GL_QUADS));
|
||||
addGLBuf(quad2=new GLBuffer(col2,2048,GL_QUADS));
|
||||
addGLBuf(lines=new GLBuffer(col,2048,GL_LINES));
|
||||
addGLBuf(quad1=new GLBuffer(col1,512,GL_QUADS));
|
||||
addGLBuf(quad2=new GLBuffer(col2,512,GL_QUADS));
|
||||
addGLBuf(lines=new GLBuffer(col,20,GL_LINE_LOOP));
|
||||
quad1->setAntiAlias(true);
|
||||
quad2->setAntiAlias(true);
|
||||
lines->setAntiAlias(false);
|
||||
@ -70,35 +70,13 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
|
||||
quad2->add(left+width-1,linetop+barh,left+width-1,linetop);
|
||||
}
|
||||
|
||||
// barcol=&col1;
|
||||
|
||||
//int qo=0;
|
||||
//if (evil_intel_graphics_card) qo=1;
|
||||
|
||||
// Draw the bars with filled quads
|
||||
/*glBegin(GL_QUADS);
|
||||
w.qglColor(*barcol);
|
||||
glVertex2f(left, linetop);
|
||||
glVertex2f(left, linetop+barh);
|
||||
glVertex2f(left+width-1, linetop+barh);
|
||||
glVertex2f(left+width-1, linetop);
|
||||
glEnd(); */
|
||||
|
||||
// Paint the actual flags
|
||||
lvisible[i]->paint(w,left,linetop,width,barh);
|
||||
linetop+=barh;
|
||||
}
|
||||
|
||||
// Draw the outer rectangle outline
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glLineWidth(1);
|
||||
w.qglColor(Qt::black);
|
||||
glVertex2f(left-1, top);
|
||||
glVertex2f(left-1, top+height);
|
||||
glVertex2f(left+width, top+height);
|
||||
glVertex2f(left+width, top);
|
||||
glEnd ();
|
||||
|
||||
lines->add(left-1, top, left-1, top+height);
|
||||
lines->add(left+width, top+height, left+width, top);
|
||||
}
|
||||
|
||||
gFlagsLine::gFlagsLine(ChannelID code,QColor flag_color,QString label,bool always_visible,FlagType flt)
|
||||
@ -172,37 +150,4 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
|
||||
if (verts_exceeded) {
|
||||
qWarning() << "maxverts exceeded in gFlagsLine::plot()";
|
||||
}
|
||||
// glScissor(left,top,width,height);
|
||||
//glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
|
||||
//quads->draw();
|
||||
//lines->draw();
|
||||
/*glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
bool antialias=pref["UseAntiAliasing"].toBool();
|
||||
if (antialias) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glLineWidth (1.5);
|
||||
} else glLineWidth (1);
|
||||
|
||||
w.qglColor(m_flag_color);
|
||||
if (quadcnt>0) {
|
||||
glVertexPointer(2, GL_SHORT, 0, quadarray);
|
||||
glDrawArrays(GL_QUADS, 0, quadcnt>>1);
|
||||
}
|
||||
if (vertcnt>0) {
|
||||
glVertexPointer(2, GL_SHORT, 0, vertarray);
|
||||
glDrawArrays(GL_LINES, 0, vertcnt>>1);
|
||||
}
|
||||
if (antialias) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
*/
|
||||
//glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
@ -39,10 +39,13 @@ void DoneGraphs()
|
||||
|
||||
void GetTextExtent(QString text, int & width, int & height, QFont *font)
|
||||
{
|
||||
static QMutex mut;
|
||||
mut.lock();
|
||||
QFontMetrics fm(*font);
|
||||
//QRect r=fm.tightBoundingRect(text);
|
||||
width=fm.width(text); //fm.width(text);
|
||||
height=fm.xHeight()+2; //fm.ascent();
|
||||
mut.unlock();
|
||||
}
|
||||
|
||||
GLBuffer::GLBuffer(QColor color,int max,int type)
|
||||
@ -291,19 +294,24 @@ const double zoom_hard_limit=500.0;
|
||||
gThread::gThread(gGraph *g)
|
||||
{
|
||||
graph=g;
|
||||
mutex.lock();
|
||||
}
|
||||
void gThread::run()
|
||||
{
|
||||
int originX=m_lastbounds.x();
|
||||
int originY=m_lastbounds.y();
|
||||
int width=m_lastbounds.width();
|
||||
int height=m_lastbounds.height();
|
||||
graph->paint(originX,originY,width,height);
|
||||
graph->threadDone();
|
||||
while (this->isRunning()) {
|
||||
mutex.lock();
|
||||
int originX=m_lastbounds.x();
|
||||
int originY=m_lastbounds.y();
|
||||
int width=m_lastbounds.width();
|
||||
int height=m_lastbounds.height();
|
||||
graph->paint(originX,originY,width,height);
|
||||
graph->threadDone();
|
||||
}
|
||||
}
|
||||
void gThread::paint(int originX, int originY, int width, int height)
|
||||
{
|
||||
m_lastbounds=QRect(originX,originY,width,height);
|
||||
mutex.unlock(); // this is the signal to start
|
||||
}
|
||||
|
||||
gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) :
|
||||
@ -326,12 +334,17 @@ gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) :
|
||||
m_marginright=10;
|
||||
m_selecting_area=m_blockzoom=false;
|
||||
m_lastx23=0;
|
||||
|
||||
m_thread=new gThread(this);
|
||||
if (m_graphview->useThreads()) m_thread->start();
|
||||
quad=new GLBuffer(QColor(128,128,255,128),8,GL_QUADS);
|
||||
quad->forceAntiAlias(true);
|
||||
}
|
||||
gGraph::~gGraph()
|
||||
{
|
||||
if (m_graphview->useThreads()) {
|
||||
m_thread->exit();
|
||||
}
|
||||
delete m_thread;
|
||||
delete quad;
|
||||
}
|
||||
@ -433,7 +446,8 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
*/
|
||||
glColor4f(0,0,0,1);
|
||||
|
||||
//glColor4f(0,0,0,1);
|
||||
renderText(title(),20,originY+height/2,90,Qt::black,mediumfont);
|
||||
|
||||
left=0,right=0,top=0,bottom=0;
|
||||
@ -494,7 +508,7 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
|
||||
/*m_graphview->gl_mutex.lock();
|
||||
drawGLBuf();
|
||||
m_graphview->gl_mutex.unlock();*/
|
||||
m_graphview->gl_mutex.unlock(); */
|
||||
|
||||
}
|
||||
|
||||
@ -1201,7 +1215,7 @@ void gGraphView::paintGL()
|
||||
threaded=true;
|
||||
} else threaded=false;
|
||||
|
||||
//threaded=true;
|
||||
threaded=true;
|
||||
for (int i=0;i<m_graphs.size();i++) {
|
||||
if (m_graphs[i]->isEmpty() || !m_graphs[i]->visible()) continue;
|
||||
numgraphs++;
|
||||
@ -1218,8 +1232,8 @@ void gGraphView::paintGL()
|
||||
if (threaded) {
|
||||
masterlock->acquire(1);
|
||||
m_graphs[i]->thread()->paint(px,py,width()-titleWidth,h);
|
||||
m_graphs[i]->thread()->start(QThread::HighestPriority);
|
||||
m_graphs[i]->thread()->wait();
|
||||
//m_graphs[i]->thread()->start(QThread::HighestPriority);
|
||||
//m_graphs[i]->thread()->wait();
|
||||
} else {
|
||||
m_graphs[i]->paint(px,py,width()-titleWidth,h);
|
||||
}
|
||||
|
@ -163,9 +163,11 @@ public:
|
||||
gThread(gGraph *g);
|
||||
void run();
|
||||
void paint(int originX, int originY, int width, int height);
|
||||
QMutex mutex;
|
||||
protected:
|
||||
gGraph * graph;
|
||||
QRect m_lastbounds;
|
||||
|
||||
};
|
||||
|
||||
class gGraph
|
||||
@ -310,6 +312,7 @@ public:
|
||||
void setDay(Day * day);
|
||||
void threadDone();
|
||||
QSemaphore * masterlock;
|
||||
bool useThreads() { return m_idealthreads>1; }
|
||||
protected:
|
||||
int m_idealthreads;
|
||||
Day * m_day;
|
||||
|
@ -16,8 +16,11 @@ gLineChart::gLineChart(ChannelID code,QColor col,bool square_plot, bool disable_
|
||||
{
|
||||
m_line_color=col;
|
||||
m_report_empty=false;
|
||||
addGLBuf(lines=new GLBuffer(col,40000,GL_LINES));
|
||||
addGLBuf(lines=new GLBuffer(col,100000,GL_LINES));
|
||||
|
||||
addGLBuf(outlines=new GLBuffer(QColor(0,0,0,255),20,GL_LINE_LOOP));
|
||||
lines->setAntiAlias(true);
|
||||
outlines->setAntiAlias(false);
|
||||
|
||||
}
|
||||
gLineChart::~gLineChart()
|
||||
@ -114,16 +117,8 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
int minz,maxz;
|
||||
|
||||
// Draw bounding box
|
||||
{
|
||||
w.qglColor(Qt::black);
|
||||
glLineWidth (1);
|
||||
glBegin (GL_LINE_LOOP);
|
||||
glVertex2i (left, top);
|
||||
glVertex2i (left, top+height);
|
||||
glVertex2i (left+width,top+height);
|
||||
glVertex2i (left+width, top);
|
||||
glEnd ();
|
||||
}
|
||||
outlines->add(left, top, left, top+height);
|
||||
outlines->add(left+width,top+height, left+width, top);
|
||||
width--;
|
||||
height-=2;
|
||||
|
||||
|
@ -33,6 +33,7 @@ protected:
|
||||
bool m_disable_accel;
|
||||
QColor m_line_color;
|
||||
GLBuffer * lines;
|
||||
GLBuffer * outlines;
|
||||
};
|
||||
|
||||
#endif // GLINECHART_H
|
||||
|
@ -135,7 +135,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
|
||||
qWarning() << "exceeded maxverts in gLineOverlay::Plot()";
|
||||
}
|
||||
|
||||
bool antialias=pref["UseAntiAliasing"].toBool();
|
||||
/* bool antialias=pref["UseAntiAliasing"].toBool();
|
||||
if (antialias) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //_MINUS_SRC_ALPHA);
|
||||
@ -151,7 +151,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
|
||||
if (antialias) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
} */
|
||||
//glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ gTimeYAxis::gTimeYAxis(QColor col)
|
||||
gTimeYAxis::~gTimeYAxis()
|
||||
{
|
||||
}
|
||||
const QString & gTimeYAxis::Format(double v)
|
||||
const QString gTimeYAxis::Format(double v)
|
||||
{
|
||||
static QString t;
|
||||
int i=v;
|
||||
|
@ -16,7 +16,7 @@ class gTimeYAxis:public gYAxis
|
||||
public:
|
||||
gTimeYAxis(QColor col=QColor("black"));
|
||||
virtual ~gTimeYAxis();
|
||||
virtual const QString & Format(double v);
|
||||
virtual const QString Format(double v);
|
||||
};
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ class gYAxis:public Layer
|
||||
void SetShowMajorTicks(bool b) { m_show_major_ticks=b; }
|
||||
bool ShowMinorTicks() { return m_show_minor_ticks; }
|
||||
bool ShowMajorTicks() { return m_show_major_ticks; }
|
||||
virtual const QString & Format(double v) { static QString t; t.sprintf("%.1f",v); return t; }
|
||||
virtual const QString Format(double v) { return QString().sprintf("%.1f",v); }
|
||||
static const int Margin=50; // Left margin space
|
||||
|
||||
void SetScale(float f) { m_yaxis_scale=f; } // Scale yaxis ticker values (only what's displayed)
|
||||
|
Loading…
Reference in New Issue
Block a user