Exemplo n.º 1
0
TEST(TestMeiDocument, RootElement) {
    MeiDocument *doc = new MeiDocument();
    Mei *m = new Mei();
    doc->setRootElement(m);

    ASSERT_EQ(m, doc->getRootElement());
}
Exemplo n.º 2
0
TEST(TestMeiElement, TestSetDocument) {
    MeiElement *m = new MeiElement("mei");
    MeiDocument *doc = new MeiDocument();
    
    ASSERT_THROW(m->setDocument(doc), mei::DocumentRootNotSetException);
    
    doc->setRootElement(m);
    ASSERT_EQ(doc->getRootElement(), m);
}
Exemplo n.º 3
0
bool MusMeiInput::ImportFile( )
{
    string encoding = "utf-8";
    string fname = m_filename.mb_str();
    MeiDocument *doc = MeiDocument::ReadFromXml(fname, encoding);
     m_doc->SetMeiDocument(doc);
    
    // When importing MEI, the first step is to load one single page and to load everything in one system
    MusPage *page = new MusPage();
    page->defin = 20;
    //m_doc->m_pages.Add( page ); // ax2
    // To simplify accessibility, we keep a pointer on that pages
    //m_page = & m_doc->m_pages[0]; // ax2

    MeiElement *root_element = doc->getRootElement();

    if (!ReadElement(root_element)) {
        wxLogError(_("An error occurred while importing '%s'"),  m_doc->m_fname.c_str() );
    }
    
     m_doc->CheckIntegrity();

    // adjust the page size - this is very temporary, we need something better
    // we also have to see what to do if we have a scoredef
    // for now, it just adjust the page size for the content (GetMaxXY)
    wxArrayPtrVoid params; // tableau de pointeurs pour parametres
    MusStaffFunctor getMaxXY( &MusLaidOutStaff::GetMaxXY );
    wxArrayPtrVoid staffParams; // idem for staff functor
    int max_x = -1;
    int max_y = 0;
    staffParams.Add( &max_x );
    staffParams.Add( &max_y );
    m_page->Process( &getMaxXY, staffParams );
    // change the staff width
    // m_page->lrg_lign = max_x / 10; // ax2
    // add the space at the bottom - so far in max_y we have the top corner of the last staff
    /*
    if (m_page->m_staves.GetCount() > 0 ) {
      max_y += max((unsigned short)(&m_page->m_staves.Last())->portNbLine,(&m_page->m_staves.Last())->ecart);
    }
    */ // ax2
    max_y *= m_page->defin; // transform this into coord.
    // update the page size
     m_doc->m_parameters.pageFormatHor = max_x / 10 + (2 *  m_doc->m_parameters.MargeGAUCHEIMPAIRE);
     m_doc->m_parameters.pageFormatVer = max_y / 10 + (2 *  m_doc->m_parameters.MargeSOMMET);

    return true;
}
Exemplo n.º 4
0
TEST(TestMeiElement, TestRemoveManyChildren) {
    MeiDocument *doc = new MeiDocument();
    MeiElement *mei = new MeiElement("mei");
    MeiElement *sd1 = new MeiElement("staffDef");
    MeiElement *sd2 = new MeiElement("staffDef");
    MeiElement *sd3 = new MeiElement("staffDef");
    MeiElement *sd4 = new MeiElement("staffDef");
    MeiElement *sd5 = new MeiElement("staffDef");
    MeiElement *sd6 = new MeiElement("staffDef");
    
    doc->setRootElement(mei);
    
    MeiElement *music = new mei::MeiElement("music");
    MeiElement *scoreDef = new mei::MeiElement("scoreDef");
    
    mei->addChild(music);
    music->addChild(scoreDef);
    scoreDef->addChild(sd1);
    scoreDef->addChild(sd2);
    scoreDef->addChild(sd3);
    scoreDef->addChild(sd4);
    scoreDef->addChild(sd5);
    scoreDef->addChild(sd6);
    
    sd1->addAttribute("n", "1");
    sd2->addAttribute("n", "2");
    sd3->addAttribute("n", "3");
    sd4->addAttribute("n", "4");
    sd5->addAttribute("n", "5");
    sd6->addAttribute("n", "6");
    
    vector<MeiElement*> scoreDefs = doc->getRootElement()->getDescendantsByName("scoreDef");
    vector<MeiElement*> staffDefs = doc->getRootElement()->getDescendantsByName("staffDef");
    
    for (vector<MeiElement*>::iterator iter = staffDefs.begin(); iter != staffDefs.end(); ++iter) {
        if ((*iter)->getAttribute("n")->getValue() == "3" || (*iter)->getAttribute("n")->getValue() == "6") {
            (*iter)->getParent()->removeChild((*iter));
        }
    }
    ASSERT_EQ(4, music->getDescendantsByName("staffDef").size());
    
}