Beispiel #1
0
JsonTree BSplineEditor::save()
{
	JsonTree tree = View::save();
	JsonTree subtree = JsonTree::makeArray( "POINTS" );
	for( auto &it : mControlPoints ) {
		vec2 mapped = norm( it );
		JsonTree subsubtree;
		subsubtree.addChild( JsonTree( "X", mapped.x ) );
		subsubtree.addChild( JsonTree( "Y", mapped.y ) );
		subtree.addChild( subsubtree );
	}
	if( subtree.getNumChildren() ) {
		tree.addChild( subtree );
	}
	return tree;
}
Beispiel #2
0
void View::load( const JsonTree &data )
{
    if( data.hasChild( "SUBVIEWS" ) && mLoadSubViews )
    {
        JsonTree tree = data.getChild( "SUBVIEWS" );
        int numSubViews = tree.getNumChildren();
        for(int i = 0; i < numSubViews; i++)
        {
            JsonTree sub = tree[i];
            ViewRef subview = getSubView( sub.getValueForKey( "NAME" ) );
            if( subview )
            {
                subview->load( sub ); 
            }
        }
    }    
}
Beispiel #3
0
JsonTree View::save()
{
    JsonTree tree; 
    tree.addChild( JsonTree( "NAME", getName() ) );
    tree.addChild( JsonTree( "ID", getID() ) );
    tree.addChild( JsonTree( "TYPE", getType() ) );
    JsonTree subtree = JsonTree::makeArray( "SUBVIEWS" );
    for ( auto &it : mSubViews )
    {
        if( it->isSaveable() )
        {
            subtree.addChild( it->save() );
        }
    }
    if( subtree.getNumChildren() )
    {
        tree.addChild( subtree );
    }
    return tree;
}