Example #1
0
void Hairpin::undoSetVeloChange(int val)
      {
      score()->undoChangeProperty(this, P_ID::VELO_CHANGE, val);
      }
Example #2
0
void Rest::toDefault()
      {
      score()->undoChangeProperty(this, P_BEAM_MODE, BEAM_NO);
      ChordRest::toDefault();
      }
Example #3
0
void Clef::undoSetShowCourtesy(bool v)
      {
      score()->undoChangeProperty(this, P_ID::SHOW_COURTESY, v);
      }
Example #4
0
void Rest::layout()
      {
      if (staff() && staff()->isTabStaff()) {
            // no rests for tablature
            _space.setLw(0.0);
            _space.setRw(0.0);
            return;
            }
      switch(durationType().type()) {
            case TDuration::V_64TH:
            case TDuration::V_32ND:
                  dotline = -3;
                  break;
            case TDuration::V_256TH:
            case TDuration::V_128TH:
                  dotline = -5;
                  break;
            default:
                  dotline = -1;
                  break;
            }
      qreal _spatium = spatium();
      int stepOffset     = 0;
      if (staff())
            stepOffset = staff()->staffType()->stepOffset();
      int line        = lrint(userOff().y() / _spatium); //  + ((staff()->lines()-1) * 2);
      int lineOffset  = 0;

      int lines = staff() ? staff()->lines() : 5;
      if (segment() && measure() && 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 TDuration::V_LONG:
                        lineOffset = up ? -3 : 5;
                        break;
                  case TDuration::V_BREVE:
                        lineOffset = up ? -3 : 5;
                        break;
                  case TDuration::V_MEASURE:
                        if (duration() >= Fraction(2, 1))    // breve symbol
                              lineOffset = up ? -3 : 5;
                        // fall through
                  case TDuration::V_WHOLE:
                        lineOffset = up ? -4 : 6;
                        break;
                  case TDuration::V_HALF:
                        lineOffset = up ? -4 : 4;
                        break;
                  case TDuration::V_QUARTER:
                        lineOffset = up ? -4 : 4;
                        break;
                  case TDuration::V_EIGHT:
                        lineOffset = up ? -4 : 4;
                        break;
                  case TDuration::V_16TH:
                        lineOffset = up ? -6 : 4;
                        break;
                  case TDuration::V_32ND:
                        lineOffset = up ? -6 : 6;
                        break;
                  case TDuration::V_64TH:
                        lineOffset = up ? -8 : 6;
                        break;
                  case TDuration::V_128TH:
                        lineOffset = up ? -8 : 8;
                        break;
                  case TDuration::V_256TH:             // not available
                        lineOffset = up ? -10 : 6;
                        break;
                  default:
                        break;
                  }
            }
      else {
            switch(durationType().type()) {
                  case TDuration::V_LONG:
                  case TDuration::V_BREVE:
                  case TDuration::V_MEASURE:
                  case TDuration::V_WHOLE:
                        if (lines == 1)
                              lineOffset = -2;
                        break;
                  case TDuration::V_HALF:
                  case TDuration::V_QUARTER:
                  case TDuration::V_EIGHT:
                  case TDuration::V_16TH:
                  case TDuration::V_32ND:
                  case TDuration::V_64TH:
                  case TDuration::V_128TH:
                  case TDuration::V_256TH:             // not available
                        if (lines == 1)
                              lineOffset = -4;
                        break;
                  default:
                        break;
                  }
            }

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

      Spatium rs;
      if (dots()) {
            rs = Spatium(score()->styleS(ST_dotNoteDistance)
               + dots() * score()->styleS(ST_dotDotDistance));
            }
      Segment* s = segment();
      if (s && s->measure() && s->measure()->multiMeasure()) {
            qreal _spatium = spatium();
            qreal h = _spatium * 6.5;
            qreal w = point(score()->styleS(ST_minMMRestWidth));
            setbbox(QRectF(-w * .5, -h + 2 * _spatium, w, h));
            }
      else {
            if (dots()) {
                  rs = Spatium(score()->styleS(ST_dotNoteDistance)
                     + dots() * score()->styleS(ST_dotDotDistance));
                  }
            setbbox(symbols[score()->symIdx()][_sym].bbox(magS()));
            }
      _space.setLw(0.0);
      _space.setRw(width() + point(rs));
      }
Example #5
0
qreal Rest::upPos() const
      {
      return symbols[score()->symIdx()][_sym].bbox(magS()).y();
      }
Example #6
0
bool TextLine::readProperties(XmlReader& e)
      {
      const QStringRef& tag(e.name());

      if (tag == "beginHookHeight") {
            _beginHookHeight = Spatium(e.readDouble());
            _beginHook = true;
            }
      else if (tag == "beginHookType")
            _beginHookType = HookType(e.readInt());
      else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete
            _endHookHeight = Spatium(e.readDouble());
            _endHook = true;
            }
      else if (tag == "endHookType")
            _endHookType = HookType(e.readInt());
      else if (tag == "hookUp")           // obsolete
            _endHookHeight *= qreal(-1.0);
      else if (tag == "beginSymbol" || tag == "symbol") {     // "symbol" is obsolete
            QString text(e.readElementText());
            _beginSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text);
            }
      else if (tag == "continueSymbol") {
            QString text(e.readElementText());
            _continueSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text);
            }
      else if (tag == "endSymbol") {
            QString text(e.readElementText());
            _endSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text);
            }
      else if (tag == "beginSymbolOffset")
            _beginSymbolOffset = e.readPoint();
      else if (tag == "continueSymbolOffset")
            _continueSymbolOffset = e.readPoint();
      else if (tag == "endSymbolOffset")
            _endSymbolOffset = e.readPoint();
      else if (tag == "lineWidth")
            _lineWidth = Spatium(e.readDouble());
      else if (tag == "lineStyle")
            _lineStyle = Qt::PenStyle(e.readInt());
      else if (tag == "beginTextPlace")
            _beginTextPlace = readPlacement(e);
      else if (tag == "continueTextPlace")
            _continueTextPlace = readPlacement(e);
      else if (tag == "lineColor")
            _lineColor = e.readColor();
      else if (tag == "beginText") {
            _beginText = new Text(score());
            _beginText->setParent(this);
            _beginText->read(e);
            }
      else if (tag == "continueText") {
            _continueText = new Text(score());
            _continueText->setParent(this);
            _continueText->read(e);
            }
      else if (!SLine::readProperties(e)) {
            qDebug(" ==readSLineProps: failed");
            return false;
            }
      return true;
      }
