Ejemplo n.º 1
0
void GLView::drawChoice0() {
  /// drawing example

  glColor3f(0,0.5,1);
  ugl::drawText("drawChoice0: "+_choiceText,0,0);

  glPushMatrix();

  glColor3f(1,0,0);

  vector<Point2> points = curve->getPoints();
  vector<Point2> refPoints = curve->getReferencePoints();
  vector<Point2> *curvePoints = curve->getCurvePoints();

  //User-defined polygon
  glLineWidth(1);
  glColor3f(1,0,0);
  glBegin(GL_LINE_STRIP);
  for(int i = 0; i < points.size(); i++){
      Point2 p = points.at(i);
      glVertex2f(p.getX(),p.getY());
  }
  if(closed){
      if(points.size() > 0){
          glVertex2f(points.at(0).getX(),points.at(0).getY());
      }
  }
  glEnd();

  //User-defined points
  glPointSize(5);
  glColor3f(1,0,0);
  glBegin(GL_POINTS);
  for(int i = 0; i < points.size(); i++){
      Point2 p = points.at(i);
      if(!p.isFixed()){
          glVertex2f(p.getX(),p.getY());
      }
  }
  glEnd();

  //Fixed points
  glPointSize(10);
  glColor3f(1,0,0);
  glBegin(GL_POINTS);
  for(int i = 0; i < points.size(); i++){
      Point2 p = points.at(i);
      if(p.isFixed()){
        glVertex2f(p.getX(),p.getY());
      }

  }
  glEnd();



  //Ref points
  glLineWidth(2);
  glColor3f(0,0,1);
  glBegin(GL_LINE_STRIP);
  for(int i = 0; i < refPoints.size(); i++){
      Point2 p = refPoints.at(i);
      glVertex2f(p.getX(), p.getY());
  }
  if(closed){
      if(refPoints.size() > 0){
          glVertex2f(refPoints.at(0).getX(),refPoints.at(0).getY());
      }
  }
  glEnd();



  //Curve
  glLineWidth(2);
  glColor3f(0,1,0);
  glBegin(GL_LINE_STRIP);
  for(int i = 0; i < curvePoints->size(); i++){
      Point2 p = curvePoints->at(i);
      glVertex2f(p.getX(), p.getY());
  }
  if(closed){
      if(curvePoints->size() > 0){
          glVertex2f(curvePoints->at(0).getX(),curvePoints->at(0).getY());
      }
  }
  glEnd();


  //Curve points
  glPointSize(5);
  glColor3f(0,1,0);
  glBegin(GL_POINTS);
  for(int i = 0; i < curvePoints->size(); i++){
      Point2 p = curvePoints->at(i);
      glVertex2f(p.getX(), p.getY());
      ugl::drawText(""+i,p.getX(),p.getY());
  }

  glEnd();

  glPopMatrix();
}