vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConnectionViz.h
Go to the documentation of this file.
1 #ifndef CONNECTIONVIZ_H
2 #define CONNECTIONVIZ_H
3 
4 #include <vrecko/Ability.h>
5 #include <osg/Group>
6 #include <osg/ShapeDrawable>
7 #include <helpers/DynamicArray.h>
8 
9 using namespace vrecko;
10 
11 namespace APObjectUtils
12 {
13  // Flags for ConnectionViz::Connection::dwFlags and ConnectionViz::createConnection() method
14  #define CVC_F_DEFAULT 0x00000001
15  // Signalizes a default connection
16 
17 
18  class ConnectionViz: public Ability {
19  public:
20  ConnectionViz();
21  virtual ~ConnectionViz();
22 
23  virtual void preInitialize();
24  virtual void postInitialize();
25  virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pParametersNode);
26  virtual void update();
27  virtual void clean();
28 
29  protected:
31 
32  bool bOnlyOutput; // show only output connetions
33  bool bColorize; // use nice(?) colors to display the connections
34 
35  class Connection {
36  public:
38 
39  enum ConnectionType { Input, Output, InputRequest, OutputRequest };
41 
42  unsigned long dwFlags; // a combination of CVC_F_*
43 
44  std::string pinName; // name of the output/input/request pin
45 
46  bool bUsedInUpdate; // auxiliary variable used when updating
47 
48  osg::ref_ptr<osg::Cone> shapeCone;
49  osg::ref_ptr<osg::ShapeDrawable> shapeDraw;
50  };
51 
52  osg::ref_ptr<EnvironmentObject> graphicObject;
53  osg::ref_ptr<osg::Geode> osgGeode;
54 
56  /* Creates the specified connection and returns its index (to the [cons] array).
57  It will return -1 in the case of an error.
58  May reuese some of the unused connection, which has [bUsedInUpdate] set to false.
59  The [bUsedInUpdate] will be set to true in this method for the returned connection.
60  [dwFlags] is a combination of CVC_F_* */
61  int createConnection(Connection::ConnectionType cType, const char *sender, const char *receiver, unsigned int dwFlags);
62  void deleteConnection(int iIndex);
63 
64  /* Creates the main objects if not created before. */
65  bool createMainObject();
66  };
67 
68 }
69 
70 
71 #endif