Beispiel #1
0
void MapScene::addMark(qreal latitude, qreal longitude, QVariant data)
{
    //NOTE: Need to be refactored for use with marks
    QPixmap pixmap(20,20);
    pixmap.fill(Qt::transparent);
    QPoint center(pixmap.width()/2, pixmap.height()/2);

    QPainter painter;
    painter.begin(&pixmap);
    painter.setBrush(Qt::blue);
    painter.drawEllipse(center, pixmap.width()/2, pixmap.height()/2);
    painter.setBrush(Qt::black);
    painter.drawEllipse(center, pixmap.width()/10, pixmap.height()/10);
    painter.end();

    QGraphicsItem * mark = this->addPixmap(pixmap);
    QPointF mark_point = OSMCoordinatesConverter::GeoToTile(latitude, longitude, this->m_zoom);

    mark_point.setX(mark_point.x()*256.0);
    mark_point.setY(mark_point.y()*256.0);
    mark->setX(mark_point.x());
    mark->setY(mark_point.y());
    mark->setData(0,data);

    this->views()[0]->centerOn(mark_point);
}
double SystemRenderer::drawDirections(const System &system,
                                      const LayoutInfo &layout, double height)
{
    double maxHeight = 0;

    for (const Direction &direction : system.getDirections())
    {
        double localHeight = 0;
        const double x = layout.getPositionX(direction.getPosition());

        for (const DirectionSymbol &symbol : direction.getSymbols())
        {
            QGraphicsItem *item = nullptr;
            switch (symbol.getSymbolType())
            {
                case DirectionSymbol::Coda:
                    item = new SimpleTextItem(QChar(MusicFont::Coda),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::DoubleCoda:
                    item = new SimpleTextItem(QString(2, MusicFont::Coda),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::Segno:
                    item = new SimpleTextItem(QChar(MusicFont::Segno),
                                              myMusicNotationFont);
                    break;
                case DirectionSymbol::SegnoSegno:
                    item = new SimpleTextItem(QString(2, MusicFont::Segno),
                                              myMusicNotationFont);
                    break;
                default:
                    // Display plain text.
                    QFont font = myPlainTextFont;
                    font.setItalic(true);
                    item = new SimpleTextItem(
                        theDirectionText[symbol.getSymbolType()], font);
                    break;
            }

            centerHorizontally(*item, x, x + layout.getPositionSpacing());
            centerSymbolVertically(*item, height + localHeight);
            // Compensate a bit for the alignment of the music notation font.
            if (symbol.getSymbolType() <= DirectionSymbol::SegnoSegno)
                item->setY(item->y() + 4);

            item->setParentItem(myParentSystem);
            localHeight += LayoutInfo::SYSTEM_SYMBOL_SPACING;
        }

        maxHeight = std::max(maxHeight, localHeight);
    }

    return maxHeight;
}