Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
195d60f4
Commit
195d60f4
authored
Jul 09, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix widget delete bug
parent
d324c03b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
108 deletions
+23
-108
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+4
-2
widget.cpp
modules/viz/src/widget.cpp
+19
-106
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
195d60f4
...
...
@@ -21,6 +21,8 @@ namespace temp_viz
Impl
*
impl_
;
friend
struct
WidgetAccessor
;
void
create
();
void
release
();
};
/////////////////////////////////////////////////////////////////////////////
...
...
@@ -28,7 +30,7 @@ namespace temp_viz
class
CV_EXPORTS
Widget3D
:
public
Widget
{
public
:
Widget3D
()
;
Widget3D
()
{}
void
setPose
(
const
Affine3f
&
pose
);
void
updatePose
(
const
Affine3f
&
pose
);
...
...
@@ -46,7 +48,7 @@ namespace temp_viz
class
CV_EXPORTS
Widget2D
:
public
Widget
{
public
:
Widget2D
()
;
Widget2D
()
{}
};
...
...
modules/viz/src/widget.cpp
View file @
195d60f4
...
...
@@ -7,129 +7,55 @@ class temp_viz::Widget::Impl
{
public
:
vtkSmartPointer
<
vtkProp
>
actor
;
int
ref_counter
;
Impl
()
:
actor
(
0
)
{}
};
temp_viz
::
Widget
::
Widget
()
:
impl_
(
0
)
{
impl_
=
new
Impl
();
create
();
}
temp_viz
::
Widget
::
Widget
(
const
Widget
&
other
)
:
impl_
(
other
.
impl_
)
{
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
temp_viz
::
Widget
&
temp_viz
::
Widget
::
operator
=
(
const
Widget
&
other
)
{
if
(
this
!=
&
other
)
{
delete
impl_
;
release
()
;
impl_
=
other
.
impl_
;
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
return
*
this
;
}
temp_viz
::
Widget
::~
Widget
()
{
if
(
impl_
)
release
();
}
void
temp_viz
::
Widget
::
create
()
{
if
(
impl_
)
release
();
impl_
=
new
Impl
();
impl_
->
ref_counter
=
1
;
}
void
temp_viz
::
Widget
::
release
()
{
if
(
impl_
&&
CV_XADD
(
&
impl_
->
ref_counter
,
-
1
)
==
1
)
{
delete
impl_
;
impl_
=
0
;
}
}
// class temp_viz::Widget::Impl
// {
// public:
// vtkSmartPointer<vtkProp> actor;
// int ref_counter;
//
// Impl() : actor(vtkSmartPointer<vtkLODActor>::New()) {}
//
// Impl(bool text_widget)
// {
// if (text_widget)
// actor = vtkSmartPointer<vtkTextActor>::New();
// else
// actor = vtkSmartPointer<vtkLeaderActor2D>::New();
// }
//
// void setColor(const Color& color)
// {
// vtkLODActor *lod_actor = vtkLODActor::SafeDownCast(actor);
// Color c = vtkcolor(color);
// lod_actor->GetMapper ()->ScalarVisibilityOff ();
// lod_actor->GetProperty ()->SetColor (c.val);
// lod_actor->GetProperty ()->SetEdgeColor (c.val);
// lod_actor->GetProperty ()->SetAmbient (0.8);
// lod_actor->GetProperty ()->SetDiffuse (0.8);
// lod_actor->GetProperty ()->SetSpecular (0.8);
// lod_actor->GetProperty ()->SetLighting (0);
// lod_actor->Modified ();
// }
//
// void setPose(const Affine3f& pose)
// {
// vtkLODActor *lod_actor = vtkLODActor::SafeDownCast(actor);
// vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
// lod_actor->SetUserMatrix (matrix);
// lod_actor->Modified ();
// }
//
// void updatePose(const Affine3f& pose)
// {
// vtkLODActor *lod_actor = vtkLODActor::SafeDownCast(actor);
// vtkSmartPointer<vtkMatrix4x4> matrix = lod_actor->GetUserMatrix();
// if (!matrix)
// {
// setPose(pose);
// return ;
// }
// Matx44f matrix_cv = convertToMatx(matrix);
//
// Affine3f updated_pose = pose * Affine3f(matrix_cv);
// matrix = convertToVtkMatrix(updated_pose.matrix);
//
// lod_actor->SetUserMatrix (matrix);
// lod_actor->Modified ();
// }
//
// Affine3f getPose() const
// {
// vtkLODActor *lod_actor = vtkLODActor::SafeDownCast(actor);
// vtkSmartPointer<vtkMatrix4x4> matrix = lod_actor->GetUserMatrix();
// Matx44f matrix_cv = convertToMatx(matrix);
// return Affine3f(matrix_cv);
// }
//
// protected:
//
// static vtkSmartPointer<vtkMatrix4x4> convertToVtkMatrix (const cv::Matx44f& m)
// {
// vtkSmartPointer<vtkMatrix4x4> vtk_matrix = vtkSmartPointer<vtkMatrix4x4>::New ();
// for (int i = 0; i < 4; i++)
// for (int k = 0; k < 4; k++)
// vtk_matrix->SetElement(i, k, m(i, k));
// return vtk_matrix;
// }
//
// static cv::Matx44f convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matrix)
// {
// cv::Matx44f m;
// for (int i = 0; i < 4; i++)
// for (int k = 0; k < 4; k++)
// m(i, k) = vtk_matrix->GetElement (i, k);
// return m;
// }
// };
///////////////////////////////////////////////////////////////////////////////////////////////
///
stream
accessor implementaion
///
widget
accessor implementaion
vtkSmartPointer
<
vtkProp
>
temp_viz
::
WidgetAccessor
::
getActor
(
const
Widget
&
widget
)
{
...
...
@@ -165,11 +91,6 @@ struct temp_viz::Widget3D::MatrixConverter
}
};
temp_viz
::
Widget3D
::
Widget3D
()
{
}
void
temp_viz
::
Widget3D
::
setPose
(
const
Affine3f
&
pose
)
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getActor
(
*
this
));
...
...
@@ -226,11 +147,3 @@ void temp_viz::Widget3D::setColor(const Color &color)
actor
->
GetProperty
()
->
SetLighting
(
0
);
actor
->
Modified
();
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget2D implementation
temp_viz
::
Widget2D
::
Widget2D
()
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment