Example #1
0
void CDraw::checkAccidental(CSymbol symbol, float x, float y)
{
    int accidental;
    const int xGap = 16;

    accidental = symbol.getStavePos().getAccidental();


    if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_suppress)
        accidental = 0; // Suppress the accidental if it is the same bar

    if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_force)
    {
        // Force the display of an accidental including naturals if it is the same bar
        accidental = CStavePos::midiNote2Name(symbol.getNote()).accidental;
        if (accidental == 0)
            accidental = 2;
    }

    if (accidental != 0)
    {
        //drColour (Cfg::lineColour());
        if (accidental == 1)
            drawSymbol(CSymbol(PB_SYMBOL_sharp, symbol.getStavePos()), x - xGap, y);
        else if (accidental == -1)
            drawSymbol(CSymbol(PB_SYMBOL_flat, symbol.getStavePos()), x - xGap, y);
        else
            drawSymbol(CSymbol(PB_SYMBOL_natural, symbol.getStavePos()), x - xGap, y);
    }
}
Example #2
0
void BarLine::drawDots(QPainter* painter, qreal x) const
      {
      qreal _spatium = spatium();

      if (parent() == 0) {    // for use in palette
            drawSymbol(SymId::repeatDot, painter, QPointF(x, 2.0 * _spatium));
            drawSymbol(SymId::repeatDot, painter, QPointF(x, 3.0 * _spatium));
            }
      else if (parent()->type() == Element::Type::SEGMENT) {
            System* s = static_cast<Segment*>(parent())->measure()->system();
            int staffIdx1    = staffIdx();
            int staffIdx2    = staffIdx1 + _span - 1;
            int sp = _span;
            if (staffIdx2 >= score()->nstaves()) {
                  qDebug("BarLine: bad _span %d", _span);
                  staffIdx2 = score()->nstaves() - 1;
                  sp = staffIdx2 - staffIdx1 + 1;
                  }
            qreal dy  = s->staff(staffIdx1)->y();
            for (int i = 0; i < sp; ++i) {
                  Staff* staff  = score()->staff(staffIdx1 + i);
                  StaffType* st = staff->staffType();
                  qreal doty1   = (st->doty1() + .5) * _spatium;
                  qreal doty2   = (st->doty2() + .5) * _spatium;

                  qreal staffy  = s->staff(staffIdx1 + i)->y() - dy;

                  drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty1));
                  drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty2));
                  }
            }
      }
Example #3
0
void Ambitus::draw(QPainter* p) const
      {
      qreal _spatium = spatium();
      qreal lw = lineWidth().val() * _spatium;
      p->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      drawSymbol(noteHead(), p, _topPos);
      drawSymbol(noteHead(), p, _bottomPos);
      if (_hasLine)
            p->drawLine(_line);

      // draw ledger lines (if not in a palette)
      if (segment() && track() > -1) {
            int tick          = segment()->tick();
            Staff* stf        = score()->staff(staffIdx());
            qreal lineDist    = stf->lineDistance(tick);
            int numOfLines    = stf->lines(tick);
            qreal step        = lineDist * _spatium;
            qreal stepTolerance = step * 0.1;
            qreal ledgerOffset = score()->styleS(Sid::ledgerLineLength).val() * 0.5 * _spatium;
            p->setPen(QPen(curColor(), score()->styleS(Sid::ledgerLineWidth).val() * _spatium,
                        Qt::SolidLine, Qt::RoundCap) );
            if (_topPos.y()-stepTolerance <= -step) {
                  qreal xMin = _topPos.x() - ledgerOffset;
                  qreal xMax = _topPos.x() + headWidth() + ledgerOffset;
                  for (qreal y = -step; y >= _topPos.y()-stepTolerance; y -= step)
                        p->drawLine(QPointF(xMin, y), QPointF(xMax, y));
                  }
            if (_bottomPos.y()+stepTolerance >= numOfLines * step) {
                  qreal xMin = _bottomPos.x() - ledgerOffset;
                  qreal xMax = _bottomPos.x() + headWidth() + ledgerOffset;
                  for (qreal y = numOfLines*step; y <= _bottomPos.y()+stepTolerance; y += step)
                        p->drawLine(QPointF(xMin, y), QPointF(xMax, y));
                  }
            }
      }
