Commit 200b254b authored by ozantonkal's avatar ozantonkal

rearrange widget constructors

parent 10d955f1
...@@ -12,7 +12,7 @@ namespace temp_viz ...@@ -12,7 +12,7 @@ namespace temp_viz
//It is indended for those users who want to develop own widgets system using VTK library API. //It is indended for those users who want to develop own widgets system using VTK library API.
struct CV_EXPORTS WidgetAccessor struct CV_EXPORTS WidgetAccessor
{ {
static vtkSmartPointer<vtkProp> getActor(const Widget &widget); static vtkSmartPointer<vtkProp> getProp(const Widget &widget);
static void setVtkProp(Widget &widget, vtkSmartPointer<vtkProp> actor); static void setProp(Widget &widget, vtkSmartPointer<vtkProp> actor);
}; };
} }
...@@ -132,6 +132,9 @@ namespace temp_viz ...@@ -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 String &text, const Point2i &pos, int font_size = 10, const Color &color = Color::white());
TextWidget(const Widget& other) : Widget2D(other) {} TextWidget(const Widget& other) : Widget2D(other) {}
TextWidget& operator=(const Widget &other); TextWidget& operator=(const Widget &other);
void setText(const String &text);
String getText() const;
}; };
class CV_EXPORTS CloudWidget : public Widget3D class CV_EXPORTS CloudWidget : public Widget3D
......
This diff is collapsed.
...@@ -874,7 +874,7 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget ...@@ -874,7 +874,7 @@ 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
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(widget)); vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(widget));
if (actor) if (actor)
{ {
// If the actor is 3D, apply pose // If the actor is 3D, apply pose
...@@ -882,8 +882,8 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget ...@@ -882,8 +882,8 @@ void temp_viz::Viz3d::VizImpl::showWidget(const String &id, const Widget &widget
actor->SetUserMatrix (matrix); actor->SetUserMatrix (matrix);
actor->Modified(); actor->Modified();
} }
renderer_->AddActor(WidgetAccessor::getActor(widget)); renderer_->AddActor(WidgetAccessor::getProp(widget));
(*widget_actor_map_)[id].actor = WidgetAccessor::getActor(widget); (*widget_actor_map_)[id].actor = WidgetAccessor::getProp(widget);
} }
void temp_viz::Viz3d::VizImpl::removeWidget(const String &id) 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 ...@@ -902,7 +902,7 @@ temp_viz::Widget temp_viz::Viz3d::VizImpl::getWidget(const String &id) const
CV_Assert(exists); CV_Assert(exists);
Widget widget; Widget widget;
WidgetAccessor::setVtkProp(widget, wam_itr->second.actor); WidgetAccessor::setProp(widget, wam_itr->second.actor);
return widget; return widget;
} }
......
...@@ -57,12 +57,12 @@ void temp_viz::Widget::release() ...@@ -57,12 +57,12 @@ void temp_viz::Widget::release()
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
/// widget accessor implementaion /// 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; 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; widget.impl_->actor = actor;
} }
...@@ -94,14 +94,14 @@ struct temp_viz::Widget3D::MatrixConverter ...@@ -94,14 +94,14 @@ struct temp_viz::Widget3D::MatrixConverter
temp_viz::Widget3D::Widget3D(const Widget& other) : Widget(other) temp_viz::Widget3D::Widget3D(const Widget& other) : Widget(other)
{ {
// Check if other's actor is castable to vtkProp3D // 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); CV_Assert(actor);
} }
temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other) temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other)
{ {
// Check if other's actor is castable to vtkProp3D // 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); CV_Assert(actor);
Widget::operator=(other); Widget::operator=(other);
...@@ -110,7 +110,7 @@ temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other) ...@@ -110,7 +110,7 @@ temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other)
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::getProp(*this));
CV_Assert(actor); CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix); vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
...@@ -120,7 +120,7 @@ void temp_viz::Widget3D::setPose(const Affine3f &pose) ...@@ -120,7 +120,7 @@ void temp_viz::Widget3D::setPose(const Affine3f &pose)
void temp_viz::Widget3D::updatePose(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); CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix(); vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
...@@ -140,7 +140,7 @@ void temp_viz::Widget3D::updatePose(const Affine3f &pose) ...@@ -140,7 +140,7 @@ void temp_viz::Widget3D::updatePose(const Affine3f &pose)
temp_viz::Affine3f temp_viz::Widget3D::getPose() const 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); CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix(); vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
...@@ -151,7 +151,7 @@ temp_viz::Affine3f temp_viz::Widget3D::getPose() const ...@@ -151,7 +151,7 @@ temp_viz::Affine3f temp_viz::Widget3D::getPose() const
void temp_viz::Widget3D::setColor(const Color &color) void temp_viz::Widget3D::setColor(const Color &color)
{ {
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty // 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); CV_Assert(actor);
Color c = vtkcolor(color); Color c = vtkcolor(color);
...@@ -171,14 +171,14 @@ void temp_viz::Widget3D::setColor(const Color &color) ...@@ -171,14 +171,14 @@ void temp_viz::Widget3D::setColor(const Color &color)
temp_viz::Widget2D::Widget2D(const Widget &other) : Widget(other) temp_viz::Widget2D::Widget2D(const Widget &other) : Widget(other)
{ {
// Check if other's actor is castable to vtkActor2D // 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); CV_Assert(actor);
} }
temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other) temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other)
{ {
// Check if other's actor is castable to vtkActor2D // 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); CV_Assert(actor);
Widget::operator=(other); Widget::operator=(other);
return *this; return *this;
...@@ -186,7 +186,7 @@ temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other) ...@@ -186,7 +186,7 @@ temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other)
void temp_viz::Widget2D::setColor(const Color &color) 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); CV_Assert(actor);
Color c = vtkcolor(color); Color c = vtkcolor(color);
actor->GetProperty ()->SetColor (c.val); actor->GetProperty ()->SetColor (c.val);
......
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