Example #1
0
void testSplines()
{
    QPolygonF points;

    // 3 points

    points << QPointF( 10, 50 ) << QPointF( 60, 30 ) << QPointF( 82, 50 );

    testSplines( points );

    // 4 points

    points.clear();
    points << QPointF( 10, 50 ) << QPointF( 60, 30 )
        << QPointF( 70, 5 ) << QPointF( 82, 50 );

    testSplines( points );

    // 5 points
    points.clear();
    points << QPointF( 10, 50 ) << QPointF( 20, 20 ) << QPointF( 60, 30 )
        << QPointF( 70, 5 ) << QPointF( 82, 50 );

    testSplines( points );

    // 12 points

    points.clear();
    points << QPointF( 10, 50 ) << QPointF( 20, 90 ) << QPointF( 25, 60 )
        << QPointF( 35, 38 ) << QPointF( 42, 40 ) << QPointF( 55, 60 )
        << QPointF( 60, 50 ) << QPointF( 65, 80 ) << QPointF( 73, 30 )
        << QPointF( 82, 30 ) << QPointF( 87, 40 ) << QPointF( 95, 50 );

    testSplines( points );

    // many points
    points.clear();

    const double x1 = 10.0;
    const double x2 = 1000.0;
    const double y1 = -10000.0;
    const double y2 = 10000.0;

    points += QPointF( x1, y1 );

    const int n = 100;
    const double dx = ( x2 - x1 ) / n;
    const int mod = y2 - y1;
    for ( int i = 1; i < n - 1; i++ )
    {
        const double r = qrand() % mod;
        points += QPointF( x1 + i * dx, y1 + r );
    }
    points += QPointF( x2, y1 );

    testSplines( points );
}
void
SplineTransferFunction::updateColorMapImage()
{
  m_colorMapImage.fill(0);

  QPainter colorMapPainter(&m_colorMapImage);
  colorMapPainter.setCompositionMode(QPainter::CompositionMode_Source);

  QPolygonF pointsLeft;
  pointsLeft.clear();
  for (int i=0; i<m_points.size(); i++)
    {
      QPointF pt = m_leftNormals[i];
      pointsLeft << QPointF(pt.x()*255, pt.y()*255);
    }
  
	  
  QPolygonF pointsRight;
  pointsRight.clear();
  for (int i=0; i<m_points.size(); i++)
    {
      QPointF pt = m_rightNormals[i];
      pointsRight << QPointF(pt.x()*255, pt.y()*255);
    }

  QGradientStops gstops = StaticFunctions::resampleGradientStops(m_gradientStops);
  for (int i=1; i<m_points.size(); i++)
    {
      QPainterPath pathRight, pathLeft;
      getPainterPathSegment(&pathRight, pointsRight, i);
      getPainterPathSegment(&pathLeft, pointsLeft, i);
      
      float pathLen = 1.5*qMax(pathRight.length(), pathLeft.length());
      for (int l=0; l<pathLen+1; l++)
	{
	  QPointF vLeft, vRight;
	  float frc = (float)l/(float)pathLen;
	  
	  vLeft = pathLeft.pointAtPercent(frc);
	  vRight = pathRight.pointAtPercent(frc);
	  
	  QLinearGradient lg(vRight.x(), vRight.y(),
			     vLeft.x(), vLeft.y());
	  lg.setStops(gstops);
	  
	  QPen pen;
	  pen.setBrush(QBrush(lg));
	  pen.setWidth(2);
	  
	  colorMapPainter.setPen(pen);
	  colorMapPainter.drawLine(vRight, vLeft);
	}
    }
}
Example #3
0
void Cota::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	Q_UNUSED(widget);

	const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform());
	if ( lod > 0.125 ) {
		painter->setPen(QPen(Qt::darkGray, 0.2));
		painter->setBrush(QBrush(Qt::darkGray));
		// Dibujamos la línea de la cota
		qreal yLine = HEIGHT_TOTAL - 3;
		painter->drawLine(QPointF(0, yLine), QPointF(d->m_width, yLine));
		painter->drawLine(QPointF(0, yLine-HEIGHT_COTA), QPointF(0, yLine+HEIGHT_COTA));
		painter->drawLine(QPointF(d->m_width, yLine-HEIGHT_COTA), QPointF(d->m_width, yLine+HEIGHT_COTA));
		// Ahora dibujamos los triángulos
		QPolygonF polygon;
		// Si el tamaño es menor que el ancho de las puntas de flecha, se dibujan al revés
		if ( d->m_width < HEIGHT_COTA ) {
			polygon << QPointF(0, yLine)
					<< QPointF(-1*(HEIGHT_COTA/2), (HEIGHT_COTA/2)+yLine)
					<< QPointF(-1*(HEIGHT_COTA/2), -1 * (HEIGHT_COTA/2)+yLine);
			painter->drawPolygon(polygon);
			polygon.clear();
			polygon << QPointF(d->m_width, yLine)
					<< QPointF(d->m_width + (HEIGHT_COTA/2), -1 * (HEIGHT_COTA/2)+yLine)
					<< QPointF(d->m_width + (HEIGHT_COTA/2), (HEIGHT_COTA/2)+yLine);
			painter->drawPolygon(polygon);
		} else {
			polygon << QPointF(0, yLine)
					<< QPointF((HEIGHT_COTA/2), (HEIGHT_COTA/2)+yLine)
					<< QPointF((HEIGHT_COTA/2), -1 * (HEIGHT_COTA/2)+yLine);
			painter->drawPolygon(polygon);
			polygon.clear();
			polygon << QPointF(d->m_width, HEIGHT_TOTAL - 3)
					<< QPointF(d->m_width - (HEIGHT_COTA/2), -1 * (HEIGHT_COTA/2)+yLine)
					<< QPointF(d->m_width - (HEIGHT_COTA/2), (HEIGHT_COTA/2)+yLine);
			painter->drawPolygon(polygon);
		}

		QFont font("Arial", 8);
		font.setStyleStrategy(QFont::ForceOutline);
		double fontScale = 0.5;
		QString text = QString("%1 %2").arg(d->m_width).arg(d->m_unit);
		QRectF rect;
		painter->setPen(QPen(Qt::black, 1));
		painter->setFont(font);
		painter->scale(fontScale, fontScale);
		d->m_textWidth = painter->fontMetrics().width(text);
		rect = QRectF((d->m_width < d->m_textWidth ? -d->m_textWidth/(2*fontScale) : 0), 0,
					  (d->m_width < d->m_textWidth ? d->m_textWidth/fontScale : d->m_width/fontScale),
						HEIGHT_TOTAL/fontScale);
		painter->drawText(rect, Qt::AlignCenter, text);
	}
}
QPainterPath UBGraphicsTriangle::shape() const
{
    QPainterPath tShape;
    QPolygonF tPolygon;

    tPolygon << A1 << B1 << C1;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    tPolygon << A2 << B2 << C2;
    tShape.addPolygon(tPolygon);
    tPolygon.clear();

    return tShape;
}
Example #5
0
/**
 * Paint arrow
 */
