IBrushPresets.h

Go to the documentation of this file.
00001 //*****************************************************************************/
00002 // Copyright (c) 1998-2005 Autodesk, Inc.
00003 // All rights reserved.
00004 // 
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //*****************************************************************************/
00011 
00012 /**********************************************************************
00013  *<
00014     FILE: BrushPresets.h
00015 
00016     DESCRIPTION:    Brush Preset functionality for the PainterInterface
00017 
00018     CREATED BY:     Michaelson Britt
00019 
00020     HISTORY:        Created December 2004
00021  *>
00022  **********************************************************************/
00023 #pragma once
00024 #include "maxheap.h"
00025 #include "maxtypes.h"
00026 #include "ifnpub.h"
00027 #include "GetCOREInterface.h"
00028 
00029 // forward declarations
00030 class IBrushPreset;
00031 class IBrushPresetParams;
00032 class IBrushPresetContext;
00033 class IBrushPresetMgr;
00034 
00035 //-----------------------------------------------------------------------------
00036 // class IBrushPreset
00037 
00039 
00045 class IBrushPreset: public MaxHeapOperators {
00046     public:
00048         virtual ~IBrushPreset() {;}
00049 
00051 
00053         virtual int         PresetID() = 0;
00054 
00056 
00058         virtual void        Apply() = 0;    // Calls ApplyParams() on every param set
00060 
00062         virtual void        Fetch() = 0;    // Calls FetchParams() on every param set
00063 
00065 
00066         virtual IBrushPresetParams* GetParams( Class_ID contextID ) = 0;
00068         virtual int         GetNumContexts() = 0;
00070 
00072         virtual Class_ID    GetContextID( int contextIndex ) = 0;
00074 
00076         virtual int         GetContextIndex( Class_ID contextID ) = 0;
00077 };
00078 
00079 
00080 //-----------------------------------------------------------------------------
00081 // class IBrushPresetParams
00082 
00084 
00085 class IBrushPresetParams: public MaxHeapOperators  {
00086     public:
00088         virtual ~IBrushPresetParams() {;}
00089 
00091         virtual Class_ID    ContextID()=0; // The ID of the param set is equal to the ID of its context
00092 
00093         // The presets param object is expected to have access to its associated context.
00094         // These methods apply the params into the context, or fetch the param values from the context
00095 
00097 
00099         virtual void        ApplyParams() = 0;
00101 
00103         virtual void        FetchParams() = 0;
00104 
00105         // Use methods in the BrushPresetContext for metadata about the parameters.
00106         // Parameter values are stored here.
00107 
00109         virtual int         GetNumParams() = 0;
00111 
00113         virtual int         GetParamID( int paramIndex ) = 0;
00115 
00117         virtual int         GetParamIndex( int paramID ) = 0;
00119 
00121         virtual FPValue     GetParamValue( int paramID ) = 0;
00123 
00125         virtual void        SetParamValue( int paramID, FPValue val ) = 0;
00127 
00133         virtual FPValue     GetDisplayParamValue( int paramID )     {return GetParamValue(paramID);}
00134 
00136 
00139         virtual void        SetParent( IBrushPreset* parent ) = 0;
00140 };
00141 
00142 
00143 //-----------------------------------------------------------------------------
00144 // class IBrushPresetContext
00145 
00147 
00152 #define STDBRUSHPRESETCONTEXT_ID    Class_ID(0,0x5fb1707c)
00153 
00155 
00167 class IBrushPresetContext: public MaxHeapOperators {
00168     public:
00170         virtual ~IBrushPresetContext() {;}
00171 
00173         virtual Class_ID    ContextID() = 0;
00175         virtual MCHAR*      GetContextName() = 0;
00176 
00178         virtual IBrushPresetParams* CreateParams() = 0;
00180 
00182         virtual void        DeleteParams( IBrushPresetParams* params ) = 0;
00183 
00185         virtual int         GetNumParams() = 0;
00187 
00189         virtual int         GetParamID( int paramIndex ) = 0;
00191 
00193         virtual int         GetParamIndex( int paramID ) = 0;
00195 
00196         virtual MCHAR*      GetParamName( int paramID ) = 0;
00198 
00199         virtual ParamType2  GetParamType( int paramID ) = 0;
00200 
00202         virtual int         GetNumDisplayParams()                   {return GetNumParams();}
00204 
00206         virtual int         GetDisplayParamID( int displayIndex )   {return GetParamID(displayIndex);}
00208 
00210         virtual int         GetDisplayParamIndex( int paramID )     {return GetParamIndex(paramID);}
00212 
00213         virtual MCHAR*      GetDisplayParamName( int paramID )      {return GetParamName(paramID);}
00214 
00216 
00218         virtual BOOL        IsDisplayParam( int paramID )           { UNUSED_PARAM(paramID); return TRUE;}
00220 
00224         virtual BOOL        IsTransientParam( int paramID )         { UNUSED_PARAM(paramID); return FALSE; }
00225 
00226         // Support for deferred plug-in loading
00227 
00229 
00233         virtual Class_ID    PluginClassID()=0; // Class ID of the plug-in containing the context
00235 
00239         virtual SClass_ID   PluginSuperClassID()=0; // Superclass ID of the plug-in containing the context
00240 };
00241 
00242 
00243 //-----------------------------------------------------------------------------
00244 // class BrushPresetMgr
00245 
00247 
00253 class IBrushPresetMgr : public FPStaticInterface {
00254     public:
00255         DECLARE_DESCRIPTOR( IBrushPresetMgr );
00256 
00258 
00261         virtual void        RegisterContext( IBrushPresetContext* context ) = 0;
00263 
00265         virtual void        UnRegisterContext( IBrushPresetContext* context ) = 0;
00266 
00268 
00271         virtual IBrushPresetContext* GetContext( Class_ID contextID ) = 0;
00273 
00275         virtual int         GetNumContexts() = 0;
00277 
00279         virtual Class_ID    GetContextID( int contextIndex ) = 0; // ID numbers are always > 0
00281 
00283         virtual int         GetContextIndex( Class_ID contextID ) = 0;
00285 
00287         virtual int         BeginContext( Class_ID contextID ) = 0;
00289 
00291         virtual int         EndContext( Class_ID contextID ) = 0;
00293 
00294         virtual BOOL        IsContextActive( Class_ID contextID ) = 0;
00295 
00297 
00298         virtual IBrushPreset* GetPreset( int presetID ) = 0;
00300         virtual IBrushPreset* CreatePreset() = 0;
00302         virtual void        DeletePreset( IBrushPreset* preset ) = 0;
00304         virtual int         GetNumPresets() = 0;
00306 
00308         virtual int         GetPresetID( int presetIndex ) = 0;
00310 
00312         virtual int         GetPresetIndex( int presetID ) = 0;
00313 
00315 
00316         virtual int         GetActivePreset() = 0;
00318 
00320         virtual void        SetActivePreset( int presetID ) = 0; // Pass zero to deactivate
00321 
00323 
00326         virtual void        OnContextUpdated( Class_ID contextID ) = 0;
00327 
00329 
00331         virtual int         ReadConfig(MCHAR *cfg=NULL) = 0;
00333 
00335         virtual int         WriteConfig(MCHAR *cfg=NULL) = 0;
00336 };
00337 
00339 #define IBRUSHPRESETMGR_INTERFACE_ID Interface_ID(0x586b1d59, 0x454d0ae9)
00340 
00342 inline IBrushPresetMgr* GetIBrushPresetMgr()
00343 { return (IBrushPresetMgr*)GetCOREInterface(IBRUSHPRESETMGR_INTERFACE_ID); }
00344 
00345