Acad::ErrorStatus AsdkSmiley::osnapQuad( const AcGePoint3d& pickPoint, AcGePoint3dArray& snapPoints) const { AcGeVector3d xoff(0,0,0); AcGeVector3d yoff(0,0,0); // Osnap quad to the face's quad points // xoff.x = yoff.y = radius(); AcGePoint3d center( center() ); snapPoints.append( center + xoff ); snapPoints.append( center + yoff ); snapPoints.append( center - xoff ); snapPoints.append( center - yoff ); // Osnap quad to the eyes' quad points // AcGePoint3dArray eyearray; AcGePoint3d eyecen; eyes( eyearray ); for( int i = 0; i < eyearray.length(); i++ ){ eyecen = eyearray.at( i ); xoff.x = meyesize; yoff.y = meyesize; snapPoints.append( eyecen + xoff ); snapPoints.append( eyecen + yoff ); snapPoints.append( eyecen - xoff ); snapPoints.append( eyecen - yoff ); } return Acad::eOk; }
void RayGenerator::Generate(int level,int pw,int ph,int x,int y, Vec3q *out) const { { DASSERT(level == 3); GridSampler sampler; Vec3q right(tright), up(tup), tadd = txyz; floatq xoff(x + 0, x + 0, x + 2, x + 2); floatq yoff(y + 0, y + 0, y - 1, y - 1); for(int ty = 0; ty < 16; ty++) { floatq tposx[4] = { floatq(0.0f) + xoff, floatq(4.0f) + xoff, floatq(8.0f) + xoff, floatq(12.0f) + xoff }; floatq tposy = floatq(ty) + yoff; Vec3q tpoint = up * tposy + tadd; Vec3q points[4] = { right * tposx[0] + tpoint, right * tposx[1] + tpoint, right * tposx[2] + tpoint, right * tposx[3] + tpoint }; out[ty * 4 + 0] = points[0] * RSqrt(points[0] | points[0]); out[ty * 4 + 1] = points[1] * RSqrt(points[1] | points[1]); out[ty * 4 + 2] = points[2] * RSqrt(points[2] | points[2]); out[ty * 4 + 3] = points[3] * RSqrt(points[3] | points[3]); } return; } if(level > 2) { int npw = pw >> 1, nph = ph >> 1, nl = level - 1; Generate(nl, npw, nph, x , y , out + 0); Generate(nl, npw, nph, x + npw, y , out + (1 << nl*2)); Generate(nl, npw, nph, x , y + nph, out + (2 << nl*2)); Generate(nl, npw, nph, x + npw, y + nph, out + (3 << nl*2)); return; }
Acad::ErrorStatus AsdkSmiley::getGripPoints( AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds) const { assertReadEnabled(); // Grip points to face // AcGePoint3d center( center() ); gripPoints.append( center ); AcGeVector3d xoff( radius(), 0, 0 ), yoff( 0, radius(), 0 ); gripPoints.append( center + xoff ); gripPoints.append( center + yoff ); gripPoints.append( center - xoff ); gripPoints.append( center - yoff ); // Grip points to mouth // AcGeLineSeg3d chord( mouthLeft(), mouthRight() ); gripPoints.append( mouthLeft() ); gripPoints.append( mouthRight() ); gripPoints.append( chord.midPoint() ); gripPoints.append( mouthBottom() ); // Grip points to eyes // AcGePoint3dArray eyearray; AcGePoint3d eyecen; eyes( eyearray ); for( int i = 0; i < eyearray.length(); i++ ){ eyecen = eyearray.at( i ); gripPoints.append( eyecen ); AcGeVector3d xoff( meyesize, 0, 0 ), yoff( 0, meyesize, 0 ); gripPoints.append( eyecen + xoff ); gripPoints.append( eyecen + yoff ); gripPoints.append( eyecen - xoff ); gripPoints.append( eyecen - yoff ); } return Acad::eOk; }
AcGePoint3d AsdkSmiley::mouthBottom() const { assertReadEnabled(); AcGeVector3d yoff( 0, radius(), 0 ); AcGePoint3d center( center() ); AcGePoint3d faceBottom( center - yoff ); AcGePointOnCurve3d pntCurve; mmoutharc.getClosestPointTo( faceBottom, pntCurve ); return pntCurve.point(); }
Acad::ErrorStatus AsdkSmiley::osnapNear( const AcGePoint3d& pickPoint, AcGePoint3dArray& snapPoints) const { // For osnap near, define the same points as the grip points. // This definitely not the proper implementation, but it is // adequate for this simple sample. // AcGeVector3d xoff( radius(), 0, 0 ); AcGeVector3d yoff( 0, radius(), 0 ); AcGePoint3d center( center() ); snapPoints.append( center + xoff ); snapPoints.append( center + yoff ); snapPoints.append( center - xoff ); snapPoints.append( center - yoff ); return Acad::eOk; }
void Trill::layout() { qreal _spatium = spatium(); setPos(0.0, yoff() * _spatium); SLine::layout(); // // special case: // if end segment is first chord/rest segment in measure, // shorten trill line so it ends at end of previous measure // Segment* seg1 = static_cast<Segment*>(startElement()); Segment* seg2 = static_cast<Segment*>(endElement()); if (seg2 && (seg1->system() == seg2->system()) && (spannerSegments().size() == 1) && (seg2->tick() == seg2->measure()->tick()) ) { qreal x1 = seg2->pagePos().x(); Measure* m = seg2->measure()->prevMeasure(); if (m) { Segment* s2 = m->last(); qreal x2 = s2->pagePos().x(); qreal dx = x1 - x2 + _spatium * .3; TrillSegment* ls = static_cast<TrillSegment*>(frontSegment()); ls->setPos2(ls->ipos2() + QPointF(-dx, 0.0)); ls->layout(); } } if (_accidental) { _accidental->setMag(.6); _accidental->layout(); _accidental->setPos(_spatium*1.3, -2.2*_spatium); _accidental->adjustReadPos(); } }
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(); 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(point(_extraLeadingSpace)); _space.setRw(width() + point(_extraTrailingSpace + rs)); // adjustReadPos(); }
void Ottava::layout() { setPos(0.0, yoff() * spatium()); SLine::layout(); }
void Volta::layout() { setPos(0.0, yoff() * spatium()); TextLine::layout(); }