1 /* === S I N F G =========================================================== */
3 ** \brief Canvas Class Member Definitions
5 ** $Id: canvas.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
24 #define SINFG_NO_ANGLE
36 #include "exception.h"
39 #include "layer_pastecanvas.h"
40 #include <sigc++/bind.h>
44 using namespace sinfg;
48 namespace sinfg { extern Canvas::Handle open_canvas(const String &filename); };
50 /* === M A C R O S ========================================================= */
58 sinfg::error("%d canvases not yet deleted!",counter);
62 int _CanvasCounter::counter(0);
64 /* === G L O B A L S ======================================================= */
66 /* === P R O C E D U R E S ================================================= */
68 /* === M E T H O D S ======================================================= */
70 Canvas::Canvas(const string &id):
77 _CanvasCounter::counter++;
90 //if(is_inline() && parent_) assert(0);
91 _CanvasCounter::counter--;
100 return CanvasBase::end()-1;
103 Canvas::const_iterator
106 return CanvasBase::end()-1;
109 Canvas::reverse_iterator
112 return CanvasBase::rbegin()+1;
115 Canvas::const_reverse_iterator
116 Canvas::rbegin()const
118 return CanvasBase::rbegin()+1;
124 return CanvasBase::size()-1;
132 Layer::Handle layer(front());
133 //if(layer->count()>2)sinfg::info("before layer->count()=%d",layer->count());
136 //if(layer->count()>1)sinfg::info("after layer->count()=%d",layer->count());
138 //CanvasBase::clear();
140 // We need to keep a blank handle at the
141 // end of the image list, and acts at
142 // the bottom. Without it, the layers
143 // would just continue going when polled
145 CanvasBase::push_back(Layer::Handle());
153 return CanvasBase::size()<=1;
159 return *(CanvasBase::end()-1);
162 const Layer::Handle &
165 return *(CanvasBase::end()-1);
169 Canvas::get_context()const
174 const ValueNodeList &
175 Canvas::value_node_list()const
177 if(is_inline() && parent_)
178 return parent_->value_node_list();
179 return value_node_list_;
183 Canvas::keyframe_list()
185 if(is_inline() && parent_)
186 return parent_->keyframe_list();
187 return keyframe_list_;
191 Canvas::keyframe_list()const
193 if(is_inline() && parent_)
194 return parent_->keyframe_list();
195 return keyframe_list_;
199 Canvas::find_layer(const Point &pos)
201 return get_context().hit_check(pos);
205 valid_id(const String &x)
207 static const char bad_chars[]=" :#@$^&()*";
210 if(!x.empty() && x[0]>='0' && x[0]<='9')
213 for(i=0;i<sizeof(bad_chars);i++)
214 if(x.find_first_of(bad_chars[i])!=string::npos)
221 Canvas::set_id(const String &x)
223 if(is_inline() && parent_)
224 throw runtime_error("Inline Canvas cannot have an ID");
227 throw runtime_error("Invalid ID");
229 signal_id_changed_();
233 Canvas::set_name(const String &x)
236 signal_meta_data_changed()("name");
237 signal_meta_data_changed("name")();
241 Canvas::set_author(const String &x)
244 signal_meta_data_changed()("author");
245 signal_meta_data_changed("author")();
249 Canvas::set_description(const String &x)
252 signal_meta_data_changed()("description");
253 signal_meta_data_changed("description")();
257 Canvas::set_time(Time t)const
259 if(is_dirty_ || !get_time().is_equal(t))
264 sinfg::info("is_dirty_=%d",is_dirty_);
265 sinfg::info("get_time()=%f",(float)get_time());
266 sinfg::info("t=%f",(float)t);
271 const_cast<Canvas&>(*this).cur_time_=t;
274 get_context().set_time(t);
280 Canvas::get_root()const
282 return parent_?parent_->get_root().get():const_cast<sinfg::Canvas *>(this);
286 Canvas::get_depth(etl::handle<Layer> layer)const
290 for(iter=begin();iter!=end();++iter,i++)
299 Canvas::get_relative_id(etl::loose_handle<const Canvas> x)const
301 if(x->get_root()==this)
303 if(is_inline() && parent_)
304 return parent_->_get_relative_id(x);
305 return _get_relative_id(x);
309 Canvas::_get_relative_id(etl::loose_handle<const Canvas> x)const
311 if(is_inline() && parent_)
312 return parent_->_get_relative_id(x);
317 if(parent()==x.get())
322 const Canvas* canvas=this;
324 for(;!canvas->is_root();canvas=canvas->parent().get())
325 id=':'+canvas->get_id()+id;
327 if(x && get_root()!=x->get_root())
329 //String file_name=get_file_name();
330 //String file_path=x->get_file_path();
333 if(is_absolute_path(get_file_name()))
334 file_name=etl::relative_path(x->get_file_path(),get_file_name());
336 file_name=get_file_name();
338 // If the path of X is inside of file_name,
340 //if(file_name.size()>file_path.size())
341 // if(file_path==String(file_name,0,file_path.size()))
342 // file_name.erase(0,file_path.size()+1);
352 Canvas::find_value_node(const String &id)
355 ValueNode::Handle::cast_const(
356 const_cast<const Canvas*>(this)->find_value_node(id)
360 ValueNode::ConstHandle
361 Canvas::find_value_node(const String &id)const
363 if(is_inline() && parent_)
364 return parent_->find_value_node(id);
367 throw Exception::IDNotFound("Empty ID");
369 // If we do not have any resolution, then we assume that the
370 // request is for this immediate canvas
371 if(id.find_first_of(':')==string::npos && id.find_first_of('#')==string::npos)
372 return value_node_list_.find(id);
374 String canvas_id(id,0,id.rfind(':'));
375 String value_node_id(id,id.rfind(':')+1);
376 if(canvas_id.empty())
378 //sinfg::warning("constfind:value_node_id: "+value_node_id);
379 //sinfg::warning("constfind:canvas_id: "+canvas_id);
381 return find_canvas(canvas_id)->value_node_list_.find(value_node_id);
385 Canvas::surefind_value_node(const String &id)
387 if(is_inline() && parent_)
388 return parent_->surefind_value_node(id);
391 throw Exception::IDNotFound("Empty ID");
393 // If we do not have any resolution, then we assume that the
394 // request is for this immediate canvas
395 if(id.find_first_of(':')==string::npos && id.find_first_of('#')==string::npos)
396 return value_node_list_.surefind(id);
398 String canvas_id(id,0,id.rfind(':'));
399 String value_node_id(id,id.rfind(':')+1);
400 if(canvas_id.empty())
403 return surefind_canvas(canvas_id)->value_node_list_.surefind(value_node_id);
407 Canvas::add_value_node(ValueNode::Handle x, const String &id)
409 if(is_inline() && parent_)
410 return parent_->add_value_node(x,id);
411 // throw runtime_error("You cannot add a ValueNode to an inline Canvas");
415 throw runtime_error("ValueNode is already exported");
418 throw Exception::BadLinkName("Empty ID");
420 if(id.find_first_of(':',0)!=string::npos)
421 throw Exception::BadLinkName("Bad character");
426 if(PlaceholderValueNode::Handle::cast_dynamic(value_node_list_.find(id)))
427 throw Exception::IDNotFound("add_value_node()");
430 throw Exception::IDAlreadyExists(id);
432 catch(Exception::IDNotFound)
437 x->set_parent_canvas(this);
439 if(!value_node_list_.add(x))
441 sinfg::error("Unable to add ValueNode");
442 throw std::runtime_error("Unable to add ValueNode");
452 Canvas::rename_value_node(ValueNode::Handle x, const String &id)
455 throw Exception::BadLinkName("Empty ID");
457 if(id.find_first_of(": ",0)!=string::npos)
458 throw Exception::BadLinkName("Bad character");
462 if(PlaceholderValueNode::Handle::cast_dynamic(value_node_list_.find(id)))
463 throw Exception::IDNotFound("rename_value_node");
464 throw Exception::IDAlreadyExists(id);
466 catch(Exception::IDNotFound)
476 Canvas::remove_value_node(ValueNode::Handle x)
478 if(is_inline() && parent_)
479 return parent_->remove_value_node(x);
480 // throw Exception::IDNotFound("Canvas::remove_value_node() was called from an inline canvas");
483 throw Exception::IDNotFound("Canvas::remove_value_node() was passed empty handle");
485 if(!value_node_list_.erase(x))
486 throw Exception::IDNotFound("Canvas::remove_value_node(): ValueNode was not found inside of this canvas");
488 //x->set_parent_canvas(0);
495 Canvas::surefind_canvas(const String &id)
497 if(is_inline() && parent_)
498 return parent_->surefind_canvas(id);
503 // If the ID contains a "#" character, then a filename is
504 // expected on the left side.
505 if(id.find_first_of('#')!=string::npos)
507 // If '#' is the first character, remove it
508 // and attempt to parse the ID again.
510 return surefind_canvas(String(id,1));
512 //! \todo This needs alot more optimization
513 String file_name(id,0,id.find_first_of('#'));
514 String external_id(id,id.find_first_of('#')+1);
516 Canvas::Handle external_canvas;
518 // If the composition is already open, then use it.
519 if(externals_.count(file_name))
520 external_canvas=externals_[file_name];
523 if(is_absolute_path(file_name))
524 external_canvas=open_canvas(file_name);
526 external_canvas=open_canvas(get_file_path()+'/'+file_name);
529 throw Exception::FileNotFound(file_name);
530 externals_[file_name]=external_canvas;
533 return Handle::cast_const(external_canvas.constant()->find_canvas(external_id));
536 // If we do not have any resolution, then we assume that the
537 // request is for this immediate canvas
538 if(id.find_first_of(':')==string::npos)
540 Children::iterator iter;
542 // Search for the image in the image list,
543 // and return it if it is found
544 for(iter=children().begin();iter!=children().end();iter++)
545 if(id==(*iter)->get_id())
548 // Create a new canvas and return it
549 //sinfg::warning("Implicitly creating canvas named "+id);
550 return new_child_canvas(id);
553 // If the first character is the seperator, then
554 // this references the root canvas.
556 return get_root()->surefind_canvas(string(id,1));
558 // Now we know that the requested Canvas is in a child
559 // of this canvas. We have to find that canvas and
560 // call "find_canvas" on it, and return the result.
562 String canvas_name=string(id,0,id.find_first_of(':'));
564 Canvas::Handle child_canvas=surefind_canvas(canvas_name);
566 return child_canvas->surefind_canvas(string(id,id.find_first_of(':')+1));
570 Canvas::find_canvas(const String &id)
573 Canvas::Handle::cast_const(
574 const_cast<const Canvas*>(this)->find_canvas(id)
579 Canvas::find_canvas(const String &id)const
581 if(is_inline() && parent_)return parent_->find_canvas(id);
586 // If the ID contains a "#" character, then a filename is
587 // expected on the left side.
588 if(id.find_first_of('#')!=string::npos)
590 // If '#' is the first character, remove it
591 // and attempt to parse the ID again.
593 return find_canvas(String(id,1));
595 //! \todo This needs alot more optimization
596 String file_name(id,0,id.find_first_of('#'));
597 String external_id(id,id.find_first_of('#')+1);
599 Canvas::Handle external_canvas;
601 // If the composition is already open, then use it.
602 if(externals_.count(file_name))
603 external_canvas=externals_[file_name];
606 if(is_absolute_path(file_name))
607 external_canvas=open_canvas(file_name);
609 external_canvas=open_canvas(get_file_path()+'/'+file_name);
612 throw Exception::FileNotFound(file_name);
613 externals_[file_name]=external_canvas;
616 return Handle::cast_const(external_canvas.constant()->find_canvas(external_id));
619 // If we do not have any resolution, then we assume that the
620 // request is for this immediate canvas
621 if(id.find_first_of(':')==string::npos)
623 Children::const_iterator iter;
625 // Search for the image in the image list,
626 // and return it if it is found
627 for(iter=children().begin();iter!=children().end();iter++)
628 if(id==(*iter)->get_id())
631 throw Exception::IDNotFound("Child Canvas in Parent Canvas: (child)"+id);
634 // If the first character is the seperator, then
635 // this references the root canvas.
636 if(id.find_first_of(':')==0)
637 return get_root()->find_canvas(string(id,1));
639 // Now we know that the requested Canvas is in a child
640 // of this canvas. We have to find that canvas and
641 // call "find_canvas" on it, and return the result.
643 String canvas_name=string(id,0,id.find_first_of(':'));
645 Canvas::ConstHandle child_canvas=find_canvas(canvas_name);
647 return child_canvas->find_canvas(string(id,id.find_first_of(':')+1));
654 return new Canvas("Untitled");
658 Canvas::push_back(etl::handle<Layer> x)
661 // int i(x->count());
663 //if(x->count()!=i+1)sinfg::info("push_back before %d, after %d",i,x->count());
667 Canvas::push_front(etl::handle<Layer> x)
670 // int i(x->count());
672 //if(x->count()!=i+1)sinfg::error("push_front before %d, after %d",i,x->count());
676 Canvas::insert(iterator iter,etl::handle<Layer> x)
678 // int i(x->count());
679 CanvasBase::insert(iter,x);
681 /*if(x->count()!=i+1)
683 sinfg::error(__FILE__":%d: Canvas::insert(): ***FAILURE*** before %d, after %d",__LINE__,i,x->count());
685 //throw runtime_error("Canvas Insertion Failed");
694 LooseHandle correct_canvas(this);
695 //while(correct_canvas->is_inline())correct_canvas=correct_canvas->parent();
696 Layer::LooseHandle loose_layer(x);
698 x->signal_added_to_group().connect(
702 &Canvas::add_group_pair
707 x->signal_removed_from_group().connect(
711 &Canvas::remove_group_pair
718 if(!x->get_group().empty())
719 add_group_pair(x->get_group(),x);
726 Canvas::push_back_simple(etl::handle<Layer> x)
728 CanvasBase::insert(end(),x);
733 Canvas::erase(Canvas::iterator iter)
735 if(!(*iter)->get_group().empty())
736 remove_group_pair((*iter)->get_group(),(*iter));
738 // HACK: We really shouldn't be wiping
739 // out these signals entirely. We should
740 // only be removing the specific connections
741 // that we made. At the moment, I'm too
742 // lazy to add the code to keep track
743 // of those connections, and no one else
744 // is using these signals, so I'll just
745 // leave these next two lines like they
746 // are for now - darco 07-30-2004
747 (*iter)->signal_added_to_group().clear();
748 (*iter)->signal_removed_from_group().clear();
750 if(!op_flag_)remove_child(iter->get());
752 CanvasBase::erase(iter);
753 if(!op_flag_)changed();
757 Canvas::clone(const GUID& deriv_guid)const
764 name=get_id()+"_CLONE";
766 throw runtime_error("Cloning of non-inline canvases is not yet suported");
769 Handle canvas(new Canvas(name));
773 canvas->is_inline_=true;
775 //canvas->set_inline(parent());
778 canvas->set_guid(get_guid()^deriv_guid);
781 for(iter=begin();iter!=end();++iter)
783 Layer::Handle layer((*iter)->clone(deriv_guid));
786 assert(layer.count()==1);
788 canvas->push_back(layer);
789 if(!(layer.count()>1))
791 sinfg::error("Canvas::clone(): Cloned layer insertion failure!");
792 sinfg::error("Canvas::clone(): \tlayer.count()=%d",layer.count());
793 sinfg::error("Canvas::clone(): \tlayer->get_name()=%s",layer->get_name().c_str());
794 sinfg::error("Canvas::clone(): \tbefore size()=%d",presize);
795 sinfg::error("Canvas::clone(): \tafter size()=%d",size());
797 assert(layer.count()>1);
801 sinfg::error("Unable to clone layer");
805 canvas->signal_group_pair_removed().clear();
806 canvas->signal_group_pair_added().clear();
812 Canvas::set_inline(LooseHandle parent)
814 if(is_inline_ && parent_)
823 // Have the parent inherit all of the group stuff
825 std::map<String,std::set<etl::handle<Layer> > >::const_iterator iter;
827 for(iter=group_db_.begin();iter!=group_db_.end();++iter)
829 parent->group_db_[iter->first].insert(iter->second.begin(),iter->second.end());
832 rend_desc()=parent->rend_desc();
836 Canvas::create_inline(Handle parent)
839 //if(parent->is_inline())
840 // return create_inline(parent->parent());
842 Handle canvas(new Canvas("inline"));
843 canvas->set_inline(parent);
848 Canvas::new_child_canvas()
850 if(is_inline() && parent_)
851 return parent_->new_child_canvas();
852 // runtime_error("You cannot create a child Canvas in an inline Canvas");
854 // Create a new canvas
855 children().push_back(create());
856 Canvas::Handle canvas(children().back());
858 canvas->parent_=this;
860 canvas->rend_desc()=rend_desc();
866 Canvas::new_child_canvas(const String &id)
868 if(is_inline() && parent_)
869 return parent_->new_child_canvas(id);
870 // runtime_error("You cannot create a child Canvas in an inline Canvas");
872 // Create a new canvas
873 children().push_back(create());
874 Canvas::Handle canvas(children().back());
877 canvas->parent_=this;
878 canvas->rend_desc()=rend_desc();
884 Canvas::add_child_canvas(Canvas::Handle child_canvas, const sinfg::String& id)
886 if(is_inline() && parent_)
887 return parent_->add_child_canvas(child_canvas,id);
889 if(child_canvas->parent() && !child_canvas->is_inline())
890 throw std::runtime_error("Cannot add child canvas because it belongs to someone else!");
893 throw runtime_error("Invalid ID");
898 throw Exception::IDAlreadyExists(id);
900 catch(Exception::IDNotFound)
902 if(child_canvas->is_inline())
903 child_canvas->is_inline_=false;
904 child_canvas->id_=id;
905 children().push_back(child_canvas);
906 child_canvas->parent_=this;
913 Canvas::remove_child_canvas(Canvas::Handle child_canvas)
915 if(is_inline() && parent_)
916 return parent_->remove_child_canvas(child_canvas);
918 if(child_canvas->parent_!=this)
919 throw runtime_error("Given child does not belong to me");
921 if(find(children().begin(),children().end(),child_canvas)==children().end())
922 throw Exception::IDNotFound(child_canvas->get_id());
924 children().remove(child_canvas);
926 child_canvas->parent_=0;
930 Canvas::set_file_name(const String &file_name)
933 parent()->set_file_name(file_name);
936 file_name_=file_name;
937 signal_file_name_changed_();
942 Canvas::signal_file_name_changed()
945 return signal_file_name_changed();
947 return signal_file_name_changed_;
951 Canvas::get_file_name()const
954 return parent()->get_file_name();
959 Canvas::get_file_path()const
962 return parent()->get_file_path();
963 return dirname(file_name_);
968 Canvas::get_meta_data(const String& key)const
970 if(!meta_data_.count(key))
972 return meta_data_.find(key)->second;
976 Canvas::set_meta_data(const String& key, const String& data)
978 if(meta_data_[key]!=data)
980 meta_data_[key]=data;
981 signal_meta_data_changed()(key);
982 signal_meta_data_changed(key)();
987 Canvas::erase_meta_data(const String& key)
989 if(meta_data_.count(key))
991 meta_data_.erase(key);
992 signal_meta_data_changed()(key);
993 signal_meta_data_changed(key)();
998 Canvas::get_meta_data_keys()const
1000 std::list<String> ret;
1002 std::map<String,String>::const_iterator iter;
1004 for(iter=meta_data_.begin();!(iter==meta_data_.end());++iter)
1005 ret.push_back(iter->first);
1011 sinfg::optimize_layers(Context context, Canvas::Handle op_canvas)
1015 std::vector< std::pair<float,Layer::Handle> > sort_list;
1018 // Go ahead and start romping through the canvas to paste
1019 for(iter=context,i=0;*iter;iter++,i++)
1021 Layer::Handle layer=*iter;
1022 float z_depth(layer->get_z_depth()*1.0001+i);
1024 // If the layer isn't active, don't worry about it
1025 if(!layer->active())
1028 // Any layer with an amount of zero is implicitly disabled.
1029 ValueBase value(layer->get_param("amount"));
1030 if(value.get_type()==ValueBase::TYPE_REAL && value.get(Real())==0)
1033 Layer_PasteCanvas* paste_canvas(static_cast<Layer_PasteCanvas*>(layer.get()));
1034 if(layer->get_name()=="PasteCanvas" && paste_canvas->get_time_offset()==0)
1036 Canvas::Handle sub_canvas(Canvas::create_inline(op_canvas));
1037 optimize_layers(paste_canvas->get_sub_canvas()->get_context(),sub_canvas);
1038 //#define SINFG_OPTIMIZE_PASTE_CANVAS 1
1040 #ifdef SINFG_OPTIMIZE_PASTE_CANVAS
1041 Canvas::iterator sub_iter;
1042 // Determine if we can just remove the paste canvas
1044 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))
1046 for(sub_iter=sub_canvas->begin();sub_iter!=sub_canvas->end();++sub_iter)
1048 Layer* layer=sub_iter->get();
1050 // any layers that deform end up breaking things
1051 // so do things the old way if we run into anything like this
1052 if(!dynamic_cast<Layer_NoDeform*>(layer))
1055 ValueBase value(layer->get_param("blend_method"));
1056 if(value.get_type()!=ValueBase::TYPE_INTEGER || value.get(int())!=(int)Color::BLEND_COMPOSITE)
1060 // It has turned out that we don't need a paste canvas
1061 // layer, so just go ahead and add all the layers onto
1062 // the current stack and be done with it
1063 while(sub_canvas->size())
1065 sort_list.push_back(std::pair<float,Layer::Handle>(z_depth,sub_canvas->front()));
1066 //op_canvas->push_back_simple(sub_canvas->front());
1067 sub_canvas->pop_front();
1072 Layer::Handle new_layer(Layer::create("PasteCanvas"));
1073 dynamic_cast<Layer_PasteCanvas*>(new_layer.get())->set_do_not_muck_with_time(true);
1074 Layer::ParamList param_list(paste_canvas->get_param_list());
1075 //param_list.erase("canvas");
1076 new_layer->set_param_list(param_list);
1077 dynamic_cast<Layer_PasteCanvas*>(new_layer.get())->set_sub_canvas(sub_canvas);
1078 dynamic_cast<Layer_PasteCanvas*>(new_layer.get())->set_do_not_muck_with_time(false);
1082 sort_list.push_back(std::pair<float,Layer::Handle>(z_depth,layer));
1083 //op_canvas->push_back_simple(layer);
1087 stable_sort(sort_list.begin(),sort_list.end());
1088 std::vector< std::pair<float,Layer::Handle> >::iterator iter2;
1089 for(iter2=sort_list.begin();iter2!=sort_list.end();++iter2)
1090 op_canvas->push_back_simple(iter2->second);
1091 op_canvas->op_flag_=true;
1095 Canvas::get_times_vfunc(Node::time_set &set) const
1097 const_iterator i = begin(),
1100 for(; i != iend; ++i)
1102 const Node::time_set &tset = (*i)->get_times();
1103 set.insert(tset.begin(),tset.end());
1107 std::set<etl::handle<Layer> >
1108 Canvas::get_layers_in_group(const String&group)
1110 if(is_inline() && parent_)
1111 return parent_->get_layers_in_group(group);
1113 if(group_db_.count(group)==0)
1114 return std::set<etl::handle<Layer> >();
1115 return group_db_.find(group)->second;
1119 Canvas::get_groups()const
1121 if(is_inline() && parent_)
1122 return parent_->get_groups();
1124 std::set<String> ret;
1125 std::map<String,std::set<etl::handle<Layer> > >::const_iterator iter;
1126 for(iter=group_db_.begin();iter!=group_db_.end();++iter)
1127 ret.insert(iter->first);
1132 Canvas::get_group_count()const
1134 if(is_inline() && parent_)
1135 return parent_->get_group_count();
1137 return group_db_.size();
1141 Canvas::add_group_pair(String group, etl::handle<Layer> layer)
1143 group_db_[group].insert(layer);
1144 if(group_db_[group].size()==1)
1145 signal_group_added()(group);
1147 signal_group_changed()(group);
1149 signal_group_pair_added()(group,layer);
1151 if(is_inline() && parent_)
1152 return parent_->add_group_pair(group,layer);
1156 Canvas::remove_group_pair(String group, etl::handle<Layer> layer)
1158 group_db_[group].erase(layer);
1160 signal_group_pair_removed()(group,layer);
1162 if(group_db_[group].empty())
1164 group_db_.erase(group);
1165 signal_group_removed()(group);
1168 signal_group_changed()(group);
1170 if(is_inline() && parent_)
1171 return parent_->remove_group_pair(group,layer);
1175 Canvas::rename_group(const String&old_name,const String&new_name)
1177 if(is_inline() && parent_)
1178 return parent_->rename_group(old_name,new_name);
1181 std::map<String,std::set<etl::handle<Layer> > >::iterator iter;
1182 iter=group_db_.find(old_name);
1183 if(iter!=group_db_.end())
1184 for(++iter;iter!=group_db_.end() && iter->first.find(old_name)==0;iter=group_db_.find(old_name),++iter)
1186 String name(iter->first,old_name.size(),String::npos);
1188 rename_group(iter->first,name);
1192 std::set<etl::handle<Layer> > layers(get_layers_in_group(old_name));
1193 std::set<etl::handle<Layer> >::iterator iter;
1195 for(iter=layers.begin();iter!=layers.end();++iter)
1197 (*iter)->remove_from_group(old_name);
1198 (*iter)->add_to_group(new_name);