|
1 | 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 |
| - // * 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*/ |
52 | 46 |
|
53 | 47 | #import <Cocoa/Cocoa.h>
|
54 | 48 | #include <vtkCocoaRenderWindow.h>
|
55 | 49 | #include <vtkCocoaRenderWindowInteractor.h>
|
56 | 50 | #include <vtkObjectFactory.h>
|
57 | 51 | #include <vtkSmartPointer.h>
|
58 | 52 |
|
| 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 | + |
59 | 60 | //----------------------------------------------------------------------------
|
60 | 61 | @interface vtkCocoaServerFix : NSObject
|
61 | 62 | {
|
@@ -124,14 +125,14 @@ - (void)breakEventLoop
|
124 | 125 | [application stop:application];
|
125 | 126 |
|
126 | 127 | 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]; |
135 | 136 | [application postEvent:event atStart:YES];
|
136 | 137 | }
|
137 | 138 |
|
@@ -160,121 +161,28 @@ - (void)windowWillClose:(NSNotification*)aNotification
|
160 | 161 |
|
161 | 162 | //----------------------------------------------------------------------------
|
162 | 163 |
|
163 |
| -#if VTK_MAJOR_VERSION >= 6 && VTK_MINOR_VERSION >=2 |
164 |
| - |
165 | 164 | 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() |
249 | 165 | {
|
250 |
| - return vtkSmartPointer<vtkCocoaRenderWindowInteractorFix>::New(); |
251 |
| -} |
252 |
| - |
253 |
| -#else |
254 |
| -namespace cv { namespace viz |
| 166 | + class vtkCocoaRenderWindowInteractorFix : public vtkCocoaRenderWindowInteractor |
255 | 167 | {
|
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) |
264 | 171 |
|
265 |
| - protected: |
266 |
| - vtkCocoaRenderWindowInteractorFix () {} |
267 |
| - ~vtkCocoaRenderWindowInteractorFix () {} |
| 172 | + virtual void Start (); |
| 173 | + virtual void TerminateApp (); |
268 | 174 |
|
269 |
| - private: |
270 |
| - vtkCocoaRenderWindowInteractorFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented. |
271 |
| - void operator = (const vtkCocoaRenderWindowInteractorFix&); // Not implemented. |
272 |
| - }; |
| 175 | + protected: |
| 176 | + vtkCocoaRenderWindowInteractorFix () {} |
| 177 | + ~vtkCocoaRenderWindowInteractorFix () {} |
273 | 178 |
|
274 |
| - vtkStandardNewMacro (vtkCocoaRenderWindowInteractorFix) |
| 179 | + private: |
| 180 | + vtkCocoaRenderWindowInteractorFix (const vtkCocoaRenderWindowInteractorFix&); // Not implemented. |
| 181 | + void operator = (const vtkCocoaRenderWindowInteractorFix&); // Not implemented. |
| 182 | + }; |
275 | 183 |
|
276 |
| - vtkSmartPointer<vtkRenderWindowInteractor> vtkCocoaRenderWindowInteractorNew(); |
277 |
| - }} |
| 184 | + vtkStandardNewMacro (vtkCocoaRenderWindowInteractorFix) |
| 185 | +}} |
278 | 186 |
|
279 | 187 | void cv::viz::vtkCocoaRenderWindowInteractorFix::Start ()
|
280 | 188 | {
|
@@ -307,4 +215,12 @@ - (void)windowWillClose:(NSNotification*)aNotification
|
307 | 215 | return vtkSmartPointer<vtkCocoaRenderWindowInteractorFix>::New();
|
308 | 216 | }
|
309 | 217 |
|
| 218 | + |
| 219 | +#else |
| 220 | + |
| 221 | +vtkSmartPointer<vtkRenderWindowInteractor> cv::viz::vtkCocoaRenderWindowInteractorNew() |
| 222 | +{ |
| 223 | + return vtkSmartPointer<vtkCocoaRenderWindowInteractor>::New(); |
| 224 | +} |
| 225 | + |
310 | 226 | #endif
|
0 commit comments