Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/render2D/element_2d.cc @ 10625

Last change on this file since 10625 was 10618, checked in by bknecht, 18 years ago

merged cleanup into trunk (only improvements)

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