Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SpecificProperty.h

00001 #ifndef SPECIFICPROPERTY_H
00002 #define SPECIFICPROPERTY_H
00003 
00004 #include "GenericProperty.h"
00005 #include "Controller.h"
00006 #include "KeyController.h"
00007 #include "ControllerFactory.h"
00008 
00009 #include "AbstractEditable.h"
00010 #include "AbstractEditor.h"
00011 
00012 class CShapePropertiesDialog;
00013 
00015 template<class T> class VSpecificProperty : public VGenericProperty, public VSpecificKeyIterator<T>
00016 {
00017 friend class CShapePropertiesDialog;
00018 protected:
00019 
00021         VController<T>* m_pControl;
00022 
00024         T m_BaseValue;
00025 
00027         int m_BaseFrame;
00028 
00029 public:
00030         VSpecificProperty()
00031         {
00032                 m_pControl  = NULL;
00033                 m_BaseFrame = 0;
00034         }
00035 
00036         VSpecificProperty(VSpecificProperty<T>* p)
00037         {
00038                 if (p != NULL)
00039                 {
00040                         if ( p->GetController() )
00041                         {
00042                                 m_pControl  = p->GetController()->Clone();
00043                         }
00044                         else
00045                         {
00046                                 m_pControl = NULL;
00047                         }
00048 
00049                         m_BaseValue = p->m_BaseValue;
00050                         m_BaseFrame = p->m_BaseFrame;
00051 
00052                 }
00053         }
00054 
00055         virtual VSpecificProperty<T>* Clone()
00056         {
00057                 return new VSpecificProperty<T>(this);
00058         }
00059 
00060 
00062 
00063 
00065                 virtual string Identify() const  { return string(""); }
00066 
00068                 string IdentifyController() const 
00069                 {
00070                         if (m_pControl != NULL)
00071                                 return m_pControl->Identify();
00072                         else
00073                                 return string("");
00074                 }
00075 
00076                 bool IsControlled() const 
00077                 {
00078                         if (m_pControl)
00079                                 return true;
00080                         else
00081                                 return false;
00082                 }
00083 
00085                 virtual bool MaintainsLinkToShape(void* p) const
00086                 {
00087                         if (m_pControl != NULL)
00088                                 return m_pControl->MaintainsLinkToShape(p);
00089                         else
00090                                 return false;
00091                 }
00092 
00094                 virtual void UnlinkShape(void* p)
00095                 {
00096                         if (m_pControl != NULL)
00097                                 m_pControl->UnlinkShape(p);
00098                 }
00099 
00101 
00102 
00104         void SetBase( T BaseValue )
00105         {
00106                 m_BaseValue = BaseValue;
00107         }
00108 
00110         T GetBase() const 
00111         {
00112                 return m_BaseValue;
00113         }
00114 
00116         void SetController(VController<T>* pNewCtrl)
00117         {
00118                 int nStartFrame = 0;
00119                 int nEndFrame = 50;
00120                 if (m_pControl != NULL) {
00121                         nStartFrame = m_pControl->StartFrame();
00122                         nEndFrame = m_pControl->EndFrame();
00123                         delete m_pControl;
00124                 }
00125 
00126                 m_pControl = pNewCtrl;
00127 
00128                 if (m_pControl != NULL) { // our new controller exists?
00129                         m_pControl->StartFrame(nStartFrame);
00130                         m_pControl->EndFrame(nEndFrame);
00131                         m_pControl->OnLink();
00132                 }
00133         }
00134 
00135         VController<T>* GetController()
00136         {
00137                 return m_pControl;
00138         }
00139 
00140 
00142 
00143 
00145                 virtual void Delete(int pos)
00146                 {
00147                         if (m_pControl != NULL)
00148                                 if (m_pControl->SupportsDirectManipulation())
00149                                         m_pControl->Delete(pos);
00150                 }
00151 
00152                 virtual int Count() const 
00153                 {
00154                         if (m_pControl != NULL) {
00155                                 if (m_pControl->SupportsDirectManipulation())
00156                                         return m_pControl->Count();
00157                                 else
00158                                         return -1;
00159                         } else
00160                                 return 0;
00161                 }
00162 
00164                 virtual void SetFrame(int pos, int f)
00165                 {
00166                         if (m_pControl != NULL) {
00167                                 if (m_pControl->SupportsDirectManipulation())
00168                                         m_pControl->SetFrame(pos, f);
00169                         } else
00170                                 m_BaseFrame = f;
00171                 }
00172 
00174                 virtual int GetFrame(int pos) 
00175                 {
00176                         if (m_pControl != NULL) {
00177                                 if (m_pControl->SupportsDirectManipulation())
00178                                         return m_pControl->GetFrame(pos);
00179                                 else
00180                                         return -1;
00181                         } else
00182                                 return -1;
00183                 }
00184 
00186                 bool Exists(int f) const 
00187                 {
00188                         if (m_pControl)
00189                                 return m_pControl->Exists( f );
00190                         else
00191                                 return false;
00192                 }
00193 
00195                 virtual void CreateBlankKeyFrame( int frame )
00196                 {
00197                         if (m_pControl != NULL) {
00198                                 if (m_pControl->SupportsDirectManipulation() && !m_pControl->Exists(frame)) {
00199                                         m_pControl->AddUpdate(frame, m_pControl->Evaluate(frame));
00200                                 }
00201                         }
00202                 }
00204 
00206 
00207 
00209                 virtual void AddUpdate(int f, T key)
00210                 {
00211                         if (m_pControl != NULL) {
00212                                 if (m_pControl->SupportsDirectManipulation())
00213                                         m_pControl->AddUpdate(f, key);
00214                         } else { // convert this to a keycontroller
00215                                 m_pControl = new VKeyController<T>;
00216                                 if (m_pControl)
00217                                 {
00218                                         m_pControl->AddUpdate(m_BaseFrame, m_BaseValue);
00219                                         m_pControl->AddUpdate(f, key);
00220                                 }
00221                                 else
00222                                 {
00223                                         OutOfMemoryIndicator( AfxGetMainWnd()->m_hWnd );
00224                                 }
00225 
00226                         }
00227                 }
00228 
00230                 virtual void SetKey(int pos, T key)
00231                 {
00232                         if (m_pControl != NULL) {
00233                                 if (m_pControl->SupportsDirectManipulation())
00234                                         m_pControl->SetKey(pos, key);
00235                         } else
00236                                 m_BaseValue = key;
00237                 }
00238 
00240                 virtual T GetKey(int pos)
00241                 {
00242                         if (m_pControl != NULL) {
00243                                 if (m_pControl->SupportsDirectManipulation())
00244                                         return m_pControl->GetKey(pos);
00245                                 else
00246                                         return m_BaseValue;
00247                         } else
00248                                 return m_BaseValue;
00249                 }
00251 
00252 
00254 
00255 
00257                 virtual T Evaluate(int nFrame) // Basic property evaluated without adding basevalue
00258                 {
00259                         if (m_pControl != NULL)
00260                                 return m_pControl->Evaluate(nFrame);
00261                         else
00262                                 return m_BaseValue;
00263                 }
00264 
00266                 virtual VAbstractEditor* CreateEditor()
00267                 {
00268                         if (IsControlled())
00269                                 return m_pControl->CreateEditor();
00270                         else
00271                                 return m_BaseValue.CreateEditor();
00272                 }
00273 
00274 
00276                 virtual bool SupportsDirectManipulation() const 
00277                 {
00278                         if (m_pControl != NULL)
00279                                 return m_pControl->SupportsDirectManipulation();
00280                         else
00281                                 return true;
00282                 }
00283 
00284 
00285 
00286 
00288 
00289 
00290 
00291 
00293 
00294 
00296                 virtual int ControllerCount() const { return 1;}
00297 
00299                 virtual void ImplementController( int index )
00300                 {
00301                         VKeyController<T>* p = new VKeyController<T>();
00302                         if (p)
00303                                 SetController(p);
00304                 }
00305 
00307                 virtual string ControllerInfo( int index ) const
00308                 {
00309                         return string("");
00310                 }
00311 
00313                 void UnlinkController( )
00314                 {
00315                         SetController(NULL);
00316                 }
00318 
00319 };
00320 
00321 #endif

Generated at Wed Aug 29 19:58:55 2001 for Pocket Animator by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001