rearrange widget constructors
This commit is contained in:
parent
10d955f18b
commit
200b254bad
@ -12,7 +12,7 @@ namespace temp_viz
|
||||
//It is indended for those users who want to develop own widgets system using VTK library API.
|
||||
struct CV_EXPORTS WidgetAccessor
|
||||
{
|
||||
static vtkSmartPointer<vtkProp> getActor(const Widget &widget);
|
||||
static void setVtkProp(Widget &widget, vtkSmartPointer<vtkProp> actor);
|
||||
static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
|
||||
static void setProp(Widget &widget, vtkSmartPointer<vtkProp> actor);
|
||||
};
|
||||
}
|
||||
|
@ -132,6 +132,9 @@ namespace temp_viz
|
||||
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;
|
||||
};
|
||||
|
||||
class CV_EXPORTS CloudWidget : public Widget3D
|
||||
|
@ -8,9 +8,7 @@ namespace temp_viz
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// line widget implementation
|
||||
temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
{
|
||||
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
|
||||
line->SetPoint1 (pt1.x, pt1.y, pt1.z);
|
||||
line->SetPoint2 (pt2.x, pt2.y, pt2.z);
|
||||
@ -19,9 +17,10 @@ temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const C
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(line->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -33,13 +32,15 @@ temp_viz::LineWidget& temp_viz::LineWidget::operator=(const Widget &other)
|
||||
|
||||
void temp_viz::LineWidget::setLineWidth(float line_width)
|
||||
{
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
actor->GetProperty()->SetLineWidth(line_width);
|
||||
}
|
||||
|
||||
float temp_viz::LineWidget::getLineWidth()
|
||||
{
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
return actor->GetProperty()->GetLineWidth();
|
||||
}
|
||||
|
||||
@ -47,9 +48,7 @@ float temp_viz::LineWidget::getLineWidth()
|
||||
/// plane widget implementation
|
||||
|
||||
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
{
|
||||
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
||||
plane->SetNormal (coefs[0], coefs[1], coefs[2]);
|
||||
double norm = cv::norm(cv::Vec3f(coefs.val));
|
||||
@ -58,17 +57,16 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(plane->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
actor->SetScale(size);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
|
||||
cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]);
|
||||
double norm_sqr = 1.0 / coefs3.dot (coefs3);
|
||||
@ -81,10 +79,11 @@ temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(plane->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
actor->SetScale(size);
|
||||
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -99,8 +98,6 @@ temp_viz::PlaneWidget& temp_viz::PlaneWidget::operator=(const Widget& other)
|
||||
|
||||
temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New ();
|
||||
sphere->SetRadius (radius);
|
||||
sphere->SetCenter (center.x, center.y, center.z);
|
||||
@ -112,9 +109,10 @@ temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, in
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(sphere->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -129,8 +127,6 @@ temp_viz::SphereWidget& temp_viz::SphereWidget::operator=(const Widget &other)
|
||||
|
||||
temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New ();
|
||||
|
||||
float startPoint[3], endPoint[3];
|
||||
@ -182,9 +178,10 @@ temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(transformPD->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -199,8 +196,6 @@ temp_viz::ArrowWidget& temp_viz::ArrowWidget::operator=(const Widget &other)
|
||||
|
||||
temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius, double thickness, const temp_viz::Color& color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkDiskSource> disk = vtkSmartPointer<vtkDiskSource>::New ();
|
||||
// Maybe the resolution should be lower e.g. 50 or 25
|
||||
disk->SetCircumferentialResolution (50);
|
||||
@ -219,9 +214,10 @@ temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius,
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(tf->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -235,9 +231,7 @@ temp_viz::CircleWidget& temp_viz::CircleWidget::operator=(const Widget &other)
|
||||
/// cylinder widget implementation
|
||||
|
||||
temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
{
|
||||
const cv::Point3f pt2 = pt_on_axis + axis_direction;
|
||||
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
|
||||
line->SetPoint1 (pt_on_axis.x, pt_on_axis.y, pt_on_axis.z);
|
||||
@ -251,9 +245,10 @@ temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(tuber->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New ();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -268,20 +263,19 @@ temp_viz::CylinderWidget& temp_viz::CylinderWidget::operator=(const Widget &othe
|
||||
|
||||
temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New ();
|
||||
cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
|
||||
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
|
||||
mapper->SetInput(cube->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
if (wire_frame)
|
||||
actor->GetProperty ()->SetRepresentationToWireframe ();
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -296,8 +290,6 @@ temp_viz::CubeWidget& temp_viz::CubeWidget::operator=(const Widget &other)
|
||||
|
||||
temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Affine3f& affine)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New ();
|
||||
axes->SetOrigin (0, 0, 0);
|
||||
axes->SetScaleFactor (scale);
|
||||
@ -324,7 +316,7 @@ temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Aff
|
||||
mapper->SetScalarModeToUsePointData ();
|
||||
mapper->SetInput(axes_tubes->GetOutput ());
|
||||
|
||||
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
cv::Vec3d t = affine.translation();
|
||||
@ -340,6 +332,8 @@ temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Aff
|
||||
|
||||
actor->SetOrientation(0,0,0);
|
||||
actor->RotateWXYZ(r_angle*180/CV_PI,rvec[0], rvec[1], rvec[2]);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
temp_viz::CoordinateSystemWidget& temp_viz::CoordinateSystemWidget::operator=(const Widget &other)
|
||||
@ -353,9 +347,7 @@ temp_viz::CoordinateSystemWidget& temp_viz::CoordinateSystemWidget::operator=(co
|
||||
|
||||
temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font_size, const Color &color)
|
||||
{
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkTextActor>::New());
|
||||
|
||||
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
||||
actor->SetPosition (pos.x, pos.y);
|
||||
actor->SetInput (text.c_str ());
|
||||
|
||||
@ -367,6 +359,8 @@ temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int fon
|
||||
|
||||
Color c = vtkcolor(color);
|
||||
tprop->SetColor (c.val);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
|
||||
@ -375,6 +369,20 @@ temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void temp_viz::TextWidget::setText(const String &text)
|
||||
{
|
||||
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
actor->SetInput(text.c_str());
|
||||
}
|
||||
|
||||
temp_viz::String temp_viz::TextWidget::getText() const
|
||||
{
|
||||
vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
return actor->GetInput();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// point cloud widget implementation
|
||||
|
||||
@ -474,9 +482,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||
CV_Assert(colors.type() == CV_8UC3 && cloud.size() == colors.size());
|
||||
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
vtkIdType nr_points;
|
||||
vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points);
|
||||
|
||||
@ -510,6 +516,8 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
|
||||
actor->GetProperty ()->SetInterpolationToFlat ();
|
||||
actor->GetProperty ()->BackfaceCullingOn ();
|
||||
actor->SetMapper (mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
}
|
||||
|
||||
temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
||||
@ -517,9 +525,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
||||
Mat cloud = _cloud.getMat();
|
||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
vtkIdType nr_points;
|
||||
vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points);
|
||||
|
||||
@ -538,6 +544,7 @@ temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
|
||||
actor->GetProperty ()->BackfaceCullingOn ();
|
||||
actor->SetMapper (mapper);
|
||||
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@ -634,9 +641,7 @@ temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _
|
||||
Mat normals = _normals.getMat();
|
||||
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
|
||||
CV_Assert(cloud.size() == normals.size() && cloud.type() == normals.type());
|
||||
|
||||
WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
|
||||
|
||||
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkIdType nr_normals = 0;
|
||||
@ -675,8 +680,9 @@ temp_viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _
|
||||
mapper->SetColorModeToMapScalars();
|
||||
mapper->SetScalarModeToUsePointData();
|
||||
|
||||
vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
WidgetAccessor::setProp(*this, actor);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
|
||||
removeActorFromRenderer(wam_itr->second.actor);
|
||||
}
|
||||
// Get the actor and set the user matrix
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(widget));
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(widget));
|
||||
if (actor)
|
||||
{
|
||||
// If the actor is 3D, apply pose
|
||||
@ -882,8 +882,8 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
|
||||
actor->SetUserMatrix (matrix);
|
||||
actor->Modified();
|
||||
}
|
||||
renderer_->AddActor(WidgetAccessor::getActor(widget));
|
||||
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget);
|
||||
renderer_->AddActor(WidgetAccessor::getProp(widget));
|
||||
(*widget_actor_map_)[id].actor = WidgetAccessor::getProp(widget);
|
||||
}
|
||||
|
||||
void temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
|
||||
@ -902,7 +902,7 @@ temp_viz::Widget temp_viz::Viz3d::VizImpl::getWidget(const String &id) const
|
||||
CV_Assert(exists);
|
||||
|
||||
Widget widget;
|
||||
WidgetAccessor::setVtkProp(widget, wam_itr->second.actor);
|
||||
WidgetAccessor::setProp(widget, wam_itr->second.actor);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ void temp_viz::Widget::release()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// widget accessor implementaion
|
||||
|
||||
vtkSmartPointer<vtkProp> temp_viz::WidgetAccessor::getActor(const Widget& widget)
|
||||
vtkSmartPointer<vtkProp> temp_viz::WidgetAccessor::getProp(const Widget& widget)
|
||||
{
|
||||
return widget.impl_->actor;
|
||||
}
|
||||
|
||||
void temp_viz::WidgetAccessor::setVtkProp(Widget& widget, vtkSmartPointer<vtkProp> actor)
|
||||
void temp_viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> actor)
|
||||
{
|
||||
widget.impl_->actor = actor;
|
||||
}
|
||||
@ -94,14 +94,14 @@ 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));
|
||||
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::getActor(other));
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
|
||||
Widget::operator=(other);
|
||||
@ -110,7 +110,7 @@ temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other)
|
||||
|
||||
void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
||||
{
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
|
||||
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
||||
@ -120,7 +120,7 @@ void temp_viz::Widget3D::setPose(const Affine3f &pose)
|
||||
|
||||
void temp_viz::Widget3D::updatePose(const Affine3f &pose)
|
||||
{
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
|
||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||
@ -140,7 +140,7 @@ void temp_viz::Widget3D::updatePose(const Affine3f &pose)
|
||||
|
||||
temp_viz::Affine3f temp_viz::Widget3D::getPose() const
|
||||
{
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
|
||||
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
||||
@ -151,7 +151,7 @@ temp_viz::Affine3f temp_viz::Widget3D::getPose() const
|
||||
void temp_viz::Widget3D::setColor(const Color &color)
|
||||
{
|
||||
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
|
||||
Color c = vtkcolor(color);
|
||||
@ -171,14 +171,14 @@ void temp_viz::Widget3D::setColor(const Color &color)
|
||||
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));
|
||||
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::getActor(other));
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(other));
|
||||
CV_Assert(actor);
|
||||
Widget::operator=(other);
|
||||
return *this;
|
||||
@ -186,7 +186,7 @@ temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other)
|
||||
|
||||
void temp_viz::Widget2D::setColor(const Color &color)
|
||||
{
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getActor(*this));
|
||||
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||
CV_Assert(actor);
|
||||
Color c = vtkcolor(color);
|
||||
actor->GetProperty ()->SetColor (c.val);
|
||||
|
Loading…
Reference in New Issue
Block a user