1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11
// For Open Source Computer Vision Library
13
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
14
// Third party copyrights are property of their respective owners.
16
// Redistribution and use in source and binary forms, with or without modification,
17
// are permitted provided that the following conditions are met:
19
// * Redistribution's of source code must retain the above copyright notice,
20
// this list of conditions and the following disclaimer.
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.
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.
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.
41
// * Ozan Tonkal, ozantonkal@gmail.com
42
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
46
#include "precomp.hpp"
48
cv::viz::Viz3d::Viz3d(const String& window_name) : impl_(0) { create(window_name); }
50
cv::viz::Viz3d::Viz3d(const Viz3d& other) : impl_(other.impl_)
53
CV_XADD(&impl_->ref_counter, 1);
56
cv::viz::Viz3d& cv::viz::Viz3d::operator=(const Viz3d& other)
63
CV_XADD(&impl_->ref_counter, 1);
68
cv::viz::Viz3d::~Viz3d() { release(); }
70
void cv::viz::Viz3d::create(const String &window_name)
75
if (VizStorage::windowExists(window_name))
76
*this = VizStorage::get(window_name);
79
impl_ = new VizImpl(window_name);
80
impl_->ref_counter = 1;
82
// Register the window
83
VizStorage::add(*this);
87
void cv::viz::Viz3d::release()
89
if (impl_ && CV_XADD(&impl_->ref_counter, -1) == 1)
95
if (impl_ && impl_->ref_counter == 1)
96
VizStorage::removeUnreferenced();
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(); }
110
void cv::viz::Viz3d::registerKeyboardCallback(KeyboardCallback callback, void* cookie)
111
{ impl_->registerKeyboardCallback(callback, cookie); }
113
void cv::viz::Viz3d::registerMouseCallback(MouseCallback callback, void* cookie)
114
{ impl_->registerMouseCallback(callback, cookie); }
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(); }
121
void cv::viz::Viz3d::showImage(InputArray image, const Size& window_size) { impl_->showImage(image, window_size); }
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); }
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(); }
132
void cv::viz::Viz3d::resetCameraViewpoint(const String &id) { impl_->resetCameraViewpoint(id); }
133
void cv::viz::Viz3d::resetCamera() { impl_->resetCamera(); }
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); }
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); }
147
void cv::viz::Viz3d::setBackgroundTexture(InputArray image) { impl_->setBackgroundTexture(image); }
148
void cv::viz::Viz3d::setBackgroundMeshLab() {impl_->setBackgroundMeshLab(); }
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); }
153
void cv::viz::Viz3d::setRepresentation(int representation) { impl_->setRepresentation(representation); }
155
void cv::viz::Viz3d::setGlobalWarnings(bool enabled) { vtkObject::SetGlobalWarningDisplay(enabled ? 1 : 0); }