1 /* 2 * DuneApp.h 3 * 4 * Copyright (C) 1999 Stephen F. White 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program (see the file "COPYING" for details); if 18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave, 19 * Cambridge, MA 02139, USA. 20 */ 21 22 // data global to the whole application 23 24 #pragma once 25 26 // time between 2 frames in best case in milliseconds 27 #define FRAME_DELAY 70 28 29 #ifndef _LIST_H 30 #include "List.h" 31 #endif 32 #ifndef _ARRAY_H 33 #include "Array.h" 34 #endif 35 #ifndef _DUNE_STRING_H 36 #include "MyString.h" 37 #endif 38 #ifndef _NODE_H 39 #include "Node.h" 40 #endif 41 #ifndef _URL_H 42 #include "URL.h" 43 #endif 44 #ifndef _PREFERENCES_APP_H 45 #include "PreferencesApp.h" 46 #endif 47 #ifndef _ECMASCRIPT_APP_H 48 #include "EcmaScriptApp.h" 49 #endif 50 #ifndef _STEREO_VIEW_APP_H 51 #include "StereoViewApp.h" 52 #endif 53 #ifndef _INPUT_DEVICE_APP_H 54 #include "InputDeviceApp.h" 55 #endif 56 #ifndef _OUTPUT_APP_H 57 #include "OutputApp.h" 58 #endif 59 #ifndef _ROUTE_VIEW_APP_H 60 #include "RouteViewApp.h" 61 #endif 62 #ifndef _START_WITH_APP_H 63 #include "StartWithApp.h" 64 #endif 65 #ifndef _EXPORT_NAMES_APP_H 66 #include "ExportNamesApp.h" 67 #endif 68 #ifndef _MODELLING_APP_H 69 #include "ModellingApp.h" 70 #endif 71 #ifndef _RENDER_APP_H 72 #include "RenderApp.h" 73 #endif 74 75 #include <GL/gl.h> 76 77 class Scene; 78 class MainWindow; 79 class PathInt; 80 81 #define DEFAULT_TESSELLATION 31 82 83 class FileBackup { 84 public: 85 FileBackup(const char* backupFile, URL url, const char* path); 86 87 MyString m_backupFile; 88 URL m_url; 89 MyString m_path; 90 }; 91 92 class DuneApp : public PreferencesApp, 93 public EcmaScriptApp, 94 public StereoViewApp, 95 public InputDeviceApp, 96 public OutputApp, 97 public RouteViewApp, 98 public StartWithApp, 99 public ExportNamesApp, 100 public ModellingApp, 101 public RenderApp { 102 public: 103 DuneApp(); 104 105 void initPreferences(void); 106 107 // file menu 108 void newMainWnd(SWND &mainWnd); 109 void OnFileNew(int id = -1); 110 void OnFileNewWindow(); 111 void OnFilePreview(Scene* scene); 112 void OnFileUpload(Scene* scene); 113 void OnFileEdit(MainWindow *window, Scene* oldscene, 114 char* filename=NULL); 115 void OnFileClose(MainWindow *window); 116 void OnFileExit(); 117 118 bool ImportFile(const char *openpath, Scene* scene, 119 Node *node = NULL, int field = -1); 120 bool AddFile(char* openpath, Scene* scene); 121 const char* getExtension(int writeFlags); 122 123 char * SaveTempFile(Scene *scene, const char *name, 124 int writeFlags, char *wrlpath = NULL); 125 bool OpenFile(const char *path); 126 127 void reOpenWindow(Scene* scene); 128 bool checkSaveOldWindow(void); 129 void deleteOldWindow(void); 130 131 // recent files in File menu 132 int GetNumRecentFiles() const; 133 const MyString &GetRecentFile(int index) const; 134 void AddToRecentFiles(const MyString &filename); 135 void SaveRecentFileList(void); 136 137 int emergency_rescue(int sig = -1); 138 GetBrowser()139 SBROWSER GetBrowser() const { return m_browser; } GetHelpBrowser()140 SHBROWSER GetHelpBrowser() const { return m_helpBrowser; } GetTextedit()141 STEXTEDIT GetTextedit() const { return m_textedit; } GetUpload()142 SUPLOAD GetUpload() const { return m_upload; } 143 getClipboardNode(void)144 Node *getClipboardNode(void) { return m_clipboardNode; } setClipboardNode(Node * node)145 void setClipboardNode(Node* node) { m_clipboardNode = node; } removeClipboardNode(Node * node)146 void removeClipboardNode(Node* node) 147 { 148 if (m_clipboardNode == node) 149 m_clipboardNode = NULL; 150 } 151 trackAnimation(void)152 bool trackAnimation(void) { return m_trackAnimation; } setTrackAnimation(void)153 void setTrackAnimation(void) { m_trackAnimation = true; } 154 void endTrackAnimation(void); 155 156 void forgetClipBoardNode(void); 157 mainWnd(void)158 SWND mainWnd(void) {return m_mainWnd;} getCurrentMainWindow(void)159 MainWindow *getCurrentMainWindow(void) 160 { 161 List<MainWindow *>::Iterator *i = m_windows.first(); 162 if (i != NULL) 163 return i->item(); 164 else 165 return NULL; 166 } 167 168 void PrintMessageWindows(const char *text); 169 void PrintMessageWindowsId(int id); 170 void PrintMessageWindowsInt(int id, int integer); 171 void PrintMessageWindowsFloat(int id, float f); 172 void PrintMessageWindowsString(int id, const char *string); 173 void PrintMessageWindowsVertex(int id, 174 const char *fieldName, 175 int handle, Vec3f vertex); 176 177 char *loadPrompt(int prompt); 178 void MessageBox(const char *text, int prompt = -1); 179 void MessageBoxId(int id, int prompt = -1); 180 void MessageBox(int id, const char *str, int prompt = -1); 181 void MessageBox(int id, const char *str1, const char *str2, 182 int prompt = -1); 183 void MessageBox(int id, int integer, int prompt = -1); 184 void MessageBox(int id, float f, int prompt = -1); 185 void MessageBoxPerror(const char *object); 186 void MessageBoxPerror(int id, const char *object); 187 188 void AddToFilesToDelete(char* string); 189 getImportURL(void)190 MyString getImportURL(void) { return m_importURL; } setImportURL(MyString newURL)191 void setImportURL(MyString newURL) 192 { 193 m_oldImportURL = ""; 194 m_oldImportURL += m_importURL; 195 m_importURL = ""; 196 m_importURL += newURL; 197 } getImportFile(void)198 MyString getImportFile(void) { return m_importFile; } setImportFile(MyString newURL)199 void setImportFile(MyString newURL) 200 { 201 m_importFile = ""; 202 m_importFile += newURL; 203 } getOldImportURL(void)204 MyString getOldImportURL(void) { return m_oldImportURL; } 205 206 void initSelectionLinenumber(void); 207 void checkSelectionLinenumberCounting(Scene* scene, 208 Node* node); 209 void incSelectionLinenumber(int increment = 1); 210 int getSelectionLinenumber(void); 211 212 void saveTempPath(Scene* scene); 213 void restoreTempPath(Scene* scene, int i); 214 215 bool saveTempFiles(MainWindow *currentWindow, 216 int useExtensionTxt); 217 void restoreTempFiles(void); 218 219 void UpdateAllWindows(void); 220 getWindows(void)221 List<MainWindow *> getWindows(void) { return m_windows; } 222 bool hasUpload(void); 223 224 void addToProtoLibrary(char* category, char* protoFile); 225 bool readProtoLibrary(Scene* scene); 226 #ifdef HAVE_OLPC isOLPC(void)227 bool isOLPC(void) { return true; } 228 #else isOLPC(void)229 bool isOLPC(void) { return false; } 230 #endif is4Kids(void)231 bool is4Kids(void) { return m_is4Kids; } set4Kids(void)232 void set4Kids(void) { m_is4Kids = true; } is4Catt(void)233 bool is4Catt(void) { return m_is4Catt; } set4Catt(void)234 void set4Catt(void) { m_is4Catt = true; } getX3dv(void)235 bool getX3dv(void) { return m_x3dv; } setFull(void)236 void setFull(void) 237 { 238 m_is4Kids = false; 239 m_is4Catt = false; 240 } setX3dv(void)241 void setX3dv(void) { m_x3dv = true; } 242 bool loadNewInline(void); setCoverMode(void)243 void setCoverMode(void) { m_coverMode = true; } getCoverMode(void)244 bool getCoverMode(void) { return m_coverMode; } setKambiMode(void)245 void setKambiMode(void) { m_kambiMode = true; } getKambiMode(void)246 bool getKambiMode(void) { return m_kambiMode; } setX3domMode(void)247 void setX3domMode(void) { m_x3domMode = true; } getX3domMode(void)248 bool getX3domMode(void) { return m_x3domMode; } GetNormalsOnMeshCreation()249 bool GetNormalsOnMeshCreation() const 250 { 251 if (m_coverMode) 252 return true; 253 return OutputApp::GetNormalsOnMeshCreation(); 254 } setFileDialogDir(char * dir)255 void setFileDialogDir(char *dir) { m_fileDialogDir = dir; } getFileDialogDir(void)256 char *getFileDialogDir(void) { return m_fileDialogDir; } getCreateAtZero(int i)257 bool getCreateAtZero(int i) { return m_createAtZero[i]; } setCreateAtZero(int i,bool b)258 void setCreateAtZero(int i, bool b) { m_createAtZero[i] = b; } 259 bool browseCommand(char *buf, int len, int ids_text); 260 bool checkCommand(const char *command, 261 bool checkForFile = false); 262 void checkAndRepairTextEditCommand(void); 263 void checkAndRepairImageEditCommand(void); 264 void checkAndRepairImageEdit4KidsCommand(void); 265 void checkAndRepairSoundEditCommand(void); 266 void checkAndRepairMovieEditCommand(void); 267 getTessellation(void)268 int getTessellation(void) 269 { return m_tessellation; } setTessellation(int tessellation)270 void setTessellation(int tessellation) 271 { m_tessellation = tessellation; } 272 273 void printRenderErrors(GLenum error); 274 int printRenderErrors(bool printOnOutOfMemory = true); 275 getVrml1Error(void)276 bool getVrml1Error(void) { return m_vrml1Error; } setVrml1Error(void)277 void setVrml1Error(void) { m_vrml1Error = true; } 278 279 int searchIllegalChar(char *id); 280 281 void setDefaults(void); 282 getDemoMode(void)283 bool getDemoMode(void) { return m_timeOut != -1; } setDemoMode(int timeOut)284 void setDemoMode(int timeOut) { m_timeOut = timeOut; } 285 getRenderFaster(void)286 bool getRenderFaster(void) 287 { return m_renderFaster; } SetRenderFaster(bool s)288 void SetRenderFaster(bool s) 289 { m_renderFaster = s; } 290 291 void interact(void); 292 bool timeOut(void); checkSimpleCyclicSceneGraph(void)293 bool checkSimpleCyclicSceneGraph(void) 294 { return m_checkSimpleCyclicSceneGraph; } setCheckSimpleCyclicSceneGraph(void)295 void setCheckSimpleCyclicSceneGraph(void) 296 { m_checkSimpleCyclicSceneGraph = true; } 297 getScriptHeaderC(void)298 const char * getScriptHeaderC(void) { return m_scriptHeaderC; } setScriptHeaderC(const char * header)299 void setScriptHeaderC(const char *header) 300 { 301 m_scriptHeaderC = ""; 302 m_scriptHeaderC += header; 303 } 304 getScriptHeaderCpp(void)305 const char * getScriptHeaderCpp(void) { return m_scriptHeaderCpp; } setScriptHeaderCpp(const char * header)306 void setScriptHeaderCpp(const char *header) 307 { 308 m_scriptHeaderCpp = ""; 309 m_scriptHeaderCpp += header; 310 } 311 getScriptHeaderJava(void)312 const char * getScriptHeaderJava(void) { return m_scriptHeaderJava; } setScriptHeaderJava(const char * header)313 void setScriptHeaderJava(const char *header) 314 { 315 m_scriptHeaderJava = ""; 316 m_scriptHeaderJava += header; 317 } hideStandardToolbar(void)318 void hideStandardToolbar(void) 319 { m_hideStandardToolbar = true; } hasStandardToolbar(void)320 bool hasStandardToolbar(void) 321 { return !m_hideStandardToolbar; } 322 importingDataFile(bool flag)323 void importingDataFile(bool flag) 324 { m_importingDataFile = flag; } isImportingDataFile(void)325 bool isImportingDataFile(void) 326 { return m_importingDataFile; } 327 importingProtoLibrary(bool flag)328 void importingProtoLibrary(bool flag) 329 { m_importingProtoLibrary = flag; } isImportingProtoLibrary(void)330 bool isImportingProtoLibrary(void) 331 { return m_importingProtoLibrary; } 332 setDisableGlList(void)333 void setDisableGlList(void) { m_disableGlList = true; } disabledGlList(void)334 bool disabledGlList(void) { return m_disableGlList; } 335 getDownloadDirectory(void)336 MyString getDownloadDirectory(void) 337 { return m_downloadDirectory; } setDownloadDirectory(MyString dir)338 void setDownloadDirectory(MyString dir) 339 { 340 m_downloadDirectory = ""; 341 m_downloadDirectory += dir; 342 } 343 getVerbose(void)344 bool getVerbose(void) { return m_verbose; } setVerbose(bool flag)345 void setVerbose(bool flag) { m_verbose = flag; } 346 getWriteUrl(void)347 const char *getWriteUrl(void) { return m_writeUrl; } setWriteUrl(const char * url)348 void setWriteUrl(const char *url) 349 { 350 m_writeUrl = ""; 351 m_writeUrl += url; 352 } getNumExportFiles(void)353 int getNumExportFiles(void) { return m_numExportFiles; } setNumExportFiles(int i)354 void setNumExportFiles(int i) { m_numExportFiles = i; } 355 setExitPid(int pid)356 void setExitPid(int pid) { m_exitPid = pid; } 357 getFullScreenAtBegin(void)358 bool getFullScreenAtBegin(void) 359 { return m_fullScreenAtBegin; } setFullScreenAtBegin(void)360 void setFullScreenAtBegin(void) { m_fullScreenAtBegin = 1; } 361 isCExporting(void)362 bool isCExporting(void) { return m_CExporting; } setCExporting(bool flag)363 void setCExporting(bool flag) { m_CExporting = flag; } 364 getCrashedFile(void)365 MyString getCrashedFile(void) { return m_recentFiles[0]; } 366 setDynamicFieldsNode(void)367 void setDynamicFieldsNode(void) 368 { m_dynamicFieldsNode = true; } getDynamicFieldsNode(void)369 bool getDynamicFieldsNode(void) 370 { return m_dynamicFieldsNode; } unsetDynamicFieldsNode(void)371 void unsetDynamicFieldsNode(void) 372 { m_dynamicFieldsNode = false; } 373 getSkipChecks(void)374 bool getSkipChecks(void) 375 { return m_skipChecks; } setSkipChecks(bool flag)376 void setSkipChecks(bool flag) 377 { m_skipChecks = flag; } 378 disableDraw(void)379 void disableDraw(void) 380 { m_avoidDraw = true; } enableDraw(void)381 void enableDraw(void) 382 { m_avoidDraw = false; } getDrawAvoided(void)383 bool getDrawAvoided(void) { return m_avoidDraw; } 384 disableMatrixParallel()385 void disableMatrixParallel() 386 { m_matrixParallel = false; } 387 enableMatrixParallel()388 void enableMatrixParallel() 389 { m_matrixParallel = true; } 390 getMatrixParallel()391 bool getMatrixParallel() 392 { return m_matrixParallel; } 393 394 protected: 395 void Exit(void); 396 397 protected: 398 List<MainWindow *> m_windows; 399 MyArray<MyString> m_recentFiles; 400 401 SBROWSER m_browser; 402 SHBROWSER m_helpBrowser; 403 STEXTEDIT m_textedit; 404 SUPLOAD m_upload; 405 406 SWND m_mainWnd; 407 Node *m_clipboardNode; 408 409 MyArray<MyString*> m_filesToDelete; 410 411 MyString m_importURL; 412 MyString m_oldImportURL; 413 MyString m_importFile; 414 415 int m_selectionLinenumber; 416 bool m_selectionLinenumberFlag; 417 418 List<FileBackup *> m_tempFiles; 419 MyArray<PathInt *> m_tempPath; 420 421 bool m_trackAnimation; 422 bool m_coverMode; 423 bool m_kambiMode; 424 bool m_x3domMode; 425 426 const char *m_keyProtoFile; 427 const char *m_keyProtoCategory; 428 bool m_is4Kids; 429 bool m_is4Catt; 430 bool m_x3dv; 431 int m_numberLoadedInlines; 432 char *m_fileDialogDir; 433 bool m_createAtZero[3]; 434 bool m_blackAndWhiteIcons; 435 int m_tessellation; 436 int m_glErrorCount; 437 MainWindow *m_currentWindow; 438 bool m_vrml1Error; 439 int m_timeOut; 440 bool m_timeOutSet; 441 int m_lastInteraction; 442 bool m_checkSimpleCyclicSceneGraph; 443 bool m_renderFaster; 444 445 bool m_loadInputDevicePreferences; 446 447 MyString m_scriptHeaderC; 448 MyString m_scriptHeaderCpp; 449 MyString m_scriptHeaderJava; 450 451 bool m_hideStandardToolbar; 452 bool m_importingDataFile; 453 bool m_importingProtoLibrary; 454 455 bool m_disableGlList; 456 457 MyString m_downloadDirectory; 458 459 bool m_verbose; 460 461 MyString m_writeUrl; 462 463 int m_numExportFiles; 464 465 int m_exitPid; 466 467 int m_fullScreenAtBegin; 468 469 bool m_CExporting; 470 471 bool m_dynamicFieldsNode; 472 473 bool m_skipChecks; 474 475 bool m_avoidDraw; 476 477 bool m_matrixParallel; 478 }; 479 480 extern DuneApp *TheApp; 481 482 483