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 <memory>
5 #include <string>
6 
7 #include <osg/ref_ptr>
8 #include <osg/Geometry>
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 Actor;
46  class Object;
47 
48  // 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
49  class ObjectTag : public TagBase
50  {
51  public:
52 
53  ObjectTag (Object* object);
54 
56 
57  virtual QString getToolTip (bool hideBasics) const;
58  };
59 
60  class ObjectMarkerTag : public ObjectTag
61  {
62  public:
63 
64  ObjectMarkerTag (Object* object, int axis);
65 
66  int mAxis;
67  };
68 
69  class Object
70  {
71  public:
72 
74  {
78  };
79 
80  private:
81 
82  static const float MarkerShaftWidth;
83  static const float MarkerShaftBaseLength;
84  static const float MarkerHeadWidth;
85  static const float MarkerHeadLength;
86 
88  std::string mReferenceId;
89  std::string mReferenceableId;
90  osg::ref_ptr<osg::PositionAttitudeTransform> mRootNode;
91  osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
92  osg::ref_ptr<osgFX::Scribe> mOutline;
93  bool mSelected;
94  osg::Group* mParentNode;
100  osg::ref_ptr<osg::Node> mMarker[3];
101  int mSubMode;
103  std::unique_ptr<Actor> mActor;
104 
106  Object (const Object&);
107 
109  Object& operator= (const Object&);
110 
112  void clear();
113 
116  void update();
117 
119  void adjustTransform();
120 
122  const CSMWorld::CellRef& getReference() const;
123 
124  void updateMarker();
125 
126  osg::ref_ptr<osg::Node> makeMoveOrScaleMarker (int axis);
127  osg::ref_ptr<osg::Node> makeRotateMarker (int axis);
128 
130  void setupCommonMarkerState(osg::ref_ptr<osg::Geometry> geometry);
131 
132  osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
133 
134  public:
135 
136  Object (CSMWorld::Data& data, osg::Group *cellNode,
137  const std::string& id, bool referenceable,
138  bool forceBaseToZero = false);
141 
142  ~Object();
143 
145  void setSelected(bool selected);
146 
147  bool getSelected() const;
148 
151  bool referenceableDataChanged (const QModelIndex& topLeft,
152  const QModelIndex& bottomRight);
153 
156  bool referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end);
157 
160  bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
161 
163  void reloadAssets();
164 
166  std::string getReferenceId() const;
167 
168  std::string getReferenceableId() const;
169 
170  osg::ref_ptr<TagBase> getTag() const;
171 
173  bool isEdited() const;
174 
175  void setEdited (int flags);
176 
177  ESM::Position getPosition() const;
178 
179  float getScale() const;
180 
182  void setPosition (const float position[3]);
183 
185  void setRotation (const float rotation[3]);
186 
188  void setScale (float scale);
189 
190  void setMarkerTransparency(float value);
191 
193  void apply (CSMWorld::CommandMacro& commands);
194 
195  void setSubMode (int subMode);
196 
199  void reset();
200  };
201 }
202 
203 #endif
bool getSelected() const
Definition: object.cpp:485
int mOverrideFlags
Definition: object.hpp:99
~Object()
Definition: object.cpp:459
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:30
Definition: object.hpp:60
Definition: object.hpp:75
bool referenceableAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Definition: object.cpp:508
Object(const Object &)
Not implemented.
osg::ref_ptr< osg::Node > makeMoveOrScaleMarker(int axis)
Definition: object.cpp:223
bool referenceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: object.cpp:529
ObjectTag(Object *object)
Definition: object.cpp:61
void setSelected(bool selected)
Mark the object as selected, selected objects show an outline effect.
Definition: object.cpp:466
Definition: object.hpp:76
std::unique_ptr< Actor > mActor
Definition: object.hpp:103
std::string getReferenceableId() const
Definition: object.cpp:572
Definition: object.hpp:69
Definition: object.hpp:77
static const float MarkerShaftBaseLength
Definition: object.hpp:83
void updateMarker()
Definition: object.cpp:186
std::string mReferenceId
Definition: object.hpp:88
static const float MarkerHeadWidth
Definition: object.hpp:84
static const float MarkerShaftWidth
Definition: object.hpp:82
ESM::Position getPosition() const
Definition: object.cpp:609
osg::ref_ptr< osg::PositionAttitudeTransform > mBaseNode
Definition: object.hpp:91
int mAxis
Definition: object.hpp:66
static const float MarkerHeadLength
Definition: object.hpp:85
float mMarkerTransparency
Definition: object.hpp:102
Resource::ResourceSystem * mResourceSystem
Definition: object.hpp:95
OverrideFlags
Definition: object.hpp:73
void clear()
Remove object from node (includes deleting)
Definition: object.cpp:76
Object & operator=(const Object &)
Not implemented.
bool referenceableDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: object.cpp:490
osg::Group * mParentNode
Definition: object.hpp:94
void setScale(float scale)
Set override scale.
Definition: object.cpp:649
void setEdited(int flags)
Definition: object.cpp:587
float getScale() const
Definition: object.cpp:624
std::string mReferenceableId
Definition: object.hpp:89
osg::Vec3f getMarkerPosition(float x, float y, float z, int axis)
Definition: object.cpp:410
void adjustTransform()
Adjust position, orientation and scale.
Definition: object.cpp:157
void apply(CSMWorld::CommandMacro &commands)
Apply override changes via command and end edit mode.
Definition: object.cpp:664
bool mSelected
Definition: object.hpp:93
Definition: commandmacro.hpp:11
void setupCommonMarkerState(osg::ref_ptr< osg::Geometry > geometry)
Sets up a stateset with properties common to all marker types.
Definition: object.cpp:401
Definition: data.hpp:80
ESM::Position mPositionOverride
Definition: object.hpp:97
Definition: tagbase.hpp:12
Wrapper for CellRef sub record.
Definition: ref.hpp:11
Definition: defs.hpp:38
Definition: object.hpp:49
bool isEdited() const
Is there currently an editing operation running on this object?
Definition: object.cpp:582
CSMWorld::Data & mData
Definition: object.hpp:87
void update()
Definition: object.cpp:80
virtual QString getToolTip(bool hideBasics) const
Definition: object.cpp:65
ObjectMarkerTag(Object *object, int axis)
Definition: object.cpp:71
osg::ref_ptr< osg::PositionAttitudeTransform > mRootNode
Definition: object.hpp:90
osg::ref_ptr< TagBase > getTag() const
Definition: object.cpp:577
float mScaleOverride
Definition: object.hpp:98
int mSubMode
Definition: object.hpp:101
Object * mObject
Definition: object.hpp:55
void reloadAssets()
Reloads the underlying asset.
Definition: object.cpp:561
void setSubMode(int subMode)
Definition: object.cpp:720
void setMarkerTransparency(float value)
Definition: object.cpp:658
void reset()
Definition: object.cpp:729
void setPosition(const float position[3])
Set override position.
Definition: object.cpp:629
osg::ref_ptr< osgFX::Scribe > mOutline
Definition: object.hpp:92
std::string getReferenceId() const
Returns an empty string if this is a refereceable-type object.
Definition: object.cpp:567
osg::ref_ptr< osg::Node > mMarker[3]
Definition: object.hpp:100
bool mForceBaseToZero
Definition: object.hpp:96
const CSMWorld::CellRef & getReference() const
Throws an exception if *this was constructed with referenceable.
Definition: object.cpp:178
void setRotation(const float rotation[3])
Set override rotation.
Definition: object.cpp:639
osg::ref_ptr< osg::Node > makeRotateMarker(int axis)
Definition: object.cpp:315