Example #4
0
void Rest::draw(QPainter* painter) const
      {
      if ( (staff() && staff()->isTabStaff()
            // in tab staff, do not draw rests is rests are off OR if dur. symbols are on
            && (!staff()->staffType()->showRests() || staff()->staffType()->genDurations()))
            || generated())
            return;
      qreal _spatium = spatium();

      painter->setPen(curColor());

      if (parent() && measure() && measure()->isMMRest()) {
            //only on voice 1
            if ((track() % VOICES) != 0)
                  return;
            Measure* m = measure();
            int n      = m->mmRestCount();
            qreal pw = _spatium * .7;
            QPen pen(painter->pen());
            pen.setWidthF(pw);
            painter->setPen(pen);

            qreal w  = _mmWidth;
            qreal y  = 0.0;
            qreal x1 = 0.0;
            qreal x2 =  w;
            pw *= .5;
            painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y));

            // draw vertical lines:
            pen.setWidthF(_spatium * .2);
            painter->setPen(pen);
            painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium));
            painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium));

            painter->setFont(score()->scoreFont()->font());
            QFontMetricsF fm(score()->scoreFont()->font());
            QString s = toTimeSigString(QString("%1").arg(n));
            y  = -_spatium * 1.5 - staff()->height() *.5;
            qreal x = center(x1, x2);
            x -= symBbox(s).width() * .5;
            drawSymbols(s, painter, QPointF(x, y));
            }
      else {
            drawSymbol(_sym, painter);
            int dots = durationType().dots();
            if (dots) {
                  qreal y = dotline * _spatium * .5;
                  for (int i = 1; i <= dots; ++i) {
                        qreal x = symWidth(_sym) + point(score()->styleS(StyleIdx::dotNoteDistance)) * i;
                        drawSymbol(SymId::augmentationDot, painter, QPointF(x, y));
                        }
                  }
            }
      }
Example #5
0
void KeySig::draw(QPainter* p) const
      {
      p->setPen(curColor());
      for (const KeySym& ks: _sig.keySymbols())
            drawSymbol(ks.sym, p, QPointF(ks.pos.x(), ks.pos.y()));
      if (!parent() && isCustom() && _sig.keySymbols().isEmpty()) {
            // atonal key signature - draw something for palette
            p->setPen(Qt::gray);
            drawSymbol(SymId::timeSigX, p, QPointF(symWidth(SymId::timeSigX) * -0.5, 2.0 * spatium()));
            }
      }
Example #6
0
void CDraw::drawKeySignature(int key)
{
    const int sharpLookUpRight[] = { 4, 1, 5, 2,-1, 3, 0};
    const int sharpLookUpLeft[]  = { 2,-1, 3, 0,-3, 1,-2};
    const int flatLookUpRight[]  = { 0, 3,-1, 2,-2, 1,-3};
    const int flatLookUpLeft[]   = {-2, 1,-3, 0,-4,-1,-5};
    const int gapX = 11;
    CStavePos pos;
    size_t i;

    if (key == NOT_USED)
        return;

    i = 0;
    while (key != 0 )
    {
        if (key > 0)
        {
            if (i < arraySize(sharpLookUpRight))
            {
                drColour ((m_displayHand != PB_PART_left) ? Cfg::noteColour() : Cfg::noteColourDim());
                pos = CStavePos(PB_PART_right, sharpLookUpRight[i]);
                drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX*i );
            }
            if (i < arraySize(sharpLookUpLeft))
            {
                drColour ((m_displayHand != PB_PART_right) ? Cfg::noteColour() : Cfg::noteColourDim());
                pos = CStavePos(PB_PART_left, sharpLookUpLeft[i]);
                drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX*i );
            }
            key--;
        }
        else
        {
            if (i < arraySize(flatLookUpRight))
            {
                drColour ((m_displayHand != PB_PART_left) ? Cfg::noteColour() : Cfg::noteColourDim());
                pos = CStavePos(PB_PART_right, flatLookUpRight[i]);
                drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX*i );
            }
            if (i < arraySize(flatLookUpLeft))
            {
                drColour ((m_displayHand != PB_PART_right) ? Cfg::noteColour() : Cfg::noteColourDim());
                pos = CStavePos(PB_PART_left, flatLookUpLeft[i]);
                drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX*i );
            }

            key++;
        }
        i++;
    }
}
Example #7
0
void TimeSig::draw(QPainter* painter) const
      {
      if (staff() && !staff()->staffType(tick())->genTimesig())
            return;
      painter->setPen(curColor());

      drawSymbols(ns, painter, pz, _scale);
      drawSymbols(ds, painter, pn, _scale);

      if (_largeParentheses) {
            drawSymbol(SymId::timeSigParensLeft,  painter, pointLargeLeftParen,  _scale.width());
            drawSymbol(SymId::timeSigParensRight, painter, pointLargeRightParen, _scale.width());
            }
      }
