/*!
  \brief Draw an intervall of the curve
  \param painter Painter
  \param xMap maps x-values into pixel coordinates.
  \param yMap maps y-values into pixel coordinates.
  \param from index of the first point to be painted
  \param to index of the last point to be painted. If to < 0 the 
         curve will be painted to its last point.

  \sa QwtCurve::drawCurve, QwtCurve::drawDots,
      QwtCurve::drawLines, QwtCurve::drawSpline,
      QwtCurve::drawSteps, QwtCurve::drawSticks
*/
void QwtCurve::draw(QPainter *painter,
    const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to)
{
    if ( !painter || dataSize() <= 0 )
        return;

    if (to < 0)
        to = dataSize() - 1;

    if ( verifyRange(from, to) > 0 )
    {
        painter->save();
        painter->setPen(d_pen);

        QBrush b = d_brush;
        if ( b.style() != Qt::NoBrush && !b.color().isValid() )
            b.setColor(d_pen.color());

        painter->setBrush(b);

        drawCurve(painter, d_style, xMap, yMap, from, to);
        painter->restore();

        if (d_sym.style() != QwtSymbol::None)
        {
            painter->save();
            drawSymbols(painter, d_sym, xMap, yMap, from, to);
            painter->restore();
        }
    }
}
Beispiel #2
0
/*!
  \brief Draw an interval of the curve
  \param painter Painter
  \param xMap maps x-values into pixel coordinates.
  \param yMap maps y-values into pixel coordinates.
  \param from index of the first point to be painted
  \param to index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.

  \sa drawCurve(), drawSymbols(),
*/
void QwtPlotCurve::draw(QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    int from, int to) const
{
	if (!painter)
		return;

	const int numPoints = (int)dataSize();
	if (to < 0 || to >= numPoints)
		to = numPoints - 1;

	if (verifyRange(numPoints, from, to) > 0){
		painter->save();
		painter->setPen(QwtPainter::scaledPen(d_data->pen));

		/*
		  Qt 4.0.0 is slow when drawing lines, but it's even
		  slower when the painter has a brush. So we don't
		  set the brush before we really need it.
		 */

		drawCurve(painter, d_data->style, xMap, yMap, from, to);
		painter->restore();

		if (d_data->symbol->style() != QwtSymbol::NoSymbol){
			painter->save();
			drawSymbols(painter, *d_data->symbol, xMap, yMap, from, to);
			painter->restore();
		}
	}
}
Beispiel #3
0
void GraphWidget::drawActiveCurves() const
{
	for (int i = m_ivActiveCurves.size() - 1; i >= 0; --i) {
		int iColor = i % CURVE_COLOR_COUNT;
		drawCurve(m_ivActiveCurves[i], iColor);
	}
}
/*!
  Draw an interval of the curve

  \param painter Painter
  \param xMap Maps x-values into pixel coordinates.
  \param yMap Maps y-values into pixel coordinates.
  \param canvasRect Contents rect of the canvas
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.

  \sa drawCurve(), drawSymbols(),
*/
void QwtPlotCurve::drawSeries( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    if ( !painter || dataSize() <= 0 )
        return;

    if ( to < 0 )
        to = (int)dataSize() - 1;

    if ( verifyRange( (int)dataSize(), from, to ) > 0 )
    {
        painter->save();
        painter->setPen( d_data->pen );

        /*
          Qt 4.0.0 is slow when drawing lines, but it's even
          slower when the painter has a brush. So we don't
          set the brush before we really need it.
         */

        drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to );
        painter->restore();

        if ( d_data->symbol &&
            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
        {
            painter->save();
            drawSymbols( painter, *d_data->symbol,
                xMap, yMap, canvasRect, from, to );
            painter->restore();
        }
    }
}
Beispiel #5
0
void DemoKeeper::requestUpdateCanvas3( MyGUI::CanvasPtr canvas, MyGUI::Canvas::Event _canvasEvent )
{
    if( ! _canvasEvent.textureChanged && ! _canvasEvent.requested ) return;
    //if (mNodeWindow1 == nullptr || mNodeWindow2 == nullptr) return;

    unsigned char * data = (unsigned char*)canvas->lock();

    int width = canvas->getTextureRealWidth();
    int height = canvas->getTextureRealHeight();

    //const MyGUI::IntPoint& node1 = mNodeWindow1->getPosition();
    //const MyGUI::IntPoint& node2 = mNodeWindow2->getPosition();

    clearCanvas((unsigned char*)data, width, height);

    /*SplineInfo info1(node1.left + 96, node1.top + 46, node2.left + 2, node2.top + 46, 96, 104, 88, 88, 88, false, true, 2);
    drawCurve((unsigned char*)data, width, height, info1);

    SplineInfo info2(node1.left + 96, node1.top + 45, node2.left + 2, node2.top + 45, 100, 100, 255, 0, 0, false, true, 2);
    drawCurve((unsigned char*)data, width, height, info2);*/

    LinkInfo link(MyGUI::IntPoint(10, 10), MyGUI::IntPoint(100, 100), MyGUI::Colour(1, 1, 1), 0, 0);
    drawCurve((unsigned char*)data, width, height, link);

    // yниточк адля драга
    //if (mIsDrug)
    //	drawCurve((unsigned char*)data, width, height, mDrugLine);


    canvas->unlock();
}
Beispiel #6
0
/*!
  \brief Draw an interval of the curve
  \param painter Painter
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param from index of the first point to be painted
  \param to index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.

  \sa drawCurve(), drawSymbols(),
*/
void QwtPolarCurve::draw( QPainter *painter,
    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
    const QPointF &pole, int from, int to ) const
{
    if ( !painter || dataSize() <= 0 )
        return;

    if ( to < 0 )
        to = dataSize() - 1;

    if ( qwtVerifyRange( dataSize(), from, to ) > 0 )
    {
        painter->save();
        painter->setPen( d_data->pen );

        drawCurve( painter, d_data->style,
            azimuthMap, radialMap, pole, from, to );

        painter->restore();

        if ( d_data->symbol->style() != QwtSymbol::NoSymbol )
        {
            painter->save();
            drawSymbols( painter, *d_data->symbol,
                azimuthMap, radialMap, pole, from, to );
            painter->restore();
        }
    }
}
Beispiel #7
0
void Curve::draw()
{
	if(0 == vDegree) {
		drawCurve();
	} else {
		drawSurface();
	}
}
Beispiel #8
0
void display(void){
    int i;
    float t;
    Xyz p;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_COLOR_MATERIAL);
    glLoadIdentity();

    glRotated(g_x_angle, 1.0f, 0.0f, 0.0f);
    glRotated(g_y_angle, 0.0f, 1.0f, 0.0f);
    glScalef(g_scale, g_scale, g_scale);
    glTranslatef(g_x_pan, -g_y_pan, 0);


    glColor3f(0, 0, 0);


    if(g_display_points == 1){
        glPointSize(4);
        glBegin(GL_POINTS);
        for(i = 0; i < g_npoint; ++i){
            glVertex3fv(&movePath[i].p.x);
        }
        glEnd();
    }

    t = current_time();


    if(g_movePathType == 0){
        if(g_displaymovePath == 1){
            glBegin(GL_LINE_STRIP);
            for(i = 0; i < g_npoint; ++i){
                glVertex3fv(&movePath[i].p.x);
            }
            glEnd();
        }
        linearPoint(t, &p.x, &p.y, &p.z);
    }
    if(g_movePathType == 1){
        if( g_displaymovePath == 1)
            drawCurve(1000);
        splinePoint(t, &p.x, &p.y, &p.z);
    }
    glTranslatef(p.x, p.y, p.z);

    glScaled(.3, .3, .3);
    glColor3f(1, 0, 1);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    drawMesh();