Example #7
0
void TextLineSegment::draw(QPainter* painter) const
      {
      TextLine* tl   = textLine();
      qreal _spatium = spatium();

      qreal textlineLineWidth    = tl->lineWidth().val() * _spatium;
      qreal textlineTextDistance = _spatium * .5;

      QPointF pp2(pos2());

      QColor color;
      bool normalColor = false;
      if (selected() && !(score() && score()->printing()))
            color = MScore::selectColor[0];
      else if (!visible())
            color = Qt::gray;
      else {
            color = curColor();
            normalColor = true;
            }

      qreal l = 0.0;
      int sym = subtype() == SEGMENT_MIDDLE ? tl->continueSymbol() : tl->beginSymbol();
      if (_text) {
            SpannerSegmentType st = subtype();
            if (
               ((st == SEGMENT_SINGLE || st == SEGMENT_BEGIN) && (tl->beginTextPlace() == PLACE_LEFT))
               || ((st == SEGMENT_MIDDLE || st == SEGMENT_END) && (tl->continueTextPlace() == PLACE_LEFT))
               ) {
                  QRectF bb(_text->bbox());
                  l = _text->pos().x() + bb.width() + textlineTextDistance;
                  }
            painter->translate(_text->pos());
            painter->setPen(normalColor ? _text->curColor() : color);
            _text->draw(painter);
            painter->translate(-_text->pos());
            }
      else if (sym != -1) {
            const QRectF& bb = symbols[score()->symIdx()][sym].bbox(magS());
            qreal h = bb.height() * .5;
            QPointF o = tl->beginSymbolOffset() * _spatium;
            painter->setPen(color);
            symbols[score()->symIdx()][sym].draw(painter, 1.0, QPointF(o.x(), h + o.y()));
            l = bb.width() + textlineTextDistance;
            }

      QPen pen(normalColor ? tl->lineColor() : color, textlineLineWidth);
      pen.setStyle(tl->lineStyle());
      painter->setPen(pen);

      if (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_END) {
            if (tl->endSymbol() != -1) {
                  int sym = tl->endSymbol();
                  const QRectF& bb = symbols[score()->symIdx()][sym].bbox(magS());
                  qreal h = bb.height() * .5;
                  QPointF o = tl->endSymbolOffset() * _spatium;
                  pp2.setX(pp2.x() - bb.width() + textlineTextDistance);
                  symbols[score()->symIdx()][sym].draw(painter, 1.0, QPointF(pp2.x() + textlineTextDistance + o.x(), h + o.y()));
                  }
            }

      QPointF pp1(l, 0.0);

      if (tl->beginHook() && tl->beginHookType() == HOOK_45)
            pp1.rx() += fabs(tl->beginHookHeight().val() * _spatium * .4);
      if (tl->endHook() && tl->endHookType() == HOOK_45)
            pp2.rx() -= fabs(tl->endHookHeight().val() * _spatium * .4);

      painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y()));

      if (tl->beginHook()) {
            qreal hh = tl->beginHookHeight().val() * _spatium;
            if (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_BEGIN) {
                  if (tl->beginHookType() == HOOK_45)
                        painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x() - fabs(hh * .4), pp1.y() + hh));
                  else
                        painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x(), pp1.y() + hh));
                  }
            }
      if (tl->endHook()) {
            qreal hh = tl->endHookHeight().val() * _spatium;
            if (subtype() == SEGMENT_SINGLE || subtype() == SEGMENT_END) {
                  if (tl->endHookType() == HOOK_45)
                        painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x() + fabs(hh * .4), pp2.y() + hh));
                  else
                        painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x(), pp2.y() + hh));
                  }
            }
      }
Example #8
0
void ScoreElement::undoChangeProperty(P_ID id, const QVariant& val)
      {
      score()->undoChangeProperty(this, id, val);
      }
Example #9
0
void ScoreElement::undoPushProperty(P_ID id)
      {
      QVariant val = getProperty(id);
      score()->undoStack()->push1(new ChangeProperty(this, id, val));
      }
Example #10
0
float sequence(char* s1, char* s2, float gapOpen, float gapExtend,
               float zeroShift, ScoringMatrix* matrix) {
  // Setup
  float maximalScore;
  int s1len = strlen(s1);
  int s2len = strlen(s2);
  float** V;
  float** G;
  float** E;
  float** F;
  V = (float**)malloc((s1len + 1) * sizeof(float*));
  G = (float**)malloc((s1len + 1) * sizeof(float*));
  E = (float**)malloc((s1len + 1) * sizeof(float*));
  F = (float**)malloc((s1len + 1) * sizeof(float*));
  int i, j;
  for (i = 0; i < strlen(s1) + 1; i++) {
    V[i] = (float*)malloc((s2len + 1) * sizeof(float));
    G[i] = (float*)malloc((s2len + 1) * sizeof(float));
    E[i] = (float*)malloc((s2len + 1) * sizeof(float));
    F[i] = (float*)malloc((s2len + 1) * sizeof(float));
  }
  for (i = 0; i < s1len + 1; i++)
    for (j = 0; j < s2len + 1; j++)
      V[i][j] = G[i][j] = E[i][j] = F[i][j] = -100000;

  for (i = 0; i < s1len + 1; i++)
    V[i][0] = E[i][0] = -1 * (gapOpen + i * gapExtend);
  for (i = 0; i < s2len + 1; i++)
    V[0][i] = F[0][i] = -1 * (gapOpen + i * gapExtend);
  V[0][0] = 0;
  // DP
  for (i = 1; i < s1len + 1; i++) {
    for (j = 1; j < s2len + 1; j++) {
      G[i][j] =
          V[i - 1][j - 1] + score(s1[i - 1], s2[j - 1], matrix) + zeroShift;
      E[i][j] = max2(E[i][j - 1], V[i][j - 1] - gapOpen) - gapExtend;
      F[i][j] = max2(F[i - 1][j], V[i - 1][j] - gapOpen) - gapExtend;
      V[i][j] = max3(G[i][j], F[i][j], E[i][j]);
    }
  }
  printf("Maximum Alignment Score: %f\n", V[--i][--j]);
  maximalScore = V[i][j];
  // Traceback
  char* alignment1 = (char*)malloc(i + j);
  char* alignment2 = (char*)malloc(i + j);
  int pos1 = 0;
  int pos2 = 0;
  while (i > 0 && j > 0) {
    if (V[i][j] == G[i][j]) {
      alignment1[pos1++] = s1[--i];
      alignment2[pos2++] = s2[--j];
    } else if (V[i][j] == E[i][j]) {
      alignment1[pos1++] = '.';
      alignment2[pos2++] = s2[--j];
      if (i == 0 || j == 0) break;
      while (E[i][j] == E[i][j + 1] + gapExtend) {
        alignment1[pos1++] = '.';
        alignment2[pos2++] = s2[--j];
        if (i == 0 || j == 0) break;
      }
    } else if (V[i][j] == F[i][j]) {
      alignment1[pos1++] = s1[--i];
      alignment2[pos2++] = '.';
      if (i == 0 || j == 0) break;
      while (F[i][j] == F[i + 1][j] + gapExtend) {
        alignment1[pos1++] = s1[--i];
        alignment2[pos2++] = '.';
        if (i == 0 || j == 0) break;
      }
    }
  }
  while (i > 0) {
    alignment1[pos1++] = s1[--i];
    alignment2[pos2++] = '.';
  }
  while (j > 0) {
    alignment1[pos1++] = '.';
    alignment2[pos2++] = s2[--j];
  }
  alignment1[pos1] = '\0';
  alignment2[pos2] = '\0';
  reverse(alignment1);
  reverse(alignment2);
  printf("%s\n%s\n", alignment1, alignment2);
  return maximalScore;
}
Example #11
0
Element* Rest::drop(const DropData& data)
      {
      Element* e = data.element;
      switch (e->type()) {
            case ARTICULATION:
                  if (e->subtype() == Articulation_Fermata)
                        score()->addArticulation(this, (Articulation*)e);
                  return 0;
            case ICON:
                  {
                  switch(e->subtype()) {
                        case ICON_SBEAM:
                              score()->undoChangeBeamMode(this, BEAM_BEGIN);
                              break;
                        case ICON_MBEAM:
                              score()->undoChangeBeamMode(this, BEAM_MID);
                              break;
                        case ICON_NBEAM:
                              score()->undoChangeBeamMode(this, BEAM_NO);
                              break;
                        case ICON_BEAM32:
                              score()->undoChangeBeamMode(this, BEAM_BEGIN32);
                              break;
                        case ICON_BEAM64:
                              score()->undoChangeBeamMode(this, BEAM_BEGIN64);
                              break;
                        case ICON_AUTOBEAM:
                              score()->undoChangeBeamMode(this, BEAM_AUTO);
                              break;
                        }
                  }
                  delete e;
                  break;

            case CHORD:
                  {
                  Chord* c      = static_cast<Chord*>(e);
                  Note* n       = c->upNote();
                  Direction dir = c->stemDirection();
                  score()->select(0, SELECT_SINGLE, 0);
                  NoteVal nval;
                  nval.pitch = n->pitch();
                  nval.headGroup = n->headGroup();
                  Fraction d = score()->inputState().duration().fraction();
                  if (!d.isZero()) {
                        Segment* seg = score()->setNoteRest(segment(), track(), nval, d, dir);
                        if (seg) {
                              ChordRest* cr = static_cast<ChordRest*>(seg->element(track()));
                              if (cr)
                                    score()->nextInputPos(cr, true);
                              }
                        }
                  delete e;
                  }
                  break;
            default:
                  return ChordRest::drop(data);
            }
      return 0;
      }
