IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Discussion :

Problème de compilation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Par défaut Problème de compilation
    Salut tout le monde j'ai un problème de compilation
    voila le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    #include <QGraphicsScene>
    #include <QGraphicsSceneMouseEvent>
    #include <QPainter>
    #include <QStyleOption>
    #include <QMessageBox>
     
    #include "Node.h"
     
    Node::Node(MyQGraphicsView *pointer,int  val,int a_size): id(inc_id++),value(val),size(a_size), half_size(a_size/2),pathValue(-1),graph(pointer)
    {
        setFlag(ItemIsMovable);
        setCacheMode(DeviceCoordinateCache);
        setZValue(1);
    }
     
    Node::~Node()
    {
     /* foreach(Edge *edge, edgeList)
      {
          (edge->sourceNode());
          (edge->destNode());
          delete edge;
      }
      */
    }
     
    void Node::addEdge(Edge *edge)
    {
        edgeList << edge;
        edge->adjust();
    }
     
    void Node::removeEdge(Edge *edge)
    {
        edgeList.removeOne(edge);
    }
     
    QList<Edge *> Node::edges() const
    {
        return edgeList;
    }
    void Node::calculateForces()
    {
        if (!scene() || scene()->mouseGrabberItem() == this) {
            newPos = pos();
            return;
        }
     
        // Sum up all forces pushing this item away
        qreal xvel = 0;
        qreal yvel = 0;
        foreach (QGraphicsItem *item, scene()->items()) {
            Node *node = qgraphicsitem_cast<Node *>(item);
            if (!node)
                continue;
     
            QLineF line(mapFromItem(node, 0, 0), QPointF(0, 0));
            qreal dx = line.dx();
            qreal dy = line.dy();
            double l = 2.0 * (dx * dx + dy * dy);
            if (l > 0) {
                xvel += (dx * 150.0) / l;
                yvel += (dy * 150.0) / l;
            }
        }
     
        // Now subtract all forces pulling items together
        double weight = (edgeList.size() + 1) * 10;
        foreach (Edge *edge, edgeList) {
            QPointF pos;
            if (edge->sourceNode() == this)
                pos = mapFromItem(edge->destNode(), 0, 0);
            else
                pos = mapFromItem(edge->sourceNode(), 0, 0);
            xvel += pos.x() / weight;
            yvel += pos.y() / weight;
        }
     
        if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
            xvel = yvel = 0;
     
        QRectF sceneRect = scene()->sceneRect();
        newPos = pos() + QPointF(xvel, yvel);
        newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
        newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
    }
     
    bool Node::advance()
    {
        if (newPos == pos())
            return false;
     
        setPos(newPos);
        return true;
    }
     
    QRectF Node::boundingRect() const
    {
        qreal adjust = 2;
        return QRectF(-(half_size) - adjust, -(half_size) - adjust,
                size + adjust+2, size + adjust+2);
    }
    QPainterPath Node::shape() const
    {
        QPainterPath path;
        path.addEllipse(-half_size, -half_size, size, size);
        return path;
    }
    void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
    {
        painter->setPen(Qt::SolidLine);
        painter->setBrush(Qt::darkGray);
        painter->drawEllipse(-half_size, -half_size, size, size);
        QRadialGradient gradient(-3, -3, 20);
     
        if( pathValue != -1 )
        {
            //gradient.setCenter(3, 3);
            //gradient.setFocalPoint(3, 3);
            gradient.setColorAt(1, QColor(Qt::darkGreen).light(120));
            gradient.setColorAt(0, QColor(Qt::green).light(120));
        }
        else if (option->state & QStyle::State_Sunken) {
            gradient.setCenter(3, 3);
            gradient.setFocalPoint(3, 3);
            gradient.setColorAt(1, QColor(Qt::yellow).light(120));
            gradient.setColorAt(0, QColor(Qt::darkYellow).light(120));
        } else {
            gradient.setColorAt(0, Qt::yellow);
            gradient.setColorAt(1, Qt::darkYellow);
        }
        painter->setBrush(gradient);
        painter->setPen(QPen(Qt::black, 0));
        painter->drawEllipse(-half_size, -half_size, size, size);
     
        if( pathValue == -1 )
            painter->drawText(QRectF(-half_size,-half_size,size,size), Qt::AlignCenter, QString::number(id)+"( "+QString::number(value)+" )");
        else
            painter->drawText(QRectF(-half_size,-half_size,size,size), Qt::AlignCenter, QString::number(id)+"( "+QString::number(value)+" )\n"+ QString::number(pathValue));
     
     
    }
    QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
    {
     
        switch (change) {
            case ItemPositionHasChanged:
                foreach (Edge *edge, edgeList)
                    edge->adjust();
                //graph->itemMoved();
                break;
            default:
                break;
        };
     
        return QGraphicsItem::itemChange(change, value);
     
    }
    void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
    {
        if(event->button() == Qt::LeftButton)
            update();
        if(event->button() == Qt::LeftButton )
        {
            emit leftClick(id);
            QGraphicsItem::mousePressEvent(event);
        }
        //else if( event->button() == Qt::MidButton ){
        else if( event->button() == Qt::RightButton ){
            emit rightClick(id);
            //QGraphicsItem::mousePressEvent(event);
        }
        //QMessageBox::information( NULL, "Application name",
        //        "Lalala.\n"
        //        "alalalal" );
     
        //update();
        //setPos( event->pos());
        //QGraphicsItem::mousePressEvent(event);
     
    }
    void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
    {
        if(event->button() == Qt::LeftButton)
             update();
        QGraphicsItem::mouseReleaseEvent(event);
    }
    l'erreur :
    indefined reference to Node::inc_id
    et merciii

  2. #2
    Rédacteur/Modérateur
    Avatar de arnolddumas
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2012
    Messages
    978
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : Autriche

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2012
    Messages : 978
    Par défaut
    On peut voir le .h ou .hpp ?

  3. #3
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2013
    Messages : 15
    Par défaut
    voilà le fichier Node.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    #ifndef NODE_H
    #define NODE_H
    #include <QGraphicsItem>
    #include <QList>
    #include <QMouseEvent>
     
    #include <Edge.h>
    //class Node
    //class Edge;
    #include "MyQGraphicsView.h"
    //#include <QGraphWidget>
     
    class Node : public QObject, public QGraphicsItem
    {
        Q_OBJECT
        static int inc_id;
        int id;
        int value;
        int size;
        int half_size;
        int pathValue;
        public:
           Node( MyQGraphicsView* pointer,int val=10,int a_size=50);
           virtual ~Node();
           int getId(){return id;}
           static int getLastId(){ return inc_id; }
           static void resetId(){ inc_id = 0; }
           void setValue(int a_value){ value = a_value; }
           int getValue(){ return value; }
     
           void setPathValue(int val){ pathValue = val;}
           int getPathValue(){ return pathValue; }
     
           void addEdge(Edge *edge);
           void removeEdge(Edge *edge);
           QList<Edge *> edges() const;
     
           enum { Type = UserType + 1 };
           int type() const { return Type; }
     
           void calculateForces();
           bool advance();
           QPainterPath shape() const;
     
           QRectF boundingRect() const;
           void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     
    signals:
            void rightClick(int);
            void leftClick(int);
     
     
        protected:
            QVariant itemChange(GraphicsItemChange change, const QVariant &value);
     
            void mousePressEvent(QGraphicsSceneMouseEvent *event);
            void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
        private:
            QList<Edge *> edgeList;
            QPointF newPos;
            MyQGraphicsView *graph;
     
    };
     
    #endif // NODE_H

  4. #4

Discussions similaires

  1. problème de compilation sous visual C++
    Par fabmili dans le forum MFC
    Réponses: 4
    Dernier message: 08/02/2004, 19h52
  2. problème de compil devc++ socket
    Par stefdem dans le forum Autres éditeurs
    Réponses: 2
    Dernier message: 11/12/2003, 11h33
  3. Réponses: 1
    Dernier message: 29/10/2003, 12h16
  4. Problème de compilation de la DLL du XMLRad
    Par [DreaMs] dans le forum XMLRAD
    Réponses: 2
    Dernier message: 16/04/2003, 16h46
  5. Réponses: 1
    Dernier message: 27/05/2002, 01h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo