Premier commit suite au crash du repo le 10 juillet 2017
This commit is contained in:
@@ -0,0 +1,412 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe d'affichage d'un graphique analogique (vitesse du train, sondes lazer,
|
||||
etc.) La fonction SetData permet d'associer la liste de points à tracer. La
|
||||
fonction DisplayData() permet de fixer le timespan à afficher. La fonction détermine
|
||||
quels points sont dans le span et crée une liste de lignes qui sont ensuite affichés
|
||||
dans la fonction de rappel paint().
|
||||
|
||||
Utilisée dans la page de visualisation des passages de train.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "AnalogGraphItem.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <limits>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CAnalogGraphItem::CAnalogGraphItem(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mDataSet = 0;
|
||||
mStartTime = mStopTime = 0;
|
||||
mDataValid = false;
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
|
||||
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
mHorizLine = 0;
|
||||
mYOffset = 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
CAnalogGraphItem::~CAnalogGraphItem()
|
||||
{
|
||||
delete mGraphPixmap;
|
||||
|
||||
if(mHorizLine != 0)
|
||||
delete mHorizLine;
|
||||
}
|
||||
|
||||
void CAnalogGraphItem::SetData(QList<CGraphAnalogDataPair*> *DataList)
|
||||
{
|
||||
mDataSet = DataList;
|
||||
//Build the lines list
|
||||
}
|
||||
|
||||
unsigned int CAnalogGraphItem::DisplayData(quint64 StartTime, quint64 StopTime)
|
||||
{
|
||||
|
||||
mPainterPath = QPainterPath();
|
||||
|
||||
if(mDataSet == 0)
|
||||
return RET_OK;
|
||||
|
||||
if(mDataSet->isEmpty())
|
||||
return RET_ERROR;
|
||||
|
||||
quint64 MinTime = mDataSet->first()->mTime;
|
||||
quint64 MaxTime = mDataSet->last()->mTime;
|
||||
|
||||
if(StartTime >= StopTime)
|
||||
return RET_ERROR;
|
||||
if(StartTime < MinTime)
|
||||
return RET_ERROR;
|
||||
if(StopTime > MaxTime)
|
||||
return RET_ERROR;
|
||||
|
||||
|
||||
|
||||
quint64 TimeSpan = StopTime - StartTime;
|
||||
|
||||
|
||||
|
||||
mStartTime = StartTime;
|
||||
mStopTime = StopTime;
|
||||
|
||||
|
||||
//Find the index of the first and last point included in the timespan.
|
||||
int StartIndex = 0, StopIndex = 0;
|
||||
int i = 0;
|
||||
bool StartFound = false, StopFound = false;
|
||||
|
||||
quint64 StartDrawTime = StartTime ,EndDrawTime = StopTime;
|
||||
|
||||
if(StartTime < mAbsoluteStartTime)
|
||||
StartDrawTime = mAbsoluteStartTime;
|
||||
|
||||
|
||||
if(StopTime > mAbsoluteEndTime)
|
||||
EndDrawTime = mAbsoluteEndTime;
|
||||
|
||||
|
||||
while(StartFound == false || StopFound == false)
|
||||
{
|
||||
if(i >= mDataSet->size())
|
||||
{
|
||||
qDebug("GraphItem::Array overflow while searching for time index");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
quint64 CurTime = mDataSet->at(i)->mTime;
|
||||
if(CurTime <= StartDrawTime)
|
||||
{
|
||||
StartIndex = i;
|
||||
StartFound = true;
|
||||
}
|
||||
if(CurTime >= EndDrawTime && !StopFound)
|
||||
{
|
||||
StopIndex = i;
|
||||
StopFound = true;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
//Find the Y scaling (vertical)
|
||||
qreal MaxValue = std::numeric_limits<float>::min();
|
||||
qreal MinValue = std::numeric_limits<float>::max();
|
||||
|
||||
for(int i = 0; i < mDataSet->size(); i++)
|
||||
{
|
||||
qreal CurValue = mDataSet->at(i)->mValue;
|
||||
|
||||
if(CurValue != -1 && CurValue != 0) //-1 is the value for "NO DATA" and 0 is not a valid value
|
||||
{
|
||||
if(MaxValue < CurValue)
|
||||
MaxValue = CurValue;
|
||||
if(MinValue > CurValue)
|
||||
MinValue = CurValue;
|
||||
}
|
||||
}
|
||||
|
||||
if(MinValue < 0)
|
||||
{
|
||||
MinValue *= -1;
|
||||
MinValue += 1;
|
||||
mYOffset = MinValue;
|
||||
|
||||
for(int i = 0; i < mDataSet->size(); i++)
|
||||
{
|
||||
mDataSet->at(i)->mValue += MinValue;
|
||||
}
|
||||
MaxValue += MinValue;
|
||||
MinValue = 1;
|
||||
}
|
||||
|
||||
//Build the lines list
|
||||
mLinesList.clear();
|
||||
qreal Width = boundingRect().width();
|
||||
qreal Height = boundingRect().height();
|
||||
qreal tick = (Width)/TimeSpan; //pixels per microsec
|
||||
qreal YFactor = (Height-2)/(MaxValue - MinValue);
|
||||
mYScaling = YFactor;
|
||||
mXScaling = tick;
|
||||
|
||||
|
||||
qreal X1,X2,Y1,Y2;
|
||||
|
||||
//There is no quadratic interpolation, simply draw a straight
|
||||
//line between the points. When needed, execute a linear
|
||||
//interpolation when one of the two points creating a line is
|
||||
//outside the timespan (at both extremities of the view).
|
||||
|
||||
// P2 P3
|
||||
// P1 | *-------* |
|
||||
// * | | P4
|
||||
// | | *
|
||||
// |<----timespan---->|
|
||||
// Start End
|
||||
//
|
||||
//Interpolation needed between Start->P2 and P3->End so there is no
|
||||
//"gap" in the graph between the first/last points and the view.
|
||||
|
||||
|
||||
for(int i = StartIndex; i < StopIndex; i++)
|
||||
{
|
||||
if(mDataSet->at(i)->mValue != -1) //-1 is the value for "NO DATA".
|
||||
{
|
||||
QLine NewLine;
|
||||
|
||||
//Check if interpolation is needed at the left
|
||||
//of the span
|
||||
if(mDataSet->at(i)->mTime < StartTime)
|
||||
{
|
||||
//Interpolate Y value at StartTime
|
||||
qreal x1 = mDataSet->at(i)->mTime;
|
||||
qreal y1 = mDataSet->at(i)->mValue - MinValue;
|
||||
qreal x2 = mDataSet->at(i+1)->mTime;
|
||||
qreal y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||
|
||||
// Y = mX + B
|
||||
qreal DeltaX = x2 - x1;
|
||||
qreal DeltaY = y2 - y1;
|
||||
|
||||
qreal m = DeltaY/DeltaX;
|
||||
|
||||
Y1 = (qreal)StartTime*m;
|
||||
|
||||
Y1 += (y2 - m*x2);
|
||||
|
||||
X1 = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
X1 = mDataSet->at(i)->mTime - StartTime;
|
||||
Y1 = mDataSet->at(i)->mValue - MinValue;
|
||||
}
|
||||
|
||||
//Check if interpolation is needed at the right
|
||||
//of the span
|
||||
if(mDataSet->at(i+1)->mTime > StopTime)
|
||||
{
|
||||
//Interpolate Y value at StopTime
|
||||
qreal x1 = mDataSet->at(i)->mTime;
|
||||
qreal y1 = mDataSet->at(i)->mValue - MinValue;
|
||||
qreal x2 = mDataSet->at(i+1)->mTime;
|
||||
qreal y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||
|
||||
qreal DeltaX = x2 - x1;
|
||||
qreal DeltaY = y2 - y1;
|
||||
|
||||
qreal m = DeltaY/DeltaX;
|
||||
|
||||
Y2 = (qreal)(StopTime)*m;
|
||||
|
||||
Y2 += (y2 - m*x2);
|
||||
|
||||
X2 = StopTime - StartTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
X2 = mDataSet->at(i+1)->mTime - StartTime;
|
||||
Y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||
}
|
||||
|
||||
Y1 = Height - Y1*YFactor;
|
||||
Y2 = Height - Y2*YFactor;
|
||||
|
||||
NewLine.setLine(X1*tick,Y1-1,X2*tick,Y2-1);
|
||||
mLinesList.append(NewLine);
|
||||
|
||||
// if(mPainterPath.isEmpty())
|
||||
// mPainterPath.moveTo(X1*tick,Y1-1);
|
||||
|
||||
// mPainterPath.lineTo(X2*tick,Y2-1);
|
||||
}
|
||||
}
|
||||
|
||||
if(mHorizLine != 0)
|
||||
{
|
||||
Y1 = (mHorizLineYPos+mYOffset-MinValue);
|
||||
Y1 = Height - Y1*YFactor;
|
||||
mHorizLine->setP1(QPoint(0,Y1-1));
|
||||
mHorizLine->setP2(QPoint((mDataSet->at(StopIndex)->mTime - StartTime)*tick,Y1-1));
|
||||
}
|
||||
|
||||
mDataValid = true;
|
||||
|
||||
//#ifndef WINDOWS_OS
|
||||
mGraphPixmap->fill(QColor(245, 245, 255));
|
||||
QPainter *painter = new QPainter(mGraphPixmap);
|
||||
painter->drawLines(mLinesList);
|
||||
delete painter;
|
||||
//#endif
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
qreal CAnalogGraphItem::GetValueForTime(quint64 time)
|
||||
{
|
||||
qreal value = 0.0;
|
||||
for(int i = 0; i < mDataSet->size()-1; i++)
|
||||
{
|
||||
if(time >= mDataSet->at(i)->mTime && time < mDataSet->at(i+1)->mTime)
|
||||
{
|
||||
value = mDataSet->at(i)->mValue - mYOffset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString label = mLabelTitle;
|
||||
label += "\n";
|
||||
label += QString().sprintf("%.2f",value);
|
||||
|
||||
mLabel->setPlainText(label);
|
||||
mLabel->setPos(mLabel->pos().x(),boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||
update();
|
||||
return value;
|
||||
}
|
||||
|
||||
void CAnalogGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
if(mDataValid == false)
|
||||
return ;
|
||||
if(mDataSet == 0)
|
||||
return;
|
||||
if(mDataSet->size() == 0)
|
||||
return;
|
||||
|
||||
// painter->setClipRect(option->exposedRect);
|
||||
|
||||
|
||||
// QPen pen;
|
||||
// pen.setWidth(1);
|
||||
|
||||
//// pen.setColor(Qt::red);
|
||||
//// painter->setPen(pen);
|
||||
//// painter->drawRect(boundingRect());
|
||||
|
||||
// pen.setColor(Qt::black);
|
||||
// painter->setPen(pen);
|
||||
|
||||
//#ifdef WINDOWS_OS
|
||||
// painter->drawLines(mLinesList);
|
||||
//#else
|
||||
|
||||
|
||||
painter->drawPixmap(0,0,*mGraphPixmap);
|
||||
if(mHorizLine != 0)
|
||||
{
|
||||
painter->setPen(QPen(Qt::red));
|
||||
painter->drawLine(*mHorizLine);
|
||||
}
|
||||
|
||||
//painter->drawPath(mPainterPath);
|
||||
|
||||
|
||||
//#endif
|
||||
// for(int i = 0; i < mLinesList.size(); i++)
|
||||
// {
|
||||
// painter->drawEllipse(mLinesList.at(i).p1(),2,2);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
//void CGraphItem::UpdateDisplay()
|
||||
//{
|
||||
// DisplayData(mStartIndex,mStopIndex);
|
||||
// update();
|
||||
//}
|
||||
|
||||
void CAnalogGraphItem::AddHorizontalLine(qreal YPosition)
|
||||
{
|
||||
if(mHorizLine == 0)
|
||||
mHorizLine = new QLine();
|
||||
|
||||
mHorizLineYPos = YPosition;
|
||||
}
|
||||
|
||||
void CAnalogGraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
||||
void CAnalogGraphItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void CAnalogGraphItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
//mBackgroundRect->setRect(boundingRect());
|
||||
delete mGraphPixmap;
|
||||
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
DisplayData(mStartTime,mStopTime);
|
||||
}
|
||||
void CAnalogGraphItem::SetLabel(QString label,int Offset)
|
||||
{
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
mLabelTitle = label;
|
||||
mLabel->setFont(font);
|
||||
mLabel->setPlainText(label);
|
||||
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||
}
|
||||
|
||||
CGraphAnalogDataPair::CGraphAnalogDataPair(qreal Value, quint64 Time):
|
||||
mValue(Value),
|
||||
mTime(Time)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef ANALOGGRAPHITEM_H
|
||||
#define ANALOGGRAPHITEM_H
|
||||
|
||||
#include <GlobalDefine.h>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
|
||||
class CGraphAnalogDataPair
|
||||
{
|
||||
public:
|
||||
CGraphAnalogDataPair(qreal Value, quint64 Time);
|
||||
qreal mValue; //changed from qint32
|
||||
quint64 mTime;
|
||||
};
|
||||
|
||||
class CAnalogGraphItem : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAnalogGraphItem(QGraphicsItem *Parent = 0);
|
||||
~CAnalogGraphItem();
|
||||
|
||||
QList<CGraphAnalogDataPair*> *mDataSet;
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
|
||||
unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
|
||||
void SetData(QList<CGraphAnalogDataPair*> *DataList);
|
||||
void SetLabel(QString label,int Offset);
|
||||
void SetAbsoluteLimits(quint64 StartTime,quint64 EndTime){mAbsoluteStartTime = StartTime; mAbsoluteEndTime = EndTime;}
|
||||
void AddHorizontalLine(qreal YPosition);
|
||||
qreal GetValueForTime(quint64 time);
|
||||
|
||||
virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
bool mDataValid;
|
||||
quint64 mStartTime, mStopTime, mAbsoluteEndTime,mAbsoluteStartTime;
|
||||
QVector<QLine> mLinesList;
|
||||
QString mLabelTitle;
|
||||
QGraphicsTextItem *mLabel;
|
||||
QPixmap *mGraphPixmap;
|
||||
qreal mYScaling,mXScaling;
|
||||
qreal mYOffset;
|
||||
qreal mHorizLineYPos;
|
||||
QLine *mHorizLine;
|
||||
|
||||
QPainterPath mPainterPath;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // ANALOGGRAPHITEM_H
|
||||
@@ -0,0 +1,144 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche un CDV. L'affichage change en fonction de l'état
|
||||
du CDV (libre, occupé, itinéraire commandé).
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130524 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "CDVItem.h"
|
||||
#include <QPainter>
|
||||
#include "ZTData.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include "CDV.h"
|
||||
|
||||
|
||||
|
||||
CCDVItem::CCDVItem(CCDV *CDVPtr,QGraphicsItem *Parent)
|
||||
{
|
||||
if(Parent != 0)
|
||||
setParentItem(Parent);
|
||||
|
||||
mCDVPtr = CDVPtr;
|
||||
mCDVFreeBrush = new QBrush(Qt::gray);
|
||||
mCDVITICommandedBrush = new QBrush(Qt::darkGreen);
|
||||
mCDVOccupiedBrush = new QBrush(QColor(255,128,0));
|
||||
|
||||
mCDVState = CDV_STATE_FREE;
|
||||
mCurBrush = mCDVFreeBrush;
|
||||
|
||||
setGeometry(0,0,90,20);
|
||||
}
|
||||
|
||||
CCDVItem::~CCDVItem()
|
||||
{
|
||||
delete mCDVFreeBrush;
|
||||
delete mCDVITICommandedBrush;
|
||||
delete mCDVOccupiedBrush;
|
||||
}
|
||||
|
||||
void CCDVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
QRectF CDVRect = rect();
|
||||
|
||||
painter->setBrush(*mCurBrush);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawRect(CDVRect);
|
||||
|
||||
// QRectF textRect(CDVRect.adjusted(-3,-3,-3,-3));
|
||||
// painter->drawRect(textRect);
|
||||
|
||||
int flags = Qt::AlignHCenter | Qt::AlignVCenter/* | Qt::TextWordWrap*/;
|
||||
|
||||
QFont font;
|
||||
// font.setPointSizeF(9.5);
|
||||
font.setPixelSize(13);
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(CDVRect, flags, mCDVLabel);
|
||||
|
||||
}
|
||||
|
||||
unsigned int CCDVItem::SetParameters(QString Label/*, unsigned int posx, unsigned int posy*/)
|
||||
{
|
||||
mCDVLabel = Label;
|
||||
// setPos(posx,posy);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CCDVItem::UpdateState()
|
||||
{
|
||||
return SetState(mCDVPtr->GetCDVState());
|
||||
}
|
||||
|
||||
unsigned int CCDVItem::SetState(unsigned int State)
|
||||
{
|
||||
if(State >= CDV_STATE_UNKNOWN)
|
||||
return RET_ERROR;
|
||||
if(mCDVState == State)
|
||||
return RET_OK;
|
||||
|
||||
mCDVState = State;
|
||||
switch(State)
|
||||
{
|
||||
case CDV_STATE_OCCUPIED:
|
||||
{
|
||||
mCurBrush = mCDVOccupiedBrush;
|
||||
break;
|
||||
}
|
||||
case CDV_STATE_FREE:
|
||||
{
|
||||
mCurBrush = mCDVFreeBrush;
|
||||
break;
|
||||
}
|
||||
case CDV_STATE_ITI_CMD:
|
||||
{
|
||||
mCurBrush = mCDVITICommandedBrush;
|
||||
break;
|
||||
}
|
||||
}
|
||||
update(rect());
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CCDVItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit CDVRightClicked(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDVItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
CCDV *CCDVItem::GetCDV()
|
||||
{
|
||||
return mCDVPtr;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QString>
|
||||
|
||||
|
||||
|
||||
#ifndef CDVITEM_H
|
||||
#define CDVITEM_H
|
||||
|
||||
class CCDV;
|
||||
|
||||
class CCDVItem : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CCDVItem(CCDV *CDVPtr,QGraphicsItem *Parent = 0);
|
||||
~CCDVItem();
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
unsigned int SetParameters(QString Label/*, unsigned int posx, unsigned int posy*/);
|
||||
virtual unsigned int SetState(unsigned int State);
|
||||
unsigned int UpdateState();
|
||||
|
||||
CCDV *GetCDV();
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
QString mCDVLabel;
|
||||
unsigned int mCDVState;
|
||||
QBrush *mCDVFreeBrush, *mCDVITICommandedBrush, *mCDVOccupiedBrush,*mCurBrush;
|
||||
|
||||
CCDV *mCDVPtr; //Pointer to the CDV object
|
||||
|
||||
signals:
|
||||
void CDVRightClicked(CCDVItem*);
|
||||
};
|
||||
|
||||
#endif // CDVITEM_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,164 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef ENGINEERINGPAGE_H
|
||||
#define ENGINEERINGPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "TextButtonWidget.h"
|
||||
#include "InputModule.h"
|
||||
|
||||
#include "PCIIOMgr.h"
|
||||
#include "PasswordPrompt.h"
|
||||
#include "ZTData.h"
|
||||
#include <QCheckBox>
|
||||
#include <QFileInfoList>
|
||||
#include "USBDriveInterface.h"
|
||||
#include "ToggleButtonWidget.h"
|
||||
#include <QSpinBox>
|
||||
#include "MixedModule.h"
|
||||
#include "OutputModule.h"
|
||||
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
class CEngineeringPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~CEngineeringPage();
|
||||
CEngineeringPage(QGraphicsWidget *Parent = 0);
|
||||
CPushButton *mToolsPushButton;
|
||||
CPasswordPrompt *mPasswordPrompt;
|
||||
bool mDisablePassword;
|
||||
|
||||
|
||||
void BindPointers(CZoneTest *ProgramHandle,CInputModule *InputModulePtr, COutputModule *OutputModulePtr, CPCIIOMgr *PCIIO,CZTSettingsData *ZTSettings,CUSBDriveInterface *USBInterface,CStation *StationPtr,CAnalogInputModule *AnalogInterface);
|
||||
void ZTLogFilesSettings(int NbLogFiles, bool KeepMPM10Logs, bool KeepZT1Logs, bool KeepZT2Logs);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void hideEvent(QHideEvent *event);
|
||||
virtual void ShowPage();
|
||||
void Init();
|
||||
|
||||
private:
|
||||
CZoneTest *mProgramHandle;
|
||||
CAnalogInputModule *mAnalogInterface;
|
||||
CInputModule *mInputModulePtr;
|
||||
COutputModule *mOutputModulePtr;
|
||||
|
||||
CPCIIOMgr *mPCIIO;
|
||||
CZTSettingsData *mZTSettings;
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CStation *mStation;
|
||||
GenericInputMasks_t *mInputMasks;
|
||||
QList<CCDV*> *mCDVList;
|
||||
|
||||
CTextButtonWidget *mCancelButton;
|
||||
CTextButtonWidget *mConvertCSVButton;
|
||||
CTextButtonWidget *mTestButton;
|
||||
CTextButtonWidget *mDeleteEngLogBtn;
|
||||
|
||||
QGraphicsTextItem *mPCIIODataText;
|
||||
QGraphicsTextItem *mExternalInputDataText;
|
||||
QGraphicsTextItem *mRAMUsageText;
|
||||
QGraphicsTextItem *mIntLazerProbeValue;
|
||||
QGraphicsTextItem *mExtLazerProbeValue;
|
||||
QGraphicsTextItem *mAnalogSDFValue;
|
||||
QCheckBox *mExportZT1CSVChkBx,*mExportZT2CSVChkBx, *mHighResLogging;
|
||||
QCheckBox *mKeepAllMPM10Logs, *mKeepZT1Logs,*mKeepZT2Logs;
|
||||
QSpinBox *mNbLogFilesSpinBox;
|
||||
|
||||
QGraphicsTextItem *mNbLogsText;
|
||||
CTextButtonWidget *mDeleteLogsButton;
|
||||
CTextButtonWidget *mArchiveLogsButton;
|
||||
CTextButtonWidget *mDeleteZTLogButton;
|
||||
|
||||
CToggleButtonWidget *mPGCalibrationSwitch;
|
||||
QSpinBox *mPGTresholdValueSpinBox, *mPGNbPassagesForCalibSpinBox;
|
||||
CTextButtonWidget *mPGValueSetBtn, *mCopyCalibValueBtn;
|
||||
QGraphicsTextItem *mCalibResultText, *mActualPGTresholdValueText;
|
||||
|
||||
|
||||
CUSBDriveInterface *mUSBInterfacePtr;
|
||||
QGraphicsTextItem *mUSBFlashDetectionTxt;
|
||||
|
||||
QTimer *mInfoUpdateTimer;
|
||||
|
||||
QFileInfoList mLogFilesList;
|
||||
|
||||
//Outputs control
|
||||
CToggleButtonWidget *OutputToggleBtn[GENERIC_OUTPUT_NB_ID];
|
||||
|
||||
//Inputs monitor
|
||||
CLedWidget *mInputLeds[GENERIC_INPUT_NB_ID];
|
||||
QList<CLedWidget*> mInputLedsCDV;
|
||||
|
||||
|
||||
bool mAutoExportZT1CSV,mAutoExportZT2CSV;
|
||||
int mPGCalibTresholdValue;
|
||||
|
||||
|
||||
|
||||
void RefreshLogsList();
|
||||
void DeleteAllLogs();
|
||||
void ArchiveLogFiles();
|
||||
|
||||
CZT1LogData *mDummy[5000];
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
void UpdateInfo();
|
||||
void PasswordValid();
|
||||
void PasswordInvalid();
|
||||
void ZT1AutoCSVCheckBoxChanged(int);
|
||||
void ZT2AutoCSVCheckBoxChanged(int);
|
||||
void HighResLogCheckBoxChanged(int);
|
||||
void KeepZT1LogsCheckBoxChanged(int);
|
||||
void KeepZT2LogsCheckBoxChanged(int);
|
||||
void KeepAllMPM10LogsCheckBoxChanged(int);
|
||||
void OutputToggled(CToggleButtonWidget*);
|
||||
void LazerProbeDataAvailable(unsigned int,unsigned int);
|
||||
void PGCalibBtnToggled(CToggleButtonWidget*);
|
||||
void PGCalibFinished(int);
|
||||
void PGCalibUpdate(int,int);
|
||||
void MaxNbLogFilesChanged(int);
|
||||
|
||||
};
|
||||
|
||||
#endif // ENGINEERINGPAGE_H
|
||||
@@ -0,0 +1,131 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Affiche un rectangle qui "flash" en rouge lorsqu'une fonction de détection
|
||||
est désactivée. Le clignotement est une petite animation qui change la
|
||||
transparence de la couleur de fond.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130524 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "EventItem.h"
|
||||
#include <QPainter>
|
||||
#include "ZTData.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include "CDV.h"
|
||||
#include <QPoint>
|
||||
|
||||
CEventItem::CEventItem(QString Label,bool Animated,QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
|
||||
// mCDVFreeBrush = new QBrush(Qt::gray);
|
||||
// mCDVITICommandedBrush = new QBrush(Qt::darkGreen);
|
||||
// mCDVOccupiedBrush = new QBrush(Qt::yellow);
|
||||
|
||||
setGeometry(0,0,40,25);
|
||||
mCurBrush = new QBrush(Qt::lightGray);
|
||||
mLabelFont.setPixelSize(12);
|
||||
mLabelFont.setBold(true);
|
||||
|
||||
SetLabel(Label);
|
||||
|
||||
mAnimated = Animated;
|
||||
if(mAnimated)
|
||||
{
|
||||
mAnimationTimeline = new QTimeLine(1000);
|
||||
connect(mAnimationTimeline,SIGNAL(valueChanged(qreal)),this,SLOT(UpdateAnimation(qreal)));
|
||||
connect(mAnimationTimeline,SIGNAL(finished()),this,SLOT(AnimationFinished()));
|
||||
mAnimationTimeline->start();
|
||||
}
|
||||
|
||||
mAlpha = 0;
|
||||
}
|
||||
|
||||
CEventItem::~CEventItem()
|
||||
{
|
||||
if(mAnimated)
|
||||
delete mAnimationTimeline;
|
||||
}
|
||||
|
||||
void CEventItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
QRectF EventRect = rect();
|
||||
|
||||
if(mAnimated)
|
||||
mCurBrush->setColor(QColor(255,mAlpha,mAlpha,255));
|
||||
|
||||
painter->setBrush(*mCurBrush);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawRect(EventRect);
|
||||
|
||||
// QRectF textRect(CDVRect.adjusted(-3,-3,-3,-3));
|
||||
// painter->drawRect(textRect);
|
||||
|
||||
int flags = Qt::AlignHCenter | Qt::AlignVCenter/* | Qt::TextWordWrap*/;
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(mLabelFont);
|
||||
painter->drawText(EventRect, flags, mLabel);
|
||||
|
||||
}
|
||||
|
||||
void CEventItem::SetLabel(QString Label)
|
||||
{
|
||||
mLabel = Label;
|
||||
QSizeF Size;
|
||||
Size = size();
|
||||
QFontMetrics FontMetrics(mLabelFont);
|
||||
Size.setWidth(FontMetrics.boundingRect(mLabel).width() + 10);
|
||||
resize(Size);
|
||||
}
|
||||
|
||||
void CEventItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit EventItemRightClicked(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CEventItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
void CEventItem::UpdateAnimation(qreal value)
|
||||
{
|
||||
mAlpha = 255*value;
|
||||
|
||||
|
||||
//update(QGraphicsItem::pos().x(),QGraphicsItem::pos().x(),40,25);
|
||||
update();
|
||||
}
|
||||
|
||||
void CEventItem::AnimationFinished()
|
||||
{
|
||||
mAnimationTimeline->toggleDirection();
|
||||
mAnimationTimeline->start();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131022 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QString>
|
||||
#include <QTimeLine>
|
||||
|
||||
|
||||
|
||||
#ifndef EVENTITEM_H
|
||||
#define EVENTITEM_H
|
||||
|
||||
class CEventItem : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEventItem(QString Label,bool Animated,QGraphicsItem *Parent = 0);
|
||||
~CEventItem();
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
unsigned int SetParameters(QString Label/*, unsigned int posx, unsigned int posy*/);
|
||||
unsigned int SetState(unsigned int State);
|
||||
unsigned int UpdateState();
|
||||
void SetLabel(QString Label);
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
private:
|
||||
QBrush *mCurBrush;
|
||||
QString mLabel;
|
||||
QFont mLabelFont;
|
||||
bool mAnimated;
|
||||
QTimeLine *mAnimationTimeline;
|
||||
unsigned int mAlpha;
|
||||
|
||||
signals:
|
||||
void EventItemRightClicked(CEventItem*);
|
||||
|
||||
public slots:
|
||||
void UpdateAnimation(qreal);
|
||||
void AnimationFinished();
|
||||
};
|
||||
|
||||
#endif // EVENTITEM_H
|
||||
@@ -0,0 +1,79 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Crée une liste d'objets CEventItem et les dispose en ligne dans le bas de
|
||||
l'écran.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "EventsBar.h"
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
CEventsBar::CEventsBar(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
resize(SCREEN_RES_WIDTH,25);
|
||||
|
||||
// QPen temp;
|
||||
// temp.setColor(Qt::red);
|
||||
// QGraphicsRectItem *temprect = new QGraphicsRectItem(this);
|
||||
// temprect->setPen(temp);
|
||||
// temprect->setRect(boundingRect());
|
||||
// temprect->show();
|
||||
}
|
||||
|
||||
//void CEventsBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
void CEventsBar::UpdateDisplay()
|
||||
{
|
||||
if(mEventsItemList.size() == 0)
|
||||
return;
|
||||
|
||||
for(int i = 1; i < mEventsItemList.size(); i++)
|
||||
{
|
||||
CEventItem *CurEvent = mEventsItemList.at(i), *PrevEvent = mEventsItemList.at(i-1);
|
||||
|
||||
CurEvent->setPos(PrevEvent->pos().x() + PrevEvent->rect().width()+3,0);
|
||||
}
|
||||
}
|
||||
|
||||
void CEventsBar::UpdateEventsList()
|
||||
{
|
||||
//clear existing list if necessary
|
||||
for(int i = 0; i < mEventsItemList.size(); i++)
|
||||
{
|
||||
delete mEventsItemList.at(i);
|
||||
}
|
||||
mEventsItemList.clear();
|
||||
|
||||
for(int i = 0; i < mEventsList->size(); i++)
|
||||
{
|
||||
CEventItem *NewItem = new CEventItem(mEventsList->at(i)->mEventLabel,mEventsList->at(i)->mItemAnimated,this);
|
||||
mEventsItemList.append(NewItem);
|
||||
}
|
||||
UpdateDisplay();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131022 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef EVENTSBAR_H
|
||||
#define EVENTSBAR_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QList>
|
||||
#include "EventItem.h"
|
||||
#include "Event.h"
|
||||
|
||||
class CEventsBar : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CEventsBar(QGraphicsItem *Parent = 0);
|
||||
|
||||
// void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
QList<CEvent*> *mEventsList;
|
||||
void UpdateEventsList();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QList<CEventItem*> mEventsItemList;
|
||||
void UpdateDisplay();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // EVENTSBAR_H
|
||||
@@ -0,0 +1,127 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Dessine une règle temporelle sur laquelle sont affichés les déclenchements.
|
||||
Une ligne rouge est dessinée au temps correspondant au déclenchement et du
|
||||
texte identifiant le type de déclenchement est aussi affiché.
|
||||
|
||||
Utilisée dans la page de visualisation des passages de train.
|
||||
|
||||
CETTE CLASSE DEVRAIT ÊTRE OPTIMISÉE.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "EventsRulerWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QTextStream>
|
||||
|
||||
CEventRulerWidget::CEventRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mPixelWidth = RulerPixelWidth;
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
}
|
||||
|
||||
void CEventRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
if(mEventItems.isEmpty())
|
||||
return;
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
painter->setFont(font);
|
||||
qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||
|
||||
QPen LinePen,TextPen;
|
||||
LinePen.setColor(Qt::red);
|
||||
LinePen.setWidth(2);
|
||||
TextPen.setColor(Qt::black);
|
||||
TextPen.setWidth(1);
|
||||
|
||||
qreal Height = boundingRect().height();
|
||||
|
||||
for(int i = 0; i < mEventItems.size(); i++)
|
||||
{
|
||||
if(mEventItems.at(i).mEventTime >= mStartTime)
|
||||
{
|
||||
if(mEventItems.at(i).mEventTime <= mEndTime)
|
||||
{
|
||||
qreal PixelPos = (mEventItems.at(i).mEventTime - mStartTime)*pitch;
|
||||
painter->setPen(LinePen);
|
||||
painter->drawLine(PixelPos,0,PixelPos,Height);
|
||||
painter->setPen(TextPen);
|
||||
painter->drawText(QRectF(PixelPos+3,0,50,Height),mEventItems.at(i).mLabel,Qt::AlignLeft | Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CEventRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||
{
|
||||
if(StartTime > EndTime)
|
||||
return false;
|
||||
|
||||
if(mEventItems.isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
mStartTime = StartTime;
|
||||
mEndTime = EndTime;
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CEventRulerWidget::AddEventItem(QString Rank, quint64 EventTime)
|
||||
{
|
||||
CEventRulerWidgetItem NewItem;
|
||||
NewItem.mLabel = Rank;
|
||||
NewItem.mEventTime = EventTime;
|
||||
|
||||
mEventItems.append(NewItem);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CEventRulerWidget::SetLabel(QString Label, int Offset)
|
||||
{
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
mLabel->setFont(font);
|
||||
mLabel->setPlainText(Label);
|
||||
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||
}
|
||||
|
||||
void CEventRulerWidget::ClearRuler()
|
||||
{
|
||||
mEventItems.clear();
|
||||
update();
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131030 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### 20131107 Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef EVENTSRULERWIDGET_H
|
||||
#define EVENTSRULERWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class CEventRulerWidgetItem
|
||||
{
|
||||
public:
|
||||
QString mLabel;
|
||||
quint64 mEventTime;
|
||||
};
|
||||
|
||||
class CEventRulerWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CEventRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||
unsigned int AddEventItem(QString EventLabel,quint64 EventTime);
|
||||
void SetLabel(QString Label,int Offset);
|
||||
void ClearRuler();
|
||||
|
||||
|
||||
private:
|
||||
qreal mPixelWidth;
|
||||
quint64 mStartTime, mEndTime;
|
||||
qreal mPixelPitch;
|
||||
QGraphicsTextItem *mLabel;
|
||||
|
||||
QList<CEventRulerWidgetItem> mEventItems;
|
||||
|
||||
};
|
||||
|
||||
#endif // RANKRULERWIDGET_H
|
||||
@@ -0,0 +1,401 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page d'activation ou de désactivation des fonctions de détection.
|
||||
Des boutons curseurs permettent de mettre à ON ou à OFF une fonction, soit
|
||||
pour son analyse ou pour sa TK ou les deux.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "FunctionSelectionPage.h"
|
||||
#include "GlobalDefine.h"
|
||||
#include "Zonetest.h"
|
||||
#include <QFont>
|
||||
|
||||
|
||||
|
||||
CFunctionSelectionPage::CFunctionSelectionPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
mProgramHandle = 0;
|
||||
mZTSimulatorPtr = 0;
|
||||
|
||||
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
QGraphicsTextItem *Title = new QGraphicsTextItem("Configuration des fonctions de détection",this);
|
||||
QFont font;
|
||||
font.setPointSize(15);
|
||||
Title->setFont(font);
|
||||
Title->setPos(40,10);
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Annuler");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(50,360);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mAcceptButton = new CTextButtonWidget("Appliquer");
|
||||
mAcceptButton->setParentItem(this);
|
||||
mAcceptButton->setPos(145,360);
|
||||
connect(mAcceptButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
|
||||
QPointF ArrayTopLeft;
|
||||
ArrayTopLeft.setX(250);
|
||||
ArrayTopLeft.setY(100);
|
||||
qreal XButtonSpacing = 90;
|
||||
qreal YLineSpacing = 40;
|
||||
QString ONPixmapFilePath = "./Images/Slider_Green.png";
|
||||
QString OFFPixmapFilePath = "./Images/Slider_Red.png";
|
||||
QSizeF SlideButtonSize(50,30);
|
||||
font.setPointSize(12);
|
||||
|
||||
|
||||
QGraphicsTextItem *Label = new QGraphicsTextItem("Analyse",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(ArrayTopLeft.x() - 10,ArrayTopLeft.y() - YLineSpacing);
|
||||
|
||||
Label = new QGraphicsTextItem("TK",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(ArrayTopLeft.x() + XButtonSpacing +5 ,ArrayTopLeft.y() - YLineSpacing);
|
||||
|
||||
int i = 0;
|
||||
Label = new QGraphicsTextItem("Frotteur Négatif:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mFNFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mFNFuncToggleBtn->resize(SlideButtonSize);
|
||||
mFNFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mFNTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mFNTKToggleBtn->resize(SlideButtonSize);
|
||||
mFNTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
|
||||
i++;
|
||||
Label = new QGraphicsTextItem("Pneu de guidage:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPGFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPGFuncToggleBtn->resize(SlideButtonSize);
|
||||
mPGFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPGTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPGTKToggleBtn->resize(SlideButtonSize);
|
||||
mPGTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
|
||||
i++;
|
||||
Label = new QGraphicsTextItem("Pneu porteur:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPPFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPPFuncToggleBtn->resize(SlideButtonSize);
|
||||
mPPFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPPTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPPTKToggleBtn->resize(SlideButtonSize);
|
||||
mPPTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
|
||||
i++;
|
||||
Label = new QGraphicsTextItem("Pneu porteur ZT2:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPP2FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPP2FuncToggleBtn->resize(SlideButtonSize);
|
||||
mPP2FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mPP2TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mPP2TKToggleBtn->resize(SlideButtonSize);
|
||||
mPP2TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
|
||||
i++;
|
||||
Label = new QGraphicsTextItem("ZT1:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mZT1FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mZT1FuncToggleBtn->resize(SlideButtonSize);
|
||||
mZT1FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
connect(mZT1FuncToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||
mZT1TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mZT1TKToggleBtn->resize(SlideButtonSize);
|
||||
mZT1TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
connect(mZT1TKToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||
|
||||
i++;
|
||||
Label = new QGraphicsTextItem("ZT2:",this);
|
||||
Label->setFont(font);
|
||||
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
mZT2FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mZT2FuncToggleBtn->resize(SlideButtonSize);
|
||||
mZT2FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
connect(mZT2FuncToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||
mZT2TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||
mZT2TKToggleBtn->resize(SlideButtonSize);
|
||||
mZT2TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||
connect(mZT2TKToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||
}
|
||||
|
||||
void CFunctionSelectionPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void CFunctionSelectionPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mAcceptButton)
|
||||
{
|
||||
UpdateConfig();
|
||||
mProgramHandle->DetectionFunctionsConfigChanged(&mZTConfig);
|
||||
hide();
|
||||
}
|
||||
else if(BtnPtr == mCancelButton)
|
||||
{
|
||||
UpdateDisplay(); //revert any changes made to the buttons
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CFunctionSelectionPage::SetConfig(CZTDetectionFunctionConfig *Config)
|
||||
{
|
||||
mZTConfig = *Config;
|
||||
UpdateDisplay();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CFunctionSelectionPage::UpdateDisplay()
|
||||
{
|
||||
//update FN buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].AnalysisActive == true)
|
||||
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].TKActive == true)
|
||||
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
//update PG buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].AnalysisActive == true)
|
||||
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].TKActive == true)
|
||||
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
//update PP buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].AnalysisActive == true)
|
||||
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].TKActive == true)
|
||||
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
//update PP2 buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive == true)
|
||||
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].TKActive == true)
|
||||
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
//update ZT1 buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].AnalysisActive == true)
|
||||
mZT1FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mZT1FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].TKActive == true)
|
||||
mZT1TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mZT1TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
//update ZT2 buttons
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].AnalysisActive == true)
|
||||
mZT2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mZT2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
if(mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].TKActive == true)
|
||||
mZT2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
else
|
||||
mZT2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
|
||||
}
|
||||
|
||||
void CFunctionSelectionPage::UpdateConfig()
|
||||
{
|
||||
//update FN flags
|
||||
if(mFNFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].AnalysisActive = false;
|
||||
|
||||
if(mFNTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_FN].TKActive = false;
|
||||
|
||||
//update PG flags
|
||||
if(mPGFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].AnalysisActive = false;
|
||||
|
||||
if(mPGTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PG].TKActive = false;
|
||||
|
||||
//update PP flags
|
||||
if(mPPFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].AnalysisActive = false;
|
||||
|
||||
if(mPPTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP].TKActive = false;
|
||||
|
||||
//update PP2 flags
|
||||
if(mPP2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive = false;
|
||||
|
||||
if(mPP2TKToggleBtn->GetButtonState())
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_PP2].TKActive = false;
|
||||
|
||||
//update ZT1 flags
|
||||
if(mZT1FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].AnalysisActive = false;
|
||||
|
||||
if(mZT1TKToggleBtn->GetButtonState())
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT1].TKActive = false;
|
||||
|
||||
|
||||
//update ZT2 flags
|
||||
if(mZT2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].AnalysisActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].AnalysisActive = false;
|
||||
|
||||
if(mZT2TKToggleBtn->GetButtonState())
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].TKActive = true;
|
||||
else
|
||||
mZTConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].TKActive = false;
|
||||
}
|
||||
|
||||
void CFunctionSelectionPage::ToggleButtonToggled(CToggleButtonWidget *ToggleButton)
|
||||
{
|
||||
|
||||
if(ToggleButton == mZT1FuncToggleBtn)
|
||||
{
|
||||
if(mZT1FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||
{
|
||||
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mFNFuncToggleBtn->SetButtonEnabled(false);
|
||||
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mPGFuncToggleBtn->SetButtonEnabled(false);
|
||||
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mPPFuncToggleBtn->SetButtonEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mFNFuncToggleBtn->SetButtonEnabled(true);
|
||||
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mPGFuncToggleBtn->SetButtonEnabled(true);
|
||||
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mPPFuncToggleBtn->SetButtonEnabled(true);
|
||||
}
|
||||
}
|
||||
if(ToggleButton == mZT1TKToggleBtn)
|
||||
{
|
||||
if(mZT1TKToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||
{
|
||||
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mFNTKToggleBtn->SetButtonEnabled(false);
|
||||
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mPGTKToggleBtn->SetButtonEnabled(false);
|
||||
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mPPTKToggleBtn->SetButtonEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mFNTKToggleBtn->SetButtonEnabled(true);
|
||||
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mPGTKToggleBtn->SetButtonEnabled(true);
|
||||
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mPPTKToggleBtn->SetButtonEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(ToggleButton == mZT2FuncToggleBtn)
|
||||
{
|
||||
if(mZT2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||
{
|
||||
mPP2FuncToggleBtn->SetButtonEnabled(false);
|
||||
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
mPP2FuncToggleBtn->SetButtonEnabled(true);
|
||||
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
}
|
||||
}
|
||||
if(ToggleButton == mZT2TKToggleBtn)
|
||||
{
|
||||
if(mZT2TKToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||
{
|
||||
mPP2TKToggleBtn->SetButtonEnabled(false);
|
||||
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
mPP2TKToggleBtn->SetButtonEnabled(true);
|
||||
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void CFunctionSelectionPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CFunctionSelectionPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef FUNCTIONSELECTIONPAGE_H
|
||||
#define FUNCTIONSELECTIONPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "ToggleButtonWidget.h"
|
||||
#include "ZTData.h"
|
||||
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
class CFunctionSelectionPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CFunctionSelectionPage(QGraphicsWidget *Parent = 0);
|
||||
CZoneTest *mProgramHandle;
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
unsigned int SetConfig(CZTDetectionFunctionConfig* Config);
|
||||
void UpdateDisplay();
|
||||
|
||||
private:
|
||||
CZTSimulator *mZTSimulatorPtr;
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton;
|
||||
CTextButtonWidget *mAcceptButton;
|
||||
|
||||
CToggleButtonWidget *mFNFuncToggleBtn, *mFNTKToggleBtn;
|
||||
CToggleButtonWidget *mPGFuncToggleBtn, *mPGTKToggleBtn;
|
||||
CToggleButtonWidget *mPPFuncToggleBtn, *mPPTKToggleBtn;
|
||||
CToggleButtonWidget *mPP2FuncToggleBtn, *mPP2TKToggleBtn;
|
||||
CToggleButtonWidget *mZT1FuncToggleBtn, *mZT1TKToggleBtn;
|
||||
CToggleButtonWidget *mZT2FuncToggleBtn, *mZT2TKToggleBtn;
|
||||
|
||||
CZTDetectionFunctionConfig mZTConfig;
|
||||
|
||||
|
||||
void UpdateConfig();
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
void ToggleButtonToggled(CToggleButtonWidget*);
|
||||
|
||||
};
|
||||
|
||||
#endif // FUNCTIONSELECTIONPAGE_H
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page offrant différentes option pour l'entretien de la ZT
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "GeneralSettingsPage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include "Zonetest.h"
|
||||
#include <QDateTime>
|
||||
#include <QFont>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <sys/time.h>
|
||||
#include "ZTLog.h"
|
||||
|
||||
|
||||
|
||||
CGeneralSettingsPage::CGeneralSettingsPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
|
||||
|
||||
mProgramHandle = 0;
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
QGraphicsTextItem *Title = new QGraphicsTextItem("Paramètres généraux",this);
|
||||
QFont font;
|
||||
font.setPointSize(18);
|
||||
Title->setFont(font);
|
||||
Title->setPos(40,10);
|
||||
|
||||
Title = new QGraphicsTextItem("Ajuster date & heure",this);
|
||||
Title->setFont(font);
|
||||
Title->setPos(270,80);
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Fermer");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(700,550);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||
mCalendarWidget = new QCalendarWidget();
|
||||
Proxy->setWidget(mCalendarWidget);
|
||||
Proxy->setPos(100,150);
|
||||
|
||||
mTimeEdit = new QTimeEdit();
|
||||
Proxy = new QGraphicsProxyWidget(this);
|
||||
Proxy->setWidget(mTimeEdit);
|
||||
Proxy->setPos(475,150);
|
||||
mTimeEdit->setTime(QTime::currentTime());
|
||||
mTimeEdit->setDisplayFormat("hh:mm");
|
||||
|
||||
mApplyDateTimeBtn = new CTextButtonWidget("Changer date & heure");
|
||||
mApplyDateTimeBtn->setParentItem(this);
|
||||
mApplyDateTimeBtn->setPos(450,250);
|
||||
connect(mApplyDateTimeBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
QGraphicsRectItem *Frame = new QGraphicsRectItem(80,70,600,300,this);
|
||||
QPen FramePen;
|
||||
FramePen.setWidth(3);
|
||||
Frame->setPen(FramePen);
|
||||
|
||||
|
||||
Title = new QGraphicsTextItem("Seuil Pneu de Guidage",this);
|
||||
Title->setFont(font);
|
||||
Title->setPos(270,400);
|
||||
Frame = new QGraphicsRectItem(80,405,600,175,this);
|
||||
Frame->setPen(FramePen);
|
||||
|
||||
mPGTresholdValueSpinBox = new QSpinBox();
|
||||
Proxy = new QGraphicsProxyWidget(this);
|
||||
Proxy->setWidget(mPGTresholdValueSpinBox);
|
||||
Proxy->setPos(125,500);
|
||||
mPGTresholdValueSpinBox->resize(70,30);
|
||||
mPGTresholdValueSpinBox->setMinimum(1);
|
||||
mPGTresholdValueSpinBox->setMaximum(2000);
|
||||
mPGTresholdValueSpinBox->setValue(255);
|
||||
|
||||
mPGValueSetBtn = new CTextButtonWidget("Changer Seuil",0,30);
|
||||
mPGValueSetBtn->setParentItem(this);
|
||||
mPGValueSetBtn->setPos(200,500);
|
||||
connect(mPGValueSetBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mActualPGTresholdValueText = new QGraphicsTextItem(this);
|
||||
mActualPGTresholdValueText->setPos(125,450);
|
||||
font.setPointSize(14);
|
||||
mActualPGTresholdValueText->setFont(font);
|
||||
mActualPGTresholdValueText->setPlainText("Valeur actuelle : 255");
|
||||
|
||||
}
|
||||
|
||||
void CGeneralSettingsPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void CGeneralSettingsPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mCancelButton)
|
||||
{
|
||||
mProgramHandle->CloseGeneralSettingsPage();
|
||||
hide();
|
||||
}
|
||||
else if(BtnPtr == mApplyDateTimeBtn)
|
||||
{
|
||||
|
||||
time_t time_data = time(0);
|
||||
struct tm* tm_ptr = localtime(&time_data);
|
||||
|
||||
tm_ptr->tm_min = mTimeEdit->time().minute();
|
||||
tm_ptr->tm_hour = mTimeEdit->time().hour();
|
||||
tm_ptr->tm_mday = mCalendarWidget->selectedDate().day();
|
||||
tm_ptr->tm_mon = mCalendarWidget->selectedDate().month()-1;
|
||||
tm_ptr->tm_year = mCalendarWidget->selectedDate().year()-1900;
|
||||
|
||||
const struct timeval tv = {mktime(tm_ptr),0};
|
||||
if(settimeofday(&tv,0) < 0)
|
||||
{
|
||||
qDebug("Settimeofday failed");
|
||||
CZTLog::instance()->AddLogString("Échec du changement de la date & de l'heure",true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( system("/sbin/hwclock --systohc") < 0 )
|
||||
{
|
||||
//qDebug("hwclock sync failed");
|
||||
CZTLog::instance()->AddLogString("Échec du changement de la date & de l'heure (hwsync failure)",true);
|
||||
}
|
||||
else
|
||||
CZTLog::instance()->AddLogString(QString().sprintf("Changement de date & heure: %s %s",mCalendarWidget->selectedDate().toString("yyyy/MM/dd").toUtf8().data(),mTimeEdit->time().toString("hh:mm").toUtf8().data()),true);
|
||||
}
|
||||
}
|
||||
else if(BtnPtr == mPGValueSetBtn)
|
||||
{
|
||||
CZTLog::instance()->AddLogString(QString().sprintf("Seuil PG changé. Ancien: %d, Nouveau: %d",mProgramHandle->GetPGTreshold(),mPGTresholdValueSpinBox->value()),true);
|
||||
mProgramHandle->SetPGTreshold(mPGTresholdValueSpinBox->value());
|
||||
mActualPGTresholdValueText->setPlainText(QString().sprintf("Valeur seuil PG actuelle %d",mProgramHandle->GetPGTreshold()));
|
||||
}
|
||||
}
|
||||
|
||||
void CGeneralSettingsPage::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
mTimeEdit->setTime(QTime::currentTime());
|
||||
mActualPGTresholdValueText->setPlainText(QString().sprintf("Valeur seuil PG actuelle %d",mProgramHandle->GetPGTreshold()));
|
||||
mPGTresholdValueSpinBox->setValue(mProgramHandle->GetPGTreshold());
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void CGeneralSettingsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CGeneralSettingsPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131122 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef GENERALSETTINGSPAGE_H
|
||||
#define GENERALSETTINGSPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QCalendarWidget>
|
||||
#include <QTimeEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
class CGeneralSettingsPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CGeneralSettingsPage(QGraphicsWidget *Parent = 0);
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void showEvent ( QShowEvent * event );
|
||||
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton;
|
||||
CTextButtonWidget *mApplyDateTimeBtn;
|
||||
|
||||
QCalendarWidget *mCalendarWidget;
|
||||
QTimeEdit *mTimeEdit;
|
||||
|
||||
|
||||
QSpinBox *mPGTresholdValueSpinBox;
|
||||
CTextButtonWidget *mPGValueSetBtn;
|
||||
QGraphicsTextItem *mActualPGTresholdValueText;
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
|
||||
};
|
||||
|
||||
#endif // GENERALSETTINGSPAGE_H
|
||||
@@ -0,0 +1,138 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Dessine une ligne verticale et garde certaines information sur la position du
|
||||
curseur
|
||||
|
||||
|
||||
Utilisée dans la page de visualisation des passages de train..
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "GraphCursorWidget.h"
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
|
||||
CVerticalGraphCursorWidget::CVerticalGraphCursorWidget(qreal Height,QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
resize(3,Height);
|
||||
mLine.setLine(0,0,0,Height);
|
||||
mColor = Qt::blue;
|
||||
mCursorTime = 0;
|
||||
mCursorSet = false;
|
||||
}
|
||||
|
||||
void CVerticalGraphCursorWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(mColor);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawLine(mLine);
|
||||
|
||||
// if(mWidth != 0)
|
||||
// painter->drawLine(mHLine);
|
||||
|
||||
}
|
||||
|
||||
qreal CVerticalGraphCursorWidget::GetPixelPos()
|
||||
{
|
||||
return pos().x();
|
||||
}
|
||||
quint64 CVerticalGraphCursorWidget::GetTime()
|
||||
{
|
||||
return mCursorTime;
|
||||
}
|
||||
void CVerticalGraphCursorWidget::SetTime(quint64 time)
|
||||
{
|
||||
mCursorTime = time;
|
||||
}
|
||||
bool CVerticalGraphCursorWidget::IsCursorSet()
|
||||
{
|
||||
return mCursorSet;
|
||||
}
|
||||
void CVerticalGraphCursorWidget::ClearCursor()
|
||||
{
|
||||
mCursorSet = false;
|
||||
hide();
|
||||
}
|
||||
void CVerticalGraphCursorWidget::SetCursor()
|
||||
{
|
||||
mCursorSet = true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CHorizontalGraphCursorWidget::CHorizontalGraphCursorWidget(qreal Width,QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
resize(3,Width);
|
||||
mLine.setLine(0,0,Width,0);
|
||||
mColor = Qt::blue;
|
||||
mCursorSet = false;
|
||||
}
|
||||
|
||||
void CHorizontalGraphCursorWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(mColor);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawLine(mLine);
|
||||
|
||||
// if(mWidth != 0)
|
||||
// painter->drawLine(mHLine);
|
||||
|
||||
}
|
||||
|
||||
qreal CHorizontalGraphCursorWidget::GetPixelPos()
|
||||
{
|
||||
return pos().y();
|
||||
}
|
||||
bool CHorizontalGraphCursorWidget::IsCursorSet()
|
||||
{
|
||||
return mCursorSet;
|
||||
}
|
||||
void CHorizontalGraphCursorWidget::ClearCursor()
|
||||
{
|
||||
mCursorSet = false;
|
||||
hide();
|
||||
}
|
||||
void CHorizontalGraphCursorWidget::SetCursor()
|
||||
{
|
||||
mCursorSet = true;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef GRAPHCURSORWIDGET_H
|
||||
#define GRAPHCURSORWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class CVerticalGraphCursorWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CVerticalGraphCursorWidget(qreal Height, QGraphicsItem *Parent = 0);
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
qreal GetPixelPos();
|
||||
void SetColor(QColor color){mColor = color;}
|
||||
quint64 GetTime();
|
||||
void SetTime(quint64 time);
|
||||
bool IsCursorSet();
|
||||
void ClearCursor();
|
||||
void SetCursor();
|
||||
|
||||
private:
|
||||
QLine mLine;
|
||||
QColor mColor;
|
||||
quint64 mCursorTime;
|
||||
bool mCursorSet;
|
||||
};
|
||||
|
||||
class CHorizontalGraphCursorWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CHorizontalGraphCursorWidget(qreal Width, QGraphicsItem *Parent = 0);
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
qreal GetPixelPos();
|
||||
void SetColor(QColor color){mColor = color;}
|
||||
bool IsCursorSet();
|
||||
void ClearCursor();
|
||||
void SetCursor();
|
||||
|
||||
private:
|
||||
QLine mLine;
|
||||
QColor mColor;
|
||||
quint64 mCursorPos;
|
||||
bool mCursorSet;
|
||||
};
|
||||
|
||||
#endif // GRAPHCURSORWIDGET_H
|
||||
@@ -0,0 +1,254 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe d'affichage d'un graphique discret (sondes magnétiques, pédales, etc.)La
|
||||
fonction SetData permet d'associer la liste des transitions. La
|
||||
fonction DisplayData() permet de fixer le timespan à afficher. La fonction détermine
|
||||
quels points sont dans le span et crée une liste de lignes qui sont ensuite affichés
|
||||
dans la fonction de rappel paint().
|
||||
|
||||
Utilisée dans la page de visualisation des passages de train.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "GraphItem.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CGraphItem::CGraphItem(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mDataSet = 0;
|
||||
mStartTime = mStopTime = 0;
|
||||
mDataValid = false;
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
}
|
||||
|
||||
CGraphItem::~CGraphItem()
|
||||
{
|
||||
delete mGraphPixmap;
|
||||
}
|
||||
|
||||
void CGraphItem::SetData(QList<CGraphDiscreteDataPair*> *DataList)
|
||||
{
|
||||
|
||||
mDataSet = DataList;
|
||||
//Build the lines list
|
||||
}
|
||||
|
||||
unsigned int CGraphItem::DisplayData(quint64 StartTime, quint64 StopTime)
|
||||
{
|
||||
if(mDataSet == 0)
|
||||
return RET_OK;
|
||||
|
||||
quint64 MinTime = mDataSet->first()->mTime;
|
||||
quint64 MaxTime = mDataSet->last()->mTime;
|
||||
|
||||
if(StartTime >= StopTime)
|
||||
return RET_ERROR;
|
||||
if(StartTime < MinTime)
|
||||
return RET_ERROR;
|
||||
if(StopTime > MaxTime)
|
||||
return RET_ERROR;
|
||||
|
||||
mStartTime = StartTime;
|
||||
mStopTime = StopTime;
|
||||
quint64 TimeSpan = StopTime - StartTime;
|
||||
|
||||
//Find the index of the first and last point in the timespan.
|
||||
int StartIndex = 0, StopIndex = 0;
|
||||
quint64 StartDeltaTime, StopDeltaTime;
|
||||
int i = 0;
|
||||
bool StartFound = false, StopFound = false;
|
||||
while(StartFound == false || StopFound == false)
|
||||
{
|
||||
if(i >= mDataSet->size())
|
||||
{
|
||||
qDebug("GraphItem::Array overflow while searching for time index");
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
quint64 CurTime = mDataSet->at(i)->mTime;
|
||||
if(CurTime <= StartTime)
|
||||
{
|
||||
StartIndex = i;
|
||||
StartDeltaTime = CurTime - StartTime;
|
||||
StartFound = true;
|
||||
}
|
||||
if(CurTime >= StopTime && !StopFound)
|
||||
{
|
||||
StopIndex = i;
|
||||
StopDeltaTime = StopTime - mDataSet->at(StopIndex)->mTime;
|
||||
StopFound = true;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//Build the lines list
|
||||
mLinesList.clear();
|
||||
qreal Width = boundingRect().width();
|
||||
qreal Height = boundingRect().height()-2;
|
||||
qreal tick = (Width)/TimeSpan; //pixels per microsec
|
||||
|
||||
qreal X1,X2,Y1,Y2;
|
||||
|
||||
//Add all the lines to create the graph. When there is a transition
|
||||
//the horizontal line must be continued to the next point and a vertical
|
||||
//line must be drawn.
|
||||
for(int i = StartIndex; i < StopIndex; i++)
|
||||
{
|
||||
QLine NewLine;
|
||||
if(mDataSet->at(i)->mTime < StartTime)
|
||||
X1 = 0;
|
||||
else
|
||||
X1 = (qreal)(mDataSet->at(i)->mTime - StartTime);
|
||||
|
||||
Y1 = mDataSet->at(i)->mValue;
|
||||
|
||||
if(mDataSet->at(i+1)->mTime > StopTime)
|
||||
{
|
||||
X2 = StopTime - StartTime;
|
||||
Y2 = mDataSet->at(i)->mValue; //Do not draw the vertical line if the point outside the span is not the same value.
|
||||
}
|
||||
else
|
||||
{
|
||||
X2 = mDataSet->at(i+1)->mTime - StartTime;
|
||||
Y2 = mDataSet->at(i+1)->mValue;
|
||||
}
|
||||
|
||||
//Reverse the Y axis
|
||||
if(Y1 == 0)
|
||||
Y1 = 1;
|
||||
else
|
||||
Y1 = 0;
|
||||
if(Y2 == 0)
|
||||
Y2 = 1;
|
||||
else
|
||||
Y2 = 0;
|
||||
|
||||
|
||||
if(Y1 == Y2) //no transition
|
||||
{
|
||||
NewLine.setLine(X1*tick,Y1*Height+1,X2*tick,Y2*Height+1);
|
||||
mLinesList.append(NewLine);
|
||||
}
|
||||
else //value transition...
|
||||
{
|
||||
NewLine.setLine(X1*tick,Y1*Height+1,X2*tick,Y1*Height+1); //horizontal line
|
||||
mLinesList.append(NewLine);
|
||||
NewLine.setLine(X2*tick,Y1*Height+1,X2*tick,Y2*Height+1); //vertical line
|
||||
mLinesList.append(NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
mDataValid = true;
|
||||
|
||||
//#ifndef WINDOWS_OS
|
||||
mGraphPixmap->fill(QColor(245, 245, 255));
|
||||
QPainter *painter = new QPainter(mGraphPixmap);
|
||||
painter->drawLines(mLinesList);
|
||||
delete painter;
|
||||
//#endif
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
// static int toto = 0;
|
||||
// qDebug("CGraphItem::paint %d",toto++);
|
||||
|
||||
if(mDataValid == false)
|
||||
return ;
|
||||
if(mDataSet == 0)
|
||||
return;
|
||||
if(mDataSet->size() == 0)
|
||||
return;
|
||||
|
||||
// painter->setClipRect(option->exposedRect);
|
||||
|
||||
// QPen pen;
|
||||
// pen.setWidth(1);
|
||||
|
||||
// pen.setColor(Qt::red);
|
||||
// painter->setPen(pen);
|
||||
// painter->drawRect(boundingRect());
|
||||
|
||||
// pen.setColor(Qt::black);
|
||||
// painter->setPen(pen);
|
||||
|
||||
//#ifdef WINDOWS_OS
|
||||
// painter->drawLines(mLinesList);
|
||||
//#else
|
||||
painter->drawPixmap(0,0,*mGraphPixmap);
|
||||
//#endif
|
||||
// for(int i = 0; i < mLinesList.size(); i++)
|
||||
// {
|
||||
// painter->drawEllipse(mLinesList.at(i).p1(),2,2);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void CGraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
||||
void CGraphItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void CGraphItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
//mBackgroundRect->setRect(boundingRect());
|
||||
delete mGraphPixmap;
|
||||
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
DisplayData(mStartTime,mStopTime);
|
||||
}
|
||||
void CGraphItem::SetLabel(QString label,int Offset)
|
||||
{
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
mLabel->setFont(font);
|
||||
mLabel->setPlainText(label);
|
||||
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||
}
|
||||
|
||||
|
||||
CGraphDiscreteDataPair::CGraphDiscreteDataPair(quint32 Value, quint64 Time):
|
||||
mValue(Value),
|
||||
mTime(Time)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef CGRAPHITEM_H
|
||||
#define CGRAPHITEM_H
|
||||
|
||||
#include <GlobalDefine.h>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
|
||||
class CGraphDiscreteDataPair
|
||||
{
|
||||
public:
|
||||
CGraphDiscreteDataPair(quint32 Value, quint64 Time);
|
||||
quint32 mValue;
|
||||
quint64 mTime;
|
||||
};
|
||||
|
||||
|
||||
class CGraphItem : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CGraphItem(QGraphicsItem *Parent = 0);
|
||||
~CGraphItem();
|
||||
|
||||
QList<CGraphDiscreteDataPair*> *mDataSet;
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
|
||||
// unsigned int DisplayData(quint32 StartIndex, quint32 StopIndex);
|
||||
unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
|
||||
void SetData(QList<CGraphDiscreteDataPair*> *DataList);
|
||||
// void UpdateDisplay(void);
|
||||
void SetLabel(QString label,int Offset);
|
||||
|
||||
virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
private:
|
||||
//quint64 mTimeSpan;
|
||||
//quint64 mOffset;
|
||||
bool mDataValid;
|
||||
//quint32 mStartIndex,mStopIndex;
|
||||
quint64 mStartTime, mStopTime;
|
||||
QVector<QLine> mLinesList;
|
||||
QGraphicsTextItem *mLabel;
|
||||
|
||||
QPixmap *mGraphPixmap;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CGRAPHITEM_H
|
||||
@@ -0,0 +1,222 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche une règle de graduation temporelle dans le bas
|
||||
de la zone d'affichage.
|
||||
|
||||
Utilisée dans la page de visualisation des passages de train.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "GraphRulerWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QTextStream>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CGraphRulerWidget::CGraphRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mPixelWidth = RulerPixelWidth;
|
||||
mPixelPitch = RulerPixelWidth/RULER_NB_TICKS;
|
||||
|
||||
mRulerPixmap = new QPixmap(RulerPixelWidth,boundingRect().height()+1);
|
||||
}
|
||||
|
||||
CGraphRulerWidget::~CGraphRulerWidget()
|
||||
{
|
||||
delete mRulerPixmap;
|
||||
}
|
||||
|
||||
void CGraphRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
painter->setClipRect(option->exposedRect);
|
||||
painter->drawPixmap(0,0,*mRulerPixmap);
|
||||
|
||||
// static int toto = 0;
|
||||
// qDebug("CGraphRulerWidget::paint %d",toto++);
|
||||
|
||||
// qreal x = 0;
|
||||
// QRectF TextRect(0,0,100,10);
|
||||
// QString TimeText;
|
||||
// qreal tick = (mEndTime - mStartTime)/mPixelWidth;
|
||||
// QFont font;
|
||||
// font.setPixelSize(12);
|
||||
// painter->setFont(font);
|
||||
// for(int i = 0; i <= RULER_NB_TICKS; i++)
|
||||
// {
|
||||
// QLine line;
|
||||
// if(i%20 == 0)
|
||||
// {
|
||||
// TimeText.clear();
|
||||
// line.setLine(x,0,x,10); //long line
|
||||
// TextRect.moveCenter(QPoint(x,15));
|
||||
// qreal time = (x*tick) + mStartTime;
|
||||
|
||||
// if(time < 1000)
|
||||
// {
|
||||
// QTextStream(&TimeText) << time << " ns";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// time /= 1000;
|
||||
// if(time < 1000)
|
||||
// {
|
||||
// QTextStream(&TimeText) << time << " us";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// time /= 1000;
|
||||
// if(time < 1000)
|
||||
// {
|
||||
// QTextStream(&TimeText) << time << " ms";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// time /= 1000;
|
||||
// if(time < 1000)
|
||||
// {
|
||||
// QTextStream(&TimeText) << time << " s";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// painter->drawText(TextRect,Qt::AlignCenter,TimeText);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// line.setLine(x,0,x,5);
|
||||
// }
|
||||
// painter->drawLine(line);
|
||||
// x += mPixelPitch;
|
||||
// }
|
||||
}
|
||||
|
||||
unsigned int CGraphRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||
{
|
||||
if(StartTime > EndTime)
|
||||
return false;
|
||||
|
||||
mStartTime = StartTime;
|
||||
mEndTime = EndTime;
|
||||
|
||||
Render();
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CGraphRulerWidget::Render()
|
||||
{
|
||||
qreal x = 0;
|
||||
QRectF TextRect(0,0,100,10);
|
||||
QString TimeText;
|
||||
qreal tick = (mEndTime - mStartTime)/mPixelWidth;
|
||||
QFont font;
|
||||
|
||||
mRulerPixmap->fill(Qt::white);
|
||||
QPainter *painter = new QPainter(mRulerPixmap);
|
||||
|
||||
font.setPixelSize(12);
|
||||
painter->setFont(font);
|
||||
for(int i = 0; i <= RULER_NB_TICKS; i++)
|
||||
{
|
||||
QLine line;
|
||||
if(i%20 == 0)
|
||||
{
|
||||
TimeText.clear();
|
||||
line.setLine(x,0,x,10); //long line
|
||||
|
||||
TextRect.moveCenter(QPoint(x,15));
|
||||
if(i == 0)
|
||||
TextRect.moveLeft(x);
|
||||
else if(i == RULER_NB_TICKS)
|
||||
TextRect.moveRight(x);
|
||||
|
||||
|
||||
qreal time = (x*tick) + mStartTime;
|
||||
|
||||
if(time < 1000)
|
||||
{
|
||||
QTextStream(&TimeText) << time << " ns";
|
||||
}
|
||||
else
|
||||
{
|
||||
time /= 1000;
|
||||
if(time < 1000)
|
||||
{
|
||||
QTextStream(&TimeText) << time << " us";
|
||||
}
|
||||
else
|
||||
{
|
||||
time /= 1000;
|
||||
if(time < 1000)
|
||||
{
|
||||
QTextStream(&TimeText) << time << " ms";
|
||||
}
|
||||
else
|
||||
{
|
||||
time /= 1000;
|
||||
if(time < 1000)
|
||||
{
|
||||
QTextStream(&TimeText) << time << " s";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
painter->drawText(TextRect,Qt::AlignLeft | Qt::AlignVCenter,TimeText);
|
||||
else if(i == RULER_NB_TICKS)
|
||||
painter->drawText(TextRect,Qt::AlignRight | Qt::AlignVCenter,TimeText);
|
||||
else
|
||||
painter->drawText(TextRect,Qt::AlignCenter,TimeText);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
line.setLine(x,0,x,5);
|
||||
}
|
||||
painter->drawLine(line);
|
||||
x += mPixelPitch;
|
||||
}
|
||||
|
||||
delete painter;
|
||||
|
||||
}
|
||||
|
||||
void CGraphRulerWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
delete mRulerPixmap;
|
||||
mRulerPixmap = new QPixmap(mPixelWidth,boundingRect().height()+1);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131030 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef GRAPHRULERWIDGET_H
|
||||
#define GRAPHRULERWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
#define RULER_NB_TICKS 200
|
||||
|
||||
class CGraphRulerWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CGraphRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||
~CGraphRulerWidget();
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
private:
|
||||
qreal mPixelWidth;
|
||||
quint64 mStartTime, mEndTime;
|
||||
qreal mPixelPitch;
|
||||
|
||||
QPixmap *mRulerPixmap;
|
||||
|
||||
void Render();
|
||||
};
|
||||
|
||||
#endif // GRAPHRULERWIDGET_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe de base d'une page de l'interface graphique (GUI = Graphics User Interface).
|
||||
Une page contient les éléments graphiques affichés à l'écran.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121220 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "Guipage.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
|
||||
CGuiPage::CGuiPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGuiPage::ShowPage()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 201212120 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef GUIPAGE_H
|
||||
#define GUIPAGE_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QTimeLine>
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
class CGuiPage : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
CGuiPage();
|
||||
|
||||
virtual void ShowPage();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // GUIPAGE_H
|
||||
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Affiche un bitmap d'une DEL verte (allumée ou éteinte).
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
|
||||
#include "LedWidget.h"
|
||||
#include <QFontMetrics>
|
||||
|
||||
CLedWidget::CLedWidget(QString Label,QGraphicsItem *Parent)
|
||||
{
|
||||
|
||||
setParentItem(Parent);
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
mLedOnPixmap = new QGraphicsPixmapItem(this);
|
||||
mLedONImage.load("./Images/green-led-on-md.png");
|
||||
|
||||
mLedOffPixmap = new QGraphicsPixmapItem(this);
|
||||
mLedOFFImage.load("./Images/green-led-off-md.png");
|
||||
|
||||
mLabel->setPlainText(Label);
|
||||
mLabel->adjustSize();
|
||||
|
||||
LedOFF();
|
||||
|
||||
resize(25,25);
|
||||
|
||||
}
|
||||
|
||||
void CLedWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
mLedOnPixmap->setPixmap(QPixmap().fromImage(mLedONImage).scaled(boundingRect().width(),boundingRect().height()));
|
||||
mLedOffPixmap->setPixmap(QPixmap().fromImage(mLedOFFImage).scaled(boundingRect().width(),boundingRect().height()));
|
||||
mLabel->setPos((boundingRect().width()/2) - ((QFontMetrics(mLabel->font()).width(mLabel->toPlainText()))/2),boundingRect().height());
|
||||
}
|
||||
|
||||
void CLedWidget::LedOFF()
|
||||
{
|
||||
mLedOnPixmap->hide();
|
||||
mLedOffPixmap->show();
|
||||
}
|
||||
|
||||
void CLedWidget::LedON()
|
||||
{
|
||||
mLedOnPixmap->show();
|
||||
mLedOffPixmap->hide();
|
||||
}
|
||||
|
||||
void CLedWidget::SetLed(bool ON)
|
||||
{
|
||||
if(ON == true)
|
||||
LedON();
|
||||
else
|
||||
LedOFF();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef LEDWIDGET_H
|
||||
#define LEDWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class CLedWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CLedWidget(QString Label,QGraphicsItem *Parent = 0);
|
||||
|
||||
QGraphicsTextItem *mLabel;
|
||||
QImage mLedONImage,mLedOFFImage;
|
||||
QGraphicsPixmapItem *mLedOnPixmap,*mLedOffPixmap;
|
||||
|
||||
void LedON();
|
||||
void LedOFF();
|
||||
void SetLed(bool ON);
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
};
|
||||
|
||||
#endif // LEDWIDGET_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,204 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef LOGVIEWPAGE_H
|
||||
#define LOGVIEWPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "TextButtonWidget.h"
|
||||
#include "LogMgr.h"
|
||||
#include <QTableWidget>
|
||||
#include "GraphItem.h"
|
||||
//#include "qcustomplot.h"
|
||||
#include "GraphCursorWidget.h"
|
||||
#include "GraphRulerWidget.h"
|
||||
#include "AnalogGraphItem.h"
|
||||
#include "RankRulerWidget.h"
|
||||
#include "EventsRulerWidget.h"
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#define GRAPH_ZONE_WIDTH 880//900
|
||||
#define GRAPH_ZONE_HEIGHT 700
|
||||
#define GRAPH_ZONE_X_OFFSET 70 //50
|
||||
#define MIN_TIMESPAN 1000 //1 millisecond
|
||||
|
||||
#define ZOOM_TICK 10
|
||||
#define SCROLL_TICK 1
|
||||
#define ZOOM_CENTERED_ON_CURSOR
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
enum eZT1DiscreetPlottableParamID
|
||||
{
|
||||
ZT1_DISCREET_PLOTTABLE_S1_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_S2_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_PPINT_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_PPEXT_PARAM,
|
||||
//ZT1_DISCREET_PLOTTABLE_PG_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_FN_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_CI_PARAM,
|
||||
ZT1_DISCREET_PLOTTABLE_ZT1_CDV_PARAM,
|
||||
|
||||
ZT1_DISCREET_PLOTTABLE_NB_PARAM
|
||||
};
|
||||
|
||||
enum eZT1AnalogPlottableParamID
|
||||
{
|
||||
ZT1_ANALOG_PLOTTABLE_PGINT_PARAM,
|
||||
ZT1_ANALOG_PLOTTABLE_PGEXT_PARAM,
|
||||
ZT1_ANALOG_PLOTTABLE_PGCOMBINED_PARAM,
|
||||
ZT1_ANALOG_PLOTTABLE_TRAIN_SPEED_PARAM,
|
||||
ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM,
|
||||
|
||||
|
||||
ZT1_ANALOG_PLOTTABLE_NB_PARAM
|
||||
};
|
||||
|
||||
enum eZT2DiscreetPlottableParamID
|
||||
{
|
||||
ZT2_DISCREET_PLOTTABLE_S1_PARAM,
|
||||
ZT2_DISCREET_PLOTTABLE_PPEXT_PARAM,
|
||||
ZT2_DISCREET_PLOTTABLE_PPINT_PARAM,
|
||||
ZT2_DISCREET_PLOTTABLE_CI_PARAM,
|
||||
ZT2_DISCREET_PLOTTABLE_APPROACH_CDV_PARAM,
|
||||
ZT2_DISCREET_PLOTTABLE_CDV_PARAM,
|
||||
|
||||
ZT2_DISCREET_PLOTTABLE_NB_PARAM
|
||||
};
|
||||
|
||||
enum eZT2AnalogPlottableParamID
|
||||
{
|
||||
ZT2_ANALOG_PLOTTABLE_NB_PARAM
|
||||
};
|
||||
|
||||
|
||||
class CDiscreetPlottableItem
|
||||
{
|
||||
public:
|
||||
unsigned int mParamID;
|
||||
QList<CGraphDiscreteDataPair*> *mDataSet;
|
||||
CGraphItem *mPlotGaph;
|
||||
};
|
||||
|
||||
class CAnalogPlottableItem
|
||||
{
|
||||
public:
|
||||
unsigned int mParamID;
|
||||
QList<CGraphAnalogDataPair*> *mDataSet;
|
||||
CAnalogGraphItem *mPlotGaph;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CLogViewPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CLogViewPage(QGraphicsWidget *Parent = 0);
|
||||
~CLogViewPage();
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
CLogElement *mLogElement;
|
||||
CDiscreetPlottableItem mZT1DiscreetPlots[ZT1_DISCREET_PLOTTABLE_NB_PARAM];
|
||||
CAnalogPlottableItem mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_NB_PARAM];
|
||||
CDiscreetPlottableItem mZT2DiscreetPlots[ZT2_DISCREET_PLOTTABLE_NB_PARAM];
|
||||
|
||||
void SetLogData(CLogElement *element);
|
||||
void DestroyData();
|
||||
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton;
|
||||
CTextButtonWidget *mCursorsZoomButton, *mZoomInButton, *mZoomOutButton, *mZoomResetButton;
|
||||
int mZoomValue;
|
||||
quint64 mStartTime, mStopTime;
|
||||
quint64 mCurTimeSpan;
|
||||
quint64 mTotalTimeSpan;
|
||||
quint64 mMinTime, mMaxTime;
|
||||
qreal mCurPixelTickValue;
|
||||
qint32 mPGTreshold;
|
||||
CVerticalGraphCursorWidget *mStaticCursor1, *mStaticCursor2, *mVCursor;
|
||||
CHorizontalGraphCursorWidget *mHCursor;
|
||||
QGraphicsTextItem *mCursorPosTxt;
|
||||
QGraphicsTextItem *mStaticCursorDeltaTimeTxt, *mCursor1TimeTxt, *mCursor2TimeTxt;
|
||||
QGraphicsTextItem *mPassageStats1Txt,*mPassageStats2Txt;
|
||||
QString mPassageDateTime, mPassageStation;
|
||||
|
||||
CGraphRulerWidget *mRuler;
|
||||
CRankRulerWidget *mRankRuler;
|
||||
CEventRulerWidget *mEventRuler;
|
||||
unsigned int mViewType;
|
||||
|
||||
int mStaticCursor1Pos, mStaticCursor2Pos;
|
||||
int mCursorPos;
|
||||
|
||||
bool mMouseDragging;
|
||||
bool mMouseMoved;
|
||||
bool mCtrlKeyDown;
|
||||
bool mShiftKeyDown;
|
||||
|
||||
QElapsedTimer mScrollRefreshTimer;
|
||||
|
||||
void SetZoom(int ZoomValue);
|
||||
void ZoomIn(bool CenterOnCursor = true);
|
||||
void ZoomOut(bool CenterOnCursor = true);
|
||||
void ScrollGraphs(qint64 Delta);
|
||||
quint64 GetTimeForPixel(qreal PixelPos);
|
||||
qreal GetPixelForTime(quint64 Time);
|
||||
unsigned int ShowSpan(qreal PixelPos1, qreal PixelPos2);
|
||||
unsigned int ShowSpan(quint64 TimePos1, quint64 TimePos2);
|
||||
unsigned int AdjustStaticCursorsPos();
|
||||
unsigned int AdjustMouseCursorPos(qreal PosX, qreal PosY);
|
||||
unsigned int UpdateStaticCursorsDeltaTime();
|
||||
void ShowPlots(unsigned int ViewType);
|
||||
void DragPlots(qreal DragValue);
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGVIEWPAGE_H
|
||||
@@ -0,0 +1,857 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page affichant la liste des passages de train.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "LogsListPage.h"
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include "Zonetest.h"
|
||||
#include "TrainLogFileMgr.h"
|
||||
#include <QString>
|
||||
#include "ZTLog.h"
|
||||
|
||||
|
||||
CLogsListPage::~CLogsListPage()
|
||||
{
|
||||
// delete mListParsingTimer;
|
||||
delete mLogArchiverThread;
|
||||
delete mLogArchiverWorkerThread;
|
||||
}
|
||||
|
||||
CLogsListPage::CLogsListPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mProgramHandle = 0;
|
||||
mUSBDetected = false;
|
||||
mShowZT1Items = mShowZT2Items = mShowNoDetections = true;
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Fermer");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(810,550);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mLogsTable = new QTableWidget(0,3);
|
||||
QGraphicsProxyWidget *TableProxy = new QGraphicsProxyWidget(this);
|
||||
TableProxy->setWidget(mLogsTable);
|
||||
TableProxy->setPos(3,20);
|
||||
TableProxy->resize(300,550);
|
||||
mLogsTable->resize(300,550);
|
||||
mLogsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
mLogsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
mLogsTable->setHorizontalHeaderLabels(QStringList() << "Date du passage" << "Décl." << "Type");
|
||||
// connect(mLogsTable,SIGNAL(cellClicked(int,int)),this,SLOT(LogsTableCellClicked(int,int)));
|
||||
connect(mLogsTable,SIGNAL(cellDoubleClicked(int,int)),SLOT(TableDoubleClicked(int,int)));
|
||||
//connect(mLogsTable,SIGNAL(currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)),this,SLOT(TableCurItemChanged(QTableWidgetItem*,QTableWidgetItem*)));
|
||||
connect(mLogsTable,SIGNAL(itemSelectionChanged()),this,SLOT(LogsTableCellSelected(/*int,int*/)));
|
||||
|
||||
|
||||
mSummaryText = new QGraphicsTextItem(this);
|
||||
QFont textfont;
|
||||
textfont.setPointSize(12);
|
||||
mSummaryText->setFont(textfont);
|
||||
mSummaryText->setPlainText("Statistiques du passage:");
|
||||
mSummaryText->setPos(350,20);
|
||||
|
||||
QGraphicsProxyWidget *CheckBoxProxy = new QGraphicsProxyWidget(this);
|
||||
mShowZT1ItemsChkBx = new QCheckBox("Masquer ZT1");
|
||||
CheckBoxProxy->setWidget(mShowZT1ItemsChkBx);
|
||||
CheckBoxProxy->setPos(320,550);
|
||||
mShowZT1ItemsChkBx->setChecked(false);
|
||||
connect(mShowZT1ItemsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||
|
||||
CheckBoxProxy = new QGraphicsProxyWidget(this);
|
||||
mShowZT2ItemsChkBx = new QCheckBox("Masquer ZT2");
|
||||
CheckBoxProxy->setWidget(mShowZT2ItemsChkBx);
|
||||
//CheckBoxProxy->setPos(410,550);
|
||||
CheckBoxProxy->setPos(320,570);
|
||||
mShowZT2ItemsChkBx->setChecked(false);
|
||||
connect(mShowZT2ItemsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||
|
||||
CheckBoxProxy = new QGraphicsProxyWidget(this);
|
||||
mShowNoDetectionsChkBx = new QCheckBox("Seulement\ndéclenchements");
|
||||
CheckBoxProxy->setWidget(mShowNoDetectionsChkBx);
|
||||
CheckBoxProxy->setPos(450,550);
|
||||
mShowNoDetectionsChkBx->setChecked(false);
|
||||
connect(mShowNoDetectionsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||
|
||||
mListParsingTimer = new QTimer();
|
||||
connect(mListParsingTimer,SIGNAL(timeout()),this,SLOT(ParsingTimerExipred()));
|
||||
|
||||
mUSBRefreshTimer = new QTimer();
|
||||
mUSBRefreshTimer->setSingleShot(false);
|
||||
connect(mUSBRefreshTimer,SIGNAL(timeout()),this,SLOT(CheckUSBKey()));
|
||||
|
||||
QGraphicsRectItem *Frame = new QGraphicsRectItem(650,50,200,80,this);
|
||||
QPen FramePen;
|
||||
FramePen.setWidth(3);
|
||||
Frame->setPen(FramePen);
|
||||
|
||||
QGraphicsTextItem *Label = new QGraphicsTextItem(this);
|
||||
Label->setPlainText("Sélection");
|
||||
Label->setPos(650,25);
|
||||
Label->setFont(textfont);
|
||||
|
||||
mViewLogDataButton = new CTextButtonWidget("Voir");
|
||||
mViewLogDataButton->setParentItem(this);
|
||||
mViewLogDataButton->setPos(730,60);
|
||||
connect(mViewLogDataButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mExportCSVLogButton = new CTextButtonWidget("Générer CSV");
|
||||
mExportCSVLogButton->setParentItem(this);
|
||||
mExportCSVLogButton->setPos(700,95);
|
||||
connect(mExportCSVLogButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
mExportCSVLogButton->hide();
|
||||
|
||||
Label = new QGraphicsTextItem(this);
|
||||
Label->setPlainText("Sauvegarde des passages");
|
||||
Label->setPos(650,150);
|
||||
Label->setFont(textfont);
|
||||
|
||||
Frame = new QGraphicsRectItem(650,175,200,80,this);
|
||||
Frame->setPen(FramePen);
|
||||
|
||||
mArchiveFilesButton = new CTextButtonWidget("Archiver tout");
|
||||
mArchiveFilesButton->setParentItem(this);
|
||||
mArchiveFilesButton->setPos(700,185);
|
||||
connect(mArchiveFilesButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
mArchiveFilesButton->hide();
|
||||
|
||||
mEraseFilesCheckbox = new QCheckBox("Conserver les passages");
|
||||
CheckBoxProxy = new QGraphicsProxyWidget(this);
|
||||
CheckBoxProxy->setWidget(mEraseFilesCheckbox);
|
||||
CheckBoxProxy->setPos(660,220);
|
||||
mEraseFilesCheckbox->hide();
|
||||
|
||||
|
||||
mInsertUSBKeyText = new QGraphicsTextItem("Veuillez insérer\nune clef USB",this);
|
||||
mInsertUSBKeyText->setPos(675,190);
|
||||
mInsertUSBKeyText->setFont(textfont);
|
||||
|
||||
mLogArchiverWorkerThread = new CLogFileArchiverThread();
|
||||
mLogArchiverThread = new QThread();
|
||||
mLogArchiverWorkerThread->moveToThread(mLogArchiverThread);
|
||||
connect(mLogArchiverThread,SIGNAL(started()),mLogArchiverWorkerThread,SLOT(ArchiveLogs()));
|
||||
connect(mLogArchiverWorkerThread,SIGNAL(LogArchivingFinished()),this,SLOT(LogsArchivingFinished()));
|
||||
|
||||
}
|
||||
|
||||
unsigned int CLogsListPage::ArchiveAllFiles()
|
||||
{
|
||||
// QString PathName = mUSBDrivePtr->GetDrivePath();
|
||||
// PathName += "/ArchiveLogZT_";
|
||||
// PathName += mProgramHandle->GetStationShortName();
|
||||
// PathName += QDateTime::currentDateTime().toString("_yyyyMMdd");
|
||||
// QDir TargetDir(PathName);
|
||||
|
||||
// TargetDir.mkdir(PathName); //If the directory does not exist, it will be created.
|
||||
|
||||
// //copy files
|
||||
// QStringList LogFilters;
|
||||
// LogFilters << "*.bin" << "*.csv";
|
||||
// QDir LogDir("./Trains/");
|
||||
|
||||
// int NbFiles = 0;
|
||||
// LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
// LogDir.setNameFilters(LogFilters);
|
||||
// LogDir.setSorting(QDir::Name);
|
||||
// for(int i = 0; i < LogDir.entryInfoList().size(); i++)
|
||||
// {
|
||||
// QString DestFileName = PathName;
|
||||
// DestFileName += "/";
|
||||
// DestFileName += LogDir.entryInfoList().at(i).fileName();
|
||||
// if(QFile::copy(LogDir.entryInfoList().at(i).absoluteFilePath(),DestFileName))
|
||||
// {
|
||||
// NbFiles++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //Copy the ZTLog file each time.
|
||||
// QString DestFileName = PathName;
|
||||
// DestFileName += "/ZTLog.txt";
|
||||
// CZTLog::instance()->CopyLogFile(DestFileName,true);
|
||||
|
||||
// system("sync");
|
||||
|
||||
// CZTLog::instance()->AddLogString(QString().sprintf("%d fichiers de passage archivés dans le répertoire %s",NbFiles,PathName.toUtf8().data()),true);
|
||||
|
||||
// if(mEraseFilesCheckbox->checkState() == Qt::Checked)
|
||||
// {
|
||||
// DeleteAllFiles();
|
||||
// system("sync");
|
||||
// mEraseFilesCheckbox->setChecked(false);
|
||||
// }
|
||||
|
||||
|
||||
mArchiveFilesButton->hide();
|
||||
mInsertUSBKeyText->setPlainText("Copie en cours\nN'enlevez pas la clef");
|
||||
mInsertUSBKeyText->show();
|
||||
mEraseFilesCheckbox->hide();
|
||||
|
||||
mLogArchiverWorkerThread->SetPathInfo(mUSBDrivePtr->GetDrivePath(),mProgramHandle->GetStationShortName());
|
||||
|
||||
QString PathName = mUSBDrivePtr->GetDrivePath();
|
||||
PathName += "/ArchiveLogZT_";
|
||||
PathName += mProgramHandle->GetStationShortName();
|
||||
PathName += QDateTime::currentDateTime().toString("_yyyyMMdd");
|
||||
QDir TargetDir(PathName);
|
||||
|
||||
TargetDir.mkdir(PathName); //If the directory does not exist, it will be created.
|
||||
|
||||
QString DestFileName = PathName;
|
||||
DestFileName += "/ZTLog.txt";
|
||||
CZTLog::instance()->CopyLogFile(DestFileName,true);
|
||||
|
||||
mLogArchiverThread->start();
|
||||
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogsListPage::DeleteAllFiles()
|
||||
{
|
||||
QStringList LogFilters;
|
||||
LogFilters << "*.bin" << "*.csv";
|
||||
QDir LogDir("./Trains/");
|
||||
|
||||
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
LogDir.setNameFilters(LogFilters);
|
||||
LogDir.setSorting(QDir::Name);
|
||||
|
||||
for(int i = 0; i < LogDir.entryInfoList().size(); i++)
|
||||
{
|
||||
QFile::remove(LogDir.entryInfoList().at(i).absoluteFilePath());
|
||||
}
|
||||
|
||||
CZTLog::instance()->AddLogString("Tous les fichiers de passages ont été effacés",true);
|
||||
|
||||
mLogMgrHandle->ParseLogs();
|
||||
RefreshList();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CLogsListPage::NewTrainLogFileSaved()
|
||||
{
|
||||
RefreshList(true);
|
||||
}
|
||||
|
||||
void CLogsListPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void CLogsListPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mCancelButton)
|
||||
{
|
||||
mSummaryText->setPlainText("Statistiques du passage:");
|
||||
hide();
|
||||
}
|
||||
else if(BtnPtr == mViewLogDataButton)
|
||||
{
|
||||
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||
return;
|
||||
|
||||
//int cursel = mLogsTable->currentItem()->data(Qt::UserRole).toInt();
|
||||
int cursel = GetCurSelectedItemIndexInTable();
|
||||
if(cursel == -1)
|
||||
return;
|
||||
|
||||
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||
//qDebug("Sel: %d, Type : %d",cursel,Element->mZTLogType);
|
||||
mProgramHandle->LogViewRequest(mLogMgrHandle->LoadLogData(Element));
|
||||
mLogMgrHandle->FreeLogData(Element);
|
||||
|
||||
|
||||
}
|
||||
else if(BtnPtr == mExportCSVLogButton)
|
||||
{
|
||||
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||
return;
|
||||
|
||||
QString Filename;
|
||||
//int cursel = mLogsTable->currentItem()->data(Qt::UserRole).toInt();
|
||||
int cursel = GetCurSelectedItemIndexInTable();
|
||||
if(cursel == -1)
|
||||
return;
|
||||
|
||||
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||
mLogMgrHandle->LoadLogData(Element);
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||
Filename = temp->mLogFileName.replace("bin","csv");
|
||||
CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mFlags,&temp->mZTDetections,temp->mStationName);
|
||||
}
|
||||
else
|
||||
{
|
||||
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||
Filename = temp->mLogFileName.replace("bin","csv");
|
||||
CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mZTDetections,temp->mStationName);
|
||||
}
|
||||
mLogMgrHandle->FreeLogData(Element);
|
||||
}
|
||||
else if(BtnPtr == mArchiveFilesButton)
|
||||
{
|
||||
ArchiveAllFiles();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CLogsListPage::BindPointers(CUSBDriveInterface *USBDriveIF)
|
||||
{
|
||||
mUSBDrivePtr = USBDriveIF;
|
||||
mUSBRefreshTimer->start(1000);
|
||||
mLogArchiverWorkerThread->mLogMgrHandle = mLogMgrHandle;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CLogsListPage::RefreshList(bool KeepSelectedCell)
|
||||
{
|
||||
|
||||
QString SelectedCellText;
|
||||
if(KeepSelectedCell == true)
|
||||
{
|
||||
|
||||
QList<QTableWidgetItem*> list = mLogsTable->selectedItems();
|
||||
|
||||
if(list.size() == 0)
|
||||
{
|
||||
KeepSelectedCell = false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if(list.at(i)->column() == 0)
|
||||
{
|
||||
SelectedCellText = list.at(i)->text();
|
||||
qDebug("Selected cell text: %s",SelectedCellText.toAscii().data());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ClearTable();
|
||||
|
||||
mShowZT1Items = (mShowZT1ItemsChkBx->checkState() == Qt::Unchecked);
|
||||
mShowZT2Items = (mShowZT2ItemsChkBx->checkState() == Qt::Unchecked);
|
||||
mShowNoDetections = (mShowNoDetectionsChkBx->checkState() == Qt::Unchecked);
|
||||
|
||||
mLogsTable->setRowCount(mLogMgrHandle->GetLogsCount());
|
||||
|
||||
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||
return RET_OK;
|
||||
|
||||
int CurRow = 0;
|
||||
|
||||
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||
for(unsigned int i = 0; i < mLogMgrHandle->GetLogsCount(); i++)
|
||||
{
|
||||
if(LogsList->at(i)->mZTLogType == ZT1_LOG_TYPE && mShowZT1Items == true)
|
||||
{
|
||||
CZT1LogElement *ZT1LogElement = (CZT1LogElement*)LogsList->at(i);
|
||||
|
||||
int NbDetections = ZT1LogElement->mZTDetections.size();
|
||||
if(mShowNoDetections == false && NbDetections == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||
QVariant ID(QVariant::Int);
|
||||
ID.setValue(i);
|
||||
NewItem->setData(Qt::UserRole,ID);
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,1,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,2,NewItem);
|
||||
|
||||
CurRow++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(LogsList->at(i)->mZTLogType == ZT2_LOG_TYPE && mShowZT2Items == true)
|
||||
{
|
||||
CZT2LogElement *ZT2LogElement = (CZT2LogElement*)LogsList->at(i);
|
||||
|
||||
int NbDetections = ZT2LogElement->mZTDetections.size();
|
||||
if(mShowNoDetections == false && NbDetections == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||
QVariant ID(QVariant::Int);
|
||||
ID.setValue(i);
|
||||
NewItem->setData(Qt::UserRole,ID);
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,1,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,2,NewItem);
|
||||
|
||||
CurRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mLogsTable->setRowCount(CurRow);
|
||||
|
||||
mLogsTable->setColumnWidth(0,150);
|
||||
mLogsTable->setColumnWidth(1,50);
|
||||
mLogsTable->setColumnWidth(2,50);
|
||||
|
||||
mLogsTable->sortItems(0,Qt::DescendingOrder);
|
||||
|
||||
if(KeepSelectedCell == true)
|
||||
{
|
||||
QList<QTableWidgetItem *> Items = mLogsTable->findItems(SelectedCellText,Qt::MatchFixedString);
|
||||
if(Items.size() != 0)
|
||||
{
|
||||
mLogsTable->setCurrentCell(Items.at(0)->row(),0);
|
||||
qDebug("Found cell text: %s",Items.at(0)->text().toAscii().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
mLogsTable->setCurrentCell(0,0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
mLogsTable->setCurrentCell(0,0);
|
||||
}
|
||||
// LogsTableCellClicked(0,0);
|
||||
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
void CLogsListPage::ClearTable()
|
||||
{
|
||||
for(int Col = 0; Col < mLogsTable->columnCount(); Col++)
|
||||
{
|
||||
for(int Row = 0; Row < mLogsTable->rowCount(); Row++)
|
||||
{
|
||||
delete mLogsTable->item(Row,Col);
|
||||
}
|
||||
}
|
||||
mLogsTable->clearContents();
|
||||
mLogsTable->setRowCount(0);
|
||||
}
|
||||
|
||||
//void CLogsListPage::LogsTableCellClicked(int row, int column)
|
||||
//{
|
||||
// return;
|
||||
// Q_UNUSED(column);
|
||||
// Q_UNUSED(row);
|
||||
|
||||
//// int rowcount = mLogsTable->rowCount();
|
||||
//// if(rowcount == 0)
|
||||
//// return;
|
||||
|
||||
////// qDebug("Selection : %d",row);
|
||||
//// QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||
|
||||
//// float MeanSpeed = 0.0;
|
||||
//// QString Summary;
|
||||
//// int ItemIndex = mLogsTable->item(row,0)->data(Qt::UserRole).toInt();
|
||||
//// ShowItemSummary(LogsList->at(ItemIndex));
|
||||
//}
|
||||
|
||||
void CLogsListPage::ShowItemSummary(CLogElement *Element)
|
||||
{
|
||||
float MeanSpeed;
|
||||
QString Summary;
|
||||
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||
{
|
||||
// //CZT1LogElement *ZT1LogElement = (CZT1LogElement*) LogsList->at(row);
|
||||
CZT1LogElement *ZT1LogElement = (CZT1LogElement*) Element;
|
||||
|
||||
MeanSpeed = ZT1LogElement->mMeanSpeed;
|
||||
QString Problem = "Non";
|
||||
if(ZT1LogElement->mFlags.mIsProblematicPassage == 1)
|
||||
{
|
||||
Problem = "Oui";
|
||||
}
|
||||
|
||||
|
||||
Summary.sprintf("Statistiques du passage:\n\nDate: %s\nHeure: %s\nTrain : %s\nNombre d'éléments: %d\nVitesse moyenne : %f mph\nPassage problématique: %s\n\nDéclenchements: \n",
|
||||
ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||
ZT1LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||
CZTData::GetTrainTypeString(ZT1LogElement->mTrainType),
|
||||
ZT1LogElement->mNbElements,
|
||||
MeanSpeed,
|
||||
Problem.toUtf8().data());
|
||||
|
||||
if(ZT1LogElement->mZTDetections.size() > 0)
|
||||
{
|
||||
for(int i = 0; i < ZT1LogElement->mZTDetections.size(); i++)
|
||||
{
|
||||
QString temp;
|
||||
if(ZT1LogElement->mZTDetections.at(i)->mDetectionID == DETECTION_FN_DETECTION)
|
||||
{
|
||||
temp.sprintf("%s au bogie %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||
}
|
||||
Summary += temp;
|
||||
if(i >= MAX_DETECTION_LIST_NBR - 1)
|
||||
{
|
||||
temp = " -- Autres déclenchements non affichés --";
|
||||
Summary += temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
Summary += "Aucun déclenchement";
|
||||
}
|
||||
//else if(LogsList->at(row)->mZTLogType == ZT2_LOG_TYPE)
|
||||
else if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||
{
|
||||
//CZT2LogElement *ZT2LogElement = (CZT2LogElement*) LogsList->at(row);
|
||||
CZT2LogElement *ZT2LogElement = (CZT2LogElement*) Element;
|
||||
QString Problem = "Non";
|
||||
if(ZT2LogElement->mFlags.mIsProblematicPassage == 1)
|
||||
{
|
||||
Problem = "Oui";
|
||||
}
|
||||
|
||||
Summary.sprintf("Statistiques du passage:\n\nDate: %s\nHeure: %s\nNombre d'éléments: %d\nPassage problématique: %s\n\n\n\nDéclenchements: \n",
|
||||
ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||
ZT2LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||
ZT2LogElement->mNbElements,
|
||||
Problem.toUtf8().data());
|
||||
|
||||
if(ZT2LogElement->mZTDetections.size() > 0)
|
||||
{
|
||||
for(int i = 0; i < ZT2LogElement->mZTDetections.size(); i++)
|
||||
{
|
||||
QString temp;
|
||||
temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT2LogElement->mZTDetections.at(i)->mDetectionID),ZT2LogElement->mZTDetections.at(i)->mRank);
|
||||
Summary += temp;
|
||||
if(i >= MAX_DETECTION_LIST_NBR-1)
|
||||
{
|
||||
temp = " -- Autres déclenchements non affichés --";
|
||||
Summary += temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
Summary += "Aucun déclenchement";
|
||||
|
||||
}
|
||||
mSummaryText->setPlainText(Summary);
|
||||
}
|
||||
|
||||
void CLogsListPage::ParsingTimerExipred()
|
||||
{
|
||||
if(mLogMgrHandle->ParseNextLog() == false)
|
||||
{
|
||||
mListParsingTimer->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
int CurRow = mLogsTable->rowCount();
|
||||
mLogsTable->setRowCount(CurRow+1);
|
||||
|
||||
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||
//for(unsigned int i = 0; i < mLogMgrHandle->GetLogsCount(); i++)
|
||||
{
|
||||
if(LogsList->last()->mZTLogType == ZT1_LOG_TYPE && mShowZT1Items == true)
|
||||
{
|
||||
CZT1LogElement *ZT1LogElement = (CZT1LogElement*)LogsList->last();
|
||||
|
||||
int NbDetections = ZT1LogElement->mZTDetections.size();
|
||||
if(mShowNoDetections == false && NbDetections == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||
NewItem->setData(Qt::UserRole,QVariant(LogsList->size()-1));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,1,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,2,NewItem);
|
||||
}
|
||||
}
|
||||
else if(LogsList->last()->mZTLogType == ZT2_LOG_TYPE && mShowZT2Items == true)
|
||||
{
|
||||
CZT2LogElement *ZT2LogElement = (CZT2LogElement*)LogsList->last();
|
||||
|
||||
int NbDetections = ZT2LogElement->mZTDetections.size();
|
||||
if(mShowNoDetections == false && NbDetections == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||
NewItem->setData(Qt::UserRole,QVariant(LogsList->size()-1));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,1,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
mLogsTable->setItem(CurRow,2,NewItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mLogsTable->setRowCount(CurRow+1);
|
||||
|
||||
mLogsTable->setColumnWidth(0,150);
|
||||
mLogsTable->setColumnWidth(1,50);
|
||||
mLogsTable->setColumnWidth(2,50);
|
||||
|
||||
|
||||
mLogsTable->sortItems(0);
|
||||
|
||||
mListParsingTimer->start(20);
|
||||
|
||||
// mLogsTable->setCurrentCell(0,0);
|
||||
// LogsTableCellClicked(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
void CLogsListPage::CheckUSBKey()
|
||||
{
|
||||
if(mUSBDrivePtr->IsDriveDetected() != mUSBDetected)
|
||||
{
|
||||
mUSBDetected = mUSBDrivePtr->IsDriveDetected();
|
||||
|
||||
if(mUSBDetected == true)
|
||||
{
|
||||
mInsertUSBKeyText->hide();
|
||||
mArchiveFilesButton->show();
|
||||
mEraseFilesCheckbox->setCheckState(Qt::Unchecked);
|
||||
mEraseFilesCheckbox->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
mInsertUSBKeyText->setPlainText("Veuillez insérer\nune clef USB");
|
||||
mInsertUSBKeyText->show();
|
||||
mArchiveFilesButton->hide();
|
||||
mEraseFilesCheckbox->hide();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void CLogsListPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CLogsListPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CLogsListPage::CheckBoxClicked(int state)
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
RefreshList();
|
||||
}
|
||||
|
||||
void CLogsListPage::TableDoubleClicked(int row, int col)
|
||||
{
|
||||
Q_UNUSED(col)
|
||||
Q_UNUSED(row)
|
||||
ButtonClicked(mViewLogDataButton);
|
||||
}
|
||||
//void CLogsListPage::TableCurItemChanged(QTableWidgetItem *Current, QTableWidgetItem *Prev)
|
||||
//{
|
||||
// int rowcount = mLogsTable->rowCount();
|
||||
// if(rowcount == 0)
|
||||
// return;
|
||||
|
||||
// if(Prev == Current)
|
||||
// return;
|
||||
|
||||
// QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||
// int Selection = Current->data(Qt::UserRole).toInt();
|
||||
// CLogElement *SelectedElement = LogsList->at(Selection);
|
||||
// ShowItemSummary(SelectedElement);
|
||||
//// qDebug("Changed %d",Selection);
|
||||
|
||||
//}
|
||||
|
||||
void CLogsListPage::LogsTableCellSelected(/*int row, int col*/)
|
||||
{
|
||||
int Selection = GetCurSelectedItemIndexInTable();
|
||||
|
||||
if(Selection == -1)
|
||||
return;
|
||||
|
||||
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||
CLogElement *SelectedElement = LogsList->at(Selection);
|
||||
ShowItemSummary(SelectedElement);
|
||||
}
|
||||
|
||||
int CLogsListPage::GetCurSelectedItemIndexInTable()
|
||||
{
|
||||
QList<QTableWidgetItem*> list = mLogsTable->selectedItems();
|
||||
|
||||
if(list.size() == 0)
|
||||
return - 1;
|
||||
|
||||
int Selection = -1;
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if(list.at(i)->column() == 0)
|
||||
{
|
||||
Selection = list.at(i)->data(Qt::UserRole).toInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Selection;
|
||||
}
|
||||
|
||||
void CLogsListPage::LogsArchivingFinished()
|
||||
{
|
||||
|
||||
// CZTLog::instance()->DeleteLogFile();
|
||||
|
||||
if(mEraseFilesCheckbox->checkState() == Qt::Unchecked)
|
||||
{
|
||||
mLogMgrHandle->DeleteErrorLogs();
|
||||
}
|
||||
|
||||
//The "sync" command has been moved in the thread instead of pausing the watchdog...
|
||||
|
||||
// The file syncing can take a lot of time (the "sync" command syncs ALL of the file system).
|
||||
// So we must disable the watchdog to avoid a computer reboot.
|
||||
// mProgramHandle->PauseInternalWatchdog();
|
||||
// system("sync");
|
||||
// mProgramHandle->ResumeInternalWatchdog();
|
||||
|
||||
|
||||
RefreshList();
|
||||
mLogArchiverThread->quit();
|
||||
if(mEraseFilesCheckbox->checkState() == Qt::Unchecked)
|
||||
{
|
||||
mProgramHandle->ResetTriggerCount();
|
||||
mProgramHandle->ResetNbPassages();
|
||||
}
|
||||
mInsertUSBKeyText->hide();
|
||||
mArchiveFilesButton->show();
|
||||
mEraseFilesCheckbox->show();
|
||||
CZTLog::instance()->DeleteLogFile();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////// Thread implementation //////////////
|
||||
|
||||
CLogFileArchiverThread::CLogFileArchiverThread()
|
||||
{
|
||||
mDrivePath = "";
|
||||
}
|
||||
|
||||
void CLogFileArchiverThread::SetPathInfo(QString DrivePath,QString StationName)
|
||||
{
|
||||
mDrivePath = DrivePath;
|
||||
mStationName = StationName;
|
||||
}
|
||||
|
||||
void CLogFileArchiverThread::ArchiveLogs()
|
||||
{
|
||||
|
||||
QString PathName = mDrivePath;
|
||||
PathName += "/ArchiveLogZT_";
|
||||
PathName += mStationName;
|
||||
PathName += QDateTime::currentDateTime().toString("_yyyyMMdd");
|
||||
QDir TargetDir(PathName);
|
||||
|
||||
TargetDir.mkdir(PathName); //If the directory does not exist, it will be created.
|
||||
|
||||
//copy files
|
||||
QStringList LogFilters;
|
||||
LogFilters << "*.bin" << "*.csv";
|
||||
QDir LogDir("./Trains/");
|
||||
|
||||
int NbFiles = 0;
|
||||
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
LogDir.setNameFilters(LogFilters);
|
||||
LogDir.setSorting(QDir::Name);
|
||||
for(int i = 0; i < LogDir.entryInfoList().size(); i++)
|
||||
{
|
||||
QString DestFileName = PathName;
|
||||
DestFileName += "/";
|
||||
DestFileName += LogDir.entryInfoList().at(i).fileName();
|
||||
if(QFile::copy(LogDir.entryInfoList().at(i).absoluteFilePath(),DestFileName))
|
||||
{
|
||||
NbFiles++;
|
||||
}
|
||||
}
|
||||
|
||||
///JFM: Is it dangerous to access these from the thread ?
|
||||
// CZTLog::instance()->DeleteLogFile();
|
||||
// mLogMgrHandle->DeleteErrorLogs();
|
||||
/// Moved outside of threads
|
||||
|
||||
system("sync");
|
||||
|
||||
CZTLog::instance()->AddLogString(QString().sprintf("%d fichiers de passage archivés dans le répertoire %s",NbFiles,PathName.toUtf8().data()),true);
|
||||
|
||||
emit LogArchivingFinished();
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131024 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef LOGSLISTPAGE_H
|
||||
#define LOGSLISTPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "TextButtonWidget.h"
|
||||
#include "LogMgr.h"
|
||||
#include <QTableWidget>
|
||||
#include <QCheckBox>
|
||||
#include "USBDriveInterface.h"
|
||||
#include <QCheckBox>
|
||||
|
||||
#define MAX_DETECTION_LIST_NBR 7
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
|
||||
class CLogFileArchiverThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CLogFileArchiverThread();
|
||||
void SetPathInfo(QString DrivePath,QString StationName);
|
||||
|
||||
CLogMgr *mLogMgrHandle;
|
||||
|
||||
public slots:
|
||||
void ArchiveLogs();
|
||||
|
||||
private:
|
||||
|
||||
QString mDrivePath;
|
||||
QString mStationName;
|
||||
|
||||
|
||||
signals:
|
||||
void LogArchivingFinished();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CLogsListPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~CLogsListPage();
|
||||
CLogsListPage(QGraphicsWidget *Parent = 0);
|
||||
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
CLogMgr *mLogMgrHandle;
|
||||
|
||||
unsigned int RefreshList(bool KeepSelectedCell = false);
|
||||
unsigned int BindPointers(CUSBDriveInterface *USBDriveIF);
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton;
|
||||
QTableWidget *mLogsTable;
|
||||
QGraphicsTextItem *mSummaryText;
|
||||
CTextButtonWidget *mViewLogDataButton;
|
||||
CTextButtonWidget *mExportCSVLogButton;
|
||||
CTextButtonWidget *mArchiveFilesButton;
|
||||
QGraphicsTextItem *mInsertUSBKeyText;
|
||||
QCheckBox *mShowZT1ItemsChkBx, *mShowZT2ItemsChkBx, *mShowNoDetectionsChkBx, *mRemoveErrorLogsChkBx;
|
||||
QTimer *mListParsingTimer;
|
||||
CUSBDriveInterface *mUSBDrivePtr;
|
||||
QTimer *mUSBRefreshTimer;
|
||||
QCheckBox *mEraseFilesCheckbox;
|
||||
|
||||
CLogFileArchiverThread *mLogArchiverWorkerThread;
|
||||
QThread *mLogArchiverThread;
|
||||
|
||||
bool mShowZT1Items,mShowZT2Items,mShowNoDetections,mUSBDetected;
|
||||
|
||||
void ClearTable();
|
||||
unsigned int ArchiveAllFiles();
|
||||
unsigned int DeleteAllFiles();
|
||||
void ShowItemSummary(CLogElement*);
|
||||
int GetCurSelectedItemIndexInTable(void);
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
// void LogsTableCellClicked(int, int);
|
||||
void CheckBoxClicked(int);
|
||||
void TableDoubleClicked(int,int);
|
||||
void ParsingTimerExipred();
|
||||
void CheckUSBKey();
|
||||
void LogsArchivingFinished();
|
||||
// void TableCurItemChanged(QTableWidgetItem*,QTableWidgetItem*);
|
||||
void LogsTableCellSelected(/*int, int*/);
|
||||
void NewTrainLogFileSaved();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // LOGSLISTPAGE_H
|
||||
@@ -0,0 +1,457 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page offrant différentes option pour l'entretien de la ZT
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "MaintenancePage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include "Zonetest.h"
|
||||
#include <QDateTime>
|
||||
#include <QFont>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include "ZTData.h"
|
||||
#include <QMessageBox>
|
||||
#include "ZTLog.h"
|
||||
#include "ZTData.h"
|
||||
|
||||
|
||||
CMaintenancePage::CMaintenancePage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
|
||||
|
||||
mProgramHandle = 0;
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
QGraphicsTextItem *Title = new QGraphicsTextItem("Entretien de la Zone Tests",this);
|
||||
QFont font;
|
||||
font.setPointSize(18);
|
||||
Title->setFont(font);
|
||||
Title->setPos(40,10);
|
||||
|
||||
|
||||
mMaintenanceActivationBtn = new CToggleButtonWidget("./Images/Slider_Green.png","./Images/Slider_Red.png",this);
|
||||
mMaintenanceActivationBtn->setPos(45,65);
|
||||
mMaintenanceActivationBtn->resize(50,30);
|
||||
connect(mMaintenanceActivationBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ActivationBtnToggled(CToggleButtonWidget*)));
|
||||
|
||||
mWatchdogEnableBtn = new CToggleButtonWidget("./Images/Slider_Green.png","./Images/Slider_Red.png",this);
|
||||
mWatchdogEnableBtn->setPos(700,350);
|
||||
mWatchdogEnableBtn->resize(50,30);
|
||||
connect(mWatchdogEnableBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(WatchdogEnableBtnToggled(CToggleButtonWidget*)));
|
||||
|
||||
|
||||
Title = new QGraphicsTextItem("Activer mode entretien",this);
|
||||
font.setPointSize(16);
|
||||
Title->setFont(font);
|
||||
Title->setPos(100,60);
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Fermer");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(700,550);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mGenerateAlarmBtn = new CTextButtonWidget("Envoyer Alarme",0,30);
|
||||
mGenerateAlarmBtn->setParentItem(this);
|
||||
mGenerateAlarmBtn->setPos(540,170);
|
||||
connect(mGenerateAlarmBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mClearAlarmButton = new CTextButtonWidget("Acquitter Alarme",0,30);
|
||||
mClearAlarmButton->setParentItem(this);
|
||||
mClearAlarmButton->setPos(540,210);
|
||||
mClearAlarmButton->hide();
|
||||
connect(mClearAlarmButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||
mAlarmTypeList = new QComboBox();
|
||||
Proxy->setWidget(mAlarmTypeList);
|
||||
Proxy->setPos(100,200);
|
||||
QStringList AlarmTypes;
|
||||
AlarmTypes << "Erreur de comptage ZT1"
|
||||
<< "Détection Frotteur Négatif"
|
||||
<< "Détection Pneu de Guidage"
|
||||
<< "Détection Pneu Porteur Intérieur ZT1"
|
||||
<< "Détection Pneu Porteur Extérieur ZT1"
|
||||
<< "Erreur de comptage ZT2"
|
||||
<< "Détection Pneu Porteur Intérieur ZT2"
|
||||
<< "Détection Pneu Porteur Extérieur ZT2"
|
||||
<< "Panne Équipement ZT1"
|
||||
<< "Panne Équipement ZT2";
|
||||
|
||||
mAlarmTypeList->addItems(AlarmTypes);
|
||||
mAlarmTypeList->resize(300,30);
|
||||
connect(mAlarmTypeList,SIGNAL(currentIndexChanged(int)),this,SLOT(AlarmTypeSelectionChanged(int)));
|
||||
Proxy->setZValue(2);
|
||||
mAlarmDescription = new QGraphicsTextItem(this);
|
||||
mAlarmDescription->setPos(100,170);
|
||||
mAlarmDescription->setPlainText("Type d'alarme");
|
||||
|
||||
|
||||
Proxy = new QGraphicsProxyWidget(this);
|
||||
mAlarmRankSpinBox = new QSpinBox();
|
||||
Proxy->setWidget(mAlarmRankSpinBox);
|
||||
Proxy->setPos(420,200);
|
||||
mAlarmRankSpinBox->resize(100,30);
|
||||
mRankDescription = new QGraphicsTextItem(this);
|
||||
mRankDescription->setPos(420,170);
|
||||
mRankDescription->setPlainText("Rang");
|
||||
|
||||
QPen FramePen;
|
||||
FramePen.setWidth(3);
|
||||
|
||||
|
||||
mAlarmsFrame = new QGraphicsRectItem(80,120,650,130,this);
|
||||
mAlarmsFrame->setPen(FramePen);
|
||||
|
||||
mFctDescription = new QGraphicsTextItem(this);
|
||||
mFctDescription->setPos(200,120);
|
||||
mFctDescription->setPlainText("Génération d'alarmes au PCC");
|
||||
font.setPointSize(18);
|
||||
mFctDescription->setFont(font);
|
||||
|
||||
mWatchdogDisableDescription = new QGraphicsTextItem(this);
|
||||
mWatchdogDisableDescription->setPos(694,310);
|
||||
mWatchdogDisableDescription->setFont(font);
|
||||
mWatchdogDisableDescription->setPlainText("Vigie");
|
||||
|
||||
int yoffset = 30;
|
||||
|
||||
mPPFrame = new QGraphicsRectItem(80,250+yoffset,550,280,this);
|
||||
mPPFrame->setPen(FramePen);
|
||||
|
||||
mPPTitle = new QGraphicsTextItem("Activation des pédales pneu porteur",this);
|
||||
mPPTitle->setFont(font);
|
||||
mPPTitle->setPos(150,250+yoffset);
|
||||
|
||||
|
||||
|
||||
|
||||
font.setPointSize(14);
|
||||
mPPIZT1Description = new QGraphicsTextItem("Pédale intérieure ZT1",this);
|
||||
mPPIZT1Description->setFont(font);
|
||||
mPPIZT1Description->setPos(100,300+15+yoffset);
|
||||
mZT1PPIStatus = new CONOFFStatusWidget("");
|
||||
mZT1PPIStatus->setParentItem(this);
|
||||
mZT1PPIStatus->setPos(320,300+yoffset);
|
||||
|
||||
mPPEZT1Description = new QGraphicsTextItem("Pédale extérieure ZT1",this);
|
||||
mPPEZT1Description->setFont(font);
|
||||
mPPEZT1Description->setPos(100,350+15+yoffset);
|
||||
mZT1PPEStatus = new CONOFFStatusWidget("");
|
||||
mZT1PPEStatus->setParentItem(this);
|
||||
mZT1PPEStatus->setPos(320,350+yoffset);
|
||||
|
||||
mPPIZT2Description = new QGraphicsTextItem("Pédale intérieure ZT2",this);
|
||||
mPPIZT2Description->setFont(font);
|
||||
mPPIZT2Description->setPos(100,400+15+yoffset);
|
||||
mZT2PPIStatus = new CONOFFStatusWidget("");
|
||||
mZT2PPIStatus->setParentItem(this);
|
||||
mZT2PPIStatus->setPos(320,400+yoffset);
|
||||
|
||||
mPPEZT2Description = new QGraphicsTextItem("Pédale extérieure ZT2",this);
|
||||
mPPEZT2Description->setFont(font);
|
||||
mPPEZT2Description->setPos(100,450+15+yoffset);
|
||||
mZT2PPEStatus = new CONOFFStatusWidget("");
|
||||
mZT2PPEStatus->setParentItem(this);
|
||||
mZT2PPEStatus->setPos(320,450+yoffset);
|
||||
|
||||
mMaintenanceModeAutoExitTimer = new QTimer();
|
||||
mMaintenanceModeAutoExitTimer->setSingleShot(true);
|
||||
connect(mMaintenanceModeAutoExitTimer,SIGNAL(timeout()),this,SLOT(AutoExit()));
|
||||
|
||||
mAlarmRankSpinBox->setValue(1);
|
||||
mAlarmRankSpinBox->setMinimum(1);
|
||||
mAlarmRankSpinBox->setMaximum(1);
|
||||
mRankDescription->setPlainText("N/A");
|
||||
|
||||
HideMaintenanceItems();
|
||||
}
|
||||
|
||||
void CMaintenancePage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void CMaintenancePage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mCancelButton)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
else if(BtnPtr == mGenerateAlarmBtn)
|
||||
{
|
||||
GenerateTK();
|
||||
}
|
||||
else if(BtnPtr == mClearAlarmButton)
|
||||
{
|
||||
if(mProgramHandle->ClearMaintenanceCurTKRequest() == RET_OK)
|
||||
{
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Acquitement MANUEL d'une TK au PCC.",true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mClearAlarmButton->hide();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMaintenancePage::AlarmTypeSelectionChanged(int index)
|
||||
{
|
||||
switch(index)
|
||||
{
|
||||
|
||||
case DETECTION_PG_DETECTION:
|
||||
case DETECTION_PPI_DETECTION:
|
||||
case DETECTION_PPE_DETECTION:
|
||||
case DETECTION_ZT2_PPI_DETECTION:
|
||||
case DETECTION_ZT2_PPE_DETECTION:
|
||||
{
|
||||
mAlarmRankSpinBox->setValue(1);
|
||||
mAlarmRankSpinBox->setMinimum(1);
|
||||
mAlarmRankSpinBox->setMaximum(36);
|
||||
mRankDescription->setPlainText("Rang");
|
||||
break;
|
||||
}
|
||||
case DETECTION_FN_DETECTION:
|
||||
{
|
||||
mAlarmRankSpinBox->setValue(1);
|
||||
mAlarmRankSpinBox->setMinimum(1);
|
||||
mAlarmRankSpinBox->setMaximum(18);
|
||||
mRankDescription->setPlainText("Bogie");
|
||||
break;
|
||||
}
|
||||
case DETECTION_MAGNETIC_SENSOR_COUNT:
|
||||
case DETECTION_ZT2_MAGNETIC_SENSOR_COUNT:
|
||||
case DETECTION_PEQ1_DETECTION:
|
||||
case DETECTION_PEQ2_DETECTION:
|
||||
{
|
||||
mAlarmRankSpinBox->setValue(1);
|
||||
mAlarmRankSpinBox->setMinimum(1);
|
||||
mAlarmRankSpinBox->setMaximum(1);
|
||||
mRankDescription->setPlainText("N/A");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMaintenancePage::ActivationBtnToggled(CToggleButtonWidget *Btn)
|
||||
{
|
||||
|
||||
if(Btn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
{
|
||||
if(mProgramHandle->EnterMaintenanceModeRequest() == true)
|
||||
{
|
||||
ShowMaintenanceItems();
|
||||
mMaintenanceModeAutoExitTimer->start(MAINTENANCE_AUTO_EXIT_TIMEOUT);
|
||||
CZTLog::instance()->AddLogString("-----------------------------------------------",true);
|
||||
CZTLog::instance()->AddLogString("Mode entretien activé: Zone Tests hors service",true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString str = "Le mode entretien ne peut être activé si:\n- ZT1 ou ZT2 sont activées\n- Un train est sur le CDV d'approche (ZT1 ou ZT2)\n- Des TK sont en cours d'émission\n- La calibration PG est activée";
|
||||
QMessageBox::information(0,"Mode Entretien non disponible",str);
|
||||
Btn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mProgramHandle->ExitMaintenanceModeRequest();
|
||||
HideMaintenanceItems();
|
||||
mZT1PPEStatus->SetOFF();
|
||||
mZT1PPIStatus->SetOFF();
|
||||
mZT2PPEStatus->SetOFF();
|
||||
mZT2PPIStatus->SetOFF();
|
||||
mMaintenanceModeAutoExitTimer->stop();
|
||||
CZTLog::instance()->AddLogString("Mode entretien désactivé: Zone Tests en service.",true);
|
||||
CZTLog::instance()->AddLogString("-------------------------------------------------",true);
|
||||
}
|
||||
}
|
||||
|
||||
void CMaintenancePage::WatchdogEnableBtnToggled(CToggleButtonWidget *Btn)
|
||||
{
|
||||
if(Btn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||
{
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Vigie réactivée.",true);
|
||||
mProgramHandle->SetWatchdogEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Vigie désactivée.",true);
|
||||
mProgramHandle->SetWatchdogEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CMaintenancePage::ShowMaintenanceItems()
|
||||
{
|
||||
mGenerateAlarmBtn->show();
|
||||
mAlarmTypeList->show();
|
||||
mAlarmRankSpinBox->show();
|
||||
mAlarmDescription->show();
|
||||
mRankDescription->show();
|
||||
mFctDescription->show();
|
||||
|
||||
mPPIZT1Description->show();
|
||||
mPPEZT1Description->show();
|
||||
mZT1PPEStatus->show();
|
||||
mZT1PPIStatus->show();
|
||||
if(mProgramHandle->IsZT2PresentInStation())
|
||||
{
|
||||
mPPIZT2Description->show();
|
||||
mPPEZT2Description->show();
|
||||
mZT2PPEStatus->show();
|
||||
mZT2PPIStatus->show();
|
||||
}
|
||||
mPPTitle->show();
|
||||
mWatchdogDisableDescription->show();
|
||||
|
||||
mAlarmsFrame->show();
|
||||
mPPFrame->show();
|
||||
|
||||
mWatchdogEnableBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||
mWatchdogEnableBtn->show();
|
||||
|
||||
mCancelButton->hide();
|
||||
}
|
||||
|
||||
void CMaintenancePage::HideMaintenanceItems()
|
||||
{
|
||||
|
||||
mGenerateAlarmBtn->hide();
|
||||
mClearAlarmButton->hide();
|
||||
mAlarmTypeList->hide();
|
||||
mAlarmRankSpinBox->hide();
|
||||
mAlarmDescription->hide();
|
||||
mRankDescription->hide();
|
||||
mFctDescription->hide();
|
||||
|
||||
mPPIZT1Description->hide();
|
||||
mPPEZT1Description->hide();
|
||||
mPPIZT2Description->hide();
|
||||
mPPEZT2Description->hide();
|
||||
mZT1PPEStatus->hide();
|
||||
mZT1PPIStatus->hide();
|
||||
mZT2PPEStatus->hide();
|
||||
mZT2PPIStatus->hide();
|
||||
mPPTitle->hide();
|
||||
mWatchdogDisableDescription->hide();
|
||||
|
||||
mAlarmsFrame->hide();
|
||||
mPPFrame->hide();
|
||||
|
||||
mWatchdogEnableBtn->hide();
|
||||
|
||||
mCancelButton->show();
|
||||
|
||||
}
|
||||
|
||||
void CMaintenancePage::GenerateTK()
|
||||
{
|
||||
int AlarmID = mAlarmTypeList->currentIndex();
|
||||
if(AlarmID < 0 || AlarmID >= DETECTION_MAX_DETECTION_ID)
|
||||
return;
|
||||
int Rank = mAlarmRankSpinBox->value();
|
||||
|
||||
mProgramHandle->SendTKToPCC(AlarmID,Rank);
|
||||
|
||||
CZTLog::instance()->AddLogString(QString().sprintf("[Mode entretien] Émission manuelle d'une alarme au PCC: %s au rang %d",CZTData::GetErrorString(AlarmID),Rank),true);
|
||||
}
|
||||
|
||||
void CMaintenancePage::TKOutputChanged(bool ZT1Active, bool ZT2Active)
|
||||
{
|
||||
if(ZT1Active || ZT2Active)
|
||||
{
|
||||
mClearAlarmButton->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
mClearAlarmButton->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void CMaintenancePage::PPActivated(unsigned int PedalID)
|
||||
{
|
||||
switch(PedalID)
|
||||
{
|
||||
case MAINTENANCE_PPI_ZT1_ID:
|
||||
{
|
||||
mZT1PPIStatus->SetON();
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Pneu porteur intérieur ZT1 détecté. TK envoyée au PCC",true);
|
||||
break;
|
||||
}
|
||||
case MAINTENANCE_PPE_ZT1_ID:
|
||||
{
|
||||
mZT1PPEStatus->SetON();
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Pneu porteur extérieur ZT1 détecté. TK envoyée au PCC",true);
|
||||
break;
|
||||
}
|
||||
case MAINTENANCE_PPI_ZT2_ID:
|
||||
{
|
||||
mZT2PPIStatus->SetON();
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Pneu porteur intérieur ZT2 détecté. TK envoyée au PCC",true);
|
||||
break;
|
||||
}
|
||||
case MAINTENANCE_PPE_ZT2_ID:
|
||||
{
|
||||
mZT2PPEStatus->SetON();
|
||||
CZTLog::instance()->AddLogString("[Mode entretien] Pneu porteur extérieur ZT2 détecté. TK envoyée au PCC",true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMaintenancePage::AutoExit()
|
||||
{
|
||||
mMaintenanceActivationBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||
mProgramHandle->ExitMaintenanceModeRequest();
|
||||
HideMaintenanceItems();
|
||||
mZT1PPEStatus->SetOFF();
|
||||
mZT1PPIStatus->SetOFF();
|
||||
mZT2PPEStatus->SetOFF();
|
||||
mZT2PPIStatus->SetOFF();
|
||||
CZTLog::instance()->AddLogString("Désactivation automatique du mode entretien: Zone Tests en service.",true);
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void CMaintenancePage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CMaintenancePage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131122 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef MAINTENANCEPAGE_H
|
||||
#define MAINTENANCEPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include "ToggleButtonWidget.h"
|
||||
#include "ONOFFStatusWidget.h"
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
|
||||
#define MAINTENANCE_AUTO_EXIT_TIMEOUT (int)7200000 //Exit after 2 hours.
|
||||
|
||||
enum ePPId
|
||||
{
|
||||
MAINTENANCE_PPI_ZT1_ID,
|
||||
MAINTENANCE_PPE_ZT1_ID,
|
||||
MAINTENANCE_PPI_ZT2_ID,
|
||||
MAINTENANCE_PPE_ZT2_ID
|
||||
};
|
||||
|
||||
class CMaintenancePage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMaintenancePage(QGraphicsWidget *Parent = 0);
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton, *mGenerateAlarmBtn, *mClearAlarmButton;
|
||||
|
||||
QComboBox *mAlarmTypeList;
|
||||
QSpinBox *mAlarmRankSpinBox;
|
||||
QGraphicsTextItem *mAlarmDescription, *mRankDescription, *mFctDescription, *mWatchdogDisableDescription;
|
||||
QGraphicsTextItem *mPPIZT1Description, *mPPIZT2Description, *mPPEZT1Description, *mPPEZT2Description, *mPPTitle;
|
||||
CToggleButtonWidget *mMaintenanceActivationBtn;
|
||||
CToggleButtonWidget *mWatchdogEnableBtn;
|
||||
CONOFFStatusWidget *mZT1PPIStatus, *mZT1PPEStatus, *mZT2PPIStatus, *mZT2PPEStatus;
|
||||
QTimer *mMaintenanceModeAutoExitTimer;
|
||||
|
||||
QGraphicsRectItem *mPPFrame, *mAlarmsFrame;
|
||||
|
||||
void GenerateTK();
|
||||
void ShowMaintenanceItems();
|
||||
void HideMaintenanceItems();
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
void AlarmTypeSelectionChanged(int);
|
||||
void ActivationBtnToggled(CToggleButtonWidget*);
|
||||
void PPActivated(unsigned int);
|
||||
void AutoExit();
|
||||
void WatchdogEnableBtnToggled(CToggleButtonWidget*);
|
||||
void TKOutputChanged(bool,bool);
|
||||
|
||||
};
|
||||
|
||||
#endif // OPTIONSPAGE_H
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130306 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ONOFFStatusWidget.h"
|
||||
#include <QPainter>
|
||||
#define ON_OFF_WIDGET_SIZE 30
|
||||
|
||||
CONOFFStatusWidget::CONOFFStatusWidget(QString Label)
|
||||
{
|
||||
mONLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-off-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
|
||||
mONLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-on-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
|
||||
mOFFLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-off-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
|
||||
mOFFLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-on-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
|
||||
|
||||
mOFFLedOffPixmap->setPos(0,20);
|
||||
mOFFLedOnPixmap->setPos(0,20);
|
||||
mONLedOffPixmap->setPos(30,20);
|
||||
mONLedOnPixmap->setPos(30,20);
|
||||
|
||||
mONLedOnPixmap->hide();
|
||||
mOFFLedOffPixmap->hide();
|
||||
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
mLabel->setPlainText(Label);
|
||||
mLabel->setPos(5,0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
CONOFFStatusWidget::~CONOFFStatusWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void CONOFFStatusWidget::SetON()
|
||||
{
|
||||
mONLedOnPixmap->show();
|
||||
mONLedOffPixmap->hide();
|
||||
mOFFLedOnPixmap->hide();
|
||||
mOFFLedOffPixmap->show();
|
||||
}
|
||||
|
||||
void CONOFFStatusWidget::SetOFF()
|
||||
{
|
||||
mONLedOnPixmap->hide();
|
||||
mONLedOffPixmap->show();
|
||||
mOFFLedOnPixmap->show();
|
||||
mOFFLedOffPixmap->hide();
|
||||
}
|
||||
|
||||
void CONOFFStatusWidget::Toggle()
|
||||
{
|
||||
if(mONLedOnPixmap->isVisible())
|
||||
{
|
||||
SetOFF();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetON();
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#ifndef ONOFFSTATUSWIDGET_H
|
||||
#define ONOFFSTATUSWIDGET_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimer>
|
||||
|
||||
class CONOFFStatusWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
CONOFFStatusWidget(QString Lable = QString());
|
||||
~CONOFFStatusWidget();
|
||||
|
||||
QGraphicsTextItem *mLabel;
|
||||
QGraphicsPixmapItem *mONLedOnPixmap,*mONLedOffPixmap;
|
||||
QGraphicsPixmapItem *mOFFLedOnPixmap,*mOFFLedOffPixmap;
|
||||
|
||||
void SetON();
|
||||
void SetOFF();
|
||||
void Toggle();
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // ONOFFSTATUSWIDGET_H
|
||||
@@ -0,0 +1,136 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page de sélection des options (sélection des fonctions de détection, ingénierie,
|
||||
mode entretien, etc.).
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "OptionsPage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include "Zonetest.h"
|
||||
#include <QDateTime>
|
||||
#include <QFont>
|
||||
|
||||
|
||||
|
||||
COptionsPage::COptionsPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
|
||||
mProgramHandle = 0;
|
||||
mZTSimulatorPtr = 0;
|
||||
|
||||
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
QGraphicsTextItem *Title = new QGraphicsTextItem("Choisissez une option",this);
|
||||
QFont font;
|
||||
font.setPointSize(18);
|
||||
Title->setFont(font);
|
||||
Title->setPos(40,10);
|
||||
|
||||
mZTFunctionsButton = new CTextButtonWidget("Fonctions Détection");
|
||||
mZTFunctionsButton->setParentItem(this);
|
||||
mZTFunctionsButton->setPos(50,60);
|
||||
connect(mZTFunctionsButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mZTMaintenanceModeButton = new CTextButtonWidget("Mode entretien");
|
||||
mZTMaintenanceModeButton->setParentItem(this);
|
||||
mZTMaintenanceModeButton->setPos(50,100);
|
||||
connect(mZTMaintenanceModeButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mZTEngineeringButton = new CTextButtonWidget("Ingénierie");
|
||||
mZTEngineeringButton->setParentItem(this);
|
||||
mZTEngineeringButton->setPos(50,140);
|
||||
connect(mZTEngineeringButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mZTGeneralSettingsButton = new CTextButtonWidget("Paramètres");
|
||||
mZTGeneralSettingsButton->setParentItem(this);
|
||||
mZTGeneralSettingsButton->setPos(50,180);
|
||||
connect(mZTGeneralSettingsButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mZTLogViewButton = new CTextButtonWidget("Fichier LOG");
|
||||
mZTLogViewButton->setParentItem(this);
|
||||
mZTLogViewButton->setPos(50,220);
|
||||
connect(mZTLogViewButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Fermer");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(50,260);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
}
|
||||
|
||||
void COptionsPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void COptionsPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mZTFunctionsButton)
|
||||
{
|
||||
mProgramHandle->ZTFunctionsOptionSelected();
|
||||
|
||||
}
|
||||
else if(BtnPtr == mZTMaintenanceModeButton)
|
||||
{
|
||||
mProgramHandle->ZTMaintenanceOptionSeleced();
|
||||
}
|
||||
else if(BtnPtr == mCancelButton)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
else if(BtnPtr == mZTEngineeringButton)
|
||||
{
|
||||
mProgramHandle->OpenEngineeringPageRequest();
|
||||
}
|
||||
else if(BtnPtr == mZTGeneralSettingsButton)
|
||||
{
|
||||
mProgramHandle->OpenGeneralSettingsPage();
|
||||
}
|
||||
else if(BtnPtr == mZTLogViewButton)
|
||||
{
|
||||
mProgramHandle->ShowZTLogViewerPage();
|
||||
}
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void COptionsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void COptionsPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef OPTIONSPAGE_H
|
||||
#define OPTIONSPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "TextButtonWidget.h"
|
||||
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
class COptionsPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
COptionsPage(QGraphicsWidget *Parent = 0);
|
||||
CPushButton *mToolsPushButton;
|
||||
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
CZTSimulator *mZTSimulatorPtr;
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mZTFunctionsButton;
|
||||
CTextButtonWidget *mZTMaintenanceModeButton;
|
||||
CTextButtonWidget *mZTEngineeringButton;
|
||||
CTextButtonWidget *mZTGeneralSettingsButton;
|
||||
CTextButtonWidget *mZTLogViewButton;
|
||||
CTextButtonWidget *mCancelButton;
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
|
||||
};
|
||||
|
||||
#endif // OPTIONSPAGE_H
|
||||
@@ -0,0 +1,152 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page qui demande à l'utlisateur d'entrer un mot de passe.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "PasswordPrompt.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include "ZTLog.h"
|
||||
#include "EngLog.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
CPasswordPrompt::CPasswordPrompt(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
setGeometry(0,0,1024,768);
|
||||
|
||||
QGraphicsRectItem *BckgndRect = new QGraphicsRectItem(this);
|
||||
BckgndRect->setRect(0,0,1024,768);
|
||||
BckgndRect->setBrush(QBrush(QColor(Qt::lightGray)));
|
||||
|
||||
mAcceptBtn = new CTextButtonWidget("OK");
|
||||
mAcceptBtn->setParentItem(this);
|
||||
mAcceptBtn->setPos(400,300);
|
||||
connect(mAcceptBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonPressed(CTextButtonWidget*)));
|
||||
|
||||
mCancelBtn = new CTextButtonWidget("Annuler");
|
||||
mCancelBtn->setParentItem(this);
|
||||
mCancelBtn->setPos(530,300);
|
||||
connect(mCancelBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonPressed(CTextButtonWidget*)));
|
||||
|
||||
mLineEditWidget = new QLineEdit();
|
||||
mLineEditWidget->setEchoMode(QLineEdit::Password);
|
||||
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||
Proxy->setWidget(mLineEditWidget);
|
||||
Proxy->setPos(400,250);
|
||||
|
||||
QGraphicsTextItem *Label = new QGraphicsTextItem(this);
|
||||
Label->setPlainText("Veuillez entrer le mot de passe:");
|
||||
Label->setPos(400,220);
|
||||
|
||||
mPassword.clear();
|
||||
mPassword = DEFAULT_PASSWORD;
|
||||
LoadPasswordFile();
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
void CPasswordPrompt::RequestPassword()
|
||||
{
|
||||
mLineEditWidget->setFocus();
|
||||
show();
|
||||
}
|
||||
|
||||
void CPasswordPrompt::ButtonPressed(CTextButtonWidget *Btn)
|
||||
{
|
||||
if(Btn == mAcceptBtn)
|
||||
{
|
||||
if(mLineEditWidget->text() == mPassword)
|
||||
{
|
||||
mLineEditWidget->clear();
|
||||
emit PasswordValid();
|
||||
}
|
||||
else
|
||||
{
|
||||
CZTLog::instance()->AddLogString("Tentative de mot de passe invalide.",true);
|
||||
CEngLog::instance()->AddLogString(QString().sprintf("Tentative de mot de passe invalide %s.",mLineEditWidget->text().toLatin1().data()),1);
|
||||
|
||||
mLineEditWidget->clear();
|
||||
}
|
||||
}
|
||||
else if(Btn == mCancelBtn)
|
||||
{
|
||||
mLineEditWidget->clear();
|
||||
emit Canceled();
|
||||
}
|
||||
}
|
||||
|
||||
bool CPasswordPrompt::LoadPasswordFile()
|
||||
{
|
||||
QFile *ZTPasswordFile = new QFile("./Configuration/ZT.pwd");
|
||||
if (!ZTPasswordFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
CEngLog::instance()->AddLogString("Fichier de mot de passe invalide. Utilisation du mot de passe par défaut.");
|
||||
delete ZTPasswordFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString string;
|
||||
|
||||
string.clear();
|
||||
string = ZTPasswordFile->readLine(1024);
|
||||
if(string.isEmpty())
|
||||
{
|
||||
CEngLog::instance()->AddLogString("Fichier de mot de passe invalide. Utilisation du mot de passe par défaut.");
|
||||
ZTPasswordFile->close();
|
||||
delete ZTPasswordFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
string.remove("\n"); //remove trailing "\n" characters inserted by QFile.readline
|
||||
mPassword.clear();
|
||||
mPassword = string;
|
||||
|
||||
ZTPasswordFile->close();
|
||||
delete ZTPasswordFile;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void CPasswordPrompt::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_Return)
|
||||
{
|
||||
ButtonPressed(mAcceptBtn);
|
||||
}
|
||||
}
|
||||
|
||||
void CPasswordPrompt::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CPasswordPrompt::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PASSWORDPROMPT_H
|
||||
#define PASSWORDPROMPT_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QLineEdit>
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
class CPasswordPrompt : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPasswordPrompt(QGraphicsItem *Parent);
|
||||
|
||||
void RequestPassword();
|
||||
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
private:
|
||||
CTextButtonWidget *mAcceptBtn, *mCancelBtn;
|
||||
QLineEdit *mLineEditWidget;
|
||||
QString mPassword;
|
||||
|
||||
bool LoadPasswordFile();
|
||||
|
||||
|
||||
signals:
|
||||
void PasswordValid();
|
||||
void Canceled();
|
||||
|
||||
public slots:
|
||||
void ButtonPressed(CTextButtonWidget*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // PASSWORDPROMPT_H
|
||||
@@ -0,0 +1,257 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Widget graphique Bouton qui consiste en une image sur laquelle l'on peut
|
||||
cliquer.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130204 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "PushButton.h"
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QBitmap>
|
||||
#include <QColor>
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
CPushButton::CPushButton(QGraphicsItem *Parent,QString NormalFileName, bool UseTextOverlay,int ButtonData)
|
||||
{
|
||||
Q_UNUSED(ButtonData)
|
||||
setParentItem(Parent);
|
||||
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
m_Normal = new QGraphicsPixmapItem(QPixmap(NormalFileName));
|
||||
|
||||
ClickTransparency = 1;
|
||||
|
||||
//Inform QGraphicsItem of the geometry
|
||||
setGeometry(m_Normal->boundingRect());
|
||||
|
||||
ispressed = false;
|
||||
isFlashingValid = false;
|
||||
mDisplayFlashIcon = false;
|
||||
isreleasing = false;
|
||||
UseOverlay = UseTextOverlay;
|
||||
ButtonTextOverlay = "";
|
||||
|
||||
|
||||
timeLine = new QTimeLine(PRESS_EFFECT_FADE_TIMEOUT);
|
||||
timeLine->setCurveShape(QTimeLine::EaseInCurve);
|
||||
connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(TimeLine(qreal)));
|
||||
|
||||
}
|
||||
|
||||
CPushButton::~CPushButton()
|
||||
{
|
||||
delete m_Normal;
|
||||
delete timeLine;
|
||||
}
|
||||
|
||||
void CPushButton::paint(QPainter *Painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
||||
// Painter->setCompositionMode(QPainter::CompositionMode_DestinationOver);
|
||||
/*if(isDown() || isChecked())
|
||||
{
|
||||
m_Normal->paint(Painter,option,widget);
|
||||
qDebug("Paint Called, button down");
|
||||
}
|
||||
else if(underMouse())
|
||||
{
|
||||
m_Hovered->paint(Painter,option,widget);
|
||||
qDebug("Paint Called, hovered");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Pressed->paint(Painter,option,widget);
|
||||
qDebug("Paint Called, normal");
|
||||
}*/
|
||||
|
||||
|
||||
if(ispressed)
|
||||
{
|
||||
|
||||
//QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||
QRadialGradient gradient(m_Normal->boundingRect().center(),m_Normal->boundingRect().width()/2);
|
||||
gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1,1));
|
||||
gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1,0));
|
||||
|
||||
QBrush brush(gradient);
|
||||
// m_Pressed->paint(Painter,option,widget);
|
||||
m_Normal->paint(Painter,option,widget);
|
||||
Painter->setBrush(brush);
|
||||
Painter->setPen(Qt::NoPen);
|
||||
//Painter->drawEllipse(m_Normal->boundingRect());
|
||||
Painter->drawEllipse(m_Normal->boundingRect());
|
||||
|
||||
//qDebug("Paint Called, pressed");
|
||||
}
|
||||
/* else if(ishovered)
|
||||
{
|
||||
m_Hovered->paint(Painter,option,widget);
|
||||
// qDebug("Paint Called, hovered");
|
||||
}*/
|
||||
else
|
||||
{
|
||||
if(mDisplayFlashIcon)
|
||||
{
|
||||
m_Flashing->paint(Painter,option,widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//draw button icon
|
||||
m_Normal->paint(Painter,option,widget);
|
||||
|
||||
//draw text overlay
|
||||
QRectF textRect = m_Normal->boundingRect();//.adjusted(15, 10, -10, -15);
|
||||
int flags = Qt::AlignHCenter | Qt::AlignVCenter;
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(16);
|
||||
font.setBold(true);
|
||||
Painter->setPen(Qt::red);
|
||||
Painter->setFont(font);
|
||||
Painter->drawText(textRect, flags, ButtonTextOverlay);
|
||||
|
||||
//if necessary, draw halo animation
|
||||
if(isreleasing)
|
||||
{
|
||||
//QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||
QRadialGradient gradient(m_Normal->boundingRect().center(),m_Normal->boundingRect().width()/2);
|
||||
gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1,ClickTransparency));
|
||||
gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1, 0));
|
||||
|
||||
QBrush brush(gradient);
|
||||
// m_Pressed->paint(Painter,option,widget);
|
||||
m_Normal->paint(Painter,option,widget);
|
||||
Painter->setBrush(brush);
|
||||
Painter->setPen(Qt::NoPen);
|
||||
//Painter->drawEllipse(m_Normal->boundingRect());
|
||||
Painter->drawEllipse(m_Normal->boundingRect());
|
||||
}
|
||||
|
||||
}
|
||||
// qDebug("Paint Called, normal");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CPushButton::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
event->accept();
|
||||
update();
|
||||
// qDebug("Hover Enter Called");
|
||||
}
|
||||
void CPushButton::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
event->accept();
|
||||
update();
|
||||
// qDebug("Hover Leave Called");
|
||||
}
|
||||
void CPushButton::mousePressEvent ( QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
//
|
||||
ispressed = true;
|
||||
update();
|
||||
emit pressed(this);
|
||||
|
||||
|
||||
// qDebug("Mouse Press Event");
|
||||
//event->ignore();
|
||||
|
||||
}
|
||||
void CPushButton::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
ispressed = false;
|
||||
|
||||
emit released(this);
|
||||
isreleasing = true;
|
||||
|
||||
timeLine->start();
|
||||
// qDebug("Button Mouse Release Event");
|
||||
|
||||
}
|
||||
|
||||
void CPushButton::StartFlashing()
|
||||
{
|
||||
mFlashTimer->start(mFlashTimeout);
|
||||
}
|
||||
void CPushButton::StopFlashing()
|
||||
{
|
||||
mFlashTimer->stop();
|
||||
mDisplayFlashIcon = false;
|
||||
}
|
||||
void CPushButton::setFlashingData(QString FlashFileName,int FlashDelay)
|
||||
{
|
||||
QPixmap temp(FlashFileName);
|
||||
QBitmap temp2 = temp.createMaskFromColor(QColor(255,255,255),Qt::MaskOutColor);
|
||||
// temp.setMask(temp2);
|
||||
m_Flashing = new QGraphicsPixmapItem(temp);
|
||||
if(!m_Flashing)
|
||||
{
|
||||
isFlashingValid = false;
|
||||
return;
|
||||
}
|
||||
isFlashingValid = true;
|
||||
mFlashTimeout = FlashDelay;
|
||||
mFlashTimer = new QTimer(this);
|
||||
connect(mFlashTimer,SIGNAL(timeout()),this,SLOT(FlashButton()));
|
||||
|
||||
}
|
||||
void CPushButton::FlashButton()
|
||||
{
|
||||
mDisplayFlashIcon = !mDisplayFlashIcon;
|
||||
update();
|
||||
}
|
||||
|
||||
void CPushButton::TimeLine(qreal value)
|
||||
{
|
||||
ClickTransparency = 1-value;
|
||||
|
||||
update();
|
||||
|
||||
if(value == 1)
|
||||
{
|
||||
isreleasing = false;
|
||||
emit clicked(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CPushButton::SetTextOverlay(QString Text)
|
||||
{
|
||||
ButtonTextOverlay = Text.left(MAX_OVERLAY_TEXT_LENGTH);
|
||||
update();
|
||||
}
|
||||
|
||||
void CPushButton::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
m_Normal->setPixmap(m_Normal->pixmap().scaled(event->newSize().width(),event->newSize().height()));
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef PUSHBUTTON_H
|
||||
#define PUSHBUTTON_H
|
||||
|
||||
//#include <QAbstractButton>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QGraphicsSceneHoverEvent>
|
||||
#include <QGraphicsItem>
|
||||
class QGraphicsPixmapItem;
|
||||
#include <QObject>
|
||||
#include <QtCore/qtimeline.h>
|
||||
|
||||
class QTimer;
|
||||
|
||||
#define PRESS_EFFECT_FADE_TIMEOUT 200
|
||||
#define MAX_OVERLAY_TEXT_LENGTH 3
|
||||
|
||||
class CPushButton : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPushButton(QGraphicsItem *Parent, QString NormalFileName,bool UseTextOverlay = false, int ButtonData = 0);
|
||||
virtual ~CPushButton();
|
||||
|
||||
void setFlashingData(QString FlashingFileName,int FlashingDelay);
|
||||
void StartFlashing(void);
|
||||
void StopFlashing(void);
|
||||
void SetTextOverlay(QString Text);
|
||||
void SetButtonData(unsigned long int ButtonData){mButtonData = ButtonData;}
|
||||
unsigned long int GetBUttonData(){return mButtonData;}
|
||||
|
||||
|
||||
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
// QRectF boundingRect() const;
|
||||
|
||||
bool ispressed;
|
||||
bool isreleasing;
|
||||
bool isFlashingValid;
|
||||
bool mDisplayFlashIcon;
|
||||
bool UseOverlay;
|
||||
QTimer *mFlashTimer;
|
||||
int mFlashTimeout;
|
||||
QString ButtonTextOverlay;
|
||||
unsigned long int mButtonData;
|
||||
|
||||
protected:
|
||||
//virtual void paintEvent(QPaintEvent *e);
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
private:
|
||||
QTimeLine *timeLine;
|
||||
qreal ClickTransparency;
|
||||
|
||||
signals:
|
||||
void clicked(CPushButton *ButtonPtr);
|
||||
void pressed(CPushButton *ButtonPtr);
|
||||
void released(CPushButton *ButtonPtr);
|
||||
|
||||
public slots:
|
||||
void FlashButton();
|
||||
void TimeLine(qreal value);
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem *m_Normal;
|
||||
QGraphicsPixmapItem *m_Pressed;
|
||||
QGraphicsPixmapItem *m_Hovered;
|
||||
QGraphicsPixmapItem *m_Flashing;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // PUSHBUTTON_H
|
||||
@@ -0,0 +1,287 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche une règle qui indique le décompte des rangs
|
||||
du train dans le temps. Ce qui permet de savoir à quel rang un événement
|
||||
est survenu lors de la consultation d'un passage de train.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "RankRulerWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QTextStream>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CRankRulerWidget::~CRankRulerWidget()
|
||||
{
|
||||
delete mRulerPixmap;
|
||||
}
|
||||
|
||||
CRankRulerWidget::CRankRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mPixelWidth = RulerPixelWidth;
|
||||
mLabel = new QGraphicsTextItem(this);
|
||||
|
||||
mRulerPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
}
|
||||
|
||||
void CRankRulerWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
delete mRulerPixmap;
|
||||
mRulerPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||
Render();
|
||||
}
|
||||
|
||||
void CRankRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget)
|
||||
|
||||
painter->setClipRect(option->exposedRect);
|
||||
painter->drawPixmap(0,0,*mRulerPixmap);
|
||||
|
||||
// if(mRankItems.isEmpty())
|
||||
// return;
|
||||
// QFont font;
|
||||
// font.setPixelSize(12);
|
||||
// painter->setFont(font);
|
||||
// qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||
|
||||
// int StartIndex = 0,EndIndex = 0;
|
||||
// bool StartFound = false;
|
||||
|
||||
// for(int i = 0; i < mRankItems.size(); i++)
|
||||
// {
|
||||
// if(StartFound == false)
|
||||
// {
|
||||
// if(mStartTime <= mRankItems.at(i).mStartTime)
|
||||
// {
|
||||
// StartIndex = i;
|
||||
// StartFound = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(mRankItems.at(i).mEndTime <= mEndTime)
|
||||
// {
|
||||
// EndIndex = i;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(StartIndex > 0)
|
||||
// {
|
||||
// if(mStartTime < mRankItems.at(StartIndex).mStartTime)
|
||||
// {
|
||||
// QRectF LabelRect;
|
||||
// qreal StartPixel = 0;//mStartTime * pitch;
|
||||
// qreal EndPixel = (mRankItems.at(StartIndex).mStartTime - mStartTime) * pitch;
|
||||
// qreal Height = boundingRect().height();
|
||||
|
||||
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
// painter->drawText(LabelRect,mRankItems.at(StartIndex-1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(int i = StartIndex; i <= EndIndex; i++)
|
||||
// {
|
||||
// QRectF LabelRect;
|
||||
// qreal StartPixel = (mRankItems.at(i).mStartTime - mStartTime) * pitch;
|
||||
|
||||
// qreal EndPixel;
|
||||
// if(mRankItems.at(i).mEndTime > mEndTime)
|
||||
// EndPixel = (mEndTime - mStartTime) * pitch;
|
||||
// else
|
||||
// EndPixel = (mRankItems.at(i).mEndTime - mStartTime) * pitch;
|
||||
|
||||
// qreal Height = boundingRect().height();
|
||||
|
||||
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
// painter->drawText(LabelRect,mRankItems.at(i).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// }
|
||||
// if(EndIndex < mRankItems.size()-1)
|
||||
// {
|
||||
// if(mEndTime > mRankItems.at(EndIndex).mStartTime)
|
||||
// {
|
||||
// QRectF LabelRect;
|
||||
// qreal StartPixel = (mRankItems.at(EndIndex).mEndTime - mStartTime) * pitch;
|
||||
// qreal EndPixel = (mEndTime - mStartTime) * pitch;
|
||||
// qreal Height = boundingRect().height();
|
||||
|
||||
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
//// if(EndIndex == StartIndex)
|
||||
//// painter->drawText(LabelRect,mRankItems.at(EndIndex).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
//// else
|
||||
// painter->drawText(LabelRect,mRankItems.at(EndIndex+1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void CRankRulerWidget::Render()
|
||||
{
|
||||
|
||||
if(mRankItems.isEmpty())
|
||||
return;
|
||||
|
||||
mRulerPixmap->fill(Qt::white);
|
||||
QPainter *painter = new QPainter(mRulerPixmap);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
painter->setFont(font);
|
||||
qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||
|
||||
|
||||
|
||||
int StartIndex = 0,EndIndex = 0;
|
||||
bool StartFound = false;
|
||||
|
||||
for(int i = 0; i < mRankItems.size(); i++)
|
||||
{
|
||||
if(StartFound == false)
|
||||
{
|
||||
if(mStartTime <= mRankItems.at(i).mStartTime)
|
||||
{
|
||||
StartIndex = i;
|
||||
StartFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(mRankItems.at(i).mEndTime <= mEndTime)
|
||||
{
|
||||
EndIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(StartIndex > 0)
|
||||
{
|
||||
if(mStartTime < mRankItems.at(StartIndex).mStartTime)
|
||||
{
|
||||
QRectF LabelRect;
|
||||
qreal StartPixel = 0;//mStartTime * pitch;
|
||||
qreal EndPixel = (mRankItems.at(StartIndex).mStartTime - mStartTime) * pitch;
|
||||
qreal Height = boundingRect().height();
|
||||
|
||||
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
painter->drawText(LabelRect,mRankItems.at(StartIndex-1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = StartIndex; i <= EndIndex; i++)
|
||||
{
|
||||
QRectF LabelRect;
|
||||
qreal StartPixel = (mRankItems.at(i).mStartTime - mStartTime) * pitch;
|
||||
|
||||
qreal EndPixel;
|
||||
if(mRankItems.at(i).mEndTime > mEndTime)
|
||||
EndPixel = (mEndTime - mStartTime) * pitch;
|
||||
else
|
||||
EndPixel = (mRankItems.at(i).mEndTime - mStartTime) * pitch;
|
||||
|
||||
qreal Height = boundingRect().height();
|
||||
|
||||
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
painter->drawText(LabelRect,mRankItems.at(i).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
if(EndIndex < mRankItems.size()-1)
|
||||
{
|
||||
if(mEndTime > mRankItems.at(EndIndex).mStartTime)
|
||||
{
|
||||
QRectF LabelRect;
|
||||
qreal StartPixel = (mRankItems.at(EndIndex).mEndTime - mStartTime) * pitch;
|
||||
qreal EndPixel = (mEndTime - mStartTime) * pitch;
|
||||
qreal Height = boundingRect().height();
|
||||
|
||||
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||
// if(EndIndex == StartIndex)
|
||||
// painter->drawText(LabelRect,mRankItems.at(EndIndex).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// else
|
||||
painter->drawText(LabelRect,mRankItems.at(EndIndex+1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
delete painter;
|
||||
}
|
||||
|
||||
|
||||
unsigned int CRankRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||
{
|
||||
if(StartTime > EndTime)
|
||||
return false;
|
||||
|
||||
if(mRankItems.isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
mStartTime = StartTime;
|
||||
mEndTime = EndTime;
|
||||
mTimeOffset = mRankItems.first().mStartTime;
|
||||
|
||||
Render();
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CRankRulerWidget::AddRankItem(QString Rank, quint64 StartTime, quint64 EndTime)
|
||||
{
|
||||
CRankWidgetItem NewItem;
|
||||
NewItem.mLabel = Rank;
|
||||
NewItem.mStartTime = StartTime;
|
||||
NewItem.mEndTime = EndTime;
|
||||
|
||||
mRankItems.append(NewItem);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CRankRulerWidget::SetLabel(QString Label, int Offset)
|
||||
{
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
mLabel->setFont(font);
|
||||
mLabel->setPlainText(Label);
|
||||
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||
}
|
||||
|
||||
void CRankRulerWidget::ClearRuler()
|
||||
{
|
||||
mRankItems.clear();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131030 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### 20131107 Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RANKRULERWIDGET_H
|
||||
#define RANKRULERWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class CRankWidgetItem
|
||||
{
|
||||
public:
|
||||
QString mLabel;
|
||||
quint64 mStartTime;
|
||||
quint64 mEndTime;
|
||||
};
|
||||
|
||||
class CRankRulerWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CRankRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||
~CRankRulerWidget();
|
||||
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||
unsigned int AddRankItem(QString Rank,quint64 StartTime,quint64 EndTime);
|
||||
void SetLabel(QString Label,int Offset);
|
||||
void ClearRuler();
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
qreal mPixelWidth;
|
||||
quint64 mStartTime, mEndTime, mTimeOffset;
|
||||
qreal mPixelPitch;
|
||||
QGraphicsTextItem *mLabel;
|
||||
|
||||
QPixmap *mRulerPixmap;
|
||||
|
||||
QList<CRankWidgetItem> mRankItems;
|
||||
|
||||
|
||||
void Render();
|
||||
|
||||
};
|
||||
|
||||
#endif // RANKRULERWIDGET_H
|
||||
@@ -0,0 +1,149 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Widget animé qui affiche une boîte contenant du texte.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121220 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "SimpleTextBoxWidget.h"
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
#include <QRectF>
|
||||
|
||||
CSimpleTextBoxWidget::CSimpleTextBoxWidget(QGraphicsItem *parent)
|
||||
: QGraphicsWidget(parent)
|
||||
{
|
||||
opacity = 1.0;
|
||||
hide();
|
||||
//mText = "TEst";
|
||||
|
||||
|
||||
timeLine = new QTimeLine(500);
|
||||
timeLine->setCurveShape(QTimeLine::EaseOutCurve);
|
||||
connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setValue(qreal)));
|
||||
|
||||
resize(SCREEN_RES_WIDTH, SCREEN_RES_HEIGHT);
|
||||
|
||||
QTransform transform;
|
||||
|
||||
// transform.translate(160,120);
|
||||
transform.translate(SCREEN_RES_WIDTH/2,SCREEN_RES_HEIGHT/2);
|
||||
transform.scale(0,0);
|
||||
//transform.translate(-160,-120);
|
||||
transform.translate(-SCREEN_RES_WIDTH/2,-SCREEN_RES_HEIGHT/2);
|
||||
setTransform(transform);
|
||||
}
|
||||
|
||||
CSimpleTextBoxWidget::~CSimpleTextBoxWidget()
|
||||
{
|
||||
delete timeLine;
|
||||
}
|
||||
|
||||
void CSimpleTextBoxWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
QRectF BoxRect;
|
||||
BoxRect.setWidth(SCREEN_RES_WIDTH - 200);
|
||||
BoxRect.setHeight(SCREEN_RES_HEIGHT - 200);
|
||||
BoxRect.moveCenter(QPoint(SCREEN_RES_WIDTH/2,SCREEN_RES_HEIGHT/2));
|
||||
// painter->setOpacity(opacity);
|
||||
painter->setPen(QPen(Qt::black, 2));
|
||||
painter->setBrush(QColor(245, 245, 255, 200));
|
||||
painter->setClipRect(rect());
|
||||
// painter->drawRoundRect(25, 10, SCREEN_RES_WIDTH - 200, SCREEN_RES_HEIGHT - 200);
|
||||
painter->drawRoundRect(BoxRect);
|
||||
|
||||
QRectF textRect(BoxRect);
|
||||
// textRect.moveCenter(QPoint(160,120));
|
||||
int flags = Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap;
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(30);
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
QString text = "Ceci est un test\nTexte multiligne";
|
||||
painter->drawText(textRect, flags, mText);
|
||||
|
||||
//textRect.moveTop(textRect.top()+15);
|
||||
//painter->drawText(textRect, flags, mCallerNumber);
|
||||
}
|
||||
|
||||
|
||||
//void CSimpleTextBoxWidget::mousePressEvent(QGraphicsSceneMouseEvent * event )
|
||||
//{
|
||||
// if(isVisible())
|
||||
// {
|
||||
// HideCallerID();
|
||||
// event->accept();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// event->ignore();
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void CSimpleTextBoxWidget::setValue(qreal value)
|
||||
{
|
||||
QTransform transform;
|
||||
|
||||
|
||||
//QRectF BoxRect = rect();
|
||||
transform.translate(SCREEN_RES_WIDTH/2,SCREEN_RES_HEIGHT/2);
|
||||
transform.scale(value,value);
|
||||
transform.translate(-SCREEN_RES_WIDTH/2,-SCREEN_RES_HEIGHT/2);
|
||||
setTransform(transform);
|
||||
|
||||
if(value == 0 && timeLine->direction()== QTimeLine::Backward)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
void CSimpleTextBoxWidget::ShowTextBox()
|
||||
{
|
||||
show();
|
||||
timeLine->setDirection(QTimeLine::Forward);
|
||||
timeLine->start();
|
||||
|
||||
}
|
||||
|
||||
void CSimpleTextBoxWidget::HideTextBox()
|
||||
{
|
||||
timeLine->setDirection(QTimeLine::Backward);
|
||||
timeLine->start();
|
||||
//hide();
|
||||
}
|
||||
|
||||
void CSimpleTextBoxWidget::InsertString(QString TextLine)
|
||||
{
|
||||
if(!mText.isEmpty())
|
||||
mText += '\n';
|
||||
mText += TextLine;
|
||||
update(rect());
|
||||
}
|
||||
|
||||
void CSimpleTextBoxWidget::ClearText()
|
||||
{
|
||||
mText.clear();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121220 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SIMPLETEXTBOXWIDGET_H
|
||||
#define SIMPLETEXTBOXWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
//#include <QObject>
|
||||
#include <QTimeLine>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QString>
|
||||
|
||||
class CSimpleTextBoxWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
|
||||
CSimpleTextBoxWidget(QGraphicsItem *parent = 0);
|
||||
~CSimpleTextBoxWidget();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
void InsertString(QString TextLine);
|
||||
void ClearText(void);
|
||||
|
||||
|
||||
void ShowTextBox(void);
|
||||
void HideTextBox(void);
|
||||
protected:
|
||||
// virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setValue(qreal value);
|
||||
|
||||
private:
|
||||
QTimeLine *timeLine;
|
||||
qreal opacity;
|
||||
QString mText;
|
||||
|
||||
};
|
||||
|
||||
#endif //CALLERIDWIDGET_H
|
||||
@@ -0,0 +1,252 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Affiche une barre d'informations.
|
||||
|
||||
Utilisé sur la page principale de la ZT.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "StatusBar.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CStatusBar::CStatusBar(QGraphicsItem *Parent)
|
||||
{
|
||||
|
||||
setParentItem(Parent);
|
||||
resize(SCREEN_RES_WIDTH,25);
|
||||
|
||||
mZT1StatusString = "INACTIVE";
|
||||
mZT2StatusString = "INACTIVE";
|
||||
mNbTrainsPass = 10;
|
||||
mNbTriggers = 2;
|
||||
|
||||
mZT1Status = mZT2Status = SB_ZT_INACTIVE_STATUS;
|
||||
mCCModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
mSEIModbusState = SB_MODBUS_NOT_PRESENT;
|
||||
// QGraphicsRectItem *temprect = new QGraphicsRectItem(this);
|
||||
// temprect->setRect(boundingRect());
|
||||
// temprect->show();
|
||||
}
|
||||
|
||||
void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
||||
Q_UNUSED(widget)
|
||||
|
||||
|
||||
painter->setClipRect(option->exposedRect);
|
||||
|
||||
QPen RectPen(Qt::SolidLine);
|
||||
RectPen.setWidth(2);
|
||||
painter->setPen(RectPen);
|
||||
painter->drawLine(boundingRect().topLeft(),boundingRect().topRight());
|
||||
|
||||
QFont font;
|
||||
QString Text;
|
||||
QRectF TextRect = boundingRect();
|
||||
QFontMetrics FontMetrics = painter->fontMetrics();
|
||||
//font.setPixelSize(1);
|
||||
font.setPointSize(15);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
Text = "ZT1: ";
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
switch(mZT1Status)
|
||||
{
|
||||
case SB_ZT_ACTIVE_STATUS:
|
||||
{
|
||||
Text = "ACTIVE";
|
||||
painter->setPen(Qt::red);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_INACTIVE_STATUS:
|
||||
{
|
||||
Text = "INACTIVE";
|
||||
painter->setPen(Qt::darkGreen);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_NOT_PRESENT_STATUS:
|
||||
{
|
||||
Text = "ABSENTE";
|
||||
painter->setPen(Qt::black);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_DISABLED_STATUS:
|
||||
{
|
||||
Text = "HORS SERVICE";
|
||||
painter->setPen(Qt::darkYellow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
font.setBold(true);
|
||||
painter->drawText(TextRect,Qt::AlignLeft,Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
Text = "ZT2: ";
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
switch(mZT2Status)
|
||||
{
|
||||
case SB_ZT_ACTIVE_STATUS:
|
||||
{
|
||||
Text = "ACTIVE";
|
||||
painter->setPen(Qt::red);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_INACTIVE_STATUS:
|
||||
{
|
||||
Text = "INACTIVE";
|
||||
painter->setPen(Qt::darkGreen);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_NOT_PRESENT_STATUS:
|
||||
{
|
||||
Text = "ABSENTE";
|
||||
painter->setPen(Qt::black);
|
||||
break;
|
||||
}
|
||||
case SB_ZT_DISABLED_STATUS:
|
||||
{
|
||||
Text = "HORS SERVICE";
|
||||
painter->setPen(Qt::darkYellow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
font.setBold(true);
|
||||
painter->drawText(TextRect,Qt::AlignLeft,Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
Text.clear();
|
||||
Text.sprintf("Passages:%d",mNbTrainsPass);
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
Text.clear();
|
||||
Text.sprintf("Déclenchements:%d",mNbTriggers);
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
if(mCCModbusState != SB_MODBUS_NOT_PRESENT || mSEIModbusState != SB_MODBUS_NOT_PRESENT)
|
||||
{
|
||||
painter->setPen(Qt::black);
|
||||
Text.clear();
|
||||
Text.sprintf("Modbus:");
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
|
||||
if(mCCModbusState == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
painter->setPen(Qt::darkGreen);
|
||||
Text.clear();
|
||||
Text.sprintf("CC[Connecté]");
|
||||
TextRect.adjust(5,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
else if(mCCModbusState == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
painter->setPen(Qt::red);
|
||||
Text.clear();
|
||||
Text.sprintf("CC[Déconnecté]");
|
||||
TextRect.adjust(5,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
|
||||
if(mSEIModbusState == SB_MODBUS_CONNECTED)
|
||||
{
|
||||
painter->setPen(Qt::darkGreen);
|
||||
Text.clear();
|
||||
Text.sprintf("SEI[Connecté]");
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
else if(mSEIModbusState == SB_MODBUS_DISCONNECTED)
|
||||
{
|
||||
painter->setPen(Qt::red);
|
||||
Text.clear();
|
||||
Text.sprintf("SEI[Déconnecté]");
|
||||
TextRect.adjust(20,0,0,0);
|
||||
painter->drawText(TextRect, Qt::AlignLeft, Text);
|
||||
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetNbPass(unsigned int Value)
|
||||
{
|
||||
mNbTrainsPass = Value;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetNbTriggers(unsigned int Value)
|
||||
{
|
||||
mNbTriggers = Value;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetZT1Status(unsigned int Status)
|
||||
{
|
||||
mZT1Status = Status;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetZT2Status(unsigned int Status)
|
||||
{
|
||||
mZT2Status = Status;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CStatusBar::SetCCModbusState(unsigned int State)
|
||||
{
|
||||
mCCModbusState = State;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
unsigned int CStatusBar::SetSEIModbusState(unsigned int State)
|
||||
{
|
||||
mSEIModbusState = State;
|
||||
update(boundingRect());
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef STATUSBAR_H
|
||||
#define STATUSBAR_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
enum eZTStatus
|
||||
{
|
||||
SB_ZT_ACTIVE_STATUS,
|
||||
SB_ZT_INACTIVE_STATUS,
|
||||
SB_ZT_NOT_PRESENT_STATUS,
|
||||
SB_ZT_DISABLED_STATUS,
|
||||
SB_ZT_MAX_STATUS
|
||||
};
|
||||
|
||||
enum eModbusState
|
||||
{
|
||||
SB_MODBUS_NOT_PRESENT,
|
||||
SB_MODBUS_DISCONNECTED,
|
||||
SB_MODBUS_CONNECTED
|
||||
};
|
||||
|
||||
class CStatusBar : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CStatusBar(QGraphicsItem *Parent = 0);
|
||||
|
||||
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
unsigned int SetZT1Status(unsigned int Status);
|
||||
unsigned int SetZT2Status(unsigned int Status);
|
||||
unsigned int SetNbPass(unsigned int Value);
|
||||
unsigned int SetNbTriggers(unsigned int Value);
|
||||
unsigned int SetCCModbusState(unsigned int State);
|
||||
unsigned int SetSEIModbusState(unsigned int State);
|
||||
|
||||
private:
|
||||
QString mZT1StatusString, mZT2StatusString;
|
||||
unsigned int mZT1Status, mZT2Status;
|
||||
unsigned int mNbTrainsPass, mNbTriggers;
|
||||
unsigned int mCCModbusState, mSEIModbusState;
|
||||
};
|
||||
|
||||
#endif // STATUSBAR_H
|
||||
@@ -0,0 +1,157 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche un CDV d'aiguillage. L'affichage change en fonction de l'état
|
||||
du CDV (libre, occupé, itinéraire commandé) et de sa position (droite, renversée)
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130524 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "SwitchCDVItem.h"
|
||||
#include <QPainter>
|
||||
#include "ZTData.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include "CDV.h"
|
||||
#include "SwitchCDV.h"
|
||||
|
||||
CSwitchCDVItem::CSwitchCDVItem(CCDV *CDVPtr,QGraphicsItem *Parent)
|
||||
:CCDVItem(CDVPtr,Parent)
|
||||
{
|
||||
mSwitchCDV = (CSwitchCDV*)CDVPtr;
|
||||
mSwitchPosition = mSwitchCDV->GetSwitchState();
|
||||
|
||||
mNormalCDVRect = rect();
|
||||
mNormalPainterPath.addRect(rect());
|
||||
|
||||
|
||||
|
||||
|
||||
qreal nibble = rect().width()*0.25;
|
||||
|
||||
int shim = 3;
|
||||
int WaysSpascing = rect().height() + 10;
|
||||
mReversedPainterPath.moveTo(0,pos().y()+WaysSpascing);
|
||||
mReversedPainterPath.lineTo(nibble-shim,pos().y()+WaysSpascing); // --
|
||||
mReversedPainterPath.lineTo(rect().width()-nibble-shim,0); // /
|
||||
mReversedPainterPath.lineTo(rect().width(),0); // --
|
||||
mReversedPainterPath.lineTo(rect().width(),rect().height()); // |
|
||||
mReversedPainterPath.lineTo(rect().width()-nibble+shim,rect().height()); // __
|
||||
mReversedPainterPath.lineTo(nibble+shim,pos().y()+WaysSpascing+rect().height()); // /
|
||||
mReversedPainterPath.lineTo(0,pos().y()+WaysSpascing+rect().height()); // __
|
||||
mReversedPainterPath.lineTo(0,pos().y()+WaysSpascing); // |
|
||||
|
||||
|
||||
this->setGeometry(0,0,90,70); //Change geometry so we can draw the reversed switch
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSwitchCDVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
|
||||
painter->setBrush(*mCurBrush);
|
||||
painter->setPen(Qt::black);
|
||||
//painter->drawRect(CDVRect);
|
||||
|
||||
if(mSwitchPosition == SWITCH_CDV_NORMAL_POSITION)
|
||||
{
|
||||
painter->drawPath(mNormalPainterPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->drawPath(mReversedPainterPath);
|
||||
}
|
||||
|
||||
// QRectF textRect(CDVRect.adjusted(-3,-3,-3,-3));
|
||||
// painter->drawRect(textRect);
|
||||
|
||||
int flags = Qt::AlignHCenter | Qt::AlignVCenter/* | Qt::TextWordWrap*/;
|
||||
|
||||
QFont font;
|
||||
// font.setPointSizeF(9.5);
|
||||
font.setPixelSize(13);
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(mNormalCDVRect, flags, mCDVLabel);
|
||||
|
||||
}
|
||||
|
||||
unsigned int CSwitchCDVItem::SetState(unsigned int State)
|
||||
{
|
||||
if(State >= CDV_STATE_UNKNOWN)
|
||||
return RET_ERROR;
|
||||
if(mCDVState == State)
|
||||
return RET_OK;
|
||||
|
||||
mCDVState = State;
|
||||
switch(State)
|
||||
{
|
||||
case CDV_STATE_OCCUPIED:
|
||||
{
|
||||
mCurBrush = mCDVOccupiedBrush;
|
||||
break;
|
||||
}
|
||||
case CDV_STATE_FREE:
|
||||
{
|
||||
mCurBrush = mCDVFreeBrush;
|
||||
break;
|
||||
}
|
||||
case CDV_STATE_ITI_CMD:
|
||||
{
|
||||
mCurBrush = mCDVITICommandedBrush;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mSwitchPosition = mSwitchCDV->GetSwitchState();
|
||||
|
||||
|
||||
update(rect());
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
//void CSwitchCDVItem::resizeEvent()
|
||||
//{
|
||||
//// mNormalPainterPath = QPainterPath();
|
||||
//// mNormalPainterPath.addRect(rect());
|
||||
//// mReversedPainterPath = QPainterPath();
|
||||
//// mReversedPainterPath.addRect(rect());
|
||||
//}
|
||||
|
||||
//void CSwitchCDVItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
//{
|
||||
// if(event->button() == Qt::LeftButton)
|
||||
// {
|
||||
// emit CDVRightClicked(this);
|
||||
// }
|
||||
//}
|
||||
|
||||
//void CSwitchCDVItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
//{
|
||||
// Q_UNUSED(event)
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QString>
|
||||
#include "CDVItem.h"
|
||||
#include <QPainterPath>
|
||||
|
||||
|
||||
#ifndef SWITCHCDVITEM_H
|
||||
#define SWITCHCDVITEM_H
|
||||
|
||||
class CCDV;
|
||||
class CSwitchCDV;
|
||||
|
||||
class CSwitchCDVItem : public CCDVItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CSwitchCDVItem(CCDV *CDVPtr,QGraphicsItem *Parent = 0);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
unsigned int SetParameters(QString Label/*, unsigned int posx, unsigned int posy*/);
|
||||
unsigned int SetState(unsigned int State);
|
||||
// unsigned int UpdateState();
|
||||
|
||||
protected:
|
||||
// virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
// virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
// virtual void resizeEvent();
|
||||
|
||||
private:
|
||||
|
||||
CSwitchCDV *mSwitchCDV;
|
||||
unsigned int mSwitchPosition;
|
||||
QPainterPath mNormalPainterPath, mReversedPainterPath;
|
||||
QRectF mNormalCDVRect;
|
||||
|
||||
//signals:
|
||||
// void CDVRightClicked(CCDVItem*);
|
||||
};
|
||||
|
||||
#endif // SWITCHCDVITEM_H
|
||||
@@ -0,0 +1,247 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Widget Bouton dans lequel est affiché du texte. Une image peut aussi être
|
||||
affichée à l'intérieur du bouton.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130306 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
CTextButtonWidget::CTextButtonWidget(QString Text, int TextButtonData,int ButtonHeight,int ButtonWidth,int FontSize, QPixmap *ButtonImage)
|
||||
{
|
||||
|
||||
if(ButtonImage)
|
||||
{
|
||||
mButtonImagePtr = ButtonImage;
|
||||
}
|
||||
else
|
||||
mButtonImagePtr = 0;
|
||||
|
||||
mIsPressed = false;
|
||||
mWidgetText = Text;
|
||||
mTextButtonData = TextButtonData;
|
||||
mButtonHeight = ButtonHeight;
|
||||
mBackgroundColor = QColor(245, 245, 255, 220);
|
||||
|
||||
if(FontSize == 0)
|
||||
mFontSize = mButtonHeight -10;
|
||||
else
|
||||
mFontSize = FontSize;
|
||||
|
||||
//Fit widget size with text
|
||||
|
||||
mTextFont.setPixelSize(mFontSize);
|
||||
mTextFont.setBold(true);
|
||||
|
||||
int IconOffset = 0;
|
||||
QFontMetrics FontMetrics(mTextFont);
|
||||
if(ButtonWidth == 0)
|
||||
{
|
||||
if(mButtonImagePtr != 0)
|
||||
IconOffset = mButtonHeight + 5;
|
||||
//mButtonWidth = FontMetrics.width(mWidgetText)+IconOffset + 10;
|
||||
mButtonWidth = FontMetrics.boundingRect(mWidgetText).width()+IconOffset + 10;
|
||||
}
|
||||
else
|
||||
mButtonWidth = ButtonWidth;
|
||||
|
||||
resize(mButtonWidth,mButtonHeight);
|
||||
|
||||
// setGeometry(0,0,TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||
setGeometry(0,0,rect().width(),rect().height());
|
||||
mIsSelected = false;
|
||||
mWidgetOrigin.setX(0);
|
||||
mWidgetOrigin.setY(0);
|
||||
|
||||
mTimeLine = new QTimeLine(200,this);
|
||||
mTimeLine->setCurveShape(QTimeLine::SineCurve);
|
||||
connect(mTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(TimeLineEvent(qreal)));
|
||||
|
||||
mButtonImagePtr = ButtonImage;
|
||||
|
||||
//QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||
QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),rect().width(),rect().height());
|
||||
|
||||
// QRectF textRect = WidgetRect.adjusted(5, 2, -2, -2);
|
||||
// int flags = Qt::AlignVCenter | Qt::AlignLeft;
|
||||
|
||||
}
|
||||
|
||||
void CTextButtonWidget::CheckScrolling()
|
||||
{
|
||||
int IconOffset = 0;
|
||||
if(mButtonImagePtr != 0)
|
||||
IconOffset = rect().height();
|
||||
|
||||
QFontMetrics FontMetrics(mTextFont);
|
||||
if(FontMetrics.boundingRect(mWidgetText).width()+IconOffset > rect().width())
|
||||
{
|
||||
mScrollingRequired = true;
|
||||
mWidgetText.append(" ");
|
||||
}
|
||||
else
|
||||
mScrollingRequired = false;
|
||||
}
|
||||
|
||||
void CTextButtonWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
PaintButtonWidget(painter,option,widget);
|
||||
}
|
||||
void CTextButtonWidget::PaintButtonWidget(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
|
||||
{
|
||||
Q_UNUSED(widget)
|
||||
Q_UNUSED(option)
|
||||
// painter->setOpacity(1);
|
||||
if(mIsPressed)
|
||||
painter->setPen(QPen(Qt::red, 2));
|
||||
else
|
||||
painter->setPen(QPen(Qt::black, 2));
|
||||
// if(mIsAnimating)
|
||||
// painter->setBrush(QColor(0, 50, 255, 220));
|
||||
// else
|
||||
//painter->setBrush(QColor(245, 245, 255, 220));
|
||||
painter->setBrush(mBackgroundColor);
|
||||
//QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||
QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),rect().width(),rect().height());
|
||||
|
||||
//painter->drawRoundedRect(WidgetRect,10,10);
|
||||
painter->drawRect(WidgetRect);
|
||||
|
||||
QRectF textRect;
|
||||
if(mButtonImagePtr)
|
||||
textRect = WidgetRect.adjusted(rect().height() + 5, 2, -2, -2); //if there is an image, it will be square so text must begin at 5 + height of button (height determines size of image)
|
||||
else
|
||||
textRect = WidgetRect.adjusted(5, 2, -2, -2);
|
||||
|
||||
int flags = Qt::AlignVCenter | Qt::AlignLeft;
|
||||
|
||||
// QFont font;
|
||||
// font.setPixelSize(mButtonHeight/2 - 10);
|
||||
// font.setBold(true);
|
||||
painter->setPen(QPen(Qt::black,1));
|
||||
painter->setFont(mTextFont);
|
||||
painter->drawText(textRect, flags, mWidgetText);
|
||||
|
||||
if(mButtonImagePtr)
|
||||
{
|
||||
painter->drawPixmap(WidgetRect.left(),WidgetRect.top(),mButtonImagePtr->scaled(rect().height(),rect().height()));
|
||||
}
|
||||
}
|
||||
|
||||
void CTextButtonWidget::SetButtonImage(QPixmap *ButtonImage)
|
||||
{
|
||||
if(ButtonImage != NULL)
|
||||
{
|
||||
mButtonImagePtr = ButtonImage;
|
||||
update(rect());
|
||||
}
|
||||
}
|
||||
|
||||
void CTextButtonWidget::SetButtonText(QString ButtonText)
|
||||
{
|
||||
mWidgetText = ButtonText;
|
||||
update(rect());
|
||||
}
|
||||
|
||||
void CTextButtonWidget::SetButtonPos(int x, int y)
|
||||
{
|
||||
mWidgetOrigin.setX(x);
|
||||
mWidgetOrigin.setY(y);
|
||||
}
|
||||
|
||||
void CTextButtonWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// qDebug("Mouse pressed Text Button Widget");
|
||||
// mIsSelected = true;
|
||||
// event->ignore();
|
||||
// update();
|
||||
|
||||
// qDebug("Mouse pressed Text Button Widget");
|
||||
mIsPressed = true;
|
||||
update(rect());
|
||||
emit TxtButtonPressed(this);
|
||||
// QGraphicsWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void CTextButtonWidget::SetBackgroundColor(QColor color)
|
||||
{
|
||||
mBackgroundColor = color;
|
||||
update(rect());
|
||||
}
|
||||
|
||||
void CTextButtonWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
///* qDebug("Mouse released Text Button Widget");
|
||||
// mIsSelected = false;
|
||||
// update();
|
||||
// if(isVisible())
|
||||
// emit clicked(this);
|
||||
// event->ignore();*/
|
||||
// //qDebug("Start Timeline");
|
||||
// mIsAnimating = true;
|
||||
// mTimeLine->start();
|
||||
// qDebug("Mouse released Text Button Widget");
|
||||
mIsPressed = false;
|
||||
update(rect());
|
||||
emit TxtButtonReleased(this);
|
||||
|
||||
// qDebug("Text Button Widget clicked");
|
||||
emit TxtButtonClicked(this);
|
||||
|
||||
// QGraphicsWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//void CTextButtonWidget::ButtonClicked()
|
||||
//{
|
||||
// mIsSelected = false;
|
||||
// qDebug("A button is clicked");
|
||||
//}
|
||||
|
||||
void CTextButtonWidget::TimeLineEvent(qreal value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
//// ClickTransparency = 255*value;
|
||||
|
||||
// update();
|
||||
|
||||
// if(value == 0)
|
||||
// {
|
||||
// mIsAnimating = false;
|
||||
// emit clicked(this);
|
||||
// }
|
||||
}
|
||||
|
||||
void CTextButtonWidget::TickScrollingText()
|
||||
{
|
||||
if(mScrollingRequired && isVisible())
|
||||
{
|
||||
QChar Character = mWidgetText.at(mSongNameIndex);
|
||||
mWidgetText.remove(mSongNameIndex,1);
|
||||
mWidgetText.append(Character);
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef TEXTBUTTONWIDGET_H
|
||||
#define TEXTBUTTONWIDGET_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
|
||||
#define TEXT_BUTTON_WIDGET_WIDTH 280
|
||||
#define TEXT_BUTTON_WIDGET_HEIGHT 25
|
||||
|
||||
class CTextButtonWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CTextButtonWidget(QString Text, int TextButtonData = 0,int ButtonHeight = TEXT_BUTTON_WIDGET_HEIGHT,int ButtonWidth = 0,int FontSize = 0,QPixmap *ButtonImage = 0);
|
||||
|
||||
QString mWidgetText;
|
||||
QString mDisplayText;
|
||||
int mTextButtonData;
|
||||
bool mIsSelected;
|
||||
QRectF mButtonsAreaWindow;
|
||||
QTimeLine *mTimeLine;
|
||||
bool mIsPressed;
|
||||
bool mScrollingRequired;
|
||||
qreal ClickTransparency;
|
||||
int mSongNameIndex;
|
||||
QPixmap *mButtonImagePtr;
|
||||
unsigned int mButtonHeight;
|
||||
unsigned int mButtonWidth;
|
||||
unsigned int mFontSize;
|
||||
QColor mBackgroundColor;
|
||||
QFont mTextFont;
|
||||
|
||||
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
void SetButtonPos(int x, int y);
|
||||
void PaintButtonWidget(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
void SetButtonImage(QPixmap *ButtonImage);
|
||||
void SetButtonText(QString ButtonText);
|
||||
void SetBackgroundColor(QColor color);
|
||||
void CheckScrolling(void);
|
||||
|
||||
|
||||
QPoint mWidgetOrigin;
|
||||
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
void ButtonClicked(void);
|
||||
|
||||
public slots:
|
||||
void TimeLineEvent(qreal value);
|
||||
void TickScrollingText();
|
||||
|
||||
signals:
|
||||
void TxtButtonClicked(CTextButtonWidget *TextButtonPtr);
|
||||
void TxtButtonPressed(CTextButtonWidget *TextButtonPtr);
|
||||
void TxtButtonReleased(CTextButtonWidget *TextButtonPtr);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TEXTBUTTONWIDGET_H
|
||||
@@ -0,0 +1,130 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Widget Bouton de style "toggle" qui affiche une image lorsqu'il est désactivé
|
||||
et une autre image lorsqu'il est activé.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130306 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ToggleButtonWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
CToggleButtonWidget::CToggleButtonWidget(QString ONImageFilePath, QString OFFImageFilePath,QGraphicsItem *Parent, QString Label)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
mButtonState = TOGGLE_BUTTON_OFF;
|
||||
|
||||
mONPixmap = new QGraphicsPixmapItem(QPixmap(ONImageFilePath), this);
|
||||
mONPixmap->hide();
|
||||
mOFFPixmap = new QGraphicsPixmapItem(QPixmap(OFFImageFilePath), this);
|
||||
mOFFPixmap->show();
|
||||
|
||||
mButtonEnabled = true;
|
||||
mButtonData = 0;
|
||||
|
||||
if(Label.isEmpty() == false)
|
||||
{
|
||||
QGraphicsTextItem *BtnLabel = new QGraphicsTextItem(this);
|
||||
BtnLabel->setPlainText(Label);
|
||||
BtnLabel->adjustSize();
|
||||
BtnLabel->setPos(-BtnLabel->boundingRect().width()-3,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CToggleButtonWidget::SetData(unsigned int data)
|
||||
{
|
||||
mButtonData = data;
|
||||
}
|
||||
unsigned int CToggleButtonWidget::GetData()
|
||||
{
|
||||
return mButtonData;
|
||||
}
|
||||
|
||||
void CToggleButtonWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
void CToggleButtonWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
if(mButtonEnabled == false)
|
||||
return ;
|
||||
|
||||
if(mButtonState == TOGGLE_BUTTON_ON)
|
||||
mButtonState = TOGGLE_BUTTON_OFF;
|
||||
else
|
||||
mButtonState = TOGGLE_BUTTON_ON;
|
||||
|
||||
UpdateButton();
|
||||
emit ButtonToggled(this);
|
||||
}
|
||||
|
||||
void CToggleButtonWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
|
||||
mONPixmap->setPixmap(mONPixmap->pixmap().scaled(boundingRect().width(),boundingRect().height()));
|
||||
mOFFPixmap->setPixmap(mOFFPixmap->pixmap().scaled(boundingRect().width(),boundingRect().height()));
|
||||
}
|
||||
|
||||
unsigned int CToggleButtonWidget::GetButtonState()
|
||||
{
|
||||
return mButtonState;
|
||||
}
|
||||
|
||||
unsigned int CToggleButtonWidget::SetButtonEnabled(bool Enabled)
|
||||
{
|
||||
mButtonEnabled = Enabled;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CToggleButtonWidget::SetButtonState(unsigned int State)
|
||||
{
|
||||
if(mButtonState != TOGGLE_BUTTON_OFF && mButtonState != TOGGLE_BUTTON_ON)
|
||||
return RET_ERROR;
|
||||
|
||||
mButtonState = State;
|
||||
UpdateButton();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
void CToggleButtonWidget::UpdateButton()
|
||||
{
|
||||
if(mButtonState == TOGGLE_BUTTON_OFF)
|
||||
{
|
||||
mOFFPixmap->show();
|
||||
mONPixmap->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
mOFFPixmap->hide();
|
||||
mONPixmap->show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef TOGGLEBUTTONWIDGET_H
|
||||
#define TOGGLEBUTTONWIDGET_H
|
||||
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
|
||||
#define TOGGLE_BUTTON_ON 1
|
||||
#define TOGGLE_BUTTON_OFF 0
|
||||
|
||||
class CToggleButtonWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CToggleButtonWidget(QString ONImageFilePath, QString OFFImageFilePath,QGraphicsItem *Parent,QString Label = QString());
|
||||
|
||||
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
QGraphicsPixmapItem *mONPixmap, *mOFFPixmap;
|
||||
|
||||
unsigned int GetButtonState();
|
||||
unsigned int SetButtonState(unsigned int State);
|
||||
unsigned int SetButtonEnabled(bool Enabled);
|
||||
void SetData(unsigned int data);
|
||||
unsigned int GetData();
|
||||
|
||||
private:
|
||||
unsigned int mButtonState;
|
||||
bool mButtonEnabled;
|
||||
unsigned int mButtonData;
|
||||
|
||||
void UpdateButton();
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void ButtonToggled(CToggleButtonWidget*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TOGGLEBUTTONWIDGET_H
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef TOGGLEBUTTONWIDGET_H
|
||||
#define TOGGLEBUTTONWIDGET_H
|
||||
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
|
||||
#define TOGGLE_BUTTON_ON 1
|
||||
#define TOGGLE_BUTTON_OFF 0
|
||||
|
||||
class CToggleButtonWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CToggleButtonWidget(QString ONImageFilePath, QString OFFImageFilePath,QGraphicsItem *Parent,QString Label = QString());
|
||||
|
||||
|
||||
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
|
||||
QGraphicsPixmapItem *mONPixmap, *mOFFPixmap;
|
||||
|
||||
unsigned int GetButtonState();
|
||||
unsigned int SetButtonState(unsigned int State);
|
||||
unsigned int SetButtonEnabled(bool Enabled);
|
||||
void SetData(unsigned int data);
|
||||
unsigned int GetData();
|
||||
|
||||
private:
|
||||
unsigned int mButtonState;
|
||||
bool mButtonEnabled;
|
||||
unsigned int mButtonData;
|
||||
l
|
||||
void UpdateButton();
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void ButtonToggled(CToggleButtonWidget*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TOGGLEBUTTONWIDGET_H
|
||||
@@ -0,0 +1,105 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20130306 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QPainter>
|
||||
#include <ToggleTextButtonWidget.h>
|
||||
|
||||
CToggleTextButtonWidget::CToggleTextButtonWidget(QString ActivatedText, QString DeActivatedText, QPixmap ActivatedButtonImage, QPixmap DeActivatedButtonImage, int ButtonHeight,int ButtonWidth,int FontSize, int ToggleTextButtonData)
|
||||
{
|
||||
mButtonState = false;
|
||||
mActivatedBtnText = ActivatedText;
|
||||
mDeActivatedButtonText = DeActivatedText;
|
||||
mActivatedBtnImage = ActivatedButtonImage;
|
||||
mDeActivatedBtnImage = DeActivatedButtonImage;
|
||||
mButtonHeight = ButtonHeight;
|
||||
mButtonData = ToggleTextButtonData;
|
||||
|
||||
if(mDeActivatedBtnImage.isNull())
|
||||
mTextButton = new CTextButtonWidget(DeActivatedText,mButtonData,mButtonHeight,ButtonWidth,FontSize,0);
|
||||
else
|
||||
mTextButton = new CTextButtonWidget(DeActivatedText,mButtonData,mButtonHeight,ButtonWidth,FontSize,&mDeActivatedBtnImage);
|
||||
connect(mTextButton, SIGNAL(TxtButtonClicked(CTextButtonWidget *)), this, SLOT(ChildTextButtonClicked(CTextButtonWidget *)));
|
||||
|
||||
setGeometry(mTextButton->rect());
|
||||
mTextButton->setParentItem(this);
|
||||
}
|
||||
CToggleTextButtonWidget::~CToggleTextButtonWidget()
|
||||
{
|
||||
delete mTextButton;
|
||||
}
|
||||
|
||||
void CToggleTextButtonWidget::ChildTextButtonClicked(CTextButtonWidget *TextButtonPtr)
|
||||
{
|
||||
Q_UNUSED(TextButtonPtr)
|
||||
|
||||
if(mButtonState)
|
||||
{
|
||||
if(!mDeActivatedBtnImage.isNull())
|
||||
mTextButton->SetButtonImage(&mDeActivatedBtnImage);
|
||||
|
||||
mTextButton->SetButtonText(mDeActivatedButtonText);
|
||||
mTextButton->SetBackgroundColor(QColor(245, 245, 255, 220));
|
||||
mButtonState = false;
|
||||
emit ToggleBtnDeActivate(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!mActivatedBtnImage.isNull())
|
||||
mTextButton->SetButtonImage(&mActivatedBtnImage);
|
||||
|
||||
mTextButton->SetButtonText(mActivatedBtnText);
|
||||
mTextButton->SetBackgroundColor(Qt::green);
|
||||
mButtonState = true;
|
||||
emit ToggleBtnActivate(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CToggleTextButtonWidget::ForceActivation(bool Emit)
|
||||
{
|
||||
if(!mActivatedBtnImage.isNull())
|
||||
mTextButton->SetButtonImage(&mActivatedBtnImage);
|
||||
|
||||
mTextButton->SetButtonText(mActivatedBtnText);
|
||||
mTextButton->SetBackgroundColor(Qt::green);
|
||||
mButtonState = true;
|
||||
|
||||
if(Emit == true)
|
||||
emit ToggleBtnActivate(this);
|
||||
}
|
||||
void CToggleTextButtonWidget::ForceDeactivation(bool Emit)
|
||||
{
|
||||
if(!mDeActivatedBtnImage.isNull())
|
||||
mTextButton->SetButtonImage(&mDeActivatedBtnImage);
|
||||
|
||||
mTextButton->SetButtonText(mDeActivatedButtonText);
|
||||
mTextButton->SetBackgroundColor(QColor(245, 245, 255, 220));
|
||||
mButtonState = false;
|
||||
|
||||
if(Emit == true)
|
||||
emit ToggleBtnDeActivate(this);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef TOGGLETEXTBUTTONWIDGET_H
|
||||
#define TOGGLETEXTBUTTONWIDGET_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QRect>
|
||||
#include <QTimeLine>
|
||||
#include "TextButtonWidget.h"
|
||||
|
||||
#define TOGGLE_TEXT_BUTTON_WIDGET_WIDTH 280
|
||||
#define TOGGLE_TEXT_BUTTON_WIDGET_HEIGHT 25
|
||||
|
||||
class CToggleTextButtonWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CToggleTextButtonWidget(QString ActivatedText,QString DeActivatedText,
|
||||
QPixmap ActivatedButtonImage,QPixmap DeActivatedButtonImage,
|
||||
int ButtonHeight = TOGGLE_TEXT_BUTTON_WIDGET_HEIGHT,int ButtonWidth = 0,int FontSize = 0, int ToggleTextButtonData = 0);
|
||||
virtual ~CToggleTextButtonWidget();
|
||||
|
||||
void ForceDeactivation(bool Emit = false);
|
||||
void ForceActivation(bool Emit = false);
|
||||
bool GetActivationState(){return mButtonState;}
|
||||
|
||||
public slots:
|
||||
void ChildTextButtonClicked(CTextButtonWidget *TextButtonPtr);
|
||||
// void TxtButtonPressed(CTextButtonWidget *TextButtonPtr);
|
||||
// void TxtButtonReleased(CTextButtonWidget *TextButtonPtr);
|
||||
|
||||
signals:
|
||||
void ToggleBtnActivate(CToggleTextButtonWidget* ButtonInstancePtr);
|
||||
void ToggleBtnDeActivate(CToggleTextButtonWidget* ButtonInstancePtr);
|
||||
|
||||
private:
|
||||
CTextButtonWidget *mTextButton;
|
||||
QString mActivatedBtnText,mDeActivatedButtonText;
|
||||
QPixmap mActivatedBtnImage,mDeActivatedBtnImage;
|
||||
unsigned int mButtonHeight,mButtonWidth;
|
||||
int mButtonData;
|
||||
bool mButtonState; //false = deactivated(up), true = activated (down)
|
||||
|
||||
};
|
||||
|
||||
#endif // TOGGLETEXTBUTTONWIDGET_H
|
||||
@@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page qui est affichée lors du démarrage de l'application. Elle affiche tout
|
||||
simplement un message à l'utilisateur.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121220 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "WelcomePage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include "QCoreApplication"
|
||||
|
||||
|
||||
|
||||
CWelcomePage::CWelcomePage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
setGeometry(0,0,SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||
|
||||
mTextBoxWidget.setParentItem(this);
|
||||
|
||||
CEngLog::instance()->AddLogString("CWelcomePage::CWelcomePage. CWelcomePage créée avec succès",2);
|
||||
|
||||
}
|
||||
|
||||
void CWelcomePage::InsertTextBoxString(QString string)
|
||||
{
|
||||
mTextBoxWidget.InsertString(string);
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
void CWelcomePage::ClearTextBoxWidget()
|
||||
{
|
||||
mTextBoxWidget.ClearText();
|
||||
}
|
||||
|
||||
void CWelcomePage::ShowTextboxWidget()
|
||||
{
|
||||
mTextBoxWidget.ShowTextBox();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121220 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef WELCOMEPAGE_H
|
||||
#define WELCOMEPAGE_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "SimpleTextBoxWidget.h"
|
||||
|
||||
|
||||
|
||||
class CWelcomePage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CWelcomePage(QGraphicsWidget *Parent = 0);
|
||||
|
||||
|
||||
void ClearTextBoxWidget(void);
|
||||
void InsertTextBoxString(QString string);
|
||||
void ShowTextboxWidget();
|
||||
|
||||
private:
|
||||
CSimpleTextBoxWidget mTextBoxWidget;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // WELCOMEPAGE_H
|
||||
@@ -0,0 +1,155 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche les équipements de la ZT1.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ZT1EquipmentWidget.h"
|
||||
#include <QPainter>
|
||||
|
||||
CZT1EquipmentWidget::CZT1EquipmentWidget(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
setGeometry(0,0,320,180);
|
||||
|
||||
QFont LabelFont;
|
||||
LabelFont.setPointSize(20);
|
||||
mZT1Label = new QGraphicsTextItem(this);
|
||||
mZT1Label->setFont(LabelFont);
|
||||
mZT1Label->setPlainText("ZT1 - Avant Gare");
|
||||
mZT1Label->setPos(boundingRect().x()+(boundingRect().width()/2 - mZT1Label->boundingRect().width()/2),boundingRect().bottom()+10);
|
||||
|
||||
|
||||
mS1Activated = mS2Activated = mFNActivated = mPPEActivated = mPPIActivated = mPGEActivated = mPGIActivated = false;
|
||||
mZT1Active = true;
|
||||
|
||||
mFNRect1.setRect(0,50,boundingRect().width(),10);
|
||||
mFNRect2.setRect(0,boundingRect().bottom()-50,boundingRect().width(),10);
|
||||
|
||||
mPGERect.setRect(boundingRect().width()/2-10,10,20,20);
|
||||
mPGIRect.setRect(boundingRect().width()/2-10,boundingRect().bottom()-20,20,20);
|
||||
|
||||
mPPERect.setRect(boundingRect().width()-50,65,10,20);
|
||||
mPPIRect.setRect(boundingRect().width()-50,boundingRect().bottom() - 75,10,20);
|
||||
|
||||
mS1Rect.setRect(boundingRect().right()-30,boundingRect().bottom()-30,30,20);
|
||||
mS2Rect.setRect(0,boundingRect().bottom()-30,30,20);
|
||||
|
||||
|
||||
mRedBrush = new QBrush(Qt::red);
|
||||
mGreenBrush = new QBrush(Qt::darkGreen);
|
||||
mHashedBrush = new QBrush(Qt::darkGray/*,Qt::Dense2Pattern*/);
|
||||
}
|
||||
|
||||
void CZT1EquipmentWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
// static int toto = 0;
|
||||
// qDebug("CZT1EquipmentWidget::paint %d",toto++);
|
||||
|
||||
if(mZT1Active == false)
|
||||
{
|
||||
painter->fillRect(mFNRect1,*mHashedBrush);
|
||||
painter->fillRect(mFNRect2,*mHashedBrush);
|
||||
painter->fillRect(mPGERect,*mHashedBrush);
|
||||
painter->fillRect(mPGIRect,*mHashedBrush);
|
||||
painter->fillRect(mS1Rect,*mHashedBrush);
|
||||
painter->fillRect(mS2Rect,*mHashedBrush);
|
||||
painter->fillRect(mPPERect,*mHashedBrush);
|
||||
painter->fillRect(mPPIRect,*mHashedBrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
QBrush *brush;
|
||||
|
||||
if(mS1Activated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mS1Rect,*brush);
|
||||
|
||||
if(mS2Activated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mS2Rect,*brush);
|
||||
|
||||
if(mPGEActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPGERect,*brush);
|
||||
|
||||
if(mPGIActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPGIRect,*brush);
|
||||
|
||||
if(mPPEActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPPERect,*brush);
|
||||
|
||||
if(mPPIActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPPIRect,*brush);
|
||||
|
||||
if(mFNActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mFNRect1,*brush);
|
||||
painter->fillRect(mFNRect2,*brush);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CZT1EquipmentWidget::SetState(bool S1, bool S2, bool FN, bool PI, bool PE, bool PPI, bool PPE)
|
||||
{
|
||||
mS1Activated = S1;
|
||||
mS2Activated = S2;
|
||||
mFNActivated = FN;
|
||||
mPGIActivated = PI;
|
||||
mPGEActivated = PE;
|
||||
mPPIActivated = PPI;
|
||||
mPPEActivated = PPE;
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT1EquipmentWidget::SetActivation(bool IsActive)
|
||||
{
|
||||
mZT1Active = IsActive;
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZT1EQUIPMENTWIDGET_H
|
||||
#define ZT1EQUIPMENTWIDGET_H
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QBrush>
|
||||
|
||||
class CZT1EquipmentWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZT1EquipmentWidget(QGraphicsItem *parent = 0);
|
||||
|
||||
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
unsigned int SetState(bool S1, bool S2, bool FN, bool PI, bool PE,bool PPI,bool PPE);
|
||||
unsigned int SetActivation(bool IsZT1Active);
|
||||
QGraphicsTextItem *mZT1Label;
|
||||
|
||||
private:
|
||||
bool mS1Activated,mS2Activated,mFNActivated,mPGEActivated,mPGIActivated,mZT1Active,mPPIActivated,mPPEActivated;
|
||||
|
||||
QRectF mS1Rect,mS2Rect,mFNRect1,mFNRect2,mPGERect,mPGIRect,mPPERect,mPPIRect;
|
||||
QBrush *mGreenBrush, *mRedBrush, *mHashedBrush;
|
||||
};
|
||||
|
||||
#endif // ZT1EQUIPMENTWIDGET_H
|
||||
@@ -0,0 +1,208 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Zone de texte qui affiche les statistiques de passage d'un train dans la ZT1
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ZT1StatsZone.h"
|
||||
|
||||
CZT1StatsZone::CZT1StatsZone(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
|
||||
QFont font;
|
||||
//font.setPixelSize(15);
|
||||
font.setPointSize(15);
|
||||
|
||||
mTrainSpeedText = new QGraphicsTextItem(this);
|
||||
mTrainSpeedText->setPos(0,12);
|
||||
// mTrainSpeedText->setPlainText("Vitesse du train: 0");
|
||||
mTrainSpeedText->setFont(font);
|
||||
|
||||
mBogieCountText = new QGraphicsTextItem(this);
|
||||
mBogieCountText->setPos(0,34);
|
||||
// mBogieCountText->setPlainText("Compte Bogie: 0");
|
||||
mBogieCountText->setFont(font);
|
||||
|
||||
mS1CountText = new QGraphicsTextItem(this);
|
||||
mS1CountText->setPos(0,56);
|
||||
// mS1CountText->setPlainText("Compte S1: 0");
|
||||
mS1CountText->setFont(font);
|
||||
|
||||
mS2CountText = new QGraphicsTextItem(this);
|
||||
mS2CountText->setPos(0,78);
|
||||
// mS2CountText->setPlainText("Compte S2: 0");
|
||||
mS2CountText->setFont(font);
|
||||
|
||||
mFNCountText = new QGraphicsTextItem(this);
|
||||
mFNCountText->setPos(0,100);
|
||||
// mFNCountText->setPlainText("Compte FN: 0");
|
||||
mFNCountText->setFont(font);
|
||||
|
||||
mActualRankText = new QGraphicsTextItem(this);
|
||||
mActualRankText->setPos(0,122);
|
||||
// mActualRankText->setPlainText("Rang: 0");
|
||||
mActualRankText->setFont(font);
|
||||
|
||||
mTrainTypeText = new QGraphicsTextItem(this);
|
||||
mTrainTypeText->setPos(0,144);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mTrainTypeText->setFont(font);
|
||||
|
||||
mPIValueText = new QGraphicsTextItem(this);
|
||||
mPIValueText->setPos(0,166);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mPIValueText->setFont(font);
|
||||
|
||||
mPEValueText = new QGraphicsTextItem(this);
|
||||
mPEValueText->setPos(0,188);
|
||||
// mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mPEValueText->setFont(font);
|
||||
|
||||
|
||||
mLastActivationDateTime = new QGraphicsTextItem(this);
|
||||
mLastActivationDateTime->setPos(0,210);
|
||||
mLastActivationDateTime->setFont(font);
|
||||
mLastActivationDateTime->setPlainText("Dernier passage : ");
|
||||
|
||||
Reset();
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::UpdateStats(CZT1ThreadData *DataPtr)
|
||||
{
|
||||
QString temp;
|
||||
|
||||
if(mBogieCount != DataPtr->mBogie)
|
||||
{
|
||||
mBogieCount = DataPtr->mBogie;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte Bogie: %d",mBogieCount);
|
||||
mBogieCountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mS1Count != DataPtr->mS1Count)
|
||||
{
|
||||
mS1Count = DataPtr->mS1Count;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte S1: %d",mS1Count);
|
||||
mS1CountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mS2Count != DataPtr->mS2Count)
|
||||
{
|
||||
mS2Count = DataPtr->mS2Count;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte S2: %d",mS2Count);
|
||||
mS2CountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mFNCount != DataPtr->mFNCount)
|
||||
{
|
||||
mFNCount = DataPtr->mFNCount;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte FN: %d",mFNCount);
|
||||
mFNCountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mActualRank != DataPtr->mRank)
|
||||
{
|
||||
mActualRank = DataPtr->mRank;
|
||||
temp.clear();
|
||||
temp.sprintf("Rang: %d",mActualRank);
|
||||
mActualRankText->setPlainText(temp);
|
||||
}
|
||||
|
||||
|
||||
if(mTrainSpeed != DataPtr->mTrainSpeed)
|
||||
{
|
||||
mTrainSpeed = DataPtr->mTrainSpeed;
|
||||
temp.clear();
|
||||
temp.sprintf("Vitesse du train: %.2f Mph",mTrainSpeed);
|
||||
mTrainSpeedText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mTrainType != DataPtr->mTrainType)
|
||||
{
|
||||
mTrainType = DataPtr->mTrainType;
|
||||
temp.clear();
|
||||
temp = "Train détecté: ";
|
||||
temp += CZTData::GetTrainTypeString(mTrainType);
|
||||
mTrainTypeText->setPlainText(temp);
|
||||
}
|
||||
if(mPIValue != DataPtr->mPGIntValue)
|
||||
{
|
||||
mPIValue = DataPtr->mPGIntValue;
|
||||
temp.clear();
|
||||
temp = "Train détecté: ";
|
||||
temp.sprintf("Pneu Guidage Int.: %i",mPIValue);
|
||||
mPIValueText->setPlainText(temp);
|
||||
}
|
||||
if(mPEValue != DataPtr->mPGExtValue)
|
||||
{
|
||||
mPEValue = DataPtr->mPGExtValue;
|
||||
temp.clear();
|
||||
temp = "Train détecté: ";
|
||||
temp.sprintf("Pneu Guidage Ext.: %i",mPEValue);
|
||||
mPEValueText->setPlainText(temp);
|
||||
}
|
||||
|
||||
|
||||
return RET_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::SetLastActivationDateTime()
|
||||
{
|
||||
QString txt = "Dernier passage: ";
|
||||
txt += QDateTime::currentDateTime().toString("yyyy/MM/dd - hh:mm:ss");
|
||||
mLastActivationDateTime->setPlainText(txt);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT1StatsZone::Reset()
|
||||
{
|
||||
mBogieCount = mS1Count = mS2Count = mFNCount = mActualRank = mActualBogie = mTrainType = 0;
|
||||
mTrainSpeed = 0.0;
|
||||
mPEValue = 0;
|
||||
mPIValue = 0;
|
||||
|
||||
mTrainSpeedText->setPlainText("Vitesse du train: 0");
|
||||
mBogieCountText->setPlainText("Compte Bogie: 0");
|
||||
mS1CountText->setPlainText("Compte S1: 0");
|
||||
mS2CountText->setPlainText("Compte S2: 0");
|
||||
mFNCountText->setPlainText("Compte FN: 0");
|
||||
mActualRankText->setPlainText("Rang: 0");
|
||||
mTrainTypeText->setPlainText("Train Détecté: Aucun");
|
||||
mPIValueText->setPlainText("Pneu Guidage Int.: ?");
|
||||
mPEValueText->setPlainText("Pneu Guidage Ext.: ?");
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZT1STATSZONE_H
|
||||
#define ZT1STATSZONE_H
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QGraphicsTextItem>
|
||||
#include "ZTData.h"
|
||||
|
||||
class CZT1StatsZone : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZT1StatsZone(QGraphicsItem *Parent);
|
||||
|
||||
// unsigned int UpdateStats(unsigned int BogieCount, unsigned int S1Count, unsigned int S2Count, unsigned int FNCount, unsigned int Rank, unsigned int Bogie, unsigned int TrainType, float TrainSpeed);
|
||||
unsigned int UpdateStats(CZT1ThreadData *DataPtr);
|
||||
unsigned int Reset();
|
||||
unsigned int SetLastActivationDateTime();
|
||||
|
||||
private:
|
||||
unsigned int mBogieCount,mS1Count,mS2Count,mFNCount,mActualRank,mActualBogie,mTrainType;
|
||||
float mTrainSpeed;
|
||||
int mPIValue, mPEValue;
|
||||
|
||||
QGraphicsTextItem *mTrainSpeedText, *mBogieCountText, *mS1CountText, *mS2CountText, *mFNCountText, *mActualRankText, *mActualBogieText, *mTrainTypeText, *mPIValueText, *mPEValueText, *mLastActivationDateTime;
|
||||
};
|
||||
|
||||
#endif // ZT1STATSZONE_H
|
||||
@@ -0,0 +1,115 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Élément graphique qui affiche les équipements de la ZT2.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ZT2EquipmentWidget.h"
|
||||
#include <QPainter>
|
||||
|
||||
CZT2EquipmentWidget::CZT2EquipmentWidget(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
setGeometry(0,0,200,180);
|
||||
|
||||
QFont LabelFont;
|
||||
LabelFont.setPointSize(20);
|
||||
mZT2Label = new QGraphicsTextItem(this);
|
||||
mZT2Label->setFont(LabelFont);
|
||||
mZT2Label->setPlainText("ZT2 - Arrière Gare");
|
||||
mZT2Label->setPos(boundingRect().x()+(boundingRect().width()/2 - mZT2Label->boundingRect().width()/2),boundingRect().bottom()+10);
|
||||
|
||||
mS1Activated = mPPEActivated = mPPIActivated = false;
|
||||
mZT2Active = false;
|
||||
|
||||
mRailRect1.setRect(0,50,boundingRect().width(),10);
|
||||
mRailRect2.setRect(0,boundingRect().bottom()-50,boundingRect().width(),10);
|
||||
mPPERect.setRect(60,65,10,20);
|
||||
mPPIRect.setRect(60,boundingRect().bottom() - 75,10,20);
|
||||
|
||||
mS1Rect.setRect(boundingRect().right()-60,boundingRect().bottom()-30,30,20);
|
||||
|
||||
mRedBrush = new QBrush(Qt::red);
|
||||
mGreenBrush = new QBrush(Qt::darkGreen);
|
||||
mHashedBrush = new QBrush(Qt::darkGray/*,Qt::Dense2Pattern*/);
|
||||
}
|
||||
|
||||
void CZT2EquipmentWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
|
||||
if(mZT2Active == false)
|
||||
{
|
||||
painter->fillRect(mS1Rect,*mHashedBrush);
|
||||
painter->fillRect(mPPERect,*mHashedBrush);
|
||||
painter->fillRect(mPPIRect,*mHashedBrush);
|
||||
painter->fillRect(mRailRect1,*mHashedBrush);
|
||||
painter->fillRect(mRailRect2,*mHashedBrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
QBrush *brush;
|
||||
|
||||
painter->fillRect(mRailRect1,*mGreenBrush);
|
||||
painter->fillRect(mRailRect2,*mGreenBrush);
|
||||
|
||||
if(mS1Activated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mS1Rect,*brush);
|
||||
|
||||
if(mPPEActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPPERect,*brush);
|
||||
|
||||
if(mPPIActivated)
|
||||
brush = mRedBrush;
|
||||
else
|
||||
brush = mGreenBrush;
|
||||
painter->fillRect(mPPIRect,*brush);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CZT2EquipmentWidget::SetState(bool S1,bool PPI, bool PPE)
|
||||
{
|
||||
mS1Activated = S1;
|
||||
mPPIActivated = PPI;
|
||||
mPPEActivated = PPE;
|
||||
|
||||
update();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT2EquipmentWidget::SetActivation(bool IsActive)
|
||||
{
|
||||
mZT2Active = IsActive;
|
||||
update();
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131101 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZT2EQUIPMENTWIDGET_H
|
||||
#define ZT2EQUIPMENTWIDGET_H
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QBrush>
|
||||
|
||||
class CZT2EquipmentWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZT2EquipmentWidget(QGraphicsItem *parent = 0);
|
||||
|
||||
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
unsigned int SetState(bool S1,bool PPI,bool PPE);
|
||||
unsigned int SetActivation(bool IsZT2Active);
|
||||
|
||||
private:
|
||||
bool mS1Activated,mZT2Active,mPPIActivated,mPPEActivated;
|
||||
|
||||
QGraphicsTextItem *mZT2Label;
|
||||
|
||||
QRectF mS1Rect,mPPERect,mPPIRect,mRailRect1,mRailRect2;
|
||||
QBrush *mGreenBrush, *mRedBrush, *mHashedBrush;
|
||||
};
|
||||
|
||||
#endif // ZT2EQUIPMENTWIDGET_H
|
||||
@@ -0,0 +1,119 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Zone de texte qui affiche les statistiques de passage d'un train dans la ZT2.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131104 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ZT2StatsZone.h"
|
||||
|
||||
CZT2StatsZone::CZT2StatsZone(QGraphicsItem *Parent)
|
||||
{
|
||||
setParentItem(Parent);
|
||||
|
||||
QFont font;
|
||||
//font.setPixelSize(15);
|
||||
font.setPointSize(15);
|
||||
|
||||
mBogieCountText = new QGraphicsTextItem(this);
|
||||
mBogieCountText->setPos(0,12);
|
||||
// mBogieCountText->setPlainText("Compte Bogie: 0");
|
||||
mBogieCountText->setFont(font);
|
||||
|
||||
mS1CountText = new QGraphicsTextItem(this);
|
||||
mS1CountText->setPos(0,34);
|
||||
// mS1CountText->setPlainText("Compte S1: 0");
|
||||
mS1CountText->setFont(font);
|
||||
|
||||
mActualRankText = new QGraphicsTextItem(this);
|
||||
mActualRankText->setPos(0,56);
|
||||
// mActualRankText->setPlainText("Rang: 0");
|
||||
mActualRankText->setFont(font);
|
||||
|
||||
mLastActivationDateTime = new QGraphicsTextItem(this);
|
||||
mLastActivationDateTime->setPos(0,78);
|
||||
mLastActivationDateTime->setFont(font);
|
||||
mLastActivationDateTime->setPlainText("Dernier passage : ");
|
||||
|
||||
Reset();
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZT2StatsZone::SetLastActivationDateTime()
|
||||
{
|
||||
QString txt = "Dernier passage: ";
|
||||
txt += QDateTime::currentDateTime().toString("yyyy/MM/dd - hh:mm:ss");
|
||||
mLastActivationDateTime->setPlainText(txt);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZT2StatsZone::UpdateStats(CZT2ThreadData *DataPtr)
|
||||
{
|
||||
QString temp;
|
||||
|
||||
if(mBogieCount != DataPtr->mBogie)
|
||||
{
|
||||
mBogieCount = DataPtr->mBogie;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte Bogie: %d",mBogieCount);
|
||||
mBogieCountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mS1Count != DataPtr->mS1Count)
|
||||
{
|
||||
mS1Count = DataPtr->mS1Count;
|
||||
temp.clear();
|
||||
temp.sprintf("Compte S1: %d",mS1Count);
|
||||
mS1CountText->setPlainText(temp);
|
||||
}
|
||||
|
||||
if(mActualRank != DataPtr->mRank)
|
||||
{
|
||||
mActualRank = DataPtr->mRank;
|
||||
temp.clear();
|
||||
temp.sprintf("Rang: %d",mActualRank);
|
||||
mActualRankText->setPlainText(temp);
|
||||
}
|
||||
|
||||
|
||||
return RET_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZT2StatsZone::Reset()
|
||||
{
|
||||
mBogieCount = mS1Count = mActualRank = 0;
|
||||
|
||||
mBogieCountText->setPlainText("Compte Bogie: 0");
|
||||
mS1CountText->setPlainText("Compte S1: 0");
|
||||
mActualRankText->setPlainText("Rang: 0");
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131104 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZT2STATSZONE_H
|
||||
#define ZT2STATSZONE_H
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include <QGraphicsTextItem>
|
||||
#include "ZTData.h"
|
||||
|
||||
class CZT2StatsZone : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZT2StatsZone(QGraphicsItem *Parent);
|
||||
|
||||
// unsigned int UpdateStats(unsigned int BogieCount, unsigned int S1Count, unsigned int S2Count, unsigned int FNCount, unsigned int Rank, unsigned int Bogie, unsigned int TrainType, float TrainSpeed);
|
||||
unsigned int UpdateStats(CZT2ThreadData *DataPtr);
|
||||
unsigned int Reset();
|
||||
unsigned int SetLastActivationDateTime();
|
||||
|
||||
private:
|
||||
unsigned int mBogieCount,mS1Count,mActualRank;
|
||||
int mPIValue, mPEValue;
|
||||
|
||||
QGraphicsTextItem *mBogieCountText, *mS1CountText,*mActualRankText, *mLastActivationDateTime;
|
||||
};
|
||||
|
||||
#endif // ZT2STATSZONE_H
|
||||
@@ -0,0 +1,138 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page permettant de visualiser le fichier ZTLog.txt
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131021 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "ZTLogViewerPage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include "Zonetest.h"
|
||||
#include <QFont>
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "ZTLog.h"
|
||||
|
||||
|
||||
|
||||
CZTLogViewerPage::CZTLogViewerPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
Q_UNUSED(Parent)
|
||||
|
||||
|
||||
mProgramHandle = 0;
|
||||
|
||||
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||
mBackgroundRect->setBrush(BackgroundBrush);
|
||||
|
||||
QGraphicsTextItem *Title = new QGraphicsTextItem("Paramètres généraux",this);
|
||||
QFont font;
|
||||
font.setPointSize(18);
|
||||
Title->setFont(font);
|
||||
Title->setPos(40,10);
|
||||
|
||||
Title = new QGraphicsTextItem("Ajuster date & heure",this);
|
||||
Title->setFont(font);
|
||||
Title->setPos(270,130);
|
||||
|
||||
mCancelButton = new CTextButtonWidget("Fermer");
|
||||
mCancelButton->setParentItem(this);
|
||||
mCancelButton->setPos(700,550);
|
||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
|
||||
mDestroyZTLogBtn = new CTextButtonWidget("Détruire ZTLog");
|
||||
mDestroyZTLogBtn->setParentItem(this);
|
||||
mDestroyZTLogBtn->setPos(400,550);
|
||||
connect(mDestroyZTLogBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||
|
||||
mDestroyZTLogBtn->hide();
|
||||
|
||||
|
||||
mZTLogTextZone = new QTextEdit();
|
||||
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||
Proxy->setWidget(mZTLogTextZone);
|
||||
Proxy->setPos(10,10);
|
||||
mZTLogTextZone->resize(780,500);
|
||||
mZTLogTextZone->setReadOnly(true);
|
||||
mZTLogTextZone->setWordWrapMode(QTextOption::NoWrap);
|
||||
|
||||
}
|
||||
|
||||
void CZTLogViewerPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
|
||||
mBackgroundRect->setRect(boundingRect());
|
||||
}
|
||||
|
||||
void CZTLogViewerPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||
{
|
||||
if(BtnPtr == mCancelButton)
|
||||
{
|
||||
mProgramHandle->HideZTLogViewerPage();
|
||||
hide();
|
||||
}
|
||||
if(BtnPtr == mDestroyZTLogBtn)
|
||||
{
|
||||
CZTLog::instance()->DeleteLogFile();
|
||||
LoadAndDisplayZTLog();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CZTLogViewerPage::LoadAndDisplayZTLog()
|
||||
{
|
||||
mZTLogTextZone->clear();
|
||||
|
||||
mZTLogTextZone->setPlainText(CZTLog::instance()->GetEntireLogFile());
|
||||
|
||||
QTextCursor Cursor = mZTLogTextZone->textCursor();
|
||||
Cursor.movePosition(QTextCursor::End);
|
||||
mZTLogTextZone->setTextCursor(Cursor);
|
||||
mZTLogTextZone->ensureCursorVisible();
|
||||
}
|
||||
|
||||
void CZTLogViewerPage::showEvent(QShowEvent *event)
|
||||
{
|
||||
LoadAndDisplayZTLog();
|
||||
return;
|
||||
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
//Grab the mouse if the user clicks outside buttons
|
||||
void CZTLogViewerPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
void CZTLogViewerPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page permettant de visualiser le fichier ZTLog.txt
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20131122 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef ZTLOGVIEWERPAGE_H
|
||||
#define ZTLOGVIEWERPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "TextButtonWidget.h"
|
||||
#include <QTextEdit>
|
||||
|
||||
class CZoneTest;
|
||||
|
||||
class CZTLogViewerPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZTLogViewerPage(QGraphicsWidget *Parent = 0);
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void showEvent ( QShowEvent * event );
|
||||
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *mBackgroundRect;
|
||||
CTextButtonWidget *mCancelButton, *mDestroyZTLogBtn;
|
||||
QTextEdit *mZTLogTextZone;
|
||||
|
||||
void LoadAndDisplayZTLog();
|
||||
|
||||
|
||||
public slots:
|
||||
void ButtonClicked(CTextButtonWidget *);
|
||||
|
||||
};
|
||||
|
||||
#endif // ZTLOGVIEWERPAGE_H
|
||||
@@ -0,0 +1,451 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Page principale de la ZT. C'est sur cette dernière que tout est affiché.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121221 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#include "ZTPage.h"
|
||||
#include <QPainter>
|
||||
#include "GlobalDefine.h"
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
#include "Zonetest.h"
|
||||
#include <QDateTime>
|
||||
#include "ZTVersion.h"
|
||||
#include "SwitchCDVItem.h"
|
||||
|
||||
|
||||
|
||||
CZTPage::CZTPage(QGraphicsWidget *Parent)
|
||||
{
|
||||
// Q_UNUSED(Parent)
|
||||
setGeometry(0,0,SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||
|
||||
mProgramHandle = 0;
|
||||
mZTSimulatorPtr = 0;
|
||||
|
||||
QGraphicsTextItem *SoftVersion = new QGraphicsTextItem(this);
|
||||
QFont TextFont;
|
||||
TextFont.setPointSize(15);
|
||||
TextFont.setBold(true);
|
||||
SoftVersion->setFont(TextFont);
|
||||
SoftVersion->setPlainText(QString().sprintf("Version: %s",ZT_SOFT_VERSION));
|
||||
SoftVersion->setZValue(1);
|
||||
SoftVersion->adjustSize();
|
||||
SoftVersion->setPos(800,2);
|
||||
|
||||
QGraphicsTextItem *ZTStartDateTime = new QGraphicsTextItem(this);
|
||||
ZTStartDateTime->setFont(TextFont);
|
||||
QString StartDateTime = "ZT démarrée le: ";
|
||||
StartDateTime += QDateTime::currentDateTime().toString("yyyy/MM/dd - hh:mm");
|
||||
ZTStartDateTime->setPlainText(StartDateTime);
|
||||
ZTStartDateTime->setZValue(1);
|
||||
//ZTStartDateTime->adjustSize();
|
||||
ZTStartDateTime->setPos(200,675);
|
||||
|
||||
mTimeDisplayText = new QGraphicsTextItem(this);
|
||||
mTimeDisplayText->setPos(400,2);
|
||||
// QFont TextFont;
|
||||
// TextFont.setPointSize(15);
|
||||
// TextFont.setBold(true);
|
||||
mTimeDisplayText->setFont(TextFont);
|
||||
mTimeDisplayText->setZValue(1);
|
||||
// mTimeDisplayText->adjustSize();
|
||||
|
||||
mToolsPushButton = new CPushButton(this,"./Images/tools.png");
|
||||
mToolsPushButton->setPos(25,650);
|
||||
mToolsPushButton->resize(50,50);
|
||||
connect( mToolsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT( SettingsButtonPressed() ) );
|
||||
|
||||
mZTLogPushButton = new CPushButton(this,"./Images/log.png");
|
||||
mZTLogPushButton->setPos(10,570);
|
||||
mZTLogPushButton->resize(65,65);
|
||||
connect( mZTLogPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT( ShowZTLogButtonPressed() ) );
|
||||
|
||||
CPushButton *LogsPushButton = new CPushButton(this,"./Images/Save-icon.png");
|
||||
LogsPushButton->setPos(10,490);
|
||||
LogsPushButton->resize(65,65);
|
||||
connect( LogsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(LogsButtonPressed()) );
|
||||
|
||||
mExitPasswordPrompt = new CPasswordPrompt(Parent);
|
||||
mExitPasswordPrompt->setZValue(2);
|
||||
mExitPasswordPrompt->hide();
|
||||
connect(mExitPasswordPrompt,SIGNAL(PasswordValid()),this,SLOT(ExitPasswordValid()));
|
||||
connect(mExitPasswordPrompt,SIGNAL(Canceled()),this,SLOT(ExitPasswordInvalid()));
|
||||
|
||||
mTimeDisplayTimer = new QTimer();
|
||||
connect(mTimeDisplayTimer,SIGNAL(timeout()),this,SLOT(UpdateTime()));
|
||||
mTimeDisplayTimer->setSingleShot(false);
|
||||
mTimeDisplayTimer->start(1000);
|
||||
|
||||
mStatusBar = new CStatusBar(this);
|
||||
mStatusBar->setPos(0,715);
|
||||
|
||||
mEventsBar = new CEventsBar(this);
|
||||
mEventsBar->setPos(0,715+mStatusBar->boundingRect().height());
|
||||
|
||||
mZT1EquipmentWidget = new CZT1EquipmentWidget(this);
|
||||
mZT1EquipmentWidget->setPos(512,150);
|
||||
|
||||
mZT2EquipmentWidget = new CZT2EquipmentWidget(this);
|
||||
mZT2EquipmentWidget->setPos(150,150);
|
||||
|
||||
mDeckRect = new QGraphicsRectItem(this);
|
||||
mDeckRect->hide();
|
||||
mDeckRect->setBrush(QBrush(Qt::Dense4Pattern));
|
||||
mDeckRect->setPen(QPen(Qt::transparent));
|
||||
|
||||
mIsZT2Present = true;
|
||||
|
||||
mZT1Stats = new CZT1StatsZone(this);
|
||||
mZT1Stats->setPos(mZT1EquipmentWidget->pos().x() + 70 ,100+mZT1EquipmentWidget->boundingRect().height() + 80);
|
||||
|
||||
mZT2Stats = new CZT2StatsZone(this);
|
||||
mZT2Stats->setPos(mZT2EquipmentWidget->pos().x() + 30,100+mZT2EquipmentWidget->boundingRect().height()+80);
|
||||
|
||||
mZT1DisplayTimer.start();
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZTSimulator(CZTSimulator *Ptr)
|
||||
{
|
||||
if(Ptr == 0)
|
||||
return RET_ERROR;
|
||||
|
||||
mZTSimulatorPtr = Ptr;
|
||||
mZTSimulatorPtr->setParentItem(this);
|
||||
mZTSimulatorPtr->setFlag(QGraphicsItem::ItemIsSelectable);
|
||||
mZTSimulatorPtr->setFlag(QGraphicsItem::ItemIsMovable);
|
||||
mZTSimulatorPtr->setFlag(QGraphicsItem::ItemSendsGeometryChanges);
|
||||
mZTSimulatorPtr->setGeometry(200,400,640,480);
|
||||
mZTSimulatorPtr->Show();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTPage::SettingsButtonPressed()
|
||||
{
|
||||
mProgramHandle->OptionsMenuPageSelected();
|
||||
}
|
||||
|
||||
void CZTPage::ShowZTLogButtonPressed()
|
||||
{
|
||||
mProgramHandle->ShowZTLogViewerPage();
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetStationName(QString Name)
|
||||
{
|
||||
QGraphicsTextItem *StationName = new QGraphicsTextItem(this);
|
||||
QFont TextFont;
|
||||
TextFont.setPointSize(18);
|
||||
TextFont.setBold(true);
|
||||
StationName->setFont(TextFont);
|
||||
StationName->setPlainText(Name);
|
||||
StationName->setZValue(1);
|
||||
StationName->adjustSize();
|
||||
StationName->setPos(50,2);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTPage::UpdateTime()
|
||||
{
|
||||
QDateTime time = QDateTime::currentDateTime();
|
||||
mTimeDisplayText->setPlainText(time.toString("yyyy/MM/dd hh:mm:ss"));
|
||||
|
||||
}
|
||||
|
||||
void CZTPage::LogsButtonPressed()
|
||||
{
|
||||
mProgramHandle->LogsPageSelected();
|
||||
}
|
||||
|
||||
|
||||
unsigned int CZTPage::SetCDVList(QList<CCDV *> *CDVListPtr)
|
||||
{
|
||||
if(CDVListPtr == 0)
|
||||
return RET_ERROR;
|
||||
|
||||
mCDVList = CDVListPtr;
|
||||
if(mCDVList->size() == 0)
|
||||
return RET_ERROR;
|
||||
|
||||
mCDVItemsList.clear();
|
||||
|
||||
int DeckPositionY = -1, DeckPositionX = -1, DeckWidth = 0;
|
||||
|
||||
//Create CDV graphical items list,
|
||||
//adjust all their position on screen and
|
||||
//set parameters
|
||||
// unsigned int LastPos = 0;
|
||||
for(int i = 0; i < mCDVList->size(); i++)
|
||||
{
|
||||
int x = 0, y = 70;
|
||||
int WaysSpacing = 10;
|
||||
CCDVItem *NewCDVGraphicalItem;
|
||||
// CCDV *temp = mCDVList->at(i);
|
||||
if(mCDVList->at(i)->GetCDVType() == CDV_NORMAL_TYPE)
|
||||
{
|
||||
NewCDVGraphicalItem = new CCDVItem(mCDVList->at(i),this);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewCDVGraphicalItem = new CSwitchCDVItem(mCDVList->at(i),this);
|
||||
|
||||
}
|
||||
|
||||
NewCDVGraphicalItem->SetParameters(mCDVList->at(i)->GetLabel());
|
||||
mCDVItemsList.append(NewCDVGraphicalItem);
|
||||
x = (mCDVList->at(i)->GetCDVGraphicalPos() * NewCDVGraphicalItem->geometry().width())+90;
|
||||
if(mCDVList->at(i)->GetCDVWay() == 2)
|
||||
y += WaysSpacing+NewCDVGraphicalItem->geometry().height();
|
||||
// NewCDVGraphicalItem->setPos(i*NewCDVGraphicalItem->geometry().width()+90,70);
|
||||
NewCDVGraphicalItem->setPos(x,y);
|
||||
NewCDVGraphicalItem->setZValue(3);
|
||||
|
||||
if(mCDVList->at(i)->IsCDVDeck() == true)
|
||||
{
|
||||
if(DeckPositionX == -1)
|
||||
{
|
||||
DeckPositionX = x/* + (NewCDVGraphicalItem->geometry().width()/2)*/;
|
||||
}
|
||||
DeckWidth += NewCDVGraphicalItem->geometry().width();
|
||||
|
||||
if(mCDVList->at(i)->GetCDVWay() == 1)
|
||||
{
|
||||
DeckPositionY = y - 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeckPositionY = y +NewCDVGraphicalItem->geometry().height() + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(DeckPositionX != -1)
|
||||
{
|
||||
mDeckRect->setRect(0,0,DeckWidth,20);
|
||||
mDeckRect->setPos(DeckPositionX,DeckPositionY);
|
||||
mDeckRect->show();
|
||||
}
|
||||
else
|
||||
mDeckRect->hide();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
unsigned int CZTPage::UpdateCDVDisplay(int CDVIndex)
|
||||
{
|
||||
if(CDVIndex >= mCDVItemsList.size())
|
||||
return RET_ERROR;
|
||||
|
||||
if(CDVIndex < 0 || CDVIndex >= mCDVItemsList.size())
|
||||
{
|
||||
for(int i = 0; i < mCDVItemsList.size(); i++)
|
||||
{
|
||||
mCDVItemsList.at(i)->UpdateState();
|
||||
}
|
||||
}
|
||||
else
|
||||
mCDVItemsList.at(CDVIndex)->UpdateState();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZTStatus(unsigned int NbPass, unsigned int NbTriggers, unsigned int ZT1Active, unsigned int ZT2Active)
|
||||
{
|
||||
mStatusBar->SetNbPass(NbPass);
|
||||
mStatusBar->SetNbTriggers(NbTriggers);
|
||||
// if(ZT1Active == true)
|
||||
// mStatusBar->SetZT1Status(SB_ZT_ACTIVE_STATUS);
|
||||
// else
|
||||
// mStatusBar->SetZT1Status(SB_ZT_INACTIVE_STATUS);
|
||||
mStatusBar->SetZT1Status(ZT1Active);
|
||||
|
||||
if(mIsZT2Present == true)
|
||||
{
|
||||
// if(ZT2Active == true)
|
||||
// {
|
||||
// mStatusBar->SetZT2Status(SB_ZT_ACTIVE_STATUS);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mStatusBar->SetZT2Status(SB_ZT_INACTIVE_STATUS);
|
||||
// }
|
||||
mStatusBar->SetZT2Status(ZT2Active);
|
||||
}
|
||||
else
|
||||
{
|
||||
mStatusBar->SetZT2Status(SB_ZT_NOT_PRESENT_STATUS);
|
||||
}
|
||||
|
||||
if(ZT1Active == SB_ZT_ACTIVE_STATUS)
|
||||
{
|
||||
mZT1EquipmentWidget->SetActivation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mZT1EquipmentWidget->SetActivation(false);
|
||||
}
|
||||
|
||||
|
||||
if(ZT2Active == SB_ZT_ACTIVE_STATUS)
|
||||
{
|
||||
mZT2EquipmentWidget->SetActivation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mZT2EquipmentWidget->SetActivation(false);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT1Data(CZT1ThreadData *Data, bool ForceDisplay)
|
||||
{
|
||||
if(Data == 0)
|
||||
return RET_ERROR;
|
||||
|
||||
//Unless specified by the ForceDisplay flag, limit refresh rate to 24 fps (~42 milliseconds)
|
||||
if(ForceDisplay == false && mZT1DisplayTimer.elapsed() < 42)
|
||||
{
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
mZT1EquipmentWidget->SetState((bool)Data->mS1,(bool)Data->mS2,(bool)Data->mFN,(bool)Data->mPG,(bool)Data->mPG,(bool)Data->mPInt,(bool)Data->mPExt);
|
||||
mZT1Stats->UpdateStats(Data);
|
||||
mZT1DisplayTimer.start();
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT2Data(CZT2ThreadData *Data)
|
||||
{
|
||||
if(Data == 0)
|
||||
return RET_ERROR;
|
||||
mZT2EquipmentWidget->SetState(Data->mS1,Data->mPPInt,Data->mPPExt);
|
||||
mZT2Stats->UpdateStats(Data);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT1ActivationState(bool ZT1Activated)
|
||||
{
|
||||
if(ZT1Activated)
|
||||
{
|
||||
// mZT1EquipmentWidget->SetActivation(true);
|
||||
mZT1Stats->SetLastActivationDateTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
// mZT1EquipmentWidget->SetActivation(false);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
unsigned int CZTPage::SetZT2ActivationSTate(bool ZT2Activated)
|
||||
{
|
||||
if(ZT2Activated)
|
||||
{
|
||||
// mZT2EquipmentWidget->SetActivation(true);
|
||||
mZT2Stats->SetLastActivationDateTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
// mZT2EquipmentWidget->SetActivation(false);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::ResetZT1Stats()
|
||||
{
|
||||
mZT1Stats->Reset();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::ResetZT2Stats()
|
||||
{
|
||||
mZT2Stats->Reset();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetEventListPtr(QList<CEvent *> *ListPtr)
|
||||
{
|
||||
mEventsBar->mEventsList = ListPtr;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
unsigned int CZTPage::UpdateEventsList()
|
||||
{
|
||||
mEventsBar->UpdateEventsList();
|
||||
return RET_OK;
|
||||
}
|
||||
unsigned int CZTPage::RequestExitPassword()
|
||||
{
|
||||
mExitPasswordPrompt->RequestPassword();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTPage::ExitPasswordValid()
|
||||
{
|
||||
mProgramHandle->ProgramExitRequest();
|
||||
}
|
||||
|
||||
void CZTPage::ExitPasswordInvalid()
|
||||
{
|
||||
mExitPasswordPrompt->hide();
|
||||
}
|
||||
|
||||
unsigned int CZTPage::SetZT2Presence(bool IsPresent)
|
||||
{
|
||||
if(IsPresent == true) //The page is already initialized with ZT2 present
|
||||
return RET_OK;
|
||||
|
||||
mZT2Stats->hide();
|
||||
mZT2EquipmentWidget->hide();
|
||||
mStatusBar->SetZT2Status(SB_ZT_NOT_PRESENT_STATUS);
|
||||
mIsZT2Present = false;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTPage::ModbusCCConnected()
|
||||
{
|
||||
mStatusBar->SetCCModbusState(SB_MODBUS_CONNECTED);
|
||||
}
|
||||
|
||||
void CZTPage::ModbusCCDisconnected()
|
||||
{
|
||||
mStatusBar->SetCCModbusState(SB_MODBUS_DISCONNECTED);
|
||||
}
|
||||
|
||||
void CZTPage::ModbusSEIConnected()
|
||||
{
|
||||
mStatusBar->SetSEIModbusState(SB_MODBUS_CONNECTED);
|
||||
}
|
||||
|
||||
void CZTPage::ModbusSEIDisconnected()
|
||||
{
|
||||
mStatusBar->SetSEIModbusState(SB_MODBUS_DISCONNECTED);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121221 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
#ifndef ZTPAGE_H
|
||||
#define ZTPAGE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QGraphicsWidget>
|
||||
#include "Guipage.h"
|
||||
#include <QString>
|
||||
#include "PushButton.h"
|
||||
#include "ZTSimulator.h"
|
||||
#include "CDVItem.h"
|
||||
#include "CDV.h"
|
||||
#include "StatusBar.h"
|
||||
#include "ZT1EquipmentWidget.h"
|
||||
#include "ZT1StatsZone.h"
|
||||
#include "EventsBar.h"
|
||||
#include "ZT2EquipmentWidget.h"
|
||||
#include "ZT2StatsZone.h"
|
||||
#include "PasswordPrompt.h"
|
||||
|
||||
class CZoneTest;
|
||||
class CEvent;
|
||||
|
||||
class CZTPage : public CGuiPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZTPage(QGraphicsWidget *Parent = 0);
|
||||
CPushButton *mToolsPushButton;
|
||||
CPushButton *mZTLogPushButton;
|
||||
|
||||
|
||||
CZoneTest *mProgramHandle;
|
||||
CPasswordPrompt *mExitPasswordPrompt;
|
||||
|
||||
unsigned int SetZTSimulator(CZTSimulator* Ptr);
|
||||
unsigned int SetStationName(QString Name);
|
||||
unsigned int SetCDVList(QList<CCDV*> *CDVListPtr);
|
||||
|
||||
unsigned int UpdateCDVDisplay(int CDVIndex = -1);
|
||||
unsigned int SetZTStatus(unsigned int NbPass, unsigned int NbTriggers, unsigned int ZT1Active, unsigned int ZT2Active);
|
||||
unsigned int SetZT1Data(CZT1ThreadData *Data, bool ForceDisplay = false);
|
||||
unsigned int SetZT2Data(CZT2ThreadData *Data);
|
||||
unsigned int SetZT1ActivationState(bool ZT1Activated);
|
||||
unsigned int SetZT2ActivationSTate(bool ZT2Activated);
|
||||
unsigned int ResetZT1Stats();
|
||||
unsigned int ResetZT2Stats();
|
||||
unsigned int SetEventListPtr(QList<CEvent*>* ListPtr);
|
||||
unsigned int UpdateEventsList();
|
||||
unsigned int RequestExitPassword();
|
||||
unsigned int SetZT2Presence(bool IsPresent);
|
||||
|
||||
|
||||
private:
|
||||
CZTSimulator *mZTSimulatorPtr;
|
||||
QTimer *mTimeDisplayTimer;
|
||||
QGraphicsTextItem *mTimeDisplayText;
|
||||
QGraphicsRectItem *mDeckRect;
|
||||
CStatusBar *mStatusBar;
|
||||
CZT1EquipmentWidget *mZT1EquipmentWidget;
|
||||
CZT2EquipmentWidget *mZT2EquipmentWidget;
|
||||
CZT1StatsZone *mZT1Stats;
|
||||
CZT2StatsZone *mZT2Stats;
|
||||
CEventsBar *mEventsBar;
|
||||
QElapsedTimer mZT1DisplayTimer;
|
||||
bool mIsZT2Present;
|
||||
|
||||
|
||||
QList<CCDV*> *mCDVList; //pointer to the list of CDVs
|
||||
QList<CCDVItem*> mCDVItemsList; //Graphical representation items only
|
||||
|
||||
public slots:
|
||||
void SettingsButtonPressed();
|
||||
void LogsButtonPressed();
|
||||
void UpdateTime();
|
||||
void ExitPasswordValid();
|
||||
void ExitPasswordInvalid();
|
||||
void ShowZTLogButtonPressed();
|
||||
void ModbusCCConnected();
|
||||
void ModbusCCDisconnected();
|
||||
void ModbusSEIConnected();
|
||||
void ModbusSEIDisconnected();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // WELCOMEPAGE_H
|
||||
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "splashitem.h"
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
//! [0]
|
||||
SplashItem::SplashItem(QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
{
|
||||
text = tr("Welcome to the Pad Navigator Example. You can use the"
|
||||
" keyboard arrows to navigate the icons, and press enter"
|
||||
" to activate an item. Press any key to begin.");
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
}
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
QRectF SplashItem::boundingRect() const
|
||||
{
|
||||
return QRectF(0, 0, 400, 175);
|
||||
}
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
painter->setPen(QPen(Qt::black, 2));
|
||||
painter->setBrush(QColor(245, 245, 255, 220));
|
||||
painter->setClipRect(boundingRect());
|
||||
painter->drawRoundRect(3, -100 + 3, 400 - 6, 250 - 6);
|
||||
|
||||
QRectF textRect = boundingRect().adjusted(10, 10, -10, -10);
|
||||
int flags = Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap;
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(18);
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(textRect, flags, text);
|
||||
}
|
||||
//! [2]
|
||||
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SPLASHITEM_H
|
||||
#define SPLASHITEM_H
|
||||
|
||||
#include <QGraphicsObject>
|
||||
|
||||
//! [0]
|
||||
class SplashItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SplashItem(QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
private:
|
||||
QString text;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif // SPLASHITEM_H
|
||||
Reference in New Issue
Block a user