Commit c4f4727e authored by ozantonkal's avatar ozantonkal

showWidget takes Affine3f as argument

parent eafcdc00
...@@ -46,7 +46,7 @@ namespace temp_viz ...@@ -46,7 +46,7 @@ namespace temp_viz
bool wasStopped() const; bool wasStopped() const;
void showWidget(const String &id, const Widget &widget); void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
bool removeWidget(const String &id); bool removeWidget(const String &id);
private: private:
Viz3d(const Viz3d&); Viz3d(const Viz3d&);
......
...@@ -199,7 +199,7 @@ public: ...@@ -199,7 +199,7 @@ public:
void setPosition (int x, int y); void setPosition (int x, int y);
void setSize (int xw, int yw); void setSize (int xw, int yw);
void showWidget(const String &id, const Widget &widget); void showWidget(const String &id, const Widget &widget, const Affine3f &pose = Affine3f::Identity());
bool removeWidget(const String &id); bool removeWidget(const String &id);
void all_data(); void all_data();
......
...@@ -79,9 +79,9 @@ void temp_viz::Viz3d::registerMouseCallback(void (*callback)(const MouseEvent&, ...@@ -79,9 +79,9 @@ void temp_viz::Viz3d::registerMouseCallback(void (*callback)(const MouseEvent&,
bool temp_viz::Viz3d::wasStopped() const { return impl_->wasStopped(); } bool temp_viz::Viz3d::wasStopped() const { return impl_->wasStopped(); }
void temp_viz::Viz3d::showWidget(const String &id, const Widget &widget) void temp_viz::Viz3d::showWidget(const String &id, const Widget &widget, const Affine3f &pose)
{ {
impl_->showWidget(id, widget); impl_->showWidget(id, widget, pose);
} }
bool temp_viz::Viz3d::removeWidget(const String &id) bool temp_viz::Viz3d::removeWidget(const String &id)
......
...@@ -864,7 +864,7 @@ bool temp_viz::Viz3d::VizImpl::addPolygon (const cv::Mat& cloud, const Color& co ...@@ -864,7 +864,7 @@ bool temp_viz::Viz3d::VizImpl::addPolygon (const cv::Mat& cloud, const Color& co
return (true); return (true);
} }
void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget) void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget, 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();
...@@ -873,8 +873,13 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget ...@@ -873,8 +873,13 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
// Remove it if it exists and add it again // Remove it if it exists and add it again
removeActorFromRenderer(wam_itr->second.actor); removeActorFromRenderer(wam_itr->second.actor);
} }
renderer_->AddActor(WidgetAccessor::getActor(widget)); // Get the actor and set the user matrix
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget); vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(widget));
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
actor->SetUserMatrix (matrix);
actor->Modified();
renderer_->AddActor(actor);
(*widget_actor_map_)[id].actor = actor;
} }
bool temp_viz::Viz3d::VizImpl::removeWidget(const String &id) bool temp_viz::Viz3d::VizImpl::removeWidget(const String &id)
......
...@@ -121,13 +121,15 @@ TEST(Viz_viz3d, accuracy) ...@@ -121,13 +121,15 @@ TEST(Viz_viz3d, accuracy)
pw.setColor(temp_viz::Color(col_blue, col_green, col_red)); pw.setColor(temp_viz::Color(col_blue, col_green, col_red));
sw.setPose(cloudPosition); sw.setPose(cloudPosition);
pw.setPose(cloudPosition); // pw.setPose(cloudPosition);
aw.setPose(cloudPosition); aw.setPose(cloudPosition);
cw.setPose(cloudPosition); cw.setPose(cloudPosition);
cyw.setPose(cloudPosition); cyw.setPose(cloudPosition);
lw.setPose(cloudPosition); lw.setPose(cloudPosition);
cuw.setPose(cloudPosition); cuw.setPose(cloudPosition);
v.showWidget("plane", pw, cloudPosition);
angle_x += 0.1f; angle_x += 0.1f;
angle_y -= 0.1f; angle_y -= 0.1f;
angle_z += 0.1f; angle_z += 0.1f;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment