-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
{
Layer::Handle layer(front());
//if(layer->count()>2)synfig::info("before layer->count()=%d",layer->count());
{
Layer::Handle layer(front());
//if(layer->count()>2)synfig::info("before layer->count()=%d",layer->count());
if(x && get_root()!=x->get_root())
{
//String file_name=get_file_name();
//String file_path=x->get_file_path();
if(x && get_root()!=x->get_root())
{
//String file_name=get_file_name();
//String file_path=x->get_file_path();
String file_name;
if(is_absolute_path(get_file_name()))
file_name=etl::relative_path(x->get_file_path(),get_file_name());
else
file_name=get_file_name();
String file_name;
if(is_absolute_path(get_file_name()))
file_name=etl::relative_path(x->get_file_path(),get_file_name());
else
file_name=get_file_name();
// If the path of X is inside of file_name,
// then remove it.
//if(file_name.size()>file_path.size())
// if(file_path==String(file_name,0,file_path.size()))
// file_name.erase(0,file_path.size()+1);
// If the path of X is inside of file_name,
// then remove it.
//if(file_name.size()>file_path.size())
// if(file_path==String(file_name,0,file_path.size()))
// file_name.erase(0,file_path.size()+1);
if(id.find_first_of(':',0)!=string::npos)
throw Exception::BadLinkName("Bad character");
if(id.find_first_of(':',0)!=string::npos)
throw Exception::BadLinkName("Bad character");
try
{
//DEBUGPOINT();
if(PlaceholderValueNode::Handle::cast_dynamic(value_node_list_.find(id)))
throw Exception::IDNotFound("add_value_node()");
try
{
//DEBUGPOINT();
if(PlaceholderValueNode::Handle::cast_dynamic(value_node_list_.find(id)))
throw Exception::IDNotFound("add_value_node()");
if(!value_node_list_.add(x))
{
synfig::error("Unable to add ValueNode");
throw std::runtime_error("Unable to add ValueNode");
}
//DEBUGPOINT();
if(!value_node_list_.add(x))
{
synfig::error("Unable to add ValueNode");
throw std::runtime_error("Unable to add ValueNode");
}
//DEBUGPOINT();
if(is_inline() && parent_)
return parent_->remove_value_node(x);
// throw Exception::IDNotFound("Canvas::remove_value_node() was called from an inline canvas");
if(is_inline() && parent_)
return parent_->remove_value_node(x);
// throw Exception::IDNotFound("Canvas::remove_value_node() was called from an inline canvas");
if(!value_node_list_.erase(x))
throw Exception::IDNotFound("Canvas::remove_value_node(): ValueNode was not found inside of this canvas");
//x->set_parent_canvas(0);
if(!value_node_list_.erase(x))
throw Exception::IDNotFound("Canvas::remove_value_node(): ValueNode was not found inside of this canvas");
//x->set_parent_canvas(0);
if(id.find_first_of('#')!=string::npos)
{
// If '#' is the first character, remove it
// and attempt to parse the ID again.
if(id[0]=='#')
return surefind_canvas(String(id,1));
if(id.find_first_of('#')!=string::npos)
{
// If '#' is the first character, remove it
// and attempt to parse the ID again.
if(id[0]=='#')
return surefind_canvas(String(id,1));
//! \todo This needs alot more optimization
String file_name(id,0,id.find_first_of('#'));
String external_id(id,id.find_first_of('#')+1);
//! \todo This needs alot more optimization
String file_name(id,0,id.find_first_of('#'));
String external_id(id,id.find_first_of('#')+1);
// If the composition is already open, then use it.
if(externals_.count(file_name))
external_canvas=externals_[file_name];
// If the composition is already open, then use it.
if(externals_.count(file_name))
external_canvas=externals_[file_name];
// If we do not have any resolution, then we assume that the
// request is for this immediate canvas
if(id.find_first_of(':')==string::npos)
{
Children::iterator iter;
// If we do not have any resolution, then we assume that the
// request is for this immediate canvas
if(id.find_first_of(':')==string::npos)
{
Children::iterator iter;
// Search for the image in the image list,
// and return it if it is found
for(iter=children().begin();iter!=children().end();iter++)
if(id==(*iter)->get_id())
return *iter;
// Search for the image in the image list,
// and return it if it is found
for(iter=children().begin();iter!=children().end();iter++)
if(id==(*iter)->get_id())
return *iter;
// Create a new canvas and return it
//synfig::warning("Implicitly creating canvas named "+id);
return new_child_canvas(id);
}
// Create a new canvas and return it
//synfig::warning("Implicitly creating canvas named "+id);
return new_child_canvas(id);
}
// this references the root canvas.
if(id[0]==':')
return get_root()->surefind_canvas(string(id,1));
// Now we know that the requested Canvas is in a child
// this references the root canvas.
if(id[0]==':')
return get_root()->surefind_canvas(string(id,1));
// Now we know that the requested Canvas is in a child
Canvas::Handle child_canvas=surefind_canvas(canvas_name);
return child_canvas->surefind_canvas(string(id,id.find_first_of(':')+1));
Canvas::Handle child_canvas=surefind_canvas(canvas_name);
return child_canvas->surefind_canvas(string(id,id.find_first_of(':')+1));
if(id.find_first_of('#')!=string::npos)
{
// If '#' is the first character, remove it
// and attempt to parse the ID again.
if(id[0]=='#')
return find_canvas(String(id,1));
if(id.find_first_of('#')!=string::npos)
{
// If '#' is the first character, remove it
// and attempt to parse the ID again.
if(id[0]=='#')
return find_canvas(String(id,1));
//! \todo This needs alot more optimization
String file_name(id,0,id.find_first_of('#'));
String external_id(id,id.find_first_of('#')+1);
//! \todo This needs alot more optimization
String file_name(id,0,id.find_first_of('#'));
String external_id(id,id.find_first_of('#')+1);
// If the composition is already open, then use it.
if(externals_.count(file_name))
external_canvas=externals_[file_name];
// If the composition is already open, then use it.
if(externals_.count(file_name))
external_canvas=externals_[file_name];
// If we do not have any resolution, then we assume that the
// request is for this immediate canvas
if(id.find_first_of(':')==string::npos)
{
Children::const_iterator iter;
// If we do not have any resolution, then we assume that the
// request is for this immediate canvas
if(id.find_first_of(':')==string::npos)
{
Children::const_iterator iter;
// Search for the image in the image list,
// and return it if it is found
for(iter=children().begin();iter!=children().end();iter++)
if(id==(*iter)->get_id())
return *iter;
// Search for the image in the image list,
// and return it if it is found
for(iter=children().begin();iter!=children().end();iter++)
if(id==(*iter)->get_id())
return *iter;
// this references the root canvas.
if(id.find_first_of(':')==0)
return get_root()->find_canvas(string(id,1));
// Now we know that the requested Canvas is in a child
// this references the root canvas.
if(id.find_first_of(':')==0)
return get_root()->find_canvas(string(id,1));
// Now we know that the requested Canvas is in a child
Canvas::ConstHandle child_canvas=find_canvas(canvas_name);
return child_canvas->find_canvas(string(id,id.find_first_of(':')+1));
Canvas::ConstHandle child_canvas=find_canvas(canvas_name);
return child_canvas->find_canvas(string(id,id.find_first_of(':')+1));
LooseHandle correct_canvas(this);
//while(correct_canvas->is_inline())correct_canvas=correct_canvas->parent();
Layer::LooseHandle loose_layer(x);
LooseHandle correct_canvas(this);
//while(correct_canvas->is_inline())correct_canvas=correct_canvas->parent();
Layer::LooseHandle loose_layer(x);
{
if(!(*iter)->get_group().empty())
remove_group_pair((*iter)->get_group(),(*iter));
{
if(!(*iter)->get_group().empty())
remove_group_pair((*iter)->get_group(),(*iter));
// HACK: We really shouldn't be wiping
// out these signals entirely. We should
// only be removing the specific connections
// HACK: We really shouldn't be wiping
// out these signals entirely. We should
// only be removing the specific connections
if(child_canvas->parent() && !child_canvas->is_inline())
throw std::runtime_error("Cannot add child canvas because it belongs to someone else!");
if(child_canvas->parent() && !child_canvas->is_inline())
throw std::runtime_error("Cannot add child canvas because it belongs to someone else!");
if(find(children().begin(),children().end(),child_canvas)==children().end())
throw Exception::IDNotFound(child_canvas->get_id());
if(find(children().begin(),children().end(),child_canvas)==children().end())
throw Exception::IDNotFound(child_canvas->get_id());
// Go ahead and start romping through the canvas to paste
for(iter=context,i=0;*iter;iter++,i++)
{
Layer::Handle layer=*iter;
float z_depth(layer->get_z_depth()*1.0001+i);
// Go ahead and start romping through the canvas to paste
for(iter=context,i=0;*iter;iter++,i++)
{
Layer::Handle layer=*iter;
float z_depth(layer->get_z_depth()*1.0001+i);
optimize_layers(paste_canvas->get_sub_canvas()->get_context(),sub_canvas);
//#define SYNFIG_OPTIMIZE_PASTE_CANVAS 1
optimize_layers(paste_canvas->get_sub_canvas()->get_context(),sub_canvas);
//#define SYNFIG_OPTIMIZE_PASTE_CANVAS 1
if(paste_canvas->get_blend_method()==Color::BLEND_COMPOSITE && paste_canvas->get_amount()==1.0f && paste_canvas->get_zoom()==0 && paste_canvas->get_time_offset()==0 && paste_canvas->get_origin()==Point(0,0))
try{
for(sub_iter=sub_canvas->begin();sub_iter!=sub_canvas->end();++sub_iter)
{
Layer* layer=sub_iter->get();
if(paste_canvas->get_blend_method()==Color::BLEND_COMPOSITE && paste_canvas->get_amount()==1.0f && paste_canvas->get_zoom()==0 && paste_canvas->get_time_offset()==0 && paste_canvas->get_origin()==Point(0,0))
try{
for(sub_iter=sub_canvas->begin();sub_iter!=sub_canvas->end();++sub_iter)
{
Layer* layer=sub_iter->get();
// any layers that deform end up breaking things
// so do things the old way if we run into anything like this
if(!dynamic_cast<Layer_NoDeform*>(layer))
// any layers that deform end up breaking things
// so do things the old way if we run into anything like this
if(!dynamic_cast<Layer_NoDeform*>(layer))
// It has turned out that we don't need a paste canvas
// layer, so just go ahead and add all the layers onto
// the current stack and be done with it
// It has turned out that we don't need a paste canvas
// layer, so just go ahead and add all the layers onto
// the current stack and be done with it
//sort_list.sort();
stable_sort(sort_list.begin(),sort_list.end());
std::vector< std::pair<float,Layer::Handle> >::iterator iter2;
//sort_list.sort();
stable_sort(sort_list.begin(),sort_list.end());
std::vector< std::pair<float,Layer::Handle> >::iterator iter2;
signal_group_pair_added()(group,layer);
if(is_inline() && parent_)
signal_group_pair_added()(group,layer);
if(is_inline() && parent_)
{
if(is_inline() && parent_)
return parent_->rename_group(old_name,new_name);
{
if(is_inline() && parent_)
return parent_->rename_group(old_name,new_name);
{
std::map<String,std::set<etl::handle<Layer> > >::iterator iter;
iter=group_db_.find(old_name);
{
std::map<String,std::set<etl::handle<Layer> > >::iterator iter;
iter=group_db_.find(old_name);
std::set<etl::handle<Layer> > layers(get_layers_in_group(old_name));
std::set<etl::handle<Layer> >::iterator iter;
std::set<etl::handle<Layer> > layers(get_layers_in_group(old_name));
std::set<etl::handle<Layer> >::iterator iter;