Example #8
0
void TimeSig::draw(QPainter* painter) const
      {
      if (staff() && !staff()->staffType(tick())->genTimesig())
            return;
      painter->setPen(curColor());
      std::vector<SymId> ns = toTimeSigString(_numeratorString);
      std::vector<SymId> ds = toTimeSigString(_denominatorString);

      drawSymbols(ns, painter, pz);
      drawSymbols(ds, painter, pn);
      if (_largeParentheses) {
            drawSymbol(SymId::timeSigParensLeft, painter, pointLargeLeftParen);
            drawSymbol(SymId::timeSigParensRight, painter, pointLargeRightParen);
            }
      }
Example #9
0
void CScore::drawScroll(bool refresh)
{
    if (refresh == false)
    {
        float topY = CStavePos(PB_PART_right, MAX_STAVE_INDEX).getPosY();
        float bottomY = CStavePos(PB_PART_left, MIN_STAVE_INDEX).getPosY();
        drColour (Cfg::backgroundColour());
        glRectf(Cfg::scrollStartX(), topY, Cfg::getAppWidth(), bottomY);
    }

    if (getCompileRedrawCount())
    {
        if (m_stavesDisplayListId == 0)
            m_stavesDisplayListId = glGenLists (1);

        glNewList (m_stavesDisplayListId, GL_COMPILE_AND_EXECUTE);
            drawSymbol(CSymbol(PB_SYMBOL_playingZone,  CStavePos(PB_PART_both, 0)), Cfg::playZoneX());
            drawStaves(Cfg::scrollStartX(), Cfg::staveEndX());
        glEndList ();
                // decrement the compile count until is reaches zero
        forceCompileRedraw(0);

    }
    else
        glCallList(m_stavesDisplayListId);

    drawScrollingSymbols(true);
    m_piano->drawPianoInput();
}
Example #10
0
void Clef::draw(QPainter* painter) const
      {
      if (symId == SymId::noSym || (staff() && !staff()->staffType()->genClef()))
            return;
      painter->setPen(curColor());
      drawSymbol(symId, painter);
      }
Example #11
0
void NoteDot::draw(QPainter* p) const
      {
      if (note() && note()->dotsHidden())     // don't draw dot if note is hidden
            return;
      if (!staff()->isTabStaff() || ((StaffTypeTablature*)staff()->staffType())->stemThrough()) {
            p->setPen(curColor());
            drawSymbol(SymId::augmentationDot, p);
            }
      }
Example #12
0
void Symbol::draw(QPainter* p) const
      {
      if (!isNoteDot() || !staff()->isTabStaff(tick())) {
            p->setPen(curColor());
            if (_scoreFont)
                  _scoreFont->draw(_sym, p, magS(), QPointF());
            else
                  drawSymbol(_sym, p);
            }
      }
