Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7330 in orxonox.OLD for trunk/src/lib/graphics/render2D


Ignore:
Timestamp:
Apr 18, 2006, 2:54:34 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Sorting in ShellCommand

Location:
trunk/src/lib/graphics/render2D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7316 r7330  
    2828
    2929#include "color.h"
     30
     31//#include "shell_command.h"
     32//SHELL_COMMAND(debug, Element2D, debug2D);
    3033
    3134using namespace std;
     
    209212  }
    210213  this->layer = layer;
     214
     215
     216  if (this->parent != NULL)
     217    this->parent->children.sort(layerSortPredicate);
    211218}
    212219
     
    510517
    511518/**
    512  * adds a child and makes this node to a parent
     519 * @brief adds a child and makes this node to a parent
    513520 * @param child child reference
    514521 * @param parentMode on which changes the child should also change ist state
     
    573580
    574581/**
    575  * removes a child from the node
     582 * @brief removes a child from the node
    576583 * @param child the child to remove from this Node..
    577584 *
     
    693700
    694701/**
    695  * does the reparenting in a very smooth way
     702 * @brief does the reparenting in a very smooth way
    696703 * @param parentName the name of the Parent to reconnect to
    697704 * @param bias the speed to iterate to this new Positions
     
    720727{
    721728  this->setParentMode2D(Element2D::stringToParentingMode2D(parentingMode));
     729}
     730
     731/**
     732 * @brief checks if elem1 is in a deeper layer as elem2
     733 * @param elem1 the first Element2D
     734 * @param elem2 the second Element2D
     735 * @returns true if elem1->layer < elem2->layer
     736 */
     737bool Element2D::layerSortPredicate(const Element2D* elem1, const Element2D* elem2)
     738{
     739  return elem1->layer < elem2->layer;
    722740}
    723741
     
    757775
    758776/**
    759  * updates the absCoordinate/absDirection
     777 * @brief updates the absCoordinate/absDirection
    760778 * @param dt The time passed since the last update
    761779
     
    9971015
    9981016/**
    999  * displays the Element2D at its position with its rotation as a Plane.
     1017 * @brief displays the Element2D at its position with its rotation as a Plane.
    10001018 */
    10011019void Element2D::debugDraw2D(unsigned int depth, float size, Vector color, unsigned int level) const
     
    10611079// helper functions //
    10621080/**
    1063  * converts a parentingMode into a string that is the name of it
     1081 * @brief converts a parentingMode into a string that is the name of it
    10641082 * @param parentingMode the ParentingMode to convert
    10651083 * @return the converted string
     
    10801098
    10811099/**
    1082  * converts a parenting-mode-string into a int
     1100 * @brief converts a parenting-mode-string into a int
    10831101 * @param parentingMode the string naming the parentingMode
    10841102 * @return the int corresponding to the named parentingMode
     
    10991117
    11001118/**
    1101  * converts a layer into its corresponding string
     1119 * @brief converts a layer into its corresponding string
    11021120 * @param layer the layer to get the name-String of.
    11031121 * @returns the Name of the Layer (on error the default-layer-string is returned)
     
    11071125  switch(layer)
    11081126  {
     1127    case E2D_LAYER_ABOVE_ALL:
     1128      return "above-all";
    11091129    case E2D_LAYER_TOP:
    11101130      return "top";
    1111       break;
    11121131    case E2D_LAYER_MEDIUM:
    11131132      return "medium";
    1114       break;
    11151133    case E2D_LAYER_BOTTOM:
    11161134      return "bottom";
    1117       break;
    11181135    case E2D_LAYER_BELOW_ALL:
    11191136      return "below-all";
    1120       break;
    11211137    default:
     1138      assert (false);
    11221139      return layer2DToChar(E2D_DEFAULT_LAYER);
    1123       break;
    1124   }
    1125 }
    1126 
    1127 /**
    1128  * converts a String holding a actual Layer
     1140  }
     1141}
     1142
     1143/**
     1144 * @brief converts a String holding a actual Layer
    11291145 * @param layer the String to convert into a Layer2D
    11301146 * @returns the E2D_LAYER on success, E2D_DEFAULT_LAYER on error.
     
    11321148E2D_LAYER Element2D::charToLayer2D(const std::string& layer)
    11331149{
    1134   if (layer =="top")
     1150  if (layer == "above-all")
     1151    return (E2D_LAYER_ABOVE_ALL);
     1152  if (layer == "top")
    11351153    return (E2D_LAYER_TOP);
    11361154  else  if (layer == "medium")
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7316 r7330  
    2424  E2D_LAYER_MEDIUM              =     2,        //!< Will be rendered on the medium Layer.
    2525  E2D_LAYER_TOP                 =     3,        //!< Will be rendered on top of everything else
    26 
    27   E2D_LAYER_COUNT               =     4,         //!< The count of Layers.
     26  E2D_LAYER_ABOVE_ALL           =     4,        //!< Will be rendered above everything else.
     27
     28  E2D_LAYER_COUNT               =     5,         //!< The count of Layers.
    2829} E2D_LAYER;
    2930#define E2D_DEFAULT_LAYER       E2D_LAYER_MEDIUM
    30 #define E2D_LAYER_ALL           4
     31#define E2D_LAYER_ALL           5
    3132
    3233typedef enum
     
    218219    static E2D_LAYER charToLayer2D(const std::string& layer);
    219220
     221    static bool layerSortPredicate(const Element2D* elem1, const Element2D* elem2);
     222
    220223  private:
    221224    void eraseChild2D(Element2D* child);
Note: See TracChangeset for help on using the changeset viewer.