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

📄 notationstaff.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    bool ok =        (int)(elt->getCanvasX()) == (int)(coords.first) &&        (int)(elt->getCanvasY()) == (int)(coords.second);    if (!ok) {        NOTATION_DEBUG        << "elementNotMoved: elt at " << elt->getViewAbsoluteTime() <<        ", ok is " << ok << endl;        NOTATION_DEBUG << "(cf " << (int)(elt->getCanvasX()) << " vs "        << (int)(coords.first) << ", "        << (int)(elt->getCanvasY()) << " vs "        << (int)(coords.second) << ")" << endl;    } else {        NOTATION_DEBUG << "elementNotMoved: elt at " << elt->getViewAbsoluteTime()        << " is ok" << endl;    }    return ok;}boolNotationStaff::elementNotMovedInY(NotationElement *elt){    if (!elt->getCanvasItem())        return false;    LinedStaffCoords coords = getCanvasCoordsForLayoutCoords                              (elt->getLayoutX(), (int)elt->getLayoutY());    bool ok = (int)(elt->getCanvasY()) == (int)(coords.second);    //     if (!ok) {    // 	NOTATION_DEBUG    // 	    << "elementNotMovedInY: elt at " << elt->getAbsoluteTime() <<    // 	    ", ok is " << ok << endl;    // 	NOTATION_DEBUG << "(cf " << (int)(elt->getCanvasY()) << " vs "    // 		  << (int)(coords.second) << ")" << std::endl;    //     }    return ok;}boolNotationStaff::elementShiftedOnly(NotationElementList::iterator i){    int shift = 0;    bool ok = false;    for (NotationElementList::iterator j = i;            j != getViewElementList()->end(); ++j) {        NotationElement *elt = static_cast<NotationElement*>(*j);        if (!elt->getCanvasItem())            break;        LinedStaffCoords coords = getCanvasCoordsForLayoutCoords                                  (elt->getLayoutX(), (int)elt->getLayoutY());        // regard any shift in y as suspicious        if ((int)(elt->getCanvasY()) != (int)(coords.second))            break;        int myShift = (int)(elt->getCanvasX()) - (int)(coords.first);        if (j == i)            shift = myShift;        else if (myShift != shift)            break;        if (elt->getViewAbsoluteTime() > (*i)->getViewAbsoluteTime()) {            // all events up to and including this one have passed            ok = true;            break;        }    }    if (!ok) {        NOTATION_DEBUG        << "elementShiftedOnly: elt at " << (*i)->getViewAbsoluteTime()        << ", ok is " << ok << endl;    }    return ok;}boolNotationStaff::isDirectlyPrintable(ViewElement *velt){    if (!m_printPainter)        return false;    return (velt->event()->isa(Note::EventType) ||            velt->event()->isa(Note::EventRestType) ||            velt->event()->isa(Text::EventType) ||            velt->event()->isa(Indication::EventType));}voidNotationStaff::renderSingleElement(ViewElementList::iterator &vli,                                   const Clef &currentClef,                                   const ::Rosegarden::Key &currentKey,                                   bool selected){    const NotationProperties &properties(getProperties());    static NotePixmapParameters restParams(Note::Crotchet, 0);    NotationElement* elt = static_cast<NotationElement*>(*vli);    bool invisible = false;    if (elt->event()->get            <Bool>(BaseProperties::INVISIBLE, invisible) && invisible) {        if (m_printPainter)            return ;        KConfig *config = kapp->config();        config->setGroup("Notation Options");        bool showInvisibles = config->readBoolEntry("showinvisibles", true);        if (!showInvisibles)            return ;    }    try {        m_notePixmapFactory->setNoteStyle        (NoteStyleFactory::getStyleForEvent(elt->event()));    } catch (NoteStyleFactory::StyleUnavailable u) {        std::cerr << "WARNING: Note style unavailable: "        << u.getMessage() << std::endl;        static bool warned = false;        if (!warned) {            KMessageBox::error(0, i18n(strtoqstr(u.getMessage())));            warned = true;        }    }    try {        QCanvasPixmap *pixmap = 0;        m_notePixmapFactory->setSelected(selected);        m_notePixmapFactory->setShaded(invisible);        int z = selected ? 3 : 0;        // these are actually only used for the printer stuff        LinedStaffCoords coords;        if (m_printPainter)            coords = getCanvasCoordsForLayoutCoords                     (elt->getLayoutX(), (int)elt->getLayoutY());        FitPolicy policy = PretendItFittedAllAlong;        if (elt->isNote()) {            renderNote(vli);        } else if (elt->isRest()) {            bool ignoreRest = false;            // NotationHLayout sets this property if it finds the rest            // in the middle of a chord -- Quantizer still sometimes gets            // this wrong            elt->event()->get            <Bool>(properties.REST_TOO_SHORT, ignoreRest);            if (!ignoreRest) {                Note::Type note = elt->event()->get                                  <Int>(BaseProperties::NOTE_TYPE);                int dots = elt->event()->get                           <Int>(BaseProperties::NOTE_DOTS);                restParams.setNoteType(note);                restParams.setDots(dots);                setTuplingParameters(elt, restParams);                restParams.setQuantized(false);                bool restOutside = false;                elt->event()->get                <Bool>(properties.REST_OUTSIDE_STAVE,                       restOutside);                restParams.setRestOutside(restOutside);                if (restOutside) {                    NOTATION_DEBUG << "NotationStaff::renderSingleElement() : rest outside staff" << endl;                    if (note == Note::DoubleWholeNote) {                        NOTATION_DEBUG << "NotationStaff::renderSingleElement() : breve rest needs leger lines" << endl;                        restParams.setLegerLines(5);                    }                }                if (m_printPainter) {                    m_notePixmapFactory->drawRest                    (restParams,                     *m_printPainter, int(coords.first), coords.second);                } else {                    pixmap = m_notePixmapFactory->makeRestPixmap(restParams);                }            }        } else if (elt->event()->isa(Clef::EventType)) {            pixmap = m_notePixmapFactory->makeClefPixmap                     (Clef(*elt->event()));        } else if (elt->event()->isa(::Rosegarden::Key::EventType)) {            ::Rosegarden::Key key(*elt->event());            ::Rosegarden::Key cancelKey = currentKey;            if (m_keySigCancelMode == 0) { // only when entering C maj / A min                if (key.getAccidentalCount() != 0)                    cancelKey = ::Rosegarden::Key();            } else if (m_keySigCancelMode == 1) { // only when reducing acc count                if (!(key.isSharp() == cancelKey.isSharp() &&                        key.getAccidentalCount() < cancelKey.getAccidentalCount())) {                    cancelKey = ::Rosegarden::Key();                }            }            pixmap = m_notePixmapFactory->makeKeyPixmap                     (key, currentClef, cancelKey);        } else if (elt->event()->isa(Text::EventType)) {            policy = MoveBackToFit;            if (elt->event()->has(Text::TextTypePropertyName) &&                    elt->event()->get                    <String>                    (Text::TextTypePropertyName) ==                    Text::Annotation &&                    !m_notationView->areAnnotationsVisible()) {                // nothing I guess            }            else if (elt->event()->has(Text::TextTypePropertyName) &&                     elt->event()->get                     <String>                     (Text::TextTypePropertyName) ==                     Text::LilypondDirective &&                     !m_notationView->areLilyPondDirectivesVisible()) {                // nothing here either            }            else {                try {                    if (m_printPainter) {                        Text text(*elt->event());                        int length = m_notePixmapFactory->getTextWidth(text);                        for (double w = -1, inc = 0; w != 0; inc += w) {                            w = setPainterClipping(m_printPainter,                                                   elt->getLayoutX(),                                                   int(elt->getLayoutY()),                                                   int(inc), length, coords,                                                   policy);                            m_notePixmapFactory->drawText                            (text, *m_printPainter, int(coords.first), coords.second);                            m_printPainter->restore();                        }                    } else {                        pixmap = m_notePixmapFactory->makeTextPixmap                                 (Text(*elt->event()));                    }                } catch (Exception e) { // Text ctor failed                    NOTATION_DEBUG << "Bad text event" << endl;                }            }        } else if (elt->event()->isa(Indication::EventType)) {            policy = SplitToFit;            try {                Indication indication(*elt->event());                timeT indicationDuration = indication.getIndicationDuration();                timeT indicationEndTime =                    elt->getViewAbsoluteTime() + indicationDuration;                NotationElementList::iterator indicationEnd =                    getViewElementList()->findTime(indicationEndTime);                std::string indicationType = indication.getIndicationType();                int length, y1;                if ((indicationType == Indication::Slur ||                        indicationType == Indication::PhrasingSlur) &&                        indicationEnd != getViewElementList()->begin()) {                    --indicationEnd;                }                if ((indicationType != Indication::Slur &&                        indicationType != Indication::PhrasingSlur) &&                        indicationEnd != getViewElementList()->begin() &&                        (indicationEnd == getViewElementList()->end() ||                         indicationEndTime ==                         getSegment().getBarStartForTime(indicationEndTime))) {                    while (indicationEnd == getViewElementList()->end() ||                            (*indicationEnd)->getViewAbsoluteTime() >= indicationEndTime)                        --indicationEnd;                    double x, w;                    static_cast<NotationElement *>(*indicationEnd)->                    getLayoutAirspace(x, w);                    length = (int)(x + w - elt->getLayoutX() -                                   m_notePixmapFactory->getBarMargin());                } else {                    length = (int)((*indicationEnd)->getLayoutX() -                                   elt->getLayoutX());                    if (indication.isOttavaType()) {                        length -= m_notePixmapFactory->getNoteBodyWidth();                    }                }                y1 = (int)(*indicationEnd)->getLayoutY();                if (length < m_notePixmapFactory->getNoteBodyWidth()) {                    length = m_notePixmapFactory->getNoteBodyWidth();                }                if (indicationType == Indication::Crescendo ||                        indicationType == Indication::Decrescendo) {                    if (m_printPainter) {                        for (double w = -1, inc = 0; w != 0; inc += w) {                            w = setPainterClipping(m_printPainter,                                                   elt->getLayoutX(),                                                   int(elt->getLayoutY()),                                                   int(inc), length, coords,                                                   policy);                            m_notePixmapFactory->drawHairpin                            (length, indicationType == Indication::Crescendo,                             *m_printPainter, int(coords.first), coords.second);                            m_printPainter->restore();                        }                    } else {                        pixmap = m_notePixmapFactory->makeHairpinPixmap                                 (length, indicationType == Indication::Crescendo);                    }                } else if (indicationType == Indication::Slur ||                           indicationType == Indication::PhrasingSlur) {                    bool above = true;                    long dy = 0;                    long length = 10;                    elt->event()->get                    <Bool>(properties.SLUR_ABOVE, above);                    elt->event()->get                    <Int>(properties.SLUR_Y_DELTA, dy);                    elt->event()->get                    <Int>(properties.SLUR_LENGTH, length);                    if (m_printPainter) {                        for (double w = -1, inc = 0; w != 0; inc += w) {                            w = setPainterClipping(m_printPainter,                                                   elt->getLayoutX(),                                                   int(elt->getLayoutY()),                                                   int(inc), length, coords,                                                   policy);                            m_notePixmapFactory->drawSlur                            (length, dy, above,                             indicationType == Indication::PhrasingSlur,                             *m_printPainter, int(coords.first), coords.second);                            m_printPainter->restore();                        }                    } else {                        pixmap = m_notePixmapFactory->makeSlurPixmap                                 (length, dy, above,                                  indicationType == Indication::PhrasingSlur);                    }                } else {                    int octaves = indication.getOttavaShift();                    if (octaves != 0) {                        if (m_printPainter) {                            for (double w = -1, inc = 0; w != 0; inc += w) {                                w = setPainterClipping(m_printPainter,                                                       elt->getLayoutX(),                                                       int(elt->getLayoutY()),                                                       int(inc), length, coords,                                                       policy);                                m_notePixmapFactory->drawOttava                                (length, octaves,

⌨️ 快捷键说明

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