• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ spatium函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中spatium函数的典型用法代码示例。如果您正苦于以下问题:C++ spatium函数的具体用法?C++ spatium怎么用?C++ spatium使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了spatium函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spatium

void Arpeggio::draw(QPainter* p) const
      {
      qreal _spatium = spatium();

      p->setPen(curColor());
      qreal y1 = _spatium - _userLen1;
      qreal y2 = _height  + _userLen2;
      qreal x1;
      qreal m = magS();
      switch (subtype()) {
            case ArpeggioType::NORMAL:
                  for (qreal y = y1; y < y2; y += _spatium)
                        symbols[score()->symIdx()][arpeggioSym].draw(p, m, QPointF(0.0, y));
                  break;

            case ArpeggioType::UP:
                  symbols[score()->symIdx()][arpeggioarrowupSym].draw(p, m, QPointF(0.0, y1));
                  for (qreal y = y1 + _spatium; y < y2; y += _spatium)
                        symbols[score()->symIdx()][arpeggioSym].draw(p, m, QPointF(0.0, y));
                  break;

            case ArpeggioType::DOWN:
                  {
                  qreal y = y1;
                  for (; y < y2 - _spatium; y += _spatium)
                        symbols[score()->symIdx()][arpeggioSym].draw(p, m, QPointF(0.0, y));
                  symbols[score()->symIdx()][arpeggioarrowdownSym].draw(p, m, QPointF(0.0, y));
                  }
                  break;

            case ArpeggioType::UP_STRAIGHT:
                  y1-= _spatium * .5;
                  x1 = _spatium * .5;
                  symbols[score()->symIdx()][close11arrowHeadSym].draw(p, m, QPointF(x1, y1 - (_spatium * .5)));
                  p->save();
                  p->setPen(QPen(curColor(),
                     score()->styleS(ST_ArpeggioLineWidth).val() * _spatium,
                     Qt::SolidLine, Qt::RoundCap));
                  p->drawLine(QLineF(x1, y1, x1, y2));
                  p->restore();
                  break;

            case ArpeggioType::DOWN_STRAIGHT:
                  y1-= _spatium;
                  y2-= _spatium * .5;
                  x1 = _spatium * .5;
                  symbols[score()->symIdx()][close1M1arrowHeadSym].draw(p, m, QPointF(x1, y2 + (_spatium * .5)));
                  p->save();
                  p->setPen(QPen(curColor(),
                     score()->styleS(ST_ArpeggioLineWidth).val() * _spatium,
                     Qt::SolidLine, Qt::RoundCap));
                  p->drawLine(QLineF(x1, y1, x1, y2));
                  p->restore();
                  break;

            case ArpeggioType::BRACKET:
                  {
                  y1 = - _userLen1;
                  y2 = _height + _userLen2;
                  p->save();

                  p->setPen(QPen(curColor(),
                     score()->styleS(ST_ArpeggioLineWidth).val() * _spatium,
                     Qt::SolidLine, Qt::RoundCap));

                  qreal w = score()->styleS(ST_ArpeggioHookLen).val() * _spatium;
                  p->drawLine(QLineF(0.0, y1, 0.0, y2));
                  p->drawLine(QLineF(0.0, y1, w, y1));
                  p->drawLine(QLineF(0.0, y2, w, y2));
                  p->restore();
                  }
                  break;
            }
      }
开发者ID:parinporecha,项目名称:MuseScore,代码行数:74,代码来源:arpeggio.cpp


示例2: rypos

void HairpinSegment::layout()
      {
      if (hairpin()->useTextLine()) {
            if (parent())
                  rypos() += score()->styleS(StyleIdx::hairpinY).val() * spatium();
            TextLineSegment::layout();
            return;
            }

      QTransform t;
      qreal _spatium = spatium();
      qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5;
      qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5;

      qreal len;
      qreal x = pos2().x();
      if (x < _spatium)             // minimum size of hairpin
            x = _spatium;
      qreal y = pos2().y();
      len     = sqrt(x * x + y * y);
      t.rotateRadians(asin(y/len));

      drawCircledTip =  hairpin()->hairpinCircledTip();
      circledTipRadius = 0;
      if( drawCircledTip )
        circledTipRadius  = 0.6 * _spatium * .5;
      if (hairpin()->hairpinType() == Hairpin::Type::CRESCENDO) {
            // crescendo
            switch (spannerSegmentType()) {
                  case SpannerSegmentType::SINGLE:
                  case SpannerSegmentType::BEGIN:
                        l1.setLine(.0 + circledTipRadius*2, .0, len, h1);
                        l2.setLine(.0 + circledTipRadius*2, .0, len, -h1);
                        circledTip.setX( 0 + circledTipRadius );
                        circledTip.setY( 0 );
                        break;
                  case SpannerSegmentType::MIDDLE:
                  case SpannerSegmentType::END:
                        drawCircledTip = false;
                        l1.setLine(.0,  h2, len, h1);
                        l2.setLine(.0, -h2, len, -h1);
                        break;
                  }
            }
      else {
            // decrescendo
            switch(spannerSegmentType()) {
                  case SpannerSegmentType::SINGLE:
                  case SpannerSegmentType::END:
                        l1.setLine(.0,  h1, len - circledTipRadius*2, 0.0);
                        l2.setLine(.0, -h1, len - circledTipRadius*2, 0.0);
                        circledTip.setX( len - circledTipRadius );
                        circledTip.setY( 0 );
                        break;
                  case SpannerSegmentType::BEGIN:
                  case SpannerSegmentType::MIDDLE:
                        drawCircledTip = false;
                        l1.setLine(.0,  h1, len, + h2);
                        l2.setLine(.0, -h1, len, - h2);
                        break;
                  }
            }
// Do Coord rotation
      l1 = t.map(l1);
      l2 = t.map(l2);
      if( drawCircledTip )
        circledTip = t.map(circledTip);


      QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized();
      qreal w = point(score()->styleS(StyleIdx::hairpinLineWidth));
      setbbox(r.adjusted(-w*.5, -w*.5, w, w));
      if (parent())
            rypos() += score()->styleS(StyleIdx::hairpinY).val() * _spatium;
      adjustReadPos();
      }
开发者ID:sidchatterjee,项目名称:MuseScore,代码行数:76,代码来源:hairpin.cpp


示例3: spatium

void Slur::computeBezier(SlurSegment* ss, QPointF p6o)
      {
      qreal _spatium  = spatium();
      qreal shoulderW;              // height as fraction of slur-length
      qreal shoulderH;
      //
      // p1 and p2 are the end points of the slur
      //
      QPointF pp1 = ss->ups[GRIP_START].p + ss->ups[GRIP_START].off * _spatium;
      QPointF pp2 = ss->ups[GRIP_END].p   + ss->ups[GRIP_END].off   * _spatium;

      QPointF p2 = pp2 - pp1;
      if (p2.x() == 0.0) {
            qDebug("zero slur");
            Measure* m1 = startChord()->segment()->measure();
            Measure* m2 = endChord()->segment()->measure();
            Page* page = m1->system()->page();
            qDebug("   at tick %d in measure %d-%d page %d",
               m1->tick(), m1->no(), m2->no(), page->no());
            return;
            }

      qreal sinb = atan(p2.y() / p2.x());
      QTransform t;
      t.rotateRadians(-sinb);
      p2  = t.map(p2);
      p6o = t.map(p6o);

      double smallH = 0.5;
      qreal d = p2.x() / _spatium;
      if (d <= 2.0) {
            shoulderH = d * 0.5 * smallH * _spatium;
            shoulderW = .6;
            }
      else {
            qreal dd = log10(1.0 + (d - 2.0) * .5) * 2.0;
            if (dd > 3.0)
                  dd = 3.0;
            shoulderH = (dd + smallH) * _spatium;
            if (d > 18.0)
                  shoulderW = 0.8;
            else if (d > 10)
                  shoulderW = 0.7;
            else
                  shoulderW = 0.6;
            }

      if (!up())
            shoulderH = -shoulderH;
//      shoulderH -= p6o.y();

      qreal c    = p2.x();
      qreal c1   = (c - c * shoulderW) * .5 + p6o.x();
      qreal c2   = c1 + c * shoulderW       + p6o.x();

      QPointF p5 = QPointF(c * .5, 0.0);

      QPointF p3(c1, -shoulderH);
      QPointF p4(c2, -shoulderH);

      qreal w = (score()->styleS(ST_SlurMidWidth).val() - score()->styleS(ST_SlurEndWidth).val()) * _spatium;
      if (((c2 - c1) / _spatium) <= _spatium)
            w *= .5;
      QPointF th(0.0, w);    // thickness of slur

      QPointF p3o = p6o + t.map(ss->ups[GRIP_BEZIER1].off * _spatium);
      QPointF p4o = p6o + t.map(ss->ups[GRIP_BEZIER2].off * _spatium);

//??      ss->ups[GRIP_BEZIER1].off = t.inverted().map(p3o) / _spatium;
//??      ss->ups[GRIP_BEZIER2].off = t.inverted().map(p4o) / _spatium;

      //-----------------------------------calculate p6
      QPointF pp3  = p3 + p3o;
      QPointF pp4  = p4 + p4o;
      QPointF ppp4 = pp4 - pp3;

      qreal r2 = atan(ppp4.y() / ppp4.x());
      t.reset();
      t.rotateRadians(-r2);
      QPointF p6  = QPointF(t.map(ppp4).x() * .5, 0.0);

      t.rotateRadians(2 * r2);
      p6 = t.map(p6) + pp3; //  - p6o;
      //-----------------------------------

      ss->path = QPainterPath();
      ss->path.moveTo(QPointF());
      ss->path.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
      if (lineType() == 0)
            ss->path.cubicTo(p4 +p4o + th, p3 + p3o + th, QPointF());

      th = QPointF(0.0, 3.0 * w);
      ss->shapePath = QPainterPath();
      ss->shapePath.moveTo(QPointF());
      ss->shapePath.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
      ss->shapePath.cubicTo(p4 +p4o + th, p3 + p3o + th, QPointF());

      // translate back
      t.reset();
      t.translate(pp1.x(), pp1.y());
//.........这里部分代码省略.........
开发者ID:Archer90,项目名称:MuseScore,代码行数:101,代码来源:slur.cpp


示例4: o

void Text::layout1()
      {
      if (styled() && !_editMode)
            SimpleText::layout();
      else {
            _doc->setDefaultFont(textStyle().font(spatium()));
            qreal w = -1.0;
            QPointF o(textStyle().offset(spatium()));

            if (parent() && layoutToParentWidth()) {
                  Element* e = parent();
                  w = e->width();
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        Box* b = static_cast<Box*>(e);
                        w -= ((b->leftMargin() + b->rightMargin()) * MScore::DPMM);
                        }
                  }

            QTextOption to = _doc->defaultTextOption();
            to.setUseDesignMetrics(true);
            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
            _doc->setDefaultTextOption(to);

            if (w <= 0.0)
                  w = _doc->idealWidth();
            _doc->setTextWidth(w);

            QSizeF size(_doc->size());

            if (align() & ALIGN_BOTTOM)
                  o.ry() -= size.height();
            else if (align() & ALIGN_VCENTER)
                  o.ry() -= (size.height() * .5);
            else if (align() & ALIGN_BASELINE)
                  o.ry() -= baseLine();

            if (align() & ALIGN_RIGHT)
                  o.rx() -= size.width();
            else if (align() & ALIGN_HCENTER)
                  o.rx() -= (size.width() * .5);

            setbbox(QRectF(QPointF(0.0, 0.0), size));
            _doc->setModified(false);
            setPos(o);
            }
      if (parent()) {
            Element* e = parent();
            qreal w, h, xo, yo;
            if (layoutToParentWidth()) {
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        // consider inner margins of frame
                        Box* b = static_cast<Box*>(e);
                        xo = b->leftMargin() * MScore::DPMM;
                        yo = b->topMargin()  * MScore::DPMM;
                        w  = b->width()  - xo - b->rightMargin() * MScore::DPMM;
                        h  = b->height() - yo - b->bottomMargin()   * MScore::DPMM;
                        }
                  else {
                        w  = e->width();
                        h  = e->height();
                        xo = 0.0;
                        yo = 0.0;
                        }
                  QPointF ro(_textStyle.reloff() * .01);
                  rxpos() += xo + ro.x() * w;
                  rypos() += yo + ro.y() * h;
                  }
            if (e->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(e);
                  rypos() += s->measure()->system()->staff(staffIdx())->y();
                  }
            }

      if (hasFrame())
            layoutFrame();
      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:76,代码来源:text.cpp


