コード例 #1
0
ファイル: floatingobject.cpp プロジェクト: ahwitz/verovio
FloatingPositioner::FloatingPositioner(FloatingObject *object) : BoundingBox()
{
    assert(object);

    m_object = object;
    if (object->Is() == DIR) {
        Dir *dir = dynamic_cast<Dir *>(object);
        assert(dir);
        // dir below by default
        m_place = dir->HasPlace() ? dir->GetPlace() : STAFFREL_below;
    }
    else if (object->Is() == DYNAM) {
        Dynam *dynam = dynamic_cast<Dynam *>(object);
        assert(dynam);
        // dynam below by default
        m_place = dynam->HasPlace() ? dynam->GetPlace() : STAFFREL_below;
    }
    else if (object->Is() == ENDING) {
        // endings always above;
        m_place = STAFFREL_above;
    }
    else if (object->Is() == FERMATA) {
        Fermata *fermata = dynamic_cast<Fermata *>(object);
        assert(fermata);
        // fermata above by default
        m_place = fermata->HasPlace() ? fermata->GetPlace() : STAFFREL_above;
    }
    else if (object->Is() == HAIRPIN) {
        Hairpin *hairpin = dynamic_cast<Hairpin *>(object);
        assert(hairpin);
        // haripin below by default;
        m_place = hairpin->HasPlace() ? hairpin->GetPlace() : STAFFREL_below;
    }
    else if (object->Is() == HARM) {
        Harm *harm = dynamic_cast<Harm *>(object);
        assert(harm);
        // harm above by default
        m_place = harm->HasPlace() ? harm->GetPlace() : STAFFREL_above;
    }
    else if (object->Is() == OCTAVE) {
        Octave *octave = dynamic_cast<Octave *>(object);
        assert(octave);
        // octave below by default (won't draw without @dis.place anyway);
        m_place = (octave->GetDisPlace() == PLACE_above) ? STAFFREL_above : STAFFREL_below;
    }
    else if (object->Is() == PEDAL) {
        Pedal *pedal = dynamic_cast<Pedal *>(object);
        assert(pedal);
        // pedal below by default
        m_place = pedal->HasPlace() ? pedal->GetPlace() : STAFFREL_below;
    }
    else if (object->Is() == TEMPO) {
        Tempo *tempo = dynamic_cast<Tempo *>(object);
        assert(tempo);
        // tempo above by default;
        m_place = tempo->HasPlace() ? tempo->GetPlace() : STAFFREL_above;
    }
    else if (object->Is() == TRILL) {
        Trill *trill = dynamic_cast<Trill *>(object);
        assert(trill);
        // trill above by default;
        m_place = trill->HasPlace() ? trill->GetPlace() : STAFFREL_above;
    }
    else {
        m_place = STAFFREL_NONE;
    }
    ResetPositioner();
};