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

📄 notationstaff.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        if (marks) {            NotationChord chord(*getViewElementList(), vli,                                m_segment.getComposition()->getNotationQuantizer(),                                properties);            params.setMarks(chord.getMarksForChord());        }        //	    params.setMarks(Marks::getMarks(*elt->event()));        if (up && note < Note::Semibreve) {            safeVertDistance = m_notePixmapFactory->getStemLength();            safeVertDistance = std::max(safeVertDistance, int(stemLength));        }    }    long tieLength = 0;    (void)(elt->event()->get           <Int>(properties.TIE_LENGTH, tieLength));    if (tieLength > 0) {        params.setTied(true);        params.setTieLength(tieLength);    } else {        params.setTied(false);    }    long accidentalShift = 0;    bool accidentalExtra = false;    if (elt->event()->get            <Int>(properties.ACCIDENTAL_SHIFT, accidentalShift)) {        elt->event()->get        <Bool>(properties.ACCIDENTAL_EXTRA_SHIFT, accidentalExtra);    }    params.setAccidentalShift(accidentalShift);    params.setAccExtraShift(accidentalExtra);    double airX, airWidth;    elt->getLayoutAirspace(airX, airWidth);    params.setWidth(int(airWidth));    if (beamed) {        if (elt->event()->get                <Bool>(properties.CHORD_PRIMARY_NOTE, primary)                && primary) {            int myY = elt->event()->get                      <Int>(properties.BEAM_MY_Y);            stemLength = myY - (int)elt->getLayoutY();            if (stemLength < 0)                stemLength = -stemLength;            int nextBeamCount =                elt->event()->get                <Int>(properties.BEAM_NEXT_BEAM_COUNT);            int width =                elt->event()->get                <Int>(properties.BEAM_SECTION_WIDTH);            int gradient =                elt->event()->get                <Int>(properties.BEAM_GRADIENT);            bool thisPartialBeams(false), nextPartialBeams(false);            (void)elt->event()->get            <Bool>            (properties.BEAM_THIS_PART_BEAMS, thisPartialBeams);            (void)elt->event()->get            <Bool>            (properties.BEAM_NEXT_PART_BEAMS, nextPartialBeams);            params.setBeamed(true);            params.setNextBeamCount(nextBeamCount);            params.setThisPartialBeams(thisPartialBeams);            params.setNextPartialBeams(nextPartialBeams);            params.setWidth(width);            params.setGradient((double)gradient / 100.0);            if (up)                safeVertDistance = stemLength;        }        else {            params.setBeamed(false);            params.setDrawStem(false);        }    }    if (heightOnStaff < 7) {        int gap = (((7 - heightOnStaff) * m_notePixmapFactory->getLineSpacing()) / 2);        if (safeVertDistance < gap)            safeVertDistance = gap;    }    params.setStemLength(stemLength);    params.setSafeVertDistance(safeVertDistance);    setTuplingParameters(elt, params);    NotePixmapFactory *factory = m_notePixmapFactory;    if (elt->isGrace()) {        params.setLegerLines(0);        m_graceNotePixmapFactory->setSelected(m_notePixmapFactory->isSelected());        m_graceNotePixmapFactory->setShaded(m_notePixmapFactory->isShaded());        factory = m_graceNotePixmapFactory;    }    if (m_printPainter) {        // Return no canvas item, but instead render straight to        // the printer.        LinedStaffCoords coords = getCanvasCoordsForLayoutCoords                                  (elt->getLayoutX(), (int)elt->getLayoutY());        // We don't actually know how wide the note drawing will be,        // but we should be able to use a fairly pessimistic estimate        // without causing any problems        int length = tieLength + 10 * m_notePixmapFactory->getNoteBodyWidth();        for (double w = -1, inc = 0; w != 0; inc += w) {            w = setPainterClipping(m_printPainter,                                   elt->getLayoutX(),                                   int(elt->getLayoutY()),                                   int(inc), length, coords,                                   SplitToFit);            factory->drawNote            (params, *m_printPainter, int(coords.first), coords.second);            m_printPainter->restore(); // save() called by setPainterClipping        }    } else {        // The normal on-screen case        bool collision = false;        QCanvasItem * haloItem = 0;        if (m_showCollisions) {            collision = elt->isColliding();            if (collision) {                // Make collision halo                QCanvasPixmap *haloPixmap = factory->makeNoteHaloPixmap(params);                haloItem = new QCanvasNotationSprite(*elt, haloPixmap, m_canvas);                haloItem->setZ(-1);            }        }        QCanvasPixmap *pixmap = factory->makeNotePixmap(params);        int z = 0;        if (factory->isSelected())            z = 3;        else if (quantized)            z = 2;        setPixmap(elt, pixmap, z, SplitToFit);        if (collision) {            // Display collision halo            LinedStaffCoords coords =                getCanvasCoordsForLayoutCoords(elt->getLayoutX(),                                               elt->getLayoutY());            double canvasX = coords.first;            int canvasY = coords.second;            elt->addCanvasItem(haloItem, canvasX, canvasY);            haloItem->show();        }    }}voidNotationStaff::setTuplingParameters(NotationElement *elt,                                    NotePixmapParameters &params){    const NotationProperties &properties(getProperties());    params.setTupletCount(0);    long tuplingLineY = 0;    bool tupled = (elt->event()->get                   <Int>(properties.TUPLING_LINE_MY_Y, tuplingLineY));    if (tupled) {        long tuplingLineWidth = 0;        if (!elt->event()->get                <Int>(properties.TUPLING_LINE_WIDTH, tuplingLineWidth)) {            std::cerr << "WARNING: Tupled event at " << elt->event()->getAbsoluteTime() << " has no tupling line width" << std::endl;        }        long tuplingLineGradient = 0;        if (!(elt->event()->get                <Int>(properties.TUPLING_LINE_GRADIENT,                      tuplingLineGradient))) {            std::cerr << "WARNING: Tupled event at " << elt->event()->getAbsoluteTime() << " has no tupling line gradient" << std::endl;        }        bool tuplingLineFollowsBeam = false;        elt->event()->get        <Bool>(properties.TUPLING_LINE_FOLLOWS_BEAM,               tuplingLineFollowsBeam);        long tupletCount;        if (elt->event()->get                <Int>(BaseProperties::BEAMED_GROUP_UNTUPLED_COUNT, tupletCount)) {            params.setTupletCount(tupletCount);            params.setTuplingLineY(tuplingLineY - (int)elt->getLayoutY());            params.setTuplingLineWidth(tuplingLineWidth);            params.setTuplingLineGradient(double(tuplingLineGradient) / 100.0);            params.setTuplingLineFollowsBeam(tuplingLineFollowsBeam);        }    }}boolNotationStaff::isSelected(NotationElementList::iterator it){    const EventSelection *selection =        m_notationView->getCurrentSelection();    return selection && selection->contains((*it)->event());}voidNotationStaff::showPreviewNote(double layoutX, int heightOnStaff,                               const Note &note){    NotePixmapParameters params(note.getNoteType(), note.getDots());    params.setAccidental(Accidentals::NoAccidental);    params.setNoteHeadShifted(false);    params.setDrawFlag(true);    params.setDrawStem(true);    params.setStemGoesUp(heightOnStaff <= 4);    params.setLegerLines(heightOnStaff < 0 ? heightOnStaff :                         heightOnStaff > 8 ? heightOnStaff - 8 : 0);    params.setBeamed(false);    params.setIsOnLine(heightOnStaff % 2 == 0);    params.setTied(false);    params.setBeamed(false);    params.setTupletCount(0);    params.setSelected(false);    params.setHighlighted(true);    delete m_previewSprite;    m_previewSprite = new QCanvasSimpleSprite                      (m_notePixmapFactory->makeNotePixmap(params), m_canvas);    int layoutY = getLayoutYForHeight(heightOnStaff);    LinedStaffCoords coords = getCanvasCoordsForLayoutCoords(layoutX, layoutY);    m_previewSprite->move(coords.first, (double)coords.second);    m_previewSprite->setZ(4);    m_previewSprite->show();    m_canvas->update();}voidNotationStaff::clearPreviewNote(){    delete m_previewSprite;    m_previewSprite = 0;}boolNotationStaff::wrapEvent(Event *e){    bool wrap = true;    /*!!! always wrap unknowns, just don't necessarily render them?             if (!m_showUnknowns) {    	std::string etype = e->getType();    	if (etype != Note::EventType &&    	    etype != Note::EventRestType &&    	    etype != Clef::EventType &&    	    etype != Key::EventType &&    	    etype != Indication::EventType &&    	    etype != Text::EventType) {    	    wrap = false;    	}        }    */    if (wrap)        wrap = Staff::wrapEvent(e);    return wrap;}voidNotationStaff::eventRemoved(const Segment *segment,                            Event *event){    LinedStaff::eventRemoved(segment, event);    m_notationView->handleEventRemoved(event);}voidNotationStaff::markChanged(timeT from, timeT to, bool movedOnly){    // first time through this, m_ready is false -- we mark it true    NOTATION_DEBUG << "NotationStaff::markChanged (" << from << " -> " << to << ") " << movedOnly << endl;    if (from == to) {        m_status.clear();        if (!movedOnly && m_ready) { // undo all the rendering we've already done            for (NotationElementList::iterator i = getViewElementList()->begin();                    i != getViewElementList()->end(); ++i) {                static_cast<NotationElement *>(*i)->removeCanvasItem();            }        }    } else {        Segment *segment = &getSegment();        Composition *composition = segment->getComposition();        NotationElementList::iterator unchanged = findUnchangedBarEnd(to);        int finalBar;        if (unchanged == getViewElementList()->end()) {            finalBar = composition->getBarNumber(segment->getEndMarkerTime());        } else {            finalBar = composition->getBarNumber((*unchanged)->getViewAbsoluteTime());        }        int fromBar = composition->getBarNumber(from);        int toBar = composition->getBarNumber(to);        if (finalBar < toBar)            finalBar = toBar;        for (int bar = fromBar; bar <= finalBar; ++bar) {            if (bar > toBar)                movedOnly = true;            //	    NOTATION_DEBUG << "bar " << bar << " status " << m_status[bar] << endl;            if (bar >= m_lastRenderCheck.first &&                    bar <= m_lastRenderCheck.second) {                //		NOTATION_DEBUG << "bar " << bar << " rendering and positioning" << endl;                if (!movedOnly || m_status[bar] == UnRendered) {                    renderElements                    (getViewElementList()->findTime(composition->getBarStart(bar)),                     getViewElementList()->findTime(composition->getBarEnd(bar)));                }                positionElements(composition->getBarStart(bar),                                 composition->getBarEnd(bar));                m_status[bar] = Positioned;            } else if (!m_ready) {                //		NOTATION_DEBUG << "bar " << bar << " rendering and positioning" << endl;                // first time through -- we don't need a separate render phase,                // only to mark as not yet positioned                m_status[bar] = Rendered;            } else if (movedOnly) {                if (m_status[bar] == Positioned) {                    //		    NOTATION_DEBUG << "bar " << bar << " marking unpositioned" << endl;                    m_status[bar] = Rendered;                }            } else {                //		NOTATION_DEBUG << "bar " << bar << " marking unrendered" << endl;                m_status[bar] = UnRendered;            }        }    }    m_ready = true;}voidNotationStaff::setPrintPainter(QPainter *painter){    m_printPainter = painter;}boolNotationStaff::checkRendered(timeT from, timeT to){    if (!m_re

⌨️ 快捷键说明

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