![]() |
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 00044 #ifndef StandAlone_MainWindow_h 00045 #define StandAlone_MainWindow_h 00046 00047 #include <set> 00048 using std::set; 00049 00050 #include <vector> 00051 using std::vector; 00052 00053 #include <map> 00054 using std::map; 00055 00056 #include <QMainWindow> 00057 00058 #include <Core/ioCore/Scene.h> 00059 #include <Core/uiCore/Camera.h> 00060 00061 #include <RL/RayLogger.h> 00062 00063 #include <StandAlone/Configuration.h> 00064 #include <StandAlone/Plugin.h> 00065 00066 00068 // Forward declarations 00069 00070 class QGridLayout; 00071 class QLabel; 00072 class QLayout; 00073 class QScrollArea; 00074 class QShortcut; 00075 class QTimer; 00076 class QWidget; 00077 00078 namespace Ui 00079 { 00080 00081 class MainWindow; 00082 00083 } // namespace Ui 00084 00085 namespace ioCore 00086 { 00087 00088 struct Options; 00089 class Scene; 00090 00091 } // namespace ioCore 00092 00093 namespace uiCore 00094 { 00095 00096 class Camera; 00097 00098 } // namespace uiCore 00099 00100 namespace Core 00101 { 00102 00103 class Mesh; 00104 00105 } // namespace Core 00106 00107 namespace rtVTK 00108 { 00109 00111 // Forward declarations 00112 00113 class Configuration; 00114 class Documentation; 00115 class AboutDialog; 00116 class glWidget; 00117 class PipelineDialog; 00118 class PluginManager; 00119 class RenderWindow; 00120 class TimerDialog; 00121 00122 00124 // Using declarations 00125 00126 using ioCore::Options; 00127 using ioCore::Scene; 00128 00129 using uiCore::Camera; 00130 00131 using Core::Mesh; 00132 00134 // Class definition 00135 00137 class MainWindow : public QMainWindow 00138 { 00139 Q_OBJECT 00140 00141 public: 00142 00144 // Public members 00145 00146 explicit MainWindow(const Configuration&, QWidget* = 0); 00147 00148 ~MainWindow(); 00149 00150 glWidget const * getGLW() const { return glw; } 00151 rl::RayLogger* getRL() const { return &rlRayLogger; } 00152 00153 void show(); 00154 00172 const set<QKeySequence>* const getTakenKeyCombos() const 00173 { 00174 return &keyCombos; 00175 } 00176 00177 // Claim and Release shortcuts interface (w/overloads) for plugins to use. 00188 inline bool claimKeyCombo(const QObject* requester_, 00189 const QString& shortcut_) 00190 { 00191 QKeySequence claimingKey(shortcut_); 00192 00193 return claimKeyCombo(requester_, claimingKey); 00194 } 00206 inline bool claimKeyCombo(const QObject* requester_, 00207 const QKeySequence& shortcut_) 00208 { 00209 // Don't accept the claim if the shortcut already exists. 00210 if (keyCombos.find(shortcut_) != keyCombos.end()) 00211 { 00212 // Not a successful claim. 00213 return false; 00214 } 00215 00216 // Else claimingKey is ready to claim. 00217 keyCombos.insert(shortcut_); 00218 pluginShortcutOwnership[shortcut_] = requester_; 00219 00220 // Claim successful. 00221 return true; 00222 } 00223 00233 inline bool releaseKeyCombo(const QObject* requester_, 00234 const QString& shortcut_) 00235 { 00236 QKeySequence existingKey(shortcut_); 00237 00238 return releaseKeyCombo(requester_, existingKey); 00239 } 00240 00252 inline bool releaseKeyCombo(const QObject* requester_, 00253 const QKeySequence& shortcut_) 00254 { 00255 // Verify shortcut existence. 00256 if(keyCombos.find(shortcut_) == keyCombos.end()) 00257 { 00258 // Not a successful release because the shortcut couldn't be found. 00259 return false; 00260 } 00261 00262 // If shortcut is assigned to a plugin then verify ownership of shortcut. 00263 if(pluginShortcutOwnership.find(shortcut_) != pluginShortcutOwnership.end() && 00264 pluginShortcutOwnership[shortcut_] != requester_) 00265 { 00266 // Not a successful release because the requester_ wasn't the owner. 00267 return false; 00268 } 00269 00270 // Safe to remove shortcut from the records. 00271 keyCombos.erase(shortcut_); 00272 pluginShortcutOwnership.erase(shortcut_); 00273 // Successful release. 00274 return true; 00275 } 00277 00278 inline QDir getConfigDir(string str) 00279 { 00280 return config[str]; 00281 } 00282 00283 00285 // Signals 00286 00287 signals: 00288 void sgnlLoadScene(const Options&); 00289 void sgnlSetView(const Scene::ViewParameters&); 00290 void sgnlSetLookMode(uiCore::CameraMode); 00291 void sgnlActivatePlugin(Plugin*, const Mesh&, QLayout*, QWidget*); 00292 void sgnlSetRotationSpeed(float); 00293 void sgnlSetTranslationSpeed(float); 00294 void sgnlSetDollySpeed(float); 00295 void sgnlSetFOV(float); 00296 void sgnlSetBG(float, float, float); 00297 void sgnlRender(); 00298 void sgnlSetIdle(bool); 00299 void sgnlNewRay(); 00300 void sgnlCoordsChanged(QString, QString); 00301 void sgnlPauseTimers(); 00302 void sgnlUnpauseTimers(); 00303 00304 00306 // Public slots 00307 00308 public slots: 00309 void slotUpdateCoords(const Camera&); 00310 00311 00313 // Private slots 00314 00315 private slots: 00320 void slotOpenScene(); 00321 void slotLoadScene(const Options&); 00322 void slotLoadMesh(); 00323 void slotLoadView(); 00325 void slotBackground(); 00326 void slotToggleFullScreenMode(bool); 00327 void slotShowUsingDocs(); 00328 void slotShowWritingDocs(); 00329 void slotShowMainDocs(); 00330 void slotSetLookModeFocal(); 00331 void slotSetLookModeEye(); 00332 00337 void slotToggleAdvancedSettings(); 00338 void slotConvertRotationSpeed(int); 00339 void slotConvertTranslationSpeed(int); 00340 void slotConvertDollySpeed(int); 00341 void slotConvertFOV(int); 00342 void slotConvertFOV(double); 00344 00348 void slotCopyImage(); 00349 void slotSaveImage(); 00350 void slotSaveView(); 00352 00357 void slotLoadDLL(QAction*); 00358 void slotUnloadDLL(QAction*); 00359 void slotSetActivePlugins(const vector<string>&); 00360 void slotEstablishTabsForActivePlugins(const vector<string>&); 00362 00363 void slotShowPipeline(); 00364 00369 void slotIncrRotation(); 00370 void slotIncrDolly(); 00371 void slotIncrTranslation(); 00372 void slotIncrFOV(); 00373 void slotDecrRotation(); 00374 void slotDecrDolly(); 00375 void slotDecrTranslation(); 00376 void slotDecrFOV(); 00378 00379 void slotSetDefaultScene(); 00380 void slotShowAbout(); 00381 00382 void slotRestoreIdle(); 00383 void slotDisableIdle(); 00384 void slotToggleIdle(); 00385 00386 void slotPauseTimers(); 00387 void slotUnpauseTimers(); 00388 00389 void slotShowTimerDialog(); 00390 00391 void slotNewRay(); 00392 void slotResetRL(); 00393 00394 00396 // Helper functions, data members 00397 00398 private: 00399 bool eventFilter(QObject*, QEvent*); 00400 00401 void loadDefaultScene(); 00402 bool initializePlugin(Plugin*); 00403 void setShortcuts(); 00404 bool event(QEvent*); 00405 00411 Ui::MainWindow* ui; 00412 00416 PluginManager* pmgr; 00417 00423 glWidget* glw; 00424 00425 RenderWindow* winRender; 00426 00430 Documentation* winDoc; 00431 00441 vector<QShortcut*> shortcuts; 00442 00474 mutable set<QKeySequence> keyCombos; 00475 00486 // In a future release, this map container might be able replace 00487 // vector<QShortcut*> shortcuts completely. 00488 mutable map<const QKeySequence, const QObject*> pluginShortcutOwnership; 00489 00494 vector<QScrollArea*> scrollAreas; 00495 vector<QWidget*> scrollAreasContents; 00497 00501 Configuration config; 00502 00506 Scene scene; 00507 00511 Mesh mesh; 00512 00516 mutable rl::RayLogger rlRayLogger; 00517 00522 float rspeed; 00523 float tspeed; 00524 float dspeed; 00525 00526 00527 // NOTE(ejq) - the set of Plugin* in pluginToTab and pipeline are not 00528 // necessarily the same - plugins in pipeline are a subset of 00529 // plugins with tabs. 00533 map<Plugin*, QWidget*> pluginToTab; 00534 00538 vector<Plugin*> pipeline; 00539 00540 AboutDialog* dlgAbout; 00541 PipelineDialog* dlgPipeline; 00542 TimerDialog* dlgTimer; 00543 00548 bool isInSlotFullScreenMode; 00554 bool userResizedCaptured; 00555 00556 bool areThereCustomPlugins; 00557 00558 }; // class MainWindow 00559 00560 } // namespace rtVTK 00561 00562 #endif // StandAlone_MainWindow_h