void ViewportPainter::drawPoint(Point2D & point) {
    if(point.getTime() != "-1") {
      QString text("t = " + point.getTime());
      QRect rect(point.x()+TEXT_OFFSET_X, point.y()-TEXT_OFFSET_Y,10*text.length()+2*TEXT_MARGIN,15+2*TEXT_MARGIN);
      this->setBrush(QColor(255, 255, 255, 255));
      this->drawRect(rect);
      this->drawText(rect,Qt::AlignHCenter|Qt::AlignVCenter,text);
    }
    if(point.selected())
      this->setBrush(QColor(255, 0, 0, 255));
    else
      this->setBrush(QColor(255, 248, 133, 255));
    this->drawEllipse(point.x()-POINT_SIZE/2,point.y()-POINT_SIZE/2,POINT_SIZE,POINT_SIZE);
}
void Viewport::enterTime(Point2D * point) {
  double time, min_time = 0, max_time = 2147483647;
  list<Point2D>::iterator itp = points.begin();
  if(point != &(points.front())) {
    Point2D * previous = NULL;
    for(itp = points.begin(); itp != points.end() && &(*itp) != point; itp++)
      previous = &(*itp);
    min_time = previous->getTime().toDouble()+0.1;
  }
  if(point != &(points.back())) {
    itp++;
    max_time = (*itp).getTime().toDouble();
    if(max_time >= 0.1)
      max_time -= 0.1;
  }
  time = QInputDialog::getDouble(this, "Time", "Please enter the time you want to apply this position (in seconds)", min_time, min_time, max_time);
  ostringstream out;
  out << time;
  string text = out.str();
  point->setTime(QString(text.data()));
}