示例5: QFontMetricsF

qreal Text::lineSpacing() const
      {
      return QFontMetricsF(textStyle().font(spatium())).lineSpacing();
      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:4,代码来源:text.cpp


示例6: frontSegment


//.........这里部分代码省略.........
            //
            if (!spannerSegments().isEmpty()) {
                  LineSegment* s = frontSegment();
                  s->layout();
                  setbbox(s->bbox());
                  }
            return;
            }
      if (startElement() == 0 || endElement() == 0) {
            qDebug("SLine::layout() failed: %s %s\n", parent()->name(), name());
            qDebug("   start %p   end %p\n", startElement(), endElement());
            return;
            }

      System* s1;
      System* s2;
      QPointF p1 = linePos(GRIP_LINE_START, &s1);
      QPointF p2 = linePos(GRIP_LINE_END,   &s2);

      QList<System*>* systems = score()->systems();
      int sysIdx1 = systems->indexOf(s1);
      int sysIdx2 = systems->indexOf(s2);
      int segmentsNeeded = 0;
      for (int i = sysIdx1; i < sysIdx2+1;  ++i) {
            if (systems->at(i)->isVbox())
                  continue;
            ++segmentsNeeded;
            }
      int segCount = spannerSegments().size();

      if (segmentsNeeded != segCount) {
            if (segmentsNeeded > segCount) {
                  int n = segmentsNeeded - segCount;
                  for (int i = 0; i < n; ++i) {
                        LineSegment* ls = createLineSegment();
                        add(ls);
                        // set user offset to previous segment's offset
                        if (segCount > 0)
                              ls->setUserOff(QPointF(0, segmentAt(segCount+i-1)->userOff().y()));
                        }
                  }
            else {
                  int n = segCount - segmentsNeeded;
                  qDebug("SLine: segments %d needed %d, remove %d\n", segCount, segmentsNeeded, n);
                  for (int i = 0; i < n; ++i) {
                        if (spannerSegments().isEmpty()) {
                              qDebug("SLine::layout(): no segment %d, %d expected\n", i, n);
                              break;
                              }
                        else {
                              // LineSegment* seg = takeLastSegment();
                              // TODO delete seg;
                              }
                        }
                  }
            }

      int segIdx = 0;
      int si  = staffIdx();
      for (int i = sysIdx1; i <= sysIdx2; ++i) {
            System* system = systems->at(i);
            if (system->isVbox())
                  continue;
            LineSegment* seg = segmentAt(segIdx++);
            seg->setSystem(system);

            Measure* m = system->firstMeasure();
            qreal x1 = m->first(SegChordRest)->pos().x() + m->pos().x();
            qreal x2 = system->bbox().right();
            qreal y  = system->staff(si)->y();

            if (sysIdx1 == sysIdx2) {
                  // single segment
                  seg->setSubtype(SEGMENT_SINGLE);
                  seg->setPos(p1);
                  seg->setPos2(QPointF(p2.x() - p1.x(), 0.0));
                  }
            else if (i == sysIdx1) {
                  // start segment
                  seg->setSubtype(SEGMENT_BEGIN);
                  seg->setPos(p1);
                  seg->setPos2(QPointF(x2 - p1.x(), 0.0));
                  }
            else if (i > 0 && i != sysIdx2) {
                  // middle segment
                  seg->setSubtype(SEGMENT_MIDDLE);
                  seg->setPos(QPointF(x1, y));
                  seg->setPos2(QPointF(x2 - x1, 0.0));
                  }
            else if (i == sysIdx2) {
                  // end segment
                  seg->setSubtype(SEGMENT_END);
                  seg->setPos(QPointF(x1, y));
                  seg->setPos2(QPointF(p2.x() - x1, 0.0));
                  }
            seg->layout();
            seg->rypos() += (_yoffset * spatium());
            seg->adjustReadPos();
            }
      }
