kernel.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 2008 Autodesk, Inc.
00003 // All rights reserved.
00004 //
00005 // Use of this software is subject to the terms of the Autodesk license
00006 // agreement provided at the time of installation or download, or which
00007 // otherwise accompanies this software in either electronic or hard copy form.
00008 //
00009 //**************************************************************************/
00010 // DESCRIPTION:
00011 // CREATED: October 2008
00012 //**************************************************************************/
00013 
00014 namespace mudbox { 
00015 
00018 class MBDLL_DECL FileEventNotifier : public Node
00019 {
00020     DECLARE_CLASS;
00021 
00022     enum Type
00023     {
00026         typeBrowseForRead,
00029         typeBrowseForWrite,
00032         typePreRead,
00034         typePostRead,
00037         typePreWrite,
00039         typePostWrite
00040     } m_eType;
00043     QString m_sFileName;
00044 };
00045 
00046 //-----------------------------------------------------------------------------
00053 class MBDLL_DECL TextureUnprojector : public Node
00054 {
00055     DECLARE_CLASS;
00056 
00057 public:
00061     virtual Texture*  DoUnproject(int xSize, int ySize, bool want16BitFP = false);
00062 };
00063 
00064 //-----------------------------------------------------------------------------
00065 
00066 class Operation;
00067 class XRef;
00068 
00072 class MBDLL_DECL Kernel : public Node
00073 {
00074     Q_DECLARE_TR_FUNCTIONS(mudbox::Kernel);
00075     DECLARE_CLASS;
00076     class XRef* m_pXRef;
00077 public:
00078 
00080     Kernel( void ); 
00081 
00088     void Log(const QString &sMessage);
00089     
00091     void LogMemoryStatus(
00092         bool bCompact = true    
00093         );
00094     
00099     void LogMemoryBlocks(
00100         float fSizeLimit = 0.01  
00101         );
00102     
00106     bool CreateNewScene(); 
00107     
00108     // Automation
00109 
00140     void RecordCommand( const QString &sCommand );
00141 
00143     astring NextCommand;
00144 
00146     class Scene *CreateDefaultScene( void );
00147 
00148     // plugin management
00158     const ClassDesc *PreferredDescendant(
00159         const ClassDesc *pClass     //< [in] The ClassDesc of a base class (obtained via the StaticClass() function:  myClass::StaticClass() )
00160         ) const;
00161     
00166     Node *CreateClassInstance( const ClassDesc *pClass ) const;
00167 
00173     Image *LoadImage(
00174         const QString &sFileName,       
00175         bool tiled = false              
00176         ) const;
00177 
00179     void GLCheckError(
00180         const char *sSourceFileName,    
00181         const char *sFunctionName,      
00182         unsigned int iLine              
00183         ) const;
00184     
00186     void GLCheckStates(
00187         const char *sSourceFileName,    
00188         const char *sFunctionName,      
00189         unsigned int iLine              
00190         ) const;
00191 
00192 
00196     void Redraw( void );
00197 
00199     class Scene *Scene( void ) const;
00200     
00202     mudbox::Preferences *Preferences( void ) const;
00203     
00205     class mudbox::Interface *Interface( void ) const;
00206 
00208     class Statistics *Statistics( void ) const;
00209     
00211     class ViewPort *ViewPort( void ) const;
00212     
00214     QString MudboxVersionName( void ) const;
00215 
00217     void RegisterWindowPlugin(WindowPlugin* plugin) const;
00218 
00220     mudbox::TrayAccessor *TrayAccessor( void ) const;
00221 
00223     bool ExtractArchiveFile(QString sArchiveFilePath, QString sDestPath);
00224     bool CreateArchiveFile(QString sArchiveFilePath, QStringList files);
00225 
00227     QString DataDirectory( void ) const;
00228 
00230     QString ApplicationDirectory( void ) const;
00231     
00233     QString ProjectFilesDirectory( void ) const;
00234     
00236     QString SafeWritableDirectory( void ) const;
00237     
00239     QString PluginDirectory( const QString& pluginName ) const;
00240     
00243     bool IsTestModeOn( void ) const;
00244     
00246     bool IsBetaVersion( void ) const;
00247 
00254 
00255     Image *ExtractUnprojectedTextures(const QString &sChannel, 
00256                                       int  iWidth,   
00257                                       int  iHeight,  
00258                                       enum Image::Format fmt = Image::e8integer, 
00259                                       bool bTiledImg = false, 
00260                                       bool allLayers = false  
00261         );
00262 
00263     Image *ExtractUnprojectedTextures(int  iWidth,   
00264                                       int  iHeight,  
00265                                       enum Image::Format fmt = Image::e8integer, 
00266                                       bool bTiledImg = false,   
00267                                       bool allLayers = false    
00268         );
00269 
00270 
00279      
00280     Image *ExtractShadingMap(int iWidth,            
00281                              int iHeight,           
00282                              enum Image::Format fmt = Image::e8integer,  
00283                              bool bTiledImg = false 
00284         );
00285 
00286 
00288     class XRef* XRef() const; 
00289 
00297     void ReportVideoMemoryUsage(
00298         qint64 iSize        
00299         );
00300     
00302     qint64 VideoMemoryUsage( void ) const;
00303 
00305     qint64 TotalVideoMemory( void ) const;
00306     
00311     bool DoOperation(
00312         Operation *pOp, 
00313         bool bMerge = false 
00314         );
00315 
00316     const QList<class ImageIOHandler *> &ExternalImageIOHandlers();
00317 
00321     void FlushUndoQueue();
00322 
00324     aevent StrokeBeginEvent;
00325 
00327     aevent StrokeEndEvent;
00328 
00330     aevent TangentMirrorUpdateEvent;
00331 
00336     aevent LowMemoryEvent;
00337     
00340     aevent RestoreMemoryEvent;
00341     
00343     aevent PostUndoRedoEvent;
00344 
00358     QString TriggerFileEvent(
00359         FileEventNotifier::Type eType,      
00360         const QString &sFileName        
00361         ) const;
00362 
00371     mutable aptr<FileEventNotifier> FileEvent;
00372  
00374     aevent ScenePreDeletedEvent;
00375 };
00376 
00378 MBDLL_DECL Kernel *Kernel( void );
00379 
00381 class MBDLL_DECL Timer
00382 {
00383     int m_iIndex;
00384 
00385 public:
00387     Timer( const char *sName, int &iIndex );
00388     ~Timer( void );
00390     static unsigned int Current( void );
00393     static void ResetAll( void );
00395     static void LogAll( void );
00396 };
00397 
00398 
00400 class MBDLL_DECL Statistics
00401 {
00402 public:
00403     void AddRenderedPolygonCount( unsigned int iPolygonCount );
00404     int FrameCount( void ) const;
00405 };
00406 
00412 template < typename c >
00413 c* CreateInstance( void ) { return dynamic_cast<c *>( Kernel()->CreateClassInstance( c::StaticClass() ) ); };
00414 
00452 template < typename c >
00453 class MBDLL_TEMPLATE_DECL Instance
00454 {
00455     c *m_pObject;
00456 
00457 public:
00458     inline Instance( c* pObject ) : m_pObject( pObject ) {};
00459     inline Instance( void ) { m_pObject = CreateInstance<c>(); };
00460     inline ~Instance( void ) { if( m_pObject ) delete m_pObject; };
00461     inline c *operator ->( void ) { return m_pObject; };
00462     inline const c *operator ->( void ) const { return m_pObject; };
00463     inline operator c*( void ) const { return m_pObject; };
00464 
00467     inline c * Release() { c* pTemp = m_pObject; m_pObject = 0; return pTemp; }
00468 };
00469 
00471 class MBDLL_DECL Utility
00472 {
00473 public:
00474 
00482     static QString SanitizeFileName( 
00483         const QString& sName  
00484         );
00485 };
00486 
00487 }; // end of namespace mudbox