15#include <adtf_filtersdk.h>
18#include <adtf_ucom3.h>
19#include <adtf_streaming3.h>
90 virtual tVoid
SetScale(
const osg::Vec3d& oScale) = 0;
105 cChildCoordinateSystem(
const tChar* strName,
106 filter::interface_client<ISceneGraph> pSceneGraph,
108 m_strName(strName), m_pSceneGraph(pSceneGraph), m_pRoot(
new osg::Group), m_pPickHandler(pHandler)
121 if (m_pCoordinateSystem)
123 m_pCoordinateSystem->SetPosition(oPos);
130 if (m_pCoordinateSystem)
132 m_pCoordinateSystem->SetAttitude(oQuat);
139 if (m_pCoordinateSystem)
141 m_pCoordinateSystem->SetScale(oScale);
146 m_oPivotPoint = oPivot;
148 if (m_pCoordinateSystem)
150 m_pCoordinateSystem->SetPivotPoint(oPivot);
154 ucom::object_ptr<ICoordinateSystem> GetCoordinateSystem()
157 return m_pCoordinateSystem;
162 if (!m_pCoordinateSystem)
164 ucom::object_ptr<ICoordinateSystem> pParent;
165 THROW_IF_FAILED(m_pSceneGraph->GetObject(pParent));
166 THROW_IF_FAILED(pParent->CreateChild(m_strName.c_str(), m_pCoordinateSystem));
167 m_pCoordinateSystem->SetPosition(m_oPos);
168 m_pCoordinateSystem->SetAttitude(m_oAttitude);
169 m_pCoordinateSystem->SetScale(m_oScale);
170 m_pCoordinateSystem->SetPivotPoint(m_oPivotPoint);
171 m_pCoordinateSystem->AddNode(m_pRoot, m_pPickHandler);
176 std::string m_strName;
177 filter::interface_client<ISceneGraph> m_pSceneGraph;
178 osg::ref_ptr<osg::Group> m_pRoot;
179 ucom::object_ptr<ICoordinateSystem> m_pCoordinateSystem;
180 INodeHandler* m_pPickHandler;
183 osg::Quat m_oAttitude;
184 osg::Vec3d m_oScale = {1.0, 1.0, 1.0};
185 osg::Vec3d m_oPivotPoint;
188class cSceneGraphProxy :
public ucom::object<ISceneGraph>
191 cSceneGraphProxy(
const tChar* strName, filter::interface_client<ISceneGraph> pSceneGraph,
INodeHandler* pHandler):
192 m_pSceneGraph(pSceneGraph), m_oChildCoordinateSystem(strName, pSceneGraph, pHandler)
196 tResult GetObject(ucom::ant::iobject_ptr<ucom::ant::IObject>& pObject,
const tChar* strObjectName =
"")
198 std::string strNameHelper = strObjectName ? strObjectName :
"";
200 if (strNameHelper.empty() ||
201 strNameHelper == adtf::disptb::mixinlib::endor::tSceneGraphObjectNames::CoordinateSystem)
203 if (IS_OK(pObject.Reset(m_oChildCoordinateSystem.GetCoordinateSystem())))
209 return m_pSceneGraph->GetObject(pObject, strObjectName);
214 return &m_oChildCoordinateSystem;
218 filter::interface_client<ISceneGraph> m_pSceneGraph;
238 public ucom::catwo::object<filter::cFilter, INodeHandler, IMenuEventSink>,
239 public ucom::ant::enable_object_ptr_from_this<cMixin>
247 m_pSceneGraph = CreateInterfaceClient<ISceneGraph>(
"scene_graph");
248 SetDescription(
"scene_graph",
"ISceneGraph interface for use with Openscenegraph 3.5.6");
269 auto pSceneGraph = ucom::make_object_ptr<detail::cSceneGraphProxy>(strName, m_pSceneGraph,
this);
270 CreateInterfaceServer<ISceneGraph>(strName, ucom::ucom_object_ptr_cast<ISceneGraph>(pSceneGraph));
271 m_oCoordinateSystemSceneGraphProxys.push_back(pSceneGraph);
272 return pSceneGraph->GetCoordinateSystem();
283 osg::ref_ptr<osg::Switch> pRootNode =
new osg::Switch;
284 ucom::object_ptr<ICoordinateSystem> pCoordinateSystem;
285 THROW_IF_FAILED(
GetSceneGraph().GetObject(pCoordinateSystem));
286 THROW_IF_FAILED(pCoordinateSystem->AddNode(pRootNode,
this));
287 m_pRootNode = pRootNode;
299 return m_pSceneGraph.Get();
313 tResult HandleMenuEvent(
const tChar* , tVoid* )
override
369 tResult Init(tInitStage eStage)
override
371 RETURN_IF_FAILED(cFilter::Init(eStage));
373 if (eStage == tInitStage::StageGraphReady)
376 m_pViewer->MakeCurrent();
377 CreateCoordinateSystems();
384 tResult Shutdown(tInitStage eStage)
override
386 if (eStage == tInitStage::StageGraphReady)
390 return cFilter::Shutdown(eStage);
393 tResult GetName(base::ant::IString&& strName)
const override
395 return cFilter::GetName(std::move(strName));
399 OnPick(tInt32 nPosX, tInt32 nPosY, tUInt32 nFlags,
const tNodePath& sNodePath, chewbacca::IMenu& oMenu)
override
401 if (sNodePath.nCount == 0)
407 if (nFlags & INodeHandler::CM_RIGHT_MB)
410 m_oLastPick.insert(m_oLastPick.end(), sNodePath.ppNodePath, sNodePath.ppNodePath + sNodePath.nCount);
415 RETURN_IF_FAILED(
OnPick(nPosX, nPosY, nFlags, sNodePath));
421 tResult Process(base::flash::tNanoSeconds tmTrigger, streaming::ant::IRunner* pRunner)
override
424 auto oResult = cFilter::Process(tmTrigger, pRunner);
429 tResult ProcessInput(base::flash::tNanoSeconds tmTrigger, streaming::flash::ISampleReader* pReader)
override
432 auto oResult = cFilter::ProcessInput(tmTrigger, pReader);
456 tVoid CreateCoordinateSystems()
458 for (
auto& pProxy : m_oCoordinateSystemSceneGraphProxys)
460 pProxy->GetCoordinateSystem()->Create();
464 osg::ref_ptr<osg::Switch> m_pRootNode;
465 filter::interface_client<ISceneGraph> m_pSceneGraph;
466 std::vector<ucom::object_ptr<detail::cSceneGraphProxy>> m_oCoordinateSystemSceneGraphProxys;
468 ucom::object_ptr<IViewer> m_pViewer;
469 std::vector<const osg::Node*> m_oLastPick;
475using endor::IChildCoordinateSystem;
Interface for accessing and manipulating a coordinate system created with cMixin::CreateCoordinateSys...
virtual tVoid SetAttitude(const osg::Quat &oQuat)=0
Set the attitude of the coordinate system.
virtual tVoid SetPosition(const osg::Vec3d &oPos)=0
Set the position of the coordinate system.
virtual tVoid SetScale(const osg::Vec3d &oScale)=0
Set the scale of the coordinate system.
~IChildCoordinateSystem()=default
not destructable
virtual osg::Group * GetRoot()=0
Use this to add nodes within the coordinate system.
virtual tVoid SetPivotPoint(const osg::Vec3d &oPivot)=0
Set the pivot point of the coordinate system.
Interface for a handler that is responsible for a node and all its children.
Interface for the scene graph of a 3D Scene Display.
virtual tResult AddMenuItemForPick(chewbacca::IMenu &, const tNodePath &)
Return context menu entries for one of your nodes.
ISceneGraph & GetSceneGraph()
Access the ISceneGraph interface.
virtual tResult OnPick(tInt32, tInt32, tUInt32, const tNodePath &)
Handle a left click on one of your nodes.
virtual tResult InitScene()
Impelement this to add your graph elements.
IChildCoordinateSystem * CreateCoordinateSystem(const tChar *strName)
Creates a new coordinate system.
virtual tVoid ClearScene()
Use this to clean up your graph elements.
osgText::Font * GetFont()
Returns a pointer to a valid Font, use this for your osgText nodes.
~cMixin() override
Destructor.
virtual tResult AddGlobalMenuItem(chewbacca::IMenu &)
Add global menu entries not related to a specific one of your nodes.
std::vector< const osg::Node * > GetLastMenuPath()
osg::Group * GetRoot()
Add your nodes to this group.
tVoid SetPivotPoint(const osg::Vec3d &oPivot) override
Set the pivot point of the coordinate system.
tVoid SetScale(const osg::Vec3d &oScale) override
Set the scale of the coordinate system.
osg::Group * GetRoot() override
Use this to add nodes within the coordinate system.
tVoid SetAttitude(const osg::Quat &oQuat) override
Set the attitude of the coordinate system.
tVoid SetPosition(const osg::Vec3d &oPos) override
Set the position of the coordinate system.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Mixin Library.
Namespace for functionality provided by the Display Toolbox.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.