eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // CoreParameters.h Core.Component package 00003 //============================================================================ 00004 // Usage : definitions of modeler parameters for UI. 00005 //---------------------------------------------------------------------------- 00006 // Copyright (C) 2008 by eLynx project 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 // See the GNU Library General Public License for more details. 00017 //---------------------------------------------------------------------------- 00018 #ifndef __CoreParameters_h__ 00019 #define __CoreParameters_h__ 00020 00021 #include "elx/core/CoreTypes.h" 00022 #include <string> 00023 #include <vector> 00024 00025 namespace eLynx { 00026 00027 enum EParameterType 00028 { 00029 PT_Boolean, 00030 PT_Enum, 00031 PT_Integer, 00032 PT_Double, 00033 PT_String, 00034 PT_StringList 00035 }; 00036 00037 //---------------------------------------------------------------------------- 00038 class ExportedByCore AbstractParameter 00039 { 00040 public: 00041 AbstractParameter(EParameterType iType, const std::string& iName); 00042 virtual ~AbstractParameter(); 00043 00044 virtual void Reset() = 0; 00045 00046 EParameterType GetType() const; 00047 std::string GetName() const; 00048 00049 protected: 00050 EParameterType _type; 00051 std::string _name; 00052 }; 00053 00054 typedef std::vector<AbstractParameter*> ParameterList; 00055 size_t ExportedByCore elxGetParameterIndex(const ParameterList& iList, const std::string& iName); 00056 00057 //---------------------------------------------------------------------------- 00058 struct ExportedByCore ParameterEnumItem 00059 { 00060 ParameterEnumItem(const std::string& iLabel, int32 iValue): _label(iLabel), _value(iValue) {} 00061 std::string GetLabel() const { return _label; } 00062 int32 GetValue() const { return _value; } 00063 00064 protected: 00065 std::string _label; 00066 int32 _value; 00067 }; 00068 typedef std::vector<ParameterEnumItem> ParameterEnumItemList; 00069 00070 00071 class ExportedByCore ParameterEnum : public AbstractParameter 00072 { 00073 public: 00074 ParameterEnum(const std::string& iName, int32 iIndex, const ParameterEnumItemList& iList); 00075 ParameterEnum(); 00076 virtual ~ParameterEnum(); 00077 00078 virtual void Reset(); 00079 00080 size_t GetSize() const; 00081 00082 int32 GetIndex() const; 00083 void SetIndex(int32 iIndex); 00084 00085 int32 GetValue() const; 00086 int32 GetValue(int32 iIndex) const; 00087 00088 std::string GetLabel() const; 00089 std::string GetLabel(int32 iIndex) const; 00090 00091 protected: 00092 int32 _index, _default; 00093 const ParameterEnumItemList& _list; 00094 }; 00095 00096 //---------------------------------------------------------------------------- 00097 class ExportedByCore ParameterInteger : public AbstractParameter 00098 { 00099 public: 00100 ParameterInteger(const std::string& iName, 00101 int32 iMin, int32 iMax, int32 iValue, int32 iTick, int32 iDigits, 00102 const std::string& iFormat); 00103 virtual ~ParameterInteger(); 00104 00105 virtual void Reset(); 00106 00107 void SetValue(int32 iValue); 00108 00109 int32 GetMin() const; 00110 int32 GetMax() const; 00111 int32 GetValue() const; 00112 int32 GetTick() const; 00113 int32 GetDigits() const; 00114 std::string GetFormat() const; 00115 00116 protected: 00117 int32 _min, _max, _value, _default; 00118 int32 _tick, _digits; 00119 std::string _format; 00120 }; 00121 00122 //---------------------------------------------------------------------------- 00123 class ExportedByCore ParameterDouble : public AbstractParameter 00124 { 00125 public: 00126 ParameterDouble(const std::string& iName, 00127 double iMin, double iMax, double iValue, int32 iTick, int32 iDigits, 00128 const std::string& iFormat); 00129 virtual ~ParameterDouble(); 00130 00131 virtual void Reset(); 00132 00133 void SetValue(double iValue); 00134 00135 double GetMin() const; 00136 double GetMax() const; 00137 double GetValue() const; 00138 int32 GetTick() const; 00139 int32 GetDigits() const; 00140 std::string GetFormat() const; 00141 00142 protected: 00143 double _min, _max, _value, _default; 00144 int32 _tick, _digits; 00145 std::string _format; 00146 }; 00147 00148 } // namespace eLynx 00149 00150 #endif // __CoreParameters_h__