Accueil > > > Window.cpp
AFFICHER DES COURBES DE BEZIER
Window.cpp
Informations sur ce code source
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 : Window.cpp
Nombre de lignes : 189 lignes
Afficher ce fichier en plein écran
- #include <QtOpenGL>
- #include <QWidget>
- #include <QSplitter>
- #include <QtGui>
- #include<QDebug>
- #include<QTimer>
-
-
- #include <QButtonGroup>
- #include <QLabel>
-
- #include "MyTableur.h"
- #include "View.h"
- #include "Window.h"
-
- Window::Window()
- {
- View = new View2D(this);
- BpQuit = new QPushButton("Quitter");
- BpQuit->setFixedWidth(75);
-
-
-
-
-
-
-
- m_Tableur = new MyTableur(this);
-
-
-
- QGroupBox *Grp = new QGroupBox("Mode d'Emploi", this);
- QVBoxLayout *Layout = new QVBoxLayout(Grp);
- QLabel *Lbl = new QLabel(Grp);
- Lbl->setAlignment(Qt::AlignLeft|Qt::AlignTop);
- Lbl->setText("<strong>Création de Courbes de Bezier</strong><br><br><br>"
- "o Vous Pouvez créer autant de courbes que vous Voulez<br>"
- "<i>(Double Clique sur une Cellule de la Derniere Ligne<br>"
- "pour Créer un Nouvelle Ligne)</i><br>"
- "<span style=\" font-size:10pt; color:#ff0000;\">o Attention : "
- "<span style=\" font-size:8pt\">Inserer/Supprimer les Element dans l'Ordre<br>"
- "<span style=\"color:#000000;\"><i>(Création de 1->8 Supression de 8->1)</i><br><br>"
- "o Noter les Points sous la Forme x;y"
- " \"5.3;4\"<br>"
- );
- Layout->addWidget(Lbl);
-
- QFrame *Frame = new QFrame(this);
- QHBoxLayout *LayoutFrame = new QHBoxLayout(Frame);
- Frame->setLayout(LayoutFrame);
- LayoutFrame->addWidget(m_Tableur);
- LayoutFrame->addWidget(Grp);
-
- setOrientation(Qt::Vertical);
- addWidget(View);
- addWidget(Frame);
- resize(500,500);
- m_Angle=0.0;
- setWindowIcon(QPixmap(":/App"));
- QObject::connect(m_Tableur,SIGNAL(cellChanged(int,int)), this, SLOT(ModificationTableur(int,int)));
-
-
- }
-
-
-
-
-
- void Window::resizeEvent (QResizeEvent *event)
- {
- refresh();
-
- qDebug() << "Ily a :" << endl
- << m_ListeCourbe.size() << " Courbe(s)";
- for(int loop=0; loop<m_ListeCourbe.size(); ++loop)
- for(int nPt=0; nPt<m_ListeCourbe.at(loop).size(); ++nPt)
- {
- qDebug() << loop << ": " << m_ListeCourbe.at(loop).at(nPt).m_x << " " << m_ListeCourbe.at(loop).at(nPt).m_y;
- }
- qDebug() << endl << endl;
-
- }
-
-
-
-
-
-
- void Window::Animation(void)
- {
- m_Angle+=0.01;
- }
-
-
-
-
- void Window::ModificationTableur(int Ligne, int Colone)
- {
- bool PtValide=0;
- float x,y;
-
-
- QString Text = m_Tableur->item(Ligne, Colone)->text();
- qDebug() << "Tableur : " << Text;
-
- // Mise en Forme ...
- QStringList TextList= Text.split(";");
-
- // Exclusion ...
- if(TextList.size()!=2)
- {
- qDebug() << "Erreur (Split)";
-
- //return;
- }
- else
- {
- qDebug() << "Identification des Valeur";
- // Convertion en float
- bool ok1, ok2;
- QString TextPart = TextList.at(0);
- x = TextPart.toFloat(&ok1);
-
- TextPart = TextList.at(1);
- y = TextPart.toFloat(&ok2);
-
- if(ok1 && ok2)
- PtValide=1;
- }
-
- // Insertion dans le Tableur ...
-
- if(Colone > m_ListeCourbe[Ligne].size())
- {
- //Il faut Rentrer les Points dans l'Ordre
- PtValide=0;
-
- }
- else
- {
- qDebug() << "Les Points sont dans l'Ordre";
- PtValide = PtValide;
- }
-
-
-
-
- if(PtValide)
- {
-
- // Création Point ...
- MyPoint pt;
- pt.m_x = x;
- pt.m_y = y;
-
- GestionCourbe* Crb = &(m_ListeCourbe[Ligne]);
- if(Colone >= Crb->size())
- Crb->append(pt);
- else
- {
- Crb->replace(Colone,pt);
- }
-
- }
- else
- {
-
- // Ce n'est pas un Point
- if(Colone == m_ListeCourbe[Ligne].size()-1)
- {
- m_ListeCourbe[Ligne].takeAt(Colone);
- }
-
- if(Colone < m_ListeCourbe[Ligne].size()-1)
- {
-
- m_Tableur->item(Ligne, Colone)->setText(QString("%1;%2").arg(m_ListeCourbe[Ligne].at(Colone).m_x).arg(m_ListeCourbe[Ligne].at(Colone).m_y));
- }
-
- if(Colone >= m_ListeCourbe[Ligne].size()-1)
- {
- m_Tableur->item(Ligne, Colone)->setText("");
- }
-
- }
-
- View->updateGL();
- }
|