Commit e4c3416f authored by Anatoly Baksheev's avatar Anatoly Baksheev

experimental widget casting functionality

parent 509a93c7
......@@ -15,6 +15,8 @@ namespace temp_viz
Widget& operator =(const Widget &other);
~Widget();
template<typename _W> _W cast();
private:
class Impl;
Impl *impl_;
......@@ -56,13 +58,10 @@ namespace temp_viz
void setColor(const Color &color);
};
class CV_EXPORTS LineWidget : public Widget3D
{
public:
LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
LineWidget(const Widget &other) : Widget3D(other) {}
LineWidget& operator=(const Widget &other);
void setLineWidth(float line_width);
float getLineWidth();
......@@ -158,4 +157,10 @@ namespace temp_viz
private:
struct ApplyCloudNormals;
};
template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>();
template<> CV_EXPORTS LineWidget Widget::cast<LineWidget>();
}
......@@ -24,12 +24,6 @@ temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const C
setColor(color);
}
temp_viz::LineWidget& temp_viz::LineWidget::operator=(const Widget &other)
{
Widget3D::operator=(other);
return *this;
}
void temp_viz::LineWidget::setLineWidth(float line_width)
{
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
......@@ -44,6 +38,12 @@ float temp_viz::LineWidget::getLineWidth()
return actor->GetProperty()->GetLineWidth();
}
template<> temp_viz::LineWidget temp_viz::Widget::cast<temp_viz::LineWidget>()
{
Widget3D widget = this->cast<Widget3D>();
return static_cast<LineWidget&>(widget);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// plane widget implementation
......
......@@ -165,6 +165,16 @@ void temp_viz::Widget3D::setColor(const Color &color)
actor->Modified ();
}
template<> temp_viz::Widget3D temp_viz::Widget::cast<temp_viz::Widget3D>()
{
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
Widget3D widget;
WidgetAccessor::setProp(widget, actor);
return widget;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget2D implementation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment