implement assignment operator and copy constructor for all widgets existing
This commit is contained in:
parent
195d60f4f8
commit
318b1c00a9
modules/viz
include/opencv2/viz
src
@ -47,10 +47,11 @@ namespace temp_viz
|
|||||||
bool wasStopped() const;
|
bool wasStopped() const;
|
||||||
|
|
||||||
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
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);
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
bool updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
private:
|
private:
|
||||||
Viz3d(const Viz3d&);
|
Viz3d(const Viz3d&);
|
||||||
|
@ -31,6 +31,8 @@ namespace temp_viz
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Widget3D() {}
|
Widget3D() {}
|
||||||
|
Widget3D(const Widget& other);
|
||||||
|
Widget3D& operator =(const Widget &other);
|
||||||
|
|
||||||
void setPose(const Affine3f &pose);
|
void setPose(const Affine3f &pose);
|
||||||
void updatePose(const Affine3f &pose);
|
void updatePose(const Affine3f &pose);
|
||||||
@ -49,6 +51,8 @@ namespace temp_viz
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Widget2D() {}
|
Widget2D() {}
|
||||||
|
Widget2D(const Widget &other);
|
||||||
|
Widget2D& operator=(const Widget &other);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -56,6 +60,8 @@ namespace temp_viz
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color = Color::white());
|
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);
|
void setLineWidth(float line_width);
|
||||||
float getLineWidth();
|
float getLineWidth();
|
||||||
@ -66,48 +72,64 @@ namespace temp_viz
|
|||||||
public:
|
public:
|
||||||
PlaneWidget(const Vec4f& coefs, double size = 1.0, const Color &color = Color::white());
|
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 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
|
class CV_EXPORTS SphereWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution = 10, const Color &color = Color::white());
|
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
|
class CV_EXPORTS ArrowWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color = Color::white());
|
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
|
class CV_EXPORTS CircleWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CircleWidget(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
|
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
|
class CV_EXPORTS CylinderWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
|
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
|
class CV_EXPORTS CubeWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame = true, const Color &color = Color::white());
|
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
|
class CV_EXPORTS CoordinateSystemWidget : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CoordinateSystemWidget(double scale, const Affine3f& affine);
|
CoordinateSystemWidget(double scale, const Affine3f& affine);
|
||||||
|
CoordinateSystemWidget(const Widget &other) : Widget3D(other) {}
|
||||||
|
CoordinateSystemWidget& operator=(const Widget &other);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS TextWidget : public Widget2D
|
class CV_EXPORTS TextWidget : public Widget2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextWidget(const String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white());
|
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
|
class CV_EXPORTS CloudWidget : public Widget3D
|
||||||
@ -115,6 +137,9 @@ namespace temp_viz
|
|||||||
public:
|
public:
|
||||||
CloudWidget(InputArray _cloud, InputArray _colors);
|
CloudWidget(InputArray _cloud, InputArray _colors);
|
||||||
CloudWidget(InputArray _cloud, const Color &color = Color::white());
|
CloudWidget(InputArray _cloud, const Color &color = Color::white());
|
||||||
|
CloudWidget(const Widget &other) : Widget3D(other) {}
|
||||||
|
CloudWidget& operator=(const Widget &other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CreateCloudWidget;
|
struct CreateCloudWidget;
|
||||||
};
|
};
|
||||||
@ -123,6 +148,9 @@ namespace temp_viz
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CloudNormalsWidget(InputArray _cloud, InputArray _normals, int level = 100, float scale = 0.02f, const Color &color = Color::white());
|
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:
|
private:
|
||||||
struct ApplyCloudNormals;
|
struct ApplyCloudNormals;
|
||||||
};
|
};
|
||||||
|
@ -200,10 +200,11 @@ public:
|
|||||||
void setSize (int xw, int yw);
|
void setSize (int xw, int yw);
|
||||||
|
|
||||||
void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
|
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);
|
void setWidgetPose(const String &id, const Affine3f &pose);
|
||||||
bool updateWidgetPose(const String &id, const Affine3f &pose);
|
void updateWidgetPose(const String &id, const Affine3f &pose);
|
||||||
Affine3f getWidgetPose(const String &id) const;
|
Affine3f getWidgetPose(const String &id) const;
|
||||||
|
|
||||||
void all_data();
|
void all_data();
|
||||||
|
@ -25,6 +25,12 @@ temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const C
|
|||||||
setColor(color);
|
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)
|
void temp_viz::LineWidget::setLineWidth(float line_width)
|
||||||
{
|
{
|
||||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||||
@ -82,6 +88,12 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::PlaneWidget& temp_viz::PlaneWidget::operator=(const Widget& other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// sphere widget implementation
|
/// sphere widget implementation
|
||||||
|
|
||||||
@ -106,6 +118,12 @@ temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, in
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::SphereWidget& temp_viz::SphereWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// arrow widget implementation
|
/// arrow widget implementation
|
||||||
|
|
||||||
@ -170,6 +188,12 @@ temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::ArrowWidget& temp_viz::ArrowWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// circle widget implementation
|
/// circle widget implementation
|
||||||
|
|
||||||
@ -201,6 +225,12 @@ temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius,
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::CircleWidget& temp_viz::CircleWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cylinder widget implementation
|
/// cylinder widget implementation
|
||||||
|
|
||||||
@ -227,6 +257,12 @@ temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::CylinderWidget& temp_viz::CylinderWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cylinder widget implementation
|
/// cylinder widget implementation
|
||||||
|
|
||||||
@ -249,6 +285,12 @@ temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, b
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::CubeWidget& temp_viz::CubeWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// coordinate system widget implementation
|
/// coordinate system widget implementation
|
||||||
|
|
||||||
@ -300,6 +342,12 @@ temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Aff
|
|||||||
actor->RotateWXYZ(r_angle*180/CV_PI,rvec[0], rvec[1], rvec[2]);
|
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
|
/// text widget implementation
|
||||||
|
|
||||||
@ -321,6 +369,12 @@ temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int fon
|
|||||||
tprop->SetColor (c.val);
|
tprop->SetColor (c.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget2D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// point cloud widget implementation
|
/// point cloud widget implementation
|
||||||
|
|
||||||
@ -487,6 +541,12 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
|||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp_viz::CloudWidget& temp_viz::CloudWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cloud normals widget implementation
|
/// cloud normals widget implementation
|
||||||
|
|
||||||
@ -618,4 +678,10 @@ temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _
|
|||||||
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
setColor(color);
|
setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
temp_viz::CloudNormalsWidget& temp_viz::CloudNormalsWidget::operator=(const Widget &other)
|
||||||
|
{
|
||||||
|
Widget3D::operator=(other);
|
||||||
|
return *this;
|
||||||
}
|
}
|
@ -84,19 +84,24 @@ void temp_viz::Viz3d::showWidget(const String &id, const Widget &widget, const A
|
|||||||
impl_->showWidget(id, widget, pose);
|
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
|
temp_viz::Affine3f temp_viz::Viz3d::getWidgetPose(const String &id) const
|
||||||
|
@ -874,9 +874,10 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
|
|||||||
removeActorFromRenderer(wam_itr->second.actor);
|
removeActorFromRenderer(wam_itr->second.actor);
|
||||||
}
|
}
|
||||||
// Get the actor and set the user matrix
|
// Get the actor and set the user matrix
|
||||||
vtkLODActor *actor;
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(widget));
|
||||||
if (actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(widget)))
|
if (actor)
|
||||||
{
|
{
|
||||||
|
// If the actor is 3D, apply pose
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
||||||
actor->SetUserMatrix (matrix);
|
actor->SetUserMatrix (matrix);
|
||||||
actor->Modified();
|
actor->Modified();
|
||||||
@ -885,61 +886,61 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
|
|||||||
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget);
|
(*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);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
CV_Assert(exists);
|
CV_Assert(exists);
|
||||||
|
CV_Assert(removeActorFromRenderer (wam_itr->second.actor));
|
||||||
if (!removeActorFromRenderer (wam_itr->second.actor))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
widget_actor_map_->erase(wam_itr);
|
widget_actor_map_->erase(wam_itr);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
|
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 widget;
|
||||||
|
WidgetAccessor::setVtkProp(widget, wam_itr->second.actor);
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_viz::Viz3d::VizImpl::setWidgetPose(const String &id, const Affine3f &pose)
|
||||||
{
|
{
|
||||||
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
CV_Assert(exists);
|
CV_Assert(exists);
|
||||||
|
|
||||||
vtkLODActor *actor;
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
|
||||||
if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
|
CV_Assert(actor);
|
||||||
{
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
||||||
actor->SetUserMatrix (matrix);
|
actor->SetUserMatrix (matrix);
|
||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
WidgetActorMap::iterator wam_itr = widget_actor_map_->find(id);
|
||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
CV_Assert(exists);
|
CV_Assert(exists);
|
||||||
|
|
||||||
vtkLODActor *actor;
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
|
||||||
if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
|
CV_Assert(actor);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||||
|
if (!matrix)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
setWidgetPose(id, pose);
|
||||||
if (!matrix)
|
return ;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
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
|
temp_viz::Affine3f temp_viz::Viz3d::VizImpl::getWidgetPose(const String &id) const
|
||||||
@ -948,12 +949,10 @@ temp_viz::Affine3f temp_viz::Viz3d::VizImpl::getWidgetPose(const String &id) con
|
|||||||
bool exists = wam_itr != widget_actor_map_->end();
|
bool exists = wam_itr != widget_actor_map_->end();
|
||||||
CV_Assert(exists);
|
CV_Assert(exists);
|
||||||
|
|
||||||
vtkLODActor *actor;
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(wam_itr->second.actor);
|
||||||
if ((actor = vtkLODActor::SafeDownCast(wam_itr->second.actor)))
|
CV_Assert(actor);
|
||||||
{
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||||
Matx44f matrix_cv = convertToMatx(matrix);
|
Matx44f matrix_cv = convertToMatx(matrix);
|
||||||
return Affine3f(matrix_cv);
|
return Affine3f(matrix_cv);
|
||||||
}
|
|
||||||
return Affine3f();
|
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ temp_viz::Widget::Widget(const Widget &other) : impl_(other.impl_)
|
|||||||
if (impl_) CV_XADD(&impl_->ref_counter, 1);
|
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)
|
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)
|
void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
||||||
{
|
{
|
||||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||||
@ -147,3 +164,22 @@ void temp_viz::Widget3D::setColor(const Color &color)
|
|||||||
actor->GetProperty ()->SetLighting (0);
|
actor->GetProperty ()->SetLighting (0);
|
||||||
actor->Modified ();
|
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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user