void View::DrawMensuralRest(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { assert(dc); assert(element); assert(layer); assert(staff); assert(measure); wchar_t charCode; Rest *rest = dynamic_cast<Rest *>(element); assert(rest); bool drawingCueSize = rest->IsCueSize(); int drawingDur = rest->GetActualDur(); int x = element->GetDrawingX(); int y = element->GetDrawingY(); switch (drawingDur) { case DUR_MX: charCode = SMUFL_E9F0_mensuralRestMaxima; break; case DUR_LG: charCode = SMUFL_E9F2_mensuralRestLongaImperfecta; break; case DUR_BR: charCode = SMUFL_E9F3_mensuralRestBrevis; break; case DUR_1: charCode = SMUFL_E9F4_mensuralRestSemibrevis; break; case DUR_2: charCode = SMUFL_E9F5_mensuralRestMinima; break; case DUR_4: charCode = SMUFL_E9F6_mensuralRestSemiminima; break; case DUR_8: charCode = SMUFL_E9F7_mensuralRestFusa; break; case DUR_16: charCode = SMUFL_E9F8_mensuralRestSemifusa; break; default: charCode = 0; // This should never happen } DrawSmuflCode(dc, x, y, charCode, staff->m_drawingStaffSize, drawingCueSize); }
int LayerElement::SetDrawingXY( ArrayPtrVoid *params ) { // param 0: a pointer doc // param 1: a pointer to the current system (unused) // param 2: a pointer to the current measure // param 3: a pointer to the current staff // param 4: a pointer to the current layer // param 5: a pointer to the view // param 6: a bool indicating if we are processing layer elements or not Doc *doc = static_cast<Doc*>((*params).at(0)); Measure **currentMeasure = static_cast<Measure**>((*params).at(2)); Staff **currentStaff = static_cast<Staff**>((*params).at(3)); Layer **currentLayer = static_cast<Layer**>((*params).at(4)); View *view = static_cast<View*>((*params).at(5)); bool *processLayerElements = static_cast<bool*>((*params).at(6)); // First pass, only set the X position if ((*processLayerElements)==false) { // Here we set the appropriate x value to be used for drawing // With Raw documents, we use m_drawingXRel that is calculated by the layout algorithm // With Transcription documents, we use the m_xAbs if ( this->m_xAbs == VRV_UNSET ) { assert( doc->GetType() == Raw ); this->SetDrawingX( this->GetXRel() + (*currentMeasure)->GetDrawingX() ); // Grace notes, also take into account the GraceAlignment Note *note = dynamic_cast<Note*>(this); if (note && note->HasGraceAlignment() ) { this->SetDrawingX( this->GetDrawingX() - note->GetAlignment()->GetGraceAligner()->GetWidth() + note->GetGraceAlignment()->GetXRel() ); } } else { assert( doc->GetType() == Transcription ); this->SetDrawingX( this->m_xAbs ); } return FUNCTOR_CONTINUE; } LayerElement *layerElementY = this; // Look for cross-staff situations // If we have one, make is available in m_crossStaff DurationInterface *durElement = dynamic_cast<DurationInterface*>(this); if ( durElement && durElement->HasStaff()) { AttCommonNComparison comparisonFirst( STAFF, durElement->GetStaff() ); m_crossStaff = dynamic_cast<Staff*>((*currentMeasure)->FindChildByAttComparison(&comparisonFirst, 1)); if (m_crossStaff) { if (m_crossStaff == (*currentStaff)) LogWarning("The cross staff reference '%d' for element '%s' seems to be identical to the parent staff", durElement->GetStaff(), this->GetUuid().c_str()); // Now try to get the corresponding layer - for now look for the same layer @n int layerN = (*currentLayer)->GetN(); // When we will have allowed @layer in <note>, we will have to do: // int layerN = durElement->HasLayer() ? durElement->GetLayer() : (*currentLayer)->GetN(); AttCommonNComparison comparisonFirstLayer( LAYER, layerN ); m_crossLayer = dynamic_cast<Layer*>(m_crossStaff->FindChildByAttComparison(&comparisonFirstLayer, 1)); if (m_crossLayer) { // Now we need to yet the element at the same position in the cross-staff layer of getting the right clef layerElementY = m_crossLayer->GetAtPos( this->GetDrawingX() ); } else { LogWarning("Could not get the layer with cross-staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); } } else { LogWarning("Could not get the cross staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); } // If we have a @layer we probably also want to change the layer element (for getting the right clef if different) } else { m_crossStaff = NULL; m_crossLayer = NULL; } Staff *staffY = m_crossStaff ? m_crossStaff : (*currentStaff); Layer *layerY = m_crossLayer ? m_crossLayer : (*currentLayer); // Here we set the appropriate Y value to be used for drawing if ( this->m_xAbs == VRV_UNSET ) { assert( doc->GetType() == Raw ); this->SetDrawingY( staffY->GetDrawingY() ); } else { assert( doc->GetType() == Transcription ); this->SetDrawingY( staffY->GetDrawingY() ); } // Finally, adjust Y for notes and rests if (this->Is() == NOTE) { Note *note = dynamic_cast<Note*>(this); assert( note ); this->SetDrawingY( this->GetDrawingY() + view->CalculatePitchPosY( staffY, note->GetPname(), layerY->GetClefOffset( layerElementY ), note->GetOct() ) ); } else if (this->Is() == REST) { Rest *rest = dynamic_cast<Rest*>(this); assert( rest ); // Automatically calculate rest position, if so requested if (rest->GetPloc() == PITCHNAME_NONE) { this->SetDrawingY( this->GetDrawingY() + view->CalculateRestPosY( staffY, rest->GetActualDur()) ); } else { this->SetDrawingY( this->GetDrawingY() + view->CalculatePitchPosY( staffY, rest->GetPloc(), layerY->GetClefOffset( layerElementY ), rest->GetOloc()) ); } } return FUNCTOR_CONTINUE; }