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
158ed299
Commit
158ed299
authored
Jul 04, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reference counting in widget
parent
141cfd56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+7
-1
widget.cpp
modules/viz/src/widget.cpp
+30
-4
No files found.
modules/viz/include/opencv2/viz/widgets.hpp
View file @
158ed299
...
...
@@ -14,6 +14,8 @@ namespace temp_viz
Widget
(
const
Widget
&
other
);
Widget
&
operator
=
(
const
Widget
&
other
);
~
Widget
();
void
copyTo
(
Widget
&
dst
);
void
setColor
(
const
Color
&
color
);
...
...
@@ -23,7 +25,11 @@ namespace temp_viz
private
:
class
Impl
;
cv
::
Ptr
<
Impl
>
impl_
;
Impl
*
impl_
;
void
create
();
void
release
();
friend
struct
WidgetAccessor
;
};
...
...
modules/viz/src/widget.cpp
View file @
158ed299
...
...
@@ -4,6 +4,7 @@ class temp_viz::Widget::Impl
{
public
:
vtkSmartPointer
<
vtkLODActor
>
actor
;
int
ref_counter
;
Impl
()
:
actor
(
vtkSmartPointer
<
vtkLODActor
>::
New
())
{}
...
...
@@ -79,23 +80,34 @@ vtkSmartPointer<vtkLODActor> temp_viz::WidgetAccessor::getActor(const Widget& wi
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget implementaion
temp_viz
::
Widget
::
Widget
()
temp_viz
::
Widget
::
Widget
()
:
impl_
(
0
)
{
impl_
=
new
Impl
();
create
();
}
temp_viz
::
Widget
::
Widget
(
const
Widget
&
other
)
temp_viz
::
Widget
::
Widget
(
const
Widget
&
other
)
:
impl_
(
other
.
impl_
)
{
impl_
=
other
.
impl_
;
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
temp_viz
::
Widget
&
temp_viz
::
Widget
::
operator
=
(
const
Widget
&
other
)
{
if
(
this
!=
&
other
)
{
release
();
impl_
=
other
.
impl_
;
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
return
*
this
;
}
temp_viz
::
Widget
::~
Widget
()
{
release
();
}
void
temp_viz
::
Widget
::
copyTo
(
Widget
&
/*dst*/
)
{
// TODO Deep copy the data if there is any
...
...
@@ -106,5 +118,19 @@ void temp_viz::Widget::setPose(const Affine3f& pose) { impl_->setPose(pose); }
void
temp_viz
::
Widget
::
updatePose
(
const
Affine3f
&
pose
)
{
impl_
->
updatePose
(
pose
);
}
temp_viz
::
Affine3f
temp_viz
::
Widget
::
getPose
()
const
{
return
impl_
->
getPose
();
}
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_
;
}
}
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