Example #13
0
void CScore::drawScore()
{
    if (getCompileRedrawCount())
    {
        if (m_scoreDisplayListId == 0)
            m_scoreDisplayListId = glGenLists (1);

        glNewList (m_scoreDisplayListId, GL_COMPILE_AND_EXECUTE);
            drColour (Cfg::staveColour());

            drawSymbol(CSymbol(PB_SYMBOL_gClef, CStavePos(PB_PART_right, -1)), Cfg::clefX()); // The Treble Clef
            drawSymbol(CSymbol(PB_SYMBOL_fClef, CStavePos(PB_PART_left, 1)), Cfg::clefX());
            drawKeySignature(CStavePos::getKeySignature());
            drawStaves(Cfg::staveStartX(), Cfg::scrollStartX());
        glEndList ();
    }
    else
        glCallList(m_scoreDisplayListId);
}
Example #14
0
void Bracket::draw(QPainter* painter) const
{
    if (h2 == 0.0)
        return;
    if (bracketType() == BRACKET_BRACE) {
        painter->setPen(Qt::NoPen);
        painter->setBrush(QBrush(curColor()));
        painter->drawPath(path);
    }
    else if (bracketType() == BRACKET_NORMAL) {
        qreal h = 2 * h2;
        qreal _spatium = spatium();
        qreal w = score()->styleS(ST_bracketWidth).val() * _spatium;
        QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap);
        painter->setPen(pen);
        qreal bd   = _spatium * .25;
        painter->drawLine(QLineF(0.0, -bd, 0.0, h + bd));
        qreal x    =  -w * .5;
        qreal y1   = -bd;
        qreal y2   = h + bd;
        drawSymbol(SymId::bracketTop, painter, QPointF(x, y1));
        drawSymbol(SymId::bracketBottom, painter, QPointF(x, y2));
    }
    else if (bracketType() == BRACKET_SQUARE) {
        qreal h = 2 * h2;
        qreal _spatium = spatium();
        qreal w = score()->styleS(ST_staffLineWidth).val() * _spatium;
        QPen pen(curColor(), w, Qt::SolidLine, Qt::SquareCap);
        painter->setPen(pen);
        painter->drawLine(QLineF(0.0, 0.0, 0.0, h));
        painter->drawLine(QLineF(0.0, 0.0, w + .5 *_spatium, 0.0));
        painter->drawLine(QLineF(0.0, h  , w + .5 *_spatium, h));
    }
    else if (bracketType() == BRACKET_LINE) {
        qreal h = 2 * h2;
        qreal _spatium = spatium();
        qreal w = 0.67 * score()->styleS(ST_bracketWidth).val() * _spatium;
        QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap);
        painter->setPen(pen);
        qreal bd   = _spatium * .25;
        painter->drawLine(QLineF(0.0, -bd, 0.0, h + bd));
    }
}
Example #15
0
void Symbol::draw(QPainter* p) const
{
    if (type() != NOTEDOT || !staff()->isTabStaff()) {
        p->setPen(curColor());
        if (_scoreFont)
            _scoreFont->draw(_sym, p, magS(), QPointF());
        else
            drawSymbol(_sym, p);
    }
}
Example #16
0
void NoteDot::draw(QPainter* p) const
      {
      if (note() && note()->dotsHidden())     // don't draw dot if note is hidden
            return;
      int tick = note()->chord()->tick();
      if (!staff()->isTabStaff(tick) || staff()->staffType(tick)->stemThrough()) {
            p->setPen(curColor());
            drawSymbol(SymId::augmentationDot, p);
            }
      }
