freSetupTransformController.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freSetupTransformController.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freSetupTransformController_h
00023 #define __freSetupTransformController_h
00024 
00025 #include "freControllerBase.h"
00026 
00027 #include "freSetupTransform.h"
00028 
00029 namespace FREE
00030 {
00031 
00032 freControllerIDMacro(SetupTransformControllerBase, "SetupTransformBase");
00033 
00039 template <class TTransformComponent>
00040 class SetupTransformControllerBase : public ComponentControllerBase<TTransformComponent>
00041 {
00042 public:  
00043   itkTypeMacro(SetupTransformControllerBase, ComponentControllerBase);
00044 
00045   typedef TTransformComponent ComponentType;
00046   typedef ComponentControllerBase<TTransformComponent> Superclass;
00047 
00048   DeclareParameterMacro(ParameterIDs);
00049   DeclareParameterMacro(AutoInitialValues);
00050 
00051         SetupTransformControllerBase()
00052         {
00053                 //Profile settings
00054                 this->UpdateControllerID(ControllerID::SetupTransformControllerBase);
00055                 this->m_Description = "Base controler for a transform of free setups, by changing specified parameters.";
00056 };
00057 
00058 protected:
00059   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00060                                const SessionComponentCache* pComponentCache,
00061                                bool bRegardOldSetup) const
00062   {
00063           //Parameters
00064           profile.Parameters().AddParameter(cParam_ParameterIDs,CtrlProfile::Parameter::PVTString,cParamDsc_ParameterIDs,1,"");
00065           profile.Parameters().AddParameter(cParam_AutoInitialValues,CtrlProfile::Parameter::PVTBool,cParamDsc_AutoInitialValues,1,"true");
00066 
00067     if (bRegardOldSetup)
00068     {
00069       profile.Parameters().AddParameter(cParam_InitialTransformValues,CtrlProfile::Parameter::PVTDouble,"",1,"0.0",-1);
00070             profile.Parameters().AddParameter(cParam_CurrentTransformValues,CtrlProfile::Parameter::PVTDouble,"",1,"0.0",-1);
00071     }
00072     else
00073     {
00074       Parameter* pParam = pComponentCache->Setup()->Parameters().GetParameter(cParam_ParameterIDs);
00075       if (!pParam) throwCtrlExceptionMacro("","Error. Cannot retrieve parameter \"ParameterIDs\". Please ensure that component is properly initialized.");
00076     
00077       profile.Parameters().AddParameter(cParam_InitialTransformValues,CtrlProfile::Parameter::PVTDouble,"",1,"0.0",pParam->LayerCount());
00078             profile.Parameters().AddParameter(cParam_CurrentTransformValues,CtrlProfile::Parameter::PVTDouble,"",1,"0.0",pParam->LayerCount());
00079     }
00080   };
00081 
00082         virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00083                                       SessionComponentCache* pComponentCache,
00084                                       SessionInfo* pSessionInfo,
00085                                                                                                                                                         const unsigned int& iActLevel) const
00086         {
00087                 typedef typename ComponentType::ParametersType ComponentParameterType;
00088     ComponentParameterType values;
00089                 bool bAutoInitValues;
00090 
00091     try
00092     {
00093       SessionAccessor::GetParameterValue(pComponentCache,cParam_AutoInitialValues,bAutoInitValues);
00094     }
00095     catchAllNPassMacro("Error while retrieving parameter values.");
00096 
00097                 pMainComponent->SetAutoInitialValues(bAutoInitValues);
00098 
00099     Parameter::Pointer smpParameter = SessionAccessor::GetParameter(pComponentCache,cParam_ParameterIDs);
00100     if (smpParameter.IsNull()) throwExceptionMacro("Missing parameter: " << cParam_ParameterIDs);
00101 
00102           for (unsigned int index = 0; index < smpParameter->ParameterSize(); index++)
00103     {
00104       std::string id;
00105       smpParameter->GetParameterValue(id,index);
00106                   pMainComponent->AddParameterID(IDPath(id));
00107     }
00108 
00109     //set initial values, if needed.
00110     if (!bAutoInitValues)
00111     {
00112       smpParameter = SessionAccessor::GetParameter(pComponentCache,cParam_InitialTransformValues);
00113       if (smpParameter.IsNull()) throwExceptionMacro("Missing parameter: " << cParam_InitialTransformValues);
00114             ComponentParameterType values = Convert::ParameterLayerToArray<ComponentParameterType>(*(smpParameter->GetParameterLayer(0)));
00115 
00116       pMainComponent->SetParameters( values );
00117     }
00118         };
00119 };  
00120 
00121 DefineParameterTemplateMacro(SetupTransformControllerBase<TTransformComponent>, class TTransformComponent,ParameterIDs,"ParameterIDs","Determines parameter values that should be changed.");
00122 DefineParameterTemplateMacro(SetupTransformControllerBase<TTransformComponent>, class TTransformComponent,AutoInitialValues,"AutoInitialValues","Determines if the transform should use the values of the passed setup (true) as initial transform values.");
00123 
00129   freControllerIDMacro(SetupTransformController, "Setup Transform");
00130 class SetupTransformController : public SetupTransformControllerBase<SetupTransform>
00131 {
00132 public:  
00133   itkTypeMacro(SetupTransformController, SetupTransformControllerBase);
00134 
00135   typedef SetupTransform ComponentType;
00136   typedef SetupTransformControllerBase<ComponentType> Superclass;
00137 
00138         SetupTransformController();
00139 };  
00140 
00141 } //end of namespace free
00142 
00143 #endif

Generated at Sat Oct 13 17:27:48 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000