mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-17 03:00:46 +00:00
gXAxis tickers had a time flicker from timezone offset calculation
This commit is contained in:
parent
92e018ceb6
commit
5444092e76
@ -19,6 +19,12 @@ gXAxis::gXAxis(QColor col)
|
|||||||
m_show_minor_lines=false;
|
m_show_minor_lines=false;
|
||||||
m_show_minor_ticks=true;
|
m_show_minor_ticks=true;
|
||||||
m_show_major_ticks=true;
|
m_show_major_ticks=true;
|
||||||
|
QDateTime d=QDateTime::currentDateTime();
|
||||||
|
QTime t1=d.time();
|
||||||
|
QTime t2=d.toUTC().time();
|
||||||
|
tz_offset=t2.secsTo(t1)/60L;
|
||||||
|
tz_offset*=60000L;
|
||||||
|
//offset=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
gXAxis::~gXAxis()
|
gXAxis::~gXAxis()
|
||||||
@ -30,7 +36,7 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
int start_px=w.GetLeftMargin();
|
int start_px=w.GetLeftMargin();
|
||||||
int start_py=w.GetBottomMargin();
|
int start_py=w.GetBottomMargin();
|
||||||
float width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
||||||
// float height=scry-(w.GetTopMargin()+w.GetBottomMargin());
|
// float height=scry-(w.GetTopMargin()+w.GetBottomMargin());
|
||||||
|
|
||||||
if (width<40)
|
if (width<40)
|
||||||
@ -85,13 +91,13 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float max_ticks=float(width)/(x+10); // Max number of ticks that will fit
|
int max_ticks=width/(x+10); // Max number of ticks that will fit
|
||||||
|
|
||||||
float fit_ticks=0;
|
int fit_ticks=0;
|
||||||
int div=-1;
|
int div=-1;
|
||||||
float closest=0,tmp,tmpft;
|
qint64 closest=0,tmp,tmpft;
|
||||||
for (int i=dividx;i<divmax;i++){
|
for (int i=dividx;i<divmax;i++){
|
||||||
tmpft=ceil(float(xx)/float(divisors[i]));
|
tmpft=xx/divisors[i];
|
||||||
tmp=max_ticks-tmpft;
|
tmp=max_ticks-tmpft;
|
||||||
if (tmp<0) continue;
|
if (tmp<0) continue;
|
||||||
if (tmpft>closest) { // Find the closest scale to the number
|
if (tmpft>closest) { // Find the closest scale to the number
|
||||||
@ -114,25 +120,26 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
qint64 zz=zqvx/step; // Number of ticks that fit up to minx
|
qint64 zz=zqvx/step; // Number of ticks that fit up to minx
|
||||||
|
|
||||||
//Align left minimum to divisor
|
//Align left minimum to divisor
|
||||||
qint64 rm=w.rmin_x % step; // Offset from rminx of an aligned time
|
qint64 aligned_start=minx/step;
|
||||||
|
aligned_start*=step;
|
||||||
|
|
||||||
|
/*qint64 rm=w.rmin_x % step; // Offset from rminx of an aligned time
|
||||||
rm=step-rm;
|
rm=step-rm;
|
||||||
rm+=w.rmin_x;
|
rm+=w.rmin_x;
|
||||||
//qint64 rd=w.rmin_x / divisors[div];
|
//qint64 rd=w.rmin_x / divisors[div];
|
||||||
//rd*=divisors[div];
|
//rd*=divisors[div];
|
||||||
qint64 aligned_start=(zz*step)+rm; // First location of aligned point.
|
qint64 aligned_start=(zz*step)+rm; // First location of aligned point.
|
||||||
aligned_start/=step;
|
*/
|
||||||
aligned_start*=step;
|
|
||||||
|
|
||||||
|
|
||||||
while (aligned_start<minx) {
|
while (aligned_start<minx) {
|
||||||
aligned_start+=step;
|
aligned_start+=step;
|
||||||
}
|
}
|
||||||
|
aligned_start/=step;
|
||||||
|
aligned_start*=step;
|
||||||
|
|
||||||
double xmult=double(width)/double(xx);
|
double xmult=double(width)/double(xx);
|
||||||
w.qglColor(Qt::black);
|
w.qglColor(Qt::black);
|
||||||
QString tmpstr;
|
QString tmpstr;
|
||||||
QTime t1=QDateTime::currentDateTime().time();
|
|
||||||
QTime t2=QDateTime::currentDateTimeUtc().time();
|
|
||||||
qint64 offset=t2.secsTo(t1)*1000;
|
|
||||||
for (qint64 i=aligned_start;i<maxx;i+=step) {
|
for (qint64 i=aligned_start;i<maxx;i+=step) {
|
||||||
px=double(i-minx)*xmult;
|
px=double(i-minx)*xmult;
|
||||||
px+=start_px;
|
px+=start_px;
|
||||||
@ -144,16 +151,16 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
if (fitmode==0) {
|
if (fitmode==0) {
|
||||||
} else {
|
} else {
|
||||||
qint64 j=i+offset;
|
qint64 j=i+tz_offset;
|
||||||
short m=(j/60000) % 60;
|
int ms=j % 1000;
|
||||||
short h=(j/3600000) % 24;
|
int m=(j/60000L) % 60L;
|
||||||
short s=(j/1000) % 60;
|
int h=(j/3600000L) % 24L;
|
||||||
|
int s=(j/1000L) % 60L;
|
||||||
if (fitmode==1) { // minute
|
if (fitmode==1) { // minute
|
||||||
tmpstr=QString("%1:%2").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0'));
|
tmpstr=QString("%1:%2").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0'));
|
||||||
} else if (fitmode==2) { // second
|
} else if (fitmode==2) { // second
|
||||||
tmpstr=QString("%1:%2:%3").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0'));
|
tmpstr=QString("%1:%2:%3").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0'));
|
||||||
} else if (fitmode==3) { // milli
|
} else if (fitmode==3) { // milli
|
||||||
short ms=j % 1000;
|
|
||||||
tmpstr=QString("%1:%2:%3:%4").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0')).arg(ms,3,10,QChar('0'));
|
tmpstr=QString("%1:%2:%3:%4").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0')).arg(ms,3,10,QChar('0'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +168,7 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
}
|
}
|
||||||
int i=0;
|
int i=0;
|
||||||
return;
|
/* return;
|
||||||
// subtract 1.. align to first div unit
|
// subtract 1.. align to first div unit
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +179,7 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
|
|
||||||
double jj=1/max_ticks;
|
double jj=1/max_ticks;
|
||||||
double minor_tick=max_ticks*xx;
|
double minor_tick=max_ticks*double(xx);
|
||||||
double st2=minx; //double(int(frac*1440.0))/1440.0;
|
double st2=minx; //double(int(frac*1440.0))/1440.0;
|
||||||
double st,q;
|
double st,q;
|
||||||
|
|
||||||
@ -311,6 +318,6 @@ void gXAxis::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ class gXAxis:public gLayer
|
|||||||
QColor m_text_color;
|
QColor m_text_color;
|
||||||
QColor m_major_color;
|
QColor m_major_color;
|
||||||
QColor m_minor_color;
|
QColor m_minor_color;
|
||||||
|
qint64 tz_offset;
|
||||||
};
|
};
|
||||||
#endif // GXAXIS_H
|
#endif // GXAXIS_H
|
||||||
|
@ -53,6 +53,8 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
|
|||||||
|
|
||||||
//scrollArea=new MyScrollArea(this);
|
//scrollArea=new MyScrollArea(this);
|
||||||
|
|
||||||
|
QString s="QTreeWidget::selection-background-color { qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5, stop: 0 #FF92BB, stop: 1 white); }";
|
||||||
|
ui->treeWidget->setStyleSheet(s);
|
||||||
GraphLayout=new QWidget();
|
GraphLayout=new QWidget();
|
||||||
ui->graphSizer->addWidget(GraphLayout,1);
|
ui->graphSizer->addWidget(GraphLayout,1);
|
||||||
|
|
||||||
|
2
daily.ui
2
daily.ui
@ -102,7 +102,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="movable">
|
<property name="movable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1060</width>
|
<width>668</width>
|
||||||
<height>355</height>
|
<height>355</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -94,7 +94,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>458</width>
|
||||||
<height>282</height>
|
<height>282</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user