mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
explicit casting among widgets, removed implicit casting
This commit is contained in:
parent
e4c3416f58
commit
d3dee3a2fe
@ -32,8 +32,6 @@ namespace temp_viz
|
||||
{
|
||||
public:
|
||||
Widget3D() {}
|
||||
Widget3D(const Widget& other);
|
||||
Widget3D& operator =(const Widget &other);
|
||||
|
||||
void setPose(const Affine3f &pose);
|
||||
void updatePose(const Affine3f &pose);
|
||||
@ -52,8 +50,6 @@ namespace temp_viz
|
||||
{
|
||||
public:
|
||||
Widget2D() {}
|
||||
Widget2D(const Widget &other);
|
||||
Widget2D& operator=(const Widget &other);
|
||||
|
||||
void setColor(const Color &color);
|
||||
};
|
||||
@ -72,64 +68,48 @@ namespace temp_viz
|
||||
public:
|
||||
PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white());
|
||||
PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size = 1.0, const Color &color = Color::white());
|
||||
PlaneWidget(const Widget& other) : Widget3D(other) {}
|
||||
PlaneWidget& operator=(const Widget& other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS SphereWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white());
|
||||
SphereWidget(const Widget &other) : Widget3D(other) {}
|
||||
SphereWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ArrowWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color = Color::white());
|
||||
ArrowWidget(const Widget &other) : Widget3D(other) {}
|
||||
ArrowWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS CircleWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
||||
CircleWidget(const Widget& other) : Widget3D(other) {}
|
||||
CircleWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS CylinderWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
|
||||
CylinderWidget(const Widget& other) : Widget3D(other) {}
|
||||
CylinderWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS CubeWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
||||
CubeWidget(const Widget& other) : Widget3D(other) {}
|
||||
CubeWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS CoordinateSystemWidget : public Widget3D
|
||||
{
|
||||
public:
|
||||
CoordinateSystemWidget(double scale, const Affine3f& affine);
|
||||
CoordinateSystemWidget(const Widget &other) : Widget3D(other) {}
|
||||
CoordinateSystemWidget& operator=(const Widget &other);
|
||||
};
|
||||
|
||||
class CV_EXPORTS TextWidget : public Widget2D
|
||||
{
|
||||
public:
|
||||
TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white());
|
||||
TextWidget(const Widget& other) : Widget2D(other) {}
|
||||
TextWidget& operator=(const Widget &other);
|
||||
|
||||
void setText(const String &text);
|
||||
String getText() const;
|
||||
@ -140,8 +120,6 @@ namespace temp_viz
|
||||
public:
|
||||
CloudWidget(InputArray _cloud, InputArray _colors);
|
||||
CloudWidget(InputArray _cloud, const Color &color = Color::white());
|
||||
CloudWidget(const Widget &other) : Widget3D(other) {}
|
||||
CloudWidget& operator=(const Widget &other);
|
||||
|
||||
private:
|
||||
struct CreateCloudWidget;
|
||||
@ -151,15 +129,24 @@ namespace temp_viz
|
||||
{
|
||||
public:
|
||||
CloudNormalsWidget(InputArray _cloud, InputArray _normals, int level = 100, float scale = 0.02f, const Color &color = Color::white());
|
||||
CloudNormalsWidget(const Widget &other) : Widget3D(other) {}
|
||||
CloudNormalsWidget& operator=(const Widget &other);
|
||||
|
||||
private:
|
||||
struct ApplyCloudNormals;
|
||||
};
|
||||
|
||||
template<> CV_EXPORTS Widget2D Widget::cast<Widget2D>();
|
||||
template<> CV_EXPORTS Widget3D Widget::cast<Widget3D>();
|
||||
template<> CV_EXPORTS LineWidget Widget::cast<LineWidget>();
|
||||
template<> CV_EXPORTS PlaneWidget Widget::cast<PlaneWidget>();
|
||||
template<> CV_EXPORTS SphereWidget Widget::cast<SphereWidget>();
|
||||
template<> CV_EXPORTS CylinderWidget Widget::cast<CylinderWidget>();
|
||||
template<> CV_EXPORTS ArrowWidget Widget::cast<ArrowWidget>();
|
||||
template<> CV_EXPORTS CircleWidget Widget::cast<CircleWidget>();
|
||||
template<> CV_EXPORTS CubeWidget Widget::cast<CubeWidget>();
|
||||
template<> CV_EXPORTS CoordinateSystemWidget Widget::cast<CoordinateSystemWidget>();
|
||||
template<> CV_EXPORTS TextWidget Widget::cast<TextWidget>();
|
||||
template<> CV_EXPORTS CloudWidget Widget::cast<CloudWidget>();
|
||||
template<> CV_EXPORTS CloudNormalsWidget Widget::cast<CloudNormalsWidget>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,10 +87,10 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::PlaneWidget& temp_viz::PlaneWidget::operator=(const Widget& other)
|
||||
template<> temp_viz::PlaneWidget temp_viz::Widget::cast<temp_viz::PlaneWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<PlaneWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -116,10 +116,10 @@ temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, in
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::SphereWidget& temp_viz::SphereWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::SphereWidget temp_viz::Widget::cast<temp_viz::SphereWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<SphereWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -185,10 +185,10 @@ temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::ArrowWidget& temp_viz::ArrowWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::ArrowWidget temp_viz::Widget::cast<temp_viz::ArrowWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<ArrowWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -221,10 +221,10 @@ temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius,
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::CircleWidget& temp_viz::CircleWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CircleWidget temp_viz::Widget::cast<temp_viz::CircleWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CircleWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -252,10 +252,10 @@ temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::CylinderWidget& temp_viz::CylinderWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CylinderWidget temp_viz::Widget::cast<temp_viz::CylinderWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CylinderWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -279,10 +279,10 @@ temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, b
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::CubeWidget& temp_viz::CubeWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CubeWidget temp_viz::Widget::cast<temp_viz::CubeWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CubeWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -336,10 +336,10 @@ temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Aff
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
temp_viz::CoordinateSystemWidget& temp_viz::CoordinateSystemWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CoordinateSystemWidget temp_viz::Widget::cast<temp_viz::CoordinateSystemWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CoordinateSystemWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -363,10 +363,10 @@ temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int fon
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::TextWidget temp_viz::Widget::cast<temp_viz::TextWidget>()
|
||||
{
|
||||
Widget2D::operator=(other);
|
||||
return *this;
|
||||
Widget2D widget = this->cast<Widget2D>();
|
||||
return static_cast<TextWidget&>(widget);
|
||||
}
|
||||
|
||||
void temp_viz::TextWidget::setText(const String &text)
|
||||
@ -548,10 +548,10 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::CloudWidget& temp_viz::CloudWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CloudWidget temp_viz::Widget::cast<temp_viz::CloudWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CloudWidget&>(widget);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -686,8 +686,8 @@ temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::CloudNormalsWidget& temp_viz::CloudNormalsWidget::operator=(const Widget &other)
|
||||
template<> temp_viz::CloudNormalsWidget temp_viz::Widget::cast<temp_viz::CloudNormalsWidget>()
|
||||
{
|
||||
Widget3D::operator=(other);
|
||||
return *this;
|
||||
Widget3D widget = this->cast<Widget3D>();
|
||||
return static_cast<CloudNormalsWidget&>(widget);
|
||||
}
|
||||
|
@ -91,23 +91,6 @@ struct temp_viz::Widget3D::MatrixConverter
|
||||
}
|
||||
};
|
||||
|
||||
temp_viz::Widget3D::Widget3D(const Widget& other) : Widget(other)
|
||||
{
|
||||
// Check if other's actor is castable to vtkProp3D
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
}
|
||||
|
||||
temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other)
|
||||
{
|
||||
// Check if other's actor is castable to vtkProp3D
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
|
||||
Widget::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
||||
{
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
@ -178,22 +161,6 @@ template<> temp_viz::Widget3D temp_viz::Widget::cast<temp_viz::Widget3D>()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// widget2D implementation
|
||||
|
||||
temp_viz::Widget2D::Widget2D(const Widget &other) : Widget(other)
|
||||
{
|
||||
// Check if other's actor is castable to vtkActor2D
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
}
|
||||
|
||||
temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other)
|
||||
{
|
||||
// Check if other's actor is castable to vtkActor2D
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
Widget::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void temp_viz::Widget2D::setColor(const Color &color)
|
||||
{
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
@ -202,3 +169,13 @@ void temp_viz::Widget2D::setColor(const Color &color)
|
||||
actor->GetProperty ()->SetColor (c.val);
|
||||
actor->Modified ();
|
||||
}
|
||||
|
||||
template<> temp_viz::Widget2D temp_viz::Widget::cast<temp_viz::Widget2D>()
|
||||
{
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
|
||||
Widget2D widget;
|
||||
WidgetAccessor::setProp(widget, actor);
|
||||
return widget;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user