Example #12
0
void Hairpin::endEdit()
      {
      if (editHairpinHeight != _hairpinHeight)
            score()->undoPropertyChanged(this, P_ID::HAIRPIN_HEIGHT, editHairpinHeight.val());
      TextLine::endEdit();
      }
Example #13
0
void Hairpin::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(StyleIdx::hairpinY).val()) * spatium();
      }
Example #14
0
void Hairpin::undoSetDynRange(Dynamic::Range val)
      {
      score()->undoChangeProperty(this, P_ID::DYNAMIC_RANGE, int(val));
      }
Example #15
0
int
main(int argc, char **argv)
{
	int i;
	int rval,ll;
	struct text *kk;

	/* If the user hits start, bail */
	cont_btn_callback(0, CONT_START, (cont_btn_callback_t)arch_exit);

	pvr_init_defaults();
	conio_init(CONIO_TTY_PVR, CONIO_INPUT_LINE);

#if 0
	/* revoke */
	setgid(getgid());
#endif

	init();         /* Initialize everything */
	/* signal(SIGINT,trapdel); */

#if 0
	if (argc > 1)   /* Restore file specified */
	{               /* Restart is label 8305 (Fortran) */
		i = restore(argv[1]);       /* See what we've got */
		switch(i)
		{
		    case 0:     /* The restore worked fine */
			yea=Start();
			k=null;
			unlink(argv[1]);/* Don't re-use the save */
			goto l8;        /* Get where we're going */
		    case 1:             /* Couldn't open it */
			exit(1);        /* So give up */
		    case 2:             /* Oops -- file was altered */
			rspeak(202);    /* You dissolve */
			exit(1);        /* File could be non-adventure */
		}                       /* So don't unlink it. */
	}
#endif

	startup();              /* prepare for a user           */

	for (;;)                        /* main command loop (label 2)  */
	{       if (newloc<9 && newloc!=0 && closng)
		{       rspeak(130);    /* if closing leave only by     */
			newloc=loc;     /*      main office             */
			if (!apanic) clock2=15;
			apanic=TRUE;
		}

		rval=fdwarf();          /* dwarf stuff                  */
		if (rval==99) die(99);

	l2000:  if (loc==0) die(99);    /* label 2000                   */
		kk = &stext[loc];
		if ((abb[loc]%abbnum)==0 || kk->seekadr==0)
			kk = &ltext[loc];
		if (!forced(loc) && dark())
		{       if (wzdark && pct(35))
			{       die(90);
				goto l2000;
			}
			kk = &rtext[16];
		}
		if (toting(bear)) rspeak(141);  /* 2001                 */
		speak(kk);
		k=1;
		if (forced(loc))
			goto l8;
		if (loc==33 && pct(25)&&!closng) rspeak(8);
		if (!dark())
		{       abb[loc]++;
			for (i=atloc[loc]; i!=0; i=linkx[i])     /*2004  */
			{       obj=i;
				if (obj>100) obj -= 100;
				if (obj==steps && toting(nugget)) continue;
				if (prop[obj]<0)
				{       if (closed) continue;
					prop[obj]=0;
					if (obj==rug||obj==chain)
						prop[obj]=1;
					tally--;
					if (tally==tally2 && tally != 0)
						if (limit>35) limit=35;
				}
				ll =  prop[obj];   /* 2006         */
				if (obj==steps && loc==fixed[steps])
					ll = 1;
				pspeak(obj, ll);
			}                                       /* 2008 */
			goto l2012;
	l2009:          k=54;                   /* 2009                 */
	l2010:          spk=k;
	l2011:          rspeak(spk);
		}
	l2012:  verb=0;                         /* 2012                 */
		obj=0;
	l2600:	checkhints();                   /* to 2600-2602         */
		if (closed)
		{       if (prop[oyster]<0 && toting(oyster))
				pspeak(oyster,1);
			for (i=1; i<100; i++)
				if (toting(i)&&prop[i]<0)       /*2604  */
					prop[i] = -1-prop[i];
		}
		wzdark=dark();                  /* 2605                 */
		if (knfloc>0 && knfloc!=loc) knfloc=1;
		getin(&wd1,&wd2);
#if 0
		if (delhit)                     /* user typed a DEL     */
		{       delhit=0;               /* reset counter        */
			strcpy(wd1,"quit");    /* pretend he's quitting*/
			*wd2=0;
		}
#endif
	l2608:  if ((foobar = -foobar)>0) foobar=0;     /* 2608         */
		/* should check here for "magic mode"                   */
		turns++;
		if (demo && turns>=SHORT) done(1);      /* to 13000     */

		if (verb==say && *wd2!=0) verb=0;
		if (verb==say)
			goto l4090;
		if (tally==0 && loc>=15 && loc!=33) clock1--;
		if (clock1==0)
		{       closing();                      /* to 10000     */
			goto l19999;
		}
		if (clock1<0) clock2--;
		if (clock2==0)
		{       caveclose();            /* to 11000             */
			continue;               /* back to 2            */
		}
		if (prop[lamp]==1) limit--;
		if (limit<=30 && here(batter) && prop[batter]==0
			&& here(lamp))
		{       rspeak(188);            /* 12000                */
			prop[batter]=1;
			if (toting(batter)) drop(batter,loc);
			limit=limit+2500;
			lmwarn=FALSE;
			goto l19999;
		}
		if (limit==0)
		{       limit = -1;             /* 12400                */
			prop[lamp]=0;
			rspeak(184);
			goto l19999;
		}
		if (limit<0&&loc<=8)
		{       rspeak(185);            /* 12600                */
			gaveup=TRUE;
			done(2);                /* to 20000             */
		}
		if (limit<=30)
		{       if (lmwarn|| !here(lamp)) goto l19999;  /*12200*/
			lmwarn=TRUE;
			spk=187;
			if (place[batter]==0) spk=183;
			if (prop[batter]==1) spk=189;
			rspeak(spk);
		}
	l19999: k=43;
		if (liqloc(loc)==water) k=70;
		if (!strncmp(wd1,"enter",5) &&
		    (!strncmp(wd2,"strea",5)||!strncmp(wd2,"water",5)))
			goto l2010;
		if (!strncmp(wd1,"enter",5) && *wd2!=0) goto l2800;
		if ((strncmp(wd1,"water",5)&&strncmp(wd1,"oil",3))
		    || (strncmp(wd2,"plant",5)&&strncmp(wd2,"door",4)))
			goto l2610;
		if (at(vocab(wd2,1,0))) strcpy(wd2,"pour");

	l2610:  if (!strncmp(wd1,"west",4))
			if (++iwest==10) rspeak(17);
	l2630:  i=vocab(wd1,-1,0);
		if (i== -1)
		{       spk=60;                 /* 3000         */
			if (pct(20)) spk=61;
			if (pct(20)) spk=13;
			rspeak(spk);
			goto l2600;
		}
		k=i%1000;
		kq=i/1000+1;
		switch(kq)
		{   case 1: goto l8;
		    case 2: goto l5000;
		    case 3: goto l4000;
		    case 4: goto l2010;
		    default:
			bug(22);
		}

	l8:
		switch(march())
		{   case 2: continue;           /* i.e. goto l2         */
		    case 99:
			die(99);
			goto l2000;
		    default: bug(110);
		}

	l2800:  strcpy(wd1,wd2);
		*wd2=0;
		goto l2610;

	l4000:  verb=k;
		spk=actspk[verb];
		if (*wd2!=0 && verb!=say) goto l2800;
		if (verb==say) obj= *wd2;
		if (obj!=0) goto l4090;
		switch(verb)
		{   case 1:                     /* take = 8010          */
			if (atloc[loc]==0||linkx[atloc[loc]]!=0) goto l8000;
			for (i=1; i<=5; i++)
				if (dloc[i]==loc&&dflag>=2) goto l8000;
			obj=atloc[loc];
			goto l9010;
		    case 2: case 3: case 9:     /* 8000 : drop,say,wave */
		    case 10: case 16: case 17:  /* calm,rub,toss        */
		    case 19: case 21: case 28:  /* find,feed,break      */
		    case 29:                    /* wake                 */
		l8000:  printf("%s what?\n",wd1);
			obj=0;
			goto l2600;
		    case 4: case 6:             /* 8040 open,lock       */
			spk=28;
			if (here(clam)) obj=clam;
			if (here(oyster)) obj=oyster;
			if (at(door)) obj=door;
			if (at(grate)) obj=grate;
			if (obj!=0 && here(chain)) goto l8000;
			if (here(chain)) obj=chain;
			if (obj==0) goto l2011;
			goto l9040;
		    case 5: goto l2009;         /* nothing              */
		    case 7: goto l9070;         /* on                   */
		    case 8: goto l9080;         /* off                  */
		    case 11: goto l8000;        /* walk                 */
		    case 12: goto l9120;        /* kill                 */
		    case 13: goto l9130;        /* pour                 */
		    case 14:                    /* eat: 8140            */
			if (!here(food)) goto l8000;
		l8142:  dstroy(food);
			spk=72;
			goto l2011;
		    case 15: goto l9150;        /* drink                */
		    case 18:                    /* quit: 8180           */
			gaveup=yes(22,54,54);
			if (gaveup) done(2);    /* 8185                 */
			goto l2012;
		    case 20:                    /* invent=8200          */
			spk=98;
			for (i=1; i<=100; i++)
			{       if (i!=bear && toting(i))
				{       if (spk==98) rspeak(99);
					blklin=FALSE;
					pspeak(i,-1);
					blklin=TRUE;
					spk=0;
				}
			}
			if (toting(bear)) spk=141;
			goto l2011;
		    case 22: goto l9220;        /* fill                 */
		    case 23: goto l9230;        /* blast                */
		    case 24:                    /* score: 8240          */
			scorng=TRUE;
			printf("If you were to quit now, you would score");
			printf(" %d out of a possible ",score());
			printf("%d.",mxscor);
			scorng=FALSE;
			gaveup=yes(143,54,54);
			if (gaveup) done(2);
			goto l2012;
		    case 25:                    /* foo: 8250            */
			k=vocab(wd1,3,0);
			spk=42;
			if (foobar==1-k) goto l8252;
			if (foobar!=0) spk=151;
			goto l2011;
		l8252:  foobar=k;
			if (k!=4) goto l2009;
			foobar=0;
			if (place[eggs]==plac[eggs]
				||(toting(eggs)&&loc==plac[eggs])) goto l2011;
			if (place[eggs]==0&&place[troll]==0&&prop[troll]==0)
				prop[troll]=1;
			k=2;
			if (here(eggs)) k=1;
			if (loc==plac[eggs]) k=0;
			move(eggs,plac[eggs]);
			pspeak(eggs,k);
			goto l2012;
		    case 26:                    /* brief=8260           */
			spk=156;
			abbnum=10000;
			detail=3;
			goto l2011;
		    case 27:                    /* read=8270            */
			if (here(magzin)) obj=magzin;
			if (here(tablet)) obj=obj*100+tablet;
			if (here(messag)) obj=obj*100+messag;
			if (closed&&toting(oyster)) obj=oyster;
			if (obj>100||obj==0||dark()) goto l8000;
			goto l9270;
		    case 30:                    /* suspend=8300         */
			spk=201;
			if (demo) goto l2011;
			printf("I can suspend your adventure for you so");
			printf(" you can resume later, but\n");
			printf("you will have to wait at least");
			printf(" %d minutes before continuing.",latncy);
			if (!yes(200,54,54)) goto l2012;
			datime(&saved,&savet);
			ciao();                 /* Do we quit? */
			continue;               /* Maybe not */
		    case 31:                    /* hours=8310           */
			printf("Colossal cave is closed 9am-5pm Mon ");
			printf("through Fri except holidays.\n");
			goto l2012;
		    default: bug(23);
		}

	l4090:
		switch(verb)
		{   case 1:                     /* take = 9010          */
	l9010:          switch(trtake())
			{   case 2011: goto l2011;
			    case 9220: goto l9220;
			    case 2009: goto l2009;
			    case 2012: goto l2012;
			    default: bug(102);
			}
	l9020:      case 2:                     /* drop = 9020          */
			switch(trdrop())
			{   case 2011: goto l2011;
			    case 19000: done(3);
			    case 2012: goto l2012;
			    default: bug(105);
			}
		    case 3:
			switch(trsay())
			{   case 2012: goto l2012;
			    case 2630: goto l2630;
			    default: bug(107);
			}
	l9040:      case 4:  case 6:            /* open, close          */
			switch(tropen())
			{   case 2011: goto l2011;
			    case 2010: goto l2010;
			    default: bug(106);
			}
		    case 5: goto l2009;         /* nothing              */
		    case 7:                     /* on   9070            */
	l9070:          if (!here(lamp))  goto l2011;
			spk=184;
			if (limit<0) goto l2011;
			prop[lamp]=1;
			rspeak(39);
			if (wzdark) goto l2000;
			goto l2012;

		    case 8:                     /* off                  */
	l9080:          if (!here(lamp)) goto l2011;
			prop[lamp]=0;
			rspeak(40);
			if (dark()) rspeak(16);
			goto l2012;

		    case 9:                     /* wave                 */
			if ((!toting(obj))&&(obj!=rod||!toting(rod2)))
				spk=29;
			if (obj!=rod||!at(fissur)||!toting(obj)||closng)
				goto l2011;
			prop[fissur]=1-prop[fissur];
			pspeak(fissur,2-prop[fissur]);
			goto l2012;
		    case 10: case 11: case 18:  /* calm, walk, quit     */
		    case 24: case 25: case 26:  /* score, foo, brief    */
		    case 30: case 31:           /* suspend, hours       */
			     goto l2011;
	l9120:      case 12:                    /* kill                 */
			switch(trkill())
			{   case 8000: goto l8000;
			    case 8: goto l8;
			    case 2011: goto l2011;
			    case 2608: goto l2608;
			    case 19000: done(3);
			    default: bug(112);
			}
	l9130:      case 13:                    /* pour                 */
			if (obj==bottle||obj==0) obj=liq();
			if (obj==0) goto l8000;
			if (!toting(obj)) goto l2011;
			spk=78;
			if (obj!=oil&&obj!=water) goto l2011;
			prop[bottle]=1;
			place[obj]=0;
			spk=77;
			if (!(at(plant)||at(door))) goto l2011;
			if (at(door))
			{       prop[door]=0;   /* 9132                 */
				if (obj==oil) prop[door]=1;
				spk=113+prop[door];
				goto l2011;
			}
			spk=112;
			if (obj!=water) goto l2011;
			pspeak(plant,prop[plant]+1);
			prop[plant]=(prop[plant]+2)% 6;
			prop[plant2]=prop[plant]/2;
			k=null;
			goto l8;
		    case 14:                    /* 9140 - eat           */
			if (obj==food) goto l8142;
			if (obj==bird||obj==snake||obj==clam||obj==oyster
			    ||obj==dwarf||obj==dragon||obj==troll
			    ||obj==bear) spk=71;
			goto l2011;
	l9150:      case 15:                    /* 9150 - drink         */
			if (obj==0&&liqloc(loc)!=water&&(liq()!=water
				||!here(bottle))) goto l8000;
			if (obj!=0&&obj!=water) spk=110;
			if (spk==110||liq()!=water||!here(bottle))
				goto l2011;
			prop[bottle]=1;
			place[water]=0;
			spk=74;
			goto l2011;
		    case 16:                    /* 9160: rub            */
			if (obj!=lamp) spk=76;
			goto l2011;
		    case 17:                    /* 9170: throw          */
			switch(trtoss())
			{   case 2011: goto l2011;
			    case 9020: goto l9020;
			    case 9120: goto l9120;
			    case 8: goto l8;
			    case 9210: goto l9210;
			    default: bug(113);
			}
		    case 19: case 20:           /* 9190: find, invent   */
			if (at(obj)||(liq()==obj&&at(bottle))
				||k==liqloc(loc)) spk=94;
			for (i=1; i<=5; i++)
				if (dloc[i]==loc&&dflag>=2&&obj==dwarf)
					spk=94;
			if (closed) spk=138;
			if (toting(obj)) spk=24;
			goto l2011;
	l9210:      case 21:                    /* feed                 */
			switch(trfeed())
			{   case 2011: goto l2011;
			    default: bug(114);
			}
	l9220:      case 22:                    /* fill                 */
			switch(trfill())
			{   case 2011: goto l2011;
			    case 8000: goto l8000;
			    case 9020: goto l9020;
			    default: bug(115);
			}
	l9230:      case 23:                    /* blast                */
			if (prop[rod2]<0||!closed) goto l2011;
			bonus=133;
			if (loc==115) bonus=134;
			if (here(rod2)) bonus=135;
			rspeak(bonus);
			done(2);
	l9270:      case 27:                    /* read                 */
			if (dark()) goto l5190;
			if (obj==magzin) spk=190;
			if (obj==tablet) spk=196;
			if (obj==messag) spk=191;
			if (obj==oyster&&hinted[2]&&toting(oyster)) spk=194;
			if (obj!=oyster||hinted[2]||!toting(oyster)
				||!closed) goto l2011;
			hinted[2]=yes(192,193,54);
			goto l2012;
		    case 28:                    /* break                */
			if (obj==mirror) spk=148;
			if (obj==vase&&prop[vase]==0)
			{       spk=198;
				if (toting(vase)) drop(vase,loc);
				prop[vase]=2;
				fixed[vase]= -1;
				goto l2011;
			}
			if (obj!=mirror||!closed) goto l2011;
			rspeak(197);
			done(3);

		    case 29:                    /* wake                 */
			if (obj!=dwarf||!closed) goto l2011;
			rspeak(199);
			done(3);

		    default: bug(24);
		}

	l5000:
		obj=k;
		if (fixed[k]!=loc && !here(k)) goto l5100;
	l5010:  if (*wd2!=0) goto l2800;
		if (verb!=0) goto l4090;
		printf("What do you want to do with the %s?\n",wd1);
		goto l2600;
	l5100:  if (k!=grate) goto l5110;
		if (loc==1||loc==4||loc==7) k=dprssn;
		if (loc>9&&loc<15) k=entrnc;
		if (k!=grate) goto l8;
	l5110:  if (k!=dwarf) goto l5120;
		for (i=1; i<=5; i++)
			if (dloc[i]==loc&&dflag>=2) goto l5010;
	l5120:  if ((liq()==k&&here(bottle))||k==liqloc(loc)) goto l5010;
		if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130;
		obj=plant2;
		goto l5010;
	l5130:  if (obj!=knife||knfloc!=loc) goto l5140;
		knfloc = -1;
		spk=116;
		goto l2011;
	l5140:  if (obj!=rod||!here(rod2)) goto l5190;
		obj=rod2;
		goto l5010;
	l5190:  if ((verb==find||verb==invent)&&*wd2==0) goto l5010;
		printf("I see no %s here\n",wd1);
		goto l2012;
	}
}
Example #16
0
void PianorollEditor::moveLocator(int i, const Pos& pos)
      {
      if (locator[i].valid())
            score()->setPos(POS(i), pos.tick());
      }
