Esempio n. 1
0
void Enlace::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                 QWidget *widget)
{
    //Dibujar la linea del centro de un nodo al otro
    // en color rojo

    painter->setPen(Qt::red);
    painter->setBrush(Qt::red);

    if (option->state & QStyle::State_Selected) {
        painter->setPen(Qt::blue);
        painter->setBrush(Qt::blue);

    }
    QLineF centerLine(this->getNodoOrigen()->pos(),
                      this->getNodoDestino()->pos());
   int x = abs(this->getNodoDestino()->x()-this->getNodoOrigen()->x())/2;
   int y =abs(this->getNodoDestino()->y()-this->getNodoOrigen()->y())/2 ;

   QPoint p;
   p.setX(x);   p.setY(y);
    this->setLine(centerLine);
    // o se pudo usar painter->drawLine(centerLine);
    painter->drawLine(this->line());
    painter->drawText(p,peso);
    qDebug() << "Painting de Enlace";
    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    this->setZValue(-1);

}
Esempio n. 2
0
/* make sure that the xvalues and yvalues contain enough values to go tracers deep */
void drawTracerGraph(HWND hwnd, long *xvalues, long *yvalues, int maxval, int tracers) {
//void drawTracerGraph(HWND hwnd, float nx, float ny) {
	HDC hdc;
	RECT rect;
	HPEN pen;
	int x,y;
	int w,h,fw,fh;
	int c;

	if (hdcTracer == NULL) initTracer(hwnd);

	/* get attributes */
	GetClientRect(hwnd, &rect);
	hdc = GetDC(hwnd);
	fw = rect.right - rect.left;
	fh = rect.bottom - rect.top;
	w = rect.right - rect.left - (XHAIR_HALF*2|1);
	h = rect.bottom - rect.top - (XHAIR_HALF*2|1);

	/* copy over the trace graph */
	BitBlt(hdc, 0, 0, fw, fh, hdcTracer, 0, 0, SRCCOPY);

	/* draw the xhair */
	for (c=tracers; c>0; c--) {
		pen = CreatePen(PS_SOLID, 1, RGB(255-(128/tracers*c),255-(255/tracers*c),0));
		SelectPen(hdc, pen);
		x = (int) (w*((float)xvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
		y = (int) (h*((float)yvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
		centerLine(hdc, x, y, (XHAIR_HALF|1)-2, LINE_XAXIS);
		centerLine(hdc, x, y, (XHAIR_HALF|1)-2, LINE_YAXIS);
		DeletePen(pen);
	}
	//special case of very first xhair
	pen = CreatePen(PS_SOLID, 1, RGB(255,0,0));
	SelectPen(hdc, pen);
	x = (int) (w*((float)xvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
	y = (int) (h*((float)yvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
	centerLine(hdc, x, y, XHAIR_HALF*2|1, LINE_XAXIS);
	centerLine(hdc, x, y, XHAIR_HALF*2|1, LINE_YAXIS);
	DeletePen(pen);
	GdiFlush();

	ReleaseDC(hwnd, hdc); 
}
Esempio n. 3
0
//! [4]
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
          QWidget *)
{
    if (myStartItem->collidesWithItem(myEndItem))
        return;

    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(myColor);
//! [4] //! [5]

    QLineF centerLine(myStartItem->pos(), myEndItem->pos());
    QPolygonF endPolygon = myEndItem->polygon();
    QPointF p1 = endPolygon.first() + myEndItem->pos();
    QPointF p2;
    QPointF intersectPoint;
    QLineF polyLine;
    for (int i = 1; i < endPolygon.count(); ++i) {
    p2 = endPolygon.at(i) + myEndItem->pos();
    polyLine = QLineF(p1, p2);
    QLineF::IntersectType intersectType =
        polyLine.intersect(centerLine, &intersectPoint);
    if (intersectType == QLineF::BoundedIntersection)
        break;
        p1 = p2;
    }

    setLine(QLineF(intersectPoint, myStartItem->pos()));
//! [5] //! [6]

    double angle = ::acos(line().dx() / line().length());
    if (line().dy() >= 0)
        angle = (Pi * 2) - angle;

        QPointF arrowP1 = line().p1() + QPointF(sin(angle + Pi / 3) * arrowSize,
                                        cos(angle + Pi / 3) * arrowSize);
        QPointF arrowP2 = line().p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
                                        cos(angle + Pi - Pi / 3) * arrowSize);

        arrowHead.clear();
        arrowHead << line().p1() << arrowP1 << arrowP2;
//! [6] //! [7]
        painter->drawLine(line());
        painter->drawPolygon(arrowHead);
        if (isSelected()) {
            painter->setPen(QPen(myColor, 1, Qt::DashLine));
        QLineF myLine = line();
        myLine.translate(0, 4.0);
        painter->drawLine(myLine);
        myLine.translate(0,-8.0);
        painter->drawLine(myLine);
    }
}
Esempio n. 4
0
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
                  QWidget *)
{
    if(!myStartItem || !myEndItem) {
        return;
    }

    if(myEndItem->sceneBoundingRect().contains(p1())) {
        return;
    }

    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 5;
    painter->setPen(myPen);
    painter->setBrush(myColor);

    QLineF centerLine(p1(), p2());
    QPolygonF endPolygon = myEndItem->mapToScene(myEndItem->shape()).toFillPolygon();
    QPointF p1 = endPolygon.first();
    QPointF p2;
    QPointF intersectPoint;
    QLineF polyLine;
    for (int i = 1; i < endPolygon.count(); ++i) {
        p2 = endPolygon.at(i);
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType =
                polyLine.intersect(centerLine, &intersectPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
        p1 = p2;
    }

    setLine(QLineF(intersectPoint, this->p1()));

    double angle = ::acos(line().dx() / line().length());
    if (line().dy() >= 0)
        angle = (Pi * 2) - angle;

    QPointF arrowP1 = line().p1() + QPointF(sin(angle + Pi / 3) * arrowSize,
                                            cos(angle + Pi / 3) * arrowSize);
    QPointF arrowP2 = line().p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
                                            cos(angle + Pi - Pi / 3) * arrowSize);

    arrowHead.clear();
    arrowHead << line().p1() << arrowP1 << arrowP2;
    painter->drawLine(line());
    painter->drawPolygon(arrowHead);
}
Esempio n. 5
0
void Enlace::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                 QWidget *widget)
{
    painter->setPen(Qt::black);
    painter->setBrush(Qt::red);

    if (option->state & QStyle::State_Selected) {
        painter->setPen(Qt::blue);
        painter->setBrush(Qt::blue);

    }
    QLineF centerLine(this->getNodoOrigen()->pos(),
                      this->getNodoDestino()->pos());
    this->setLine(centerLine);
    painter->drawText((this->getNodoOrigen()->pos()+
                      this->getNodoDestino()->pos())/2,peso);
    painter->drawLine(this->line());

}
Esempio n. 6
0
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
          QWidget *)
{
    if (source->collidesWithItem(destination))
        return;

    QPen myPen = pen();
    myPen.setColor(color);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(color);

    QLineF centerLine(source->pos(), destination->pos());
    centerLine.setLength(centerLine.length()-20.0);

    setLine(QLineF(centerLine.p2(), source->pos()));

    double angle = ::acos(line().dx() / line().length());
    if (line().dy() >= 0)
        angle = (3.14 * 2) - angle;

    QPointF arrowP1 = line().p1() + QPointF(sin(angle + 3.14 / 3) * arrowSize,
                                    cos(angle + 3.14 / 3) * arrowSize);
    QPointF arrowP2 = line().p1() + QPointF(sin(angle + 3.14 - 3.14 / 3) * arrowSize,
                                    cos(angle + 3.14 - 3.14 / 3) * arrowSize);

    arrowHead.clear();
    arrowHead << line().p1() << arrowP1 << arrowP2;
    painter->drawLine(line());
    painter->drawPolygon(arrowHead);
    if (isSelected()) {
        painter->setPen(QPen(color, 1, Qt::DashLine));
        QLineF myLine = line();
        myLine.translate(0, 4.0);
        painter->drawLine(myLine);
        myLine.translate(0,-8.0);
        painter->drawLine(myLine);
    }
}
void GraphicsTransition::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){

    //If the collide no need to draw an arrow
    if (mCurrentState->collidesWithItem(mNextState))
       return;


    QPen myPen = pen();
    myPen.setColor(Qt::white);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(Qt::white);


    QLineF centerLine(mCurrentState->getCenterPoint(), mNextState->getCenterPoint());
    QPolygonF endPolygon = mNextState->boundingRect();
    QPointF p1 = endPolygon.first() + mNextState->pos();
    QPointF p2;
    QPointF intersectPoint;
    QLineF polyLine;
    for (int i = 1; i < endPolygon.count(); ++i) {
        p2 = endPolygon.at(i) + mNextState->pos();
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType = polyLine.intersect(centerLine, &intersectPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
        p1 = p2;

    }

    setLine(QLineF(intersectPoint, mCurrentState->getCenterPoint()));

    double angle = ::acos(line().dx() / line().length());
    if (line().dy() >= 0)
        angle = (PI * 2) - angle;

    QPointF arrowP1 = line().p1() + QPointF(sin(angle + PI / 3) * arrowSize,
                                    cos(angle + PI / 3) * arrowSize);
    QPointF arrowP2 = line().p1() + QPointF(sin(angle + PI - PI / 3) * arrowSize,
                                    cos(angle + PI - PI / 3) * arrowSize);

    mArrowHead.clear();
    mArrowHead << line().p1() << arrowP1 << arrowP2;


    painter->drawLine(line());


    painter->drawPolygon(mArrowHead);
    //painter->drawEllipse(line().p1(), 10,10);

    //Selection square
    if (isSelected()) {
        painter->setPen(QPen(Qt::yellow, 3, Qt::DashLine));
        QLineF myLine = line();
        myLine.translate(0, 4.0);
        painter->drawLine(myLine);
        myLine.translate(0,-8.0);
        painter->drawLine(myLine);

    }




}
//! [4]
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
					QWidget *)
{
	if (myStartNode->collidesWithItem(myEndNode))
			return;

		QPen myPen = pen();
		myPen.setColor(myColor);
		qreal arrowSize = 10;
		painter->setPen(myPen);
		painter->setBrush(myColor);
//! [4] //! [5]

		// ----- gilgil temp 2012.06.29 -----
		/*
		QLineF centerLine(myStartNode->pos(), myEndNode->pos());
		QPolygonF endPolygon = myEndNode->polygon();
		QPointF p1 = endPolygon.first() + myEndNode->pos();
		QPointF p2;
		QPointF intersectPoint;
		QLineF polyLine;
		for (int i = 1; i < endPolygon.count(); ++i) {
		p2 = endPolygon.at(i) + myEndNode->pos();
		polyLine = QLineF(p1, p2);
		QLineF::IntersectType intersectType =
				polyLine.intersect(centerLine, &intersectPoint);
		if (intersectType == QLineF::BoundedIntersection)
				break;
				p1 = p2;
		}
		*/
		// ----------------------------------
		QPointF start, end;
		start.setX(myStartNode->pos().x() + myStartNode->boundingRect().width() / 2);
		start.setY(myStartNode->pos().y() + myStartNode->boundingRect().height() / 2);
		end.setX  (myEndNode->pos().x()   + myEndNode->boundingRect().width() / 2);
		end.setY  (myEndNode->pos().y()   + myEndNode->boundingRect().height() / 2);
		QLineF centerLine(start, end);

		QPointF intersectPoint;
		QLineF::IntersectType intersectType;
		QLineF polyLine;

		while (true)
		{
			polyLine = QLineF(myEndNode->sceneBoundingRect().topLeft(), myEndNode->sceneBoundingRect().topRight());
			intersectType = polyLine.intersect(centerLine, &intersectPoint);
			if (intersectType == QLineF::BoundedIntersection) break;

			polyLine = QLineF(myEndNode->sceneBoundingRect().topLeft(), myEndNode->sceneBoundingRect().bottomLeft());
			intersectType = polyLine.intersect(centerLine, &intersectPoint);
			if (intersectType == QLineF::BoundedIntersection) break;

			polyLine = QLineF(myEndNode->sceneBoundingRect().topRight(), myEndNode->sceneBoundingRect().bottomRight());
			intersectType = polyLine.intersect(centerLine, &intersectPoint);
			if (intersectType == QLineF::BoundedIntersection) break;

			polyLine = QLineF(myEndNode->sceneBoundingRect().bottomLeft(), myEndNode->sceneBoundingRect().bottomRight());
			intersectType = polyLine.intersect(centerLine, &intersectPoint);
			if (intersectType == QLineF::BoundedIntersection) break;

			break;
		}

		setLine(QLineF(intersectPoint, start));
//! [5] //! [6]

		double angle = ::acos(line().dx() / line().length());
		if (line().dy() >= 0)
			angle = (Pi * 2) - angle;

			QPointF arrowP1 = line().p1() + QPointF(sin(angle + Pi / 3) * arrowSize, cos(angle + Pi / 3) * arrowSize);
			QPointF arrowP2 = line().p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize, cos(angle + Pi - Pi / 3) * arrowSize);

			arrowHead.clear();
			arrowHead << line().p1() << arrowP1 << arrowP2;
//! [6] //! [7]
			painter->drawLine(line());
			painter->drawPolygon(arrowHead);
			if (isSelected()) {
				painter->setPen(QPen(myColor, 1, Qt::DashLine));
			QLineF myLine = line();
			myLine.translate(0, 4.0);
			painter->drawLine(myLine);
			myLine.translate(0,-8.0);
			painter->drawLine(myLine);
		}
}
Esempio n. 9
0
/* create and hdc of the trace graph so it can just be
	blitted over and we don't have to construct it every time */
static void initTracer(HWND hwnd) {
	HDC hdc;
	HBITMAP graph;
	HPEN pen;
	HBRUSH brush;
	RECT rect;
	long fw,fh,w,h;

	GetClientRect(hwnd, &rect);
	fw = rect.right - rect.left;
	fh = rect.bottom - rect.top;
	w = fw - (XHAIR_HALF*2|1);
	h = fh - (XHAIR_HALF*2|1);


	/* create the memoryDC for the graph */
	hdc = GetDC(hwnd);
	graph = CreateCompatibleBitmap(hdc, fw, fh);
	hdcTracer = CreateCompatibleDC(hdc);
	ReleaseDC(hwnd, hdc); //we now longer need this, we now draw into hdcTracer
	SelectBitmap(hdcTracer, graph);

	/* fill with black */
	brush = CreateSolidBrush(RGB(0,0,0));
	FillRect(hdcTracer, &rect, brush);
	DeleteBrush(brush);
	
	/* draw reference grid */
	pen = CreatePen(PS_SOLID, 1, RGB(0,255,255));
	SelectPen(hdcTracer, pen);
	//Squares
	brush = CreateSolidBrush(RGB(0,64,64));
	SelectBrush(hdcTracer, brush);
	//borderRect(hdcTracer, XHAIR_HALF, XHAIR_HALF, XHAIR_HALF+w+1, XHAIR_HALF+h+1, brush);
	borderRect(hdcTracer, XHAIR_HALF, XHAIR_HALF, XHAIR_HALF+w+1, XHAIR_HALF+w+1, brush);
	borderRect(hdcTracer, XHAIR_HALF + w/4, XHAIR_HALF + h/4, XHAIR_HALF + w/4*3+1, XHAIR_HALF + h/4*3+1, brush);
	DeleteBrush(brush);
	/*brush = CreateSolidBrush(RGB(0,16,16));
	SelectBrush(hdcTracer, brush);
	borderRect(hdcTracer, XHAIR_HALF + w/8*3, XHAIR_HALF + h/8*3, XHAIR_HALF + w/8*5+1, XHAIR_HALF + h/8*5+1, brush);
	borderRect(hdcTracer, XHAIR_HALF + w/8, XHAIR_HALF + h/8, XHAIR_HALF + w/8*7+1, XHAIR_HALF + h/8*7+1, brush);
	DeleteBrush(brush);*/
	//Main Axis
	centerLine(hdcTracer, fw/2, fh/2, w, LINE_XAXIS);
	centerLine(hdcTracer, fw/2, fh/2, h, LINE_YAXIS);
	//X half hashes
	centerLine(hdcTracer,			XHAIR_HALF, h/2 + XHAIR_HALF, BIG_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w/4	+ XHAIR_HALF, h/2 + XHAIR_HALF, BIG_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w/4*3 + XHAIR_HALF, h/2 + XHAIR_HALF, BIG_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w	  + XHAIR_HALF, h/2 + XHAIR_HALF, BIG_HASH, LINE_YAXIS);
	//X quarter hashes
	centerLine(hdcTracer, w/8	+ XHAIR_HALF, h/2 + XHAIR_HALF, SMALL_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w/8*3 + XHAIR_HALF, h/2 + XHAIR_HALF, SMALL_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w/8*5 + XHAIR_HALF, h/2 + XHAIR_HALF, SMALL_HASH, LINE_YAXIS);
	centerLine(hdcTracer, w/8*7 + XHAIR_HALF, h/2 + XHAIR_HALF, SMALL_HASH, LINE_YAXIS);
	//Y half hashes
	centerLine(hdcTracer, w/2 + XHAIR_HALF,			XHAIR_HALF, BIG_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/4	+ XHAIR_HALF, BIG_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/4*3 + XHAIR_HALF, BIG_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h	  + XHAIR_HALF, BIG_HASH, LINE_XAXIS);
	//Y quarter hashes
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/8	+ XHAIR_HALF, SMALL_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/8*3 + XHAIR_HALF, SMALL_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/8*5 + XHAIR_HALF, SMALL_HASH, LINE_XAXIS);
	centerLine(hdcTracer, w/2 + XHAIR_HALF, h/8*7 + XHAIR_HALF, SMALL_HASH, LINE_XAXIS);

	DeletePen(pen);
	GdiFlush();
}
Esempio n. 10
0
/*--------------------------------------------------------------------------*/
static void centerPrint(char *str)
{
    centerLine(str);
    sciprint(str);
}
Esempio n. 11
0
void Arrow::updatePosition()
{
    //QLineF line(mapFromItem(m_startItem, 0, 0), mapFromItem(m_endItem, 0, 0));
    //setLine(line);
    const QPointF startPos = m_startItem->pos();
    const QPointF endPos = m_endItem->pos();

    if (m_startItem->collidesWithItem(m_endItem)) {
        setLine(0, 0, 0, 0);
        return;
    }

    const qreal startScale = m_startItem->scale();
    const qreal endScale = m_endItem->scale();

    const int deltaX = qAbs(startPos.x() - endPos.x());
    const int deltaY = qAbs(startPos.y() - endPos.y());
    const QPointF pointDeltaX = QPointF(m_startItem->boundingRect().width() / 4, 0) * startScale;
    const QPointF pointDeltaY = QPointF(0, m_startItem->boundingRect().height() / 4) * startScale;

    QLineF centerLine(startPos + m_startItem->boundingRect().center() * startScale,
                      endPos + m_endItem->boundingRect().center() * endScale);

    switch (m_status) {
    case PostMonster::Ok:
    case PostMonster::True:
        if (deltaX < deltaY)
            centerLine = QLineF(centerLine.p1() + pointDeltaX, centerLine.p2() + pointDeltaX);
        else
            centerLine = QLineF(centerLine.p1() - pointDeltaY, centerLine.p2() - pointDeltaY);
        break;

    case PostMonster::Fail:
    case PostMonster::False:
        if (deltaX < deltaY)
            centerLine = QLineF(centerLine.p1() - pointDeltaX, centerLine.p2() - pointDeltaX);
        else
            centerLine = QLineF(centerLine.p1() + pointDeltaY, centerLine.p2() + pointDeltaY);
        break;

    case PostMonster::Default:
        break;
    }

    QPolygonF itemPolygon = m_endItem->shape().toFillPolygon();
    QPointF p1 = itemPolygon.first() + endPos;
    QPointF p2;
    QPointF startPoint, endPoint;
    QLineF polyLine;
    for (int i = 1; i < itemPolygon.count(); ++i) {
        p2 = itemPolygon.at(i) * endScale + endPos;
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType =
            polyLine.intersect(centerLine, &endPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
        p1 = p2;
    }

    itemPolygon = m_startItem->shape().toFillPolygon();
    p1 = itemPolygon.first() + startPos;
    for (int i = 1; i < itemPolygon.count(); ++i) {
        p2 = itemPolygon.at(i) * startScale + startPos;
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType =
            polyLine.intersect(centerLine, &startPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
        p1 = p2;
    }

    setLine(QLineF(endPoint, startPoint));
}
Esempio n. 12
0
void Lien::redraw(QPainter *painter, const QStyleOptionGraphicsItem *,QWidget *)
 {
     qDebug()<<"void lien::paint(QPainter *painter, const QStyleOptionGraphicsItem *,QWidget *)";
     if (t1->collidesWithItem(t2))
         return;
     QColor myColor(Qt::red);
     QPen myPen = laLigne->pen();
     myPen.setColor(myColor);
     painter->setPen(myPen);
     painter->setBrush(myColor);
     QPointF origine=t1->pos()+QPointF(t1->boundingRect().width()/2,10);
     QPointF destination=t2->pos()+QPointF(t2->boundingRect().width()/2,10);
     QLineF centerLine(origine,destination);
     QPolygonF endPolygon = t2->polygon();
     QPolygonF beginPolygon = t1->polygon();

     QPointF p1 = endPolygon.first()+t2->pos() ;
     QPointF p2;
     QPointF intersectPointT2;
     QLineF polyLine;
     for (int i = 1; i < endPolygon.count(); ++i)
     {
         p2 = endPolygon.at(i)+t2->pos();
         polyLine = QLineF(p1, p2);
         QLineF::IntersectType intersectType =
                 polyLine.intersect(centerLine, &intersectPointT2);
         if (intersectType == QLineF::BoundedIntersection)
             break;
         p1 = p2;
     }
     p1 = beginPolygon.first()+t1->pos() ;

     QPointF intersectPointT1;

     for (int i = 1; i < beginPolygon.count(); ++i)
     {
         p2 = beginPolygon.at(i)+t1->pos();
         polyLine = QLineF(p1, p2);
         QLineF::IntersectType intersectType =
                 polyLine.intersect(centerLine, &intersectPointT1);
         if (intersectType == QLineF::BoundedIntersection)
             break;
         p1 = p2;
     }
     laLigne->setLine(QLineF(intersectPointT1,intersectPointT2));
if(typeDeJointure=="Cross")
     {

         texte1->document()->setPlainText("X");

         texte2->document()->setPlainText("X");
     }
     else
{
     if(typeDeJointure=="Natural")
     {

         texte1->document()->setPlainText("?");

         texte2->document()->setPlainText("?");
     }
     else
     {
         if(typeDeJointure=="Inner")
         {

             texte1->document()->setPlainText("=");

             texte2->document()->setPlainText("=");
         }
         else
         {
             if(typeDeJointure=="left outer")
         {

             texte1->document()->setPlainText("+=");

             texte2->document()->setPlainText("");
         }
         else
         {
             if(typeDeJointure=="right outer")
         {

             texte1->document()->setPlainText("");

             texte2->document()->setPlainText("+=");
         }

         }

         }
     }
 }
         QPointF posTexte1,posTexte2;

         if(intersectPointT1.x()<intersectPointT2.x())
         {
             posTexte1.setX(intersectPointT1.x());
             posTexte2.setX(intersectPointT2.x()-texte2->document()->size().width());

         }
         else
         {
             posTexte2.setX(intersectPointT2.x());
             posTexte1.setX(intersectPointT1.x()-texte1->document()->size().width());

         }
         if(intersectPointT1.y()<intersectPointT2.y())
         {
             posTexte1.setY(intersectPointT1.y());
             posTexte2.setY(intersectPointT2.y()-texte2->document()->size().height());
         }
         else
         {
             posTexte2.setY(intersectPointT2.y());
             posTexte1.setY(intersectPointT1.y()-texte1->document()->size().height());
         }
         texte1->setPos(posTexte1);
         texte2->setPos(posTexte2);


    painter->drawLine(laLigne->line());

     //
     if (isSelected())
     {
         painter->setPen(QPen(myColor, 1, Qt::DashLine));
         QLineF myLine = laLigne->line();
         myLine.translate(0, 4.0);
         painter->drawLine(myLine);
         myLine.translate(0,-8.0);
         painter->drawLine(myLine);
     }
}