void CScribbleMgr::save() { if (doc && isScbDirty()) { PV_SCBPRINTF("Save scribble now!"); scb_doc_save(doc); } setScbDirty(false); }
//======================================================================== // 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); }
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); }
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); }