开发者ID:guifre2,项目名称:MuseScore,代码行数:101,代码来源:line.cpp


示例7: Space

Space Glissando::space() const
      {
      return Space(0.0, spatium() * 2.0);
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:4,代码来源:glissando.cpp


示例8: spatium

void Tremolo::layout()
      {
      qreal _spatium  = spatium();

      qreal w2  = _spatium * score()->styleS(StyleIdx::tremoloWidth).val() * .5;
      qreal h2  = _spatium * score()->styleS(StyleIdx::tremoloBoxHeight).val()  * .5;
      qreal lw  = _spatium * score()->styleS(StyleIdx::tremoloStrokeWidth).val();
      qreal td  = _spatium * score()->styleS(StyleIdx::tremoloDistance).val();
      path      = QPainterPath();

      qreal ty   = 0.0;
      for (int i = 0; i < _lines; ++i) {
            path.moveTo(-w2,  ty + h2 - lw);
            path.lineTo( w2,  ty - h2);
            path.lineTo( w2,  ty - h2 + lw);
            path.lineTo(-w2,  ty + h2);

            path.closeSubpath();
            ty += td;
            }

      QRectF rect = path.boundingRect();
      if ((parent() == 0) && !twoNotes())
            rect.setHeight(rect.height() + _spatium);
      setbbox(rect);

      _chord1 = static_cast<Chord*>(parent());
      if (_chord1 == 0)
            return;
      Note* anchor1 = _chord1->upNote();
      Stem* stem    = _chord1->stem();
      qreal x, y, h;
      if (stem) {
            x  = stem->pos().x();
            y  = stem->pos().y();
            h  = stem->stemLen();
            }
      else {
            // center tremolo above note
            x = anchor1->x() + anchor1->headWidth() * .5;
            y = anchor1->y();
            h = 2.0 * _spatium + bbox().height();
            if (anchor1->line() > 4)
                  h *= -1;
            }
      if (!twoNotes()) {
            //
            // single note tremolos
            //
            bool up = _chord1->up();
            int line = up ? _chord1->upLine() : _chord1->downLine();
            static const qreal t[3][2][4][2] = {
                  // normal stem
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 6,           5          },  // line 1
                        { 6 - 2 * .8,  5 - 2 * .8 },  // line 2
                        { 6 - 4 * .8,  3          },  // line 3
                        { 2         ,  3          }   // line 4
                        },
                     // UP
                     {
                        // even line   odd line
                        { -6,          -5          },  // line 1
                        { -6,          -5          },  // line 2
                        { -6,          -3 - 4 * .8 },  // line 3
                        { -2 - 6 * .8, -3 - 6 * .8 }   // line 4
                        }
                     },
                  // stem with hook
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 3,           3          },  // line 1
                        { 2,           2          },  // line 2
                        { 2,           2          },  // line 3
                        { 2,           2          }   // line 4
                        },
                     // UP
                     {
                        // even line   odd line
                        { -3,          -3          },  // line 1
                        { -2 - 2 * .8, -2 - 2 * .8 },  // line 2
                        { -2 - 4 * .8, -2 - 4 * .8 },  // line 3
                        { -2 - 6 * .8, -2 - 6 * .8 }   // line 4
                        }
                     },
                  // stem with beam
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 3,           3          },  // line 1
                        { 2,           2          },  // line 2
                        { 2,           2          },  // line 3
                        { 2,           2          }   // line 4
                        },
