00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freTransformControllerBase_txx
00023 #define __freTransformControllerBase_txx
00024
00025 #include "freTransformControllerBase.h"
00026 #include "freMediaControllerBase.h"
00027
00028 #include "freReferencePointsAccessor.h"
00029
00030 namespace FREE
00031 {
00032
00033
00037
00038 template <class TControlledTransform, int iDimension>
00039 TransformControllerBase<TControlledTransform, iDimension>::
00040 TransformControllerBase():ComponentControllerBase<TControlledTransform>()
00041 {
00042 this->UpdateControllerID(ControllerID::TransformControllerBase);
00043 this->m_Description = "Base class for transform controller; not for practical use.";
00044
00045 };
00046
00047 template <class TControlledTransform, int iDimension>
00048 void
00049 TransformControllerBase<TControlledTransform, iDimension>::
00050 GenerateProfile(CtrlProfile::ControllerProfile& profile,
00051 const SessionComponentCache* pComponentCache,
00052 bool bRegardOldSetup) const
00053 {
00054 Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00055
00056 profile.Parameters().AddParameter(cParam_InitialisationMethod,Parameter::PVTInteger,cParamDsc_InitialisationMethod,1,"1");
00057
00058
00059 std::string sPointControllerID = "Point Set 2D Media";
00060 if (iDimension == 3)
00061 {
00062 sPointControllerID = "Point Set 3D Media";
00063 }
00064
00065 profile.MediaMap().AddMedia(cParam_MovingReferencePoints,sPointControllerID,DASet,iDimension);
00066 profile.MediaMap().AddMedia(cParam_FixedReferencePoints,sPointControllerID,DASet,iDimension);
00067
00068
00069
00070
00071 profile.MediaMap().AddMedia("movingMedia",ControllerID::MediaControllerBase,DASet,iDimension,1,true);
00072 profile.MediaMap().AddMedia("fixedMedia",ControllerID::MediaControllerBase,DASet,iDimension,1,true);
00073 };
00074
00075 template <class TControlledTransform, int iDimension>
00076 bool
00077 TransformControllerBase<TControlledTransform, iDimension>::
00078 SetInitialTransformValues( ComponentType* pTransformComponent,
00079 SessionComponentCache* pComponentCache,
00080 SessionInfo* pSessionInfo,
00081 const int& iInitializeByITV) const
00082 {
00083 return false;
00087 };
00088
00089 template <class TControlledTransform, int iDimension>
00090 void
00091 TransformControllerBase<TControlledTransform, iDimension>::
00092 ActualizeMainComponent(ComponentType* pMainComponent,
00093 SessionComponentCache* pComponentCache, SessionInfo* pSessionInfo,
00094 const unsigned int& iActLevel) const
00095 {
00096 if(iActLevel==0)
00097 {
00098 if (!pComponentCache->Setup()) throwCtrlExceptionMacro("","Error; passed component setup is null.");
00099
00100 int iInitializeByITV;
00101
00102 try
00103 {
00104 SessionAccessor::GetParameterValue(pComponentCache,cParam_InitialisationMethod,iInitializeByITV);
00105 }
00106 catchAllNPassMacro("Error while retrieving initialisation method.");
00107
00108 if (!pMainComponent) throwCtrlExceptionMacro("","Error; passed transform component is null.");
00109 if (!pComponentCache) throwCtrlExceptionMacro("","Error; passed component cache is null.");
00110 if (!pSessionInfo) throwCtrlExceptionMacro("","Error; passed session info is null.");
00111
00112
00113 Parameter::Pointer smpInitialValues;
00114 try
00115 {
00116 smpInitialValues = SessionAccessor::GetParameter(pComponentCache,cParam_InitialTransformValues);
00117 }
00118 catchAllNPassMacro("Error while retrieving initial transformation values.");
00119 Parameter::Pointer smpCurrentValues = pComponentCache->Setup()->Parameters().GetParameter(cParam_CurrentTransformValues);
00120 if (smpCurrentValues.IsNull())
00121 {
00122 smpCurrentValues = pComponentCache->Setup()->Parameters().AddParameter(cParam_CurrentTransformValues, smpInitialValues->ParameterSize(), 1);
00123 }
00124 *(smpCurrentValues.GetPointer()) = *(smpInitialValues.GetPointer());
00125
00126 smpCurrentValues->SetParameterName(cParam_CurrentTransformValues);
00127
00128
00129 SetInitialTransformValues(pMainComponent,pComponentCache, pSessionInfo, iInitializeByITV);
00130 }
00131
00134 };
00135
00136 template <class TControlledTransform, int iDimension>
00137 void
00138 TransformControllerBase<TControlledTransform, iDimension>::
00139 SetMediaCasted(const MediaID& mediaID, GenericMediaType* pMedia, ComponentType* pComponent, SessionComponentCache* pComponentCache,
00140 SessionInfo* pSessionInfo) const
00141 {
00142 if (mediaID == cParam_MovingReferencePoints)
00143 {
00144 ReferencePointsAccessor<iDimension> pointAccessor(pComponentCache);
00145 PointSetType* pPointSet = dynamic_cast<PointSetType*>(pMedia);
00146 pointAccessor.SetMovingPoints(pPointSet);
00147 }
00148 else if (mediaID == cParam_FixedReferencePoints)
00149 {
00150 ReferencePointsAccessor<iDimension> pointAccessor(pComponentCache);
00151 PointSetType* pPointSet = dynamic_cast<PointSetType*>(pMedia);
00152 pointAccessor.SetFixedPoints(pPointSet);
00153 }
00154 else Superclass::SetMediaCasted(mediaID, pMedia, pComponent, pComponentCache, pSessionInfo);
00155 };
00156
00157 }
00158
00159 #endif