00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "freCenteredRigid2DTransformController.h"
00024 #include "freTransformSetupAdaptor.h"
00025
00026 namespace FREE
00027 {
00031
00032
00033 CenteredRigid2DTransformController::
00034 CenteredRigid2DTransformController()
00035 {
00036 this->UpdateControllerID(ControllerID::CenteredRigid2DTransformController);
00037 this->m_Description = "A combination of rotation and translation in 2 dimensions.";
00038 };
00039
00040 void
00041 CenteredRigid2DTransformController::
00042 GenerateProfile(CtrlProfile::ControllerProfile& profile,
00043 const SessionComponentCache* pComponentCache,
00044 bool bRegardOldSetup) const
00045 {
00046 Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00047
00048
00049 profile.Parameters().AddParameter(cParam_InitialTransformValues,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"0");
00050 profile.Parameters().AddParameter(cParam_CurrentTransformValues,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"0");
00051 profile.Parameters().AddParameter(cParam_TransformScale,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"1",-1,true);
00052 };
00053
00054 bool
00055 CenteredRigid2DTransformController::
00056 SetInitialTransformValues( ComponentType* pTransformComponent,
00057 SessionComponentCache* pComponentCache,
00058 SessionInfo* pSessionInfo,
00059 const int& iInitializeByITV) const
00060 {
00061
00062 Superclass::SetInitialTransformValues( pTransformComponent, pComponentCache, pSessionInfo, iInitializeByITV);
00063
00064 int iCenterType;
00065
00066 if (!pComponentCache->SetupIsAssigned()) throwCtrlExceptionMacro("","Cannot initialize transform values, transform setup is not assigned in cache.");
00067 ComponentSetup* pTransformSetup = pComponentCache->Setup();
00068
00069 if (!pTransformSetup->Parameters().GetParameterValue(cParam_CenterInitializationType,iCenterType)) throwExceptionMacro("Missing parameter: " << "CenterType");
00070
00071 TransformSetupAdaptor adaptor(pTransformSetup);
00072 ParameterArrayType itv = adaptor.GetInitialTransformParameters();
00073
00074
00075 for (int iIndex=0; iIndex<itv.Size(); iIndex++)
00076 {
00077 pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,itv[iIndex],iIndex);
00078 };
00079
00080 if (iCenterType>0)
00081 {
00082
00083 for (int iIndex=0; iIndex<2; iIndex++)
00084 {
00085 pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,pTransformComponent->GetCenter().GetElement(iIndex),iIndex+1);
00086 }
00087 }
00088
00089 if (iCenterType>1)
00090 {
00091
00092 for (int iIndex=0; iIndex<2; iIndex++)
00093 {
00094 pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,pTransformComponent->GetTranslation().GetElement(iIndex),iIndex+3);
00095 }
00096 }
00097
00098 return true;
00099 };
00100
00101 }