//    g_npoint = 0;
    glutSwapBuffers();

}
Beispiel #9
0
void plotter::refreshPixmap()
{
    pixmap = QPixmap(size());
    pixmap.fill(this, 0, 0);

    QPainter painter(&pixmap);
    painter.initFrom(this);
    drawGrid(&painter);
    drawCurve(&painter);
    update();
}
//================================================================
// Function : OCCDemo_Presentation::sampleRevolSurface
// Purpose  : 
//================================================================
void Convert_Presentation::sampleRevolSurface()
{
  FitMode=false;
  ResetView();
  SetViewCenter(176.84682,102.12892);
  SetViewScale(0.69326);

  getAISContext()->EraseAll();

  Standard_CString aName = "Surface of revolution";
  TCollection_AsciiString aText (
    "  // creating a curve for revolution.  Let it be a Bezier curve." EOL
    "  Handle(Geom_BezierCurve) aBezierCurve;" EOL EOL

    "  // array of the bezier curve poles" EOL
    "  TColgp_Array1OfPnt aPoles(1,4);" EOL
    "  // array of the poles' weights" EOL
    "  TColStd_Array1OfReal aWeights(1,4);" EOL EOL

    "  aPoles(1) = gp_Pnt(0, 0, 0);      aWeights(1) = 1;" EOL
    "  aPoles(2) = gp_Pnt(150, 250, 0);  aWeights(2) =75;" EOL
    "  aPoles(3) = gp_Pnt(350, 150, 0);  aWeights(3) =120;" EOL
    "  aPoles(4) = gp_Pnt(500, 500, 0);  aWeights(4) = 1;" EOL EOL

    "  // creating a bezier curve" EOL
    "  aBezierCurve = new Geom_BezierCurve(aPoles, aWeights);" EOL EOL

    "  // creating a surface of revolution of the bezier curve around Y axis" EOL
    "  gp_Ax1 anAx(gp_Pnt(0, 0, 0), gp_Dir(0,1,0));" EOL
    "  Handle(Geom_SurfaceOfRevolution) aSurface = new Geom_SurfaceOfRevolution(aBezierCurve, anAx);" EOL
    );
  
  // array of the bezier curve poles
  TColgp_Array1OfPnt aPoles(1,4);
  // array of the poles' weights
  TColStd_Array1OfReal aWeights(1,4);

  aPoles(1) = gp_Pnt(0, 0, 0);      aWeights(1) = 1;
  aPoles(2) = gp_Pnt(150, 250, 0);  aWeights(2) =75;
  aPoles(3) = gp_Pnt(350, 150, 0);  aWeights(3) =120;
  aPoles(4) = gp_Pnt(500, 500, 0);  aWeights(4) = 1;

  Handle(Geom_BezierCurve) aBezierCurve = new Geom_BezierCurve(aPoles, aWeights);
  drawCurve(aBezierCurve);

  // creating a surface of revolution of the bezier curve around Y axis
  gp_Ax1 anAx(gp_Pnt(0,0,0), gp_Dir(0,1,0));
  Handle(Geom_SurfaceOfRevolution) aSurface = new Geom_SurfaceOfRevolution(aBezierCurve, anAx);

  drawSurfaceAndItsBSpline (aSurface, aName, aText);
  FitMode=true;
}
Beispiel #11
0
void ofApp::draw() {
	ofBackground(0);
	
	ofPushMatrix();
	ofTranslate(10, 10);
	drawAudioInput(0, 0, 128);
	drawVinyl(128, 0, 128);
	
	ofTranslate(256, 0);
	ofSetColor(yellowPrint);
	drawCurve(absolutePosition, 128);
	ofSetColor(magentaPrint);
	drawCurve(relativePosition, 128);
	ofSetColor(255);
	drawCurve(faderPosition, 128, 0, 255);
	ofPopMatrix();
	
	ofSetColor(255);
	
	ofPushMatrix();
	ofTranslate(10, ofGetHeight() - 120);
	ofDrawBitmapString("pitch: " + ofToString(xwax.getPitch(), 2) + "x", 0, 20);
	ofDrawBitmapString("velocity: " + ofToString(xwax.getVelocity(), 2) + " ms", 0, 40);
	ofDrawBitmapString("relative: " + ofToString(xwax.getRelative(), 0) + " ms", 0, 60);
	ofDrawBitmapString("absolute: " + ofToString(xwax.getAbsolute(), 0) + " ms", 0, 80);
	ofDrawBitmapString("absolute valid: " + ofToString(xwax.isAbsoluteValid() ? "yes" : "no"), 0, 100);
	ofPopMatrix();
	
	ofPushMatrix();
	ofTranslate(256, ofGetHeight() - 120);
	ofDrawBitmapString("format: " + xwax.getFormat() + " (" + recordSide +")", 0, 20);
	ofDrawBitmapString("osc: " + oscHost + ":" + ofToString(oscPort), 0, 40);
	ofDrawBitmapString("subdivide: " + ofToString(oscSubdivide) + " (" + ofToString(oscRate, 1) + "Hz)", 0, 60);
	ofDrawBitmapString("audio: " + ofToString(audioSamplerate) + "Hz, " + ofToString(audioBuffersize) + " samples", 0, 80);
	ofDrawBitmapString("serial: " + ofToString(serialPort), 0, 100);
	
	ofPopMatrix();
}
//================================================================
// Function : Convert_Presentation::drawCurveAndItsBSpline
// Purpose  : 
//================================================================
void Convert_Presentation::drawCurveAndItsBSpline(Handle_Geom_Curve theCurve, 
                                                  const Standard_CString theName, 
                                                  TCollection_AsciiString& theText)
{
  TCollection_AsciiString aTitle ("Converting ");
  aTitle += theName;
  aTitle += " to BSpline curve";

  theText += EOL
    "  Handle_Geom_BSplineCurve aBSpline = " EOL
    "    GeomConvert::CurveToBSplineCurve(aCurve);" EOL;

  setResultTitle (aTitle.ToCString());
  setResultText (theText.ToCString());
  
  drawCurve (theCurve, CurveColor);
  
  if (WAIT_A_LITTLE) return;

  Handle_Geom_BSplineCurve aBSpline = GeomConvert::CurveToBSplineCurve(theCurve);

  drawCurve (aBSpline, BSplineColor);
}
Beispiel #13
0
	void GraphPlotter::updateCurve(const std::string& name, Curve& C) {
		if (!valid)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] no valid graph set!" << std::endl;
			return;
		}
		boost::mutex::scoped_lock data_mutex_lock(data_mutex);

		for (unsigned int i = 0; i < g.Curves.size(); ++i)
		{
			if (g.Curves[i].name == name)
			{
				g.Curves[i] = C;

				dynScaleAxes(g.getMaximas());
				// update the corresponding vertexarray
				drawCurve(g.Curves[i], RenderArrays[i]);
			}
		}
	}
