00001 #include <CLAM/BaseTypedInControl.hxx> 00002 #include <CLAM/Processing.hxx> 00003 00004 namespace CLAM 00005 { 00006 BaseTypedInControl::BaseTypedInControl(const std::string &name, Processing * proc) 00007 : mName(name) 00008 , mProcessing(proc) 00009 , mUpperBound(1) 00010 , mLowerBound(0) 00011 , mBounded(false) 00012 , mHasDefaultValue(false) 00013 { 00014 if (proc) proc->RegisterTypedInControl(this); 00015 } 00016 00017 BaseTypedInControl::~BaseTypedInControl() 00018 { 00019 if (mProcessing) 00020 mProcessing->GetTypedInControls().ProcessingInterface_Unregister(this); 00021 } 00022 bool BaseTypedInControl::IsBounded() const 00023 { 00024 return mBounded; 00025 } 00026 float BaseTypedInControl::UpperBound() const 00027 { 00028 return mUpperBound; 00029 } 00030 float BaseTypedInControl::LowerBound() const 00031 { 00032 return mLowerBound; 00033 } 00034 void BaseTypedInControl::SetBounds( float lower, float upper ) 00035 { 00036 mLowerBound = lower; 00037 mUpperBound = upper; 00038 mBounded = true; 00039 } 00040 void BaseTypedInControl::SetDefaultValue( float val ) 00041 { 00042 mDefaultValue = val; 00043 mHasDefaultValue = true; 00044 } 00045 float BaseTypedInControl::DefaultValue() const 00046 { 00047 if (mHasDefaultValue) return mDefaultValue; 00048 return (mUpperBound+mLowerBound)/2.f; 00049 } 00050 }