MNE-CPP  beta 0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
progressbarwidget.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "progressbarwidget.h"
43 
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // QT INCLUDES
48 //=============================================================================================================
49 
50 #include <QPaintEvent>
51 #include <QPainter>
52 #include <QTimer>
53 
54 
55 //*************************************************************************************************************
56 //=============================================================================================================
57 // USED NAMESPACES
58 //=============================================================================================================
59 
60 using namespace XDISPLIB;
61 using namespace XMEASLIB;
62 
63 
64 //*************************************************************************************************************
65 //=============================================================================================================
66 // DEFINE MEMBER METHODS
67 //=============================================================================================================
68 
69 ProgressBarWidget::ProgressBarWidget(QSharedPointer<ProgressBar> pProgressBar, QWidget *parent)
70 : MeasurementWidget(parent)
71 , m_pProgressBar(pProgressBar)
72 , m_dSegmentSize(0.0)
73 
74 {
75  ui.setupUi(this);
76  m_usXPos = ui.m_qFrame->geometry().x();
77 
78  QTimer* timer = new QTimer(this);
79  connect(timer, SIGNAL(timeout()), this, SLOT(update()));
80  timer->start(1000);
81 
82  m_Brush.setStyle(Qt::SolidPattern);
83  m_Font.setBold(true);
84  m_Font.setPointSizeF(28);
85 }
86 
87 
88 //*************************************************************************************************************
89 
91 {
92 
93 }
94 
95 
96 //*************************************************************************************************************
97 
99 {
100  m_usXPos = (unsigned short)(ui.m_qFrame->geometry().x()+m_dSegmentSize*m_pProgressBar->getValue());
101  m_Text = QString::number(m_pProgressBar->getValue()/10.0f);
102 
103  if((m_pProgressBar->getValue() >= 0) && (m_pProgressBar->getValue() <= 40))
104  m_Brush.setColor(Qt::green);
105 
106  else if((m_pProgressBar->getValue() > 40) && (m_pProgressBar->getValue() <= 80))
107  m_Brush.setColor(Qt::yellow);
108 
109  else
110  m_Brush.setColor(Qt::red);
111 }
112 
113 
114 //*************************************************************************************************************
115 
117 {
118  ui.m_qLabel_Caption->setText(m_pProgressBar->getName());
119  m_dSegmentSize = static_cast<double>(ui.m_qFrame->width())/(m_pProgressBar->getMaxScale()-m_pProgressBar->getMinScale());
120 }
121 
122 
123 //*************************************************************************************************************
124 
126 {
127  QPainter painter(this);
128  painter.fillRect(ui.m_qFrame->geometry().x(), ui.m_qFrame->geometry().y(), m_usXPos, ui.m_qFrame->geometry().height(), m_Brush);
129  painter.setFont(m_Font);
130  painter.drawText(ui.m_qFrame->geometry(), Qt::AlignCenter, m_Text);
131 }
ProgressBarWidget(QSharedPointer< ProgressBar > pProgressBar, QWidget *parent=0)
The MeasurementWidget class is the base class of all measurement widgets.
virtual void paintEvent(QPaintEvent *event)
Contains the declaration of the ProgressBar class.
The Subject class provides the base class of every subject of the observer design pattern...
virtual void update(Subject *pSubject)
Contains the declaration of the ProgressBarWidget class.