OutControlSender.cxx

Go to the documentation of this file.
00001 #include "OutControlSender.hxx"
00002 #include "ProcessingFactory.hxx"
00003 
00004 
00005 namespace CLAM
00006 {
00007 namespace Hidden
00008 {
00009         static const char * metadata[] = {
00010                 "key", "OutControlSender",
00011                 "category", "Controls",
00012                 "description", "OutControlSender",
00013                 "icon", "hslider.png",
00014                 "control_sender_type", typeid(TControlData).name(),
00015                 0
00016         };
00017         static FactoryRegistrator<ProcessingFactory, OutControlSender> reg = metadata;
00018 }
00019         
00020 Enum::tEnumValue OutControlSenderConfig::EControlRepresentation::sEnumValues[] =
00021         {
00022                 { EControlRepresentation::eUndetermined, "Undetermined" },
00023                 { EControlRepresentation::eVerticalSlider, "Vertical Slider" },
00024                 { EControlRepresentation::eHorizontalSlider, "Horizontal Slider" },
00025                 { EControlRepresentation::eKnot, "Knot" },
00026                 { EControlRepresentation::eSpinBox, "Spin Box" },
00027                 { 0, NULL }
00028         };
00029 
00030 Enum::tEnumValue OutControlSenderConfig::EMapping::sEnumValues[] =
00031         {
00032                 { EMapping::eLinear, "Linear" },
00033                 { EMapping::eInverted, "Inverted" },
00034                 { EMapping::eLog, "Log" },
00035                 { EMapping::eReverseLog, "Reverse Log" },
00036                 { 0, NULL }
00037         };
00038 
00039 
00040 Enum::tValue OutControlSenderConfig::EControlRepresentation::sDefault =
00041         OutControlSenderConfig::EControlRepresentation::eHorizontalSlider;
00042 
00043 Enum::tValue OutControlSenderConfig::EMapping::sDefault =
00044         OutControlSenderConfig::EMapping::eLinear;
00045 
00046 void OutControlSenderConfig::DefaultInit(void)
00047 {
00048         AddAll();
00049         UpdateData();
00050         SetMin( 0.0 );
00051         SetDefault( 0.0 );
00052         SetMax( 1.0 );
00053         SetStep(1.0);
00054 }
00055 
00056 OutControlSender::OutControlSender()
00057         : mOutput("out", this)
00058         , mFirstDoAfterStart(true)
00059 {
00060         OutControlSenderConfig cfg;
00061         Configure(cfg);
00062 }
00063 
00064 OutControlSender::OutControlSender( const OutControlSenderConfig & cfg)
00065         : mOutput( "out", this )
00066         , mFirstDoAfterStart(true)
00067 {
00068         Configure(cfg);
00069 }
00070 
00071 
00072 bool OutControlSender::ConcreteStart()
00073 {
00074         mFirstDoAfterStart=true;
00075         std::cout << "Start" << std::endl;
00076         return true;
00077 }
00078 
00079 bool OutControlSender::Do()
00080 {
00081         if( !AbleToExecute() ) return true;
00082         if (mFirstDoAfterStart)
00083         {
00084                 std::cout << "First do" << std::endl;
00085                 mFirstDoAfterStart=false;
00086                 mOutput.SendControl( mLastValue );
00087         }
00088         return true;
00089 }
00090 
00091 void OutControlSender::SendControl(TControlData value)
00092 {
00093         // TODO: Solve thread boundary here
00094         mLastValue=value;
00095         mOutput.SendControl( mLastValue );
00096 }
00097 
00098 bool OutControlSender::ConcreteConfigure(const ProcessingConfig& c)
00099 {
00100         CopyAsConcreteConfig(mConfig, c);
00101         if(mConfig.GetMin() > mConfig.GetMax() )
00102         {
00103                 AddConfigErrorMessage(" min value greater than max");
00104                 return false;
00105         }
00106         if((mConfig.GetDefault() > mConfig.GetMax()) || (mConfig.GetDefault() < mConfig.GetMin()))
00107         {
00108                 AddConfigErrorMessage(" default value out of range");
00109                 return false;
00110         }
00111         if(mConfig.GetStep() == 0 )
00112         {
00113                 AddConfigErrorMessage(" step value equal to 0");
00114                 return false;
00115         }
00116         mLastValue = mConfig.GetDefault();
00117         return true;
00118 }
00119 
00120 } // namespace CLAM
00121 
00122 
00123 
Generated by  doxygen 1.6.3