Example #17
0
void TextLineSegment::layout1()
      {
      TextLine* tl = textLine();
      if (!tl->diagonal())
            _userOff2.setY(0);
      switch (subtype()) {
            case SEGMENT_SINGLE:
            case SEGMENT_BEGIN:
                  if (tl->beginText()) {
                        if (_text == 0) {
                              _text = new Text(*tl->beginText());
                              _text->setFlag(ELEMENT_MOVABLE, false);
                              _text->setParent(this);
                              }
                        }
                  else {
                        delete _text;
                        _text = 0;
                        }
                  break;
            case SEGMENT_MIDDLE:
            case SEGMENT_END:
                  if (tl->continueText()) {
                        if (_text == 0) {
                              _text = new Text(*tl->continueText());
                              _text->setFlag(ELEMENT_MOVABLE, false);
                              _text->setParent(this);
                              }
                        }
                  else {
                        delete _text;
                        _text = 0;
                        }
                  break;
            }
      if (_text)
            _text->layout();

      QPointF pp1;
      QPointF pp2(pos2());

      if (!_text && pp2.y() != 0) {
            setbbox(QRectF(pp1, pp2).normalized());
            return;
            }
      qreal y1 = point(-textLine()->lineWidth());
      qreal y2 = -y1;

      int sym = textLine()->beginSymbol();
      if (_text) {
            qreal h = _text->height();
            if (textLine()->beginTextPlace() == PLACE_ABOVE)
                  y1 = -h;
            else if (textLine()->beginTextPlace() == PLACE_BELOW)
                  y2 = h;
            else {
                  y1 = -h * .5;
                  y2 = h * .5;
                  }
            }
      else if (sym != -1) {
            qreal hh = symbols[score()->symIdx()][sym].height(magS()) * .5;
            y1 = -hh;
            y2 = hh;
            }
      if (textLine()->endHook()) {
            qreal h = point(textLine()->endHookHeight());
            if (h > y2)
                  y2 = h;
            else if (h < y1)
                  y1 = h;
            }
      if (textLine()->beginHook()) {
            qreal h = point(textLine()->beginHookHeight());
            if (h > y2)
                  y2 = h;
            else if (h < y1)
                  y1 = h;
            }
      bbox().setRect(.0, y1, pp2.x(), y2 - y1);
      }
