Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/graphics/render2D/element_2d.cc @ 9715

Last change on this file since 9715 was 9715, checked in by bensch, 18 years ago

renamed newclassid to classid and newobjectlist to objectlist

File size: 35.8 KB
RevLine 
[4744]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[4838]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[3955]16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
[1853]17
[4839]18#include "element_2d.h"
[4840]19#include "render_2d.h"
[1853]20
[6142]21#include <algorithm>
22
[7843]23// ONLY IF PNODE ENABLED //
24#include "state.h"
[5775]25#include "p_node.h"
[7843]26#include "camera.h"
27///////////////////////////
[5775]28
[4843]29#include "graphics_engine.h"
[7193]30#include "util/loading/load_param.h"
[5775]31
[5285]32#include "color.h"
[4843]33
[7332]34#include "shell_command.h"
[8360]35SHELL_COMMAND(debug, Element2D, debug2D);
[7330]36
[9715]37ObjectListDefinition(Element2D);
[1853]38
[9685]39
[5285]40/**
[6295]41 * @brief standard constructor
[5285]42 * @param parent the parent to set for this Element2D
43 *
44 * NullElement2D needs this constructor with parameter NULL to initialize
45 * itself. Otherwise it would result in an endless Loop.
46 */
[6299]47Element2D::Element2D (Element2D* parent, E2D_LAYER layer, short nodeFlags)
[3365]48{
[9685]49  this->registerObject(this, Element2D::_objectList);
[6299]50
51  this->setVisibility(true);
[7843]52  this->bCurrentlyVisible = true;
[6299]53  this->activate2D();
54  this->setAlignment(E2D_ALIGN_NONE);
55  this->bindNode = NULL;
56
57  this->parentMode = nodeFlags;
58  this->parent = NULL;
59  this->absDirection = 0.0;
60  this->relDirection = 0.0;
61  this->bRelCoorChanged = true;
62  this->bRelDirChanged = true;
63  this->toCoordinate = NULL;
64  this->toDirection = NULL;
[7919]65
66  this->size = Vector2D(0,0);
[7031]67  this->toSize = NULL;
[6299]68
69
[5402]70  this->layer = layer;
[6299]71  if (parent != NULL)
72    parent->addChild2D(this);
[3365]73}
[1853]74
[6299]75
[3245]76/**
[6299]77 * @brief the mighty NullElement
78 * TopMost Node of them all.
79 */
80Element2D* Element2D::nullElement = NULL;
81
82
83/**
[6295]84 * @brief standard deconstructor
[5285]85 *
86 * There are two general ways to delete an Element2D
87 * 1. delete instance;
88 *   -> result
89 *    delete this Node and all its children and children's children...
90 *    (danger if you still want the instance!!)
91 *
92 * 2. instance->remove2D(); delete instance;
93 *   -> result:
[5401]94 *    moves its children to the NullElement2D
[5285]95 *    then deletes the Element.
96 */
[4838]97Element2D::~Element2D ()
[3543]98{
[6299]99  // remove the Element2D, delete it's children (if required).
100  std::list<Element2D*>::iterator tmp = this->children.begin();
101  std::list<Element2D*>::iterator deleteNode;
102  while(!this->children.empty())
103    while (tmp != this->children.end())
104    {
105      deleteNode = tmp;
106      tmp++;
[9406]107      //      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassCName(), this->getName());
[6299]108      if ((this->parentMode & E2D_PROHIBIT_CHILD_DELETE) ||
109          ((*deleteNode)->parentMode & E2D_PROHIBIT_DELETE_WITH_PARENT))
110      {
111        if (this == Element2D::nullElement && (*deleteNode)->parentMode & E2D_REPARENT_TO_NULL)
112          delete (*deleteNode);
113        else
114          (*deleteNode)->reparent2D();
115      }
116      else
117        delete (*deleteNode);
118    }
119
[5285]120  if (this->parent != NULL)
121  {
[6299]122    this->parent->eraseChild2D(this);
[5285]123    this->parent = NULL;
124  }
[5089]125
[5285]126  // remove all other allocated memory.
[5088]127  if (this->toCoordinate != NULL)
128    delete this->toCoordinate;
129  if (this->toDirection != NULL)
130    delete this->toDirection;
[7727]131  if (this->toSize != NULL)
132    delete this->toSize;
[6299]133
134  if (this == Element2D::nullElement)
135    Element2D::nullElement = NULL;
[3543]136}
[4843]137
138
[4858]139/**
[6295]140 * @brief Loads the Parameters of an Element2D from...
[4858]141 * @param root The XML-element to load from
142 */
143void Element2D::loadParams(const TiXmlElement* root)
144{
[6512]145  BaseObject::loadParams(root);
146
[5402]147  // ELEMENT2D-native settings.
[5671]148  LoadParam(root, "alignment", this, Element2D, setAlignment)
[7332]149  .describe("loads the alignment: (either: center, left, right or screen-center)");
[4858]150
[5671]151  LoadParam(root, "layer", this, Element2D, setLayer)
[7332]152  .describe("loads the layer onto which to project: (either: top, medium, bottom, below-all)");
[4858]153
[5671]154  LoadParam(root, "bind-node", this, Element2D, setBindNode)
[7332]155  .describe("sets a node, this 2D-Element should be shown upon (name of the node)");
[4858]156
[5671]157  LoadParam(root, "visibility", this, Element2D, setVisibility)
[7332]158  .describe("if the Element is visible or not");
[5089]159
160
[7332]161  // PNode-style:
[6878]162  LoadParam(root, "rel-coor-2d", this, Element2D, setRelCoor2D)
[7332]163  .describe("Sets The relative position of the Node to its parent.");
[5091]164
[6878]165  LoadParam(root, "abs-coor-2d", this, Element2D, setAbsCoor2D)
[7332]166  .describe("Sets The absolute Position of the Node.");
[5091]167
[6878]168  LoadParam(root, "rel-dir-2d", this, Element2D, setRelDir2D)
[7332]169  .describe("Sets The relative rotation of the Node to its parent.");
[5091]170
[6878]171  LoadParam(root, "abs-dir-2d", this, Element2D, setAbsDir2D)
[7332]172  .describe("Sets The absolute rotation of the Node.");
[5091]173
[5671]174  LoadParam(root, "parent", this, Element2D, setParent2D)
[7332]175  .describe("the Name of the Parent of this Element2D");
[5091]176
[5671]177  LoadParam(root, "parent-mode", this, Element2D, setParentMode2D)
[7332]178  .describe("the mode to connect this node to its parent ()");
[5091]179
180  // cycling properties
[6295]181  LOAD_PARAM_START_CYCLE(root, element);
[5091]182  {
[6299]183    LoadParam_CYCLE(element, "child", this, Element2D, addChild2D)
[7332]184    .describe("adds a new Child to the current Node.");
[5091]185  }
[6295]186  LOAD_PARAM_END_CYCLE(element);
[4858]187}
188
189/**
[7342]190 * @brief sets the alignment of the 2D-element in form of a String
[4858]191 * @param alignment the alignment @see loadParams
192*/
[7221]193void Element2D::setAlignment(const std::string& alignment)
[4858]194{
[7221]195  if (alignment == "center")
[4858]196    this->setAlignment(E2D_ALIGN_CENTER);
[7221]197  else if (alignment == "left")
[4858]198    this->setAlignment(E2D_ALIGN_LEFT);
[7221]199  else if (alignment == "right")
[4858]200    this->setAlignment(E2D_ALIGN_RIGHT);
[7221]201  else if (alignment == "screen-center")
[4858]202    this->setAlignment(E2D_ALIGN_SCREEN_CENTER);
203}
204
[4862]205
[4858]206/**
[7840]207 * @brief moves a Element to another layer
[4862]208 * @param layer the Layer this is drawn on
209 */
210void Element2D::setLayer(E2D_LAYER layer)
211{
[7341]212  if (unlikely(this->layer == layer)) return;
213
[5402]214  if (this->parent != NULL && this->parent->getLayer() > layer)
215  {
[5403]216    PRINTF(2)("Unable to set %s to layer %s, because it's parent(%s) is of higher layer %s\n",
[9406]217              this->getCName(),
[5403]218              Element2D::layer2DToChar(layer),
[9406]219              this->parent->getCName(),
[5403]220              Element2D::layer2DToChar(this->parent->getLayer()));
[5402]221    layer = this->parent->getLayer();
222  }
[4862]223  this->layer = layer;
[7330]224
225
226  if (this->parent != NULL)
227    this->parent->children.sort(layerSortPredicate);
[4862]228}
229
230/**
[7342]231 * @brief sets the layer onto which this 2D-element is projected to.
[7221]232 * @param layer the layer @see loadParams @see Element2D::charToLayer2D(const std::string& layer)
[4858]233 */
[7221]234void Element2D::setLayer(const std::string& layer)
[4858]235{
[5401]236  this->setLayer(Element2D::charToLayer2D(layer));
[4858]237}
238
[7846]239/**
240 * @brief sets the Size of the Element2D softly.
241 * @param x the x-coordinate
242 * @param y the y-coordinate.
243 * @param bias the bias (bigger = faster).
244 */
[7031]245void Element2D::setSizeSoft2D(float x, float y, float bias)
246{
247  if (likely(this->toSize == NULL))
248    this->toSize = new Vector2D();
[4858]249
[7031]250  *this->toSize = Vector2D(x,y);;
251  this->bias = bias;
252}
253
254
[7843]255/**
256 * @brief sets a node, this 2D-Element should be shown upon
257 * @param bindNode the Node of the Node. (if NULL it will be unset).
258 */
259void Element2D::setBindNode(const PNode* bindNode)
260{
261  this->bindNode = bindNode;
[7845]262  this->bCurrentlyVisible = (bindNode == NULL);
[7843]263}
[7031]264
[4858]265/**
[6299]266 * @brief sets a node, this 2D-Element should be shown upon
[4858]267 * @param bindNode the name of the Node (should be existing)
268 */
[7221]269void Element2D::setBindNode(const std::string& bindNode)
[4858]270{
[9685]271  const PNode* tmpBindNode = PNode::objectList().getObject(bindNode);
[4858]272  if (tmpBindNode != NULL)
273    this->bindNode = tmpBindNode;
274}
275
[5091]276/**
[7840]277 * @brief sets the relative coordinate of the Element2D to its parent
[5091]278 * @param relCoord the relative coordinate to the parent
279 */
[7316]280void Element2D::setRelCoor2D (const Vector2D& relCoord)
[5081]281{
[5113]282  if (this->toCoordinate!= NULL)
283  {
284    delete this->toCoordinate;
285    this->toCoordinate = NULL;
286  }
[5082]287  this->relCoordinate = relCoord;
288  this->bRelCoorChanged = true;
[5081]289}
290
[5091]291/**
[7840]292 * @brief sets the relative coordinate of the Element2D to its Parent
[5091]293 * @param x the x coordinate
294 * @param y the y coordinate
295 */
[7316]296void Element2D::setRelCoor2D (float x, float y)
[5081]297{
[7316]298  this->setRelCoor2D(Vector2D(x,y));
[5081]299}
300
[5091]301/**
[8035]302 * @brief updates the Rel - Coordinate in x-direction
303 * @param x the x coordinate
304 */
305void Element2D::setRelCoorX2D(float x)
306{
307  this->setRelCoor2D(Vector2D(x, this->relCoordinate.y));
308}
309
310/**
311 * @brief updates the Rel - Coordinate in y-direction
312 * @param y the y coordinate
313 */
314void Element2D::setRelCoorY2D(float y)
315{
316  this->setRelCoor2D(Vector2D(this->relCoordinate.x, y));
317}
318
319
320/**
[7840]321 * @brief sets the Relative coordinate to the parent in Pixels
[5091]322 * @param x the relCoord X
323 * @param y the relCoord Y
324 */
[5089]325void Element2D::setRelCoor2Dpx (int x, int y)
326{
[7316]327  this->setRelCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
[7332]328                              (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));
[5089]329}
330
[5091]331/**
[7840]332 * @brief sets a new relative position smoothely
[5091]333 * @param relCoordSoft the new Position to iterate to
334 * @param bias how fast to iterate to this position
335 */
[7316]336void Element2D::setRelCoorSoft2D(const Vector2D& relCoordSoft, float bias)
[5081]337{
[5082]338  if (likely(this->toCoordinate == NULL))
[7316]339    this->toCoordinate = new Vector2D();
[5082]340
341  *this->toCoordinate = relCoordSoft;
342  this->bias = bias;
[5081]343}
344
[5091]345/**
[7840]346 * @brief sets a new relative position smoothely
[5091]347 * @param x the new x-coordinate in Pixels of the Position to iterate to
348 * @param y the new y-coordinate in Pixels of the Position to iterate to
349 * @param bias how fast to iterate to this position
350 */
[5089]351void Element2D::setRelCoorSoft2Dpx (int x, int y, float bias)
352{
[7316]353  this->setRelCoorSoft2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
[7332]354                                  (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()),
[5089]355                         bias);
356}
357
[5091]358/**
[7840]359 * @brief set relative coordinates smoothely
[5091]360 * @param x x-relative coordinates to its parent
361 * @param y y-relative coordinates to its parent
362 * @param z z-relative coordinates to its parent
[7316]363 * @see  void PNode::setRelCoorSoft (const Vector2D&, float)
[5091]364 */
[7316]365void Element2D::setRelCoorSoft2D(float x, float y, float bias)
[5081]366{
[7316]367  this->setRelCoorSoft2D(Vector2D(x, y), bias);
[5081]368}
369
[5091]370/**
371 * @param absCoord set absolute coordinate
372 */
[7316]373void Element2D::setAbsCoor2D (const Vector2D& absCoord)
[5081]374{
[5113]375  if (this->toCoordinate!= NULL)
376  {
377    delete this->toCoordinate;
378    this->toCoordinate = NULL;
379  }
380
[5082]381  if( likely(this->parentMode & E2D_PARENT_MOVEMENT))
382  {
383    /* if you have set the absolute coordinates this overrides all other changes */
384    if (likely(this->parent != NULL))
385      this->relCoordinate = absCoord - parent->getAbsCoor2D ();
386    else
387      this->relCoordinate = absCoord;
388  }
389  if( this->parentMode & E2D_PARENT_ROTATE_MOVEMENT)
390  {
391    if (likely(this->parent != NULL))
392      this->relCoordinate = absCoord - parent->getAbsCoor2D ();
393    else
394      this->relCoordinate = absCoord;
395  }
396
397  this->bRelCoorChanged = true;
[5081]398}
399
[5091]400/**
401 * @param x x-coordinate.
402 * @param y y-coordinate.
403 * @param z z-coordinate.
[7316]404 * @see void PNode::setAbsCoor (const Vector2D& absCoord)
[5091]405 */
[7316]406void Element2D::setAbsCoor2D (float x, float y)
[5081]407{
[7316]408  this->setAbsCoor2D(Vector2D(x, y));
[5081]409}
410
[5091]411/**
[8035]412 * @brief updates the Abs - Coordinate in x-direction
413 * @param x the x coordinate
414 */
415void Element2D::setAbsCoorX2D(float x)
416{
417  this->setAbsCoor2D(x, this->getAbsCoor2D().y);
418}
419
420/**
421 * @brief updates the Abs - Coordinate in y-direction
422 * @param y the y coordinate
423 */
424void Element2D::setAbsCoorY2D(float y)
425{
426  this->setAbsCoor2D(this->getAbsCoor2D().x, y);
427}
428
429
430/**
[5091]431 * @param x x-coordinate in Pixels
432 * @param y y-coordinate in Pixels
[7316]433 * @see void PNode::setAbsCoor (const Vector2D& absCoord)
[5091]434 */
[5089]435void Element2D::setAbsCoor2Dpx (int x, int y)
436{
[7316]437  this->setAbsCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
[7332]438                              (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));
[5089]439}
440
[5091]441/**
[5414]442 * @param absCoordSoft set absolute coordinate
443 * @param bias how fast to iterato to the new Coordinate
444 */
[7316]445void Element2D::setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias)
[5414]446{
447  if (this->toCoordinate == NULL)
[7316]448    this->toCoordinate = new Vector2D();
[5414]449
450  if( likely(this->parentMode & E2D_PARENT_MOVEMENT))
451  {
452    /* if you have set the absolute coordinates this overrides all other changes */
453    if (likely(this->parent != NULL))
454      *this->toCoordinate = absCoordSoft - parent->getAbsCoor2D ();
455    else
456      *this->toCoordinate = absCoordSoft;
457  }
458  if( this->parentMode & E2D_PARENT_ROTATE_MOVEMENT)
459  {
460    if (likely(this->parent != NULL))
461      *this->toCoordinate = absCoordSoft - parent->getAbsCoor2D ();
462    else
463      *this->toCoordinate = absCoordSoft;
464  }
465
466  this->bias = bias;
467}
468
469/**
470 * @param x x-coordinate.
471 * @param y y-coordinate.
472 * @param z z-coordinate.
[7316]473 * @see void PNode::setAbsCoor (const Vector2D& absCoord)
[5414]474 */
[7316]475void Element2D::setAbsCoorSoft2D (float x, float y, float bias)
[5414]476{
[7316]477  this->setAbsCoorSoft2D(Vector2D(x, y), bias);
[5414]478}
479
480/**
[7840]481 * @brief shift coordinate ralative
[5091]482 * @param shift shift vector
483 *
[7316]484 * This simply adds the shift-Vector2D to the relative Coordinate
[5091]485 */
[7316]486void Element2D::shiftCoor2D (const Vector2D& shift)
[5081]487{
[5082]488  this->relCoordinate += shift;
489  this->bRelCoorChanged = true;
[5081]490}
491
[5091]492/**
[7840]493 * @brief shifts in PixelSpace
[5091]494 * @param x the pixels to shift in X
495 * @param y the pixels to shift in Y
496 */
[5089]497void Element2D::shiftCoor2Dpx (int x, int y)
498{
[7316]499  this->shiftCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(),
[7332]500                             (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));
[5089]501}
502
[5091]503/**
[7840]504 * @brief set relative direction
[5091]505 * @param relDir to its parent
506 */
[5081]507void Element2D::setRelDir2D (float relDir)
508{
[5113]509  if (this->toDirection!= NULL)
510  {
511    delete this->toDirection;
512    this->toDirection = NULL;
513  }
514
[5082]515  this->relDirection = relDir;
516  this->bRelDirChanged = true;
[5081]517}
518
[5091]519/**
[7840]520 * @brief sets the Relative Direction of this node to its parent in a Smoothed way
[5091]521 * @param relDirSoft the direction to iterate to smoothely.
522 * @param bias how fast to iterate to the new Direction
523 */
[5081]524void Element2D::setRelDirSoft2D(float relDirSoft, float bias)
525{
[5082]526  if (likely(this->toDirection == NULL))
527    this->toDirection = new float;
528
529  *this->toDirection = relDirSoft;
530  this->bias = bias;
[5081]531}
532
[5091]533/**
[7840]534 * @brief sets the absolute direction
[5091]535 * @param absDir absolute coordinates
536 */
[5081]537void Element2D::setAbsDir2D (float absDir)
538{
[5113]539  if (this->toDirection!= NULL)
540  {
541    delete this->toDirection;
542    this->toDirection = NULL;
543  }
544
[5082]545  if (likely(this->parent != NULL))
546    this->relDirection = absDir - this->parent->getAbsDir2D();
547  else
548    this->relDirection = absDir;
549
550  this->bRelDirChanged = true;
[5081]551}
552
[5091]553/**
[7840]554 * @brief sets the absolute direction softly
[5414]555 * @param absDir absolute coordinates
556 */
557void Element2D::setAbsDirSoft2D (float absDirSoft, float bias)
558{
559  if (this->toDirection == NULL)
560    this->toDirection = new float;
561
562  if (likely(this->parent != NULL))
563    *this->toDirection = absDirSoft - this->parent->getAbsDir2D();
564  else
565    *this->toDirection = absDirSoft;
566
567  this->bias = bias;
568}
569
570/**
[5091]571 * shift Direction
572 * @param shift the direction around which to shift.
573 */
[5083]574void Element2D::shiftDir2D (float shiftDir)
[5081]575{
[5082]576  this->relDirection = this->relDirection + shiftDir;
577  this->bRelDirChanged = true;
[5081]578}
579
[5091]580/**
[7330]581 * @brief adds a child and makes this node to a parent
[5091]582 * @param child child reference
583 * @param parentMode on which changes the child should also change ist state
584 *
585 * use this to add a child to this node.
586 */
[5403]587void Element2D::addChild2D (Element2D* child)
[5081]588{
[6295]589  assert(child != NULL);
[5082]590  if( likely(child->parent != NULL))
591  {
[5254]592    PRINTF(5)("Element2D::addChild() - reparenting node: removing it and adding it again\n");
[6299]593    child->parent->eraseChild2D(child);
[5082]594  }
[6299]595  if (this->checkIntegrity(child))
[5402]596  {
[7332]597    // Setting the New Parent.
[6299]598    child->parent = this;
599    if (likely(this != NULL))
[5403]600    {
[7332]601      // Layers of Children that are smaller than this(parents) Layer will be updated, and pushed to the front.
602      if (unlikely(this->layer > child->getLayer()))
603      {
604        PRINTF(2)("Layer '%s' of Child(%s::%s) lower than parents(%s::%s) layer '%s'. updating...\n",
[9406]605                  Element2D::layer2DToChar(child->getLayer()),child->getClassCName(), child->getCName(),
606                  this->getClassCName(), this->getCName(), Element2D::layer2DToChar(this->layer));
[7332]607        child->layer = this->layer;
608        this->children.push_front(child);
609      }
610      else
611      {
612        // Inserting the Element at the right Layer depth.
[7840]613        std::list<Element2D*>::iterator elem;
[7332]614        for (elem = this->children.begin(); elem != this->children.end(); elem++)
615        {
616          if ((*elem)->layer <= child->layer)
617          {
618            this->children.insert(elem, child);
619            break;
620          }
621        }
622        // if we are at the Last child push it back.
623        if (elem == this->children.end())
624          this->children.push_back(child);
625      }
626    }
627    else
628    {
629      PRINTF(1)("Tried to reparent2D to own child '%s::%s' to '%s::%s'.\n",
[9406]630                this->getClassCName(), this->getCName(), child->getClassCName(), child->getCName());
[7332]631      child->parent = NULL;
632    }
[5402]633  }
[6299]634  child->parentCoorChanged2D();
[5081]635}
636
[5091]637/**
638 * @see Element2D::addChild(Element2D* child);
639 * @param childName the name of the child to add to this PNode
640 */
[7221]641void Element2D::addChild2D (const std::string& childName)
[5081]642{
[9685]643  Element2D* childNode = Element2D::objectList().getObject(childName);
[5082]644  if (childNode != NULL)
645    this->addChild2D(childNode);
[5081]646}
647
[5091]648/**
[7330]649 * @brief removes a child from the node
[5091]650 * @param child the child to remove from this Node..
651 *
652 * Children from nodes will not be lost, they are referenced to NullPointer
653 */
[5081]654void Element2D::removeChild2D (Element2D* child)
655{
[5212]656  if (child != NULL)
657    child->remove2D();
[5081]658}
659
[5091]660/**
[6299]661 * !! PRIVATE FUNCTION
662 * @brief reparents an Element2D (happens on Parents Node delete or remove and Flags are set.)
663 */
664void Element2D::reparent2D()
665{
666  if (this->parentMode & E2D_REPARENT_TO_NULL)
667    this->setParent2D((Element2D*)NULL);
668  else if (this->parentMode & E2D_REPARENT_TO_PARENTS_PARENT && this->parent != NULL)
669    this->setParent2D(this->parent->getParent2D());
670  else
671    this->setParent2D(Element2D::getNullElement());
672}
673
674
675/**
676 * @param child the child to be erased from this Nodes List
677 */
678void Element2D::eraseChild2D(Element2D* child)
679{
680  assert (this != NULL && child != NULL);
681  std::list<Element2D*>::iterator childIT = std::find(this->children.begin(), this->children.end(), child);
682  this->children.erase(childIT);
683}
684
685
686
687/**
[7840]688 * @brief remove this Element from the tree and adds all children to NullElement2D
[5091]689 *
[5285]690 * afterwards this Node is free, and can be reattached, or deleted freely.
[5091]691 */
[5081]692void Element2D::remove2D()
693{
[7840]694  std::list<Element2D*>::iterator child = this->children.begin();
695  std::list<Element2D*>::iterator reparenter;
[6299]696  while (child != this->children.end())
697  {
698    reparenter = child;
699    child++;
700    if (this->parentMode & E2D_REPARENT_CHILDREN_ON_REMOVE ||
701        (*reparenter)->parentMode & E2D_REPARENT_ON_PARENTS_REMOVE)
702    {
703      (*reparenter)->reparent2D();
[9406]704      PRINTF(5)("REPARENTED TO: %s::%s\n",(*reparenter)->getParent2D()->getClassCName(),(*reparenter)->getParent2D()->getCName());
[6299]705    }
706  }
[5214]707  if (this->parent != NULL)
[5285]708  {
[6299]709    this->parent->eraseChild2D(this);
[5285]710    this->parent = NULL;
711  }
[5081]712}
713
714
[5091]715/**
716 * @see Element2D::setParent(Element2D* parent);
717 * @param parentName the name of the Parent to set to this Element2D
718 */
[7221]719void Element2D::setParent2D (const std::string& parentName)
[5081]720{
[9685]721  Element2D* parentNode = Element2D::objectList().getObject(parentName);
[5082]722  if (parentNode != NULL)
723    parentNode->addChild2D(this);
[6299]724  else
725    PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n",
[9406]726              this->getClassCName(), this->getCName(), parentName.c_str());
[5081]727}
728
[5091]729/**
[7840]730 * @brief does the reparenting in a very smooth way
[5091]731 * @param parentNode the new Node to connect this node to.
732 * @param bias the speed to iterate to this new Positions
733 */
[5382]734void Element2D::setParentSoft2D(Element2D* parentNode, float bias)
[5081]735{
[5082]736  if (this->parent == parentNode)
737    return;
738
739  if (likely(this->toCoordinate == NULL))
740  {
[7316]741    this->toCoordinate = new Vector2D();
[5082]742    *this->toCoordinate = this->getRelCoor2D();
743  }
744  if (likely(this->toDirection == NULL))
745  {
746    this->toDirection = new float;
747    *this->toDirection = this->getRelDir2D();
748  }
749  this->bias = bias;
750
751
[7316]752  Vector2D tmpV = this->getAbsCoor2D();
[5082]753  float tmpQ = this->getAbsDir2D();
754
755  parentNode->addChild2D(this);
756
[6299]757  if (this->parentMode & E2D_PARENT_ROTATE_MOVEMENT) //! @todo implement this.
[5082]758    ;//this->setRelCoor(this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor()));
759  else
[5382]760    this->relCoordinate = (tmpV - parentNode->getAbsCoor2D());
761  this->bRelCoorChanged = true;
[5082]762
[5382]763  this->relDirection = (tmpQ - parentNode->getAbsDir2D());
764  this->bRelDirChanged = true;
[5081]765}
766
[5091]767/**
[7330]768 * @brief does the reparenting in a very smooth way
[5091]769 * @param parentName the name of the Parent to reconnect to
770 * @param bias the speed to iterate to this new Positions
771 */
[7221]772void Element2D::setParentSoft2D(const std::string& parentName, float bias)
[5081]773{
[9685]774  Element2D* parentNode = Element2D::objectList().getObject(parentName);
[5082]775  if (parentNode != NULL)
[5382]776    this->setParentSoft2D(parentNode, bias);
[5081]777}
778
[6299]779/**
780 * @param parentMode sets the parentingMode of this Node
781 */
782void Element2D::setParentMode2D(E2D_PARENT_MODE parentMode)
[6142]783{
[6307]784  this->parentMode = ((this->parentMode & 0xfff0) | parentMode);
[6142]785}
786
[6299]787
[5091]788/**
[6295]789 * @brief sets the mode of this parent manually
[5091]790 * @param parentMode a String representing this parentingMode
791 */
[7221]792void Element2D::setParentMode2D (const std::string& parentingMode)
[5081]793{
[7221]794  this->setParentMode2D(Element2D::stringToParentingMode2D(parentingMode));
[5081]795}
796
[7330]797/**
798 * @brief checks if elem1 is in a deeper layer as elem2
799 * @param elem1 the first Element2D
800 * @param elem2 the second Element2D
801 * @returns true if elem1->layer < elem2->layer
802 */
803bool Element2D::layerSortPredicate(const Element2D* elem1, const Element2D* elem2)
804{
805  return elem1->layer < elem2->layer;
806}
[6299]807
[7330]808
[5091]809/**
[6299]810 * @returns the NullElement (and if needed (most probably) creates it)
811 */
812Element2D* Element2D::createNullElement()
813{
814  if (likely(Element2D::nullElement == NULL))
815  {
816    Element2D::nullElement = new Element2D(NULL, E2D_LAYER_BELOW_ALL, E2D_PARENT_MODE_DEFAULT | E2D_REPARENT_TO_NULL);
817    Element2D::nullElement->setName("NullElement");
818  }
819  return Element2D::nullElement;
820}
821
822
823/**
824 * !! PRIVATE FUNCTION
825 * @brief checks the upward integrity (e.g if Element2D is somewhere up the Node tree.)
826 * @param checkParent the Parent to check.
827 * @returns true if the integrity-check succeeds, false otherwise.
828 *
829 * If there is a second occurence of checkParent before NULL, then a loop could get
830 * into the Tree, and we do not want this.
831 */
832bool Element2D::checkIntegrity(const Element2D* checkParent) const
833{
834  const Element2D* parent = this;
835  while ( (parent = parent->getParent2D()) != NULL)
836    if (unlikely(parent == checkParent))
837      return false;
838  return true;
839}
840
841
842/**
[7330]843 * @brief updates the absCoordinate/absDirection
[5091]844 * @param dt The time passed since the last update
[5081]845
[5091]846   this is used to go through the parent-tree to update all the absolute coordinates
847   and directions. this update should be done by the engine, so you don't have to
848   worry, normaly...
849 */
[5081]850void Element2D::update2D (float dt)
851{
[5089]852  // setting the Position of this 2D-Element.
[5083]853  if( likely(this->parent != NULL))
854  {
[7332]855    // movement for nodes with smoothMove enabled
[5083]856    if (unlikely(this->toCoordinate != NULL))
857    {
[7316]858      Vector2D moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
[5082]859
[5083]860      if (likely(moveVect.len() >= .001))//PNODE_ITERATION_DELTA))
861      {
862        this->shiftCoor2D(moveVect);
863      }
864      else
865      {
[7316]866        Vector2D tmp = *this->toCoordinate;
[5377]867        this->setRelCoor2D(tmp);
[9406]868        PRINTF(5)("SmoothMove of %s finished\n", this->getCName());
[5083]869      }
870    }
871    if (unlikely(this->toDirection != NULL))
872    {
[5376]873      float rotFlot = (*this->toDirection - this->relDirection) *fabsf(dt)*bias;
874      if (likely(fabsf(rotFlot) >= .001))//PNODE_ITERATION_DELTA))
[5083]875      {
876        this->shiftDir2D(rotFlot);
877      }
878      else
879      {
[5377]880        float tmp = *this->toDirection;
881        this->setRelDir2D(tmp);
[9406]882        PRINTF(5)("SmoothRotate of %s finished\n", this->getCName());
[5083]883      }
884    }
[7031]885    if (unlikely(this->toSize != NULL))
886    {
[7919]887      Vector2D shiftSize = (*this->toSize - this->size) *fabsf(dt)*bias;
[7031]888      if (likely((shiftSize).len() >= .001))//PNODE_ITERATION_DELTA))
889      {
[7919]890        this->size += shiftSize;
[7031]891      }
892      else
893      {
894        delete this->toSize;
895        this->toSize = NULL;
[9406]896        PRINTF(5)("SmoothRotate of %s finished\n", this->getCName());
[7031]897      }
898    }
[5083]899
900    // MAIN UPDATE /////////////////////////////////////
901    this->lastAbsCoordinate = this->absCoordinate;
902
[9406]903    PRINTF(5)("Element2D::update - %s - (%f, %f)\n", this->getCName(), this->absCoordinate.x, this->absCoordinate.y);
[5083]904
905
[5118]906    if( this->parentMode & E2D_PARENT_LOCAL_ROTATE && this->bRelDirChanged)
[5083]907    {
908      /* update the current absDirection - remember * means rotation around sth.*/
[5090]909      this->prevRelDirection = this->relDirection;
[5083]910      this->absDirection = this->relDirection + parent->getAbsDir2D();;
911    }
912
[5089]913
[5397]914    if (unlikely(this->alignment & E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged))
[5083]915    {
916      this->prevRelCoordinate = this->relCoordinate;
[5089]917      this->absCoordinate.x = .5 + this->relCoordinate.x;
918      this->absCoordinate.y = .5 + this->relCoordinate.y;
[5083]919    }
[5397]920    else if (unlikely(this->bindNode != NULL))
[5083]921    {
[7843]922      if (State::getCamera()->distance(this->bindNode) < 0)
923        this->bCurrentlyVisible = false;
924      else
925      {
926        this->bCurrentlyVisible = true;
927      }
928
[7871]929      /// TODO this should be done on the new Projection Matrix.
[6778]930      GLdouble projectPos[3] = {0.0, 0.0, 0.0};
[5089]931      gluProject(this->bindNode->getAbsCoor().x,
932                 this->bindNode->getAbsCoor().y,
933                 this->bindNode->getAbsCoor().z,
934                 GraphicsEngine::modMat,
935                 GraphicsEngine::projMat,
936                 GraphicsEngine::viewPort,
937                 projectPos,
938                 projectPos+1,
939                 projectPos+2);
[9406]940      //       printf("%s::%s  == %f %f %f :: %f %f\n", this->getClassCName(), this->getName(),
[7332]941      //              this->bindNode->getAbsCoor().x,
942      //              this->bindNode->getAbsCoor().y,
943      //              this->bindNode->getAbsCoor().z,
944      //              projectPos[0],
945      //              projectPos[1]);
[6778]946
[5396]947      this->prevRelCoordinate.x = this->absCoordinate.x = projectPos[0] /* /(float)GraphicsEngine::getInstance()->getResolutionX() */ + this->relCoordinate.x;
948      this->prevRelCoordinate.y = this->absCoordinate.y = (float)GraphicsEngine::getInstance()->getResolutionY() -  projectPos[1] + this->relCoordinate.y;
949      this->bRelCoorChanged = true;
[5089]950    }
951    else
952    {
953      if(likely(this->parentMode & PNODE_MOVEMENT && this->bRelCoorChanged))
954      {
955        /* update the current absCoordinate */
956        this->prevRelCoordinate = this->relCoordinate;
957        this->absCoordinate = this->parent->getAbsCoor2D() + this->relCoordinate;
958      }
959      else if( this->parentMode & PNODE_ROTATE_MOVEMENT && this->bRelCoorChanged)
960      {
961        /* update the current absCoordinate */
962        this->prevRelCoordinate = this->relCoordinate;
[8316]963//         float sine = sin(this->parent->getAbsDir2D());
964//         float cose = cos(this->parent->getAbsDir2D());
[7332]965        //        this->absCoordinate.x = this->relCoordinate.x*cose - this->relCoordinate.y*sine + this->parent->getRelCoor2D().x*(1-cose) +this->parent->getRelCoor2D().y*sine;
966        //        this->absCoordinate.y = this->relCoordinate.x*sine + this->relCoordinate.y*cose + this->parent->getRelCoor2D().y*(1-cose) +this->parent->getRelCoor2D().x*sine;
[5090]967
[5089]968        this->absCoordinate.x = this->parent->getAbsCoor2D().x + (this->relCoordinate.x*cos(this->parent->getAbsDir2D()) - this->relCoordinate.y * sin(this->parent->getAbsDir2D()));
969        this->absCoordinate.y = this->parent->getAbsCoor2D().y + (this->relCoordinate.x*sin(this->parent->getAbsDir2D()) + this->relCoordinate.y * cos(this->parent->getAbsDir2D()));
[5083]970
[5089]971      }
[5083]972    }
973    /////////////////////////////////////////////////
974  }
975  else
976  {
[7316]977    PRINTF(5)("Element2D::update - (%f, %f)\n", this->absCoordinate.x, this->absCoordinate.y);
[5083]978    if (this->bRelCoorChanged)
[5118]979    {
980      this->prevRelCoordinate = this->relCoordinate;
[5083]981      this->absCoordinate = this->relCoordinate;
[5118]982    }
[5083]983    if (this->bRelDirChanged)
[5118]984    {
985      this->prevRelDirection = this->relDirection;
[5376]986      this->absDirection = this->getAbsDir2D() + this->relDirection;
[5118]987    }
[5083]988  }
989
[5089]990
991  // UPDATE CHILDREN
[6299]992  if(!this->children.empty() || this->parentMode & E2D_UPDATE_CHILDREN_IF_INACTIVE)
[5083]993  {
[7840]994    std::list<Element2D*>::iterator child;
[5775]995    for (child = this->children.begin(); child != this->children.end(); child++)
[5083]996    {
997      /* if this node has changed, make sure, that all children are updated also */
998      if( likely(this->bRelCoorChanged))
[6299]999        (*child)->parentCoorChanged2D();
[5083]1000      if( likely(this->bRelDirChanged))
[6299]1001        (*child)->parentDirChanged2D();
[5083]1002
[5775]1003      (*child)->update2D(dt);
[5083]1004    }
1005  }
[5089]1006
1007  // FINISHING PROCESS
[5083]1008  this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
1009  this->bRelCoorChanged = false;
1010  this->bRelDirChanged = false;
[5081]1011}
1012
[6299]1013
[5091]1014/**
[7840]1015 * @brief displays some information about this pNode
[5091]1016 * @param depth The deph into which to debug the children of this Element2D to.
1017 * (0: all children will be debugged, 1: only this Element2D, 2: this and direct children...)
1018 * @param level The n-th level of the Node we draw (this is internal and only for nice output)
1019 */
[7052]1020void Element2D::debug2D (unsigned int depth, unsigned int level) const
[5081]1021{
[5082]1022  for (unsigned int i = 0; i < level; i++)
1023    PRINT(0)(" |");
[5775]1024  if (this->children.size() > 0)
[5082]1025    PRINT(0)(" +");
1026  else
1027    PRINT(0)(" -");
[7332]1028  PRINT(0)("E2D(%s::%s);AC:(%0.2f, %0.2f);RC:(%0.2f, %0.2f);AD(%0.2f)->%s;Layer:(%s)\n",
[9406]1029           this->getClassCName(),
1030           this->getCName(),
[7332]1031           this->absCoordinate.x,
1032           this->absCoordinate.y,
1033           this->relCoordinate.x,
1034           this->relCoordinate.y,
1035           this->getAbsDir2D(),
1036           Element2D::parentingModeToString2D(parentMode),
1037           Element2D::layer2DToChar(this->layer));
[5402]1038
[5082]1039  if (depth >= 2 || depth == 0)
1040  {
[7840]1041    std::list<Element2D*>::const_iterator child;
[5775]1042    for (child = this->children.begin(); child != this->children.end(); child++)
[5082]1043    {
1044      if (depth == 0)
[7052]1045        (*child)->debug2D(0, level + 1);
[5082]1046      else
[7052]1047        (*child)->debug2D(depth - 1, level +1);
[5082]1048    }
1049  }
[5081]1050}
1051
[5285]1052/**
[7840]1053 * @brief ticks the 2d-Element
[5285]1054 * @param dt the time elapsed since the last tick
[5401]1055 *
1056 * the element only gets tickt, if it is active.
1057 * Be aware, that this walks through the entire Element2D-tree,
1058 * searching for Elements to be ticked.
[5285]1059 */
[5401]1060void Element2D::tick2D(float dt)
[5285]1061{
[6299]1062  if (this->bActive)
[5401]1063    this->tick(dt);
[5775]1064  if (this->children.size() > 0)
[5401]1065  {
[7840]1066    std::list<Element2D*>::iterator child;
[5775]1067    for (child = this->children.begin(); child != this->children.end(); child++)
1068      (*child)->tick2D(dt);
[5401]1069  }
1070}
[5082]1071
[5401]1072/**
[7840]1073 * @brief draws all the Elements from this element2D downwards
[8360]1074 * @param from the minimal Layer to draw. @see E2D_LAYER
1075 * @param to the maximal Layer to draw. @see E2D_LAYER
1076 *
[5401]1077 */
[7840]1078void Element2D::draw2D(E2D_LAYER from, E2D_LAYER to) const
[5401]1079{
[7844]1080  if (this->isVisible())
[8360]1081  {
[5401]1082    this->draw();
[8360]1083    this->drawChildren(from, to);
1084  }
1085  else if ((parentMode & E2D_HIDE_CHILDREN_IF_HIDDEN) == 0)
1086    this->drawChildren(from, to);
1087}
1088
1089/**
1090 * @brief Draws the Children of the Element2D node.
1091 * @param param the minimal Layer to draw. @see E2D_LAYER
1092 * @param to the maximal Layer to draw. @see E2D_LAYER
1093 */
1094void Element2D::drawChildren(E2D_LAYER from, E2D_LAYER to) const
1095{
1096  if (likely(this->children.size() > 0))
[5401]1097  {
[7840]1098    std::list<Element2D*>::const_iterator child;
[5775]1099    for (child = this->children.begin(); child != this->children.end(); child++)
[7840]1100      if (likely( (*child)->layer >= from && (*child)->layer <= to))
1101        (*child)->draw2D(from, to);
[5401]1102  }
[5285]1103}
1104
[8360]1105
[5091]1106/**
[7330]1107 * @brief displays the Element2D at its position with its rotation as a Plane.
[5091]1108 */
[5417]1109void Element2D::debugDraw2D(unsigned int depth, float size, Vector color, unsigned int level) const
[5081]1110{
[5417]1111  if (level == 0)
1112  {
1113    glPushAttrib(GL_ENABLE_BIT);
1114    glMatrixMode(GL_MODELVIEW);
[5082]1115
[5417]1116    glDisable(GL_LIGHTING);
1117    glDisable(GL_BLEND);
1118    glDisable(GL_TEXTURE_2D);
1119  }
1120
1121  glPushMatrix();
1122  /* translate */
1123  /* rotate */
1124  glColor3f(color.x, color.y, color.z);
1125
1126  glTranslatef (this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
1127  glRotatef(this->getAbsDir2D(), 0,0,1);
1128  glBegin(GL_LINE_LOOP);
[5418]1129  glVertex2f(0, 0);
1130  glVertex2f(0, +this->getSizeY2D());
[5417]1131  glVertex2f(+this->getSizeX2D(), +this->getSizeY2D());
[5418]1132  glVertex2f(+this->getSizeX2D(), 0);
[5417]1133  glEnd();
1134
1135
1136  glPopMatrix();
1137  if (depth >= 2 || depth == 0)
1138  {
1139    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
[7840]1140    std::list<Element2D*>::const_iterator child;
[5775]1141    for (child = this->children.begin(); child != this->children.end(); child++)
[5417]1142    {
1143      // drawing the Dependency graph
[6299]1144      if (this != Element2D::getNullElement())
[5417]1145      {
1146        glBegin(GL_LINES);
1147        glColor3f(color.x, color.y, color.z);
1148        glVertex3f(this->getAbsCoor2D ().x,
1149                   this->getAbsCoor2D ().y,
1150                   0);
1151        glColor3f(childColor.x, childColor.y, childColor.z);
[5775]1152        glVertex3f((*child)->getAbsCoor2D ().x,
1153                   (*child)->getAbsCoor2D ().y,
[5417]1154                   0);
1155        glEnd();
1156      }
1157      if (depth == 0)
[5775]1158        (*child)->debugDraw2D(0, size, childColor, level+1);
[5417]1159      else
[5775]1160        (*child)->debugDraw2D(depth - 1, size, childColor, level +1);
[5417]1161    }
1162  }
1163  if (level == 0)
1164    glPopAttrib();
[5081]1165}
1166
1167
1168// helper functions //
[5091]1169/**
[7330]1170 * @brief converts a parentingMode into a string that is the name of it
[5091]1171 * @param parentingMode the ParentingMode to convert
1172 * @return the converted string
1173 */
[7221]1174const char* Element2D::parentingModeToString2D(int parentingMode)
[5081]1175{
[5082]1176  if (parentingMode == E2D_PARENT_LOCAL_ROTATE)
1177    return "local-rotate";
1178  else if (parentingMode == E2D_PARENT_ROTATE_MOVEMENT)
1179    return "rotate-movement";
1180  else if (parentingMode == E2D_PARENT_MOVEMENT)
1181    return "movement";
1182  else if (parentingMode == E2D_PARENT_ALL)
1183    return "all";
1184  else if (parentingMode == E2D_PARENT_ROTATE_AND_MOVE)
1185    return "rotate-and-move";
[8316]1186  else return "all";
[5081]1187}
1188
[5091]1189/**
[7330]1190 * @brief converts a parenting-mode-string into a int
[5091]1191 * @param parentingMode the string naming the parentingMode
1192 * @return the int corresponding to the named parentingMode
1193 */
[7221]1194E2D_PARENT_MODE Element2D::stringToParentingMode2D(const std::string& parentingMode)
[5081]1195{
[7221]1196  if (parentingMode == "local-rotate")
[5082]1197    return (E2D_PARENT_LOCAL_ROTATE);
[7221]1198  else  if (parentingMode == "rotate-movement")
[5082]1199    return (E2D_PARENT_ROTATE_MOVEMENT);
[7221]1200  else  if (parentingMode == "movement")
[5082]1201    return (E2D_PARENT_MOVEMENT);
[7221]1202  else  if (parentingMode == "all")
[5082]1203    return (E2D_PARENT_ALL);
[7221]1204  else  if (parentingMode == "rotate-and-move")
[5082]1205    return (E2D_PARENT_ROTATE_AND_MOVE);
[8316]1206  else return E2D_PARENT_ALL;
[5081]1207}
1208
[5401]1209/**
[7330]1210 * @brief converts a layer into its corresponding string
[5401]1211 * @param layer the layer to get the name-String of.
1212 * @returns the Name of the Layer (on error the default-layer-string is returned)
1213 */
1214const char* Element2D::layer2DToChar(E2D_LAYER layer)
1215{
1216  switch(layer)
1217  {
[7330]1218    case E2D_LAYER_ABOVE_ALL:
1219      return "above-all";
[5401]1220    case E2D_LAYER_TOP:
1221      return "top";
1222    case E2D_LAYER_MEDIUM:
1223      return "medium";
1224    case E2D_LAYER_BOTTOM:
1225      return "bottom";
1226    case E2D_LAYER_BELOW_ALL:
1227      return "below-all";
1228    default:
[7330]1229      assert (false);
[5401]1230      return layer2DToChar(E2D_DEFAULT_LAYER);
1231  }
1232}
[5081]1233
[5401]1234/**
[7330]1235 * @brief converts a String holding a actual Layer
[5401]1236 * @param layer the String to convert into a Layer2D
1237 * @returns the E2D_LAYER on success, E2D_DEFAULT_LAYER on error.
1238 */
[7221]1239E2D_LAYER Element2D::charToLayer2D(const std::string& layer)
[5401]1240{
[7330]1241  if (layer == "above-all")
1242    return (E2D_LAYER_ABOVE_ALL);
1243  if (layer == "top")
[5401]1244    return (E2D_LAYER_TOP);
[7221]1245  else  if (layer == "medium")
[5401]1246    return (E2D_LAYER_MEDIUM);
[7221]1247  else  if (layer == "bottom")
[5401]1248    return (E2D_LAYER_BOTTOM);
[7221]1249  else  if (layer == "below-all")
[5401]1250    return (E2D_LAYER_BELOW_ALL);
1251  else
1252    return (E2D_DEFAULT_LAYER);
1253}
Note: See TracBrowser for help on using the repository browser.