1 /* === S I N F G =========================================================== */
2 /*! \file layerduplicate.cpp
3 ** \brief Template File
5 ** $Id: layerduplicate.cpp,v 1.1.1.1 2005/01/07 03:34:37 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 ======================================================= */
31 #include "layerduplicate.h"
33 #include <sinfgapp/canvasinterface.h>
39 using namespace sinfg;
40 using namespace sinfgapp;
41 using namespace Action;
43 /* === M A C R O S ========================================================= */
45 ACTION_INIT(Action::LayerDuplicate);
46 ACTION_SET_NAME(Action::LayerDuplicate,"layer_duplicate");
47 ACTION_SET_LOCAL_NAME(Action::LayerDuplicate,"Duplicate Layer");
48 ACTION_SET_TASK(Action::LayerDuplicate,"duplicate");
49 ACTION_SET_CATEGORY(Action::LayerDuplicate,Action::CATEGORY_LAYER);
50 ACTION_SET_PRIORITY(Action::LayerDuplicate,0);
51 ACTION_SET_VERSION(Action::LayerDuplicate,"0.0");
52 ACTION_SET_CVS_ID(Action::LayerDuplicate,"$Id: layerduplicate.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 Action::LayerDuplicate::LayerDuplicate()
65 Action::LayerDuplicate::get_param_vocab()
67 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
69 ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
70 .set_local_name(_("Layer"))
71 .set_desc(_("Layer to be duplicated"))
72 .set_supports_multiple()
79 Action::LayerDuplicate::is_canidate(const ParamList &x)
81 return canidate_check(get_param_vocab(),x);
85 Action::LayerDuplicate::set_param(const sinfg::String& name, const Action::Param ¶m)
87 if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
89 layers.push_back(param.get_layer());
94 return Action::CanvasSpecific::set_param(name,param);
98 Action::LayerDuplicate::is_ready()const
102 return Action::CanvasSpecific::is_ready();
106 Action::LayerDuplicate::prepare()
111 std::list<sinfg::Layer::Handle>::const_iterator iter;
113 for(iter=layers.begin();iter!=layers.end();++iter)
115 Layer::Handle layer(*iter);
117 Canvas::Handle subcanvas(layer->get_canvas());
119 // Find the iterator for the layer
120 Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
122 // If we couldn't find the layer in the canvas, then bail
124 throw Error(_("This layer doesn't exist anymore."));
126 // If the subcanvas isn't the same as the canvas,
127 // then it had better be an inline canvas. If not,
129 if(get_canvas()!=subcanvas && !subcanvas->is_inline())
130 throw Error(_("This layer doesn't belong to this canvas anymore"));
132 Layer::Handle new_layer(layer->clone(guid));
135 Action::Handle action(Action::create("layer_move"));
137 action->set_param("canvas",subcanvas);
138 action->set_param("canvas_interface",get_canvas_interface());
139 action->set_param("layer",new_layer);
140 action->set_param("new_index",layers.front()->get_depth());
142 add_action_front(action);
145 Action::Handle action(Action::create("layer_add"));
147 action->set_param("canvas",subcanvas);
148 action->set_param("canvas_interface",get_canvas_interface());
149 action->set_param("new",new_layer);
151 add_action_front(action);