/usr/include/synfig-1.0/synfig/layer.h is in libsynfig-dev 1.0.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | /* === S Y N F I G ========================================================= */
/*! \file layer.h
** \brief Layer Class Header
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2008 Chris Moore
** Copyright (c) 2011-2013 Carlos López
**
** 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.
**
** 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.
** \endlegal
*/
/* ========================================================================= */
/* === S T A R T =========================================================== */
#ifndef __SYNFIG_LAYER_H
#define __SYNFIG_LAYER_H
/* === H E A D E R S ======================================================= */
#include <map>
#include <ETL/handle>
#include "real.h"
#include "string.h"
#include <sigc++/signal.h>
#include <sigc++/connection.h>
#include "node.h"
#include "time.h"
#include "guid.h"
#include "interpolation.h"
#include "target.h" // for RenderMethod. TODO: put RenderMethod apart
#include "cairo.h"
#include "rendermethod.h"
/* === M A C R O S ========================================================= */
// This macros should be removed when rendering optimization complete
#define RENDER_TRANSFORMED_IF_NEED(file, line) \
if (!renddesc.get_transformation_matrix().is_identity()) \
return render_transformed(this, context, surface, quality, renddesc, cb, file, line);
//! Defines various variables and the create method, common for all importers.
//! To be used in the private part of the importer class definition.
#define SYNFIG_LAYER_MODULE_EXT \
public: \
static const char name__[], version__[], cvs_id__[], local_name__[], category__[]; \
static Layer *create();
//! Sets the name of the layer
#define SYNFIG_LAYER_SET_NAME(class,x) \
const char class::name__[]=x
//! Sets the local name of the layer
#define SYNFIG_LAYER_SET_LOCAL_NAME(class,x) \
const char class::local_name__[]=x;
//! Sets the category of the layer
#define SYNFIG_LAYER_SET_CATEGORY(class,x) \
const char class::category__[]=x
//! Sets the version string for the layer
#define SYNFIG_LAYER_SET_VERSION(class,x) \
const char class::version__[]=x
//! Sets the CVS ID string for the layer
#define SYNFIG_LAYER_SET_CVS_ID(class,x) \
const char class::cvs_id__[]=x
//! Defines de implementation of the create method for the importer
#define SYNFIG_LAYER_INIT(class) \
synfig::Layer* class::create() \
{ \
return new class(); \
}
//! Imports a parameter if it is of the same type as param
#define IMPORT_VALUE(x) \
if (#x=="param_"+param && x.get_type()==value.get_type()) \
{ \
x=value; \
return true; \
}
//! Imports a parameter 'x' and perform an action usually based on
//! some condition 'y'
#define IMPORT_VALUE_PLUS_BEGIN(x) \
if (#x=="param_"+param && x.get_type()==value.get_type()) \
{ \
x=value; \
{
#define IMPORT_VALUE_PLUS_END \
} \
return true; \
}
#define IMPORT_VALUE_PLUS(x,y) \
IMPORT_VALUE_PLUS_BEGIN(x) \
y; \
IMPORT_VALUE_PLUS_END
//! Exports a parameter if it is the same type as value
#define EXPORT_VALUE(x) \
if (#x=="param_"+param) \
{ \
synfig::ValueBase ret; \
ret.copy(x); \
return ret; \
}
//! Exports the name or the local name of the layer
#define EXPORT_NAME() \
if (param=="Name" || param=="name" || param=="name__") \
return name__; \
else if (param=="local_name__") \
return dgettext("synfig",local_name__);
//! Exports the version of the layer
#define EXPORT_VERSION() \
if (param=="Version" || param=="version" || param=="version__") \
return version__;
//! This is used as the category for layer book entries which represent aliases of layers.
//! It prevents these layers showing up in the menu.
#define CATEGORY_DO_NOT_USE "Do Not Use"
//! Sets the interpolation defaults for the layer
#define SET_INTERPOLATION_DEFAULTS() \
{ \
Vocab vocab(get_param_vocab()); \
Vocab::const_iterator viter; \
for(viter=vocab.begin();viter!=vocab.end();viter++) \
{ \
ValueBase v=get_param(viter->get_name()); \
v.set_interpolation(viter->get_interpolation()); \
set_param(viter->get_name(), v); \
} \
} \
//! Sets the static defaults for the layer
#define SET_STATIC_DEFAULTS() \
{ \
Vocab vocab(get_param_vocab()); \
Vocab::const_iterator viter; \
for(viter=vocab.begin();viter!=vocab.end();viter++) \
{ \
ValueBase v=get_param(viter->get_name()); \
v.set_static(viter->get_static()); \
set_param(viter->get_name(), v); \
} \
} \
/* === T Y P E D E F S ===================================================== */
/* === C L A S S E S & S T R U C T S ======================================= */
namespace synfig {
class Canvas;
class Vector;
typedef Vector Point;
class Canvas;
class ParamDesc;
class ParamVocab;
class ValueNode;
class ValueBase;
class Time;
class Surface;
class CairoSurface;
class RendDesc;
class ProgressCallback;
class IndependentContext;
class Context;
class Color;
class CairoColor;
class Transform;
class Rect;
class GUID;
/*! \class Layer
** \todo writeme
** \see Canvas
*/
class Layer : public Node
{
friend class ValueNode;
friend class IndependentContext;
friend class Context;
/*
-- ** -- T Y P E S -----------------------------------------------------------
*/
public:
//! Type that represents a pointer to a Layer's constructor.
/*! As a pointer to the constructor, it represents a "factory" of layers.
*/
typedef Layer* (*Factory)();
struct BookEntry
{
Factory factory;
String name;
String local_name;
String category;
String cvs_id;
String version;
BookEntry(): factory() { }
BookEntry(Factory factory,
const String &name,
const String &local_name,
const String &category,
const String &cvs_id,
const String &version):
factory(factory),
name(name),
local_name(local_name),
category(category),
cvs_id(cvs_id),
version(version) { }
};
//! Book of types of layers indexed by layer type name.
/*! While the sifz file is read, each time a new layer entry is found,
** the factory constructor that the "factory" pointer member of the
** "BookEntry" struct points to, is called, and a new layer of that type
** is created.
** \sa Layer::Factory
*/
typedef std::map<String,BookEntry> Book;
static void register_in_book(const BookEntry &);
static Book& book();
//! Inits the book of layers and inserts in it the basic layers that
//! doesn't depend on modules
/*! \todo motionblur should be in the mod_filter module
*/
static bool subsys_init();
//! Stops the layer system by deleting the book of registered layers
static bool subsys_stop();
//! Map of Value Base parameters indexed by name
typedef std::map<String,ValueBase> ParamList;
typedef etl::handle<Layer> Handle;
typedef etl::loose_handle<Layer> LooseHandle;
typedef etl::handle<const Layer> ConstHandle;
//! Map of parameters that are animated Value Nodes indexed by the param name
typedef std::map<String,etl::rhandle<ValueNode> > DynamicParamList;
//! A list type which describes all the parameters that a layer has.
/*! \see get_param_vocab() */
typedef ParamVocab Vocab;
/*
-- ** -- D A T A -------------------------------------------------------------
*/
private:
/*! \c true if the layer is visible, \c false if it is to be skipped
** \see set_active(), enable(), disable, active()
*/
bool active_;
//! flag to prevent re-apply optimization features
bool optimized_;
/*! When \c true, layer will skipped while final rendering
** but will still present onto work view.
** \see set_exclude_from_rendering(), get_exclude_from_rendering()
*/
bool exclude_from_rendering_;
//! Handle to the canvas to which this layer belongs
etl::loose_handle<Canvas> canvas_;
//! Map of parameter with animated value nodes
DynamicParamList dynamic_param_list_;
//! A description of what this layer does
String description_;
//! The depth parameter of the layer in the layer stack
ValueBase param_z_depth;
//! \writeme
mutable Time dirty_time_;
//! Contains the name of the group that this layer belongs to
String group_;
//! Signal to connect to the signal_deleted canvas's member
//! Used to do let a layer with a canvas parent that doesn't exists
//! Instead of that it connects to a zero canvas
//! \see Layer::set_canvas()
sigc::connection parent_death_connect_;
/*
-- ** -- S I G N A L S -------------------------------------------------------
*/
private:
//! Status Changed
sigc::signal<void> signal_status_changed_;
//! Parameter changed
sigc::signal<void,String> signal_param_changed_;
//! Description Changed
sigc::signal<void> signal_description_changed_;
//! Moved
sigc::signal<void, int, etl::handle<Canvas> > signal_moved_;
sigc::signal<void, String> signal_added_to_group_;
sigc::signal<void, String> signal_removed_from_group_;
/*
-- ** -- S I G N A L I N T E R F A C E -------------------------------------
*/
public:
//! Status Changed
sigc::signal<void>& signal_status_changed() { return signal_status_changed_; }
//! Parameter changed
sigc::signal<void,String>& signal_param_changed() { return signal_param_changed_; }
//! Description Changed
sigc::signal<void>& signal_description_changed() { return signal_description_changed_;}
//! Moved
sigc::signal<void, int, etl::handle<Canvas> >& signal_moved() { return signal_moved_; }
sigc::signal<void, String>& signal_added_to_group() { return signal_added_to_group_; }
sigc::signal<void, String>& signal_removed_from_group() { return signal_removed_from_group_; }
/*
-- ** -- C O N S T R U C T O R S ---------------------------------------------
*/
protected:
Layer();
public:
virtual ~Layer();
/*
-- ** -- M E M B E R F U N C T I O N S -------------------------------------
*/
public:
virtual void on_canvas_set();
//! Adds this layer to the given layer group
void add_to_group(const String&);
//! Removes this layer from the given layer group
void remove_from_group(const String&);
//! Removes this layer from all layer groups
void remove_from_all_groups();
//! Gets the name of the group that this layer belongs to
String get_group()const;
//! Retrieves the dynamic param list member
//! \see DynamicParamList
const DynamicParamList &dynamic_param_list()const { return dynamic_param_list_; }
//! Enables the layer for rendering (Making it \em active)
void enable() { set_active(true); }
//! Disables the layer for rendering. (Making it \em inactive)
/*! When a layer is disabled, it will be skipped when the
** canvas is rendered. */
void disable() { set_active(false); }
//! Sets the 'active' flag for the Layer to the state described by \a x
/*! When a layer is disabled, it will be skipped when the
** canvas is rendered. */
void set_active(bool x);
//! Returns that status of the 'active' flag
bool active()const { return active_; }
//! flag to prevent re-apply optimization features
bool optimized()const { return optimized_; }
//! set flag to prevent re-apply optimization features
void set_optimized(bool x) { optimized_ = x; }
//! Sets the 'exclude_from_rendering' flag for the Layer
/*! When set, layer will skipped while final rendering
** but will still present onto work view. */
void set_exclude_from_rendering(bool x);
//! Returns that status of the 'exclude_from_rendering' flag
bool get_exclude_from_rendering()const { return exclude_from_rendering_; }
//! Returns the position of the layer in the canvas.
/*! Returns negative on error */
int get_depth()const;
//! Gets the non animated z depth of the layer
float get_z_depth()const { return param_z_depth.get(Real()); }
//! Gets the z depth of the layer at a time t
float get_z_depth(const synfig::Time& t)const;
//! Gets the true z depth of the layer (index + parameter)
float get_true_z_depth(const synfig::Time& t=Time(0))const;
//! Sets the z depth of the layer (non animated)
void set_z_depth(float x) { param_z_depth=ValueBase(Real(x)); }
//! Sets the Canvas that this Layer is a part of
void set_canvas(etl::loose_handle<Canvas> canvas);
//! Returns a handle to the Canvas to which this Layer belongs
etl::loose_handle<Canvas> get_canvas()const;
//! Returns the description of the layer
const String& get_description()const { return description_; }
String get_string()const;
//! Sets the description of the layer
void set_description(const String& x);
//! Returns the layer's description if it's not empty, else its local name
const String get_non_empty_description()const { return get_description().empty() ? get_local_name() : get_description(); }
//! Returns the localised version of the given layer parameter
const String get_param_local_name(const String ¶m_name)const;
//! Returns a handle to the Parent PasteCanvas layer or NULL if layer belongs to root canvas
/*! Notice that it could return the wrong handle to PasteCanvas if the layer */
/*! belongs to a exported canvas (canvas can be referenced multiple times)*/
Layer::LooseHandle get_parent_paste_canvas_layer()const;
/*
-- ** -- V I R T U A L F U N C T I O N S -----------------------------------
*/
public:
//! Returns the rectangle that includes the layer
//! \see synfig::Rect
virtual Rect get_bounding_rect()const;
//!Returns the rectangle that includes the context of the layer
//!\see synfig::Rect synfig::Context
virtual Rect get_full_bounding_rect(Context context)const;
//! Returns a string containing the name of the Layer
virtual String get_name()const;
//! Returns a string containing the localized name of the Layer
virtual String get_local_name()const;
//! Gets the parameter vocabulary
virtual Vocab get_param_vocab()const;
//! Gets the version string for this layer
virtual String get_version()const;
//! Returns a handle to the Transform class of the layer
//! \see synfig::Transform
virtual etl::handle<Transform> get_transform()const;
//! Sets the virtual version to use for backwards-compatibility
/*!
** \see reset_version() */
virtual bool set_version(const String &ver);
//! Resets the virtual version
/*!
** \see set_version() */
virtual void reset_version();
//! Sets the parameter described by \a param to \a value.
/*! \param param The name of the parameter to set
** \param value What the parameter is to be set to.
** \return \c true on success, \c false upon rejection or failure.
** If it returns \c false, then the Layer is assumed to remain unchanged.
** \sa get_param()
** \todo \a param should be of the type <tt>const String \¶m</tt>
*/
virtual bool set_param(const String ¶m, const ValueBase &value);
//! Sets a list of parameters
virtual bool set_param_list(const ParamList &);
//! Get the value of the specified parameter.
/*! \return The requested parameter value, or (upon failure) a NIL ValueBase.
** \sa set_param()
** \todo \a param should be of the type <tt>const String \&</tt>
*/
virtual ValueBase get_param(const String ¶m)const;
//! Get a list of all of the parameters and their values
virtual ParamList get_param_list()const;
//! Sets the \a time for the Layer and those under it
/*! \param context Context iterator referring to next Layer.
** \param time writeme
** \see Context::set_time()
*/
virtual void set_time(IndependentContext context, Time time)const;
//! Sets the \a time for the selected Layer and those under it for a specific \a point
/*! \param context Context iterator referring to next Layer.
** \param time writeme
** \param point writeme
** \see Context::set_time()
** \todo \a point should be of the type <tt>const Point \&</tt> */
virtual void set_time(IndependentContext context, Time time, const Point &point)const;
//! Gets the blend color of the Layer in the context at \a pos
/*! \param context Context iterator referring to next Layer.
** \param pos Point which indicates where the Color should come from
** \see Context::get_color()
*/
virtual Color get_color(Context context, const Point &pos)const;
virtual CairoColor get_cairocolor(Context context, const Point &pos)const;
//! Sets the render method to the layer. Not all layers uses this virtual member
virtual void set_render_method(Context context, RenderMethod x);
// Temporary function to render transformed layer for leyers which yet not suppurt transformed rendering
static bool render_transformed(const Layer *layer, Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb, const char *file, int line);
//! Renders the Canvas to the given Surface in an accelerated manner
/*! \param context Context iterator referring to next Layer.
** \param surface Pointer to Surface to render to.
** \param quality The requested quality-level to render at.
** \param renddesc The associated RendDesc.
** \param cb Pointer to callback object. May be NULL if there is no callback.
** \return \c true on success, \c false on failure
** \see Context::accelerated_render()
*/
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
virtual bool accelerated_cairorender(Context context, cairo_t* cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
//! Checks to see if a part of the layer is directly under \a point
/*! \param context Context iterator referring to next Layer.
** \param point The point to check
** \return The handle of the layer under \a point. If there is not
** a layer under \a point, then returns an empty handle.
** \see Context::hit_check
*/
virtual Handle hit_check(Context context, const Point &point)const;
//! Duplicates the Layer
virtual Handle clone(etl::loose_handle<Canvas> canvas, const GUID& deriv_guid=GUID())const;
//! Returns true if the layer needs to be able to examine its context.
/*! context to render itself, other than for simple blending. For
** example, the blur layer will return true - it can't do its job
** if it can't see its context, and the circle layer will return
** false - rendering a circle doesn't depend on the underlying
** context until the final blend operation. */
virtual bool reads_context()const;
//! Duplicates the Layer without duplicating the value nodes
virtual Handle simple_clone()const;
//! Connects the parameter to another Value Node
virtual bool connect_dynamic_param(const String& param, etl::loose_handle<ValueNode>);
//! Disconnects the parameter from any Value Node
virtual bool disconnect_dynamic_param(const String& param);
//! Retrieves the grow value from its parent canvas
Real get_parent_canvas_grow_value()const;
virtual void fill_sound_processor(SoundProcessor &soundProcessor) const;
protected:
//! This is called whenever a parameter is changed
virtual void on_changed();
//! Called to figure out the animation time information
virtual void get_times_vfunc(Node::time_set &set) const;
/*
-- ** -- S T A T I C F U N C T I O N S --------------------------------------
*/
public:
//! Creates a Layer of type \a type
/*! If the Layer type is unknown, then a Mime layer is created in its place.
** \param type A string describing the name of the layer to construct.
** \return Always returns a handle to a new Layer.
** \see Mime
*/
static Layer::LooseHandle create(const String &type);
}; // END of class Layer
}; // END of namespace synfig
/* === E N D =============================================================== */
#endif
|