1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

implement assignment operator and copy constructor for all widgets existing

This commit is contained in:
ozantonkal
2013-07-09 14:12:49 +02:00
parent 195d60f4f8
commit 318b1c00a9
7 changed files with 193 additions and 57 deletions
+37 -1
View File
@@ -22,7 +22,7 @@ temp_viz::Widget::Widget(const Widget &other) : impl_(other.impl_)
if (impl_) CV_XADD(&impl_->ref_counter, 1);
}
temp_viz::Widget& temp_viz::Widget::operator =(const Widget &other)
temp_viz::Widget& temp_viz::Widget::operator=(const Widget &other)
{
if (this != &other)
{
@@ -91,6 +91,23 @@ 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::getActor(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::getActor(other));
CV_Assert(actor);
Widget::operator=(other);
return *this;
}
void temp_viz::Widget3D::setPose(const Affine3f &pose)
{
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
@@ -147,3 +164,22 @@ void temp_viz::Widget3D::setColor(const Color &color)
actor->GetProperty ()->SetLighting (0);
actor->Modified ();
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// 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::getActor(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::getActor(other));
CV_Assert(actor);
Widget::operator=(other);
return *this;
}