#include "crossWidget.hh"

using namespace mimas;

CrossWidget::CrossWidget( QWidget *parent, Qt::WFlags f ):
  VideoWidget( parent, f ), hasPoint(false), pointX( 0 ), pointY( 0 )
{
}

void CrossWidget::setCross( const Vector &v )
{
  hasPoint = true;
  pointX = (int)v[0];
  pointY = (int)v[1];
  update();
}

void CrossWidget::clearCross(void)
{
  hasPoint = false;
  update();
}

void CrossWidget::paintGL(void)
{
  VideoWidget::paintGL();
  if ( hasPoint ) {
    glColor3ub( 255, 0, 0 );
    glPushMatrix();
    glScalef( zoom, zoom, 1.0 );
    glTranslatef( pointX, pointY, 0 );
    glBegin( GL_LINES );
    glVertex2i( -5, -5 );
    glVertex2i( +5, +5 );
    glVertex2i( -5, +5 );
    glVertex2i( +5, -5 );
    glEnd();
    glPopMatrix();
  };
};