Trouver un fichier de code source :
   

Version Française - English Version
Accueil > 

C++

 > 

AFFICHER DES COURBES DE BEZIER

 > 

View2D.cpp


AFFICHER DES COURBES DE BEZIER

View2D.cpp


Informations sur ce code source

Cliquez pour voir la capture en taille normale
Code Source AFFICHER DES COURBES DE BEZIER
Auteur shorzy
Fichier View2D.cpp en C / C++ / C++.NET
Publié le 23/08/2011

Bonjour à Tous suite à un Problème que je rencontre actuellement : http://www.cppfrance.com/forum/sujet-CREER-GRAND-CARREAU-NURBS_1542679.aspx J'ai décider d’écrire le Bout de Programme qui va bien pour m'aidé à voir ou je vais avec les Courb
 

Fichier : View2D.cpp

Nombre de lignes : 230 lignes


Afficher ce fichier en plein écran
  • #include<QDebug>
  • #include "Window.h"
  • #include "View2D.h"
  • #define PRECISION_BEZIER 100
  • View2D::View2D(QWidget *parent) :
  • QGLWidget(parent), m_Win((Window*)parent)
  • {
  • qDebug() << "Appel au Constructeur" << endl;
  • setMinimumSize(300,300);
  • makeCurrent();
  • m_XMax = 35.0;
  • m_XMin = -10.0;
  • m_YMax = 10.0;
  • m_YMin = -10.0;
  • m_Step_x = m_Step_y = 5;
  • }
  • void View2D::resizeGL (int width, int height)
  • {
  • qDebug() << "Appel au ResizeGL()" << endl;
  • glViewport (0, 0, width, height);
  • glMatrixMode (GL_PROJECTION);
  • glLoadIdentity ();
  • glOrtho(m_XMin-1, m_XMax+1, m_YMin-1, m_YMax+1, 10, 15);
  • glMatrixMode (GL_MODELVIEW);
  • glLoadIdentity ();
  • }
  • void View2D::initializeGL(void)
  • {
  • qDebug() << "Appel au initializeGL()" << endl;
  • glClearColor(0.8,0.8,0.85,0);
  • glEnable(GL_DEPTH_TEST);
  • }
  • void View2D::Init(void)
  • {
  • qDebug() << "Appel au Init()" << endl;
  • glClearColor(0.4,0.4,0.4,0);
  • }
  • void View2D::paintGL(void)
  • {
  • qDebug() << "Appel au paintGL()" << endl;
  • glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  • glPushMatrix();
  • glTranslatef(0, 0, -11);
  • DessinAxe();
  • DessinPoints();
  • Dessin();
  • glPopMatrix();
  • }
  • void View2D::Dessin(void)
  • {
  • }
  • void View2D::DessinPoints(void)
  • {
  • glEnable(GL_POINT_SIZE);
  • glEnable(GL_POINT_SMOOTH);
  • glPointSize(9);
  • for(int Courbe=0; Courbe<m_Win->m_ListeCourbe.size(); ++Courbe)
  • {
  • Window::GestionCourbe* Crb = &(m_Win->m_ListeCourbe[Courbe]);
  • for(int Pt=0; Pt<Crb->size(); ++Pt)
  • {
  • switch(Courbe)
  • {
  • case 1:
  • glColor4f(1.0, 0.0, 0.0, 1.0);
  • break;
  • case 2:
  • glColor4f(0.0, 1.0, 0.0, 1.0);
  • break;
  • case 3:
  • glColor4f(0.0, 0.0, 1.0, 1.0);
  • break;
  • case 4:
  • glColor4f(1.0, 1.0, 0.0, 1.0);
  • break;
  • case 5:
  • glColor4f(1.0, 0.0, 1.0, 1.0);
  • break;
  • case 6:
  • glColor4f(0.0, 1.0, 1.0, 1.0);
  • break;
  • default:
  • glColor4f(0.0, 0.0, 0.0, 1.0);
  • break;
  • };
  • glPushMatrix();
  • glBegin(GL_POINTS);
  • glVertex3f(Crb->at(Pt).m_x, Crb->at(Pt).m_y, 0);
  • glEnd();
  • glPopMatrix();
  • glLineWidth(3);
  • InitCourbe(Courbe);
  • glMapGrid1f(PRECISION_BEZIER, 0.0, 1.0);
  • glEvalMesh1(GL_LINE, 0, PRECISION_BEZIER);
  • }
  • }
  • for(int Courbe=0; Courbe<m_Win->m_ListeCourbe.size(); ++Courbe)
  • {
  • }
  • }
  • void View2D::DessinAxe(void)
  • {
  • glEnable(GL_LINE_WIDTH);
  • glLineWidth(5);
  • // Dessinde l'Axe Principal ...
  • glPushMatrix();
  • glBegin(GL_LINES);
  • glColor4f(0.0, 0.0, 0.0, 1.0);
  • glVertex3f(m_XMin, 0, 0);
  • glVertex3f(m_XMax, 0, 0);
  • glEnd();
  • glBegin(GL_LINES);
  • glVertex3f(0, m_YMin, 0);
  • glVertex3f(0, m_YMax, 0);
  • glEnd();
  • glPopMatrix();
  • glLineWidth(1);
  • // Dessinde l'Axe Secondaire ...
  • for(int loop=m_XMin; loop<=(m_XMax-m_XMin);++loop)
  • {
  • if(loop % m_Step_x)
  • {
  • glColor4f(0.9, 0.9, 0.9, 1.0);
  • }
  • else
  • {
  • glColor4f(0.0, 0.0, 0.0, 1.0);
  • }
  • glBegin(GL_LINES);
  • glVertex3f(m_XMin + loop, m_YMin, 0);
  • glVertex3f(m_XMin + loop, m_YMax, 0);
  • glEnd();
  • }
  • for(int loop=m_YMin; loop<=(m_YMax-m_YMin);++loop)
  • {
  • if(loop % m_Step_y)
  • {
  • glColor4f(0.9, 0.9, 0.9, 1.0);
  • }
  • else
  • {
  • glColor4f(0.0, 0.0, 0.0, 1.0);
  • }
  • glBegin(GL_LINES);
  • glVertex3f(m_XMin, m_YMin + loop, 0);
  • glVertex3f(m_XMax, m_YMin + loop, 0);
  • glEnd();
  • }
  • glDisable(GL_LINE_WIDTH);
  • }
  • void View2D::InitCourbe(int No)
  • {
  • GLfloat ctrlpoints[8][3];
  • Window::GestionCourbe* Crb = &(m_Win->m_ListeCourbe[No]);
  • for(int nPt=0; nPt< Crb->size(); ++nPt)
  • {
  • ctrlpoints[nPt][0] = Crb->at(nPt).m_x;
  • ctrlpoints[nPt][1] = Crb->at(nPt).m_y;
  • ctrlpoints[nPt][2] = 0;
  • }
  • glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, Crb->size(), &ctrlpoints[0][0]);
  • glEnable(GL_MAP1_VERTEX_3);
  • }


