Skip to content

Commit f6d5a1d

Browse files
committed
Merge pull request opencv#7727 from alalek:backport_7536
2 parents 979b0ae + 11b642f commit f6d5a1d

File tree

5 files changed

+87
-171
lines changed

5 files changed

+87
-171
lines changed
Lines changed: 82 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,62 @@
11
/*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-
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
42-
//
43-
// This workaround code was taken from PCL library(www.pointclouds.org)
44-
//
45-
// Modified by Jasper Shemilt to work with VTK 6.2
46-
// The fix was needed because GetCocoaServer has been moved from
47-
// vtkCocoaRenderWindowInteractor to vtkCocoaRenderWindow in VTK 6.2.
48-
// This alteration to VTK happened almost a year ago according to the gitHub
49-
// commit a3e9fc9.
50-
//
51-
//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+
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
42+
//
43+
// This workaround code was taken from PCL library(www.pointclouds.org)
44+
//
45+
//M*/
5246

5347
#import <Cocoa/Cocoa.h>
5448
#include <vtkCocoaRenderWindow.h>
5549
#include <vtkCocoaRenderWindowInteractor.h>
5650
#include <vtkObjectFactory.h>
5751
#include <vtkSmartPointer.h>
5852

53+
namespace cv { namespace viz {
54+
vtkSmartPointer<vtkRenderWindowInteractor> vtkCocoaRenderWindowInteractorNew();
55+
}} // namespace
56+
57+
#if ((VTK_MAJOR_VERSION < 6) || ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION < 2)))
58+
59+
5960
//----------------------------------------------------------------------------
6061
@interface vtkCocoaServerFix : NSObject
6162
{
@@ -124,14 +125,14 @@ - (void)breakEventLoop
124125
[application stop:application];
125126

126127
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
127-
location:NSMakePoint(0.0,0.0)
128-
modifierFlags:0
129-
timestamp:0
130-
windowNumber:-1
131-
context:nil
132-
subtype:0
133-
data1:0
134-
data2:0];
128+
location:NSMakePoint(0.0,0.0)
129+
modifierFlags:0
130+
timestamp:0
131+
windowNumber:-1
132+
context:nil
133+
subtype:0
134+
data1:0
135+
data2:0];
135136
[application postEvent:event atStart:YES];
136137
}
137138

@@ -160,121 +161,28 @@ - (void)windowWillClose:(NSNotification*)aNotification
160161

161162
//----------------------------------------------------------------------------
162163

