data_STEMDIRECTION Layer::GetDrawingStemDir(const ArrayOfBeamElementCoords *coords) { assert(!coords->empty()); // Adjust the x position of the first and last element for taking into account the stem width LayerElement *first = dynamic_cast<LayerElement *>(coords->front()->m_element); LayerElement *last = dynamic_cast<LayerElement *>(coords->back()->m_element); if (!first || !last) { return m_drawingStemDir; } Measure *measure = dynamic_cast<Measure *>(this->GetFirstParent(MEASURE)); assert(measure); // First check if there is any <space> in the measure - if not we can return the layer stem direction if (!measure->FindChildByType(SPACE)) { return m_drawingStemDir; } Alignment *alignmentFirst = first->GetAlignment(); assert(alignmentFirst); Alignment *alignmentLast = last->GetAlignment(); assert(alignmentLast); // We are ignoring cross-staff situation here because this should not be called if we have one Staff *staff = dynamic_cast<Staff *>(first->GetFirstParent(STAFF)); assert(staff); double time = alignmentFirst->GetTime(); double duration = alignmentLast->GetTime() - time + last->GetAlignmentDuration(); duration = durRound(duration); return GetDrawingStemDir(time, duration, measure, staff->GetN()); }
std::vector<Staff *> TimePointInterface::GetTstampStaves(Measure *measure) { std::vector<Staff *> staves; std::vector<int>::iterator iter; std::vector<int> staffList; if (this->HasStaff()) { staffList = this->GetStaff(); } else if (m_start) { Staff *staff = dynamic_cast<Staff *>(m_start->GetFirstParent(STAFF)); if (staff) staffList.push_back(staff->GetN()); } for (iter = staffList.begin(); iter != staffList.end(); iter++) { AttCommonNComparison comparison(STAFF, *iter); Staff *staff = dynamic_cast<Staff *>(measure->FindChildByAttComparison(&comparison, 1)); if (!staff) { // LogDebug("Staff with @n '%d' not found in measure '%s'", *iter, measure->GetUuid().c_str()); continue; } staves.push_back(staff); } if (staves.empty()) LogDebug("Empty @staff array"); return staves; }
void Measure::AddChild(Object *child) { if (child->IsControlElement()) { assert(dynamic_cast<ControlElement *>(child)); } else if (child->IsEditorialElement()) { assert(dynamic_cast<EditorialElement *>(child)); } else if (child->Is(STAFF)) { Staff *staff = dynamic_cast<Staff *>(child); assert(staff); if (staff && (staff->GetN() < 1)) { // This is not 100% safe if we have a <app> and <rdg> with more than // one staff as a previous child. staff->SetN(this->GetChildCount()); } } else { LogError("Adding '%s' to a '%s'", child->GetClassName().c_str(), this->GetClassName().c_str()); assert(false); } child->SetParent(this); m_children.push_back(child); Modify(); }
int Layer::PrepareProcessingLists(FunctorParams *functorParams) { PrepareProcessingListsParams *params = dynamic_cast<PrepareProcessingListsParams *>(functorParams); assert(params); // Alternate solution with StaffN_LayerN_VerseN_t // StaffN_LayerN_VerseN_t *tree = static_cast<StaffN_LayerN_VerseN_t*>((*params).at(0)); Staff *staff = dynamic_cast<Staff *>(this->GetFirstParent(STAFF)); assert(staff); params->m_layerTree.child[staff->GetN()].child[this->GetN()]; return FUNCTOR_CONTINUE; }
void Measure::AddFloatingElement( FloatingElement *element ) { element->SetParent( this ); m_children.push_back( element ); if (element->Is() == STAFF) { Staff *staff = dynamic_cast<Staff*>(element); assert( staff ); if ( staff->GetN() < 1) { // This is not 100% safe if we have a <app> and <rdg> with more than // one staff as a previous child. staff->SetN( this->GetChildCount() ); } } }
bool TimePointInterface::IsOnStaff(int n) { if (this->HasStaff()) { std::vector<int> staffList = this->GetStaff(); std::vector<int>::iterator iter; for (iter = staffList.begin(); iter != staffList.end(); iter++) { if (*iter == n) return true; } return false; } else if (m_start) { Staff *staff = dynamic_cast<Staff *>(m_start->GetFirstParent(STAFF)); if (staff && (staff->GetN() == n)) return true; } return false; }
int Verse::PrepareProcessingLists(FunctorParams *functorParams) { PrepareProcessingListsParams *params = dynamic_cast<PrepareProcessingListsParams *>(functorParams); assert(params); // StaffN_LayerN_VerseN_t *tree = static_cast<StaffN_LayerN_VerseN_t*>((*params).at(0)); Staff *staff = dynamic_cast<Staff *>(this->GetFirstParent(STAFF)); Layer *layer = dynamic_cast<Layer *>(this->GetFirstParent(LAYER)); assert(staff && layer); params->m_verseTree.child[staff->GetN()].child[layer->GetN()].child[this->GetN()]; // Alternate solution with StaffN_LayerN_VerseN_t //(*tree)[ staff->GetN() ][ layer->GetN() ][ this->GetN() ] = true; return FUNCTOR_SIBLINGS; }
int Verse::PrepareProcessingLists(ArrayPtrVoid *params) { // param 0: the IntTree* for staff/layer/verse // param 1: the IntTree* for staff/layer (unused) IntTree *tree = static_cast<IntTree *>((*params).at(0)); // Alternate solution with StaffN_LayerN_VerseN_t // StaffN_LayerN_VerseN_t *tree = static_cast<StaffN_LayerN_VerseN_t*>((*params).at(0)); Staff *staff = dynamic_cast<Staff *>(this->GetFirstParent(STAFF)); Layer *layer = dynamic_cast<Layer *>(this->GetFirstParent(LAYER)); assert(staff && layer); tree->child[staff->GetN()].child[layer->GetN()].child[this->GetN()]; // Alternate solution with StaffN_LayerN_VerseN_t //(*tree)[ staff->GetN() ][ layer->GetN() ][ this->GetN() ] = true; return FUNCTOR_SIBLINGS; }
int Layer::AlignHorizontallyEnd(FunctorParams *functorParams) { AlignHorizontallyParams *params = dynamic_cast<AlignHorizontallyParams *>(functorParams); assert(params); params->m_scoreDefRole = SCOREDEF_CAUTIONARY; params->m_time = params->m_measureAligner->GetMaxTime(); if (this->GetCautionStaffDefClef()) { GetCautionStaffDefClef()->AlignHorizontally(params); } if (this->GetCautionStaffDefKeySig()) { GetCautionStaffDefKeySig()->AlignHorizontally(params); } if (this->GetCautionStaffDefMensur()) { GetCautionStaffDefMensur()->AlignHorizontally(params); } if (this->GetCautionStaffDefMeterSig()) { GetCautionStaffDefMeterSig()->AlignHorizontally(params); } params->m_scoreDefRole = SCOREDEF_NONE; Staff *staff = dynamic_cast<Staff *>(this->GetFirstParent(STAFF)); assert(staff); int graceAlignerId = params->m_doc->GetOptions()->m_graceRhythmAlign.GetValue() ? 0 : staff->GetN(); int i; for (i = 0; i < params->m_measureAligner->GetChildCount(); ++i) { Alignment *alignment = dynamic_cast<Alignment *>(params->m_measureAligner->GetChild(i)); assert(alignment); if (alignment->HasGraceAligner(graceAlignerId)) { alignment->GetGraceAligner(graceAlignerId)->AlignStack(); } } return FUNCTOR_CONTINUE; }
data_STEMDIRECTION Layer::GetDrawingStemDir(LayerElement *element) { assert(element); Measure *measure = dynamic_cast<Measure *>(this->GetFirstParent(MEASURE)); assert(measure); // First check if there is any <space> in the measure - if not we can return the layer stem direction if (!measure->FindChildByType(SPACE)) { return m_drawingStemDir; } Alignment *alignment = element->GetAlignment(); assert(alignment); Layer *layer = NULL; Staff *staff = element->GetCrossStaff(layer); if (!staff) { staff = dynamic_cast<Staff *>(element->GetFirstParent(STAFF)); } // At this stage we have the parent or the cross-staff assert(staff); return GetDrawingStemDir(alignment->GetTime(), element->GetAlignmentDuration(), measure, staff->GetN()); }
int Object::SetCurrentScoreDef( ArrayPtrVoid params ) { // param 0: the current scoreDef ScoreDef *currentScoreDef = static_cast<ScoreDef*>(params[0]); StaffDef **currentStaffDef = static_cast<StaffDef**>(params[1]); assert( currentScoreDef ); // starting a new page Page *page = dynamic_cast<Page*>(this); if ( page ) { if ( page->m_parent->GetChildIndex( page ) == 0 ) { currentScoreDef->SetRedrawFlags( true, true, true, true ); currentScoreDef->SetDrawLabels( true ); } else { currentScoreDef->SetRedrawFlags( true, true, false, false ); currentScoreDef->SetDrawLabels( false ); } page->m_drawingScoreDef = *currentScoreDef; return FUNCTOR_CONTINUE; } // starting a new system System *system = dynamic_cast<System*>(this); if ( system ) { currentScoreDef->SetRedrawFlags( true, true, false, false ); return FUNCTOR_CONTINUE; } // starting a new scoreDef ScoreDef *scoreDef= dynamic_cast<ScoreDef*>(this); if ( scoreDef ) { bool drawClef = false; bool drawKeySig = false; bool drawMensur = false; bool drawMeterSig = false; if (scoreDef->GetClef()) { currentScoreDef->ReplaceClef(scoreDef->GetClef()); drawClef = true; } if (scoreDef->GetKeySig()) { currentScoreDef->ReplaceKeySig(scoreDef->GetKeySig()); drawKeySig = true; } if (scoreDef->GetMensur()) { currentScoreDef->ReplaceMensur(scoreDef->GetMensur()); drawMensur = true; } if (scoreDef->GetMeterSig()) { currentScoreDef->ReplaceMeterSig(scoreDef->GetMeterSig()); drawMeterSig = true; } // Replace the current scoreDef with the new one, including its content (staffDef) currentScoreDef->Replace(scoreDef); currentScoreDef->SetRedrawFlags( drawClef, drawKeySig, drawMensur, drawMeterSig ); return FUNCTOR_CONTINUE; } // starting a new staffDef // Because staffDef have to be included in a scoreDef, a new staffDef was already // replaced by the new scoreDef (see above). Here we only need to reset the drawing flags StaffDef *staffDef= dynamic_cast<StaffDef*>(this); if ( staffDef ) { StaffDef *tmpStaffDef = currentScoreDef->GetStaffDef( staffDef->GetN() ); if (staffDef->GetClef()) { tmpStaffDef->SetDrawClef( true ); } if (staffDef->GetKeySig()) { tmpStaffDef->SetDrawKeySig( true ); } if (staffDef->GetMensur()) { tmpStaffDef->SetDrawMensur( true ); } if (staffDef->GetMeterSig()) { tmpStaffDef->SetDrawMeterSig( true ); } } // starting a new staff Staff *staff = dynamic_cast<Staff*>(this); if ( staff ) { (*currentStaffDef) = currentScoreDef->GetStaffDef( staff->GetN() ); return FUNCTOR_CONTINUE; } // starting a new layer Layer *layer = dynamic_cast<Layer*>(this); if ( layer ) { // setting the layer stem direction. Alternatively, this could be done in // View::DrawLayer. If this (and other things) is kept here, renaming the method to something more // generic (PrepareDrawing?) might be a good idea... if (layer->m_parent->GetChildCount() > 1) { if (layer->m_parent->GetChildIndex(layer)==0) { layer->SetDrawingStemDir(STEMDIRECTION_up); } else { layer->SetDrawingStemDir(STEMDIRECTION_down); } } layer->SetDrawingAndCurrentValues( currentScoreDef, (*currentStaffDef) ); return FUNCTOR_CONTINUE; } // starting a new clef Clef *clef = dynamic_cast<Clef*>(this); if ( clef ) { assert( *currentStaffDef ); (*currentStaffDef)->ReplaceClef( clef ); return FUNCTOR_CONTINUE; } // starting a new keysig KeySig *keysig = dynamic_cast<KeySig*>(this); if ( keysig ) { assert( *currentStaffDef ); (*currentStaffDef)->ReplaceKeySig( keysig ); return FUNCTOR_CONTINUE; } return FUNCTOR_CONTINUE; }