00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __CIVFDOCUMENT_H__
00025 #define __CIVFDOCUMENT_H__
00026
00027 #define IVF_MAX_URL_NAME_LENGTH 1024
00028 #define MAX_SCRATCH_FILES 4
00029
00030 #define DEF_CAMERA_GROUP_NAME "TGS_DEFCAMERA"
00031 #define NEW_CAMERA_GROUP_NAME "TGS_NEWCAMERA"
00032
00037 #define ID_FIRST_VIEWPOINT 17410
00038
00039 #include <Inventor/SbBasic.h>
00040
00041 #include <Ivf/IvfComponent.h>
00042 #include <Inventor/actions/SoCallbackAction.h>
00043
00044 class SbColor;
00045 class SbString;
00046 class SbPList;
00047 class SoSwitch;
00048 class SoGroup;
00049 class SoSeparator;
00050 class SoInput;
00051 class SoInfo;
00052 class SoNode;
00053 class SoOutput;
00054 class SoPathList;
00055 class SoTexture2;
00056 class SoWWWAnchor;
00057 class SoWWWInline;
00058 class SoPrimitiveVertex;
00059
00060 class CArchive;
00061
00062 class CInlineQueue;
00063 class CInlineItem;
00064 class CAsyncFileQueue;
00065 class CIvfAsyncFile;
00066 class SoDEPRECATED CIvfDocument
00089 {
00090 friend CIvfComponent;
00091
00092 public:
00093 CIvfDocument();
00094 ~CIvfDocument();
00095
00096 public:
00101 void IvfSetFileHeader(LPCSTR header) { strcpy(m_fileHeader, header); }
00102
00107 virtual BOOL IvfOnNewDocument();
00108
00114 virtual BOOL IvfOnOpenDocument(LPCTSTR lpszPathName);
00115
00120 virtual BOOL IvfOnSaveDocument(LPCTSTR lpszPathName);
00121
00127 virtual BOOL IvfOnOpenDocument(UINT hFile);
00128
00133 virtual BOOL IvfOnSaveDocument(UINT hFile);
00134
00135 #if _MSC_VER >= 1300
00136
00141 virtual BOOL IvfOnOpenDocument(HANDLE hFile);
00146 virtual BOOL IvfOnSaveDocument(HANDLE hFile);
00147 #endif
00148
00152 virtual BOOL IvfOnSaveDocument(const CFile* cFile);
00153
00159 virtual BOOL IvfOnOpenDocument(CArchive &rArchive);
00160
00165 virtual BOOL IvfOnSaveDocument(CArchive &rArchive);
00166
00172 BOOL IvfOnOpenDocumentMessage(LPCTSTR lpszPathName);
00173
00177 void IvfImportDocument(LPTSTR PathName);
00178
00184 enum IVFDOC_OPEN_ENUM {
00185 IVFDOC_OPEN_NORMAL,
00186 IVFDOC_OPEN_LOAD,
00187 IVFDOC_OPEN_IMPORT,
00188 IVFDOC_OPEN_PLUGIN
00189 };
00190 IVFDOC_OPEN_ENUM m_eOpenType;
00191
00195 void CIvfDocument::IvfInitDocument(void *pCreateArgs);
00196
00201 virtual void IvfDeleteContents();
00202
00206 virtual LPCTSTR IvfGetUrlName(void);
00207
00213 virtual BOOL IvfIsEmbedded();
00214
00219 virtual BOOL IvfIsTitleSet(void);
00220 virtual void IvfUpdateTitle(void);
00221 virtual LPCTSTR IvfGetTitleString(void);
00222
00226 virtual BOOL IvfIsInfoSet(void);
00227 virtual LPCTSTR IvfGetDocInfoString(void);
00228
00232 virtual void OnFileViewInfo(void);
00233
00238 virtual void IvfSetSceneGraph(SoSeparator *pRoot);
00239 SoSeparator *IvfGetDocSceneGraph();
00240
00244 SoCamera *IvfGetActiveCamera(int in_ix = -1);
00245 int IvfGetActiveCameraIX();
00246 SoGroup *IvfGetActiveCamParent();
00247 SbPList *IvfGetCameraList();
00248
00257 virtual void setCameraType(SoType type);
00258
00263 SoType getCameraType()
00264 { return m_cameraType; }
00265
00271 SoCamera *IvfReplaceCamera(SoCamera *cam, int ix);
00272
00278 virtual void IvfPrepareForSave();
00279
00287 virtual void IvfPostSave();
00288
00295 virtual void IvfFindAnchors(SoGroup *root);
00296
00301 BOOL IvfIsOleSrvr();
00302
00306 void IvfUpdateHeadlightHint(BOOL bOn);
00307
00313 static SoSeparator *IvfReadAll(SoInput *, CIvfDocument *);
00314
00319 static BOOL IvfSaveSceneGraph(LPCTSTR lpFname, SoSeparator *pRoot,
00320 CIvfDocument *);
00321
00327 static SoSeparator *IvfLoadSceneGraph(LPCTSTR lpFname,
00328 CIvfDocument *);
00329
00334 static BOOL IvfSaveSceneGraph(UINT hFile, SoSeparator *pRoot,
00335 CIvfDocument *);
00336
00341 static BOOL IvfSaveSceneGraph(SoOutput* out, SoSeparator *pRoot,
00342 CIvfDocument *);
00343
00349 static SoSeparator *IvfLoadSceneGraph(UINT hFile, CIvfDocument *);
00350
00355 static BOOL IvfSaveSceneGraph(CArchive &rArchive, SoSeparator *pRoot,
00356 CIvfDocument *);
00357
00363 static SoSeparator *IvfLoadSceneGraph(CArchive &rArchive,
00364 CIvfDocument *);
00365
00369 virtual void IvfDeleteSceneGraph();
00370
00375 virtual void IvfSceneGraphChanged();
00376
00380 virtual void IvfSceneGraphCompleted();
00381
00386 virtual void IvfScrubInlines();
00387
00394 virtual void IvfOnLocationChanged(LPCTSTR urlName);
00395
00400 virtual void IvfOnUpdateViewpoints(CCmdUI* pCmdUI);
00401
00402 virtual void IvfRemoveViewpointMenu(CCmdUI* pCmdUI);
00403
00407 int IvfGetNumComponents();
00408
00412 virtual BOOL IdleProcessInlines(void);
00413
00417 static BOOL IvfIsInventorFile(LPCTSTR lpszFileName);
00418
00420 enum IVF_FILETYPE {
00422 IVF_FILETYPE_IV,
00424 IVF_FILETYPE_VRML,
00426 IVF_FILETYPE_VRML2,
00428 IVF_FILETYPE_VRML3
00429 };
00430
00431 void IvfSetFileType(IVF_FILETYPE);
00432 IVF_FILETYPE IvfGetFileType(void);
00433
00434 virtual void IvfSetBgColor(const SbColor &);
00435 virtual SbColor &IvfGetBgColor(void);
00436
00444 virtual BOOL IvfPreTranslateMessage(MSG *);
00445
00450 virtual CIvfAsyncFile *IvfCreateAsyncFile(void *data);
00451
00455 virtual BOOL IvfOnOpenUrl(LPCTSTR url);
00456
00461 void IvfRemoveAsyncFile(CIvfAsyncFile *file);
00462 void IvfAbortAllAsyncFiles();
00463
00467 BOOL IvfIsAsyncFilesPending();
00468
00472 int IvfIsInlinesPending();
00473
00478 virtual void IvfEnableStatAccumulation(BOOL bDoAccum);
00479
00484 virtual void IvfClearStatCounters(BOOL bClearAll=FALSE);
00485
00489 ULONG m_nTriCount, m_nNodeCount, m_nLineCount, m_nPointCount;
00490
00495 BOOL m_bHasTouchSensors;
00496 static BOOL m_queueingOff;
00497 void SetBaseUrlPath(LPCTSTR b_path);
00498 LPCTSTR GetBaseUrlPath(void) { return(m_BasePath); }
00499 static TCHAR m_StaticPath[IVF_MAX_URL_NAME_LENGTH];
00500
00501 private: protected:
00505 SoSeparator *m_pSceneRoot;
00506
00514 virtual void IvfRemoveCameras(SoGroup *root);
00515
00520 virtual void IvfRestoreCameras(SoGroup *root);
00521
00527 virtual void IvfDeleteCameraList();
00528
00537 virtual BOOL IvfOnLoadUrlMessage(CIvfAsyncFile *pIvfASFile);
00538
00549 virtual void IvfSetupUrlFetchCallback();
00550
00554 virtual void IvfRemoveUrlFetchCallback();
00555
00566 virtual void IvfOnFetchUrl(LPCTSTR urlName);
00567
00574 static void IvfStaticFetchUrlCB(const SbString &url,
00575 void *userData,
00576 SoWWWAnchor *node);
00577
00582 static void IvfStaticFetchInlineUrlCB(const SbString &url,
00583 void *userData,
00584 SoNode *node);
00585
00586 static BOOL IvfStaticFetchTexture2UrlCB(const SbString &url,
00587 void *userData,
00588 void *node);
00589
00597 BOOL IsPendingAsyncRequest(CIvfAsyncFile *pIvfASFile, int &status);
00598
00602 void OpenLocalAsyncDoc(CIvfAsyncFile *);
00603
00607 void OnProcessPendingInline(WPARAM, LPARAM);
00608 void ProcessPendingTexture2(CInlineItem *, BOOL);
00609
00610 void PostInlineLocation(SoNode *, LPTSTR , void *);
00611 LPTSTR MakeFullUrlPath(LPTSTR out_url, LPCTSTR in_url);
00612
00616 BOOL IsOKFile(LPTSTR filename);
00617 BOOL MakeScratchName(LPTSTR new_path, LPTSTR filename);
00618 void CleanupScratchFile(LPTSTR filename);
00619
00624 void CountPrimitives();
00625
00629 SoSwitch *m_pCameraSwitch;
00630 SoGroup *m_pCameraSwitchParent;
00631 SoInfo *m_pCameraSwitchInfo;
00632
00633 SoType m_cameraType;
00634
00642 SoGroup *m_pDefaultCameraGroup;
00643
00647 SbPList *m_pCamList;
00648
00653 SbPList *m_pCamParentList;
00654
00658 int m_nActiveCameraIX;
00659
00660 BOOL IVOpenError;
00661
00667 SbPList *m_pInfoList;
00668
00673 SoPathList *m_pAnchorList;
00674
00678 SoInfo *m_pBackColorInfo, *m_pHLInfo;
00679
00683 SoGroup *m_pVPWindowSizePar;
00684 SoInfo *m_pVPWindowSize;
00685
00689 BOOL m_nEnableUrlFetch;
00690
00694 BOOL m_nEnableUrlDisplay;
00695
00699 BOOL m_nEnableViewpoints;
00700
00705 TCHAR m_urlName[IVF_MAX_URL_NAME_LENGTH];
00706
00710 IVF_FILETYPE m_fileType;
00711 char m_fileHeader[256];
00712
00718 void AddInlineChild(CInlineItem *);
00719 void AddInlineChild(SoNode *node, LPTSTR filename, void *cb);
00720 CInlineQueue *m_pInlineQueue;
00721 CAsyncFileQueue *m_pAsyncQueue;
00722 TCHAR m_BasePath[IVF_MAX_URL_NAME_LENGTH];
00723 TCHAR m_OriginalPath[IVF_MAX_URL_NAME_LENGTH];
00724 BOOL m_bSceneGraphComplete, m_bNewGraphPrepped, m_bBasePathPreset,
00725 m_bContainsInlines;
00726
00727 TCHAR* lcl_scratch_filename[MAX_SCRATCH_FILES];
00728 int n_scratch_files;
00740 static BOOL viewerSpeedHintSet;
00741 static BOOL autoClipOffHintSet;
00742 static BOOL titleHintSet;
00743 static BOOL anyLightsSet;
00744
00745 BOOL m_bTitleHintSet;
00746 BOOL m_bDocInfoSet;
00747 BOOL m_bSaveAsBinary;
00748 BOOL m_bDefHeadlightVal;
00753 float motionSpeedHintVal;
00754 CIvfComponent::IvfViewerType viewerTypeHintSet;
00755
00756 SbString *sceneTitle, *docInfoString;
00757 void IvfScanForHints(SoNode *root);
00758
00759 void DetermineViewerType(const SoInfo *info);
00760 void DetermineViewerSpeed(const SoInfo *info);
00761 void DetermineBackgroundColor(const SoInfo *info);
00762 void DetermineTitle(const SoInfo *info);
00763
00767 static SoCallbackAction::Response InfoHintCB(void *userData,
00768 SoCallbackAction *action,
00769 const SoNode *node);
00770
00771 static SoCallbackAction::Response NavInfoCB(void *userData,
00772 SoCallbackAction *action,
00773 const SoNode *node);
00774
00775 static SoCallbackAction::Response WorldInfoCB(void *userData,
00776 SoCallbackAction *action,
00777 const SoNode *node);
00778
00779 static SoCallbackAction::Response WWWInlineCB(void *userData,
00780 SoCallbackAction *action,
00781 const SoNode *node);
00782
00783 static SoCallbackAction::Response VRMLInlineCB(void *userData,
00784 SoCallbackAction *action,
00785 const SoNode *node);
00786
00787 static SoCallbackAction::Response CheckForLightsCB(void *userData,
00788 SoCallbackAction *action,
00789 const SoNode *node);
00790
00791 static SoCallbackAction::Response CountNodesCB(void *userData,
00792 SoCallbackAction *action,
00793 const SoNode *node);
00794
00795 static void CountTrisCB(void *userData,
00796 SoCallbackAction *action,
00797 const SoPrimitiveVertex *,
00798 const SoPrimitiveVertex *,
00799 const SoPrimitiveVertex *);
00800
00801 static void CountLinesCB(void *userData,
00802 SoCallbackAction *action,
00803 const SoPrimitiveVertex *,
00804 const SoPrimitiveVertex *);
00805
00806 static void CountPointsCB(void *userData,
00807 SoCallbackAction *action,
00808 const SoPrimitiveVertex *);
00809 };
00810
00811 extern UINT WMIVF_PROCPENDINGINLINE;
00812 extern UINT WMIVF_LOADURL;
00813
00814 #if defined(_DEBUG)
00815 void DumpSceneGraph(SoNode *pGraph);
00816 #endif
00817
00818 #endif
00819
00820