Ejemplo n.º 1
0
// construct a doc
// add pages
// add strokes
// add point
// dump
// remove 
void testDoc()
{
    // doc
    ScbDocPtr doc = scb_doc_new();
    if (NULL == doc)
    {
        TRACE("Could not construct a scribble document!");
        return;
    }

    // page list
    ScbPagesPtr pages = scb_doc_get_pages(doc);

    // add some pages
    {
        ScbPageId id;
        ScbPagePtr page = NULL;
        int i = 0; 
        for(; i < 5; ++i)
        {
            scb_page_id_from_int(&id, i);
            page = scb_page_new(&id);
            scb_pages_add_page(pages, page);
        }
        scb_pages_dump(pages);
    }

    scb_doc_free(doc);
}
Ejemplo n.º 2
0
//========================================================================
// construct a doc
// add pages
// add strokes
// add point
// dump
// save
// remove 
void testDocSave()
{
    static const int PAGES      = 20;       // total pages
    static const int STROKES    = 100;      //  strokes per page
    static const int POINTS     = 100;      // points per stroke

    // doc
    TRACE("Start to create a new doc!");
    ScbDocPtr doc = scb_doc_new();
    if (NULL == doc)
    {
        TRACE("Could not construct a scribble document!");
        return;
    }
    TRACE("create document done!");

    // page list
    ScbPagesPtr pages = scb_doc_get_pages(doc);

    // add some pages
    ScbPageId id;
    ScbPagePtr page = NULL;
    int i , j , k;
    for(i = 1; i <= PAGES; ++i)     
    {
        scb_page_id_from_int(&id, i);
        page = scb_page_new();
        scb_page_set_id(page, &id);

        // add strokes
        for(k = 1; k <= STROKES; ++k)     
        {
            ScbStrokePtr stroke = scb_stroke_new();
            ScbPoint point;
            for(j = 1;j < POINTS; ++j)     
            {
                point.x = i; point.y = j; point.pressure = i * j;
                scb_stroke_add_point(stroke, &point);
            }
            scb_page_add_stroke(page, stroke);          
        }                
        scb_pages_add_page(pages, page);
    }

    TRACE("Added pages done! Dump Page now!");
    TRACE("pages %d", scb_pages_get_count(pages));
    TRACE("Visit page %s!", id.id);
    page = scb_pages_get_page(pages, &id);

    //   scb_pages_dump(pages);
    strcpy(doc->path.scbname, "/scb.xml");
    scb_doc_save(doc);
    TRACE("Save done");
    scb_doc_free(doc);
}
Ejemplo n.º 3
0
void testDocLoad(const char *pathName)
{
    ScbPath path; strcpy(path.scbname, pathName);
    ScbDocPtr doc = scb_doc_open(&path);

    if (NULL == doc)
    {
        TRACE("Could not open file %s", pathName);
        return;
    }

    //scb_doc_dump(doc);
    scb_doc_free(doc);
}
Ejemplo n.º 4
0
void CScribbleMgr::close(bool bSave)
{
    if (doc && bSave && isScbDirty())
    {
        PV_SCBPRINTF("Save scribble now!");
        scb_doc_save(doc);
    }
    scb_doc_free(doc);
    doc = NULL;
    memset(&path, 0, sizeof(path));
    page = NULL;
    stroke = NULL;
    setScbDirty(false);
}
Ejemplo n.º 5
0
void testFastDraw()
{
    ScbPath path; 
    strncpy(path.scbname, "/temp.irx", MAX_PATH);
    ScbDocPtr doc = scb_doc_make_sure_exist(&path);
    
    ScbPageId id; 
    scb_page_id_from_str(&id, "abcdef");
    
    ScbPagePtr page = scb_doc_get_page(doc, &id);
    if (NULL == page)
    {
        page = scb_page_new();
        scb_page_set_id(page, &id);
        scb_doc_add_page(doc, page);
    }        

    
    ScbStrokePtr stroke = scb_stroke_new();
    
    stroke->style.color.pixel = 3;
    stroke->style.penSize = 3;
    static const int POINTS  = 1000;
    
    int i;
    ScbPoint point;
    for(i = 0; i < POINTS - 1; ++i)
    {
        point.x = i; point.y = i; point.pressure = i * i;
        scb_stroke_add_point(stroke, &point);
        scb_stroke_fast_draw_point(stroke, &point); 
    }
    point.x = i; point.y = i; point.pressure = i * i;
    scb_stroke_add_point(stroke, &point);
    scb_stroke_fast_draw_point_done(stroke, &point);
    scb_page_add_stroke(page, stroke);
    scb_doc_save(doc);
    scb_doc_free(doc);
}
Ejemplo n.º 6
0
//========================================================================
// common memory data structure test
void testDataStruct()
{
    static const int PAGES      = 5;
    static const int STROKES    = 5;
    static const int POINTS     = 5;

    ScbDocPtr doc = scb_doc_new();
    ScbPagesPtr pages = scb_doc_get_pages(doc);

    // add pages
    ScbPageId id;
    ScbPagePtr page = NULL;
    int i , j , k;
    for(i = 1; i <= PAGES; ++i)     
    {
        scb_page_id_from_int(&id, i);
        page = scb_page_new();
        scb_page_set_id(page, &id);

        // add strokes
        for(k = 1; k <= STROKES; ++k)     
        {
            ScbStrokePtr stroke = scb_stroke_new();
            ScbPoint point;
            for(j = 1;j < POINTS; ++j)     
            {
                point.x = i; point.y = j; point.pressure = i * j;
                scb_stroke_add_point(stroke, &point);
            }
            scb_page_add_stroke(page, stroke);          
        }                
        scb_pages_add_page(pages, page);
    }
    //scb_pages_dump(pages);
    TRACE("add test done! Have a rest!");
    sleep(SLEEP);
    
    // remove pages
    for(i = 1; i <= PAGES / 2; ++i)     
    {
        scb_page_id_from_int(&id, i);
        TRACE("go to remove page %s!", id.id);
        scb_pages_remove_page(pages, &id);
    }
    //scb_pages_dump(pages);
    TRACE("remove test done! new count %d Have a rest!", scb_pages_get_count(pages));
    sleep(SLEEP);
    
    
    // detach
    ScbPages tmp;
    scb_pages_new(&tmp);
    for(i = PAGES/2  + 1; i <=PAGES; ++i)
    {
        scb_page_id_from_int(&id, i);
        scb_pages_add_page(&tmp, scb_pages_detach_page(pages, &id));
    }
    TRACE("dump pages");
    //scb_pages_dump(pages);
    sleep(SLEEP);
    
    TRACE("dump tmp");
    //scb_pages_dump(&tmp);
    sleep(SLEEP);

 
    scb_pages_free(&tmp);
    scb_pages_free(pages);
    scb_doc_free(doc);
}