Example #17
0
void MSToggleButtonBase::redraw(void)
{
  if (owner()->mapped()==MSTrue)
   {
     MSWidgetCommon::drawBackground();
     if(highlighted()==MSTrue) drawHighlight();
     else undrawHighlight();
     drawSymbol();
     if (pixmap()==0) drawLabel();
     else drawPixmap();
   }
}
Example #18
0
void Plot2DProfile::drawSteps (QPainter *painter, const QwtScaleMap &xMap,
        const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const {
    QPen curvePen( m_defaultColor );
    curvePen.setStyle( m_penStyle );
    painter->setPen( curvePen );
    if ( from != to ){
        QwtPlotCurve::drawSteps( painter, xMap, yMap, canvasRect, from, to );
    }
    else {
        drawSymbol( painter, xMap, yMap, canvasRect, from, to );
    }
}
Example #19
0
QPixmap symbolChooser::createSymbol(int index, const triC& color) const {

  const int drawDimension = symbolDimension_ - 2 * borderDimension_;
  QPixmap drawSymbol(drawDimension, drawDimension);
  drawSymbol.fill(Qt::white);
  if (index < numberOfSymbols()) {
    QPainter painter(&drawSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    const int interval = unicodeCharacters_.size();
    // type1 symbol doesn't need further editing
    if (index >= interval && index < 2*interval) {
      index -= interval;
      createSymbolType2(&painter, drawDimension);
    }
    else if (index >= 2*interval && index < 3*interval) {
      index -= 2*interval;
      createSymbolType3(&painter, drawDimension);
    }
    else if (index >= 3*interval && index < 4*interval) {
      index -= 3*interval;
      createSymbolType4(&painter, drawDimension);
    }
    const QChar symbolChar = unicodeCharacters_[index];
    const QString symbolString(symbolChar);
    painter.setFont(unicodeFont_.qFont());
    const int heightBuffer = 2;
    ::setFontHeight(&painter, drawDimension - heightBuffer);
    const QRect textRect(0, heightBuffer/2, drawDimension,
                         drawDimension - heightBuffer/2);
    painter.drawText(textRect, Qt::AlignCenter, symbolString);
  }
  else { // no symbols left, so just make it the original color
    QPainter painter(&drawSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.fillRect(0, 0, drawDimension, drawDimension, color.qc());
  }

  if (borderDimension_) {
    QPixmap newSymbol(symbolDimension_, symbolDimension_);
    newSymbol.fill(color.qrgb());
    QPainter painter(&newSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.drawPixmap(QPoint(borderDimension_, borderDimension_),
                       drawSymbol);
    return newSymbol;
  }
  else {
    return drawSymbol;
  }
}
QgsLayerTreeModelLegendNode::ItemMetrics QgsLayerTreeModelLegendNode::draw( const QgsLegendSettings& settings, ItemContext* ctx )
{
    QFont symbolLabelFont = settings.style( QgsComposerLegendStyle::SymbolLabel ).font();

    double textHeight = settings.fontHeightCharacterMM( symbolLabelFont, QChar( '0' ) );
    // itemHeight here is not realy item height, it is only for symbol
    // vertical alignment purpose, i.e. ok take single line height
    // if there are more lines, thos run under the symbol
    double itemHeight = qMax(( double ) settings.symbolSize().height(), textHeight );

    ItemMetrics im;
    im.symbolSize = drawSymbol( settings, ctx, itemHeight );
    im.labelSize = drawSymbolText( settings, ctx, im.symbolSize );
    return im;
}
Example #21
0
void BW_LED_Number::display(char s ){
  
  QPainter p;     

  p.begin( this );
  
  old_symbol = current_symbol;
  old_segments = current_segments;
  current_symbol = s;
  current_segments = getSegments(s);

  drawSymbol(&p,s,FALSE);

  p.end();

}
Example #22
0
void Articulation::draw(QPainter* painter) const
      {
      SymId sym = _up ? articulationList[articulationType()].upSym : articulationList[articulationType()].downSym;
      int flags = articulationList[articulationType()].flags;
      if (staff()) {
            if (staff()->staffGroup() == TAB_STAFF_GROUP) {
                  if (!(flags & ARTICULATION_SHOW_IN_TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ARTICULATION_SHOW_IN_PITCHED_STAFF))
                        return;
                  }
            }
      painter->setPen(curColor());
      drawSymbol(sym, painter, QPointF(-0.5 * width(), _up ? 0.0 : height()));
      }
Example #23
0
void Articulation::draw(QPainter* painter) const
      {
      SymId sym = _up ? articulationList[int(articulationType())].upSym : articulationList[int(articulationType())].downSym;
      ArticulationShowIn flags = articulationList[int(articulationType())].flags;
      if (staff()) {
            if (staff()->staffGroup() == StaffGroup::TAB) {
                  if (!(flags & ArticulationShowIn::TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ArticulationShowIn::PITCHED_STAFF))
                        return;
                  }
            }
      painter->setPen(curColor());
      drawSymbol(sym, painter, QPointF(-0.5 * width(), 0.0));
      }
Example #24
0
void GlissandoSegment::draw(QPainter* painter) const
      {
      painter->save();
      qreal _spatium = spatium();

      QPen pen(glissando()->curColor());
      pen.setWidthF(glissando()->lineWidth().val() * spatium());
      pen.setCapStyle(Qt::RoundCap);
      painter->setPen(pen);
//      painter->drawLine(QPointF(), pos2());               // DEBUG

      // rotate painter so that the line become horizontal
      qreal w     = pos2().x();
      qreal h     = pos2().y();
      qreal l     = sqrt(w * w + h * h);
      qreal wi = asin(-h / l) * 180.0 / M_PI;
      painter->rotate(-wi);

      if (glissando()->glissandoType() == Glissando::Type::STRAIGHT) {
            painter->drawLine(QLineF(0.0, 0.0, l, 0.0));
            }
      else if (glissando()->glissandoType() == Glissando::Type::WAVY) {
            QRectF b = symBbox(SymId::wiggleTrill);
//            qreal h  = symHeight(SymId::wiggleTrill);     // DEBUG
            qreal w  = symWidth(SymId::wiggleTrill);
            int n    = (int)(l / w);      // always round down (truncate) to avoid overlap
            qreal x  = (l - n*w) * 0.5;   // centre line in available space
            drawSymbol(SymId::wiggleTrill, painter, QPointF(x, b.height()*.70), n);
            }
      if (glissando()->showText()) {
            const TextStyle& st = score()->textStyle(TextStyleType::GLISSANDO);
            QFont f = st.fontPx(_spatium);
            QRectF r = QFontMetricsF(f).boundingRect(glissando()->text());
            // if text longer than available space, skip it
            if (r.width() < l) {
                  qreal yOffset = r.height() + r.y();       // find text descender height
                  // raise text slightly above line and slightly more with WAVY than with STRAIGHT
                  yOffset += _spatium * (glissando()->glissandoType() == Glissando::Type::WAVY ? 0.5 : 0.1);
                  painter->setFont(f);
                  qreal x = (l - r.width()) * 0.5;
                  painter->drawText(QPointF(x, -yOffset), glissando()->text());
                  }
            }
      painter->restore();
      }
Example #25
0
void Tremolo::draw(QPainter* painter) const
      {
      if (tremoloType() == TremoloType::BUZZ_ROLL) {
            painter->setPen(curColor());
            drawSymbol(SymId::buzzRoll, painter);
            }
      else {
            painter->setBrush(QBrush(curColor()));
            painter->setPen(Qt::NoPen);
            painter->drawPath(path);
            }
      if ((parent() == 0) && !twoNotes()) {
            qreal x = 0.0; // bbox().width() * .25;
            QPen pen(curColor(), point(score()->styleS(Sid::stemWidth)));
            painter->setPen(pen);
            qreal _spatium = spatium() * mag();
            painter->drawLine(QLineF(x, -_spatium*.5, x, path.boundingRect().height() + _spatium));
            }
      }
Example #26
0
void Fermata::draw(QPainter* painter) const
      {
#if 0
      SymId sym = symId();
      FermataShowIn flags = articulationList[int(articulationType())].flags;
      if (staff()) {
            if (staff()->staffGroup() == StaffGroup::TAB) {
                  if (!(flags & FermataShowIn::TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & FermataShowIn::PITCHED_STAFF))
                        return;
                  }
            }
#endif
      painter->setPen(curColor());
      drawSymbol(_symId, painter, QPointF(-0.5 * width(), 0.0));
      }
Example #27
0
void ShadowNote::draw(QPainter* painter) const
      {
      if (!visible() || sym == SymId::noSym)
            return;

      QPointF ap(pagePos());
#if 0 // yet(?) unused
      QRect r(abbox().toRect());
#endif

      painter->translate(ap);
      qreal lw = point(score()->styleS(StyleIdx::ledgerLineWidth));
      InputState ps = score()->inputState();
      int voice;
      if (ps.drumNote() != -1 && ps.drumset() && ps.drumset()->isValid(ps.drumNote()))
            voice = ps.drumset()->voice(ps.drumNote());
      else
            voice = ps.voice();

      QPen pen(MScore::selectColor[voice].lighter(140), lw);
      painter->setPen(pen);

      drawSymbol(sym, painter);

      qreal ms = spatium();

      qreal x1 = symWidth(sym) * .5 - (ms * mag());
      qreal x2 = x1 + 2 * ms * mag();

      ms *= .5;
      if (_line < 100 && _line > -100 && !ps.rest()) {
            for (int i = -2; i >= _line; i -= 2) {
                  qreal y = ms * mag() * (i - _line);
                  painter->drawLine(QLineF(x1, y, x2, y));
                  }
            for (int i = 10; i <= _line; i += 2) {
                  qreal y = ms * mag() * (i - _line);
                  painter->drawLine(QLineF(x1, y, x2, y));
                  }
            }
      painter->translate(-ap);
      }
Example #28
0
void Stem::draw(QPainter* painter) const
      {
      // hide if second chord of a cross-measure pair
      if (chord() && chord()->crossMeasure() == CrossMeasure::SECOND)
            return;

      Staff* st = staff();
      bool useTab = st && st->isTabStaff();

      qreal lw = lineWidth();
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);

      if (!useTab || !chord())
            return;

      // TODO: adjust bounding rectangle in layout() for dots and for slash
      StaffType* stt = st->staffType();
      qreal sp = spatium();
      bool _up = up();

      // slashed half note stem
      if (chord()->durationType().type() == TDuration::DurationType::V_HALF && stt->minimStyle() == TablatureMinimStyle::SLASHED) {
            // position slashes onto stem
            qreal y = _up ? -(_len+_userLen) + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp : (_len+_userLen) - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp;
            // if stems through, try to align slashes within or across lines
            if (stt->stemThrough()) {
                  qreal halfLineDist = stt->lineDistance().val() * sp * 0.5;
                  qreal halfSlashHgt = STAFFTYPE_TAB_SLASH_2TOTHEIGHT * sp * 0.5;
                  y = lrint( (y + halfSlashHgt) / halfLineDist) * halfLineDist - halfSlashHgt;
                  }
            // draw slashes
            qreal hlfWdt= sp * STAFFTYPE_TAB_SLASH_WIDTH * 0.5;
            qreal sln   = sp * STAFFTYPE_TAB_SLASH_SLANTY;
            qreal thk   = sp * STAFFTYPE_TAB_SLASH_THICK;
            qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL;
            QPainterPath path;
            for (int i = 0; i < 2; ++i) {
                  path.moveTo( hlfWdt, y);            // top-right corner
                  path.lineTo( hlfWdt, y+thk);        // bottom-right corner
                  path.lineTo(-hlfWdt, y+thk+sln);    // bottom-left corner
                  path.lineTo(-hlfWdt, y+sln);        // top-left corner
                  path.closeSubpath();
                  y += displ;
                  }
            painter->setBrush(QBrush(curColor()));
            painter->setPen(Qt::NoPen);
            painter->drawPath(path);
            }

      // dots
      // NOT THE BEST PLACE FOR THIS?
      // with tablatures and stems beside staves, dots are not drawn near 'notes', but near stems
      int nDots = chord()->dots();
      if (nDots > 0 && !stt->stemThrough()) {
            qreal x     = chord()->dotPosX();
            qreal y     = ( (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN * 0.2) * sp) * (_up ? -1.0 : 1.0);
            qreal step  = score()->styleS(StyleIdx::dotDotDistance).val() * sp;
            for (int dot = 0; dot < nDots; dot++, x += step)
                  drawSymbol(SymId::augmentationDot, painter, QPointF(x, y));
            }
      }
Example #29
0
void Breath::draw(QPainter* p) const
      {
      p->setPen(curColor());
      drawSymbol(symList[_breathType], p);
      }
Example #30
0
void BarLine::draw(QPainter* painter) const
      {
      // get line length and do nothing if 0 (or near enough)
      qreal y1, y2;
      getY(&y1, &y2);
      if (y2-y1 < 0.1)
            return;

      qreal _spatium = score()->spatium();
      qreal lw = score()->styleS(StyleIdx::barWidth).val() * _spatium;

      QPen pen(curColor(), lw, Qt::SolidLine, Qt::FlatCap);
      painter->setPen(pen);

      switch(barLineType()) {
            case BarLineType::BROKEN:
                  pen.setStyle(Qt::DashLine);
                  painter->setPen(pen);
                  painter->drawLine(QLineF(lw * .5, y1, lw * .5, y2));
                  break;

            case BarLineType::DOTTED:
                  pen.setStyle(Qt::DotLine);
                  painter->setPen(pen);

            case BarLineType::NORMAL:
                  painter->drawLine(QLineF(lw * .5, y1, lw * .5, y2));
                  break;

            case BarLineType::END:
                  {
                  qreal lw2 = score()->styleS(StyleIdx::endBarWidth).val() * _spatium;
                  qreal d   = score()->styleS(StyleIdx::endBarDistance).val() * _spatium;

                  painter->drawLine(QLineF(lw * .5, y1, lw * .5, y2));
                  pen.setWidthF(lw2);
                  painter->setPen(pen);
                  qreal x = d + lw2 * .5 + lw;
                  painter->drawLine(QLineF(x, y1, x, y2));
                  }
                  break;

            case BarLineType::DOUBLE:
                  {
                  lw      = point(score()->styleS(StyleIdx::doubleBarWidth));
                  qreal d = point(score()->styleS(StyleIdx::doubleBarDistance));

                  pen.setWidthF(lw);
                  painter->setPen(pen);
                  qreal x = lw * .5;
                  painter->drawLine(QLineF(x, y1, x, y2));
                  x += d + lw;
                  painter->drawLine(QLineF(x, y1, x, y2));
                  }
                  break;

            case BarLineType::START_REPEAT:
                  {
                  qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth));
                  qreal d1  = point(score()->styleS(StyleIdx::endBarDistance));

                  qreal x2   =  lw2 * .5;                               // thick line (lw2)
                  qreal x1   =  lw2 + d1 + lw * .5;                     // thin line (lw)
                  qreal x0   =  lw2 + d1 + lw + d1;                     // dot position

                  drawDots(painter, x0);

                  painter->drawLine(QLineF(x1, y1, x1, y2));

                  pen.setWidthF(lw2);
                  painter->setPen(pen);
                  painter->drawLine(QLineF(x2, y1, x2, y2));

                  if (score()->styleB(StyleIdx::repeatBarTips)) {
                        drawSymbol(SymId::bracketTop, painter, QPointF(0.0, y1));
                        drawSymbol(SymId::bracketBottom, painter, QPointF(0.0, y2));
                        }
                  }
                  break;

            case BarLineType::END_REPEAT:
                  {
                  qreal lw2  = point(score()->styleS(StyleIdx::endBarWidth));
                  qreal d1   = point(score()->styleS(StyleIdx::endBarDistance));
                  qreal dotw = symWidth(SymId::repeatDot);
                  qreal x1   =  dotw + d1 + lw * .5;
                  qreal x2   =  dotw + d1 + lw + d1 + lw2 * .5;

                  drawDots(painter, 0.0);
                  painter->drawLine(QLineF(x1, y1, x1, y2));
                  pen.setWidthF(lw2);
                  painter->setPen(pen);
                  painter->drawLine(QLineF(x2, y1, x2, y2));

                  if (score()->styleB(StyleIdx::repeatBarTips)) {
                        qreal x = x2 + lw2 * .5;
                        qreal w1 = symBbox(SymId::reversedBracketTop).width();
                        drawSymbol(SymId::reversedBracketTop, painter, QPointF(x - w1, y1));
                        drawSymbol(SymId::reversedBracketBottom, painter, QPointF(x - w1, y2));
                        }
                  }
                  break;

            case BarLineType::END_START_REPEAT:
                  {
                  qreal lw2  = point(score()->styleS(StyleIdx::endBarWidth));
                  qreal d1   = point(score()->styleS(StyleIdx::endBarDistance));
                  qreal dotw = symWidth(SymId::repeatDot);

                  qreal x1   =  dotw + d1 + lw * .5;                                // thin bar
                  qreal x2   =  dotw + d1 + lw + d1 + lw2 * .5;                     // thick bar
                  qreal x3   =  dotw + d1 + lw + d1 + lw2 + d1 + lw * .5;           // thin bar
                  qreal x4   =  dotw + d1 + lw + d1 + lw2 + d1 + lw + d1;           // dot position

                  drawDots(painter, .0);
                  drawDots(painter, x4);
                  painter->drawLine(QLineF(x1, y1, x1, y2));

                  pen.setWidthF(lw2);
                  painter->setPen(pen);
                  painter->drawLine(QLineF(x2, y1, x2, y2));

                  pen.setWidthF(lw);
                  painter->setPen(pen);
                  painter->drawLine(QLineF(x3, y1, x3, y2));

                  if (score()->styleB(StyleIdx::repeatBarTips)) {
                        qreal x = x2;
                        qreal w1 = symBbox(SymId::reversedBracketTop).width();
                        drawSymbol(SymId::bracketTop, painter, QPointF(x, y1));
                        drawSymbol(SymId::bracketBottom, painter, QPointF(x, y2));
                        drawSymbol(SymId::reversedBracketTop, painter, QPointF(x - w1, y1));
                        drawSymbol(SymId::reversedBracketBottom, painter, QPointF(x - w1, y2));
                        }
                  }
                  break;
            }
      }