1 /* === S I N F G =========================================================== */
3 ** \brief Template File
5 ** $Id: layeradd.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 ======================================================= */
32 #include <sinfgapp/canvasinterface.h>
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::LayerAdd);
45 ACTION_SET_NAME(Action::LayerAdd,"layer_add");
46 ACTION_SET_LOCAL_NAME(Action::LayerAdd,"Add Layer");
47 ACTION_SET_TASK(Action::LayerAdd,"add");
48 ACTION_SET_CATEGORY(Action::LayerAdd,Action::CATEGORY_LAYER);
49 ACTION_SET_PRIORITY(Action::LayerAdd,0);
50 ACTION_SET_VERSION(Action::LayerAdd,"0.0");
51 ACTION_SET_CVS_ID(Action::LayerAdd,"$Id: layeradd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::LayerAdd::LayerAdd()
64 Action::LayerAdd::get_param_vocab()
66 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68 ret.push_back(ParamDesc("new",Param::TYPE_LAYER)
69 .set_local_name(_("New Layer"))
70 .set_desc(_("Layer to be added"))
77 Action::LayerAdd::is_canidate(const ParamList &x)
79 return canidate_check(get_param_vocab(),x);
83 Action::LayerAdd::set_param(const sinfg::String& name, const Action::Param ¶m)
85 if(name=="new" && param.get_type()==Param::TYPE_LAYER)
87 layer=param.get_layer();
92 return Action::CanvasSpecific::set_param(name,param);
96 Action::LayerAdd::is_ready()const
100 return Action::CanvasSpecific::is_ready();
104 Action::LayerAdd::perform()
106 // Set the layer's canvas
107 layer->set_canvas(get_canvas());
109 // Push the layer onto the front of the canvas
110 get_canvas()->push_front(layer);
112 // Mark ourselves as dirty if necessary
113 //set_dirty(layer->active());
115 // Signal that a layer has been inserted
116 if(get_canvas_interface())
118 get_canvas_interface()->signal_layer_inserted()(layer,0);
120 else sinfg::warning("CanvasInterface not set on action");
124 Action::LayerAdd::undo()
126 // Find the iterator for the layer
127 Canvas::iterator iter=find(get_canvas()->begin(),get_canvas()->end(),layer);
129 // If we couldn't find the layer in the canvas, then bail
131 throw Error(_("This layer doesn't exist anymore."));
133 // Remove the layer from the canvas
134 get_canvas()->erase(iter);
136 // Mark ourselves as dirty if necessary
137 //set_dirty(layer->active());
139 // Signal that a layer has been inserted
140 if(get_canvas_interface())
142 get_canvas_interface()->signal_layer_removed()(layer);
144 else sinfg::warning("CanvasInterface not set on action");