~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/modules/viz/src/viz3d.cpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*M///////////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
 
4
//
 
5
//  By downloading, copying, installing or using the software you agree to this license.
 
6
//  If you do not agree to this license, do not download, install,
 
7
//  copy or use the software.
 
8
//
 
9
//
 
10
//                           License Agreement
 
11
//                For Open Source Computer Vision Library
 
12
//
 
13
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
 
14
// Third party copyrights are property of their respective owners.
 
15
//
 
16
// Redistribution and use in source and binary forms, with or without modification,
 
17
// are permitted provided that the following conditions are met:
 
18
//
 
19
//   * Redistribution's of source code must retain the above copyright notice,
 
20
//     this list of conditions and the following disclaimer.
 
21
//
 
22
//   * Redistribution's in binary form must reproduce the above copyright notice,
 
23
//     this list of conditions and the following disclaimer in the documentation
 
24
//     and/or other materials provided with the distribution.
 
25
//
 
26
//   * The name of the copyright holders may not be used to endorse or promote products
 
27
//     derived from this software without specific prior written permission.
 
28
//
 
29
// This software is provided by the copyright holders and contributors "as is" and
 
30
// any express or implied warranties, including, but not limited to, the implied
 
31
// warranties of merchantability and fitness for a particular purpose are disclaimed.
 
32
// In no event shall the Intel Corporation or contributors be liable for any direct,
 
33
// indirect, incidental, special, exemplary, or consequential damages
 
34
// (including, but not limited to, procurement of substitute goods or services;
 
35
// loss of use, data, or profits; or business interruption) however caused
 
36
// and on any theory of liability, whether in contract, strict liability,
 
37
// or tort (including negligence or otherwise) arising in any way out of
 
38
// the use of this software, even if advised of the possibility of such damage.
 
39
//
 
40
// Authors:
 
41
//  * Ozan Tonkal, ozantonkal@gmail.com
 
42
//  * Anatoly Baksheev, Itseez Inc.  myname.mysurname <> mycompany.com
 
43
//
 
44
//M*/
 
45
 
 
46
#include "precomp.hpp"
 
47
 
 
48
cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name); }
 
49
 
 
50
cv::viz::Viz3d::Viz3d(const Viz3d& other) : impl_(other.impl_)
 
51
{
 
52
    if (impl_)
 
53
        CV_XADD(&impl_->ref_counter, 1);
 
54
}
 
55
 
 
56
cv::viz::Viz3d& cv::viz::Viz3d::operator=(const Viz3d& other)
 
57
{
 
58
    if (this != &other)
 
59
    {
 
60
        release();
 
61
        impl_ = other.impl_;
 
62
        if (impl_)
 
63
            CV_XADD(&impl_->ref_counter, 1);
 
64
    }
 
65
    return *this;
 
66
}
 
67
 
 
68
cv::viz::Viz3d::~Viz3d() { release(); }
 
69
 
 
70
void cv::viz::Viz3d::create(const String &window_name)
 
71
{
 
72
    if (impl_)
 
73
        release();
 
74
 
 
75
    if (VizStorage::windowExists(window_name))
 
76
        *this = VizStorage::get(window_name);
 
77
    else
 
78
    {
 
79
        impl_ = new VizImpl(window_name);
 
80
        impl_->ref_counter = 1;
 
81
 
 
82
        // Register the window
 
83
        VizStorage::add(*this);
 
84
    }
 
85
}
 
86
 
 
87
void cv::viz::Viz3d::release()
 
88
{
 
89
    if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1)
 
90
    {
 
91
        delete impl_;
 
92
        impl_ = 0;
 
93
    }
 
94
 
 
95
    if (impl_ && impl_->ref_counter == 1)
 
96
        VizStorage::removeUnreferenced();
 
97
 
 
98
    impl_ = 0;
 
99
}
 
100
 
 
101
void cv::viz::Viz3d::spin() { impl_->spin(); }
 
102
void cv::viz::Viz3d::spinOnce(int time, bool force_redraw) { impl_->spinOnce(time, force_redraw); }
 
103
void cv::viz::Viz3d::setOffScreenRendering() { impl_->setOffScreenRendering(); }
 
104
void cv::viz::Viz3d::removeAllLights() { impl_->removeAllLights(); }
 
105
void cv::viz::Viz3d::addLight(Vec3d position, Vec3d focalPoint, Color color, Color diffuseColor, Color ambientColor, Color specularColor)
 
106
{  impl_->addLight(position, focalPoint, color, diffuseColor, ambientColor, specularColor);  }
 
107
bool cv::viz::Viz3d::wasStopped() const { return impl_->wasStopped(); }
 