void Viewport::drawObj(Object* obj){
    if(obj->getNCoordsSize() == 0) return;

    switch(obj->getType()){
    case ObjType::OBJECT:
        break;
    case ObjType::POINT:
        drawPoint(obj);
        break;
    case ObjType::LINE:
        drawLine(obj);
        break;
    case ObjType::POLYGON:
        drawPolygon(obj);
        break;
    case ObjType::BEZIER_CURVE:
    case ObjType::BSPLINE_CURVE:
        drawCurve(obj);
        break;
    }
}
Beispiel #15
0
void PlotWindow::plot(std::list<LoggingVariable*> *lvlist) {
		
	hDC = GetDC(hWnd);

	hRC = wglCreateContext(hDC);
	
	wglMakeCurrent(hDC, hRC);

	glEnable(GL_LINE_SMOOTH);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glClearColor(bgColor[0], bgColor[1], bgColor[2], 1.0f);

	glClear(GL_COLOR_BUFFER_BIT);
	int k = 0;

	for (std::list<LoggingVariable*>::const_iterator lv = lvlist->begin(), end = lvlist->end(); lv != end; ++lv) {
		
		if ((*lv)->isPlotting) {
			
			drawCurve((*lv));
			
		}
		
	}
	
	
	SwapBuffers(hDC);
	
	wglMakeCurrent(NULL, NULL);

	wglDeleteContext(hRC);
	ReleaseDC(hWnd, hDC);
	
}
//================================================================
// Function : DrawCurve                                 
// Purpose  : displays a given curve 2d
//================================================================
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawCurve
                                  (const Handle_Geom2d_Curve& theCurve,
                                   const Quantity_Color& theColor,
                                   const Standard_Boolean toDisplay,
                                   const gp_Ax2& aPosition)
{
  // create 3D curve in plane
  Handle(Geom_Curve) aCurve3d;
  if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
  {
    Handle(Geom2d_OffsetCurve) aOffCurve =
      Handle(Geom2d_OffsetCurve)::DownCast(theCurve);
    Handle(Geom_Curve) aBasCurve3d =
      GeomAPI::To3d (aOffCurve->BasisCurve(), gp_Pln(aPosition));
    Standard_Real aDist = aOffCurve->Offset();
    aCurve3d = new Geom_OffsetCurve (aBasCurve3d, aDist, aPosition.Direction());
  }
  else
  {
    aCurve3d = GeomAPI::To3d (theCurve, gp_Pln(aPosition));
  }
  return drawCurve (aCurve3d, theColor, toDisplay);
}
Beispiel #17
0
/* Initialize anything necessary to set up the scene for the roller coaster simulation. */
void init(void){
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    
    // Read in the control points from a file, first lets test without that feature.
    leftRail = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    rightRail = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    centerRail = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    columnTopRight = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    columnTopLeft = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    qValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    dqValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    ddqValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    uValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    vValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    nValues = (double **)malloc(COASTER_POINTS*NUMBER_SEGMENTS * sizeof(double *));
    calculateVectors();
    
    // Generate a display list that will hold the scene.
    scene = glGenLists(1);
    glNewList(scene, GL_COMPILE);
        // Draw the ground and colour it green.
        drawGround();
    
        // Draw the sky and colour it blue.
        drawSkybox();
        // Draw the coaster.
        drawCurve();
    
        // Draw the connection pieces for the rails.
        drawConnectors();
    
        // Draw the columnst that support the rails.
        drawColumns();
    glEndList();
}
Beispiel #18
0
void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
  ctx->fillRect(rect, KDColorWhite);
  drawGrid(ctx, rect);
  drawAxes(ctx, rect, Axis::Horizontal);
  drawAxes(ctx, rect, Axis::Vertical);
  drawLabels(ctx, rect, Axis::Horizontal, true);
  drawLabels(ctx, rect, Axis::Vertical, true);
  for (int series = 0; series < Store::k_numberOfSeries; series++) {
    if (!m_store->seriesIsEmpty(series)) {
      KDColor color = Palette::DataColor[series];
      float regressionParameters[2] = {(float)m_store->slope(series), (float)m_store->yIntercept(series)};
      drawCurve(ctx, rect, [](float abscissa, void * model, void * context) {
          float * params = (float *)model;
          return params[0]*abscissa+params[1];
          },
          regressionParameters, nullptr, color);
      for (int index = 0; index < m_store->numberOfPairsOfSeries(series); index++) {
        drawDot(ctx, rect, m_store->get(series, 0, index), m_store->get(series, 1, index), color);
      }
      drawDot(ctx, rect, m_store->meanOfColumn(series, 0), m_store->meanOfColumn(series, 1), color, true);
      drawDot(ctx, rect, m_store->meanOfColumn(series, 0), m_store->meanOfColumn(series, 1), KDColorWhite);
    }
  }
}
//============================================================
static void idle( void )
{
   drawCurve();
}
Beispiel #20
0
void onDisplay( )
{
	glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (currentCur != NULL)
    {
        glLineWidth(8);
        glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
        glPointSize(9);
        glColor3d(1,1,1);
        currentCur->drawControlPoints();
        onIdle();
        currentCur->draw(.2,.6,1);
        
    }
    
    glColor3d(1,1,1);
    glLineWidth(3);
    glPointSize(6);
    // defalt setting
   
    
    if (!LC.empty())
    {
        for (int i = 0; i < LC.size(); i++)
            drawCurve(LC.at(i));
    }
    
    if(!BC.empty())
    {
        for(int i = 0; i < BC.size(); i++)
            drawCurve(BC.at(i));
    }
    if(!PL.empty())
    {
        for(int i = 0; i < PL.size(); i++)
            drawCurve(PL.at(i));
    }
    if(!CC.empty())
    {
        for(int i = 0; i < CC.size(); i++)
            drawCurve(CC.at(i));
    }
    if(!CR.empty())
    {
        for(int i = 0; i < CR.size(); i++)
            drawCurve(CR.at(i));
    }
    
    int NoC = (int) Curves.size();
    std::vector<int> stack;
    
    while (NoC > 0)
    {
        stack.push_back(NoC % 10);
        NoC = NoC/10;
    }
    int shift = 0;
    if(stack.empty())
        BezierZero(shift);
    
    // For the Bezier curve counter
    while(!stack.empty())
    {
        int n = stack.back();
        stack.pop_back();
        switch (n) {
            case 0:
                BezierZero(shift);
                break;
            case 1:
                BezierOne(shift);
                break;
            case 2:
                BezierTwo(shift);
                break;
            case 3:
                BezierThree(shift);
                break;
            case 4:
                BezierFour(shift);
                break;
            case 5:
                BezierFive(shift);
                break;
            case 6:
                BezierSix(shift);
                break;
            case 7:
                BezierSeven(shift);
                break;
            case 8:
                BezierEight(shift);
                break;
            case 9:
                BezierNine(shift);
                break;
            default:
                break;
                
        }
        shift +=1;
        
    }
    
	glutSwapBuffers();
    
}
Beispiel #21
0
//////////////////////////////////////////////////////////////////////////////////////////
// Fonction que vous allez modifier afin de dessiner
/////////////////////////////////////////////////////////////////////////////////////////
void render_scene()
{
//Définition de la couleur
 glColor3f(1.0, 1.0, 1.0);

  //  Nous créons ici un polygone. Nous pourrions aussi créer un triangle ou des lignes. Voir ci-dessous les parties 
  // en commentaires (il faut commenter le bloc qui ne vous intéresse pas et décommenter celui que vous voulez tester.

   // Création de deux lignes
/*	glBegin(GL_LINES);
		glVertex3f(-1, -1, 0);
		glVertex3f(1, 1, 0);
		glVertex3f(1, -1, 0);
		glVertex3f(-1, 1, 0); 
	glEnd();*/
  
 // création d'un polygone

	/*glBegin(GL_POLYGON);
		glVertex3f(-1, -1, 0);
		glVertex3f(1, -1, 0);
		glVertex3f(1, 1, 0);
		glVertex3f(-1, 1, 0);
	glEnd();*/

	//glutSolidCube(2);

/*
// création d'un triangle
	glBegin(GL_TRIANGLES);
		glVertex3f(-1, -1, 0);
		glVertex3f(1, -1, 0);
		glVertex3f(1, 1, 0);
	glEnd();
*/
/*	Point A(-3.0, -3.0, 0.0);
	Point B(3.0, 3.0, 0.0);
	Point C(-3.0, 3.0, 0.0);
	Point Cp = C.ProjectOnLine(A, B);

	glPointSize (5.0);

	glBegin(GL_POINTS);
		myGlVertex(A);
		myGlVertex(B);
	glEnd();

	glBegin(GL_LINES);
		myGlVertex(A);
		myGlVertex(B);
	glEnd();

	glBegin(GL_POINTS);
		myGlVertex(C);
	glEnd();

	glBegin(GL_POINTS);
		myGlVertex(Cp);
	glEnd();
*/
	Point A(-0.0, -0.0, 0.0);
	Point B(2.0, 0.0, 0.0);
	Vector v1(1.0, 1.0, 0.0);
	Vector v2(1.0, -1.0, 0.0);

	glPointSize (4.0);

	glBegin(GL_POINTS);
		myGlVertex(A);
		myGlVertex(B);
	glEnd();

	displayLine(A, v1);
	displayLine(B, v2);

	Hermite myCurve(A, v1, B, v2);
	Point curve[10];
	myCurve.HermiteCubicCurve(curve ,10);
	drawCurve(curve, 10);
}
void ShiftTraceTool::draw() {
  updateData();
  drawControlRect();
  drawCurve();
}
Beispiel #23
0
void run() {
	drawCurve(getParamInt(0),getParamDouble(1));
}
Beispiel #24
0
	void GraphPlotter::updateVertexArrays() {
		if (!valid)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] no valid graph set!" << std::endl;
			return;
		}

		if (g.AxisSize.x <= 0 || g.AxisSize.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxisSize < 0 ) !" << std::endl;
			return;
		}

		if (g.AxesPoints.x <= 0 || g.AxesPoints.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxesPoints < 0 ) !" << std::endl;
			return;
		}

		if (g.MinPointDist <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( MinPointDist < 0 ) !" << std::endl;
			return;
		}

		if (g.Size.x <= 0 || g.Size.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( Size < 0 ) !" << std::endl;
			return;
		}

		RenderArrays.clear();
		AxisLabels.clear();
		Legend.clear();
		Axes.clear();
		Axes.setPrimitiveType(sf::Lines);
		RenderArrays.insert(RenderArrays.end(), 2 + g.Curves.size(), sf::VertexArray());
		for (sf::VertexArray& vA : RenderArrays)
		{
			vA.clear();
			vA.setPrimitiveType(sf::Lines);
		}

		boost::mutex::scoped_lock data_mutex_lock(data_mutex);

		glm::ipoint2 maximas = g.getMaximas();

		dynScaleAxes(maximas);
		if (g.AxisStart.x > maximas.x) g.AxisStart.x = maximas.x;
		//if ( g.AxisStart.x < 0) g.AxisStart.x = maximas.x + g.AxisStart.x;

		if (g.AxisStart.y > maximas.y) g.AxisStart.y = maximas.y;
		//if ( g.AxisStart.y < 0) g.AxisStart.y = maximas.y + g.AxisStart.y;


		if (g.AxisSize.x <= 0 || g.AxisSize.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxisSize < 0 ) !" << std::endl;
			//printSettings();
			return;
		}

		if (g.drawLegend) drawLegend();
		if (g.drawAxisLabels) drawAxisLabels();
		if (g.drawAxes) drawAxes();

		for (unsigned int i = 0; i < g.Curves.size(); ++i)
		{
			drawCurve(g.Curves[i], RenderArrays[i]);
		}
	}
