Fix archiac weight glitch.. made cube even more annoying

This commit is contained in:
Mark Watkins 2012-01-06 01:17:50 +10:00
parent 582c70ef60
commit 1485afe17c
6 changed files with 103 additions and 30 deletions

View File

@ -2356,6 +2356,8 @@ void gGraphView::renderSomethingFun()
// When I'm feeling more energetic, I'll change it to a textured sheep or something.
static float rotqube=0;
static float xpos=0,ypos=7,spos=0;
glLoadIdentity();
glAlphaFunc(GL_GREATER,0.1);
@ -2368,13 +2370,24 @@ void gGraphView::renderSomethingFun()
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTranslatef(0.0f, 0.0f,-7.0f);
double xx=sin(M_PI/180.0 * xpos)*2; // ((4.0/width()) * m_mouse.rx())-2.0;
double yy=cos(M_PI/180.0 * ypos)*2; //2-((4.0/height()) * m_mouse.ry());
xpos+=1;
ypos+=1.32;
if (xpos > 360) xpos-=360.0;
if (ypos > 360) ypos-=360.0;
//m_mouse.x();
glTranslatef(xx, 0.0f,-7.0f+yy);
glRotatef(rotqube,0.0f,1.0f,0.0f);
glRotatef(rotqube,1.0f,1.0f,1.0f);
int i=0;
glEnable(GL_TEXTURE_2D);
cubetex=bindTexture(*cubeimg[0]);
//glBindTexture(GL_TEXTURE_2D, cubetex); //texid[i % imgcount]);
i++;
glColor4f(1,1,1,1);
@ -2426,8 +2439,8 @@ void gGraphView::renderSomethingFun()
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
glEnd();
// Left Face
//bindTexture(*cubeimg[i % imgcount]);
//glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
//GLuint tex=bindTexture(*images["mask"]);
//glBindTexture(GL_TEXTURE_2D, tex);
i++;
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad
@ -2753,12 +2766,23 @@ void gGraphView::paintGL()
}
#ifdef DEBUG_EFFICIENCY
const int rs=10;
static double ring[rs]={0};
static int rp=0;
// Show FPS and draw time
if (m_showsplitter && PROFILE.general->showDebug()) {
QString ss;
qint64 ela=time.nsecsElapsed();
double ms=double(ela)/1000000.0;
ss="Debug Mode "+QString::number(ms,'f',1)+"ms ("+QString::number(1000.0/float(ms),'f',1)+"fps)";
ring[rp++]=1000.0/ms;
rp %= rs;
double v=0;
for (int i=0;i<rs;i++) {
v+=ring[i];
}
double fps=v/double(rs);
ss="Debug Mode "+QString::number(ms,'f',1)+"ms ("+QString::number(fps,'f',1)+"fps)";
int w,h;
GetTextExtent(ss,w,h);
QColor col=Qt::white;
@ -2773,7 +2797,7 @@ void gGraphView::paintGL()
if (this->isVisible()) {
if (m_limbo || m_inAnimation || (something_fun && !numgraphs)) {
redrawtimer->setInterval(20);
redrawtimer->setInterval(1000.0/50);
redrawtimer->setSingleShot(true);
redrawtimer->start();
}
@ -2812,6 +2836,8 @@ void gGraphView::mouseMoveEvent(QMouseEvent * event)
int x=event->x();
int y=event->y();
m_mouse=QPoint(x,y);
if (m_sizer_dragging) { // Resize handle being dragged
float my=y - m_sizer_point.y();
//qDebug() << "Sizer moved vertically" << m_sizer_index << my*m_scaleY;

View File

@ -1058,6 +1058,8 @@ protected:
bool m_inAnimation;
bool m_blockUpdates;
QPoint m_mouse;
QTime m_animationStarted;
//QVector<GLuint> texid;

View File

@ -1202,7 +1202,7 @@ void Daily::Load(QDate date)
void Daily::UnitsChanged()
{
double kg;
if (PROFILE.general->unitSystem()==US_Metric) {
if (PROFILE.general->unitSystem()==US_Archiac) {
kg=ui->weightSpinBox->value();
float ounces=(kg*1000.0)/ounce_convert;
int pounds=ounces/16;
@ -1253,8 +1253,7 @@ void Daily::Unload(QDate date)
}
}
if (journal->IsChanged()) {
mainwin->getOverview()->ResetGraphs();
// blah.. was updating overview graphs here.. Was too slow.
}
Machine *jm=PROFILE.GetMachine(MT_JOURNAL);
if (jm) jm->SaveSession(journal);
@ -1637,12 +1636,7 @@ void Daily::on_ZombieMeter_valueChanged(int action)
journal->settings[Journal_ZombieMeter]=ui->ZombieMeter->value();
journal->SetChanged(true);
gGraph *g;
if (mainwin->getOverview()) {
g=mainwin->getOverview()->graphView()->findGraph("Zombie");
if (g) g->setDay(NULL);
//mainwin->getOverview()->RedrawGraphs();
}
if (mainwin->getOverview()) mainwin->getOverview()->ResetGraph("Zombie");
}
void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
@ -1650,8 +1644,26 @@ void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
Q_UNUSED(item);
update_Bookmarks();
}
void Daily::on_weightSpinBox_valueChanged(double arg1)
{
// Update the BMI display
double kg;
if (PROFILE.general->unitSystem()==US_Archiac) {
kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0;
} else kg=arg1;
double height=PROFILE.user->height()/100.0;
if ((height>0) && (kg>0)) {
double bmi=kg/(height * height);
ui->BMI->display(bmi);
ui->BMI->setVisible(true);
}
}
void Daily::on_weightSpinBox_editingFinished()
{
double arg1=ui->weightSpinBox->value();
double height=PROFILE.user->height()/100.0;
Session *journal=GetJournalSession(previous_date);
if (!journal) {
@ -1660,7 +1672,7 @@ void Daily::on_weightSpinBox_valueChanged(double arg1)
double kg;
if (PROFILE.general->unitSystem()==US_Archiac) {
kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert);
kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0;
} else {
kg=arg1;
}
@ -1683,17 +1695,30 @@ void Daily::on_weightSpinBox_valueChanged(double arg1)
}
journal->SetChanged(true);
}
void Daily::on_ouncesSpinBox_valueChanged(int arg1)
{
// just update for BMI display
double height=PROFILE.user->height()/100.0;
double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0;
if ((height>0) && (kg>0)) {
double bmi=kg/(height * height);
ui->BMI->display(bmi);
ui->BMI->setVisible(true);
}
}
void Daily::on_ouncesSpinBox_editingFinished()
{
double arg1=ui->ouncesSpinBox->value();
Session *journal=GetJournalSession(previous_date);
if (!journal) {
journal=CreateJournalSession(previous_date);
}
double height=PROFILE.user->height()/100.0;
double kg=(ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert);
double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0;
journal->settings[Journal_Weight]=kg;
gGraph *g;
if (mainwin->getOverview()) {
g=mainwin->getOverview()->graphView()->findGraph(STR_TR_Weight);
@ -1712,7 +1737,9 @@ void Daily::on_ouncesSpinBox_valueChanged(int arg1)
}
}
journal->SetChanged(true);
if (mainwin->getOverview()) mainwin->getOverview()->ResetGraph("Weight");
}
QString Daily::GetDetailsText()
{
ui->webView->triggerPageAction(QWebPage::SelectAll);

32
daily.h
View File

@ -187,19 +187,6 @@ private slots:
*/
void on_bookmarkTable_itemChanged(QTableWidgetItem *item);
/*! \fn on_weightSpinBox_valueChanged(double arg1);
\brief Called when weight has changed.. Updates the BMI dislpay and journal objects.
Also Refreshes the Overview charts
*/
void on_weightSpinBox_valueChanged(double arg1);
/*! \fn on_ouncesSpinBox_valueChanged(int arg1);
\brief Called when weights ounces component has changed.. Updates the BMI dislpay and journal objects.
Also Refreshes the Overview charts
*/
void on_ouncesSpinBox_valueChanged(int arg1);
/*! \fn on_ouncesSpinBox_valueChanged(int arg1);
\brief Called when the zombie slider has been moved.. Updates the BMI dislpay and journal objects.
@ -216,6 +203,25 @@ private slots:
void on_resetLayoutButton_clicked();
/*! \fn on_weightSpinBox_editingFinished();
\brief Called when weight has changed.. Updates the BMI dislpay and journal objects.
Also Refreshes the Overview charts
*/
void on_weightSpinBox_editingFinished();
/*! \fn on_ouncesSpinBox_editingFinished();
\brief Called when weights ounces component has changed.. Updates the BMI dislpay and journal objects.
Also Refreshes the Overview charts
*/
void on_ouncesSpinBox_editingFinished();
void on_ouncesSpinBox_valueChanged(int arg1);
void on_weightSpinBox_valueChanged(double arg1);
protected:
private:

View File

@ -331,6 +331,8 @@ void Overview::updateGraphCombo()
void Overview::ResetGraphs()
{
//qint64 st,et;
//GraphView->GetXBounds(st,et);
QDate start=ui->dateStart->date();
QDate end=ui->dateEnd->date();
GraphView->setDay(NULL);
@ -338,6 +340,15 @@ void Overview::ResetGraphs()
if (start.isValid() && end.isValid()) {
setRange(start,end);
}
//GraphView->SetXBounds(st,et);
}
void Overview::ResetGraph(QString name)
{
gGraph *g=GraphView->findGraph(name);
if (!g) return;
g->setDay(NULL);
GraphView->redraw();
}
void Overview::RedrawGraphs()

View File

@ -65,6 +65,7 @@ public:
QVector<SummaryChart *> OverviewCharts;
void updateGraphCombo();
void ResetGraph(QString name);
public slots:
// ! \brief Print button down the bottom, does the same as File->Print