OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
object.hpp
Go to the documentation of this file.
1 #ifndef OPENCS_VIEW_OBJECT_H
2 #define OPENCS_VIEW_OBJECT_H
3 
4 #include <string>
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include <osg/ref_ptr>
9 #include <osg/Referenced>
10 
11 #include <components/esm/defs.hpp>
12 
13 #include "tagbase.hpp"
14 
15 class QModelIndex;
16 class QUndoStack;
17 
18 namespace osg
19 {
20  class PositionAttitudeTransform;
21  class Group;
22  class Node;
23  class Geode;
24 }
25 
26 namespace osgFX
27 {
28  class Scribe;
29 }
30 
31 namespace Resource
32 {
33  class ResourceSystem;
34 }
35 
36 namespace CSMWorld
37 {
38  class Data;
39  struct CellRef;
40  class CommandMacro;
41 }
42 
43 namespace CSVRender
44 {
45  class Object;
46 
47  // An object to attach as user data to the osg::Node, allows us to get an Object back from a Node when we are doing a ray query
48  class ObjectTag : public TagBase
49  {
50  public:
51 
52  ObjectTag (Object* object);
53 
55 
56  virtual QString getToolTip (bool hideBasics) const;
57  };
58 
59  class ObjectMarkerTag : public ObjectTag
60  {
61  public:
62 
63  ObjectMarkerTag (Object* object, int axis);
64 
65  int mAxis;
66  };
67 
68  class Object
69  {
70  public:
71 
73  {
77  };
78 
79  private:
80 
81  static const float MarkerShaftWidth;
82  static const float MarkerShaftBaseLength;
83  static const float MarkerHeadWidth;
84  static const float MarkerHeadLength;
85 
87  std::string mReferenceId;
88  std::string mReferenceableId;
89  osg::ref_ptr<osg::PositionAttitudeTransform> mRootNode;
90  osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
91  osg::ref_ptr<osgFX::Scribe> mOutline;
92  bool mSelected;
93  osg::Group* mParentNode;
99  osg::ref_ptr<osg::Node> mMarker[3];
100  int mSubMode;
101 
103  Object (const Object&);
104 
106  Object& operator= (const Object&);
107 
109  void clear();
110 
113  void update();
114 
116  void adjustTransform();
117 
119  const CSMWorld::CellRef& getReference() const;
120 
121  void updateMarker();
122 
123  osg::ref_ptr<osg::Node> makeMoveOrScaleMarker (int axis);
124  osg::ref_ptr<osg::Node> makeRotateMarker (int axis);
125 
126  osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
127 
128  public:
129 
130  Object (CSMWorld::Data& data, osg::Group *cellNode,
131  const std::string& id, bool referenceable,
132  bool forceBaseToZero = false);
135 
136  ~Object();
137 
139  void setSelected(bool selected);
140 
141  bool getSelected() const;
142 
145  bool referenceableDataChanged (const QModelIndex& topLeft,
146  const QModelIndex& bottomRight);
147 
150  bool referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end);
151 
154  bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
155 
157  std::string getReferenceId() const;
158 
159  std::string getReferenceableId() const;
160 
161  osg::ref_ptr<TagBase> getTag() const;
162 
164  bool isEdited() const;
165 
166  void setEdited (int flags);
167 
168  ESM::Position getPosition() const;
169 
170  float getScale() const;
171 
173  void setPosition (const float position[3]);
174 
176  void setRotation (const float rotation[3]);
177 
179  void setScale (float scale);
180 
182  void apply (CSMWorld::CommandMacro& commands);
183 
184  void setSubMode (int subMode);
185 
188  void reset();
189  };
190 }
191 
192 #endif
bool getSelected() const
Definition: object.cpp:459
int mOverrideFlags
Definition: object.hpp:98
~Object()
Definition: object.cpp:434
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
Definition: object.hpp:59
Definition: object.hpp:74
bool referenceableAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: object.cpp:482
Object(const Object &)
Not implemented.
osg::ref_ptr< osg::Node > makeMoveOrScaleMarker(int axis)
Definition: object.cpp:212
bool referenceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: object.cpp:503
ObjectTag(Object *object)
Definition: object.cpp:56
void setSelected(bool selected)
Mark the object as selected, selected objects show an outline effect.
Definition: object.cpp:441
Definition: object.hpp:75
std::string getReferenceableId() const
Definition: object.cpp:540
Definition: object.hpp:68
Definition: object.hpp:76
static const float MarkerShaftBaseLength
Definition: object.hpp:82
void updateMarker()
Definition: object.cpp:175
std::string mReferenceId
Definition: object.hpp:87
static const float MarkerHeadWidth
Definition: object.hpp:83
static const float MarkerShaftWidth
Definition: object.hpp:81
ESM::Position getPosition() const
Definition: object.cpp:577
osg::ref_ptr< osg::PositionAttitudeTransform > mBaseNode
Definition: object.hpp:90
int mAxis
Definition: object.hpp:65
static const float MarkerHeadLength
Definition: object.hpp:84
Resource::ResourceSystem * mResourceSystem
Definition: object.hpp:94
OverrideFlags
Definition: object.hpp:72
void clear()
Remove object from node (includes deleting)
Definition: object.cpp:71
Object & operator=(const Object &)
Not implemented.
bool referenceableDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: object.cpp:464
osg::Group * mParentNode
Definition: object.hpp:93
void setScale(float scale)
Set override scale.
Definition: object.cpp:617
void setEdited(int flags)
Definition: object.cpp:555
float getScale() const
Definition: object.cpp:592
std::string mReferenceableId
Definition: object.hpp:88
osg::Vec3f getMarkerPosition(float x, float y, float z, int axis)
Definition: object.cpp:385
void adjustTransform()
Adjust position, orientation and scale.
Definition: object.cpp:146
void apply(CSMWorld::CommandMacro &commands)
Apply override changes via command and end edit mode.
Definition: object.cpp:626
bool mSelected
Definition: object.hpp:92
Definition: commandmacro.hpp:11
Definition: data.hpp:77
ESM::Position mPositionOverride
Definition: object.hpp:96
Definition: tagbase.hpp:12
Wrapper for CellRef sub record.
Definition: ref.hpp:11
Definition: defs.hpp:38
Definition: object.hpp:48
bool isEdited() const
Is there currently an editing operation running on this object?
Definition: object.cpp:550
CSMWorld::Data & mData
Definition: object.hpp:86
void update()
Definition: object.cpp:75
virtual QString getToolTip(bool hideBasics) const
Definition: object.cpp:60
ObjectMarkerTag(Object *object, int axis)
Definition: object.cpp:66
osg::ref_ptr< osg::PositionAttitudeTransform > mRootNode
Definition: object.hpp:89
osg::ref_ptr< TagBase > getTag() const
Definition: object.cpp:545
float mScaleOverride
Definition: object.hpp:97
int mSubMode
Definition: object.hpp:100
Object * mObject
Definition: object.hpp:54
void setSubMode(int subMode)
Definition: object.cpp:682
void reset()
Definition: object.cpp:691
void setPosition(const float position[3])
Set override position.
Definition: object.cpp:597
osg::ref_ptr< osgFX::Scribe > mOutline
Definition: object.hpp:91
std::string getReferenceId() const
Returns an empty string if this is a refereceable-type object.
Definition: object.cpp:535
osg::ref_ptr< osg::Node > mMarker[3]
Definition: object.hpp:99
bool mForceBaseToZero
Definition: object.hpp:95
const CSMWorld::CellRef & getReference() const
Throws an exception if *this was constructed with referenceable.
Definition: object.cpp:167
void setRotation(const float rotation[3])
Set override rotation.
Definition: object.cpp:607
osg::ref_ptr< osg::Node > makeRotateMarker(int axis)
Definition: object.cpp:304