Exemplo n.º 1
0
 void Editor::onMapReady()
 {
   myUi->graphicsView->scene()->setSceneRect(0, 0, myGame->generator()->width(), myGame->generator()->height());
   for (unsigned int i = 0; i < myGame->generator()->regions().size(); i++)
   {
     QPolygonF qring, sqring;
     auto ring = boost::geometry::exterior_ring(myGame->generator()->regions()[i].poly);
     boost::geometry::convert(ring, qring);
     boost::geometry::simplify(qring, sqring, 1);
     QPen pen;
     pen.setColor(QColor(0,0,0));
     pen.setStyle(Qt::PenStyle::DashLine);
     QBrush brush;
     brush.setStyle(Qt::BrushStyle::SolidPattern);
     std::string colour = myGame->biomes()[myGame->generator()->regions()[i].biome]->jsonValue["mapColour"].asString();
     pen.setColor(QColor(colour.c_str()));
     brush.setColor(QColor(colour.c_str()));
     QGraphicsPolygonItem * pi = new RegionPolygonItem(this);
     pi->setPen(pen);
     pi->setBrush(brush);
     pi->setPolygon(sqring);
     QPolygonF convex;
     boost::geometry::convex_hull(sqring, convex);
     double area = boost::geometry::area(convex);
     pi->setZValue(-area);
     pi->setData(0, i);
     pi->setFlag(QGraphicsItem::GraphicsItemFlag::ItemIsFocusable, true);
     pi->setFlag(QGraphicsItem::GraphicsItemFlag::ItemIsSelectable, true);
     myUi->graphicsView->scene()->addItem(pi);
   }
 }
