Profile==NULL assert fix

This commit is contained in:
Mark Watkins 2011-06-27 20:23:24 +10:00
parent 1368afa7c5
commit 4000d73edc
9 changed files with 201 additions and 218 deletions

View File

@ -72,7 +72,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
//TextMarkup... //TextMarkup...
GetTextExtent(msg,x,y,bigfont); GetTextExtent(msg,x,y,bigfont);
//w.renderText(start_px+(width/2.0)-(x/2.0),start_py+(height/2.0)-(y/2.0),msg,*bigfont); //w.renderText(start_px+(width/2.0)-(x/2.0),start_py+(height/2.0)-(y/2.0),msg,*bigfont);
DrawText(w,msg,start_px+(width/2.0)-(x/2.0),scry-w.GetBottomMargin()-height/2.0+y/2.0,0,QColor("dark grey"),bigfont);//-(y/2.0) DrawText(w,msg,start_px+(width/2.0)-(x/2.0),scry-w.GetBottomMargin()-height/2.0+y/2.0,0,Qt::gray,bigfont);//-(y/2.0)
} }
return; return;
} }

View File

@ -44,7 +44,7 @@ void GetTextExtent(QString text, float & width, float & height, QFont *font)
width=fm.width(text); //fm.width(text); width=fm.width(text); //fm.width(text);
height=fm.xHeight()+2; //fm.ascent(); height=fm.xHeight()+2; //fm.ascent();
} }
void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, QColor color,QFont *font) void DrawText(gGraphWindow & wid, QString text, int x, int y, float angle, QColor color,QFont *font)
{ {
//QFontMetrics fm(*font); //QFontMetrics fm(*font);
float w,h; float w,h;
@ -56,22 +56,26 @@ void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, Q
abort(); abort();
return; return;
} }
glColor4ub(color.red(),color.green(),color.blue(),color.alpha());
if (angle==0) { // glEnable(GL_TEXTURE_2D);
wid.renderText(x,y,text,*font); glDisable(GL_DEPTH_TEST);
// DrawText2(text,x,y,font); glFlush();
return;
}
QPainter painter(&wid); QPainter painter(&wid);
//painter.setFont(*font);
painter.setPen(Qt::black);
painter.setOpacity(1);
// painter.setCompositionMode(QPainter::CompositionMode_);
if (angle==0) {
painter.drawText(x,y,text);
} else {
GetTextExtent(text, w, h, font);
painter.translate(floor(x),floor(y));
painter.rotate(-90);
painter.drawText(floor(-w/2.0),floor(-h/2.0),text);
painter.translate(floor(-x),floor(-y));
GetTextExtent(text, w, h, font); }
painter.translate(floor(x),floor(y));
painter.rotate(-90);
painter.setFont(*font);
painter.setPen(QPen(color));
painter.drawText(floor(-w/2.0),floor(-h/2.0),text);
painter.translate(floor(-x),floor(-y));
painter.end(); painter.end();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);

View File

@ -22,7 +22,7 @@ extern QFont * bigfont;
class gGraphWindow; class gGraphWindow;
void GetTextExtent(QString text, float & width, float & height, QFont *font=defaultfont); void GetTextExtent(QString text, float & width, float & height, QFont *font=defaultfont);
void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle=0, QColor color=QColor("black"),QFont *font=defaultfont); void DrawText(gGraphWindow & wid, QString text, int x, int y, float angle=0, QColor color=QColor("black"),QFont *font=defaultfont);
void LinedRoundedRectangle(int x,int y,int w,int h,int radius,int lw,QColor color); void LinedRoundedRectangle(int x,int y,int w,int h,int radius,int lw,QColor color);
void RoundedRectangle(int x,int y,int w,int h,int radius,const QColor color); void RoundedRectangle(int x,int y,int w,int h,int radius,const QColor color);

View File

