void PoseSeq::store(Mapping& archive, const BodyPtr body) const { archive.write("type", "PoseSeq"); archive.write("name", name(), DOUBLE_QUOTED); archive.write("targetBody", body->name(), DOUBLE_QUOTED); Listing& refsNode = *archive.createListing("refs"); for(PoseRefList::const_iterator p = refs.begin(); p != refs.end(); ++p){ const PoseRef& ref = *p; MappingPtr refNode = refsNode.newMapping(); refNode->write("time", ref.time()); if(ref.maxTransitionTime() > 0.0){ refNode->write("maxTransitionTime", ref.maxTransitionTime()); } const string& name = ref.name(); if((storedNames.find(name) == storedNames.end() /* && !ref.isExternalReference()*/) || name.empty()){ const_cast<PoseSeq*>(this)->storedNames.insert(name); MappingPtr childNode = refNode->createMapping("refer"); ref.poseUnit()->store(*childNode, body); } else { refNode->write("refer", name, DOUBLE_QUOTED); } } }
bool EditableSceneBodyImpl::storeProperties(Archive& archive) { ListingPtr states = new Listing(); ItemList<BodyItem> bodyItems; bodyItems.extractChildItems(RootItem::instance()); for(size_t i=0; i < bodyItems.size(); ++i){ BodyItem* bodyItem = bodyItems[i]; EditableSceneBody* sceneBody = bodyItem->existingSceneBody(); if(sceneBody){ ValueNodePtr id = archive.getItemId(bodyItem); if(id){ EditableSceneBodyImpl* impl = sceneBody->impl; MappingPtr state = new Mapping(); state->insert("bodyItem", id); state->write("showCenterOfMass", impl->isCmVisible); state->write("showZmp", impl->isZmpVisible); states->append(state); } } } if(!states->empty()){ archive.insert("editableSceneBodies", states); return true; } return false; }
MappingPtr ViewAreaImpl::storeSplitterState(QSplitter* splitter, Archive* archive) { MappingPtr state = new Mapping; ListingPtr children = new Listing; for(int i=0; i < splitter->count(); ++i){ QSplitter* childSplitter = dynamic_cast<QSplitter*>(splitter->widget(i)); if(childSplitter){ MappingPtr childState = storeSplitterState(childSplitter, archive); if(childState){ children->append(childState); } } else { ViewPane* pane = dynamic_cast<ViewPane*>(splitter->widget(i)); if(pane && pane->count() > 0){ MappingPtr childState = storePaneState(pane, archive); if(childState){ children->append(childState); } } } } const int numChildren = children->size(); if(numChildren == 0){ state.reset(); } else if(numChildren == 1){ state = children->at(0)->toMapping(); } else if(numChildren == 2){ state->write("type", "splitter"); state->write("orientation", (splitter->orientation() == Qt::Vertical) ? "vertical" : "horizontal"); Listing* sizeSeq = state->createFlowStyleListing("sizes"); QList<int> sizes = splitter->sizes(); for(int i=0; i < sizes.size(); ++i){ sizeSeq->append(sizes[i]); } state->insert("children", children); } return state; }
MappingPtr ViewAreaImpl::storePaneState(ViewPane* pane, Archive* archive) { MappingPtr state = new Mapping(); state->write("type", "pane"); Listing* views = state->createFlowStyleListing("views"); const int n = pane->count(); for(int i=0; i < n; ++i){ View* view = pane->view(i); int id = archive->getViewId(view); if(id >= 0){ views->append(id); if(i == pane->currentIndex()){ state->write("current", id); } } } if(views->empty()){ state.reset(); } return state; }