Example #18
0
int main(int argc, char **argv) {
	TypePosition orderstart=1, orderend=10;
	char option[256], inputFileName[SIZE_BUFFER_CHAR], outputFileName[SIZE_BUFFER_CHAR], bufferOutput[SIZE_BUFFER_CHAR], *table, 
	outputFormat = 'r', typeDec = 'l', typeAlphabet = '?', typeCalc = 'g', type = 't';
	TypeSetOfSequences *set, seq;
	TypeAlignment aln, atmp;
	int fixed = 0;
	double threshold = 0.001, tmin = 1E-20, tmax=0.1, tstep = 0.00001, qmin = -25, qmax = -3, qprec = 0.5;
	double thre;
	TypeNumber n;
	TypeDistance distA, distB;
	TypePosition l, tot, lmax = 50;
	TypeSuffixTree *suffixTree;
	TypeMarkovModel *model;
	TypeCodeScheme *scheme;
/*	TypeDistFunction *distfunc[MAX_FUNC]=
	{computeProba, computeKullbackLeiber1, computePham, computeCommon, computeCommonBis, computeGillesPham, computeMatchesBis, computeMatches, computeAlex, computeAlexBis};
*/		
	FILE *fi, *fo;
	int i = 1, typeDist = 0;

	for(i=0; i<256; i++)
		option[i] = 0;
	for(i=1; i<argc && *(argv[i]) == '-'; i++) {
		int j;
		for(j=1; argv[i][j] != '\0'; j++)
			option[argv[i][j]] = 1;
		if(option['f']) {
			option['f'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%c", &outputFormat) == 1)
				i++;
		}
		if(option['s']) {
			option['s'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%c", &typeAlphabet) == 1)
				i++;
		}
		if(option['c']) {
			option['c'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%c", &typeCalc) == 1)
				i++;
		}
		if(option['m']) {
			option['m'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%lf", &tmin) == 1)
				i++;
			if(typeDist >= MAX_FUNC)
				typeDist = 0;
		}
		if(option['t']) {
			option['t'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%lf", &threshold) == 1)
				i++;
		}
		if(option['y']) {
			option['y'] = 0;
			if((i+1)<argc && sscanf(argv[i+1], "%c", &type) == 1)
				i++;
		}
	if(option['h']) {
			printf("%s\n", HELPMESSAGE);
			exitProg(ExitOk, NULL);
		}
	}
	if (i>=argc || sscanf(argv[i++], "%s", inputFileName) != 1) exitProg(ErrorArgument, HELPMESSAGE);
	if (i>=argc || sscanf(argv[i++], "%s", outputFileName) != 1) exitProg(ErrorArgument, HELPMESSAGE);

	switch(typeAlphabet) {
		case 'd':
			table = (char*) monmalloc((strlen(DNA)+1)*sizeof(char));
			strcpy(table, DNA);
			break;
		case 'r':
			table = (char*) monmalloc((strlen(RNA)+1)*sizeof(char));
			strcpy(table, RNA);
			break;
		case 'p':
			table = (char*) monmalloc((strlen(PRO)+1)*sizeof(char));
			strcpy(table, PRO);
			break;
		case '?':
		default:
			table = (char*) monmalloc(sizeof(char));
			table[0] = '\0';
	}
	if(fi = fopen(inputFileName, "r")) {
		aln = readAlignement(fi, table, typeAlphabet == '?');
		switch(typeAlphabet) {
			case 'd':
			case 'r':
				aln.ambiguity = getXNAAmbiguity();
				break;
			case 'p':
				aln.ambiguity = getProteinAmbiguity();
				break;
			case '?':
			default:
				aln.ambiguity.number = 0;
		}
		aln.cardinal -= aln.ambiguity.number;
		fclose(fi);
	} else {
		exitProg(ErrorReading, inputFileName);
	}
	fixAlignmentAmbiguity(&aln);
	set=toSequences(&aln);

	if(!(fo = fopen(outputFileName, "w")))
		exitProg(ErrorWriting, outputFileName);
	distA = computeWholeDistancePairAln(aln, computeNorm1Aln);
	scheme = (TypeCodeScheme*) monmalloc(sizeof(TypeCodeScheme));
	scheme->suffixTree = getSuffixTree(set);
	scheme->code = (TypePosition*) monmalloc(scheme->suffixTree->size*sizeof(TypePosition));
	scheme->buffSize = INC_SIZE_CODE;
	scheme->lengthCode = (TypePosition*) monmalloc(scheme->buffSize*sizeof(TypePosition));
	if(type == 't') {
		int l;
		model = estimateMarkovModel(set);
//		for(thre=tmin; thre<=tmax; thre *= 10.0) {
		for(l=tmin; l<=-1; l++) {
			double t;
			int k;
			thre = pow(10.0, (double) l);
			for(k=0; k<10; k++) {
//			for(t=thre; t<thre*10; t+=thre) {
				double corr, sc;
				TypeSetOfSequences *dec;
				t = ((double)k+1.)*thre;
				scheme->cardCode = 0;
				buildCodeThreshold(t, scheme->suffixTree->root, 0, 1., model, scheme);
//printLengthDistribution(stdout, scheme->lengthCode,scheme->cardCode);
				dec = getDecodedFromScheme(scheme);
//printf("cardinal dec = %ld\n", dec->cardinal);
				distB = computeWholeDistanceDec(dec);
				corr = computeCorrelation(distA, distB);
				monfree((void*)distB.table);
				sc = score(dec);
				printf("%lE\t%lf\t%.2lf\n", t, corr, sc);
				fprintf(fo, "%lE\t%lf\t%.2lf\n", t, corr, sc);
				for(n=0; n<dec->number; n++)
					monfree((void*) dec->sequence[n]);
				monfree((void*) dec->sequence);
				monfree((void*) dec->size);
				monfree((void*) dec);
			}
		}
		fprintf(stdout, "\n\n%.4lE\n\n", findMode(set, qmin, qmax, qprec, scheme, model));
		freeModel(model);
	} else {
		for(l = lmax; l>=1; l--) {
			double corr;
			TypeSetOfSequences *dec;
			scheme->cardCode = 0;
			buildCodeLength(l, scheme->suffixTree->root, 0, scheme);
//printLengthDistribution(stdout, scheme->lengthCode,scheme->cardCode);
			dec = getDecodedFromScheme(scheme);
//printf("cardinal dec = %ld\n", dec->cardinal);
			distB = computeWholeDistanceDec(dec);
			corr = computeCorrelation(distA, distB);
			monfree((void*)distB.table);
			fprintf(fo, "%ld\t%lf\n", l, corr);
			fprintf(stdout, "%ld\t%lf\n", l, corr);
			for(n=0; n<dec->number; n++)
				monfree((void*) dec->sequence[n]);
			monfree((void*) dec->sequence);
			monfree((void*) dec->size);
			monfree((void*) dec);
		}
	}
		
	freeScheme(scheme);
	monfree((void*)distA.table);
	fprintf(stdout, "\n\n%ld\n\n", totalLength(*set));
	monfree((void*)set->size);
	for(n=0; n<set->number; n++)
		monfree((void*)set->sequence[n]);
	monfree((void*)set->sequence);
	monfree((void*)set);
	fclose(fo);
/*	sprintf(bufferOutput, "%s_Ali.nex", outputFileName);
	if(!(fo = fopen(bufferOutput, "w")))
		exitProg(ErrorWriting, bufferOutput);
	printDistanceNexus(fo, distA);
	fclose(fo);
	sprintf(bufferOutput, "%s_New.nex", outputFileName);
	if(!(fo = fopen(bufferOutput, "w")))
		exitProg(ErrorWriting, bufferOutput);
	printDistanceNexus(fo, distB);
	fclose(fo);
*/
;
	exitProg(ExitOk,NULL);
	return 0;
}
Example #19
0
LineSegment* TextLine::createLineSegment()
      {
      return new TextLineSegment(score());
      }
Example #20
0
LineSegment* PalmMute::createLineSegment()
      {
      return new PalmMuteSegment(score());
      }
Example #21
0
void Graphe::paint(QGraphicsScene &scene,int wi,int he,QStringList *LesChaineADN)
{

    /*QLine ligne(50, 50, 200, 200);
    scene.addLine(ligne);*/

   int nbSequence=LesChaineADN->size();

   int plusLongSequence=LesChaineADN->at(0).size();

   for(int i=1;i<LesChaineADN->size();i++)
   {
       if(LesChaineADN->at(i).size()>plusLongSequence)
           plusLongSequence=LesChaineADN->at(i).size();
   }


   int distanct_w=5; // 5 pixel
   int distanct_h=5;

   if( nbSequence*5 < (he-espaceLibre) )
   {
       // on lesse 20 pixel de haut et 40 de bas
       distanct_h= (he-espaceLibre)/nbSequence;
   }

   if(plusLongSequence*5 < (wi-espaceLibre))
   {
       distanct_w= (wi-espaceLibre)/plusLongSequence;
   }


   /// calculer les score de chaque colone
    QList<int> listScorColon;
    score(listScorColon,LesChaineADN,plusLongSequence);

    QList<int> listPointScorY;

    int scoreMax=( fact(nbSequence)/(2*fact(nbSequence-2)) ) * scoreSimilarite;

    /// le point 0 = he - espaceLibre_B
    /// score max                       --------> he-(espaceLibre+10)
    /// score X (listScorColon.at(i))   --------> y
    /// y= listScorColon.at(i)* (he-(espaceLibre+20)) / score max
    /// 20 la posision de valMax avant la fine de flache
    /// pour inverser les point y on doit faire y=(he-espaceLibre_B)-y;

    qDebug("he : %d",he);
    qDebug("max : %d",he-(he-(espaceLibre+20)));
    qDebug("max : %d",espaceLibre_H+20);

    for(int i=0;i<listScorColon.size();i++)
    {                                                                           // scor max
        listPointScorY.append((he-espaceLibre_B)-((listScorColon.at(i)*(he-(espaceLibre+20))) / scoreMax));

        qDebug("le poit at: %d == %d",i,listPointScorY.at(i));
    }

    /////////// dessiner la line x
    scene.addLine(espaceLibre_L,he-espaceLibre_B,wi-espaceLibre_R,he-espaceLibre_B);
    scene.addLine(wi-espaceLibre_R-5,he-espaceLibre_B-5,wi-espaceLibre_R,he-espaceLibre_B);
    scene.addLine(wi-espaceLibre_R-5,he-espaceLibre_B+5,wi-espaceLibre_R,he-espaceLibre_B);


    /////////// dessiner la line y
    scene.addLine(espaceLibre_L,he-espaceLibre_B,espaceLibre_L,espaceLibre_H);
    scene.addLine(espaceLibre_L-5,espaceLibre_H+5,espaceLibre_L,espaceLibre_H);
    scene.addLine(espaceLibre_L+5,espaceLibre_H+5,espaceLibre_L,espaceLibre_H);


    /////////// score max
    scene.addLine(espaceLibre_L-3,espaceLibre_H+20,espaceLibre_L+3,espaceLibre_H+20,QPen(Qt::blue));

   ////////////// ajouter text
    QGraphicsTextItem *text_H=new QGraphicsTextItem("Taux d'alignement");
    QGraphicsTextItem *text_B=new QGraphicsTextItem("N=° colonne");
    scene.addItem(text_H);
    scene.addItem(text_B);

     text_H->setDefaultTextColor(Qt::red);
     text_B->setDefaultTextColor(Qt::red);

    text_H->setPos(10,0);
    text_B->setPos(wi-(espaceLibre_R*4),he-espaceLibre_B+2);



    int colone=espaceLibre_L;
    int colone2=distanct_w+ colone;

    for(int i=0;i < plusLongSequence-1;i++)
    {
        scene.addLine(colone,listPointScorY.at(i),colone2,listPointScorY.at(i+1),QPen(Qt::red));


        /////////// score x
        scene.addLine(espaceLibre_L-3,listPointScorY.at(i),espaceLibre_L+3,listPointScorY.at(i),QPen(Qt::blue));

        ////////// n=° colone
        scene.addLine(colone2,he-espaceLibre_B-3,colone2,he-espaceLibre_B+3,QPen(Qt::blue));

       colone=colone2;
       colone2+=distanct_w;




    }
}
Example #22
0
void PalmMute::setYoff(qreal val)
      {
      rUserYoffset() += val * spatium() - score()->styleP(placeAbove() ? Sid::palmMutePosAbove : Sid::palmMutePosBelow);
      }
Example #23
0
qreal Rest::centerX() const
      {
      return symbols[score()->symIdx()][_sym].width(magS())*.5;
      }
Example #24
0
LineSegment* Pedal::createLineSegment()
      {
      return new PedalSegment(score());
      }
Example #25
0
qreal Rest::downPos() const
      {
      return symbols[score()->symIdx()][_sym].bbox(magS()).y() + symbols[score()->symIdx()][_sym].height(magS());
      }
Example #26
0
void Pedal::setYoff(qreal val)
      {
      rUserYoffset() += val * spatium() - score()->styleP(placeAbove() ? StyleIdx::pedalPosAbove : StyleIdx::pedalPosBelow);
      }
Example #27
0
void Clef::layout()
      {
      // determine current number of lines and line distance
      int   lines       = 5;              // assume resonable defaults
      qreal lineDist    = 1.0;

      Staff*      stf         = staff();
      StaffType*  staffType   = nullptr;
      Segment*    clefSeg     = static_cast<Segment*>(parent());
      // check clef visibility and type compatibility
      if (clefSeg && stf && stf->staffType()) {
            bool        bHide;
            // check staff type allows clef display
            staffType = staff()->staffType();
#if 0 // <<<<<<< HEAD
            if (!staffType->genClef()) {        // if no clef, set empty bbox and do nothing
                  qDeleteAll(elements);
                  elements.clear();
                  setbbox(QRectF());
                  return;
                  }

            // tablatures:
            if (staffType->group() == StaffGroup::TAB) {
                  // if current clef type not compatible with tablature,
                  // set tab clef according to score style
                  if (ClefInfo::staffGroup(clefType()) != StaffGroup::TAB)
                        setClefType( ClefType(score()->styleI(StyleIdx::tabClef)) );
#else
            bHide = !staffType->genClef();

            // check clef is compatible with staff type group
            int tick = clefSeg->tick();
            if (ClefInfo::staffGroup(clefType()) != staffType->group()) {
                  if (tick > 0 && !generated()) // if clef is not generated, hide it
                        bHide = true;
                  else                          // if generated, replace with initial clef type
                        // TODO : instead of initial staff clef (which is assumed to be compatible)
                        // use the last compatible clef previously found in staff
                        _clefTypes = stf->clefTypeList(0);
#endif      // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79
                  }

            //
            // courtesy clef
            //
            bool showClef = true;
#if 0 // <<<<<<< HEAD
            Segment* clefSeg = static_cast<Segment*>(parent());
            if (clefSeg) {
                  int tick = clefSeg->tick();
                  // only if there is a clef change
                  if (stf->clef(tick) != stf->clef(tick-1)) {
                        // locate clef at the begining of next measure, if any
                        Clef*       clefNext    = nullptr;
                        Segment*    clefSegNext = nullptr;
                        Measure*    meas        = static_cast<Measure*>(clefSeg->parent());
                        Measure*    measNext    = meas->nextMeasure();
                        if (measNext) {
                              clefSegNext = measNext->findSegment(SegmentType::Clef, tick);
                              if (clefSegNext)
                                    clefNext = static_cast<Clef*>(clefSegNext->element(track()));
                              }
                        // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure)
                        showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks())
                              // if courtesy clef: show if score has courtesy clefs on
                              || ( score()->styleB(StyleIdx::genCourtesyClef)
                              // AND measure is not at the end of a repeat or of a section
                              && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() )
                              // AND this clef has courtesy clef turned on
                              && showCourtesy() );
                        if (!showClef)    {     // if no clef, set empty bbox and do nothing
                              qDeleteAll(elements);
                              elements.clear();
                              setbbox(QRectF());
                              return;
                              }
#else
            // only if there is a clef change
            if (!bHide && tick > 0 && stf->clef(tick) != stf->clef(tick-1)) {
                  // locate clef at the begining of next measure, if any
                  Clef*       clefNext    = nullptr;
                  Segment*    clefSegNext = nullptr;
                  Measure*    meas        = static_cast<Measure*>(clefSeg->parent());
                  Measure*    measNext    = meas->nextMeasure();
                  if (measNext) {
                        clefSegNext = measNext->findSegment(SegmentType::Clef, tick);
                        if (clefSegNext)
                              clefNext = static_cast<Clef*>(clefSegNext->element(track()));
#endif      // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79
                        }
                  // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure)
                  showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks())
                        // if courtesy clef: show if score has courtesy clefs on
                        || ( score()->styleB(StyleIdx::genCourtesyClef)
                        // AND measure is not at the end of a repeat or of a section
                        && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() )
                        // AND this clef has courtesy clef turned on
                        && showCourtesy() );
                  bHide |= !showClef;
                  }

            // if clef not to show or not compatible with staff group
            if (bHide) {
                  qDeleteAll(elements);         // set empty bbox and do nothing
                  elements.clear();
                  setbbox(QRectF());
                  return;
                  }

            lines = staffType->lines();         // init values from staff type
            lineDist = staffType->lineDistance().val();
            }

      // if nothing changed since last layout, do nothing
//DEBUG      if (curClefType == clefType() && curLines == lines && curLineDist == lineDist)
//            return;
      // if something has changed, cache new values and re-layout
      curClefType = clefType();
      curLines    = lines;
      curLineDist = lineDist;
      layout1();
      }

//---------------------------------------------------------
//   layout1
//---------------------------------------------------------

void Clef::layout1()
      {
      qreal smag     = mag();
      qreal _spatium = spatium();
      // qreal msp      = score()->spatium() * smag;
      qreal yoff     = 0.0;

      qDeleteAll(elements);
      elements.clear();

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

      switch (curClefType) {
            case ClefType::G:                              // G clef on 2nd line
                  symbol->setSym(SymId::gClef);
                  yoff = 3.0 * curLineDist;
                  break;
            case ClefType::G1:                             // G clef 8va on 2nd line
                  symbol->setSym(SymId::gClef8va);
                  yoff = 3.0 * curLineDist;
                  break;
            case ClefType::G2:                             // G clef 15ma on 2nd line
                  symbol->setSym(SymId::gClef15ma);
                  yoff = 3.0 * curLineDist;
                  break;
            case ClefType::G3:                             // G clef 8vb on 2nd line
                  symbol->setSym(SymId::gClef8vb);
                  yoff = 3.0 * curLineDist;
                  break;
            case ClefType::F:                              // F clef on penultimate line
                  symbol->setSym(SymId::fClef);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::F8:                             // F clef 8va bassa on penultimate line
                  symbol->setSym(SymId::fClef8vb);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::F15:                            // F clef 15ma bassa on penultimate line
                  symbol->setSym(SymId::fClef15mb);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::F_B:                            // baritone clef
                  symbol->setSym(SymId::fClef);
                  yoff = 2.0 * curLineDist;
                  break;
            case ClefType::F_C:                            // subbass clef
                  symbol->setSym(SymId::fClef);
                  yoff = 0.0;
                  break;
            case ClefType::C1:                             // C clef in 1st line
                  symbol->setSym(SymId::cClef);
                  yoff = 4.0 * curLineDist;
                  break;
            case ClefType::C2:                             // C clef on 2nd line
                  symbol->setSym(SymId::cClef);
                  yoff = 3.0 * curLineDist;
                  break;
            case ClefType::C3:                             // C clef in 3rd line
                  symbol->setSym(SymId::cClef);
                  yoff = 2.0 * curLineDist;
                  break;
            case ClefType::C4:                             // C clef on 4th line
                  symbol->setSym(SymId::cClef);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::C5:                             // C clef on 5th line
                  symbol->setSym(SymId::cClef);
                  yoff = 0.0;
                  break;
            case ClefType::TAB:                            // TAB clef
                  symbol->setSym(SymId::sixStringTabClef);
                  // on tablature, position clef at half the number of spaces * line distance
                  yoff = curLineDist * (curLines - 1) * .5;
                  break;
            case ClefType::TAB2:                           // TAB clef alternate style
                  symbol->setSym(SymId::sixStringTabClefSerif);
                  // on tablature, position clef at half the number of spaces * line distance
                  yoff = curLineDist * (curLines - 1) * .5;
                  break;
            case ClefType::PERC:                           // percussion clefs
            case ClefType::PERC2:         // no longer supported: fall back to same glyph as PERC
                  symbol->setSym(SymId::unpitchedPercussionClef1);
                  yoff = curLineDist * (curLines - 1) * 0.5;
                  break;
            case ClefType::G4:                             // G clef in 1st line
                  symbol->setSym(SymId::gClef);
                  yoff = 4.0 * curLineDist;
                  break;
            case ClefType::F_8VA:                          // F clef 8va on penultimate line
                  symbol->setSym(SymId::fClef8va);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::F_15MA:                         // F clef 15ma on penultimate line
                  symbol->setSym(SymId::fClef15ma);
                  yoff = 1.0 * curLineDist;
                  break;
            case ClefType::INVALID:
            case ClefType::MAX:
                  return;
            }

      symbol->setMag(smag);
      symbol->layout();
      addElement(symbol, .0, yoff * _spatium);
      setbbox(QRectF());
      for (auto i = elements.begin(); i != elements.end(); ++i) {
            Element* e = *i;
            e->setColor(curColor());
            addbbox(e->bbox().translated(e->pos()));
            e->setSelected(selected());
            }
      }

//---------------------------------------------------------
//   draw
//---------------------------------------------------------

void Clef::draw(QPainter* painter) const
      {
      if (staff() && !staff()->staffType()->genClef())
            return;
      QColor color(curColor());
      foreach(Element* e, elements) {
            e->setColor(color);
            QPointF pt(e->pos());
            painter->translate(pt);
            e->draw(painter);
            painter->translate(-pt);
            }
      }
Example #28
0
QPointF Pedal::linePos(Grip grip, System** sys) const
      {
      qreal x;
      qreal nhw = score()->noteHeadWidth();
      System* s = nullptr;
      if (grip == Grip::START) {
            ChordRest* c = static_cast<ChordRest*>(startElement());
            s = c->segment()->system();
            x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
            if (c->type() == Element::Type::REST && c->durationType() == TDuration::DurationType::V_MEASURE)
                  x -= c->x();
            if (beginHook() && beginHookType() == HookType::HOOK_45)
                  x += nhw * .5;
            }
      else {
            Element* e = endElement();
            ChordRest* c = static_cast<ChordRest*>(endElement());
            if (!e || e == startElement() || (endHook() && endHookType() == HookType::HOOK_90)) {
                  // pedal marking on single note or ends with non-angled hook:
                  // extend to next note or end of measure
                  Segment* seg = nullptr;
                  if (!e)
                        seg = startSegment();
                  else
                        seg = c->segment();
                  if (seg) {
                        seg = seg->next();
                        for ( ; seg; seg = seg->next()) {
                              if (seg->segmentType() == Segment::Type::ChordRest) {
                                    // look for a chord/rest in any voice on this staff
                                    bool crFound = false;
                                    int track = staffIdx() * VOICES;
                                    for (int i = 0; i < VOICES; ++i) {
                                          if (seg->element(track + i)) {
                                                crFound = true;
                                                break;
                                                }
                                          }
                                    if (crFound)
                                          break;
                                    }
                              else if (seg->segmentType() == Segment::Type::EndBarLine) {
                                    break;
                                    }
                              }
                        }
                  if (seg) {
                        s = seg->system();
                        x = seg->pos().x() + seg->measure()->pos().x() - nhw * 2;
                        }
                  }
            else if (c) {
                  s = c->segment()->system();
                  x = c->pos().x() + c->segment()->pos().x() + c->segment()->measure()->pos().x();
                  if (c->type() == Element::Type::REST && c->durationType() == TDuration::DurationType::V_MEASURE)
                        x -= c->x();
                  }
            if (!s) {
                  int t = tick2();
                  Measure* m = score()->tick2measure(t);
                  s = m->system();
                  x = m->tick2pos(t);
                  }
            if (endHook() && endHookType() == HookType::HOOK_45)
                  x += nhw * .5;
            else
                  x += nhw;
            }

      *sys = s;
      return QPointF(x, 0);
      }
Example #29
0
void Box::read(XmlReader& e)
      {
      _leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0;
      bool keepMargins = false;        // whether original margins have to be kept when reading old file

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "height")
                  _boxHeight = Spatium(e.readDouble());
            else if (tag == "width")
                  _boxWidth = Spatium(e.readDouble());
            else if (tag == "topGap")
                  _topGap = e.readDouble();
            else if (tag == "bottomGap")
                  _bottomGap = e.readDouble();
            else if (tag == "leftMargin")
                  _leftMargin = e.readDouble();
            else if (tag == "rightMargin")
                  _rightMargin = e.readDouble();
            else if (tag == "topMargin")
                  _topMargin = e.readDouble();
            else if (tag == "bottomMargin")
                  _bottomMargin = e.readDouble();
            else if (tag == "Text") {
                  Text* t;
                  if (type() == TBOX) {
                        t = static_cast<TBox*>(this)->getText();
                        t->read(e);
                        }
                  else {
                        t = new Text(score());
                        t->read(e);
                        add(t);
                        if (score()->mscVersion() <= 114)
                              t->setLayoutToParentWidth(true);
                        }
                  }
            else if (tag == "Symbol") {
                  Symbol* s = new Symbol(score());
                  s->read(e);
                  add(s);
                  }
            else if (tag == "Image") {
                  Image* image = new Image(score());
                  image->setTrack(e.track());
                  image->read(e);
                  add(image);
                  }
            else if (tag == "FretDiagram") {
                  FretDiagram* f = new FretDiagram(score());
                  f->read(e);
                  add(f);
                  }
            else if (tag == "LayoutBreak") {
                  LayoutBreak* lb = new LayoutBreak(score());
                  lb->read(e);
                  add(lb);
                  }
            else if (tag == "HBox") {
                  HBox* hb = new HBox(score());
                  hb->read(e);
                  add(hb);
                  keepMargins = true;     // in old file, box nesting used outer box margins
                  }
            else if (tag == "VBox") {
                  VBox* vb = new VBox(score());
                  vb->read(e);
                  add(vb);
                  keepMargins = true;     // in old file, box nesting used outer box margins
                  }
            else if (Element::readProperties(e))
                  ;
            else
                  e.unknown();
            }

      // with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box:
      // for backward compatibility set them to 0 in all other cases

      if (score()->mscVersion() < 117 && (type() == HBOX || type() == VBOX) && !keepMargins)  {
            _leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0;
            }
      }
Example #30
0
void Hairpin::undoSetHairpinType(Type val)
      {
      score()->undoChangeProperty(this, P_ID::HAIRPIN_TYPE, int(val));
      }