|
|
@ -24,28 +24,18 @@ class temp_viz::Widget::Impl |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
String id; |
|
|
|
String id; |
|
|
|
vtkSmartPointer<vtkActor> actor; |
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
|
|
|
|
Impl()
|
|
|
|
Impl()
|
|
|
|
{ |
|
|
|
{ |
|
|
|
actor = vtkSmartPointer<vtkActor>:: New(); |
|
|
|
actor = vtkSmartPointer<vtkLODActor>::New (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkActor> getActor() |
|
|
|
vtkSmartPointer<vtkLODActor> getActor() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return actor; |
|
|
|
return actor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setId(const String &id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this->id = id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const temp_viz::String & getString() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setColor(const Color & color) |
|
|
|
void setColor(const Color & color) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Color c = vtkcolor(color); |
|
|
|
Color c = vtkcolor(color); |
|
|
@ -85,11 +75,22 @@ public: |
|
|
|
return Affine3f(matrix_cv); |
|
|
|
return Affine3f(matrix_cv); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setActorMapperInput(const vtkSmartPointer<vtkDataSet> &data) |
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSetMapper> mapper = reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ()); |
|
|
|
|
|
|
|
if (mapper == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mapper = vtkSmartPointer<vtkDataSetMapper>::New (); |
|
|
|
|
|
|
|
actor->SetMapper(mapper); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapper->SetInput (data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f &m) const |
|
|
|
vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f &m) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New(); |
|
|
|
vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New (); |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int k = 0; k < 4; k++) |
|
|
|
for (int k = 0; k < 4; k++) |
|
|
|
vtk_matrix->SetElement(i, k, m(i, k)); |
|
|
|
vtk_matrix->SetElement(i, k, m(i, k)); |
|
|
@ -101,20 +102,12 @@ protected: |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
for (int k = 0; k < 4; k++) |
|
|
|
for (int k = 0; k < 4; k++) |
|
|
|
m(i,k) = vtk_matrix->GetElement (i, k); |
|
|
|
m(i,k) = vtk_matrix->GetElement (i, k); |
|
|
|
} |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
temp_viz::Widget::Widget() |
|
|
|
temp_viz::Widget::Widget() |
|
|
|
{ |
|
|
|
{ |
|
|
|
impl_ = new Impl(); |
|
|
|
impl_ = new Impl(); |
|
|
|
impl_->setId("id"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp_viz::Widget::Widget(const String &id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
impl_ = new Impl(); |
|
|
|
|
|
|
|
impl_->setId("id"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
temp_viz::Widget::Widget(const Widget &other) |
|
|
|
temp_viz::Widget::Widget(const Widget &other) |
|
|
@ -122,11 +115,6 @@ temp_viz::Widget::Widget(const Widget &other) |
|
|
|
impl_ = other.impl_; |
|
|
|
impl_ = other.impl_; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Widget::setId(const String &id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
impl_->setId(id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Widget::setColor(const Color &color) |
|
|
|
void temp_viz::Widget::setColor(const Color &color) |
|
|
|
{ |
|
|
|
{ |
|
|
|
impl_->setColor(color); |
|
|
|
impl_->setColor(color); |
|
|
@ -147,11 +135,18 @@ temp_viz::Affine3f temp_viz::Widget::getPose() const |
|
|
|
return impl_->getPose(); |
|
|
|
return impl_->getPose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO Check if HAVE_VTK
|
|
|
|
|
|
|
|
#include "opencv2/viz/widget_accessor.hpp" |
|
|
|
#include "opencv2/viz/widget_accessor.hpp" |
|
|
|
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkActor> temp_viz::WidgetAccessor::getActor(const temp_viz::Widget &widget) |
|
|
|
vtkSmartPointer<vtkLODActor> temp_viz::WidgetAccessor::getActor(const temp_viz::Widget &widget) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return widget.impl_->actor; |
|
|
|
return widget.impl_->actor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color) : Widget() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create the line and set actor's data
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New (); |
|
|
|
|
|
|
|
mapper->SetInput(createLine(pt1,pt2)); |
|
|
|
|
|
|
|
temp_viz::WidgetAccessor::getActor(*this)->SetMapper(mapper); |
|
|
|
|
|
|
|
setColor(color); |
|
|
|
|
|
|
|
} |