163-
#if VTK_MAJOR_VERSION >= 6 && VTK_MINOR_VERSION >=2
164-
165164
namespace cv { namespace viz
166-
{
167-
class vtkCocoaRenderWindowInteractorFix : public vtkCocoaRenderWindowInteractor
168-
{
169-
public:
170-
static vtkCocoaRenderWindowInteractorFix *New ();
171-
vtkTypeMacro (vtkCocoaRenderWindowInteractorFix, vtkCocoaRenderWindowInteractor)
172-
173-
virtual void Start ();
174-
virtual void TerminateApp ();
175-
176-
protected:
177-
vtkCocoaRenderWindowInteractorFix () {}
178-
~vtkCocoaRenderWindowInteractorFix () {}
179-
180-
private:
181-
vtkCocoaRenderWindowInteractorFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
182-
void operator = (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
183-
};
184-
185-
vtkStandardNewMacro (vtkCocoaRenderWindowInteractorFix)
186-
187-
vtkSmartPointer<vtkRenderWindowInteractor> vtkCocoaRenderWindowInteractorNew();
188-
189-
class vtkCocoaRenderWindowFix : public vtkCocoaRenderWindow
190-
{
191-
public:
192-
static vtkCocoaRenderWindowFix *New ();
193-
vtkTypeMacro ( vtkCocoaRenderWindowFix, vtkCocoaRenderWindow)
194-
195-
virtual vtkCocoaServerFix * GetCocoaServer ();
196-
virtual void SetCocoaServer (void* );
197-
198-
protected:
199-
vtkCocoaRenderWindowFix () {}
200-
~vtkCocoaRenderWindowFix () {}
201-
202-
private:
203-
vtkCocoaRenderWindowFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
204-
void operator = (const vtkCocoaRenderWindowFix&); // Not implemented.
205-
};
206-
207-
vtkStandardNewMacro (vtkCocoaRenderWindowFix)
208-
209-
vtkSmartPointer<vtkRenderWindow> vtkCocoaRenderWindowNew();
210-
}}
211-
212-
vtkCocoaServerFix * cv::viz::vtkCocoaRenderWindowFix::GetCocoaServer ()
213-
{
214-
return reinterpret_cast<vtkCocoaServerFix*> (this->GetCocoaServer ());
215-
}
216-
217-
void cv::viz::vtkCocoaRenderWindowFix::SetCocoaServer (void* server)
218-
{
219-
this->SetCocoaServer (server);
220-
}
221-
222-
void cv::viz::vtkCocoaRenderWindowInteractorFix::Start ()
223-
{
224-
vtkCocoaRenderWindowFix* renWin = vtkCocoaRenderWindowFix::SafeDownCast(this->GetRenderWindow ());
225-
if (renWin != NULL)
226-
{
227-
vtkCocoaServerFix *server = reinterpret_cast<vtkCocoaServerFix*> (renWin->GetCocoaServer ());
228-
if (!renWin->GetCocoaServer ())
229-
{
230-
server = [vtkCocoaServerFix cocoaServerWithRenderWindow:renWin];
231-
renWin->SetCocoaServer (reinterpret_cast<void*> (server));
232-
}
233-
234-
[server start];
235-
}
236-
}
237-
238-
void cv::viz::vtkCocoaRenderWindowInteractorFix::TerminateApp ()
239-
{
240-
vtkCocoaRenderWindowFix *renWin = vtkCocoaRenderWindowFix::SafeDownCast (this->RenderWindow);
241-
if (renWin)
242-
{
243-
vtkCocoaServerFix *server = reinterpret_cast<vtkCocoaServerFix*> (renWin->GetCocoaServer ());
244-
[server stop];
245-
}
246-
}
247-
248-
vtkSmartPointer<vtkRenderWindowInteractor> cv::viz::vtkCocoaRenderWindowInteractorNew()
249165
{
250-
return vtkSmartPointer<vtkCocoaRenderWindowInteractorFix>::New();
251-
}
252-
253-
#else
254-
namespace cv { namespace viz
166+
class vtkCocoaRenderWindowInteractorFix : public vtkCocoaRenderWindowInteractor
255167
{
256-
class vtkCocoaRenderWindowInteractorFix : public vtkCocoaRenderWindowInteractor
257-
{
258-
public:
259-
static vtkCocoaRenderWindowInteractorFix *New ();
260-
vtkTypeMacro (vtkCocoaRenderWindowInteractorFix, vtkCocoaRenderWindowInteractor)
261-
262-
virtual void Start ();
263-
virtual void TerminateApp ();
168+
public:
169+
static vtkCocoaRenderWindowInteractorFix *New ();
170+
vtkTypeMacro (vtkCocoaRenderWindowInteractorFix, vtkCocoaRenderWindowInteractor)
264171

265-
protected:
266-
vtkCocoaRenderWindowInteractorFix () {}
267-
~vtkCocoaRenderWindowInteractorFix () {}
172+
virtual void Start ();
173+
virtual void TerminateApp ();
268174

269-
private:
270-
vtkCocoaRenderWindowInteractorFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
271-
void operator = (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
272-
};
175+
protected:
176+
vtkCocoaRenderWindowInteractorFix () {}
177+
~vtkCocoaRenderWindowInteractorFix () {}
273178

274-
vtkStandardNewMacro (vtkCocoaRenderWindowInteractorFix)
179+
private:
180+
vtkCocoaRenderWindowInteractorFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
181+
void operator = (const vtkCocoaRenderWindowInteractorFix&); // Not implemented.
182+
};
275183

276-
vtkSmartPointer<vtkRenderWindowInteractor> vtkCocoaRenderWindowInteractorNew();
277-
}}
184+
vtkStandardNewMacro (vtkCocoaRenderWindowInteractorFix)
185+
}}
278186

279187
void cv::viz::vtkCocoaRenderWindowInteractorFix::Start ()
280188
{
@@ -307,4 +215,12 @@ - (void)windowWillClose:(NSNotification*)aNotification
307215
return vtkSmartPointer<vtkCocoaRenderWindowInteractorFix>::New();
308216
}
309217

218+
219+
#else
220+
221+
vtkSmartPointer<vtkRenderWindowInteractor> cv::viz::vtkCocoaRenderWindowInteractorNew()
222+
{
223+
return vtkSmartPointer<vtkCocoaRenderWindowInteractor>::New();
224+
}
225+
310226
#endif

samples/cpp/tutorial_code/viz/creating_widgets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace std;
2424
* @function help
2525
* @brief Display instructions to use this tutorial program
2626
*/
27-
void help()
27+
static void help()
2828
{
2929
cout
3030
<< "--------------------------------------------------------------------------" << endl

samples/cpp/tutorial_code/viz/launching_viz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace std;
1414
* @function help
1515
* @brief Display instructions to use this tutorial program
1616
*/
17-
void help()
17+
static void help()
1818
{
1919
cout
2020
<< "--------------------------------------------------------------------------" << endl

samples/cpp/tutorial_code/viz/transformations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace std;
1515
* @function help
1616
* @brief Display instructions to use this tutorial program
1717
*/
18-
void help()
18+
static void help()
1919
{
2020
cout
2121
<< "--------------------------------------------------------------------------" << endl
@@ -31,7 +31,7 @@ void help()
3131
* @function cvcloud_load
3232
* @brief load bunny.ply
3333
*/
34-
Mat cvcloud_load()
34+
static Mat cvcloud_load()
3535
{
3636
Mat cloud(1, 1889, CV_32FC3);
3737
ifstream ifs("bunny.ply");

samples/cpp/tutorial_code/viz/widget_pose.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace std;
1515
* @function help
1616
* @brief Display instructions to use this tutorial program
1717
*/
18-
void help()
18+
static void help()
1919
{
2020
cout
2121
<< "--------------------------------------------------------------------------" << endl

0 commit comments

Comments
 (0)