Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4840 in orxonox.OLD


Ignore:
Timestamp:
Jul 12, 2005, 3:32:37 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more definitions for element2D

Location:
orxonox/trunk/src/lib
Files:
6 edited

Legend:

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

    r4839 r4840  
    1717
    1818#include "element_2d.h"
     19#include "render_2d.h"
    1920
    2021using namespace std;
     
    2930   this->setClassID(CL_ELEMENT_2D, "Element2D");
    3031
     32   Render2D::getInstance()->registerElement2D(this);
    3133}
    3234
     
    3739{
    3840  // delete what has to be deleted here
     41  Render2D::getInstance()->unregisterElement2D(this);
    3942}
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.h

    r4839 r4840  
    1818  E2D_BOTTOM,                          //!< Will be rendered on the bottom Layer
    1919  E2D_BELOW_ALL                        //!< Will be rendered below the 3D-scene. @todo make this work.
    20 }E2DDepth;
     20} E2DLayer;
    2121
    2222//! A class for ...
     
    2828
    2929
     30  void setPosition(int xCoord, int yCoord);
     31  void setLayer(E2DLayer layer);
     32
     33
     34  virtual void draw() const = NULL;
     35
    3036 private:
    31    bool               bDraw;
     37   bool               visible;
    3238   int                position2D[2];    //!< X-coord, Y-Coord
    33    E2DDepth           depth;
     39   E2DLayer           layer;
    3440
    3541};
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.cc

    r4839 r4840  
    1818#include "render_2d.h"
    1919
     20#include "graphics_engine.h"
     21#include "class_list.h"
     22#include "list.h"
     23#include "element_2d.h"
     24
    2025using namespace std;
    2126
     
    3035   this->setName("Render2D");
    3136
     37   this->element2DList = new tList<Element2D>();
    3238}
    3339
     
    3844
    3945/**
    40    @brief standard deconstructor
     46 * standard deconstructor
    4147 */
    4248Render2D::~Render2D ()
    4349{
     50  delete this->element2DList;
     51
    4452  Render2D::singletonRef = NULL;
    4553}
     54
     55
     56/**
     57 * registers a 2D-element to the 2D-Renderer
     58 * @param element2D the element to registers
     59 */
     60void Render2D::registerElement2D(Element2D* element2D)
     61{
     62  this->element2DList->add(element2D);
     63}
     64
     65/**
     66 * unregisters a 2D-element from the 2D-Renderer
     67 * @param element2D The element to unregister
     68 */
     69void Render2D::unregisterElement2D(Element2D* element2D)
     70{
     71  this->element2DList->remove(element2D);
     72}
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.h

    r4839 r4840  
    1010
    1111// FORWARD DEFINITION
     12template <class T> class tList;
     13class Element2D;
    1214
    1315//! A default singleton class.
     
    1517
    1618 public:
    17   virtual ~Render2D(void);
     19  virtual ~Render2D();
    1820  /** @returns a Pointer to the only object of this Class */
    19   inline static Render2D* getInstance(void) { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
     21  inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
     22
     23
     24  void draw() const;
     25
     26  void registerElement2D(Element2D* element2D);
     27  void unregisterElement2D(Element2D* element2D);
    2028
    2129 private:
    22   Render2D(void);
    23   static Render2D* singletonRef;
     30  Render2D();
     31  static Render2D*               singletonRef;           //!< Reference to this class.
     32
     33  tList<Element2D>*              element2DList;          //!< List of all valid 2D-elements.
    2434};
    2535
  • orxonox/trunk/src/lib/lang/class_list.cc

    r4836 r4840  
    107107    tmp = tmp->next;
    108108  }
     109}
     110
     111tList<BaseObject>* ClassList::getList(long classID)
     112{
     113  if(unlikely(ClassList::first == NULL))
     114    return NULL;
     115  else
     116  {
     117    ClassList* tmpCL = ClassList::first;
     118    while (likely(tmpCL != NULL))
     119    {
     120      if (unlikely(tmpCL->classID == classID))
     121        return tmpCL->objectList;
     122      tmpCL = tmpCL->next;
     123    }
     124  }
     125  return NULL;
     126
    109127}
    110128
  • orxonox/trunk/src/lib/lang/class_list.h

    r4836 r4840  
    3535
    3636    // STATIC FUNCTIONS
    37     static void         addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
    38     static void         removeFromClassList(BaseObject* objectPointer);
     37    static void               addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
     38    static void               removeFromClassList(BaseObject* objectPointer);
    3939
    40     static BaseObject*  getObject(const char* name, long classID = CL_NULL);
    41     static bool         exists(BaseObject* object, long classID = CL_NULL);
     40    static tList<BaseObject>* getList(long classID = CL_NULL);
     41    static BaseObject*        getObject(const char* name, long classID = CL_NULL);
     42    static bool               exists(BaseObject* object, long classID = CL_NULL);
    4243
    4344    static void debug(unsigned int debugLevel = 0);
Note: See TracChangeset for help on using the changeset viewer.