void drawCurves(SDL_Renderer* renderer, std::vector<trackObj> track)
{
    for (int i=0; i<track.size(); i++) {
        drawCurve(renderer, track[i]);
    }
}
Beispiel #26
0
void display()
{
	//clear window
  	 glClear( GL_COLOR_BUFFER_BIT );
	
	drawCurve(num_controls);

	//draw control points
	if (control_view){
		glPointSize(5.0);
		glDrawArrays(GL_POINTS, 0, num_controls);
	}
	//draw curve
	glPointSize(1.0);
	glDrawArrays(GL_POINTS, num_controls, num_segments*num_curve_vertices);

	//draw 1-smooth guide
	if (guide)
	{
		
		glLineStipple(1, 0x3F07);
		glEnable(GL_LINE_STIPPLE);

		//create points for guide line
		points[num_segments*num_curve_vertices + num_controls]   = -control_points[((num_segments-1)*3)+2];
		points[num_segments*num_curve_vertices + num_controls+1] = control_points[((num_segments-1)*3)+3];
		glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(points), points );

		//turn the points green
		colors[num_segments*num_curve_vertices + num_controls] = colors[num_segments*num_curve_vertices + num_controls+1] 
			= color4(0.3, 1.0, 0.0, 1.0);
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
		
		//draw the line
		glDrawArrays(GL_LINES, num_segments*num_curve_vertices + num_controls, 2);
		
		
		colors[((num_segments-1)*3)+2] = colors[((num_segments-1)*3)+3] = color4(1.0, 0.0, 0.0, 1.0);
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
		glDisable(GL_LINE_STIPPLE);

		
	}
	
	//draw control polygon
	if (control_polygon)
	{
		for (int i = 0; i < num_controls; ++i)
		{		
			colors[i] = color4(0.8, 0.7, 0.0, 1.0);
		}
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
		glDrawArrays(GL_LINE_STRIP, 0, num_controls);
		for (int i = 0; i < num_controls; ++i)
		{		
			colors[i] = color4(1.0, 0.0, 0.0, 1.0);
		}
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
	}

	//draw convex hull (doesn't work. didn't have time to figure it out)
	if (convex_hull)
	{
		for (int i = 0; i < num_controls + 1; ++i)
		{		
			colors[i] = color4(1.0, 1.0, 1.0, 1.0);
		}
		int mod; 
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
		for (int g = 0; g < num_segments; ++g)
		{
			mod = g*3;
			
			glDrawArrays(GL_LINE_LOOP, 0+mod, 2);
			glDrawArrays(GL_LINE_LOOP, 1+mod, 2);
			glDrawArrays(GL_LINE_LOOP, 2+mod, 2);
			glDrawArrays(GL_LINE_LOOP, 3+mod, 2);	
		}
		
		
		for (int i = 0; i < num_controls + 1; ++i)
		{		
			colors[i] = color4(1.0, 0.0, 0.0, 1.0);
		}
		glBufferSubData( GL_ARRAY_BUFFER, sizeof(points), sizeof(colors), colors );
	}

	glutSwapBuffers();
}