@ -255,7 +255,7 @@ Machine * Profile::GetMachine(MachineType t)
} }
Profile *profile=NULL; //Profile *profile=NULL;
QString SHA1(QString pass) QString SHA1(QString pass)
{ {
return pass; return pass;

View File

@ -100,15 +100,27 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
PRD->AddLayer(new gLineChart(pressure_eap,QColor("red"),4096,false,true,true)); PRD->AddLayer(new gLineChart(pressure_eap,QColor("red"),4096,false,true,true));
PRD->setMinimumHeight(150); PRD->setMinimumHeight(150);
AddCPAPData(leakdata=new EventData(CPAP_Leak,0));
//leakdata->ForceMinY(0);
//leakdata->ForceMaxY(120);
AddGraph(LEAK=new gGraphWindow(gSplitter,"Leaks",SF));
LEAK->AddLayer(new gXAxis());
LEAK->AddLayer(new gYAxis());
LEAK->AddLayer(new gFooBar());
LEAK->AddLayer(new gLineChart(leakdata,QColor("purple"),4096,false,false,false));
LEAK->setMinimumHeight(150);
AddGraph(FRW=new gGraphWindow(gSplitter,"Flow Rate",SF)); AddGraph(FRW=new gGraphWindow(gSplitter,"Flow Rate",SF));
FRW->AddLayer(new gXAxis());
FRW->AddLayer(new gYAxis());
FRW->AddLayer(new gFooBar()); FRW->AddLayer(new gFooBar());
FRW->AddLayer(new gYAxis());
FRW->AddLayer(new gXAxis());
FRW->AddLayer(new gLineOverlayBar(flags[0],QColor("light green"),"CSR")); FRW->AddLayer(new gLineOverlayBar(flags[0],QColor("light green"),"CSR"));
gLineChart *g=new gLineChart(frw,QColor("black"),200000,true); gLineChart *g=new gLineChart(frw,QColor("black"),200000,true);
g->ReportEmpty(true); g->ReportEmpty(true);
FRW->AddLayer(g); FRW->AddLayer(g);
FRW->AddLayer(new gLineOverlayBar(flags[3],QColor("blue"),"H")); FRW->AddLayer(new gLineOverlayBar(flags[3],QColor("blue"),"H"));
FRW->AddLayer(new gLineOverlayBar(flags[7],QColor("red"),"PR",LOT_Dot)); FRW->AddLayer(new gLineOverlayBar(flags[7],QColor("red"),"PR",LOT_Dot));
@ -121,17 +133,6 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
FRW->setMinimumHeight(190); FRW->setMinimumHeight(190);
AddCPAPData(leakdata=new EventData(CPAP_Leak,0));
//leakdata->ForceMinY(0);
//leakdata->ForceMaxY(120);
AddGraph(LEAK=new gGraphWindow(gSplitter,"Leaks",SF));
LEAK->AddLayer(new gXAxis());
LEAK->AddLayer(new gYAxis());
LEAK->AddLayer(new gFooBar());
LEAK->AddLayer(new gLineChart(leakdata,QColor("purple"),4096,false,false,false));
LEAK->setMinimumHeight(150);
AddCPAPData(snore=new EventData(CPAP_SnoreGraph,0)); AddCPAPData(snore=new EventData(CPAP_SnoreGraph,0));
//snore->ForceMinY(0); //snore->ForceMinY(0);
//snore->ForceMaxY(15); //snore->ForceMaxY(15);

View File

@ -79,7 +79,7 @@ void MainWindow::Startup()
qstatus->setText("Loading Data"); qstatus->setText("Loading Data");
qprogress->show(); qprogress->show();
Profile *profile=Profiles::Get(pref["Profile"].toString()); profile=Profiles::Get(pref["Profile"].toString());
profile->LoadMachineData(); profile->LoadMachineData();
daily=new Daily(ui->tabWidget,shared_context); daily=new Daily(ui->tabWidget,shared_context);

View File

@ -68,6 +68,7 @@ private:
Overview * overview; Overview * overview;
QGLContext *shared_context; QGLContext *shared_context;
bool first_load; bool first_load;
Profile *profile;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -255,13 +255,13 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>115</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>115</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -338,188 +338,166 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<widget class="QToolButton" name="overviewButton"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="geometry"> <item>
<rect> <widget class="QToolButton" name="importButton">
<x>2</x> <property name="sizePolicy">
<y>194</y> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<width>92</width> <horstretch>0</horstretch>
<height>90</height> <verstretch>0</verstretch>
</rect> </sizepolicy>
</property> </property>
<property name="sizePolicy"> <property name="minimumSize">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <size>
<horstretch>0</horstretch> <width>0</width>
<verstretch>0</verstretch> <height>0</height>
</sizepolicy> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>90</height> <height>90</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Overview</string> <string>Import</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="Resources.qrc"> <iconset resource="Resources.qrc">
<normaloff>:/icons/overview.png</normaloff>:/icons/overview.png</iconset> <normaloff>:/icons/sdcard.png</normaloff>:/icons/sdcard.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>64</width> <width>64</width>
<height>64</height> <height>64</height>
</size> </size>
</property> </property>
<property name="toolButtonStyle"> <property name="checkable">
<enum>Qt::ToolButtonTextUnderIcon</enum> <bool>false</bool>
</property> </property>
<property name="autoRaise"> <property name="toolButtonStyle">
<bool>true</bool> <enum>Qt::ToolButtonTextUnderIcon</enum>
</property> </property>
</widget> <property name="autoRaise">
<widget class="QToolButton" name="dailyButton"> <bool>true</bool>
<property name="geometry"> </property>
<rect> <property name="arrowType">
<x>2</x> <enum>Qt::NoArrow</enum>
<y>98</y> </property>
<width>92</width> </widget>
<height>90</height> </item>
</rect> <item>
</property> <widget class="QToolButton" name="dailyButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>90</height> <height>90</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Daily</string> <string>Daily</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="Resources.qrc"> <iconset resource="Resources.qrc">
<normaloff>:/icons/edit-find.png</normaloff>:/icons/edit-find.png</iconset> <normaloff>:/icons/edit-find.png</normaloff>:/icons/edit-find.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>64</width> <width>64</width>
<height>64</height> <height>64</height>
</size> </size>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum> <enum>Qt::ToolButtonTextUnderIcon</enum>
</property> </property>
<property name="autoRaise"> <property name="autoRaise">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QToolButton" name="preferencesButton"> </item>
<property name="geometry"> <item>
<rect> <widget class="QToolButton" name="overviewButton">
<x>2</x> <property name="sizePolicy">
<y>290</y> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<width>92</width> <horstretch>0</horstretch>
<height>90</height> <verstretch>0</verstretch>
</rect> </sizepolicy>
</property> </property>
<property name="sizePolicy"> <property name="maximumSize">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <size>
<horstretch>0</horstretch> <width>16777215</width>
<verstretch>0</verstretch> <height>90</height>
</sizepolicy> </size>
</property> </property>
<property name="maximumSize"> <property name="text">
<size> <string>Overview</string>
<width>16777215</width> </property>
<height>90</height> <property name="icon">
</size> <iconset resource="Resources.qrc">
</property> <normaloff>:/icons/overview.png</normaloff>:/icons/overview.png</iconset>
<property name="text"> </property>
<string>Preferences</string> <property name="iconSize">
</property> <size>
<property name="icon"> <width>64</width>
<iconset resource="Resources.qrc"> <height>64</height>
<normaloff>:/icons/preferences.png</normaloff>:/icons/preferences.png</iconset> </size>
</property> </property>
<property name="iconSize"> <property name="toolButtonStyle">
<size> <enum>Qt::ToolButtonTextUnderIcon</enum>
<width>64</width> </property>
<height>64</height> <property name="autoRaise">
</size> <bool>true</bool>
</property> </property>
<property name="toolButtonStyle"> </widget>
<enum>Qt::ToolButtonTextUnderIcon</enum> </item>
</property> <item>
<property name="autoRaise"> <widget class="QToolButton" name="preferencesButton">
<bool>true</bool> <property name="sizePolicy">
</property> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
</widget> <horstretch>0</horstretch>
<widget class="QToolButton" name="importButton"> <verstretch>0</verstretch>
<property name="geometry"> </sizepolicy>
<rect> </property>
<x>2</x> <property name="maximumSize">
<y>2</y> <size>
<width>92</width> <width>16777215</width>
<height>90</height> <height>90</height>
</rect> </size>
</property> </property>
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <string>Preferences</string>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="icon">
</sizepolicy> <iconset resource="Resources.qrc">
</property> <normaloff>:/icons/preferences.png</normaloff>:/icons/preferences.png</iconset>
<property name="minimumSize"> </property>
<size> <property name="iconSize">
<width>0</width> <size>
<height>0</height> <width>64</width>
</size> <height>64</height>
</property> </size>
<property name="maximumSize"> </property>
<size> <property name="toolButtonStyle">
<width>16777215</width> <enum>Qt::ToolButtonTextUnderIcon</enum>
<height>90</height> </property>
</size> <property name="autoRaise">
</property> <bool>true</bool>
<property name="text"> </property>
<string>Import Data</string> </widget>
</property> </item>
<property name="icon"> </layout>
<iconset resource="Resources.qrc">
<normaloff>:/icons/sdcard.png</normaloff>:/icons/sdcard.png</iconset>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -535,7 +513,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1089</width> <width>1089</width>
<height>25</height> <height>29</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -181,8 +181,7 @@ void UpdateCal(QCalendarWidget *cal)
QDate d1=cal->minimumDate(); QDate d1=cal->minimumDate();
d1.setYMD(d1.year(),d1.month(),1); d1.setYMD(d1.year(),d1.month(),1);
QTextCharFormat fmt=cal->weekdayTextFormat(Qt::Monday); QTextCharFormat fmt=cal->weekdayTextFormat(Qt::Monday);
QBrush b(QColor("light grey")); fmt.setForeground(QBrush(Qt::gray));
fmt.setForeground(b);
for (QDate d=d1;d < cal->minimumDate();d=d.addDays(1)) { for (QDate d=d1;d < cal->minimumDate();d=d.addDays(1)) {
cal->setDateTextFormat(d,fmt); cal->setDateTextFormat(d,fmt);
} }