Liste des fichiers du ZIP

FichierTaille
App.ico3,69 Ko
Bezier2D.pro165 o
main.cpp300 o
MyTableur.cpp1,2 Ko
MyTableur.h384 o
view.cpp103 o
view.h229 o
View2D.cpp4,56 Ko
View2D.h636 o
Window.cpp4,18 Ko
Window.h1,17 Ko

Pour télécharger le zip au complet, veuillez vous rendre sur cette page :
Télécharger AFFICHER DES COURBES DE BEZIER


Sources du même auteur ayant un ZIP


  • C / C++ / C++.NET Qxtapplication - raccourci blague
    Ce code QT utilise les Extensions Qt d'où Qxt ! Il vous montre comment utiliser : QxApplication QxGlobalShorcut mais aussi : QSystemTra...
    Langage : C / C++ / C++.NET, publié le 30/11/2010 par shorzy

  • C / C++ / C++.NET Double buffering (mfc)
    Application qui Gère le Double-Buffering... L'Effet (très Génant) de Scintillement lors des Opérations de Dessin peut être Résolu simple...
    Langage : C / C++ / C++.NET, publié le 28/12/2008 par shorzy

  • C / C++ / C++.NET Faire glisser la souris
    Bonjour. Cette Source pourrait faire partie d'une Blague : Une fois le Programme Lancé, votre Souris Glissera au Moindre de vos Déplace...
    Langage : C / C++ / C++.NET, publié le 06/03/2008 par shorzy

Voir la suite...


Sources du même langage comportant un zip


Voir la suite...





Logiciels à télécharger...

  • Easy-Planning (4.5.0.11)
    Easy-Planning (4.5.0.11)
    Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté aux petites et moyennes entreprises(PME). Easy-Planning permet la création de plannings prévisionnels, p...
  • CVEasy (3.1.0.51)
    CVEasy (3.1.0.51)
    PHMSD-CVEasy est un logiciel d'aide à la rédaction de CV d'une simplicité déconcertante. PHMSD-CVEasy vous assistera pour la rédaction de votre CV, le CV de vos amis ou de membres de votre famille, m...
  • LettresFaciles 2011 (8.6.0.31)
    LettresFaciles 2011 (8.6.0.31)
    LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types. Son interface simple d'utilisation mais suffisamment complète vous permettra de créer une multitude de lettres....

Sondage...

Le top des photos

Photo ??Photo ???????????????
Photo ????????Photo ????????
 

Développement réalisé par Nicolas SOREL (Nix) et Emmanuel (EBArtSoft) avec l'aide de Cyril DURAND, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,27 sec