![]() |
rtVTK
0.6.0
|
00001 00002 /****************************************************************************** 00003 * Copyright (c) 2012, Grove City College 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * * Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * * Neither the name of Grove City College nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 */ 00035 00036 00043 #ifndef StandAlone_Plugin_h 00044 #define StandAlone_Plugin_h 00045 00046 #include <iostream> 00047 using std::ostream; 00048 00049 #include <string> 00050 using std::string; 00051 00052 #include <Core/Types.h> 00053 00054 00056 // Forward declarations 00057 00058 class QGridLayout; 00059 class QWidget; 00060 00061 namespace uiCore 00062 { 00063 00064 class Camera; 00065 00066 } // namespace uiCore 00067 00068 namespace Core 00069 { 00070 00071 class Mesh; 00072 00073 } // namespace Core 00074 00078 namespace rtVTK 00079 { 00080 00082 // Forward declarations 00083 00084 class MainWindow; 00085 00086 00088 // Using declarations 00089 00090 using uiCore::Camera; 00091 00092 using Core::Mesh; 00093 00094 00096 // Structure definition 00097 00100 struct Plugin 00101 { 00103 // Type definitions 00104 00125 typedef void* (*Create)( MainWindow *const, 00126 const Camera&, 00127 const Mesh&, 00128 QWidget*); 00129 // QGridLayout*); 00130 00140 typedef void* (*Init)(void*); 00141 00151 typedef void (*Resize)(void*, uint, uint); 00152 00160 typedef void (*Render)(void*); 00161 00171 typedef void (*Close)(void*); 00172 00181 typedef void (*Idle)(void*); 00182 00198 typedef bool (*TraceRay)(void*,int,int); 00199 00205 typedef uint PluginID; 00206 00211 Plugin() : 00212 id(idCounter++), 00213 create(0), 00214 init(0), 00215 resize(0), 00216 render(0), 00217 closer(0), 00218 idle(0), 00219 traceRay(0), 00220 ptr(0), 00221 name(""), 00222 requiresTab(false), 00223 initialized(false) 00224 { 00225 // no-op 00226 } 00227 00228 00230 // Wrappers to invoke interface functions on plugin objects 00236 void callCreate( MainWindow *const mw, 00237 const Camera& camera, 00238 const Mesh& mesh, 00239 QWidget* sa_contents) 00240 // QGridLayout* layout) 00241 { 00242 // ptr = create(mw, camera, mesh, layout); 00243 ptr = create(mw, camera, mesh, sa_contents); 00244 } 00245 00246 void callInit() 00247 { 00248 init(ptr); 00249 } 00250 00251 void callResize(uint w, uint h) 00252 { 00253 resize(ptr, w, h); 00254 } 00255 00256 void callRender() 00257 { 00258 render(ptr); 00259 } 00260 00261 void callClose() 00262 { 00263 closer(ptr); 00264 } 00265 00266 void callIdle() 00267 { 00268 idle(ptr); 00269 } 00270 00271 bool callTraceRay(int x, int y) 00272 { 00273 return traceRay(ptr,x,y); 00274 } 00276 00277 00279 // Stream I/O 00280 00288 friend ostream& operator<<(ostream& out, const Plugin& plugin) 00289 { 00290 out << "(\"" << plugin.name << "\", " << plugin.ptr << ')'; 00291 return out; 00292 } 00293 00294 00296 // Data members 00297 00301 const PluginID id; 00302 00308 Create create; 00309 Init init; 00310 Resize resize; 00311 Render render; 00312 Close closer; 00313 Idle idle; 00314 TraceRay traceRay; 00316 00322 void* ptr; 00323 00328 string name; 00329 00330 bool requiresTab; 00331 bool initialized; 00332 00337 static PluginID idCounter; 00338 }; // class Plugin 00339 00340 00341 } // namespace rtVTK 00342 00343 #endif // StandAlone_Plugin_h