void drawLineHead (QPainter * painter, QPointF end, double angle, double size, bool figure)
{
    QPointF lineP1 = end + QPointF( sin( angle + Pi / 3) * size, cos( angle + Pi / 3) * size);
    QPointF lineP2 = end + QPointF( sin( angle + Pi - Pi / 3) * size, cos( angle + Pi - Pi / 3) * size);
	QPointF centre = (lineP1 + lineP2 + end)/3;

	if (figure)
	{
		QPainterPath arrow;
		arrow.moveTo (end);
		arrow.quadTo (centre, lineP1);
		arrow.lineTo (lineP2);
		arrow.quadTo (centre, end);

		painter->drawPath (arrow);
	}
	else
	{
		QPolygonF lineHead;
		lineHead.clear();
		lineHead << end << lineP1 << lineP2;
	
		painter->drawPolygon (lineHead);
	}
}
Example #6
0
QgsConstWkbPtr QgsClipper::clippedLineWKB( QgsConstWkbPtr wkbPtr, const QgsRectangle& clipExtent, QPolygonF& line )
{
  QgsWKBTypes::Type wkbType = wkbPtr.readHeader();

  int nPoints;
  wkbPtr >> nPoints;

  int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double );

  if ( static_cast<int>( nPoints * ( 2 * sizeof( double ) + skipZM ) ) > wkbPtr.remaining() )
  {
    QgsDebugMsg( QString( "%1 points exceed wkb length (%2>%3)" ).arg( nPoints ).arg( nPoints * ( 2 * sizeof( double ) + skipZM ) ).arg( wkbPtr.remaining() ) );
    return QgsConstWkbPtr( nullptr, 0 );
  }

  double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
  double p1x_c, p1y_c; //clipped end coordinates
  double lastClipX = 0.0, lastClipY = 0.0; //last successfully clipped coords

  line.clear();
  line.reserve( nPoints + 1 );

  for ( int i = 0; i < nPoints; ++i )
  {
    if ( i == 0 )
    {
      wkbPtr >> p1x >> p1y;
      wkbPtr += skipZM;
      continue;
    }
    else
    {
Example #7
0
void Plot::drawDots(QVector< QVector<struct numCluster> > data, double n, double k, int index, int size, int number)
{
    int j, l;
    QPolygonF points;
    QwtPlotCurve *curve;

    QwtSymbol *symbol;

    points.clear();
    curve = new QwtPlotCurve();//QString("y = norm%1(x)").arg(index));
    curve->setItemAttribute(QwtPlotItem::Legend, false);
    curve->setStyle( QwtPlotCurve::Dots );
    for (l = 0; l < data.size(); l++){
        if (data[l][number].cluster == index){
            // ПЕРЕДЕЛАТЬ если возможно!!! Нужно, чтобы он печатал сразу для всех кластеров одной л.п.
            if (index == 0 && data[l][number].number < n){
                points << QPointF(data[l][number].number, 1);
            }else if (index == size - 1 && data[l][number].number > n){
                points << QPointF(data[l][number].number, 1);
            }else{
                points << QPointF(data[l][number].number, func_normal(data[l][number].number,n,k));
            }

            //std::cout << index << "data = " << data[l][i].number << std::endl;
        }
    }
    curve->setSamples(points);
    switch (index % 5){
    case 0:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::yellow ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 1:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::green ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 2:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::cyan ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 3:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::magenta ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 4:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::gray ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    default:
        break;
    }
    curve->attach(this);
    this->replot();
}
void HgTransformedQuad::getTransformedPoints(QPolygonF& poly) const
{
    poly.clear();
    poly.append(mTransformedPoints[0].toPointF());
    poly.append(mTransformedPoints[1].toPointF());
    poly.append(mTransformedPoints[2].toPointF());
    poly.append(mTransformedPoints[3].toPointF());
}
void Triangle::transformerEnPolygone(QPolygonF &polygone , QVector<QPointF>& points)
{
    polygone.clear();
    polygone.push_back(points[this->sommets[0]]);
    polygone.push_back(points[this->sommets[1]]);
    polygone.push_back(points[this->sommets[2]]);

}
Example #10
0
void DataConverter::makeCirclePolygon(QPolygonF &points, qreal radius)
{
	points.clear();

	for (int i = 0; i < 1440; i++)
	{
		points.append( QPointF( radius * qSin( 2 *3.14145 * i / 1440.0), radius * qCos( 2 * 3.14159 * i / 1440.0 )) );
	}
}
void paintElements( AbstractDiagram::Private *diagramPrivate, PaintContext* ctx,
                    const LabelPaintCache& lpc, const LineAttributesInfoList& lineList )
{
    AbstractDiagram* diagram = diagramPrivate->diagram;
    // paint all lines and their attributes
    const PainterSaver painterSaver( ctx->painter() );
    ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() );

    QBrush curBrush;
    QPen curPen;
    QPolygonF points;
    KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) {
        const QModelIndex& index = lineInfo.index;
        const ThreeDLineAttributes td = threeDLineAttributes( diagram, index );

        if ( td.isEnabled() ) {
            PaintingHelpers::paintThreeDLines( ctx, diagram, index, lineInfo.value,
                                               lineInfo.nextValue, td, &diagramPrivate->reverseMapper );
        } else {
            const QBrush brush( diagram->brush( index ) );
            const QPen pen( diagram->pen( index ) );

            // line goes from lineInfo.value to lineInfo.nextValue
            diagramPrivate->reverseMapper.addLine( lineInfo.index.row(), lineInfo.index.column(),
                                                   lineInfo.value, lineInfo.nextValue );

            if ( points.count() && points.last() == lineInfo.value && curBrush == brush && curPen == pen ) {
                // continue the current run of lines
            } else {
                // different painter settings or discontinuous line: start a new run of lines
                if ( points.count() ) {
                    PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points );
                }
                curBrush = brush;
                curPen = pen;
                points.clear();
                points << lineInfo.value;
            }
            points << lineInfo.nextValue;
        }
    }
    if ( points.count() ) {
        // the last run of lines is yet to be painted - do it now
        PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points );
    }

    KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) {
        const ValueTrackerAttributes vt = valueTrackerAttributes( diagram, lineInfo.index );
        if ( vt.isEnabled() ) {
            PaintingHelpers::paintValueTracker( ctx, vt, lineInfo.nextValue );
        }
    }

    // paint all data value texts and the point markers
    diagramPrivate->paintDataValueTextsAndMarkers( ctx, lpc, true );
}
// this method is factored out from LineDiagram::paint, and contains
// the common parts of the method that  previously implemented all
// chart types in one
void LineDiagram::LineDiagramType::paintElements(
    PaintContext* ctx,
    DataValueTextInfoList& list,
    LineAttributesInfoList& lineList,
    LineAttributes::MissingValuesPolicy policy )
{
    Q_UNUSED( policy );
    // paint all lines and their attributes
    const PainterSaver painterSaver( ctx->painter() );
    if ( diagram()->antiAliasing() )
        ctx->painter()->setRenderHint ( QPainter::Antialiasing );
    LineAttributesInfoListIterator itline ( lineList );

    QBrush curBrush;
    QPen curPen;
    QPolygonF points;
    while ( itline.hasNext() ) {
        const LineAttributesInfo& lineInfo = itline.next();
        const QModelIndex& index = lineInfo.index;
        const ThreeDLineAttributes td = diagram()->threeDLineAttributes( index );
        const ValueTrackerAttributes vt = diagram()->valueTrackerAttributes( index );

        if( td.isEnabled() ){
            paintThreeDLines( ctx, index, lineInfo.value, lineInfo.nextValue, td.depth() );
        } else {
            const QBrush br( diagram()->brush( index ) );
            const QPen pn( diagram()->pen( index ) );
            if( points.count() && points.last() == lineInfo.value && curBrush == br && curPen == pn ) {
                // line goes from last value in points to lineInfo.nextValue
                reverseMapper().addLine( lineInfo.index.row(), lineInfo.index.column(), points.last(), lineInfo.nextValue );
                points << lineInfo.nextValue;
            } else {
                if( points.count() )
                    paintPolyline( ctx, curBrush, curPen, points );
                curBrush = br;
                curPen   = pn;
                points.clear();
                // line goes from lineInfo.value to lineInfo,nextValue
                reverseMapper().addLine( lineInfo.index.row(), lineInfo.index.column(), lineInfo.value, lineInfo.nextValue );
                points << lineInfo.value << lineInfo.nextValue;
            }
        }

        if( vt.isEnabled() )
            paintValueTracker( ctx, vt, lineInfo.value );
    }
    if( points.count() )
        paintPolyline( ctx, curBrush, curPen, points );
    // paint all data value texts and the point markers
    paintDataValueTextsAndMarkers( diagram(), ctx, list, true );
}
Example #13
0
void HorizontalPaintingStrategy::drawTabs(const KoRulerPrivate *d, QPainter &painter)
{
    if (! d->showTabs)
        return;
    QPolygonF polygon;

    painter.setBrush(d->ruler->palette().color(QPalette::Text));
    painter.setRenderHint( QPainter::Antialiasing );

    foreach (const KoRuler::Tab & t, d->tabs) {
        qreal x;
        if (d->rightToLeft)
            x = d->viewConverter->documentToViewX(d->activeRangeEnd - t.position)
                    + d->offset;
        else
            x = d->viewConverter->documentToViewX(d->activeRangeStart + t.position)
                    + d->offset;

        polygon.clear();
        switch (t.type) {
        case QTextOption::LeftTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::RightTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::CenterTab:
            polygon << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5);
            painter.drawPolygon(polygon);
            break;
        case QTextOption::DelimiterTab:
            polygon << QPointF(x-5.5, d->ruler->height() - 2.5)
                << QPointF(x+0.5, d->ruler->height() - 8.5)
                << QPointF(x+6.5, d->ruler->height() - 2.5);
            painter.drawPolyline(polygon);
            break;
        default:
            break;
        }
    }
    //painter.setRenderHint( QPainter::Antialiasing, false );
}
Example #14
0
void HorizontalDistancesPaintingStrategy::drawDistanceLine(const KoRulerPrivate *d, QPainter &painter, const qreal start, const qreal end)
{

    // Don't draw too short lines
    if (qMax(start, end) - qMin(start, end) < 1)
        return;

    painter.save();
    painter.translate(d->offset, d->ruler->height() / 2);
    painter.setPen(d->ruler->palette().color(QPalette::Text));
    painter.setBrush(d->ruler->palette().color(QPalette::Text));

    QLineF line(QPointF(d->viewConverter->documentToViewX(start), 0),
            QPointF(d->viewConverter->documentToViewX(end), 0));
    QPointF midPoint = line.pointAt(0.5);

    // Draw the label text
    QFont font = KGlobalSettings::smallestReadableFont();
    font.setPointSize(6);
    QFontMetrics fontMetrics(font);
    QString label = d->unit.toUserStringValue(
            d->viewConverter->viewToDocumentX(line.length())) + ' ' + KUnit::unitName(d->unit);
    QPointF labelPosition = QPointF(midPoint.x() - fontMetrics.width(label)/2,
            midPoint.y() + fontMetrics.ascent()/2);
    painter.setFont(font);
    painter.drawText(labelPosition, label);

    // Draw the arrow lines
    qreal arrowLength = (line.length() - fontMetrics.width(label)) / 2 - 2;
    arrowLength = qMax(qreal(0.0), arrowLength);
    QLineF startArrow(line.p1(), line.pointAt(arrowLength / line.length()));
    QLineF endArrow(line.p2(), line.pointAt(1.0 - arrowLength / line.length()));
    painter.drawLine(startArrow);
    painter.drawLine(endArrow);

    // Draw the arrow heads
    QPolygonF arrowHead;
    arrowHead << line.p1() << QPointF(line.x1()+3, line.y1()-3)
        << QPointF(line.x1()+3, line.y1()+3);
    painter.drawPolygon(arrowHead);
    arrowHead.clear();
    arrowHead << line.p2() << QPointF(line.x2()-3, line.y2()-3)
        << QPointF(line.x2()-3, line.y2()+3);
    painter.drawPolygon(arrowHead);

    painter.restore();
}
Example #15
0
void HorizontalPaintingStrategy::drawIndents(const KoRulerPrivate *d, QPainter &painter)
{
    QPolygonF polygon;

    painter.setBrush(d->ruler->palette().brush(QPalette::Base));
    painter.setRenderHint( QPainter::Antialiasing );

    qreal x;
    // Draw first line start indent
    if (d->rightToLeft)
        x = d->effectiveActiveRangeEnd() - d->firstLineIndent - d->paragraphIndent;
    else
        x = d->effectiveActiveRangeStart() + d->firstLineIndent + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    polygon << QPointF(x+6.5, 0.5)
        << QPointF(x+0.5, 8.5)
        << QPointF(x-5.5, 0.5)
        << QPointF(x+5.5, 0.5);
    painter.drawPolygon(polygon);

    // draw the hanging indent.
    if (d->rightToLeft)
        x = d->effectiveActiveRangeStart() + d->endIndent;
    else
        x = d->effectiveActiveRangeStart() + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    const int bottom = d->ruler->height();
    polygon.clear();
    polygon << QPointF(x+6.5, bottom - 0.5)
        << QPointF(x+0.5, bottom - 8.5)
        << QPointF(x-5.5, bottom - 0.5)
        << QPointF(x+5.5, bottom - 0.5);
    painter.drawPolygon(polygon);

    // Draw end-indent or paragraph indent if mode is rightToLeft
    qreal diff;
    if (d->rightToLeft)
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
                     - d->paragraphIndent) + d->offset - x;
    else
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() - d->endIndent)
                + d->offset - x;
    polygon.translate(diff, 0);
    painter.drawPolygon(polygon);
}
Example #16
0
void Viewport::drawAxesFg(QPainter *painter)
{

	SharedDataLock ctxlock(ctx->mutex);

	if (selection < 0 || selection >= (int)(*ctx)->dimensionality)
		return;

	QPen pen;
	pen.setWidth(0); // hairline width, needed because of our projection
	pen.setColor(active ? Qt::red : Qt::gray); // draw selection in foreground
	painter->setPen(pen);

	qreal top = ((*ctx)->nbins);
	if (illuminant_show && !illuminantCurve.empty())
		top *= illuminantCurve.at(selection);
	painter->drawLine(QPointF(selection, 0.), QPointF(selection, top));

	// draw limiters
	if (limiterMode) {
		pen.setColor(Qt::red);
		painter->setPen(pen);
		for (size_t i = 0; i < (*ctx)->dimensionality; ++i) {
			qreal y1 = limiters[i].first, y2 = limiters[i].second + 1;
			if (!illuminantAppl.empty()) {
				y1 *= illuminantAppl.at(i);
				y2 *= illuminantAppl.at(i);
			}
			qreal h = (*ctx)->nbins*0.01;
			if (h > y2 - y1)	// don't let them overlap, looks uncool
				h = y2 - y1;
			QPolygonF polygon;
			polygon << QPointF(i - 0.25, y1 + h)
			        << QPointF(i - 0.25, y1)
			        << QPointF(i + 0.25, y1)
			        << QPointF(i + 0.25, y1 + h);
			painter->drawPolyline(polygon);
			polygon.clear();
			polygon << QPointF(i - 0.25, y2 - h)
			        << QPointF(i - 0.25, y2)
			        << QPointF(i + 0.25, y2)
			        << QPointF(i + 0.25, y2 - h);
			painter->drawPolyline(polygon);
		}
	}
}
Example #17
0
void get_part_polygon(const PartBBox &part_bbox, QPolygonF &polygon)
{
  polygon.clear();

  boost_math::double_vector t(2);
  t = part_bbox.part_x_axis*part_bbox.min_proj_x + part_bbox.part_y_axis*part_bbox.min_proj_y + part_bbox.part_pos;
  polygon.push_back(QPointF(t(0), t(1)));
    
  t = part_bbox.part_x_axis*part_bbox.max_proj_x + part_bbox.part_y_axis*part_bbox.min_proj_y + part_bbox.part_pos;
  polygon.push_back(QPointF(t(0), t(1)));

  t = part_bbox.part_x_axis*part_bbox.max_proj_x + part_bbox.part_y_axis*part_bbox.max_proj_y + part_bbox.part_pos;
  polygon.push_back(QPointF(t(0), t(1)));

  t = part_bbox.part_x_axis*part_bbox.min_proj_x + part_bbox.part_y_axis*part_bbox.max_proj_y + part_bbox.part_pos;
  polygon.push_back(QPointF(t(0), t(1)));
}
Example #18
0
QPolygonF caGraphics::getHead( QPointF p1, QPointF p2 ) {
    qreal Pi = 3.14;
    QPolygonF arrowHead;
    QLineF m_line = QLineF( p1, p2 );
    double angle = ::acos( m_line.dx() / m_line.length() );

    if ( m_line.dy() >= 0 )  angle = ( Pi * 2 ) - angle;

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

    arrowHead.clear();
    arrowHead << m_line.p1() << arrowP1 << arrowP2 << m_line.p1();
    return arrowHead;
}
Example #19
0
void BaseObjectView::configureProtectedIcon(void)
{
	if(protected_icon)
	{
		QGraphicsPolygonItem *pol_item=nullptr;
		QPolygonF pol;
		float factor;

		//Calculates the factor used to resize the protection icon accordding the font size
		factor=font_config[ParsersAttributes::GLOBAL].font().pointSizeF()/DEFAULT_FONT_SIZE;

		pol.append(QPointF(2,5)); pol.append(QPointF(2,2));
		pol.append(QPointF(3,1)); pol.append(QPointF(4,0));
		pol.append(QPointF(7,0)); pol.append(QPointF(8,1));
		pol.append(QPointF(9,2)); pol.append(QPointF(9,5));
		pol.append(QPointF(7,5)); pol.append(QPointF(7,3));
		pol.append(QPointF(6,2)); pol.append(QPointF(5,2));
		pol.append(QPointF(4,3)); pol.append(QPointF(4,5));

		if(factor!=1.0f)
			this->resizePolygon(pol, pol.boundingRect().width() * factor,
													pol.boundingRect().height() * factor);

		pol_item=dynamic_cast<QGraphicsPolygonItem *>(protected_icon->childItems().at(0));
		pol_item->setPolygon(pol);
		pol_item->setBrush(this->getFillStyle(ParsersAttributes::LOCKER_ARC));
		pol_item->setPen(this->getBorderStyle(ParsersAttributes::LOCKER_ARC));

		pol.clear();
		pol.append(QPointF(1,5));  pol.append(QPointF(10,5));
		pol.append(QPointF(11,6)); pol.append(QPointF(11,9));
		pol.append(QPointF(10,10)); pol.append(QPointF(1,10));
		pol.append(QPointF(0,9)); pol.append(QPointF(0,6));

		if(factor!=1.0f)
			this->resizePolygon(pol, pol.boundingRect().width() * factor,
													pol.boundingRect().height() * factor);

		pol_item=dynamic_cast<QGraphicsPolygonItem *>(protected_icon->childItems().at(1));
		pol_item->setPolygon(pol);
		pol_item->setBrush(this->getFillStyle(ParsersAttributes::LOCKER_BODY));
		pol_item->setPen(this->getBorderStyle(ParsersAttributes::LOCKER_BODY));
	}
}
QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const
{
    QPainterPath result;
    QPolygonF polygon;
    TInt glyphIndex = glyph;
    TInt pointNumber = 0;
    TInt x, y;
    while (m_shapingExtension->GlyphPointInFontUnits(glyphIndex, pointNumber++, x, y)) {
        const QPointF point(qreal(x) / 0xffff, qreal(y) / 0xffff);
        if (polygon.contains(point)) {
            result.addPolygon(polygon);
            result.closeSubpath();
            polygon.clear();
        } else {
            polygon.append(point);
        }
    }
    return result;
}
Example #21
0
QPolygonF GraphicalRobotElement::calculateArrowHeadPosition (QLineF aLine) {
	int arrowSize = 10;
	QPolygonF polyF;
	QLineF Line;
	Line.setP1 (aLine.p2() );
	Line.setP2 (aLine.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);
	polyF.clear();
	polyF << Line.p1() << arrowP1 << arrowP2;
	return polyF;
}
Example #22
0
static PyObject *meth_QPolygonF_clear(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QPolygonF *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QPolygonF, &sipCpp))
        {
            sipCpp->clear();

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QPolygonF, sipName_clear, doc_QPolygonF_clear);

    return NULL;
}
Example #23
0
void EFX::preview(QPolygonF &polygon, Function::Direction direction, int startOffset) const
{
    int stepCount = 128;
    int step = 0;
    float stepSize = (float)(1) / ((float)(stepCount) / (M_PI * 2.0));

    float i = 0;
    float x = 0;
    float y = 0;

    /* Reset the polygon to fill it with new values */
    polygon.clear();

    /* Draw a preview of the effect */
    for (step = 0; step < stepCount; step++)
    {
        calculatePoint(direction, startOffset, i, &x, &y);
        polygon << QPointF(x, y);
        i += stepSize;
    }
}
Example #24
0
//! Internal, used by the Outline style.
void QwtPlotHistogram::flushPolygon( QPainter *painter,
    double baseLine, QPolygonF &polygon ) const
{
    if ( polygon.size() == 0 )
        return;

    if ( orientation() == Qt::Horizontal )
        polygon += QPointF( baseLine, polygon.last().y() );
    else
        polygon += QPointF( polygon.last().x(), baseLine );

    if ( d_data->brush.style() != Qt::NoBrush )
    {
        painter->setPen( Qt::NoPen );
        painter->setBrush( d_data->brush );

        if ( orientation() == Qt::Horizontal )
        {
            polygon += QPointF( polygon.last().x(), baseLine );
            polygon += QPointF( polygon.first().x(), baseLine );
        }
        else
        {
            polygon += QPointF( baseLine, polygon.last().y() );
            polygon += QPointF( baseLine, polygon.first().y() );
        }
        QwtPainter::drawPolygon( painter, polygon );
	int resize = polygon.size();
	if ( resize > 1 )
	    resize -= 2;
        polygon.resize( resize );
    }
    if ( d_data->pen.style() != Qt::NoPen )
    {
        painter->setBrush( Qt::NoBrush );
        painter->setPen( d_data->pen );
        QwtPainter::drawPolyline( painter, polygon );
    }
    polygon.clear();
}
Example #25
0
void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
	//AbstractProfilePolygonItem::modelDataChanged();
	if (!shouldCalculateStuff(topLeft, bottomRight))
		return;

	plot_data *entry = dataModel->data().entry;
	QPolygonF poly;
	QPolygonF alertpoly;
	alertPolygons.clear();
	QSettings s;
	s.beginGroup("TecDetails");
	double threshould = s.value(threshouldKey).toDouble();
	bool inAlertFragment = false;
	for (int i = 0; i < dataModel->rowCount(); i++, entry++) {
		double value = dataModel->index(i, vDataColumn).data().toDouble();
		int time = dataModel->index(i, hDataColumn).data().toInt();
		QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
		poly.push_back(point);
		if (value >= threshould) {
			if (inAlertFragment) {
				alertPolygons.back().push_back(point);
			} else {
				alertpoly.clear();
				alertpoly.push_back(point);
				alertPolygons.append(alertpoly);
				inAlertFragment = true;
			}
		} else {
			inAlertFragment = false;
		}
	}
	setPolygon(poly);
	/*
	createPPLegend(trUtf8("pN" UTF8_SUBSCRIPT_2),getColor(PN2), legendPos);
	*/
}
Example #26
0
void GraphDraw::drawStaticParEq()
{
    QList< QList<Point> > *list;
    QPolygonF polygon;
    Point point;
    ColorSaver *colorSaver;

    pen.setWidth(graphSettings.curvesThickness);
    painter.setRenderHint(QPainter::Antialiasing, graphSettings.smoothing && !moving);
    painter.setPen(pen);

    for(int i = 0; i < parEqs->size(); i++)
    {
        if(!parEqs->at(i)->getDrawState() || parEqs->at(i)->isAnimated())
            continue;

        list = parEqs->at(i)->getPointsList();
        colorSaver = parEqs->at(i)->getColorSaver();

        for(int curve = 0; curve < list->size(); curve++)
        {
            pen.setColor(colorSaver->getColor(curve));
            painter.setPen(pen);

            polygon.clear();

            for(int pos = 0 ; pos < list->at(curve).size(); pos ++)
            {
                point = list->at(curve).at(pos);
                polygon << QPointF(point.x * uniteX, - point.y * uniteY);
            }

            painter.drawPolyline(polygon);
        }
    }
}
Example #27
0
/*!
  \brief Draw lines

  If the CurveAttribute Fitted is enabled a QwtCurveFitter tries
  to interpolate/smooth the curve, before it is painted.

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rectangle of the canvas
  \param from index of the first point to be painted
  \param to index of the last point to be painted

  \sa setCurveAttribute(), setCurveFitter(), draw(),
      drawLines(), drawDots(), drawSteps(), drawSticks()
*/
void QwtPlotCurve::drawLines( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    if ( from > to )
        return;

    const bool doAlign = QwtPainter::roundingAlignment( painter );
    const bool doFit = ( d_data->attributes & Fitted ) && d_data->curveFitter;
    const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
            && ( d_data->brush.color().alpha() > 0 );

    QRectF clipRect;
    if ( d_data->paintAttributes & ClipPolygons )
    {
        qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
        clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
    }

    bool doIntegers = false;

#if QT_VERSION < 0x040800

    // For Qt <= 4.7 the raster paint engine is significantly faster
    // for rendering QPolygon than for QPolygonF. So let's
    // see if we can use it.

    if ( painter->paintEngine()->type() == QPaintEngine::Raster )
    {
        // In case of filling or fitting performance doesn't count
        // because both operations are much more expensive
        // then drawing the polyline itself

        if ( !doFit && !doFill )
            doIntegers = true; 
    }
#endif

    const bool noDuplicates = d_data->paintAttributes & FilterPoints;

    QwtPointMapper mapper;
    mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
    mapper.setFlag( QwtPointMapper::WeedOutPoints, noDuplicates );
    mapper.setBoundingRect( canvasRect );

    if ( doIntegers )
    {
        QPolygon polyline = mapper.toPolygon( 
            xMap, yMap, data(), from, to );

        if ( d_data->paintAttributes & ClipPolygons )
        {
            polyline = QwtClipper::clipPolygon( 
                clipRect.toAlignedRect(), polyline, false );
        }

        QwtPainter::drawPolyline( painter, polyline );
    }
    else
    {
        QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );

        if ( doFit )
            polyline = d_data->curveFitter->fitCurve( polyline );

        if ( doFill )
        {
            if ( painter->pen().style() != Qt::NoPen )
            {
                // here we are wasting memory for the filled copy,
                // do polygon clipping twice etc .. TODO

                QPolygonF filled = polyline;
                fillCurve( painter, xMap, yMap, canvasRect, filled );
                filled.clear();

                if ( d_data->paintAttributes & ClipPolygons )
                {
                    polyline = QwtClipper::clipPolygonF( 
                        clipRect, polyline, false );
                }

                QwtPainter::drawPolyline( painter, polyline );
            }
            else
            {
                fillCurve( painter, xMap, yMap, canvasRect, polyline );
            }
        }
        else
        {
            if ( d_data->paintAttributes & ClipPolygons )
            {
                polyline = QwtClipper::clipPolygonF(
                    clipRect, polyline, false );
            }

            QwtPainter::drawPolyline( painter, polyline );
        }
    }
}
Example #28
0
void
Storage::drawArrows(
    QPainter *aPainter,
    QPen *aPen
) const
{
    if (0 == _arrow_list)
    {
        return;
        /* NOTREACHED */
    }

    Qt::PenStyle penStyle;
    int width = 2;
    /* рисуем все эллипсы */
    for (int i = 0; i < _arrow_list->size(); i++) {
        penStyle = Qt::SolidLine;
        int labelID = _arrow_list->operator [](i).getEvidenceID();

        /* настраиваем цвет для лкйбла к которому относится выделенная область */
//        if (labelID < list_label_color_->count())
//            aPen->setColor(QColor(list_label_color_->at(labelID)));
//        /* в случае если нет цвета для текущего лейбла */
//        else
//            aPen->setColor(QColor(Qt::white));
        aPen->setColor(QColor(_arrow_list->operator [](i).getColor()));

        /* меняем стиль линии и толщину если текущая область выбрана(для изменения) */
//        if (ArrowFigure == focused_selection_type_ &&
//            focused_selection_ == i) {
//            penStyle = Qt::DotLine;
//            width = 3;
//        }

        /* масштабируем */
        QLineF _line = _arrow_list->operator [](i).getCoordinates();
        QPointF p1 = _line.p1() * scale_;
        QPointF p2 = _line.p2() * scale_;

        _line.setP1(p1);
        _line.setP2(p2);
//        if (focused_selection_ == i &&
//            focused_selection_type_ == ArrowFigure) {
//            QPen circPen;
//            circPen.setWidth(2);
//            circPen.setStyle(Qt::SolidLine);
//            circPen.setColor(aPen->color());
//            aPainter->setPen(circPen);
//            for (int j = 0; j < 2; j++) {
//                QPointF point;
//                /* по номеру точки записаннму при кликах получаем вершины прямоугольника */
//                if (!j) {
//                    point = line.p1();
//                }
//                else if (1 == j)
//                {
//                    point = line.p2();
//                }
//                /* если точка неподтвержденная(меняем область) то делаем ее стиллистически заметной */
//                if (i == hovered_point_.figureID &&
//                    j == hovered_point_.pointID &&
//                    ArrowFigure == hovered_point_.figure) {
//                    QBrush brush;
//                    brush.setColor(aPen->color());
//                    brush.setStyle(Qt::SolidPattern);
//                    aPainter->setBrush(brush);
//                }
//                aPainter->drawEllipse(point, point_radius_, point_radius_);
//                aPainter->setBrush(Qt::NoBrush);
//            }
//        }
//        if(set_label_width_)
//        {
//            qDebug() <<list_width_->size();
//            for(int j=0; j<list_width_->size();++j)
//            {
//                if(list_width_->at(j).label_ID_== labelID)
//                {
//                    width = list_width_->at(j).new_width_;
//                }
//            }
//        }

        aPen->setWidth(width);
        aPen->setStyle(penStyle);
//        if(!view_labels_)
//        {
//            qDebug() << "лейблы не видны?";
//            aPen->setStyle(Qt::NoPen);
//        }
////        qDebug() << view_current_l_;
//        if(view_current_l_)
//        {
//            if(labelID!= *label_ID_)
//            {
//                qDebug() << "лейблы не видны?";
//                aPen->setStyle(Qt::NoPen);
//            }
//            qDebug() << "ok?";
//        }
//        qDebug() << *label_ID_;
        aPainter->setPen(*aPen);

//        aPainter->drawEllipse(line);
        ///222

        double angle = ::acos(_line.dx() / _line.length());
        qreal Pi = atan(1)*4;
        if (_line.dy() >= 0)
            angle = (Pi * 2) - angle;

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

        QPolygonF arrowTop;
        arrowTop.clear();
        arrowTop << _line.p1() << arrowP1 << arrowP2;

        aPainter->drawLine(_line);
        qDebug() << "arrow_top_" << arrow_top_;
        aPainter->drawPolygon(arrowTop);

        /*подписываем ID*/
        QString labelIDText =
            QString("%1").arg(labelID);

        aPainter->drawText(
            _line.p2().x() + 5,
            _line.p2().y() + 5,
            20,
            20,
            Qt::AlignLeft,
            labelIDText
            );
    }

}
Example #29
0
void Storage::paintEvent(QPaintEvent *anEvent)
{
    QLabel::paintEvent(anEvent);

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    //painter.setRenderHint(QPainter::SmoothPixmapTransform);
    QPen pen;

    if (NoTool != tool_) {
        pen.setWidth(5);
        pen.setColor(QColor(Qt::white));
        pen.setStyle(Qt::DashLine);
        painter.setPen(pen);

        if (BoundingBoxTool == tool_) {
            /* с учётом масштаба */
            QRect bbox = rect.getCoordinates();
            QPoint bboxTopLeft = bbox.topLeft() * scale_;
            QPoint bboxBottomRight = bbox.bottomRight() * scale_;

            bbox.setTopLeft(bboxTopLeft);
            bbox.setBottomRight(bboxBottomRight);

            painter.drawRect(bbox);
        }
        else if (EllipseTool == tool_) {
            /* с учётом масштаба */
            QRect elli = ell.getCoordinates().normalized();
            QPoint ellTopLeft = elli.topLeft() * scale_;
            QPoint ellBottomRight = elli.bottomRight() * scale_;

            elli.setTopLeft(ellTopLeft);
            elli.setBottomRight(ellBottomRight);

            if(1 < elli.height() && 1 < elli.width() )
            {
                painter.drawEllipse(elli);
            }
//            painter.drawRect(ell);
        }
        else if (ArrowTool == tool_) {
            /* с учётом масштаба */
            QLineF line = arrow.getCoordinates();
            QPointF p1 = line.p1() * scale_;
            QPointF p2 = line.p2() * scale_;

            line.setP1(p1);
            line.setP2(p2);

            if(1 < line.length())
            {
                double angle = ::acos(line.dx() / line.length());
                qreal Pi = atan(1)*4;
                if (line.dy() >= 0)
                    angle = (Pi * 2) - angle;

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

                QPolygonF arrowTop;
                arrowTop.clear();
                arrowTop << line.p1() << arrowP1 << arrowP2;

                painter.drawLine(line);
                painter.drawPolygon(arrowTop);///111
                qDebug() << "arrowTop" << arrowTop;
                arrow_top_ = arrowTop;
            }

            }
        else if (PolygonTool == tool_) {
            /* с учётом масштаба */
            QPoint point;
            QPolygon pol = poly.getCoordinates();
            for (int i = 0; i < pol.size(); i++) {
                point.setX(pol.at(i).x());
                point.setY(pol.at(i).y());
                point *= scale_;
                pol.remove(i);
                pol.insert(i, point);
            }
            painter.drawPolygon(pol);
        }
    }

    /* рисуем фигуры */
    drawBoundingBoxes(&painter, &pen);
    drawPolygons(&painter, &pen);
    drawEllipses(&painter, &pen);
    drawArrows(&painter, &pen);
}
Example #30
0
void GraphicalView::configureObject(void)
{
	View *view=dynamic_cast<View *>(this->getSourceObject());
	QPolygonF pol;
	int i, count, count1=0;
	Reference ref;
	QPen pen;
	TableObjectView *graph_ref=nullptr;
	QList<QGraphicsItem *> subitems;
	vector<TableObject *> tab_objs;
	QGraphicsItemGroup *groups[]={ columns, ext_attribs };
	QGraphicsPolygonItem *bodies[]={ body, ext_attribs_body };
  QString attribs[]={ ParsersAttributes::VIEW_BODY, ParsersAttributes::VIEW_EXT_BODY },
          tag_attribs[]={ ParsersAttributes::TABLE_BODY, ParsersAttributes::TABLE_EXT_BODY };
	float width, type_width=0, px=0;
	TableObjectView *col_item=nullptr;
	QList<TableObjectView *> col_items;
	TableObject *tab_obj=nullptr;
  Tag *tag=view->getTag();

	//Configures the view's title
	title->configureObject(view);

	//Gets the reference count on SELECT part of the SQL definition
	count=view->getReferenceCount(Reference::SQL_REFER_SELECT);

	if(count==0)
		count=count1=view->getReferenceCount(Reference::SQL_VIEW_DEFINITION);

	//Moves the references group to the origin to be moved latter
	columns->moveBy(-columns->scenePos().x(),
										 -columns->scenePos().y());

	subitems=columns->childItems();

	for(i=0; i < count; i++)
	{
		if(count1==0)
			ref=view->getReference(i, Reference::SQL_REFER_SELECT);
		else
			ref=view->getReference(i, Reference::SQL_VIEW_DEFINITION);

		//Reuses the subitem if it was allocated before
		if(!subitems.isEmpty() && i < subitems.size())
		{
			graph_ref=dynamic_cast<TableObjectView *>(subitems[i]);

			//Moves the reference to the origin to be moved latter
			graph_ref->moveBy(-graph_ref->scenePos().x(),
												-graph_ref->scenePos().y());
		}
		else
			graph_ref=new TableObjectView;

		columns->removeFromGroup(graph_ref);
		graph_ref->configureObject(ref);
		graph_ref->moveBy(HORIZ_SPACING, (i * graph_ref->boundingRect().height()) + VERT_SPACING);
		columns->addToGroup(graph_ref);
	}

	//Destroy the graphical references not used
	i=subitems.size()-1;
	while(i > count-1)
	{
		graph_ref=dynamic_cast<TableObjectView *>(subitems[i]);
		columns->removeFromGroup(graph_ref);
		delete(graph_ref);
		i--;
	}

	tab_objs.assign(view->getObjectList(OBJ_RULE)->begin(),
									view->getObjectList(OBJ_RULE)->end());
	tab_objs.insert(tab_objs.end(),
									view->getObjectList(OBJ_TRIGGER)->begin(),
									view->getObjectList(OBJ_TRIGGER)->end());

	ext_attribs->setVisible(!tab_objs.empty() && !hide_ext_attribs);
	ext_attribs_body->setVisible(!tab_objs.empty() && !hide_ext_attribs);

	if(!tab_objs.empty())
	{
		count=tab_objs.size();

		//Gets the subitems of the current group
		subitems=ext_attribs->childItems();
		ext_attribs->moveBy(-ext_attribs->scenePos().x(),
												-ext_attribs->scenePos().y());
		for(i=0; i < count; i++)
		{
			tab_obj=tab_objs.at(i);

			//Reusing the subitem if it was allocated before
			if(!subitems.isEmpty() && i < subitems.size())
			{
				col_item=dynamic_cast<TableObjectView *>(subitems[i]);
				col_item->setSourceObject(tab_obj);
				col_item->configureObject();
				col_item->moveBy(-col_item->scenePos().x(),
												 -col_item->scenePos().y());
			}
			else
				col_item=new TableObjectView(tab_obj);

			//Configures the item and set its position
			col_item->configureObject();
			col_item->moveBy(HORIZ_SPACING, (i * col_item->boundingRect().height()) + VERT_SPACING);

			/* Calculates the width of the name + type of the object. This is used to align all
			the constraint labels on table */
			width=col_item->getChildObject(0)->boundingRect().width() +
						col_item->getChildObject(1)->boundingRect().width() + (3 * HORIZ_SPACING);
			if(px < width)  px=width;

			//Gets the maximum width of the column type label to align all at same horizontal position
			if(type_width < col_item->getChildObject(2)->boundingRect().width())
				type_width=col_item->getChildObject(2)->boundingRect().width() + (3 * HORIZ_SPACING);

			col_items.push_back(col_item);
		}

		//Destroy the unused items
		i=subitems.size()-1;
		while(i > count-1)
		{
			col_item=dynamic_cast<TableObjectView *>(subitems[i]);
			ext_attribs->removeFromGroup(col_item);
			delete(col_item);
			i--;
		}

		//Set all items position
		while(!col_items.isEmpty())
		{
			col_item=dynamic_cast<TableObjectView *>(col_items.front());
			ext_attribs->removeFromGroup(col_item);
			col_items.pop_front();

			//Positioning the type label
			col_item->setChildObjectXPos(2, px);

			//Positioning the constraints label
			col_item->setChildObjectXPos(3, px + type_width);
			ext_attribs->addToGroup(col_item);
		}
	}

	/* Calculating the maximum width between the title, columns and extended attributes.
		This width is used to set the uniform width of table */
	if(!columns->childItems().isEmpty() &&
		 (columns->boundingRect().width() > title->boundingRect().width() &&
			((hide_ext_attribs || (columns->boundingRect().width() > ext_attribs->boundingRect().width())))))
		width=columns->boundingRect().width() + (2 * HORIZ_SPACING);
	else if(!ext_attribs->childItems().isEmpty() &&  !hide_ext_attribs &&
					(ext_attribs->boundingRect().width() > title->boundingRect().width() &&
					 ext_attribs->boundingRect().width() > columns->boundingRect().width()))
		width=ext_attribs->boundingRect().width() + (2 * HORIZ_SPACING);
	else
		width=title->boundingRect().width() + (2 * HORIZ_SPACING);

	//Resizes the title using the new width
	title->resizeTitle(width, title->boundingRect().height());

	pol.clear();
	pol.append(QPointF(0.0f,0.0f));
	pol.append(QPointF(1.0f,0.0f));
	pol.append(QPointF(1.0f,1.0f));
	pol.append(QPointF(0.0f,1.0f));

	//Resizes the columns/extended attributes using the new width
	for(int idx=0; idx < 2; idx++)
	{
		this->resizePolygon(pol, width, groups[idx]->boundingRect().height() + (2 * VERT_SPACING));
		bodies[idx]->setPolygon(pol);

    pen=this->getBorderStyle(attribs[idx]);
    pen.setStyle(Qt::DashLine);

    if(!tag)
      bodies[idx]->setBrush(this->getFillStyle(attribs[idx]));
    else
    {
      bodies[idx]->setBrush(tag->getFillStyle(tag_attribs[idx]));
      pen.setColor(tag->getElementColor(tag_attribs[idx], Tag::BORDER_COLOR));
    }

		bodies[idx]->setPen(pen);

		if(idx==0)
			bodies[idx]->setPos(title->pos().x(), title->boundingRect().height()-1);
		else
			bodies[idx]->setPos(title->pos().x(),
													title->boundingRect().height() +
													bodies[0]->boundingRect().height() - 2);
		groups[idx]->setPos(bodies[idx]->pos());

		subitems=groups[idx]->childItems();
		while(!subitems.isEmpty())
		{
			col_item=dynamic_cast<TableObjectView *>(subitems.front());
			subitems.pop_front();
			col_item->setChildObjectXPos(3, width -
																	 col_item->boundingRect().width() - (2 * HORIZ_SPACING) - 1);
		}
	}

	this->bounding_rect.setTopLeft(title->boundingRect().topLeft());
	this->bounding_rect.setWidth(title->boundingRect().width());

	if(!ext_attribs->isVisible())
		this->bounding_rect.setHeight(title->boundingRect().height() +
																	body->boundingRect().height() - 1);
	else
		this->bounding_rect.setHeight(title->boundingRect().height() +
																	body->boundingRect().height() +
																	ext_attribs_body->boundingRect().height() -2);

	//Set the protected icon position to the top-right on the title
	protected_icon->setPos(title->pos().x() + title->boundingRect().width() * 0.90f,
												 2 * VERT_SPACING);

	BaseObjectView::__configureObject();
	BaseObjectView::configureObjectShadow();
	BaseObjectView::configureObjectSelection();

	this->table_tooltip=Utf8String::create(view->getName(true)) +
											" (" + view->getTypeName() + ") \n" +
                      QString("Id: %1\n").arg(view->getObjectId()) +
											TableObjectView::CONSTR_DELIM_START +
											trUtf8("Connected rels: %1").arg(this->getConnectRelsCount()) +
											TableObjectView::CONSTR_DELIM_END;

	this->setToolTip(this->table_tooltip);
  configureTag();
}