コード例 #1
0
void CartesianRenderItem::paintRelations(QPainter *painter) {

  QRectF normalRect = rect();
  normalRect = normalRect.normalized();

  painter->save();
  painter->translate(normalRect.x(), normalRect.y());

  foreach (RelationPtr relation, relationList()) {
    //FIXME static_cast to kstvcurve and take advantage of extra api

    CurveRenderContext context;
    context.painter = painter;
    context.window = QRect(); //no idea if this should be floating point
    context.penWidth = painter->pen().width(); //floating point??
    context.xLog = isXAxisLog();
    context.yLog = isYAxisLog();
    context.xLogBase = xLogBase();
    context.yLogBase = yLogBase();
    context.foregroundColor = painter->pen().color();
    context.backgroundColor = painter->brush().color();

    //FIXME rename these methods in kstvcurve
    //FIXME Completely refactor KstCurveRenderContext now that we know what these are

    //Set the projection box...
    context.XMin = projectionRect().left();
    context.XMax = projectionRect().right();
    context.YMin = projectionRect().top();
    context.YMax = projectionRect().bottom();

    //Set the log box...
    context.x_max = isXAxisLog() ? logXHi(context.XMax, context.xLogBase) : context.XMax;
    context.y_max = isYAxisLog() ? logXHi(context.YMax, context.yLogBase) : context.YMax;
    context.x_min = isXAxisLog() ? logXLo(context.XMin, context.xLogBase) : context.XMin;
    context.y_min = isYAxisLog() ? logXLo(context.YMin, context.yLogBase) : context.YMin;

    //These are the bounding box in regular QGV coord
    context.Lx = plotRect().left();
    context.Hx = plotRect().right();
    context.Ly = plotRect().top();
    context.Hy = plotRect().bottom();

    //To convert between the last two...
    double m_X = double(plotRect().width()-1)/(context.x_max - context.x_min);
    double m_Y = -double(plotRect().height()-1)/(context.y_max - context.y_min);
    double b_X = context.Lx - m_X * context.x_min;
    double b_Y = context.Ly - m_Y * context.y_max;

    context.m_X = m_X;
    context.m_Y = m_Y;
    context.b_X = b_X;
    context.b_Y = b_Y;

    relation->paint(context);
  }
コード例 #2
0
    AlbumXmlHandler(MusicBrainzAlbumInfo& albumInfo) : SimpleSaxHandler<AlbumXmlHandler>("metadata"), m_albumInfo(albumInfo), m_bTargetIsUrl(false)
    {
        Node& meta (getRoot()); meta.onEnd = &AlbumXmlHandler::onMetaEnd;
            Node& rel (makeNode(meta, "release")); rel.onStart = &AlbumXmlHandler::onRelStart;
                Node& albTitle (makeNode(rel, "title")); albTitle.onChar = &AlbumXmlHandler::onAlbTitleChar;
                Node& asin (makeNode(rel, "asin")); asin.onChar = &AlbumXmlHandler::onAsinChar;
                Node& albArtist (makeNode(rel, "artist"));
                    Node& albArtistName (makeNode(albArtist, "name")); albArtistName.onChar = &AlbumXmlHandler::onAlbArtistNameChar;
                Node& albRelEvents (makeNode(rel, "release-event-list"));
                    Node& albEvent (makeNode(albRelEvents, "event")); albEvent.onStart = &AlbumXmlHandler::onAlbEventStart;
                Node& albTrackList (makeNode(rel, "track-list"));
                    Node& track (makeNode(albTrackList, "track")); track.onStart = &AlbumXmlHandler::onTrackStart;
                        Node& trackTitle (makeNode(track, "title")); trackTitle.onChar = &AlbumXmlHandler::onTrackTitleChar;
                        Node& trackArtist (makeNode(track, "artist"));
                            Node& trackArtistName (makeNode(trackArtist, "name")); trackArtistName.onChar = &AlbumXmlHandler::onTrackArtistName;
                Node& relationList (makeNode(rel, "relation-list")); relationList.onStart = &AlbumXmlHandler::onRelationListStart;
                    Node& relation (makeNode(relationList, "relation")); relation.onStart = &AlbumXmlHandler::onRelationStart;

        m_albumInfo.m_eVarArtists = AlbumInfo::VA_SINGLE;
    }