/*******************************************************************************
*                                                                              *
* 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;
}
