2013-09-08 21:20:02 +08:00
|
|
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
|
|
//
|
|
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
|
|
// If you do not agree to this license, do not download, install,
|
|
|
|
// copy or use the software.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// License Agreement
|
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
// are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// This software is provided by the copyright holders and contributors "as is" and
|
|
|
|
// any express or implied warranties, including, but not limited to, the implied
|
|
|
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
|
|
// the use of this software, even if advised of the possibility of such damage.
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// * Ozan Tonkal, ozantonkal@gmail.com
|
|
|
|
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
|
|
|
|
//
|
|
|
|
// OpenCV Viz module is complete rewrite of
|
|
|
|
// PCL visualization module (www.pointclouds.org)
|
|
|
|
//
|
|
|
|
//M*/
|
|
|
|
|
2013-07-04 17:54:00 +08:00
|
|
|
#include "precomp.hpp"
|
|
|
|
|
2013-07-09 16:21:57 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// widget implementation
|
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
class cv::viz::Widget::Impl
|
2013-07-04 17:54:00 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-09 23:35:26 +08:00
|
|
|
vtkSmartPointer<vtkProp> prop;
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-07-09 23:35:26 +08:00
|
|
|
Impl() : prop(0) {}
|
2013-07-09 16:21:57 +08:00
|
|
|
};
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-08-30 00:41:12 +08:00
|
|
|
cv::viz::Widget::Widget() : impl_( new Impl() ) { }
|
2013-08-29 03:27:30 +08:00
|
|
|
|
2013-08-30 00:41:12 +08:00
|
|
|
cv::viz::Widget::Widget(const Widget& other) : impl_( new Impl() )
|
2013-09-18 19:50:55 +08:00
|
|
|
{
|
2013-08-30 00:41:12 +08:00
|
|
|
if (other.impl_ && other.impl_->prop) impl_->prop = other.impl_->prop;
|
2013-08-29 03:27:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cv::viz::Widget& cv::viz::Widget::operator=(const Widget& other)
|
|
|
|
{
|
2013-08-30 00:41:12 +08:00
|
|
|
if (!impl_) impl_ = new Impl();
|
|
|
|
if (other.impl_) impl_->prop = other.impl_->prop;
|
2013-08-29 03:27:30 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-09-18 19:50:55 +08:00
|
|
|
cv::viz::Widget::~Widget()
|
|
|
|
{
|
2013-08-30 00:41:12 +08:00
|
|
|
if (impl_)
|
2013-08-29 03:27:30 +08:00
|
|
|
{
|
|
|
|
delete impl_;
|
|
|
|
impl_ = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-08-23 01:42:19 +08:00
|
|
|
cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
|
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
|
|
|
|
reader->SetFileName(file_name.c_str());
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-08-23 01:42:19 +08:00
|
|
|
vtkSmartPointer<vtkDataSet> data = reader->GetOutput();
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("File does not exist or file format is not supported." && data);
|
2013-08-23 01:42:19 +08:00
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
|
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
|
2013-09-09 00:55:41 +08:00
|
|
|
#if VTK_MAJOR_VERSION <= 5
|
2013-09-07 20:48:46 +08:00
|
|
|
mapper->SetInput(data);
|
2013-09-09 00:55:41 +08:00
|
|
|
#else
|
|
|
|
mapper->SetInputData(data);
|
|
|
|
#endif
|
2013-08-23 01:42:19 +08:00
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
vtkSmartPointer<vtkDataArray> scalars = data->GetPointData()->GetScalars();
|
2013-08-23 01:42:19 +08:00
|
|
|
if (scalars)
|
|
|
|
{
|
2013-12-13 02:05:10 +08:00
|
|
|
cv::Vec2d minmax(scalars->GetRange());
|
2013-08-23 01:42:19 +08:00
|
|
|
mapper->SetScalarRange(minmax.val);
|
2013-09-07 20:48:46 +08:00
|
|
|
mapper->SetScalarModeToUsePointData();
|
2013-08-23 01:42:19 +08:00
|
|
|
|
|
|
|
// interpolation OFF, if data is a vtkPolyData that contains only vertices, ON for anything else.
|
2013-09-07 20:48:46 +08:00
|
|
|
vtkPolyData* polyData = vtkPolyData::SafeDownCast(data);
|
|
|
|
bool interpolation = (polyData && polyData->GetNumberOfCells() != polyData->GetNumberOfVerts());
|
2013-08-23 01:42:19 +08:00
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
mapper->SetInterpolateScalarsBeforeMapping(interpolation);
|
|
|
|
mapper->ScalarVisibilityOn();
|
2013-08-23 01:42:19 +08:00
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
mapper->ImmediateModeRenderingOff();
|
2013-08-23 01:42:19 +08:00
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->SetNumberOfCloudPoints(int(std::max<vtkIdType>(1, data->GetNumberOfPoints() / 10)));
|
|
|
|
actor->GetProperty()->SetInterpolationToFlat();
|
|
|
|
actor->GetProperty()->BackfaceCullingOn();
|
2013-08-23 01:42:19 +08:00
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->SetMapper(mapper);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-08-23 01:42:19 +08:00
|
|
|
Widget widget;
|
|
|
|
widget.impl_->prop = actor;
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2013-08-24 17:49:56 +08:00
|
|
|
void cv::viz::Widget::setRenderingProperty(int property, double value)
|
|
|
|
{
|
|
|
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget type is not supported." && actor);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-08-24 17:49:56 +08:00
|
|
|
switch (property)
|
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
case POINT_SIZE:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetProperty()->SetPointSize(float(value));
|
|
|
|
actor->Modified();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case OPACITY:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetProperty()->SetOpacity(value);
|
|
|
|
actor->Modified();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case IMMEDIATE_RENDERING:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetMapper()->SetImmediateModeRendering(int(value));
|
|
|
|
actor->Modified();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case LINE_WIDTH:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetProperty()->SetLineWidth(float(value));
|
|
|
|
actor->Modified();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case FONT_SIZE:
|
|
|
|
{
|
|
|
|
vtkTextActor* text_actor = vtkTextActor::SafeDownCast(actor);
|
|
|
|
CV_Assert("Widget does not have text content." && text_actor);
|
|
|
|
vtkSmartPointer<vtkTextProperty> tprop = text_actor->GetTextProperty();
|
|
|
|
tprop->SetFontSize(int(value));
|
|
|
|
text_actor->Modified();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPRESENTATION:
|
|
|
|
{
|
|
|
|
switch (int(value))
|
|
|
|
{
|
|
|
|
case REPRESENTATION_POINTS: actor->GetProperty()->SetRepresentationToPoints(); break;
|
|
|
|
case REPRESENTATION_WIREFRAME: actor->GetProperty()->SetRepresentationToWireframe(); break;
|
|
|
|
case REPRESENTATION_SURFACE: actor->GetProperty()->SetRepresentationToSurface(); break;
|
|
|
|
}
|
|
|
|
actor->Modified();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SHADING:
|
|
|
|
{
|
|
|
|
switch (int(value))
|
|
|
|
{
|
|
|
|
case SHADING_FLAT: actor->GetProperty()->SetInterpolationToFlat(); break;
|
|
|
|
case SHADING_GOURAUD:
|
|
|
|
{
|
|
|
|
if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals())
|
|
|
|
{
|
|
|
|
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
|
2013-09-09 00:55:41 +08:00
|
|
|
#if VTK_MAJOR_VERSION <= 5
|
2013-09-07 20:48:46 +08:00
|
|
|
normals->SetInput(actor->GetMapper()->GetInput());
|
2013-09-09 00:55:41 +08:00
|
|
|
#else
|
|
|
|
normals->SetInputData(actor->GetMapper()->GetInput());
|
|
|
|
#endif
|
2013-09-07 20:48:46 +08:00
|
|
|
normals->Update();
|
2013-09-09 00:55:41 +08:00
|
|
|
vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInputConnection(normals->GetOutputPort());
|
2013-09-07 20:48:46 +08:00
|
|
|
}
|
|
|
|
actor->GetProperty()->SetInterpolationToGouraud();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SHADING_PHONG:
|
|
|
|
{
|
|
|
|
if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals())
|
|
|
|
{
|
|
|
|
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
|
2013-09-09 00:55:41 +08:00
|
|
|
#if VTK_MAJOR_VERSION <= 5
|
2013-09-07 20:48:46 +08:00
|
|
|
normals->SetInput(actor->GetMapper()->GetInput());
|
2013-09-09 00:55:41 +08:00
|
|
|
#else
|
|
|
|
normals->SetInputData(actor->GetMapper()->GetInput());
|
|
|
|
#endif
|
2013-09-07 20:48:46 +08:00
|
|
|
normals->Update();
|
2013-09-09 00:55:41 +08:00
|
|
|
vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInputConnection(normals->GetOutputPort());
|
2013-09-07 20:48:46 +08:00
|
|
|
}
|
|
|
|
actor->GetProperty()->SetInterpolationToPhong();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actor->Modified();
|
|
|
|
break;
|
|
|
|
}
|
2013-09-18 19:50:55 +08:00
|
|
|
|
|
|
|
|
2013-08-24 17:49:56 +08:00
|
|
|
default:
|
|
|
|
CV_Assert("setPointCloudRenderingProperties: Unknown property");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double cv::viz::Widget::getRenderingProperty(int property) const
|
|
|
|
{
|
|
|
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget type is not supported." && actor);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-08-24 17:49:56 +08:00
|
|
|
double value = 0.0;
|
|
|
|
switch (property)
|
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
case POINT_SIZE:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
value = actor->GetProperty()->GetPointSize();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case OPACITY:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
value = actor->GetProperty()->GetOpacity();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case IMMEDIATE_RENDERING:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
value = actor->GetMapper()->GetImmediateModeRendering();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case LINE_WIDTH:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
value = actor->GetProperty()->GetLineWidth();
|
2013-08-24 17:49:56 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case FONT_SIZE:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
vtkTextActor* text_actor = vtkTextActor::SafeDownCast(actor);
|
|
|
|
CV_Assert("Widget does not have text content." && text_actor);
|
|
|
|
vtkSmartPointer<vtkTextProperty> tprop = text_actor->GetTextProperty();
|
|
|
|
value = tprop->GetFontSize();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REPRESENTATION:
|
|
|
|
{
|
|
|
|
switch (actor->GetProperty()->GetRepresentation())
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
case VTK_POINTS: value = REPRESENTATION_POINTS; break;
|
|
|
|
case VTK_WIREFRAME: value = REPRESENTATION_WIREFRAME; break;
|
|
|
|
case VTK_SURFACE: value = REPRESENTATION_SURFACE; break;
|
2013-08-24 17:49:56 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-09-07 20:48:46 +08:00
|
|
|
case SHADING:
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
switch (actor->GetProperty()->GetInterpolation())
|
2013-08-24 17:49:56 +08:00
|
|
|
{
|
2013-09-07 20:48:46 +08:00
|
|
|
case VTK_FLAT: value = SHADING_FLAT; break;
|
|
|
|
case VTK_GOURAUD: value = SHADING_GOURAUD; break;
|
|
|
|
case VTK_PHONG: value = SHADING_PHONG; break;
|
2013-08-24 17:49:56 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
CV_Assert("getPointCloudRenderingProperties: Unknown property");
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2013-07-04 17:54:00 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
2013-07-09 17:07:21 +08:00
|
|
|
/// widget accessor implementaion
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
vtkSmartPointer<vtkProp> cv::viz::WidgetAccessor::getProp(const Widget& widget)
|
2013-07-04 17:54:00 +08:00
|
|
|
{
|
2013-07-09 23:35:26 +08:00
|
|
|
return widget.impl_->prop;
|
2013-07-04 17:54:00 +08:00
|
|
|
}
|
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
void cv::viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> prop)
|
2013-07-09 16:21:57 +08:00
|
|
|
{
|
2013-07-09 23:35:26 +08:00
|
|
|
widget.impl_->prop = prop;
|
2013-07-09 16:21:57 +08:00
|
|
|
}
|
|
|
|
|
2013-07-04 17:54:00 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
2013-07-09 16:21:57 +08:00
|
|
|
/// widget3D implementation
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
void cv::viz::Widget3D::setPose(const Affine3f &pose)
|
2013-07-04 17:54:00 +08:00
|
|
|
{
|
2013-07-09 21:18:44 +08:00
|
|
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget is not 3D." && actor);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-07-09 16:21:57 +08:00
|
|
|
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->SetUserMatrix(matrix);
|
|
|
|
actor->Modified();
|
2013-07-04 17:54:00 +08:00
|
|
|
}
|
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
void cv::viz::Widget3D::updatePose(const Affine3f &pose)
|
2013-07-04 17:54:00 +08:00
|
|
|
{
|
2013-07-09 21:18:44 +08:00
|
|
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget is not 3D." && actor);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-07-09 16:21:57 +08:00
|
|
|
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
|
|
|
|
if (!matrix)
|
2013-07-04 20:57:49 +08:00
|
|
|
{
|
2013-07-09 16:21:57 +08:00
|
|
|
setPose(pose);
|
|
|
|
return ;
|
2013-07-04 20:57:49 +08:00
|
|
|
}
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-12-01 19:25:44 +08:00
|
|
|
Affine3f updated_pose = pose * Affine3f(convertToMatx(matrix));
|
|
|
|
matrix = convertToVtkMatrix(updated_pose.matrix);
|
2013-07-04 20:57:49 +08:00
|
|
|
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->SetUserMatrix(matrix);
|
|
|
|
actor->Modified();
|
2013-07-04 17:54:00 +08:00
|
|
|
}
|
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
cv::Affine3f cv::viz::Widget3D::getPose() const
|
2013-07-04 20:57:49 +08:00
|
|
|
{
|
2013-07-09 21:18:44 +08:00
|
|
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget is not 3D." && actor);
|
2013-12-01 19:25:44 +08:00
|
|
|
return Affine3f(convertToMatx(actor->GetUserMatrix()));
|
2013-07-04 20:57:49 +08:00
|
|
|
}
|
2013-07-04 17:54:00 +08:00
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
void cv::viz::Widget3D::setColor(const Color &color)
|
2013-07-04 20:57:49 +08:00
|
|
|
{
|
2013-07-09 16:21:57 +08:00
|
|
|
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
|
2013-07-09 21:18:44 +08:00
|
|
|
vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget type is not supported." && actor);
|
2013-09-18 19:50:55 +08:00
|
|
|
|
2013-07-09 16:21:57 +08:00
|
|
|
Color c = vtkcolor(color);
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetMapper()->ScalarVisibilityOff();
|
|
|
|
actor->GetProperty()->SetColor(c.val);
|
|
|
|
actor->GetProperty()->SetEdgeColor(c.val);
|
|
|
|
actor->Modified();
|
2013-07-04 20:57:49 +08:00
|
|
|
}
|
2013-07-09 20:12:49 +08:00
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
template<> cv::viz::Widget3D cv::viz::Widget::cast<cv::viz::Widget3D>()
|
2013-07-10 00:02:43 +08:00
|
|
|
{
|
|
|
|
vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget cannot be cast." && actor);
|
2013-07-10 00:02:43 +08:00
|
|
|
|
|
|
|
Widget3D widget;
|
|
|
|
WidgetAccessor::setProp(widget, actor);
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2013-07-09 20:12:49 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// widget2D implementation
|
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
void cv::viz::Widget2D::setColor(const Color &color)
|
2013-07-09 20:28:55 +08:00
|
|
|
{
|
2013-07-09 21:18:44 +08:00
|
|
|
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget type is not supported." && actor);
|
2013-07-09 20:28:55 +08:00
|
|
|
Color c = vtkcolor(color);
|
2013-09-07 20:48:46 +08:00
|
|
|
actor->GetProperty()->SetColor(c.val);
|
|
|
|
actor->Modified();
|
2013-07-09 23:35:26 +08:00
|
|
|
}
|
2013-07-10 15:55:42 +08:00
|
|
|
|
2013-07-13 22:01:56 +08:00
|
|
|
template<> cv::viz::Widget2D cv::viz::Widget::cast<cv::viz::Widget2D>()
|
2013-07-10 15:55:42 +08:00
|
|
|
{
|
|
|
|
vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
|
2013-08-31 17:30:37 +08:00
|
|
|
CV_Assert("Widget cannot be cast." && actor);
|
2013-07-10 15:55:42 +08:00
|
|
|
|
|
|
|
Widget2D widget;
|
|
|
|
WidgetAccessor::setProp(widget, actor);
|
|
|
|
return widget;
|
|
|
|
}
|