Exemplo n.º 2
0
void Dialog::setMap(QPolygonF *poly)
{
    QPen pen(Qt::green);
    pen.setWidth(0);
    QGraphicsPolygonItem* item = new QGraphicsPolygonItem(*poly);
    item->setPen(pen);
    item->setBrush(QBrush(Qt::darkGreen)); //, Qt::BDiagPattern)
    item->setZValue(-1);
    QMatrix m;
    m.scale(1, -1);
//    m.translate(60, -90);
    item->setMatrix(m);
//    QRectF bounds = item->sceneBoundingRect();
    QRectF bounds = item->boundingRect();
//    qDebug() << "Bounds: " << bounds;
//    qDebug() << "Bounds center: " << bounds.center();
    qreal viewHeight = myView->viewport()->rect().height();
    qreal sceneHeight = bounds.height();
    qreal ratio = 460 / sceneHeight;  //FIXME: Get actual height instead
//    qDebug() << "View/Scene ratio: " << ratio << " hv:" << viewHeight << " hs: " << sceneHeight;
    myView->setProperty("scale", ratio / 1.5);
    myView->centerItems(bounds.center());
    myView->setSceneRect(QRect(0, 0, 1, 1));  //To synchronize model and view center
    myView->addMap(poly);
//    myView->addItem(item);
//    polyItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache);  //Boost?
}
void ShapeFormulaNode::AddPolygon(QVector<QPointF>& points, QColor& color)
{
	QGraphicsPolygonItem* i = new QGraphicsPolygonItem(points, item);
	i->setBrush(QBrush(color));
	((QGraphicsItemGroup*)item)->addToGroup(i);
	item->update();
}
void MainWindow::slotAddPolygonItem()   //在场景中加入一个多边形图元
{
    QVector<QPoint> v;
    v<<QPoint(30,-15)<<QPoint(0,-30)<<QPoint(-30,-15)<<QPoint(-30,15)<<QPoint(0,30)<<QPoint(30,15);
    QGraphicsPolygonItem *item = new QGraphicsPolygonItem(QPolygonF(v));
    item->setBrush(QColor(qrand()%256,qrand()%256,qrand()%256));
    item->setFlag(QGraphicsItem::ItemIsMovable);

    scene->addItem(item);
    item->setPos((qrand()%int(scene->sceneRect().width()))-200,(qrand()%int(scene->sceneRect().height()))-200);
}
Exemplo n.º 5
0
void NodeBackDropPrivate::setColorInternal(const QColor& color)
{
    _publicInterface->setBrush(color);
    
    if (isSelected) {
        float r,g,b;
        appPTR->getCurrentSettings()->getDefaultSelectedNodeColor(&r, &g, &b);
        QColor selCol;
        selCol.setRgbF(r, g, b);
        header->setBrush(selCol);
        resizeHandle->setBrush(selCol);
    } else {
        QColor brightenColor;
        brightenColor.setRgbF(Natron::clamp(color.redF() * 1.2),
                              Natron::clamp(color.greenF() * 1.2),
                              Natron::clamp(color.blueF() * 1.2));
        header->setBrush(brightenColor);
        resizeHandle->setBrush(brightenColor);
    }
}
Exemplo n.º 6
0
void PlayerIndicator::unhighlight(){
    if(highlightedPlayer == -1 || highlightedPlayer >= (int)playerList.size()){
        return;
    }
    Player* targetPlayer = playerList.at(highlightedPlayer);
    QGraphicsPolygonItem* polyItem = playerTriangles.at(highlightedPlayer);
    polyItem->setScale(1);
    QBrush brush(QColor(targetPlayer->playerColorSet->getFillColor()));
    polyItem->setBrush(brush);
    highlightedPlayer = -1;
}
Exemplo n.º 7
0
void KMapScene::updateObstacles() {

	QGraphicsPolygonItem *cell;
	QVector<QPoint> curve1(0);
	int colorValue = 0, cellNum = 0;
	int r, s;
	QPen penForBlackLine (Qt::black);
	penForBlackLine.setWidth (2);
	for (r = 0; r < cellsOfRadius; r++) {
		for (s = 0; s < cellsOfRing; s++) {
			int sPlusOne = s==cellsOfRing-1 ? 0 : s+1;
			QPoint x0 ( gridImgH[r][s], gridImgV[r][s]);
			QPoint x1 ( gridImgH[r+1][s], gridImgV[r+1][s]);
			QPoint x2 ( gridImgH[r+1][sPlusOne], gridImgV[r+1][sPlusOne]);
			QPoint x3 ( gridImgH[r][sPlusOne], gridImgV[r][sPlusOne]);
			
			curve1.clear();
			curve1.append (x0);
			curve1.append (x1);
			curve1.append (x2);
			curve1.append (x3);
			
			cell = cellsList.at (cellNum);
			cell->setPolygon (QPolygon (curve1) );
			cell->setPen(penForBlackLine);
			if(!smallMap){
				colorValue = ColorMax - PolarGrid[r][s] * ColorMax;
				cell->setBrush (QColor (colorValue, colorValue, colorValue) );
			}else{
				colorValue = ColorMax - PolarGrid[r][s] * ColorMax;
				cell->setBrush (QColor (0, 0, colorValue) );
			}

			cellNum++;
		}
	}
			cout << smallMap << endl;
}
Exemplo n.º 8
0
void PlayerIndicator::highlightPlayer(Player* targetPlayer){
    int highlightNext = findPlayer(targetPlayer);
    if(highlightNext != -1){
        if(highlightedPlayer == highlightNext){
            return;
        }
        unhighlight();
        QGraphicsPolygonItem* polyItem = playerTriangles.at(highlightNext);
        polyItem->setScale(SCALE);
        QBrush brush(QColor(targetPlayer->playerColorSet->getHighlightColor()));
        polyItem->setBrush(brush);
        highlightedPlayer = highlightNext;
    }
}
void
rce::gui::RImageMarkerScene::
setPolygonBrushAndPen(quint32 id,
                      const QBrush &brush,
                      const QPen &pen)
{
    auto it = polygonItems_.find(id);
    if(it != polygonItems_.end())
    {
        QGraphicsPolygonItem *polygonItem = it.value();
        polygonItem->setBrush(brush);
        polygonItem->setPen(pen);
    }
}
Exemplo n.º 10
0
void KMapScene::updateObstacles (bool initialization) {
	QGraphicsPolygonItem *cell;
	QVector<QPoint> curve1 (0);
	int colorValue = 0, cellNum = 0;
	int r, s;

	for (r = 0; r < TotalRings ; r++) {
		for (s = 0; s < N; s++) {
			QPoint x0 ( gridImgH[r][s], gridImgV[r][s]);
			QPoint x1 ( gridImgH[ (r+1) ][s], gridImgV[ (r+1) ][s]);
			QPoint x2 ( gridImgH[ (r+1) ][wrapTo (s+1, N) ], gridImgV[ (r+1) ][wrapTo (s+1, N) ]);
			QPoint x3 ( gridImgH[r][wrapTo (s+1, N) ], gridImgV[r][wrapTo (s+1, N) ]);
			curve1.clear();
			curve1.append (x0);
			curve1.append (x1);
			curve1.append (x2);
			curve1.append (x3);
			colorValue = ColorMax - PolarGrid[present][r][s] * ColorMax;

			if (initialization) {
				cell = staticCellsList.at (cellNum);
			} else {
				cell = cellsList.at (cellNum);
			}

			cell->setPolygon (QPolygon (curve1) );

			if (r == InnerRing ) {
				cell->setBrush (QBrush (Qt::white) );
			} else {
				cell->setBrush (QColor (colorValue, colorValue, colorValue) );
			}

			cellNum++;
		}
	}
}
Exemplo n.º 11
0
QGraphicsItem *Sector::render(double radius, double arcWidth) const {
	QPen pen;
	QBrush brush;

	ColorToBrushAndPen(color, pen, brush);

	QPolygonF polygon = createPolygonArc(radius, arcWidth, startAngle, endAngle);

	QGraphicsPolygonItem *polygonItem = new QGraphicsPolygonItem(polygon);
	polygonItem->setFillRule(Qt::OddEvenFill);
	polygonItem->setPen(pen);
	polygonItem->setBrush(brush);

	return polygonItem;
}
Exemplo n.º 12
0
void Main::addPolygon()
{
    const int size = int(canvas.width()/2);
    Q3PointArray pa(6);
    pa[0] = QPoint(0,0);
    pa[1] = QPoint(size,size/5);
    pa[2] = QPoint(size*4/5,size);
    pa[3] = QPoint(size/6,size*5/4);
    pa[4] = QPoint(size*3/4,size*3/4);
    pa[5] = QPoint(size*3/4,size/4);
    QGraphicsPolygonItem* i = canvas.addPolygon(pa);
    i->setFlag(QGraphicsItem::ItemIsMovable);
    i->setPen(Qt::NoPen);
    i->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) );
    i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height()));
    i->setZValue(qrand()%256);
}
void VisualizationWorkstationExtensionPlugin::addSegmentationsToViewer() {
  if (_lst) {
    std::vector<std::shared_ptr<Annotation> > tmp = _lst->getAnnotations();
    float scl = _viewer->getSceneScale();
    for (std::vector<std::shared_ptr<Annotation> >::iterator it = tmp.begin(); it != tmp.end(); ++it) {
      QPolygonF poly;
      std::vector<Point> coords = (*it)->getCoordinates();
      for (std::vector<Point>::iterator pt = coords.begin(); pt != coords.end(); ++pt) {
        poly.append(QPointF(pt->getX()*scl, pt->getY()*scl));
      }
      QGraphicsPolygonItem* cur = new QGraphicsPolygonItem(poly);
      cur->setBrush(QBrush());
      cur->setPen(QPen(QBrush(QColor("red")), 1.));
      _viewer->scene()->addItem(cur);
      cur->setZValue(std::numeric_limits<float>::max());
      _polygons.append(cur);
    }
  }
}
Exemplo n.º 14
0
// draw an arrowhead
QGraphicsPolygonItem* GAction::makeArrowHead(const GVEdge& e, const QColor& color) {

    // arrow pointing to the right
    QPointF p = e.path.pointAtPercent(1);
    QPointF* q = new QPointF(p.x() - 8, p.y() - 5);
    QPointF* r = new QPointF(p.x() - 8, p.y() + 5);
    QPolygonF polygon;
    polygon.push_back(p);
    polygon.push_back(*q);
    polygon.push_back(*r);

    // rotate arrow
    QMatrix matrix;
    matrix.translate(p.x(), p.y());
    matrix.rotate(-e.path.angleAtPercent(1));
    matrix.translate(-p.x(), -p.y());
    polygon = matrix.map(polygon);

    // turn into QGraphicsPolygonItem
    QGraphicsPolygonItem* res = new QGraphicsPolygonItem (polygon, display);
    res->setPen(QPen(color));
    res->setBrush(QBrush(color));
    return res;
}
Exemplo n.º 15
0
void
MatrixElement::reconfigure(timeT time, timeT duration, int pitch, int velocity)
{
    const RulerScale *scale = m_scene->getRulerScale();
    int resolution = m_scene->getYResolution();

    double x0 = scale->getXForTime(time);
    double x1 = scale->getXForTime(time + duration);
    m_width = x1 - x0;

    m_velocity = velocity;

    // if the note has TIED_FORWARD or TIED_BACK properties, draw it with a
    // different fill pattern
    bool tiedNote = (event()->has(BaseProperties::TIED_FORWARD) ||
                     event()->has(BaseProperties::TIED_BACKWARD));
    Qt::BrushStyle brushPattern = (tiedNote ? Qt::Dense2Pattern : Qt::SolidPattern);

    QColor colour;
    if (event()->has(BaseProperties::TRIGGER_SEGMENT_ID)) {
        //!!! Using gray for trigger events and events from other, non-active
        // segments won't work.  This should be handled some other way, with a
        // color outside the range of possible velocity choices, which probably
        // leaves some kind of curious light blue or something
        colour = Qt::cyan;
    } else {
        colour = DefaultVelocityColour::getInstance()->getColour(velocity);
    }
    colour.setAlpha(160);

    double fres(resolution);

    if (m_drum) {
        fres = resolution + 1;
        QGraphicsPolygonItem *item = dynamic_cast<QGraphicsPolygonItem *>(m_item);
        if (!item) {
            delete m_item;
            item = new QGraphicsPolygonItem;
            m_item = item;
            m_scene->addItem(m_item);
        }
        QPolygonF polygon;
        polygon << QPointF(0, 0)
                << QPointF(fres/2, fres/2)
                << QPointF(0, fres)
                << QPointF(-fres/2, fres/2)
                << QPointF(0, 0);
        item->setPolygon(polygon);
        item->setPen
            (QPen(GUIPalette::getColour(GUIPalette::MatrixElementBorder), 0));
        item->setBrush(QBrush(colour, brushPattern));
    } else {
        QGraphicsRectItem *item = dynamic_cast<QGraphicsRectItem *>(m_item);
        if (!item) {
            delete m_item;
            item = new QGraphicsRectItem;
            m_item = item;
            m_scene->addItem(m_item);
        }
        float width = m_width;
        if (width < 1) width = 1;
        QRectF rect(0, 0, width, fres + 1);
        item->setRect(rect);
        item->setPen
            (QPen(GUIPalette::getColour(GUIPalette::MatrixElementBorder), 0));
        item->setBrush(QBrush(colour, brushPattern));
    }

    setLayoutX(x0);

    m_item->setData(MatrixElementData, QVariant::fromValue((void *)this));

    // set the Y position taking m_pitchOffset into account, subtracting the
    // opposite of whatever the originating segment transpose was

//    std::cout << "TRANSPOSITION TEST: event pitch: "
//              << (pitch ) << " m_pitchOffset: " << m_pitchOffset
//              << std::endl;

    m_item->setPos(x0, (127 - pitch - m_pitchOffset) * (resolution + 1));

    // set a tooltip explaining why this event is drawn in a different pattern
    if (tiedNote) m_item->setToolTip(QObject::tr("This event is tied to another event."));
}
Exemplo n.º 16
0
void cbSimulator::showGraph(int id)
{
    unsigned int w,c;
    QGraphicsPolygonItem *wallCanvas;
    QGraphicsRectItem *grCanvas;

	if(id<1 || id > (int)robots.size()) {
		cerr << "Cannot show graph of robot " << id << "\n";
		return;
	}

	labCanvasWidth=(int)(lab->Width()*30);
	labCanvasHeight=(int)(lab->Height()*30);

    labScene=new QGraphicsScene(0, 0, labCanvasWidth,labCanvasHeight);

    labView=new cbGraphView(labScene,this);
    labView->viewport()->setMouseTracking(true);

    QPolygon *pa;

    for(w=1; w<lab->nWalls();w++) {
        vector<cbPoint> &corners=lab->Wall(w)->Corners();
        //pa.resize(corners.size());
        pa = new QPolygon(corners.size());
        for(c=0; c<corners.size();c++)
            pa->setPoint(c,(int)(corners[c].X()*labCanvasWidth/lab->Width()),
                         (int)(labCanvasHeight-corners[c].Y()*labCanvasHeight/lab->Height()) );
        wallCanvas = new QGraphicsPolygonItem(0, labScene);
        wallCanvas->setPolygon(*pa);
        wallCanvas->setBrush(QBrush(Qt::black));
		wallCanvas->setVisible(true);
	}


	unsigned int x,y;
	double distMax=0.0;

	//grAux=graph;  Tentativa de optimizacao
	for(x = 0; x < GRIDSIZE; x++)
	    for(y = 0; y < GRIDSIZE; y++) {
		    *grAux=*graph;

		    //grAux->resetInitState();  Tentativa de optimizacao - testes indicam que fica muito mais lento!!
		    //grAux->writeGraph();

		    cbPoint p((0.5+x)*lab->Width()/GRIDSIZE, (GRIDSIZE-0.5-y)*lab->Height()/GRIDSIZE);
		    grAux->addFinalPoint(id,p);
		    distGrid[x][y]=grAux->dist(id);
		    if(distGrid[x][y] < 2000 && distGrid[x][y]>distMax)
			    distMax=distGrid[x][y];
	    }

//        fprintf(stderr,"distmax=%f labCanvasWidth=%d labCanvasHeight=%d\n",
//			 distMax,labCanvasWidth,labCanvasHeight);

	for(x = 0; x < GRIDSIZE; x++)
	    for(y = 0; y < GRIDSIZE; y++) {

            if(distGrid[x][y]<2000) {
                grCanvas = new QGraphicsRectItem(x*labCanvasWidth/GRIDSIZE,y*labCanvasHeight/GRIDSIZE,
                                                 (x+1)*labCanvasWidth/GRIDSIZE - x*labCanvasWidth/GRIDSIZE,
                                                 (y+1)*labCanvasHeight/GRIDSIZE -y*labCanvasHeight/GRIDSIZE,
                                                 0, labScene);
                QColor color((int)(0+distGrid[x][y]/distMax*250),
                             (int)(0+distGrid[x][y]/distMax*250),
                             (int)(0+distGrid[x][y]/distMax*250));
                grCanvas->setBrush(QBrush(color));
                grCanvas->setPen(QPen(color));
			    grCanvas->setVisible(true);
			    //debug
			    //distGrid[x][y]=(int)(0+distGrid[x][y]/distMax*250);
		    }

        }
    labScene->update();

}
Exemplo n.º 17
0
void ProfileGraphicsView::plot_depth_profile()
{
    int i, incr;
    int sec, depth;
    struct plot_data *entry;
    int maxtime, maxdepth, marker, maxline;
    int increments[8] = { 10, 20, 30, 60, 5*60, 10*60, 15*60, 30*60 };

    /* Get plot scaling limits */
    maxtime = get_maxtime(&gc.pi);
    maxdepth = get_maxdepth(&gc.pi);

    gc.maxtime = maxtime;

    /* Time markers: at most every 10 seconds, but no more than 12 markers.
     * We start out with 10 seconds and increment up to 30 minutes,
     * depending on the dive time.
     * This allows for 6h dives - enough (I hope) for even the craziest
     * divers - but just in case, for those 8h depth-record-breaking dives,
     * we double the interval if this still doesn't get us to 12 or fewer
     * time markers */
    i = 0;
    while (maxtime / increments[i] > 12 && i < 7)
        i++;
    incr = increments[i];
    while (maxtime / incr > 12)
        incr *= 2;

    gc.leftx = 0;
    gc.rightx = maxtime;
    gc.topy = 0;
    gc.bottomy = 1.0;

    last_gc = gc;

    QColor c = getColor(TIME_GRID);
    for (i = incr; i < maxtime; i += incr) {
        QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(i, 0), SCALEGC(i, 1));
        QPen pen(defaultPen);
        pen.setColor(c);
        item->setPen(pen);
        scene()->addItem(item);
    }

    timeMarkers = new QGraphicsRectItem();
    /* now the text on the time markers */
    struct text_render_options tro = {DEPTH_TEXT_SIZE, TIME_TEXT, CENTER, LINE_DOWN};
    if (maxtime < 600) {
        /* Be a bit more verbose with shorter dives */
        for (i = incr; i < maxtime; i += incr)
            plot_text(&tro, QPointF(i, 0), QString("%1:%2").arg(i/60).arg(i%60, 2, 10, QChar('0')), timeMarkers);
    } else {
        /* Only render the time on every second marker for normal dives */
        for (i = incr; i < maxtime; i += 2 * incr)
            plot_text(&tro, QPointF(i, 0), QString("%1").arg(QString::number(i/60)), timeMarkers);
    }
    timeMarkers->setPos(0,0);
    scene()->addItem(timeMarkers);

    /* Depth markers: every 30 ft or 10 m*/
    gc.leftx = 0;
    gc.rightx = 1.0;
    gc.topy = 0;
    gc.bottomy = maxdepth;
    switch (prefs.units.length) {
    case units::METERS:
        marker = 10000;
        break;
    case units::FEET:
        marker = 9144;
        break;	/* 30 ft */
    }
    maxline = qMax(gc.pi.maxdepth + marker, maxdepth * 2 / 3);

    c = getColor(DEPTH_GRID);

    for (i = marker; i < maxline; i += marker) {
        QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, i), SCALEGC(1, i));
        QPen pen(defaultPen);
        pen.setColor(c);
        item->setPen(pen);
        scene()->addItem(item);
    }

    gc.leftx = 0;
    gc.rightx = maxtime;
    c = getColor(MEAN_DEPTH);

    /* Show mean depth */
    if (! gc.printer) {
        QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, gc.pi.meandepth),
                SCALEGC(gc.pi.entry[gc.pi.nr - 1].sec, gc.pi.meandepth));
        QPen pen(defaultPen);
        pen.setColor(c);
        item->setPen(pen);
        scene()->addItem(item);
    }

