bool wasStopped() const;
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
- bool removeWidget(const String &id);
+ void removeWidget(const String &id);
+ Widget getWidget(const String &id) const;
- bool setWidgetPose(const String &id, const Affine3f &pose);
- bool updateWidgetPose(const String &id, const Affine3f &pose);
+ void setWidgetPose(const String &id, const Affine3f &pose);
+ void updateWidgetPose(const String &id, const Affine3f &pose);
Affine3f getWidgetPose(const String &id) const;
private:
Viz3d(const Viz3d&);
{
public:
Widget3D() {}
+ Widget3D(const Widget& other);
+ Widget3D& operator =(const Widget &other);
void setPose(const Affine3f &pose);
void updatePose(const Affine3f &pose);
{
public:
Widget2D() {}
+ Widget2D(const Widget &other);
+ Widget2D& operator=(const Widget &other);
};
{
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();
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);
};
class CV_EXPORTS CloudWidget : public Widget3D
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;
};
{
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;
};
void setSize (int xw, int yw);
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
- bool removeWidget(const String &id);
+ void removeWidget(const String &id);
+ Widget getWidget(const String &id) const;
- bool setWidgetPose(const String &id, const Affine3f &pose);
- bool updateWidgetPose(const String &id, const Affine3f &pose);
+ void setWidgetPose(const String &id, const Affine3f &pose);
+ void updateWidgetPose(const String &id, const Affine3f &pose);
Affine3f getWidgetPose(const String &id) const;
void all_data();
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::getActor(*this));
setColor(color);
}
+temp_viz::PlaneWidget& temp_viz::PlaneWidget::operator=(const Widget& other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// sphere widget implementation
setColor(color);
}
+temp_viz::SphereWidget& temp_viz::SphereWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// arrow widget implementation
setColor(color);
}
+temp_viz::ArrowWidget& temp_viz::ArrowWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// circle widget implementation
setColor(color);
}
+temp_viz::CircleWidget& temp_viz::CircleWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation
setColor(color);
}
+temp_viz::CylinderWidget& temp_viz::CylinderWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation
setColor(color);
}
+temp_viz::CubeWidget& temp_viz::CubeWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// coordinate system widget implementation
actor->RotateWXYZ(r_angle*180/CV_PI,rvec[0], rvec[1], rvec[2]);
}
+temp_viz::CoordinateSystemWidget& temp_viz::CoordinateSystemWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// text widget implementation
tprop->SetColor (c.val);
}
+temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
+{
+ Widget2D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// point cloud widget implementation
setColor(color);
}
+temp_viz::CloudWidget& temp_viz::CloudWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// cloud normals widget implementation
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
actor->SetMapper(mapper);
setColor(color);
+}
+
+temp_viz::CloudNormalsWidget& temp_viz::CloudNormalsWidget::operator=(const Widget &other)
+{
+ Widget3D::operator=(other);
+ return *this;
}
\ No newline at end of file
impl_->showWidget(id, widget, pose);
}
-bool temp_viz::Viz3d::removeWidget(const String &id)
+void temp_viz::Viz3d::removeWidget(const String &id)
{
- return impl_->removeWidget(id);
+ impl_->removeWidget(id);
}
-bool temp_viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose)
+temp_viz::Widget temp_viz::Viz3d::getWidget(const String &id) const
{
- return impl_->setWidgetPose(id, pose);
+ return impl_->getWidget(id);
}
-bool temp_viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose)
+void temp_viz::Viz3d::setWidgetPose(const String &id, const Affine3f &pose)
{
- return impl_->updateWidgetPose(id, pose);
+ impl_->setWidgetPose(id, pose);
+}
+
+void temp_viz::Viz3d::updateWidgetPose(const String &id, const Affine3f &pose)
+{
+ impl_->updateWidgetPose(id, pose);
}
temp_viz::Affine3f temp_viz::Viz3d::getWidgetPose(const String &id) const
removeActorFromRenderer(wam_itr->second.actor);
}
// Get the actor and set the user matrix
- vtkLODActor *actor;
- if (actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(widget)))
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(widget));
+ if (actor)
{
+ // If the actor is 3D, apply pose
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
actor->SetUserMatrix (matrix);
actor->Modified();
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget);
}
-bool temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
+void temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
{
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
bool exists = wam_itr != widget_actor_map_->end();
CV_Assert(exists);
+ CV_Assert(removeActorFromRenderer (wam_itr->second.actor));
+ widget_actor_map_->erase(wam_itr);
+}
- if (!removeActorFromRenderer (wam_itr->second.actor))
- return false;
+temp_viz::Widget temp_viz::Viz3d::VizImpl::getWidget(const String &id) const
+{
+ WidgetActorMap::const_iterator wam_itr = widget_actor_map_->find(id);
+ bool exists = wam_itr != widget_actor_map_->end();
+ CV_Assert(exists);
- widget_actor_map_->erase(wam_itr);
- return true;
+ Widget widget;
+ WidgetAccessor::setVtkProp(widget, wam_itr->second.actor);
+ return widget;
}
-bool temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
+void temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
{
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
bool exists = wam_itr != widget_actor_map_->end();
CV_Assert(exists);
- vtkLODActor *actor;
- if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
- {
- vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
- actor->SetUserMatrix (matrix);
- actor->Modified ();
- return true;
- }
- return false;
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
+ CV_Assert(actor);
+
+ vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
+ actor->SetUserMatrix (matrix);
+ actor->Modified ();
}
-bool temp_viz::Viz3d::VizImpl::updateWidgetPose(const String &id, const Affine3f &pose)
+void temp_viz::Viz3d::VizImpl::updateWidgetPose(const String &id, const Affine3f &pose)
{
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
bool exists = wam_itr != widget_actor_map_->end();
CV_Assert(exists);
- vtkLODActor *actor;
- if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
+ CV_Assert(actor);
+
+ vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
+ if (!matrix)
{
- vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
- if (!matrix)
- {
- setWidgetPose(id, pose);
- return true;
- }
- Matx44f matrix_cv = convertToMatx(matrix);
-
- Affine3f updated_pose = pose * Affine3f(matrix_cv);
- matrix = convertToVtkMatrix(updated_pose.matrix);
-
- actor->SetUserMatrix (matrix);
- actor->Modified ();
- return true;
+ setWidgetPose(id, pose);
+ return ;
}
- return false;
+ Matx44f matrix_cv = convertToMatx(matrix);
+ Affine3f updated_pose = pose * Affine3f(matrix_cv);
+ matrix = convertToVtkMatrix(updated_pose.matrix);
+
+ actor->SetUserMatrix (matrix);
+ actor->Modified ();
}
temp_viz::Affine3f temp_viz::Viz3d::VizImpl::getWidgetPose(const String &id) const
bool exists = wam_itr != widget_actor_map_->end();
CV_Assert(exists);
- vtkLODActor *actor;
- if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
- {
- vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
- Matx44f matrix_cv = convertToMatx(matrix);
- return Affine3f(matrix_cv);
- }
- return Affine3f();
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
+ CV_Assert(actor);
+
+ vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
+ Matx44f matrix_cv = convertToMatx(matrix);
+ return Affine3f(matrix_cv);
}
\ No newline at end of file
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)
{
}
};
+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));
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;
+}
\ No newline at end of file