gapMea  1.0-rc1-1.5.3.2
GapMea est un outil visuel écrit en c++ à l'aide de la bibliothèque QT qui sert de base entre autre à l'environnement graphique de KDE.Il permet de dessiner des schémas recueillant et structurant les informations nécessaires à un domaine de gestion. Le schéma obtenu est enregistré dans un fichier texte au format xml.
 All Classes Functions Variables
association.cpp
1 #include "association.h"
2 #include <QPainter>
3 #include <QDebug>
4 
5 Association::Association(MainWindow* mum,QString nom,qreal x,qreal y, QGraphicsItem* parent, QCustomGraphicsScene * laScene, QStringList listeChamps, bool isAssoc)
6  : Entite(mum,nom,x,y, parent, laScene,listeChamps,isAssoc)
7 {
8  qDebug()<<"Association::Association(MainWindow* mum,QString nom,qreal x,qreal y, QGraphicsItem* parent, QCustomGraphicsScene * laScene, QStringList listeChamps)";
9  QGraphicsRectItem::setFlags(
10  QGraphicsItem::ItemIsFocusable
11  | QGraphicsItem::ItemIsMovable
12  | QGraphicsItem::ItemIsSelectable
13  |QGraphicsItem::ItemClipsChildrenToShape);
14  m_radius_x=20;
15  m_radius_y=m_radius_x;
16  rectTitle=NULL;
17  //if(rect().height()<100)rect().setHeight(100);
18 }
19 
20 
21 void Association::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
22 {
23  qDebug()<<"void Association::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)";
24  painter->setRenderHint(QPainter::Antialiasing,true);
25  if (QGraphicsRectItem::isSelected())
26  {
27  QPen pen;
28  pen.setStyle(Qt::DashLine);
29  painter->setPen(pen);
30  }
31 
32  //les dimensions
33  int hauteur=title->boundingRect().height();
34  if(vecteurChamps.size()>0)
35  hauteur+=vecteurChamps.size()*vecteurChamps[0]->boundingRect().height();
36  else
37  hauteur*=2;
38  QRectF leRect=rect();
39  leRect.setHeight(hauteur);
40  setRect(leRect);
41  //le contour
42  painter->drawRoundedRect(this->rect(),m_radius_x,m_radius_y);
43  //essais
44  QLinearGradient gradient(rect().topLeft(), rect().bottomRight()); // diagonal gradient from top-left to bottom-right
45  gradient.setColorAt(0, QColor("#FFD4A3"));
46  gradient.setColorAt(1, Qt::white);
47  //painter->fillRect(rect(), gradient);*/
48 
49  /* nouvel essais */
50  QPainterPath roundRectPath;
51  /*
52  roundRectPath.moveTo(80.0, 35.0);
53  roundRectPath.arcTo(70.0, 30.0, 10.0, 10.0, 0.0, 90.0);
54  roundRectPath.lineTo(25.0, 30.0);
55  roundRectPath.arcTo(20.0, 30.0, 10.0, 10.0, 90.0, 90.0);
56  roundRectPath.lineTo(20.0, 65.0);
57  roundRectPath.arcTo(20.0, 60.0, 10.0, 10.0, 180.0, 90.0);
58  roundRectPath.lineTo(75.0, 70.0);
59  roundRectPath.arcTo(70.0, 60.0, 10.0, 10.0, 270.0, 90.0);
60  roundRectPath.closeSubpath();
61  */
62  float largeur,left,top;
63  largeur=rect().width();
64  hauteur=rect().height();
65  left=0;
66  top=0;
67  float rayon=20;
68 
69  roundRectPath.moveTo(largeur, top+rayon);
70  roundRectPath.arcTo(largeur-2*rayon, top, 2*rayon, 2*rayon, 0.0, 90.0);
71  roundRectPath.lineTo(left+rayon, top);
72  roundRectPath.arcTo(left, top, 2*rayon, 2*rayon, 90.0, 90.0);
73  roundRectPath.lineTo(top, hauteur-rayon);
74  roundRectPath.arcTo(left, hauteur-2*rayon, 2*rayon, 2*rayon, 180.0, 90.0);
75  roundRectPath.lineTo(largeur-rayon, hauteur);
76  roundRectPath.arcTo(largeur-2*rayon, hauteur-2*rayon, 2*rayon, 2*rayon, 270.0, 90.0);
77  roundRectPath.closeSubpath();
78  //ajout de la ligne
79  //la ligne sous le titre
80 
81  float y=title->boundingRect().height();
82  roundRectPath.moveTo(0,y);
83  roundRectPath.lineTo(rect().width(),y);
84 
85  //redimensionnement
86 
87  painter->setBrush(gradient);
88  painter->drawPath(roundRectPath);
89 
90 }
91 
92 void Association::setRoundedRect(const QRectF rect, const double radius_x, const double radius_y)
93 {
94  this->setRect(rect);
95  this->setRadiusX(radius_x);
96  this->setRadiusY(radius_y);
97 }
98 
100 {
101  QVector <Entite*> resultat;
102  foreach (Lien* leLien, vectLiens) {
103  if(leLien->t2==this && leLien->typeDeJointure==QObject::tr("Leg"))
104  {
105  resultat.append(leLien->t1);
106  }
107  }
108  return resultat;
109 }
Entite * t2
t2 second object
Definition: lien.h:40
The QCustomGraphicsScene class This class is designed to deal with mouse events.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
paint association
Definition: association.cpp:21
void setRoundedRect(const QRectF rect, const double radius_x, const double radius_y)
Set the rounded rect.
Definition: association.cpp:92
The Lien class a link is betwwen to objects it contains a line a role text cardinality ...
Definition: lien.h:17
QVector< Entite * > vectEntitesAssociees()
vectEntitesAssociees
Definition: association.cpp:99
Entite * t1
t1 first object
Definition: lien.h:35
QVector< Lien * > vectLiens
vectLiens this vector contains adresses of the links concerning entity
Definition: entite.h:69
void setRadiusY(const double radius_y)
Set the rounded rect corner y radius.
Definition: association.h:53
QString typeDeJointure
typeDeJointure cif –1,1–CIF–0,n–> df –0,1–DF–0,n–>or leg --------—
Definition: lien.h:79
QVector< Property * > vecteurChamps
vecteurChamps container for entity's fields
Definition: entite.h:74
Association(MainWindow *mum, QString nom, qreal x, qreal y, QGraphicsItem *parent, QCustomGraphicsScene *laScene, QStringList listeChamps, bool isAssoc)
Association.
Definition: association.cpp:5
void setRadiusX(const double radius_x)
Set the rounded rect corner x radius.
Definition: association.h:50
The Entite class Entity is an object we have to deal with.
Definition: entite.h:20
QGraphicsTextItem * title
title
Definition: entite.h:53
The MainWindow class main code of application.
Definition: mainwindow.h:20
QGraphicsRectItem * rectTitle
rectTitle rectangle wich contains title
Definition: entite.h:49