//--------------------------------------------------------------------------------------- void SelectionSet::add_gmo(GmoObj* pGmo, bool fSaveImoId) { ensure_set_is_valid(); m_gmos.push_back(pGmo); ImoObj* pImo = pGmo->get_creator_imo(); if (pImo) { m_imos.push_back(pImo); if (fSaveImoId) m_ids.push_back( pImo->get_id() ); if (pImo->is_staffobj()) add_staffobj_to_collection( static_cast<ImoStaffObj*>(pImo) ); } }
//--------------------------------------------------------------------------------------- void SelectionSet::ensure_set_is_valid() { if (!m_fValid) { if (m_pDoc) { m_gmos.clear(); m_imos.clear(); delete m_pCollection; m_pCollection = NULL; m_pMasterCollection = NULL; m_fValid = true; list<ImoId>::iterator it = m_ids.begin(); while (it != m_ids.end()) { ImoObj* pImo = m_pDoc->get_pointer_to_imo(*it); if (pImo) { m_imos.push_back(pImo); if (pImo->is_staffobj()) add_staffobj_to_collection( static_cast<ImoStaffObj*>(pImo) ); if (m_pGModel) //In some unit tests, there is no GModel { GmoObj* pGmo = m_pGModel->get_main_shape_for_imo( pImo->get_id() ); //TODO: When adding a GmoObj, its Shape Id should be saved so that // following method can be used: // GmoShape* get_shape_for_imo(ImoId imoId, ShapeId shapeId); m_gmos.push_back(pGmo); } ++it; } else it = m_ids.erase(it); } } else clear(); } }