cherish
SelectedGroup.h
1 #ifndef SELECTEDGROUP_H
2 #define SELECTEDGROUP_H
3 
4 #include <vector>
5 #include <osg/Geode>
6 #include <osg/BoundingBox>
7 #include "Entity2D.h"
8 
9 namespace entity {
10 
15 {
16 public:
17  SelectedGroup(const osg::Vec3f& canvasCenter = cher::CENTER);
18 
19  void addEntity(entity::Entity2D* entity, osg::Geode* geodeData);
20  bool removeEntity(entity::Entity2D* entity);
21  void resetAll();
22  void selectAll(osg::Geode* geodeData);
23  const std::vector<Entity2D *> &getEntities() const;
24  entity::Entity2D* getEntity(int i) const;
25  int getSize() const;
26  bool isEmpty() const;
27  osg::Vec3f getCenter3D(const osg::Matrix& M) const;
28  osg::Vec3f getCenter2D() const;
29  osg::Vec3f getCenter3DCustom(const osg::Matrix& M) const;
30  void setCenter3DCustom(const osg::Vec3f& center, const osg::Matrix& M);
31  osg::Vec3f getCenter2DCustom() const;
32  void setCenter2DCustom(const osg::Vec3f& center);
33  osg::BoundingBox getBoundingBox() const;
34  double getRotationAngle() const;
35 
36  void move(double du, double dv);
37  void move(std::vector<Entity2D *> &entities, double du, double dv);
38  void scale(double sx, double sy);
39  void scale(std::vector<Entity2D *> &entities, double sx, double sy, const osg::Vec3f& center);
40  void rotate(double theta);
41  void rotate(std::vector<Entity2D *> &entities, double theta, const osg::Vec3f& center);
42 
43 protected:
44  int isEntitySelected(entity::Entity2D* entity) const;
45  void setEntitySelectedColor(entity::Entity2D* entity, bool selected = true);
46 
47  std::vector<entity::Entity2D*> m_group;
48 
49  osg::Vec3f m_center; /* local center for rotation and scaling */
50  float m_theta; /* whether axis was rotated */
51  bool m_centerEdited; /* whether center was edited by user or not */
52 
53 }; // class SelectedGroup
54 
55 } // namespace entity
56 
57 
58 #endif // SELECTEDGROUP_H
Scene graph entities.
Definition: AddEntityCommand.h:17
Definition: Entity2D.h:13
Definition: SelectedGroup.h:14