108
void cv::viz::Viz3d::close() { impl_->close(); }
 
109
 
 
110
void cv::viz::Viz3d::registerKeyboardCallback(KeyboardCallback callback, void* cookie)
 
111
{ impl_->registerKeyboardCallback(callback, cookie); }
 
112
 
 
113
void cv::viz::Viz3d::registerMouseCallback(MouseCallback callback, void* cookie)
 
114
{ impl_->registerMouseCallback(callback, cookie); }
 
115
 
 
116
void cv::viz::Viz3d::showWidget(const String &id, const Widget &widget, const Affine3d &pose) { impl_->showWidget(id, widget, pose); }
 
117
void cv::viz::Viz3d::removeWidget(const String &id) { impl_->removeWidget(id); }
 
118
cv::viz::Widget cv::viz::Viz3d::getWidget(const String &id) const { return impl_->getWidget(id); }
 
119
void cv::viz::Viz3d::removeAllWidgets() { impl_->removeAllWidgets(); }
 
120
 
 
121
void cv::viz::Viz3d::showImage(InputArray image, const Size& window_size) { impl_->showImage(image, window_size); }
 
122
 
 
123
void cv::viz::Viz3d::setWidgetPose(const String &id, const Affine3d &pose) { impl_->setWidgetPose(id, pose); }
 
124
void cv::viz::Viz3d::updateWidgetPose(const String &id, const Affine3d &pose) { impl_->updateWidgetPose(id, pose); }
 
125
cv::Affine3d cv::viz::Viz3d::getWidgetPose(const String &id) const { return impl_->getWidgetPose(id); }
 
126
 
 
127
void cv::viz::Viz3d::setCamera(const Camera &camera) { impl_->setCamera(camera); }
 
128
cv::viz::Camera cv::viz::Viz3d::getCamera() const { return impl_->getCamera(); }
 
129
void cv::viz::Viz3d::setViewerPose(const Affine3d &pose) { impl_->setViewerPose(pose); }
 
130
cv::Affine3d cv::viz::Viz3d::getViewerPose() { return impl_->getViewerPose(); }
 
131
 
 
132
void cv::viz::Viz3d::resetCameraViewpoint(const String &id) { impl_->resetCameraViewpoint(id); }
 
133
void cv::viz::Viz3d::resetCamera() { impl_->resetCamera(); }
 
134
 
 
135
void cv::viz::Viz3d::convertToWindowCoordinates(const Point3d &pt, Point3d &window_coord) { impl_->convertToWindowCoordinates(pt, window_coord); }
 
136
void cv::viz::Viz3d::converTo3DRay(const Point3d &window_coord, Point3d &origin, Vec3d &direction) { impl_->converTo3DRay(window_coord, origin, direction); }
 
137
 
 
138
cv::Size cv::viz::Viz3d::getWindowSize() const { return impl_->getWindowSize(); }
 
139
void cv::viz::Viz3d::setWindowSize(const Size &window_size) { impl_->setWindowSize(window_size); }
 
140
cv::String cv::viz::Viz3d::getWindowName() const { return impl_->getWindowName(); }
 
141
cv::Mat cv::viz::Viz3d::getScreenshot() const { return impl_->getScreenshot(); }
 
142
void cv::viz::Viz3d::saveScreenshot(const String &file) { impl_->saveScreenshot(file); }
 
143
void cv::viz::Viz3d::setWindowPosition(const Point& window_position) { impl_->setWindowPosition(window_position); }
 
144
void cv::viz::Viz3d::setFullScreen(bool mode) { impl_->setFullScreen(mode); }
 
145
void cv::viz::Viz3d::setBackgroundColor(const Color& color, const Color& color2) { impl_->setBackgroundColor(color, color2); }
 
146
 
 
147
void cv::viz::Viz3d::setBackgroundTexture(InputArray image) { impl_->setBackgroundTexture(image); }
 
148
void cv::viz::Viz3d::setBackgroundMeshLab() {impl_->setBackgroundMeshLab(); }
 
149
 
 
150
void cv::viz::Viz3d::setRenderingProperty(const String &id, int property, double value) { getWidget(id).setRenderingProperty(property, value); }
 
151
double cv::viz::Viz3d::getRenderingProperty(const String &id, int property) { return getWidget(id).getRenderingProperty(property); }
 
152
 
 
153
void cv::viz::Viz3d::setRepresentation(int representation) { impl_->setRepresentation(representation); }
 
154
 
 
155
void cv::viz::Viz3d::setGlobalWarnings(bool enabled) { vtkObject::SetGlobalWarningDisplay(enabled ? 1 : 0); }