mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 02:30:44 +00:00
Print bookmarked flow rate areas in Daily report
This commit is contained in:
parent
f31179b1f9
commit
a85438486c
@ -734,16 +734,18 @@ void Layer::drawGLBuf(float linesize)
|
||||
int type;
|
||||
float size;
|
||||
if (!m_visible) return;
|
||||
GLBuffer *buf;
|
||||
for (int i=0;i<mgl_buffers.size();i++) {
|
||||
size=mgl_buffers[i]->size();
|
||||
type=mgl_buffers[i]->type();
|
||||
buf=mgl_buffers[i];
|
||||
size=buf->size();
|
||||
type=buf->type();
|
||||
if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
|
||||
mgl_buffers[i]->setSize(linesize);
|
||||
}
|
||||
mgl_buffers[i]->draw();
|
||||
if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
|
||||
mgl_buffers[i]->setSize(size);
|
||||
buf->setSize(linesize);
|
||||
}
|
||||
buf->draw();
|
||||
//if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
|
||||
buf->setSize(size);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ gXGrid::gXGrid(QColor col)
|
||||
{
|
||||
Q_UNUSED(col)
|
||||
|
||||
m_major_color=QColor(100,100,100,128);
|
||||
// m_major_color=QColor(180,180,180,128);
|
||||
m_major_color=QColor(100,100,100,64);
|
||||
//m_major_color=QColor(180,180,180,92);
|
||||
m_minor_color=QColor(220,220,220,128);
|
||||
m_show_major_lines=true;
|
||||
m_show_minor_lines=true;
|
||||
@ -156,7 +156,7 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
|
||||
static QString fd="0";
|
||||
GetTextExtent(fd,x,y);
|
||||
|
||||
double max_yticks=round(height / (y+10.0)); // plus spacing between lines
|
||||
double max_yticks=round(height / (y+12.0)); // plus spacing between lines
|
||||
|
||||
double mxy=MAX(fabs(maxy),fabs(miny));
|
||||
double mny=miny;
|
||||
|
177
daily.cpp
177
daily.cpp
@ -984,6 +984,8 @@ void Daily::Load(QDate date)
|
||||
QVariantList end=journal->settings["BookmarkEnd"].toList();
|
||||
QStringList notes=journal->settings["BookmarkNotes"].toStringList();
|
||||
|
||||
ui->bookmarkTable->blockSignals(true);
|
||||
|
||||
bool ok;
|
||||
for (int i=0;i<start.size();i++) {
|
||||
qint64 st=start.at(i).toLongLong(&ok);
|
||||
@ -1000,6 +1002,8 @@ void Daily::Load(QDate date)
|
||||
tw->setData(Qt::UserRole,st);
|
||||
tw->setData(Qt::UserRole+1,et);
|
||||
}
|
||||
ui->bookmarkTable->blockSignals(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1035,100 +1039,19 @@ void Daily::Unload(QDate date)
|
||||
Session *journal=GetJournalSession(date);
|
||||
|
||||
bool nonotes=ui->JournalNotes->toPlainText().isEmpty();
|
||||
bool ok;
|
||||
if (journal) {
|
||||
QString jhtml=ui->JournalNotes->toHtml();
|
||||
if ((!journal->settings.contains(Journal_Notes) && !nonotes) || (journal->settings[Journal_Notes]!=jhtml)) {
|
||||
journal->settings[Journal_Notes]=jhtml;
|
||||
journal->SetChanged(true);
|
||||
}
|
||||
//double w=ui->weightSpinBox->value();
|
||||
if (journal->settings.contains("Weight") && ui->weightSpinBox->value()==0) {
|
||||
journal->settings.erase(journal->settings.find("Weight"));
|
||||
if (journal->settings.contains("BMI")) {
|
||||
journal->settings.erase(journal->settings.find("BMI"));
|
||||
}
|
||||
journal->SetChanged(true);
|
||||
} else if (ui->weightSpinBox->value()>0) {
|
||||
double kg;
|
||||
if (PROFILE["Units"].toString()=="metric") {
|
||||
kg=ui->weightSpinBox->value();
|
||||
} else {
|
||||
kg=(ui->weightSpinBox->value()*(ounce_convert*16.0))+(ui->ouncesSpinBox->value()*ounce_convert);
|
||||
kg/=1000.0;
|
||||
}
|
||||
double height=PROFILE["Height"].toDouble(&ok)/100.0;
|
||||
double bmi=0;
|
||||
if (height>0)
|
||||
bmi=kg/(height*height);
|
||||
journal->settings["Weight"]=kg;
|
||||
journal->settings["BMI"]=bmi;
|
||||
journal->SetChanged(true);
|
||||
}
|
||||
if ((!journal->settings.contains("ZombieMeter") && (ui->ZombieMeter->value()!=5)) || (journal->settings["ZombieMeter"].toDouble(&ok)!=ui->ZombieMeter->value())) {
|
||||
journal->settings["ZombieMeter"]=ui->ZombieMeter->value();
|
||||
journal->SetChanged(true);
|
||||
}
|
||||
if (BookmarksChanged) {
|
||||
QVariantList start;
|
||||
QVariantList end;
|
||||
QStringList notes;
|
||||
QTableWidgetItem *item;
|
||||
for (int row=0;row<ui->bookmarkTable->rowCount();row++) {
|
||||
item=ui->bookmarkTable->item(row,1);
|
||||
start.push_back(item->data(Qt::UserRole));
|
||||
end.push_back(item->data(Qt::UserRole+1));
|
||||
notes.push_back(item->text());
|
||||
}
|
||||
journal->settings["BookmarkStart"]=start;
|
||||
journal->settings["BookmarkEnd"]=end;
|
||||
journal->settings["BookmarkNotes"]=notes;
|
||||
}
|
||||
} else {
|
||||
if (!nonotes || ZombieMeterMoved || (ui->weightSpinBox->value() > 0) || (ui->bookmarkTable->rowCount()>0)) {
|
||||
if (!nonotes) {
|
||||
journal=CreateJournalSession(date);
|
||||
if (!nonotes) {
|
||||
journal->settings[Journal_Notes]=ui->JournalNotes->toHtml();
|
||||
journal->SetChanged(true);
|
||||
}
|
||||
if (ZombieMeterMoved) {
|
||||
journal->settings["ZombieMeter"]=ui->ZombieMeter->value();
|
||||
journal->SetChanged(true);
|
||||
}
|
||||
if (ui->weightSpinBox->value() > 0) {
|
||||
double kg;
|
||||
if (PROFILE["Units"].toString()=="metric") {
|
||||
kg=ui->weightSpinBox->value();
|
||||
} else {
|
||||
kg=(ui->weightSpinBox->value()*(ounce_convert*16))+(ui->ouncesSpinBox->value()*ounce_convert);
|
||||
kg/=1000.0;
|
||||
}
|
||||
double height=PROFILE["Height"].toDouble(&ok)/100.0;
|
||||
double bmi=0;
|
||||
if (height>0)
|
||||
bmi=kg/(height*height);
|
||||
//if (kg>0) {
|
||||
journal->settings["Weight"]=kg;
|
||||
if (bmi>0)
|
||||
journal->settings["BMI"]=bmi;
|
||||
journal->SetChanged(true);
|
||||
//}
|
||||
}
|
||||
if (BookmarksChanged) {
|
||||
QVariantList start;
|
||||
QVariantList end;
|
||||
QStringList notes;
|
||||
QTableWidgetItem *item;
|
||||
for (int row=0;row<ui->bookmarkTable->rowCount();row++) {
|
||||
item=ui->bookmarkTable->item(row,1);
|
||||
start.push_back(item->data(Qt::UserRole));
|
||||
end.push_back(item->data(Qt::UserRole+1));
|
||||
notes.push_back(item->text());
|
||||
}
|
||||
journal->settings["BookmarkStart"]=start;
|
||||
journal->settings["BookmarkEnd"]=end;
|
||||
journal->settings["BookmarkNotes"]=notes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1386,52 +1309,24 @@ void Daily::on_evViewSlider_valueChanged(int value)
|
||||
|
||||
int winsize=PROFILE["EventViewSize"].toInt()*60;
|
||||
|
||||
if (0) {
|
||||
/* if (ui->treeWidget->selectedItems().size()==0) return;
|
||||
QTreeWidgetItem *item=ui->treeWidget->selectedItems().at(0);
|
||||
if (!item) return;
|
||||
QDateTime d;
|
||||
if (!item->text(1).isEmpty()) {
|
||||
d=d.fromString(item->text(1),"yyyy-MM-dd HH:mm:ss");
|
||||
gGraph *g=GraphView->findGraph("Event Flags");
|
||||
if (!g) return;
|
||||
qint64 st=g->min_x;
|
||||
qint64 et=g->max_x;
|
||||
qint64 len=et-st;
|
||||
qint64 d=st+len/2.0;
|
||||
|
||||
|
||||
double st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L;
|
||||
double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L;
|
||||
|
||||
gGraph *g=GraphView->findGraph("Event Flags");
|
||||
if (!g) return;
|
||||
if (st<g->rmin_x) {
|
||||
st=g->rmin_x;
|
||||
et=st+winsize*1000;
|
||||
}
|
||||
if (et>g->rmax_x) {
|
||||
et=g->rmax_x;
|
||||
st=et-winsize*1000;
|
||||
}
|
||||
GraphView->SetXBounds(st,et);
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
gGraph *g=GraphView->findGraph("Event Flags");
|
||||
if (!g) return;
|
||||
|
||||
qint64 st=g->min_x;
|
||||
qint64 et=g->max_x;
|
||||
qint64 len=et-st;
|
||||
qint64 d=st+len/2.0;
|
||||
|
||||
st=d-(winsize/2)*1000;
|
||||
et=d+(winsize/2)*1000;
|
||||
if (st<g->rmin_x) {
|
||||
st=g->rmin_x;
|
||||
et=st+winsize*1000;
|
||||
}
|
||||
if (et>g->rmax_x) {
|
||||
et=g->rmax_x;
|
||||
st=et-winsize*1000;
|
||||
}
|
||||
GraphView->SetXBounds(st,et);
|
||||
st=d-(winsize/2)*1000;
|
||||
et=d+(winsize/2)*1000;
|
||||
if (st<g->rmin_x) {
|
||||
st=g->rmin_x;
|
||||
et=st+winsize*1000;
|
||||
}
|
||||
if (et>g->rmax_x) {
|
||||
et=g->rmax_x;
|
||||
st=et-winsize*1000;
|
||||
}
|
||||
GraphView->SetXBounds(st,et);
|
||||
}
|
||||
|
||||
void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
|
||||
@ -1462,17 +1357,41 @@ void Daily::on_addBookmarkButton_clicked()
|
||||
tw->setData(Qt::UserRole,st);
|
||||
tw->setData(Qt::UserRole+1,et);
|
||||
|
||||
BookmarksChanged=true;
|
||||
update_Bookmarks();
|
||||
|
||||
//ui->bookmarkTable->setItem(row,2,new QTableWidgetItem(QString::number(st)));
|
||||
//ui->bookmarkTable->setItem(row,3,new QTableWidgetItem(QString::number(et)));
|
||||
}
|
||||
void Daily::update_Bookmarks()
|
||||
{
|
||||
QVariantList start;
|
||||
QVariantList end;
|
||||
QStringList notes;
|
||||
QTableWidgetItem *item;
|
||||
for (int row=0;row<ui->bookmarkTable->rowCount();row++) {
|
||||
item=ui->bookmarkTable->item(row,1);
|
||||
start.push_back(item->data(Qt::UserRole));
|
||||
end.push_back(item->data(Qt::UserRole+1));
|
||||
notes.push_back(item->text());
|
||||
}
|
||||
Session *journal=GetJournalSession(previous_date);
|
||||
if (!journal) {
|
||||
journal=CreateJournalSession(previous_date);
|
||||
}
|
||||
|
||||
journal->settings["BookmarkStart"]=start;
|
||||
journal->settings["BookmarkEnd"]=end;
|
||||
journal->settings["BookmarkNotes"]=notes;
|
||||
journal->SetChanged(true);
|
||||
BookmarksChanged=true;
|
||||
}
|
||||
|
||||
void Daily::on_removeBookmarkButton_clicked()
|
||||
{
|
||||
int row=ui->bookmarkTable->currentRow();
|
||||
if (row>=0) {
|
||||
ui->bookmarkTable->removeRow(row);
|
||||
BookmarksChanged=true;
|
||||
update_Bookmarks();
|
||||
}
|
||||
}
|
||||
void Daily::on_ZombieMeter_valueChanged(int action)
|
||||
@ -1501,7 +1420,7 @@ void Daily::on_ZombieMeter_actionTriggered(int action)
|
||||
void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
|
||||
{
|
||||
Q_UNUSED(item);
|
||||
BookmarksChanged=true;
|
||||
update_Bookmarks();
|
||||
}
|
||||
void Daily::on_weightSpinBox_valueChanged(double arg1)
|
||||
{
|
||||
|
4
daily.h
4
daily.h
@ -47,6 +47,7 @@ public:
|
||||
QDate getDate() { return previous_date; }
|
||||
void PrintReport();
|
||||
void UnitsChanged();
|
||||
Session * GetJournalSession(QDate date);
|
||||
|
||||
private slots:
|
||||
|
||||
@ -95,7 +96,8 @@ protected:
|
||||
|
||||
private:
|
||||
Session * CreateJournalSession(QDate date);
|
||||
Session * GetJournalSession(QDate date);
|
||||
void update_Bookmarks();
|
||||
|
||||
void Load(QDate date);
|
||||
void Unload(QDate date);
|
||||
void UpdateCalendarDay(QDate date);
|
||||
|
@ -680,6 +680,7 @@ EventList *packEventList(EventList *ev)
|
||||
void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
{
|
||||
if (!gv) return;
|
||||
Session * journal=NULL;
|
||||
//QDate d=QDate::currentDate();
|
||||
|
||||
int visgraphs=gv->visibleGraphs();
|
||||
@ -688,7 +689,20 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
return;
|
||||
}
|
||||
|
||||
bool print_bookmarks=false;
|
||||
QString username=PROFILE.Get("_{Username}_");
|
||||
QStringList booknotes;
|
||||
if (name=="Daily") {
|
||||
journal=getDaily()->GetJournalSession(getDaily()->getDate());
|
||||
if (journal->settings.contains("BookmarkNotes")) {
|
||||
booknotes=journal->settings["BookmarkNotes"].toStringList();
|
||||
if (booknotes.size()>0) {
|
||||
if (QMessageBox::question(this,"Bookmarks","Would you like to show bookmarked areas in this report?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) {
|
||||
print_bookmarks=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPrinter * zprinter;
|
||||
|
||||
@ -728,8 +742,8 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
QRect res=printer.pageRect();
|
||||
qDebug() << "Printer Resolution is" << res.width() << "x" << res.height();
|
||||
|
||||
const int graphs_per_page=5;
|
||||
const int footer_height=(res.height()/21);
|
||||
const int graphs_per_page=6;
|
||||
const int footer_height=(res.height()/22);
|
||||
|
||||
float pw=res.width();
|
||||
float realheight=res.height()-footer_height;
|
||||
@ -785,11 +799,6 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
int i=0;
|
||||
int top=0;
|
||||
int gcnt=0;
|
||||
if (qprogress) {
|
||||
qprogress->setValue(0);
|
||||
qprogress->setMaximum(gv->size());
|
||||
qprogress->show();
|
||||
}
|
||||
|
||||
//int header_height=200;
|
||||
QString title=name+" Report";
|
||||
@ -876,6 +885,53 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
//top=header_height;
|
||||
|
||||
bool first=true;
|
||||
QStringList labels;
|
||||
QVector<gGraph *> graphs;
|
||||
QVector<qint64> start,end;
|
||||
qint64 st,et;
|
||||
gv->GetXBounds(st,et);
|
||||
for (int i=0;i<gv->size();i++) {
|
||||
bool normal=true;
|
||||
gGraph *g=(*gv)[i];
|
||||
if (g->isEmpty()) continue;
|
||||
if (!g->visible()) continue;
|
||||
if (print_bookmarks && (g->title()=="Flow Rate")) {
|
||||
if (journal) {
|
||||
start.push_back(st);
|
||||
end.push_back(et);
|
||||
graphs.push_back(g);
|
||||
labels.push_back("Current Selection");
|
||||
|
||||
if (journal->settings.contains("BookmarkStart")) {
|
||||
QVariantList st1=journal->settings["BookmarkStart"].toList();
|
||||
QVariantList et1=journal->settings["BookmarkEnd"].toList();
|
||||
QStringList notes=journal->settings["BookmarkNotes"].toStringList();
|
||||
|
||||
for (int i=0;i<notes.size();i++) {
|
||||
labels.push_back(notes.at(i));
|
||||
start.push_back(st1.at(i).toLongLong());
|
||||
end.push_back(et1.at(i).toLongLong());
|
||||
graphs.push_back(g);
|
||||
}
|
||||
if (notes.size()>0) normal=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (normal) {
|
||||
start.push_back(st);
|
||||
end.push_back(et);
|
||||
graphs.push_back(g);
|
||||
labels.push_back("");
|
||||
}
|
||||
}
|
||||
|
||||
if (qprogress) {
|
||||
qprogress->setValue(0);
|
||||
qprogress->setMaximum(graphs.size());
|
||||
qprogress->show();
|
||||
}
|
||||
|
||||
i=0;
|
||||
do {
|
||||
//+" on "+d.toString(Qt::SystemLocaleLongDate)
|
||||
if (first) {
|
||||
@ -890,9 +946,8 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
painter.drawText(pagebnds,pagestr,QTextOption(Qt::AlignRight));
|
||||
first=false;
|
||||
}
|
||||
gGraph *g=(*gv)[i];
|
||||
if (g->isEmpty()) continue;
|
||||
if (!g->visible()) continue;
|
||||
gGraph *g=graphs[i];
|
||||
g->SetXBounds(start[i],end[i]);
|
||||
g->deselect();
|
||||
|
||||
if (top+ph>realheight) { //top+pm.height()>res.height()) {
|
||||
@ -907,6 +962,15 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString label=labels[i];
|
||||
if (!label.isEmpty()) {
|
||||
QRectF pagebnds=painter.boundingRect(QRectF(0,top,res.width(),0),label,QTextOption(Qt::AlignCenter));
|
||||
painter.drawText(pagebnds,label,QTextOption(Qt::AlignCenter));
|
||||
top+=pagebnds.height();
|
||||
qDebug() << label;
|
||||
|
||||
}
|
||||
QPixmap pm=g->renderPixmap(gw,gh);
|
||||
QPixmap pm2=pm.scaledToWidth(pw);
|
||||
painter.drawPixmap(0,top,pm2.width(),pm2.height(),pm2);
|
||||
@ -917,7 +981,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
qprogress->setValue(i);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
} while (++i<gv->size());
|
||||
} while (++i<graphs.size());
|
||||
|
||||
qprogress->hide();
|
||||
painter.end();
|
||||
|
Loading…
Reference in New Issue
Block a user