Пример #1
0
void Stem::draw(QPainter* painter) const
      {
      bool useTab = false;
      Staff* st = staff();
      if (st && st->isTabStaff()) {     // stems used in palette do not have a staff
            if (st->staffType()->slashStyle())
                  return;
            useTab = true;
            }
      qreal lw = point(score()->styleS(ST_stemWidth));
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);

      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      // TODO: adjust bounding rectangle in layout()
      if (useTab) {
            int nDots = chord()->dots();
            if (nDots > 0) {
                  qreal sp = spatium();
                  qreal y = stemLen() - ( ((StaffTypeTablature*)st->staffType())->stemsDown() ?
                              (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
                  symbols[score()->symIdx()][dotSym].draw(painter, magS(),
                              QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
                  }
            }
      }
Пример #2
0
void Stem::draw(QPainter* painter) const
      {
      Staff* st = staff();
      bool useTab = st && st->isTabStaff();

      if (useTab && st->staffType()->slashStyle())
            return;
      qreal lw = lineWidth();
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);
      if (!useTab)
            return;

      // TODO: adjust bounding rectangle in layout() for dots and for slash
      StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType());
      qreal sp = spatium();

      // slashed half note stem
      if (chord() && chord()->durationType().type() == TDuration::V_HALF
         && stt->minimStyle() == TAB_MINIM_SLASHED) {
            qreal wdt   = sp * STAFFTYPE_TAB_SLASH_WIDTH;
            qreal sln   = sp * STAFFTYPE_TAB_SLASH_SLANTY;
            qreal thk   = sp * STAFFTYPE_TAB_SLASH_THICK;
            qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL;
            QPainterPath path;

            qreal y = stt->stemsDown() ?
                         _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp :
                        -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp;
            for (int i = 0; i < 2; ++i) {
                  path.moveTo( wdt*0.5-lw, y);        // top-right corner
                  path.lineTo( wdt*0.5-lw, y+thk);    // bottom-right corner
                  path.lineTo(-wdt*0.5,    y+thk+sln);// bottom-left corner
                  path.lineTo(-wdt*0.5,    y+sln);    // top-left corner
                  path.closeSubpath();
                  y += displ;
                  }
//            setbbox(path.boundingRect());
            painter->setBrush(QBrush(curColor()));
            painter->setPen(Qt::NoPen);
            painter->drawPath(path);
            }

      // dots
      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      int nDots = chord()->dots();
      if (nDots > 0) {
            qreal y = stemLen() - (stt->stemsDown() ?
                        (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
            symbols[score()->symIdx()][dotSym].draw(painter, magS(),
                        QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
            }
      }
Пример #3
0
void Stem::draw(Painter* painter) const
      {
      bool useTab = false;
      Staff* st = staff();
      if (st && st->useTablature()) {     // stems used in palette do not have a staff
            useTab = true;
            if (st->staffType()->slashStyle())
                  return;
            }
      qreal lw = point(score()->styleS(ST_stemWidth));
      painter->setLineWidth(lw);
      painter->setCapStyle(Qt::RoundCap);
      painter->drawLine(0.0, 0.0, 0.0, stemLen());
      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      if (useTab) {
            int nDots = chord()->dots();
            if (nDots > 0)
                  symbols[score()->symIdx()][dotSym].draw(painter, magS(), spatium(), stemLen(), nDots);
            }
      }
Пример #4
0
void Stem::updateGrips(int* grips, QRectF* grip) const
      {
      *grips   = 1;
      QPointF p(0.0, stemLen());
      grip[0].translate(pagePos() + p);
      }