ADTF Display Toolbox
Loading...
Searching...
No Matches
baseobjectmixin.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "mixin.h"
10#include "baseobjectscene.h"
11#include "baseobject.h"
12
13#include "adtfstreaming3/samplereader.h"
14
15namespace adtf
16{
17
18namespace disptb
19{
20
21namespace mixinlib
22{
23
24namespace endor
25{
26
37{
38public:
43 {
44 }
45
50 {
51 }
52
60 virtual tResult AddScene(adtf::streaming::flash::ISampleReader* pSampleReader, cBaseObjectScene* pScene)
61 {
62 auto oScene = m_oScenes.find(pSampleReader);
63 if (oScene != m_oScenes.end())
64 {
65 RETURN_ERROR_DESC(ERR_DEVICE_IN_USE, "The scene was already registered");
66 }
67 m_oScenes[pSampleReader] = pScene;
68
69 GetRoot()->addChild(pScene);
70
71 RETURN_NOERROR;
72 }
73
80 virtual tResult GetScene(adtf::streaming::flash::ISampleReader* pSampleReader, cBaseObjectScene** ppScene)
81 {
82 auto oScene = m_oScenes.find(pSampleReader);
83 if (oScene == m_oScenes.end())
84 {
85 RETURN_ERROR(ERR_NOT_FOUND);
86 }
87
88 *ppScene = oScene->second;
89 RETURN_NOERROR;
90 }
91
92public: // overrides cMixin
94 tResult ProcessInput(adtf::streaming::flash::ISampleReader* pReader,
95 const adtf::ucom::ant::iobject_ptr<const adtf::streaming::ant::ISample>& pSample) override
96 {
97 cBaseObjectScene* pScene = nullptr;
98 if (IS_OK(GetScene(pReader, &pScene)))
99 {
100 RETURN_IF_FAILED(UpdateScene(pScene, pSample));
101 }
102
103 RETURN_NOERROR;
104 }
105
106 tResult OnPick(tInt32 nPosX, tInt32 nPosY, tUInt32 nFlags, const tNodePath& sNodePath) override
107 {
108 // walk through the path until we reach a cIdSwitch
109 const cBaseObjectScene* pScene = nullptr;
110
111 for (tSize nIndex = 0; nIndex < sNodePath.nCount; ++nIndex)
112 {
113 auto pNode = sNodePath.ppNodePath[nIndex];
114 if (!pScene)
115 {
116 // remember the scene
117 pScene = dynamic_cast<const cBaseObjectScene*>(pNode);
118 }
119
120 // we do a dynamic cast the see if it is a cIdSwitch
121 auto pObj = dynamic_cast<const cBaseObject*>(pNode);
122 if (pObj)
123 {
124 // we found and object so let it handle it
125 // its ours so the const cast is ok
126 RETURN_IF_FAILED(OnObjectPick(const_cast<cBaseObjectScene*>(pScene), const_cast<cBaseObject*>(pObj),
127 nPosX, nPosY, nFlags, sNodePath));
128 break;
129 }
130 }
131
132 RETURN_NOERROR;
133 }
135
136protected:
144 virtual tResult UpdateScene(cBaseObjectScene* pScene,
145 const adtf::ucom::ant::iobject_ptr<const adtf::streaming::ant::ISample>& pSample) = 0;
146
151 virtual tResult OnObjectPick(cBaseObjectScene* /*pScene*/,
152 cBaseObject* pObj,
153 tInt /*nPosX*/,
154 tInt /*nPosY*/,
155 tUInt32 /*nFlags*/,
156 const tNodePath& /*sNodePath*/)
157 {
158 RETURN_IF_FAILED(pObj->SetSelected(!pObj->IsSelected()));
159 RETURN_NOERROR;
160 }
162
163protected:
164 std::map<adtf::streaming::ISampleReader*, osg::ref_ptr<cBaseObjectScene>> m_oScenes;
165};
166
167} // namespace endor
168
171
172} // namespace mixinlib
173
174} // namespace disptb
175
176} // namespace adtf
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Base class for objects that can be managed with cBaseObjectScene.
Definition baseobject.h:42
virtual tBool IsSelected()
Returns the selected property of the object.
Definition baseobject.h:453
virtual tResult SetSelected(tBool bSelected)
Gives the object a chance to change its appearance when being selected or unselected.
Definition baseobject.h:435
Base mixin for handling cBaseObjectScene s.
std::map< adtf::streaming::ISampleReader *, osg::ref_ptr< cBaseObjectScene > > m_oScenes
Handles searching for a corresponding cBaseObject OnObjectPick.
virtual tResult UpdateScene(cBaseObjectScene *pScene, const adtf::ucom::ant::iobject_ptr< const adtf::streaming::ant::ISample > &pSample)=0
Updates the scene with data from a new media sample.
virtual tResult AddScene(adtf::streaming::flash::ISampleReader *pSampleReader, cBaseObjectScene *pScene)
Adds a new object scene.
virtual tResult GetScene(adtf::streaming::flash::ISampleReader *pSampleReader, cBaseObjectScene **ppScene)
Returns the scene which is assigned to a specific pin.
Base class for managing a scene of objects.
virtual tResult OnPick(tInt32, tInt32, tUInt32, const tNodePath &)
Handle a left click on one of your nodes.
Definition mixin.h:333
osg::Group * GetRoot()
Add your nodes to this group.
Definition mixin.h:279
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Mixin Library.
Definition baseobject.h:26
Namespace for functionality provided by the Display Toolbox.
Main namespace.