⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notepixmapfactory.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        m_p->drawNoteCharacter(m_left + s1.x() - hotspot.x(), y, flagChar);    }}voidNotePixmapFactory::drawStem(const NotePixmapParameters &params,                            const QPoint &s0, const QPoint &s1,                            int shortening){    if (params.m_stemGoesUp)        shortening = -shortening;    for (int i = 0; i < getStemThickness(); ++i) {        m_p->drawLine(m_left + s0.x() + i, m_above + s0.y(),                      m_left + s1.x() + i, m_above + s1.y() - shortening);    }}voidNotePixmapFactory::makeRoomForBeams(const NotePixmapParameters &params){    int beamSpacing = (int)(params.m_width * params.m_gradient);    if (params.m_stemGoesUp) {        beamSpacing = -beamSpacing;        if (beamSpacing < 0)            beamSpacing = 0;        m_above += beamSpacing + 2;        // allow a bit extra in case the h fixpoint is non-normal        m_right = std::max(m_right, params.m_width + m_noteBodyWidth);    } else {        if (beamSpacing < 0)            beamSpacing = 0;        m_below += beamSpacing + 2;        m_right = std::max(m_right, params.m_width);    }}voidNotePixmapFactory::drawShallowLine(int x0, int y0, int x1, int y1,                                   int thickness, bool smooth){    if (!smooth || m_inPrinterMethod || (y0 == y1)) {        if (!m_inPrinterMethod) {            if (m_selected)                m_p->painter().setBrush(GUIPalette::getColour(GUIPalette::SelectedElement));            else                m_p->painter().setBrush(Qt::black);        }        if (thickness < 4) {            for (int i = 0; i < thickness; ++i) {                m_p->drawLine(x0, y0 + i, x1, y1 + i);            }        } else {            Profiler profiler("NotePixmapFactory::drawShallowLine(polygon)");            QPointArray qp(4);            qp.setPoint(0, x0, y0);            qp.setPoint(1, x0, y0 + thickness);            qp.setPoint(2, x1, y1 + thickness);            qp.setPoint(3, x1, y1);            m_p->drawPolygon(qp);        }        return ;    }    Profiler profiler("NotePixmapFactory::drawShallowLine(points)");    int dv = y1 - y0;    int dh = x1 - x0;    static std::vector<QColor> colours, selectedColours;    if (colours.size() == 0) {        int h, s, v;        QColor c = GUIPalette::getColour(GUIPalette::SelectedElement);        c.hsv(&h, &s, &v);        for (int step = 0; step < 256; step += (step == 0 ? 63 : 64)) {            colours.push_back(QColor( -1, 0, step, QColor::Hsv));            selectedColours.push_back(QColor(h, 255 - step, v, QColor::Hsv));        }    }    int cx = x0, cy = y0;    int inc = 1;    if (dv < 0) {        dv = -dv;        inc = -1;    }    int g = 2 * dv - dh;    int dg1 = 2 * (dv - dh);    int dg2 = 2 * dv;    int segment = (dg2 - dg1) / 4;    while (cx < x1) {        if (g > 0) {            g += dg1;            cy += inc;        } else {            g += dg2;        }        int quartile = segment ? ((dg2 - g) / segment) : 0;        if (quartile < 0)            quartile = 0;        if (quartile > 3)            quartile = 3;        if (inc > 0)            quartile = 4 - quartile;        /*                NOTATION_DEBUG                    << "x = " << cx << ", y = " << cy                    << ", g = " << g << ", dg1 = " << dg1 << ", dg2 = " << dg2                    << ", seg = " << segment << ", q = " << quartile << endl;        */         // I don't know enough about Qt to be sure of this, but I        // suspect this may be some of the most inefficient code ever        // written:        int off = 0;        if (m_selected) {            m_p->painter().setPen(selectedColours[quartile]);        } else {            m_p->painter().setPen(colours[quartile]);        }        m_p->drawPoint(cx, cy);        drawBeamsCount ++;        if (thickness > 1) {            if (m_selected) {                m_p->painter().setPen(GUIPalette::getColour(GUIPalette::SelectedElement));            } else {                m_p->painter().setPen(Qt::black);            }        }        while (++off < thickness) {            m_p->drawPoint(cx, cy + off);            drawBeamsCount ++;        }        if (m_selected) {            m_p->painter().setPen(selectedColours[4 - quartile]);        } else {            m_p->painter().setPen(colours[4 - quartile]);        }        m_p->drawPoint(cx, cy + off);        drawBeamsCount ++;        ++cx;    }    m_p->painter().setPen(Qt::black);}voidNotePixmapFactory::drawBeams(const QPoint &s1,                             const NotePixmapParameters &params,                             int beamCount){    clock_t startTime = clock();    // draw beams: first we draw all the beams common to both ends of    // the section, then we draw beams for those that appear at the    // end only    int startY = m_above + s1.y(), startX = m_left + s1.x();    int commonBeamCount = std::min(beamCount, params.m_nextBeamCount);    unsigned int thickness;    (void)m_font->getBeamThickness(thickness);    int width = params.m_width;    double grad = params.m_gradient;    bool smooth = m_font->isSmooth();    int spacing = getLineSpacing();    int sign = (params.m_stemGoesUp ? 1 : -1);    if (!params.m_stemGoesUp)        startY -= thickness;    if (!smooth)        startY -= sign;    else if (grad > -0.01 && grad < 0.01)        startY -= sign;    if (m_inPrinterMethod) {        startX += getStemThickness() / 2;    }    for (int j = 0; j < commonBeamCount; ++j) {        int y = sign * j * spacing;        drawShallowLine(startX, startY + y, startX + width,                        startY + (int)(width*grad) + y,                        thickness, smooth);        drawBeamsBeamCount ++;    }    int partWidth = width / 3;    if (partWidth < 2)        partWidth = 2;    else if (partWidth > m_noteBodyWidth)        partWidth = m_noteBodyWidth;    if (params.m_thisPartialBeams) {        for (int j = commonBeamCount; j < beamCount; ++j) {            int y = sign * j * spacing;            drawShallowLine(startX, startY + y, startX + partWidth,                            startY + (int)(partWidth*grad) + y,                            thickness, smooth);            drawBeamsBeamCount ++;        }    }    if (params.m_nextPartialBeams) {        startX += width - partWidth;        startY += (int)((width - partWidth) * grad);        for (int j = commonBeamCount; j < params.m_nextBeamCount; ++j) {            int y = sign * j * spacing;            drawShallowLine(startX, startY + y, startX + partWidth,                            startY + (int)(partWidth*grad) + y,                            thickness, smooth);            drawBeamsBeamCount ++;        }    }    clock_t endTime = clock();    drawBeamsTime += (endTime - startTime);}voidNotePixmapFactory::drawSlashes(const QPoint &s0,                               const NotePixmapParameters &params,                               int slashCount){    unsigned int thickness;    (void)m_font->getBeamThickness(thickness);    thickness = thickness * 3 / 4;    if (thickness < 1)        thickness = 1;    int gap = thickness - 1;    if (gap < 1)        gap = 1;    bool smooth = m_font->isSmooth();    int width = m_noteBodyWidth * 4 / 5;    int sign = (params.m_stemGoesUp ? -1 : 1);    int offset =        (slashCount == 1 ? m_noteBodyHeight * 2 :         slashCount == 2 ? m_noteBodyHeight * 3 / 2 :         m_noteBodyHeight);    int y = m_above + s0.y() + sign * (offset + thickness / 2);    for (int i = 0; i < slashCount; ++i) {        int yoff = width / 2;        drawShallowLine(m_left + s0.x() - width / 2, y + yoff / 2,                        m_left + s0.x() + width / 2 + getStemThickness(), y - yoff / 2,                        thickness, smooth);        y += sign * (thickness + gap);    }}voidNotePixmapFactory::makeRoomForTuplingLine(const NotePixmapParameters &params){    int lineSpacing =        (int)(params.m_tuplingLineWidth * params.m_tuplingLineGradient);    int th = m_tupletCountFontMetrics.height();    if (params.m_tuplingLineY < 0) {        lineSpacing = -lineSpacing;        if (lineSpacing < 0)            lineSpacing = 0;        m_above = std::max(m_above, -params.m_tuplingLineY + th / 2);        m_above += lineSpacing + 1;    } else {        if (lineSpacing < 0)            lineSpacing = 0;        m_below = std::max(m_below, params.m_tuplingLineY + th / 2);        m_below += lineSpacing + 1;    }    m_right = std::max(m_right, params.m_tuplingLineWidth);}voidNotePixmapFactory::drawTuplingLine(const NotePixmapParameters &params){    int thickness = getStaffLineThickness() * 3 / 2;    int countSpace = thickness * 2;    QString count;    count.setNum(params.m_tupletCount);    QRect cr = m_tupletCountFontMetrics.boundingRect(count);    int tlw = params.m_tuplingLineWidth;    int indent = m_noteBodyWidth / 2;    if (tlw < (cr.width() + countSpace * 2 + m_noteBodyWidth * 2)) {        tlw += m_noteBodyWidth - 1;        indent = 0;    }    int w = (tlw - cr.width()) / 2 - countSpace;    int startX = m_left + indent;    int endX = startX + w;    int startY = params.m_tuplingLineY + m_above + getLineSpacing() / 2;    int endY = startY + (int)(params.m_tuplingLineGradient * w);    if (startY == endY)        ++thickness;    int tickOffset = getLineSpacing() / 2;    if (params.m_tuplingLineY >= 0)        tickOffset = -tickOffset;    //    NOTATION_DEBUG << "adjusted params.m_tuplingLineWidth = "    //			 << tlw    //			 << ", cr.width = " << cr.width()    //			 << ", tickOffset = " << tickOffset << endl;    //    NOTATION_DEBUG << "line: (" << startX << "," << startY << ") -> ("    //			 << endX << "," << endY << ")" << endl;    bool smooth = m_font->isSmooth();    if (!params.m_tuplingLineFollowsBeam) {        m_p->drawLine(startX, startY, startX, startY + tickOffset);        drawShallowLine(startX, startY, endX, endY, thickness, smooth);    }    m_p->painter().setFont(m_tupletCountFont);    if (!m_inPrinterMethod)        m_p->maskPainter().setFont(m_tupletCountFont);    int textX = endX + countSpace;    int textY = endY + cr.height() / 2;    //    NOTATION_DEBUG << "text: (" << textX << "," << textY << ")" << endl;    m_p->drawText(textX, textY, count);    startX += tlw - w;    endX = startX + w;    startY += (int)(params.m_tuplingLineGradient * (tlw - w));    endY = startY + (int)(params.m_tuplingLineGradient * w);    //    NOTATION_DEBUG << "line: (" << startX << "," << startY << ") -> ("    //			 << endX << "," << endY << ")" << endl;    if (!params.m_tuplingLineFollowsBeam) {        drawShallowLine(startX, startY, endX, endY, thickness, smooth);        m_p->drawLine(endX, endY, endX, endY + tickOffset);    }}voidNotePixmapFactory::drawTie(bool above, int length, int shift){#ifdef NASTY_OLD_FLAT_TIE_CODE    int tieThickness = getStaffLineThickness() * 2;    int tieCurve = m_font->getSize() * 2 / 3;    int height = tieCurve + tieThickness;    int x = m_left + m_noteBodyWidth;    int y = (above ? m_above - height - tieCurve / 2 :             m_above + m_noteBodyHeight + tieCurve / 2 + 1);    int i;    length -= m_noteBodyWidth;    if (length < tieCurve * 2)        length = tieCurve * 2;    if (length < m_noteBodyWidth * 3) {        length += m_noteBodyWidth - 2;        x -= m_noteBodyWidth / 2 - 1;    }    for (i = 0; i < tieThickness; ++i) {        if (above) {            m_p->drawArc            (x, y + i, tieCurve*2, tieCurve*2, 90*16, 70*16);            m_p->drawLine            (x + tieCurve, y + i, x + length - tieCurve - 2, y + i);            m_p->drawArc            (x + length - 2*tieCurve - 1, y + i,             tieCurve*2, tieCurve*2, 20*16, 70*16);        } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -