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( const OutControlSenderConfig & cfg)
00057 : _output( "out", this )
00058 , _firstDoAfterStart(true)
00059 {
00060 Configure(cfg);
00061 }
00062
00063
00064 bool OutControlSender::ConcreteStart()
00065 {
00066 _firstDoAfterStart=true;
00067 return true;
00068 }
00069
00070 bool OutControlSender::Do()
00071 {
00072 if (_firstDoAfterStart)
00073 {
00074 _firstDoAfterStart=false;
00075 _output.SendControl( _lastValue );
00076 }
00077 return true;
00078 }
00079
00080 void OutControlSender::SendControl(TControlData value)
00081 {
00082
00083 _lastValue=value;
00084 _output.SendControl( _lastValue );
00085 }
00086
00087 bool OutControlSender::ConcreteConfigure(const ProcessingConfig& c)
00088 {
00089 CopyAsConcreteConfig(_config, c);
00090
00091 if (_config.GetMin() > _config.GetMax() )
00092 return AddConfigErrorMessage("Min value greater than max");
00093
00094 if ((_config.GetDefault() > _config.GetMax()) || (_config.GetDefault() < _config.GetMin()))
00095 return AddConfigErrorMessage("Default value out of range");
00096
00097 if (_config.GetStep() == 0 )
00098 return AddConfigErrorMessage("Step value equal to 0");
00099
00100 _lastValue = _config.GetDefault();
00101 return true;
00102 }
00103
00104 }
00105
00106
00107