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

📄 notepixmapfactory.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    int dy = gap;    std::vector<Mark> normalMarks = params.getNormalMarks();    std::vector<Mark> aboveMarks = params.getAboveMarks();    bool normalMarksAreAbove = !(isStemmed && params.m_stemGoesUp);    for (std::vector<Mark>::iterator i = normalMarks.begin();            i != normalMarks.end(); ++i) {        if (!Marks::isTextMark(*i)) {            NoteCharacter character = getCharacter                                      (m_style->getMarkCharName(*i), PlainColour,                                       !normalMarksAreAbove);            int x = m_left + m_noteBodyWidth / 2 - character.getWidth() / 2;            int y = (normalMarksAreAbove ?                     (m_above - dy - character.getHeight() - 1) :                     (m_above + m_noteBodyHeight + m_borderY * 2 + dy));            m_p->drawNoteCharacter(x, y, character);            dy += character.getHeight() + gap;        } else {            QString text = strtoqstr(Marks::getTextFromMark(*i));            QRect bounds = m_textMarkFontMetrics.boundingRect(text);            m_p->painter().setFont(m_textMarkFont);            if (!m_inPrinterMethod)                m_p->maskPainter().setFont(m_textMarkFont);            int x = m_left + m_noteBodyWidth / 2 - bounds.width() / 2;            int y = (normalMarksAreAbove ?                     (m_above - dy - 3) :                     (m_above + m_noteBodyHeight + m_borderY * 2 + dy + bounds.height() + 1));            m_p->drawText(x, y, text);            dy += bounds.height() + gap;        }    }    if (!normalMarksAreAbove)        dy = gap;    if (params.m_safeVertDistance > 0) {        if (normalMarksAreAbove) {            dy = std::max(dy, params.m_safeVertDistance);        } else {            dy = params.m_safeVertDistance;        }    } else if (isStemmed && params.m_stemGoesUp) {        dy += stemLength;    }    for (std::vector<Mark>::iterator i = aboveMarks.begin();            i != aboveMarks.end(); ++i) {        if (m_selected)            m_p->painter().setPen(GUIPalette::getColour(GUIPalette::SelectedElement));        else            m_p->painter().setPen(Qt::black);        if (!Marks::isFingeringMark(*i)) {            int x = m_left + m_noteBodyWidth / 2;            int y = m_above - dy - 1;            if (*i != Marks::TrillLine) {                NoteCharacter character                (getCharacter                 (m_style->getMarkCharName(*i), PlainColour,                  false));                x -= character.getWidth() / 2;                y -= character.getHeight();                m_p->drawNoteCharacter(x, y, character);                y += character.getHeight() / 2;                x += character.getWidth();                dy += character.getHeight() + gap;            } else {                NoteCharacter character                (getCharacter                 (m_style->getMarkCharName(Marks::Trill), PlainColour,                  false));                y -= character.getHeight() / 2;                dy += character.getHeight() + gap;            }            if (*i == Marks::LongTrill ||                    *i == Marks::TrillLine) {                NoteCharacter extension;                if (getCharacter(NoteCharacterNames::TRILL_LINE, extension,                                 PlainColour, false)) {                    x += extension.getHotspot().x();                    while (x < m_left + params.m_width - extension.getWidth()) {                        x -= extension.getHotspot().x();                        m_p->drawNoteCharacter(x, y, extension);                        x += extension.getWidth();                    }                }                if (*i == Marks::TrillLine)                    dy += extension.getHeight() + gap;            }        } else {            QString text = strtoqstr(Marks::getFingeringFromMark(*i));            QRect bounds = m_fingeringFontMetrics.boundingRect(text);            m_p->painter().setFont(m_fingeringFont);            if (!m_inPrinterMethod)                m_p->maskPainter().setFont(m_fingeringFont);            int x = m_left + m_noteBodyWidth / 2 - bounds.width() / 2;            int y = m_above - dy - 3;            m_p->drawText(x, y, text);            dy += bounds.height() + gap;        }    }}voidNotePixmapFactory::makeRoomForLegerLines(const NotePixmapParameters &params){    if (params.m_legerLines < 0 || params.m_restOutsideStave) {        m_above = std::max(m_above,                           (m_noteBodyHeight + 1) *                           ( -params.m_legerLines / 2));    }    if (params.m_legerLines > 0 || params.m_restOutsideStave) {        m_below = std::max(m_below,                           (m_noteBodyHeight + 1) *                           (params.m_legerLines / 2));    }    if (params.m_legerLines != 0) {        m_left = std::max(m_left, m_noteBodyWidth / 5 + 1);        m_right = std::max(m_right, m_noteBodyWidth / 5 + 1);    }    if (params.m_restOutsideStave) {        m_above += 1;        m_left = std::max(m_left, m_noteBodyWidth * 3 + 1);        m_right = std::max(m_right, m_noteBodyWidth * 3 + 1);    }}voidNotePixmapFactory::drawLegerLines(const NotePixmapParameters &params){    int x0, x1, y;    if (params.m_legerLines == 0)        return ;    if (params.m_restOutsideStave) {        if (m_selected)            m_p->painter().setPen(GUIPalette::getColour(GUIPalette::SelectedElement));        else            m_p->painter().setPen(Qt::black);    }    x0 = m_left - m_noteBodyWidth / 5 - 1;    x1 = m_left + m_noteBodyWidth + m_noteBodyWidth / 5 /* + 1 */;    if (params.m_shifted) {        if (params.m_stemGoesUp) {            x0 += m_noteBodyWidth;            x1 += m_noteBodyWidth;        } else {            x0 -= m_noteBodyWidth;            x1 -= m_noteBodyWidth;        }    }    int offset = m_noteBodyHeight + getStaffLineThickness();    int legerLines = params.m_legerLines;    bool below = (legerLines < 0);    if (below) {        legerLines = -legerLines;        offset = -offset;    }    if (params.m_restOutsideStave)        y = m_above;    else {        if (!below) { // note above staff            if (legerLines % 2) { // note is between lines                y = m_above + m_noteBodyHeight;            } else { // note is on a line                y = m_above + m_noteBodyHeight / 2 - getStaffLineThickness() / 2;            }        } else { // note below staff            if (legerLines % 2) { // note is between lines                y = m_above - getStaffLineThickness();            } else { // note is on a line                y = m_above + m_noteBodyHeight / 2;            }        }    }    if (params.m_restOutsideStave) {        NOTATION_DEBUG << "draw leger lines: " << legerLines << " lines, below "        << below        << ", note body height " << m_noteBodyHeight        << ", thickness " << getLegerLineThickness()        << " (staff line " << getStaffLineThickness() << ")"        << ", offset " << offset << endl;    }    //    NOTATION_DEBUG << "draw leger lines: " << legerLines << " lines, below "    //		   << below    //		   << ", note body height " << m_noteBodyHeight    //		   << ", thickness " << getLegerLineThickness()    //		   << " (staff line " << getStaffLineThickness() << ")"    //		   << ", offset " << offset << endl;    //    bool first = true;    if (getLegerLineThickness() > getStaffLineThickness()) {        y -= (getLegerLineThickness() - getStaffLineThickness() + 1) / 2;    }    for (int i = legerLines - 1; i >= 0; --i) {        if (i % 2) {            //	    NOTATION_DEBUG << "drawing leger line at y = " << y << endl;            for (int j = 0; j < getLegerLineThickness(); ++j) {                m_p->drawLine(x0, y + j, x1, y + j);            }            y += offset;            //	    if (first) {            //		x0 += getStemThickness();            //		x1 -= getStemThickness();            //		first = false;            //	    }        }    }}voidNotePixmapFactory::makeRoomForStemAndFlags(int flagCount, int stemLength,        const NotePixmapParameters &params,        QPoint &s0, QPoint &s1){    // The coordinates we set in s0 and s1 are relative to (m_above, m_left)    if (params.m_stemGoesUp) {        m_above = std::max                  (m_above, stemLength - m_noteBodyHeight / 2);    } else {        m_below = std::max                  (m_below, stemLength - m_noteBodyHeight / 2 + 1);    }    if (flagCount > 0) {        if (params.m_stemGoesUp) {            int width = 0, height = 0;            if (!m_font->getDimensions                    (m_style->getFlagCharName(flagCount), width, height)) {                width = m_font->getWidth(m_style->getPartialFlagCharName(false));            }            m_right += width;        }    }    unsigned int stemThickness = getStemThickness();    NoteStyle::HFixPoint hfix;    NoteStyle::VFixPoint vfix;    m_style->getStemFixPoints(params.m_noteType, hfix, vfix);    switch (hfix) {    case NoteStyle::Normal:    case NoteStyle::Reversed:        if (params.m_stemGoesUp ^ (hfix == NoteStyle::Reversed)) {            s0.setX(m_noteBodyWidth - stemThickness);        } else {            s0.setX(0);        }        break;    case NoteStyle::Central:        if (params.m_stemGoesUp ^ (hfix == NoteStyle::Reversed)) {            s0.setX(m_noteBodyWidth / 2 + 1);        } else {            s0.setX(m_noteBodyWidth / 2);        }        break;    }    switch (vfix) {    case NoteStyle::Near:    case NoteStyle::Far:        if (params.m_stemGoesUp ^ (vfix == NoteStyle::Far)) {            s0.setY(0);        } else {            s0.setY(m_noteBodyHeight);        }        if (vfix == NoteStyle::Near) {            stemLength -= m_noteBodyHeight / 2;        } else {            stemLength += m_noteBodyHeight / 2;        }        break;    case NoteStyle::Middle:        if (params.m_stemGoesUp) {            s0.setY(m_noteBodyHeight * 3 / 8);        } else {            s0.setY(m_noteBodyHeight * 5 / 8);        }        stemLength -= m_noteBodyHeight / 8;        break;    }    if (params.m_stemGoesUp) {        s1.setY(s0.y() - stemLength + getStaffLineThickness());    } else {        s1.setY(s0.y() + stemLength);    }    s1.setX(s0.x());}voidNotePixmapFactory::drawFlags(int flagCount,                             const NotePixmapParameters &params,                             const QPoint &, const QPoint &s1){    if (flagCount < 1)        return ;    NoteCharacter flagChar;    bool found = getCharacter(m_style->getFlagCharName(flagCount),                              flagChar,                              PlainColour,                              !params.m_stemGoesUp);    if (!found) {        // Handle fonts that don't have all the flags in separate characters        found = getCharacter(m_style->getPartialFlagCharName(false),                             flagChar,                             PlainColour,                             !params.m_stemGoesUp);        if (!found) {            std::cerr << "Warning: NotePixmapFactory::drawFlags: No way to draw note with " << flagCount << " flags in this font!?" << std::endl;            return ;        }        QPoint hotspot = flagChar.getHotspot();        NoteCharacter oneFlagChar;        bool foundOne =            (flagCount > 1 ?             getCharacter(m_style->getPartialFlagCharName(true),                          oneFlagChar,                          PlainColour,                          !params.m_stemGoesUp) : false);        unsigned int flagSpace = m_noteBodyHeight;        (void)m_font->getFlagSpacing(flagSpace);        for (int flag = 0; flag < flagCount; ++flag) {            // use flag_1 in preference to flag_0 for the final flag, so            // as to end with a flourish            if (flag == flagCount - 1 && foundOne)                flagChar = oneFlagChar;            int y = m_above + s1.y();            if (params.m_stemGoesUp)                y += flag * flagSpace;            else                y -= (flag * flagSpace) + flagChar.getHeight();            if (!m_inPrinterMethod) {                m_p->end();                // Super-slow                PixmapFunctions::drawPixmapMasked(*m_generatedPixmap,                                                  *m_generatedMask,                                                  m_left + s1.x() - hotspot.x(),                                                  y,                                                  *flagChar.getPixmap());                m_p->begin(m_generatedPixmap, m_generatedMask);            } else {                // No problem with mask here                m_p->drawNoteCharacter(m_left + s1.x() - hotspot.x(),                                       y,                                       flagChar);            }        }    } else { // the normal case        QPoint hotspot = flagChar.getHotspot();        int y = m_above + s1.y();        if (!params.m_stemGoesUp)            y -= flagChar.getHeight();

⌨️ 快捷键说明

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