#if 0
    /*
     * These are good for debugging text placement etc,
     * but not for actual display..
     */
    if (0) {
        plot_smoothed_profile(gc, pi);
        plot_minmax_profile(gc, pi);
    }
#endif

    /* Do the depth profile for the neat fill */
    gc.topy = 0;
    gc.bottomy = maxdepth;

    entry = gc.pi.entry;

    QPolygonF p;
    QLinearGradient pat(0.0,0.0,0.0,scene()->height());
    QGraphicsPolygonItem *neatFill = NULL;

    p.append(QPointF(SCALEGC(0, 0)));
    for (i = 0; i < gc.pi.nr; i++, entry++)
        p.append(QPointF(SCALEGC(entry->sec, entry->depth)));

    /* Show any ceiling we may have encountered */
    if (prefs.profile_dc_ceiling) {
        for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
            if (!entry->in_deco) {
                /* not in deco implies this is a safety stop, no ceiling */
                p.append(QPointF(SCALEGC(entry->sec, 0)));
            } else if (entry->stopdepth < entry->depth) {
                p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
            } else {
                p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
            }
        }
    }
    pat.setColorAt(1, getColor(DEPTH_BOTTOM));
    pat.setColorAt(0, getColor(DEPTH_TOP));

    neatFill = new QGraphicsPolygonItem();
    neatFill->setPolygon(p);
    neatFill->setBrush(QBrush(pat));
    neatFill->setPen(QPen(QBrush(Qt::transparent),0));
    scene()->addItem(neatFill);


    /* if the user wants the deco ceiling more visible, do that here (this
     * basically draws over the background that we had allowed to shine
     * through so far) */
    if (prefs.profile_dc_ceiling && prefs.profile_red_ceiling) {
        p.clear();
        pat.setColorAt(0, getColor(CEILING_SHALLOW));
        pat.setColorAt(1, getColor(CEILING_DEEP));

        entry = gc.pi.entry;
        p.append(QPointF(SCALEGC(0, 0)));
        for (i = 0; i < gc.pi.nr; i++, entry++) {
            if (entry->in_deco && entry->stopdepth) {
                if (entry->stopdepth < entry->depth) {
                    p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
                } else {
                    p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
                }
            } else {
                p.append(QPointF(SCALEGC(entry->sec, 0)));
            }
        }

        neatFill = new QGraphicsPolygonItem();
        neatFill->setBrush(QBrush(pat));
        neatFill->setPolygon(p);
        neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
        scene()->addItem(neatFill);
    }

    /* finally, plot the calculated ceiling over all this */
    if (prefs.profile_calc_ceiling) {
        pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
        pat.setColorAt(1, getColor(CALC_CEILING_DEEP));

        entry = gc.pi.entry;
        p.clear();
        p.append(QPointF(SCALEGC(0, 0)));
        for (i = 0; i < gc.pi.nr; i++, entry++) {
            if (entry->ceiling)
                p.append(QPointF(SCALEGC(entry->sec, entry->ceiling)));
            else
                p.append(QPointF(SCALEGC(entry->sec, 0)));
        }
        p.append(QPointF(SCALEGC((entry-1)->sec, 0)));
        neatFill = new QGraphicsPolygonItem();
        neatFill->setPolygon(p);
        neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
        neatFill->setBrush(pat);
        scene()->addItem(neatFill);
    }

    /* plot the calculated ceiling for all tissues */
    if (prefs.profile_calc_ceiling && prefs.calc_all_tissues) {
        int k;
        for (k=0; k<16; k++) {
            pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
            pat.setColorAt(1, QColor(100, 100, 100, 50));

            entry = gc.pi.entry;
            p.clear();
            p.append(QPointF(SCALEGC(0, 0)));
            for (i = 0; i < gc.pi.nr; i++, entry++) {
                if ((entry->ceilings)[k])
                    p.append(QPointF(SCALEGC(entry->sec, (entry->ceilings)[k])));
                else
                    p.append(QPointF(SCALEGC(entry->sec, 0)));
            }
            p.append(QPointF(SCALEGC((entry-1)->sec, 0)));
            neatFill = new QGraphicsPolygonItem();
            neatFill->setPolygon(p);
            neatFill->setBrush(pat);
            scene()->addItem(neatFill);
        }
    }
    /* next show where we have been bad and crossed the dc's ceiling */
    if (prefs.profile_dc_ceiling) {
        pat.setColorAt(0, getColor(CEILING_SHALLOW));
        pat.setColorAt(1, getColor(CEILING_DEEP));

        entry = gc.pi.entry;
        p.clear();
        p.append(QPointF(SCALEGC(0, 0)));
        for (i = 0; i < gc.pi.nr; i++, entry++)
            p.append(QPointF(SCALEGC(entry->sec, entry->depth)));

        for (i-- , entry--; i >= 0; i--, entry--) {
            if (entry->in_deco && entry->stopdepth > entry->depth) {
                p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
            } else {
                p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
            }
        }
    }
    neatFill = new QGraphicsPolygonItem();
    neatFill->setPolygon(p);
    neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
    neatFill->setBrush(QBrush(pat));
    scene()->addItem(neatFill);

    /* Now do it again for the velocity colors */
    entry = gc.pi.entry;
    for (i = 1; i < gc.pi.nr; i++) {
        entry++;
        sec = entry->sec;
        /* we want to draw the segments in different colors
         * representing the vertical velocity, so we need to
         * chop this into short segments */
        depth = entry->depth;
        QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(entry[-1].sec, entry[-1].depth), SCALEGC(sec, depth));
        QPen pen(defaultPen);
        pen.setColor(getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + entry->velocity)));
        item->setPen(pen);
        scene()->addItem(item);
    }
}