//.........这里部分代码省略.........
开发者ID:cardinot,项目名称:MuseScore,代码行数:101,代码来源:tremolo.cpp


示例9: spatium

void Tremolo::layout()
      {
      qreal _spatium  = spatium() * mag();

      qreal w2  = _spatium * score()->styleS(StyleIdx::tremoloWidth).val() * .5;
      qreal lw  = _spatium * score()->styleS(StyleIdx::tremoloStrokeWidth).val();
      qreal td  = _spatium * score()->styleS(StyleIdx::tremoloDistance).val();
      path      = QPainterPath();

      qreal ty   = 0.0;

      for (int i = 0; i < _lines; i++) {
            path.addRect(-w2, ty, 2.0 * w2, lw);
            ty += td;
            }

      // QRectF rect = path.boundingRect();
      // if ((parent() == 0) && !twoNotes())
      //       rect.setHeight(rect.height() + _spatium);

      _chord1 = static_cast<Chord*>(parent());
      if (_chord1 == 0) {
            // just for the palette
            QTransform shearTransform;
            shearTransform.shear(0.0, -(lw / 2.0) / w2);
            path = shearTransform.map(path);
            setbbox(path.boundingRect());
            addbbox(QRectF(bbox().x(), bbox().bottom(), bbox().width(), _spatium));
            return;
            }
      Note* anchor1 = _chord1->upNote();
      Stem* stem    = _chord1->stem();
      qreal x, y, h;
      if (stem) {
            x  = stem->pos().x();
            y  = stem->pos().y();
            h  = stem->stemLen();
            }
      else {
            // center tremolo above note
            x = anchor1->x() + anchor1->headWidth() * .5;
            y = anchor1->y();
            h = 2.0 * _spatium + bbox().height();
            if (anchor1->line() > 4)
                  h *= -1;
            }
      if (!twoNotes()) {
            //
            // single note tremolos
            //
            bool up = _chord1->up();
            int line = up ? _chord1->upLine() : _chord1->downLine();
            static const qreal t[3][2][4][2] = {
                  // normal stem
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 6,           5          },  // line 1
                        { 6 - 2 * .8,  5 - 2 * .8 },  // line 2
                        { 6 - 4 * .8,  3          },  // line 3
                        { 2         ,  3          }   // line 4
                        },
                     // UP
                     {
                        // even line   odd line
                        { -6,          -5          },  // line 1
                        { -6,          -5          },  // line 2
                        { -6,          -3 - 4 * .8 },  // line 3
                        { -2 - 6 * .8, -3 - 6 * .8 }   // line 4
                        }
                     },
                  // stem with hook
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 3,           3          },  // line 1
                        { 2,           2          },  // line 2
                        { 2,           2          },  // line 3
                        { 2,           2          }   // line 4
                        },
                     // UP
                     {
                        // even line   odd line
                        { -3,          -3          },  // line 1
                        { -2 - 2 * .8, -2 - 2 * .8 },  // line 2
                        { -2 - 4 * .8, -2 - 4 * .8 },  // line 3
                        { -2 - 6 * .8, -2 - 6 * .8 }   // line 4
                        }
                     },
                  // stem with beam
                  {
                     // DOWN
                     {
                        // even line   odd line
                        { 3,           3          },  // line 1
                        { 2,           2          },  // line 2
                        { 2,           2          },  // line 3
                        { 2,           2          }   // line 4
//.........这里部分代码省略.........
开发者ID:AntonioBL,项目名称:MuseScore,代码行数:101,代码来源:tremolo.cpp


示例10: spatium

void HairpinSegment::layout()
      {
      Dynamic* sd = 0;
      Dynamic* ed = 0;
      qreal _spatium = spatium();

      if (autoplace()) {
            setUserOff(QPointF());
            setUserOff2(QPointF());
            }
      if (isSingleType() || isBeginType()) {
            sd = lookupDynamic(hairpin()->startElement());
            if (sd) {
                  if (autoplace()) {
                        qreal dx        = sd->bbox().right() + sd->pos().x()
                                             + sd->segment()->pos().x() + sd->measure()->pos().x();
                        // hardcoded distance between Dynamic and Hairpin: 0.5sp
                        qreal dist      = dx - pos().x() + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
                        rUserXoffset()  = dist;
                        rUserXoffset2() = -dist;
                        }
                  else
                        sd->doAutoplace();
                  }
            }
      if (isSingleType() || isEndType()) {
            ed = lookupDynamic(hairpin()->endElement());
            if (ed) {
                  if (autoplace()) {
                        rUserXoffset2() -= ed->bbox().width();
                        qreal dx         = ed->bbox().left() + ed->pos().x()
                                           + ed->segment()->pos().x() + ed->measure()->pos().x();
                        // hardcoded distance between Hairpin and Dynamic: 0.5sp
                        ed->rUserXoffset() = pos2().x() + pos().x() - dx + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance);
                        }
                  else
                        ed->doAutoplace();
                  }
            }

      Hairpin::Type type = hairpin()->hairpinType();
      if (type == Hairpin::Type::DECRESC_LINE || type == Hairpin::Type::CRESC_LINE) {
            twoLines = false;
            TextLineSegment::layout();
            drawCircledTip = false;
            if (parent())
                  rypos() += score()->styleP(StyleIdx::hairpinY);
            }
      else {
            delete _text;
            delete _endText;
            _text    = 0;
            _endText = 0;

            QTransform t;
            qreal h1 = hairpin()->hairpinHeight().val()     * spatium() * .5;
            qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5;

            qreal len;
            qreal x = pos2().x();
            if (x < _spatium)             // minimum size of hairpin
                  x = _spatium;
            qreal y = pos2().y();
            len     = sqrt(x * x + y * y);
            t.rotateRadians(asin(y/len));

            drawCircledTip   =  hairpin()->hairpinCircledTip();
            circledTipRadius = drawCircledTip ? 0.6 * _spatium * .5 : 0.0;

            QLine l1, l2;
            twoLines  = true;

            switch (type) {
                  case Hairpin::Type::CRESC_HAIRPIN: {
                        switch (spannerSegmentType()) {
                              case SpannerSegmentType::SINGLE:
                              case SpannerSegmentType::BEGIN:
                                    l1.setLine(circledTipRadius * 2.0, 0.0, len, h1);
                                    l2.setLine(circledTipRadius * 2.0, 0.0, len, -h1);
                                    circledTip.setX(circledTipRadius );
                                    circledTip.setY(0.0);
                                    break;

                              case SpannerSegmentType::MIDDLE:
                              case SpannerSegmentType::END:
                                    drawCircledTip = false;
                                    l1.setLine(.0,  h2, len, h1);
                                    l2.setLine(.0, -h2, len, -h1);
                                    break;
                              }
                        }
                        break;
                  case Hairpin::Type::DECRESC_HAIRPIN: {
                        switch(spannerSegmentType()) {
                              case SpannerSegmentType::SINGLE:
                              case SpannerSegmentType::END:
                                    l1.setLine(0.0,  h1, len - circledTipRadius * 2, 0.0);
                                    l2.setLine(0.0, -h1, len - circledTipRadius * 2, 0.0);
                                    circledTip.setX(len - circledTipRadius);
                                    circledTip.setY(0.0);
//.........这里部分代码省略.........
开发者ID:shredpub,项目名称:MuseScore,代码行数:101,代码来源:hairpin.cpp


示例11: score

void Clef::layout1()
      {
      qreal smag     = _small ? score()->style(ST_smallClefMag).toDouble() : 1.0;
      qreal _spatium = spatium();
      qreal msp      = _spatium * smag;
      qreal yoff     = 0.0;

      qDeleteAll(elements);
      elements.clear();

      Symbol* symbol = new Symbol(score());

      switch (curClefType) {
      case CLEF_G:                              // G clef on 2nd line
            symbol->setSym(trebleclefSym);
            yoff = 3.0 * curLineDist;
            break;
      case CLEF_G1:                             // G clef 8va on 2nd line
            {
            symbol->setSym(trebleclefSym);
            yoff = 3.0 * curLineDist;
            Symbol* number = new Symbol(score());
            number->setMag(smag);
            number->setSym(clefEightSym);
            addElement(number, 1.0 * msp, -5.0 * msp + yoff * _spatium);
            }
            break;
      case CLEF_G2:                             // G clef 15ma on 2nd line
            {
            symbol->setSym(trebleclefSym);
            yoff = 3.0 * curLineDist;
            Symbol* number = new Symbol(score());
            symbol->setMag(smag);
            number->setSym(clefOneSym);
            addElement(number, .6 * msp, -5.0 * msp + yoff * _spatium);
            number = new Symbol(score());
            number->setSym(clefFiveSym);
            addElement(number, 1.4 * msp, -5.0 * msp + yoff * _spatium);
            }
            break;
      case CLEF_G3:                             // G clef 8va bassa on 2nd line
            {
            symbol->setSym(trebleclefSym);
            yoff = 3.0 * curLineDist;
            Symbol* number = new Symbol(score());
            symbol->setMag(smag);
            number->setSym(clefEightSym);
            addElement(number, 1.0 * msp, 4.0 * msp + yoff * _spatium);
            }
            break;
      case CLEF_F:                              // F clef on penultimate line
            symbol->setSym(bassclefSym);
            yoff = 1.0 * curLineDist;
            break;
      case CLEF_F8:                             // F clef 8va bassa on penultimate line
            {
            symbol->setSym(bassclefSym);
            yoff = 1.0 * curLineDist;
            Symbol* number = new Symbol(score());
            symbol->setMag(smag);
            number->setSym(clefEightSym);
            addElement(number, .0, 4.5 * msp + yoff * _spatium);
            }
            break;
      case CLEF_F15:                            // F clef 15ma bassa on penultimate line
            {
            symbol->setSym(bassclefSym);
            yoff = 1.0 * curLineDist;
            Symbol* number = new Symbol(score());
            symbol->setMag(smag);
            number->setSym(clefOneSym);
            addElement(number, .0, 4.5 * msp + yoff * _spatium);
            number = new Symbol(score());
            number->setSym(clefFiveSym);
            addElement(number, .8 * msp, 4.5 * msp + yoff * _spatium);
            }
            break;
      case CLEF_F_B:                            // baritone clef
            symbol->setSym(bassclefSym);
            yoff = 2.0 * curLineDist;
            break;
      case CLEF_F_C:                            // subbass clef
            symbol->setSym(bassclefSym);
            yoff = 0.0;
            break;
      case CLEF_C1:                             // C clef in 1st line
            symbol->setSym(altoclefSym);
            yoff = 4.0 * curLineDist;
            break;
      case CLEF_C2:                             // C clef on 2nd line
            symbol->setSym(altoclefSym);
            yoff = 3.0 * curLineDist;
            break;
      case CLEF_C3:                             // C clef in 3rd line
            symbol->setSym(altoclefSym);
            yoff = 2.0 * curLineDist;
            break;
      case CLEF_C4:                             // C clef on 4th line
            symbol->setSym(altoclefSym);
            yoff = 1.0 * curLineDist;
//.........这里部分代码省略.........
开发者ID:sommerp,项目名称:MuseScore,代码行数:101,代码来源:clef.cpp


示例12: rUserYoffset

void Trill::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(StyleIdx::trillY).val()) * spatium();
      }
开发者ID:BartlomiejLewandowski,项目名称:MuseScore,代码行数:4,代码来源:trill.cpp


示例13: staff

void Rest::layout()
      {
      int lines = staff()->lines();

      switch(durationType().type()) {
            case Duration::V_64TH:
            case Duration::V_32ND:
                  dotline = -3;
                  break;
            case Duration::V_256TH:
            case Duration::V_128TH:
                  dotline = -5;
                  break;
            default:
                  dotline = -1;
                  break;
            }
      qreal _spatium = spatium();
      int line        = lrint(userOff().y() / _spatium); //  + ((staff()->lines()-1) * 2);
      int lineOffset  = 0;

      if (measure()->mstaff(staffIdx())->hasVoices) {
            // move rests in a multi voice context
            bool up = (voice() == 0) || (voice() == 2);       // TODO: use style values
            switch(durationType().type()) {
                  case Duration::V_LONG:
                        lineOffset = up ? -3 : 5;
                        break;
                  case Duration::V_BREVE:
                        lineOffset = up ? -3 : 5;
                        break;
                  case Duration::V_MEASURE:
                  case Duration::V_WHOLE:
                        lineOffset = up ? -4 : 6;
                        break;
                  case Duration::V_HALF:
                        lineOffset = up ? -4 : 4;
                        break;
                  case Duration::V_QUARTER:
                        lineOffset = up ? -4 : 4;
                        break;
                  case Duration::V_EIGHT:
                        lineOffset = up ? -4 : 4;
                        break;
                  case Duration::V_16TH:
                        lineOffset = up ? -6 : 4;
                        break;
                  case Duration::V_32ND:
                        lineOffset = up ? -6 : 6;
                        break;
                  case Duration::V_64TH:
                        lineOffset = up ? -8 : 6;
                        break;
                  case Duration::V_128TH:
                        lineOffset = up ? -8 : 8;
                        break;
                  case Duration::V_256TH:             // not available
                        lineOffset = up ? -10 : 6;
                        break;
                  default:
                        break;
                  }
            }
      else {
            switch(durationType().type()) {
                  case Duration::V_LONG:
                  case Duration::V_BREVE:
                  case Duration::V_MEASURE:
                  case Duration::V_WHOLE:
                        if (lines == 1)
                              lineOffset = -2;
                        break;
                  case Duration::V_HALF:
                  case Duration::V_QUARTER:
                  case Duration::V_EIGHT:
                  case Duration::V_16TH:
                  case Duration::V_32ND:
                  case Duration::V_64TH:
                  case Duration::V_128TH:
                  case Duration::V_256TH:             // not available
                        if (lines == 1)
                              lineOffset = -4;
                        break;
                  default:
                        break;
                  }
            }

      int yo;
      _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo);
      setYoff(qreal(yo) + qreal(lineOffset) * .5);
      layoutArticulations();
      setPos(0.0, yoff() * _spatium);

      Spatium rs;
      if (dots()) {
            rs = Spatium(score()->styleS(ST_dotNoteDistance)
               + dots() * score()->styleS(ST_dotDotDistance));
            }
      Segment* s = segment();
//.........这里部分代码省略.........
开发者ID:gthomas,项目名称:MuseScore,代码行数:101,代码来源:rest.cpp


示例14: spatium

void LayoutBreak::spatiumChanged(qreal, qreal)
      {
      lw = spatium() * 0.3;
      layout0();
      }
开发者ID:FryderykChopin,项目名称:MuseScore,代码行数:5,代码来源:layoutbreak.cpp


示例15: spatium

void Tie::layout()
      {
      qreal _spatium = spatium();

      //
      //    show short bow
      //
      if (startNote() == 0 || endNote() == 0) {
            if (startNote() == 0) {
                  qDebug("Tie::layout(): no start note");
                  return;
                  }
            Chord* c1 = startNote()->chord();
            if (_slurDirection == MScore::Direction::AUTO) {
                  if (c1->measure()->mstaff(c1->staffIdx())->hasVoices) {
                        // in polyphonic passage, ties go on the stem side
                        _up = c1->up();
                        }
                  else
                        _up = !c1->up();
                  }
            else
                  _up = _slurDirection == MScore::Direction::UP ? true : false;
            fixupSegments(1);
            SlurSegment* segment = segmentAt(0);
            segment->setSpannerSegmentType(SpannerSegmentType::SINGLE);
            segment->setSystem(startNote()->chord()->segment()->measure()->system());
            SlurPos sPos;
            slurPos(&sPos);
            segment->layout(sPos.p1, sPos.p2);
            return;
            }

      calculateDirection();

      qreal w   = startNote()->headWidth();
      qreal xo1 = w * 1.12;
      qreal h   = w * 0.3;
      qreal yo  = _up ? -h : h;

      QPointF off1(xo1, yo);
      QPointF off2(0.0, yo);

#if 0 // yet(?) unused
      QPointF ppos(pagePos());
#endif

      // TODO: cleanup

      SlurPos sPos;
      slurPos(&sPos);

      // p1, p2, s1, s2

      QList<System*>* systems = score()->systems();
      setPos(0, 0);

      //---------------------------------------------------------
      //   count number of segments, if no change, all
      //    user offsets (drags) are retained
      //---------------------------------------------------------

      int sysIdx1 = systems->indexOf(sPos.system1);
      if (sysIdx1 == -1) {
            qDebug("system not found");
            foreach(System* s, *systems)
                  qDebug("   search %p in %p", sPos.system1, s);
            return;
            }

      int sysIdx2     = systems->indexOf(sPos.system2);
      if (sysIdx2 < 0)
            sysIdx2 = sysIdx1;
      unsigned nsegs  = sysIdx2 - sysIdx1 + 1;
      fixupSegments(nsegs);

      int i = 0;
      for (uint ii = 0; ii < nsegs; ++ii) {
            System* system = (*systems)[sysIdx1++];
            if (system->isVbox())
                  continue;
            SlurSegment* segment = segmentAt(i);
            segment->setSystem(system);

            // case 1: one segment
            if (sPos.system1 == sPos.system2) {
                  segment->layout(sPos.p1, sPos.p2);
                  segment->setSpannerSegmentType(SpannerSegmentType::SINGLE);
                  }
            // case 2: start segment
            else if (i == 0) {
                  qreal x = system->bbox().width();
                  segment->layout(sPos.p1, QPointF(x, sPos.p1.y()));
                  segment->setSpannerSegmentType(SpannerSegmentType::BEGIN);
                  }
            // case 4: end segment
            else {
                  qreal x = firstNoteRestSegmentX(system) - 2 * _spatium;

                  segment->layout(QPointF(x, sPos.p2.y()), sPos.p2);
//.........这里部分代码省略.........
开发者ID:mastashake08,项目名称:MuseScore,代码行数:101,代码来源:tie.cpp


示例16: spatium

QSizeF Image::pixel2size(const QSizeF& s) const
      {
      return s / (_sizeIsSpatium ? spatium() : DPMM);
      }
开发者ID:IsaacWeiss,项目名称:MuseScore,代码行数:4,代码来源:image.cpp


示例17: getY

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ spawn函数代码示例发布时间:2022-05-30
下一篇:
C++ spannerSegments函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap