13#include <adtf_filtersdk.h>
14#include <adtffiltersdk/filter.h>
34class cDrawerImplementation
37 base::property_variable<tInt> m_nZOrder;
38 base::property_variable<tBool> m_bVisible;
39 base::property_variable<tFloat32> m_fTransX{0.0};
40 base::property_variable<tFloat32> m_fTransY{0.0};
41 base::property_variable<tFloat32> m_fScaleX{0.0};
42 base::property_variable<tFloat32> m_fScaleY{0.0};
43 base::property_variable<tFloat32> m_fRotate{0.0};
44 ucom::ant::object_ptr<streaming::IBindingObject> m_pBindingClient;
45 ucom::object_ptr<drawerlib::cDrawerManager> m_pDrawerManager;
48 cDrawerImplementation(): m_nZOrder(1), m_bVisible(tTrue), m_pDrawerManager(ucom::make_object_ptr<cDrawerManager>())
52 virtual ~cDrawerImplementation() =
default;
74 tResult OnDrawImpl(
dengar::IDrawer* pDrawer,
const ucom::ant::iobject_ptr<graphicslib::ICanvas>& pCanvas)
76 pCanvas->PushMatrix();
79 tResult nResult = ERR_NOERROR;
83 nResult = pDrawer->
Draw(pCanvas);
84 if (IS_FAILED(nResult))
86 LogDrawerError(nResult, pDrawer);
90 if (m_pDrawerManager->HasChildren())
92 for (
auto* pChild : m_pDrawerManager->GetOrderedDrawerList())
94 nResult = pChild->OnDraw(pCanvas);
95 if (IS_FAILED(nResult))
97 LogDrawerError(nResult, pDrawer);
102 pCanvas->PopMatrix();
107 tResult Register(dengar::IDrawer* pDrawer)
109 ucom::object_ptr<IDrawerManager> pDrawerManager =
nullptr;
110 if (IS_OK(m_pBindingClient->GetServerObject(pDrawerManager)))
112 pDrawerManager->RegisterManagedDrawer(pDrawer);
117 tVoid ClearChildren()
119 m_pDrawerManager->Clear();
122 static tVoid LogDrawerError(tResult nResult, dengar::IDrawer* pDrawer)
124 if (
auto* pFilter =
dynamic_cast<adtf::filter::cFilter*
>(pDrawer))
126 util::cString strName{};
127 pFilter->GetName(adtf_string_intf(strName));
128 LOG_ERROR(
"Error %s:%s in Drawer %s", nResult.GetErrorString(), nResult.GetDescription(), strName.GetPtr());
139 tVoid
ApplyMatrix(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& pCanvas)
141 pCanvas->Translate(m_fTransX, m_fTransY, 0.0f);
142 pCanvas->Scale(m_fScaleX, m_fScaleY, 1.0f);
143 pCanvas->Rotate(m_fRotate, 0.0f, 0.0f, 1.0f);
156 tVoid
SetMatrix(tFloat32 fTransX, tFloat32 fTransY, tFloat32 fScaleX, tFloat32 fScaleY, tFloat32 fRotate)
194 THROW_IF_FAILED(streaming::create_client<IDrawerManager>(*
this,
"drawer_manager"));
195 THROW_IF_FAILED(FindBindingObject(
"drawer_manager", m_pBindingClient));
196 THROW_IF_FAILED(streaming::create_server<IDrawerManager>(
197 *
this,
"_drawer_manager", ucom::ucom_object_ptr_cast<IDrawerManager>(m_pDrawerManager)));
211 RETURN_IF_FAILED(RegisterPropertyVariable(
"Z-Order", m_nZOrder));
212 RETURN_IF_FAILED(RegisterPropertyVariable(
"Visible", m_bVisible));
213 RETURN_IF_FAILED(RegisterPropertyVariable(
"CS/TranslateX", m_fTransX));
214 RETURN_IF_FAILED(RegisterPropertyVariable(
"CS/TranslateY", m_fTransY));
215 RETURN_IF_FAILED(RegisterPropertyVariable(
"CS/ScaleX", m_fScaleX));
216 RETURN_IF_FAILED(RegisterPropertyVariable(
"CS/ScaleY", m_fScaleY));
217 RETURN_IF_FAILED(RegisterPropertyVariable(
"CS/Rotate", m_fRotate));
243 virtual tResult
Draw(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& )
override
254 tResult
OnDraw(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& pCanvas)
override
256 return OnDrawImpl(
this, pCanvas);
261 tResult Init(tInitStage eStage)
override
263 if (eStage == tInitStage::StageGraphReady)
265 RETURN_IF_FAILED(Register(
this));
270 tResult Shutdown(tInitStage eStage)
override
272 if (eStage == tInitStage::StageGraphReady)
310 m_nZOrder.SetDescription(
"Value of the z-order.");
311 RegisterPropertyVariable(
"Z-Order", m_nZOrder);
313 m_bVisible.SetDescription(
"If enabled, drawer will be visible.");
314 RegisterPropertyVariable(
"Visible", m_bVisible);
316 m_fTransX.SetDescription(
"Value for the x-axis of the translation matrix to be multiplied with the current "
317 "matrix (note: z-value = 0.0).");
318 RegisterPropertyVariable(
"CS/TranslateX", m_fTransX);
320 m_fTransY.SetDescription(
"Value for the y-axis of the translation matrix to be multiplied with the current "
321 "matrix (note: z-value = 0.0).");
322 RegisterPropertyVariable(
"CS/TranslateY", m_fTransY);
324 m_fScaleX.SetDescription(
"Value for the uniform scale factor along the x-axis (note: z-value = 1.0).");
325 RegisterPropertyVariable(
"CS/ScaleX", m_fScaleX);
327 m_fScaleY.SetDescription(
"Value for the uniform scale factor along the y-axis (note: z-value = 1.0).");
328 RegisterPropertyVariable(
"CS/ScaleY", m_fScaleY);
330 m_fRotate.SetDescription(
"Value for the rotation angle degree around the vector x=0.0/y=0.0/z=1.0.");
331 RegisterPropertyVariable(
"CS/Rotate", m_fRotate);
333 THROW_IF_FAILED(streaming::create_client<IDrawerManager>(*
this,
"drawer_manager"));
334 SetDescription(
"drawer_manager",
"IDrawerManager interface (client).");
335 THROW_IF_FAILED(FindBindingObject(
"drawer_manager", m_pBindingClient));
336 THROW_IF_FAILED(streaming::create_server<IDrawerManager>(
337 *
this,
"_drawer_manager", ucom::ucom_object_ptr_cast<IDrawerManager>(m_pDrawerManager)));
338 SetDescription(
"_drawer_manager",
"IDrawerManager interface (server).");
368 virtual tResult
Draw(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& )
override
379 tResult
OnDraw(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& pCanvas)
override
390 virtual tResult
ContextCreated(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& )
override
402 tResult
OnCreateContext(
const ucom::ant::iobject_ptr<graphicslib::dengar::ICanvas>& pCanvas)
final override
404 tResult nResult = ERR_NOERROR;
406 if (IS_FAILED(nResult))
408 LogDrawerError(nResult,
this);
413 if (m_pDrawerManager->HasChildren())
415 for (
auto* pChild : m_pDrawerManager->GetOrderedDrawerList())
419 nResult = pNewChild->OnCreateContext(pCanvas);
420 if (IS_FAILED(nResult))
422 LogDrawerError(nResult,
this);
449 tResult nResult = ERR_NOERROR;
451 if (IS_FAILED(nResult))
453 LogDrawerError(nResult,
this);
456 if (m_pDrawerManager->HasChildren())
458 for (
auto* pChild : m_pDrawerManager->GetOrderedDrawerList())
462 nResult = pNewChild->OnDestroyContext();
463 if (IS_FAILED(nResult))
465 LogDrawerError(nResult,
this);
476 tResult Init(tInitStage eStage)
override
478 if (eStage == tInitStage::StageGraphReady)
485 tResult Shutdown(tInitStage eStage)
override
487 if (eStage == tInitStage::StageGraphReady)
ADTF 2D Display Drawer interface.
virtual tResult Draw(const ucom::ant::iobject_ptr< disptb::graphicslib::dengar::ICanvas > &pCanvas)=0
This method is where the user code defines what is drawn on the canvas.
tInt GetZOrder() const override
The ZOrder defines the order of drawing the objects, if there are in the same coordinate space level.
virtual ~cDrawer()=default
Destructor.
tResult RegisterProperties()
Registers all defined property variables.
virtual tResult Draw(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &) override
This method is where the user code defines what is drawn on the canvas.
tResult OnDraw(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &pCanvas) override
This method is called from the drawer manager to draw on the give canvas.
tBool IsVisible() const override
tInt GetZOrderImpl() const
The ZOrder defines the order of drawing the objects, if there are in the same coordinate space level.
tBool IsVisibleImpl() const
IsVisible() is not the same as IsActive()!
tVoid ApplyMatrix(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &pCanvas)
This method is called before Drawing.
tVoid SetMatrix(tFloat32 fTransX, tFloat32 fTransY, tFloat32 fScaleX, tFloat32 fScaleY, tFloat32 fRotate)
SetMatrix sets all parameter for the matrix to use in ApplyMatrix() Draw() don't need them because th...
ADTF 2D Display Drawer interface.
tInt GetZOrder() const override
The ZOrder defines the order of drawing the objects, if there are in the same coordinate space level.
virtual ~cDrawer()=default
Destructor.
virtual tResult Draw(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &) override
This method is where the user code defines what is drawn on the canvas.
virtual tResult ContextCreated(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &) override
This method can be overwritten to define the desired behavior during the OnCreateContext event.
virtual tResult ContextDestroyed() override
This method can be overwritten to define the desired behavior during the OnDestroyContext event.
tResult OnCreateContext(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &pCanvas) final override
This oneshot method is called once when the transition from runlevel 4 to runlevel 5 occurs The use o...
tResult OnDraw(const ucom::ant::iobject_ptr< graphicslib::dengar::ICanvas > &pCanvas) override
This method is called from the drawer manager to draw on the give canvas.
tBool IsVisible() const override
tResult OnDestroyContext() final
This oneshot method is called once when the transition from runlevel 5 to runlevel 4 occurs The use o...
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Display Toolbox.