Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 1fe8450d authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

selectById added

parent 46792701
......@@ -190,9 +190,7 @@ namespace campvis {
tbb::mutex::scoped_lock lock(_localMutex);
float pos = static_cast<float>(e->x()) / static_cast<float>(_canvas->width());
cgt::col4 col = cgt::col4(255);
float alpha = cgt::clamp(static_cast<float>(_canvas->height() - e->y()) / static_cast<float>(_canvas->height()), 0.f, 1.f);
col.a = static_cast<uint8_t>(alpha * 255.f);
g->addKeyPoint(pos, alpha);
}
......
......@@ -185,6 +185,37 @@ namespace campvis {
%template(Vec4Property) FloatingPointProperty< cgt::Vector4<float> >;
typedef FloatingPointProperty< cgt::Vector4<float> > Vec4Property;
/* OptionProperty */
class AbstractOptionProperty : public IntProperty {
public:
AbstractOptionProperty(const std::string& name, const std::string& title);
virtual ~AbstractOptionProperty();
virtual const std::string& getOptionId() = 0;
virtual void selectById(const std::string& id) = 0;
};
template<typename T>
class GenericOptionProperty : public AbstractOptionProperty {
public:
GenericOptionProperty(
const std::string& name,
const std::string& title,
const GenericOption<T>* options,
int count);
virtual ~GenericOptionProperty();
const std::string& getOptionId();
void selectById(const std::string& id);
};
/* Downcast the return value of selectById to appropriate subclass */
%factory(void campvis::AbstractOptionProperty::selectById,
campvis::GenericOptionProperty);
/* Downcast the return value of getOptionId to appropriate subclass */
%factory(void campvis::AbstractOptionProperty::getOptionId,
campvis::GenericOptionProperty);
/* TFGeometry1D */
%nodefaultctor TFGeometry1D;
......@@ -341,17 +372,22 @@ namespace campvis {
sigslot::signal0 s_changed;
%mutable;
};
/* Down casting or super classes.
* Down casting follows the order of declaration.
* Declare the classes as child first according to the class hierarchy.
*/
/* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getProperty,
campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::AbstractOptionProperty, campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
campvis::TransferFunctionProperty,
campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
/* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */
%factory(AbstractProperty* campvis::HasPropertyCollection::getNestedProperty,
campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::AbstractOptionProperty, campvis::IntProperty, campvis::IVec2Property, campvis::IVec3Property, campvis::IVec4Property,
campvis::FloatProperty, campvis::Vec2Property, campvis::Vec3Property, campvis::Vec4Property,
campvis::TransferFunctionProperty,
campvis::DataNameProperty, campvis::StringProperty, campvis::ButtonProperty, campvis::BoolProperty);
......
......@@ -139,15 +139,16 @@ namespace campvis {
void TFGeometry1D::addKeyPoint( float position, float alpha) {
TFGeometry1D::KeyPoint kp(position, cgt::col4(255));
cgt::col4 color(255);
std::vector<TFGeometry1D::KeyPoint>::iterator lb = std::upper_bound(_keyPoints.begin(), _keyPoints.end(), kp);
if (lb != _keyPoints.end()) {
kp._color = lb->_color;
color = lb->_color;
}
else {
kp._color = _keyPoints.back()._color;
color = _keyPoints.back()._color;
}
kp._color.a = static_cast<uint8_t>(alpha * 255.f);
_keyPoints.insert(lb, kp);
color.a = static_cast<uint8_t>(alpha * 255.f);
addKeyPoint(position, color);
}
void TFGeometry1D::addKeyPoint( float position, const cgt::col4& color ) {
......
......@@ -52,6 +52,19 @@ namespace campvis {
* Pure virtual destructor.
*/
virtual ~AbstractOptionProperty() {};
/**
* Returns the id of the currently selected option.
* \return _options[_value]._id
*/
virtual const std::string& getOptionId() = 0;
/**
* Sets the selected option to the first option with the given id.
* If no such option is found, the selected option will not change.
* \param id Id of the option to select.
*/
virtual void selectById(const std::string& id) = 0;
/**
* Returns all Options als pair of std::strings.
......@@ -146,7 +159,7 @@ namespace campvis {
* Returns the id of the currently selected option.
* \return _options[_value]._id
*/
std::string& getOptionId() const;
const std::string& getOptionId();
/**
......@@ -252,7 +265,7 @@ namespace campvis {
}
template<typename T>
std::string& campvis::GenericOptionProperty<T>::getOptionId() const {
const std::string& campvis::GenericOptionProperty<T>::getOptionId() {
return _options[_value]._id;
}
......
......@@ -53,7 +53,7 @@ namespace campvis {
*/
virtual ~AbstractPropertyLua();
public:
virtual std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc) = 0;
virtual std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) = 0;
protected:
AbstractProperty* _property; ///< The property this lua handles
......
......@@ -34,7 +34,7 @@ namespace campvis {
BoolPropertyLua::~BoolPropertyLua() {
}
std::string BoolPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string BoolPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix +_property->getName() + "\"):setValue("
......
......@@ -46,7 +46,7 @@ namespace campvis {
*/
virtual ~BoolPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
......@@ -35,7 +35,7 @@ namespace campvis {
ColorPropertyLua::~ColorPropertyLua() {
}
std::string ColorPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string ColorPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::vec4 value = static_cast<ColorProperty*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......
......@@ -48,7 +48,7 @@ namespace campvis {
*/
virtual ~ColorPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// ================================================================================================
......
......@@ -35,7 +35,7 @@ namespace campvis {
DataNamePropertyLua::~DataNamePropertyLua() {
}
std::string DataNamePropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string DataNamePropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
const std::string value = static_cast<DataNameProperty*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......
......@@ -53,7 +53,7 @@ namespace campvis {
*/
virtual ~DataNamePropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
......@@ -35,7 +35,7 @@ namespace campvis {
FloatProperty* property = static_cast<FloatProperty*>(_property);
}
std::string FloatPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string FloatPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):setValue("
......
......@@ -48,7 +48,7 @@ namespace campvis {
*/
virtual ~FloatPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
......@@ -102,7 +102,7 @@ namespace campvis {
*/
virtual ~VecPropertyLua();
virtual std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
virtual std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
......@@ -120,7 +120,7 @@ namespace campvis {
}
template<size_t SIZE>
std::string VecPropertyLua<SIZE>::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string VecPropertyLua<SIZE>::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "-- NOT IMPLEMENTED VecProperty";
return ret;
}
......@@ -133,7 +133,7 @@ namespace campvis {
{
}
std::string Vec2PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string Vec2PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::vec2 value = static_cast<Vec2Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......@@ -151,7 +151,7 @@ namespace campvis {
: VecPropertyLua<3>(property, dataContainer)
{
}
std::string Vec3PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string Vec3PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::vec3 value = static_cast<Vec3Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......@@ -171,7 +171,7 @@ namespace campvis {
{
}
std::string Vec4PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string Vec4PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::vec4 value = static_cast<Vec4Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......
......@@ -34,7 +34,7 @@ namespace campvis {
IntPropertyLua::~IntPropertyLua() {
}
std::string IntPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string IntPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):setValue("
......
......@@ -48,7 +48,7 @@ namespace campvis {
*/
virtual ~IntPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......@@ -101,7 +101,7 @@ namespace campvis {
*/
virtual ~IVecPropertyLua();
virtual std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
virtual std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// ================================================================================================
......@@ -117,7 +117,7 @@ namespace campvis {
}
template<size_t SIZE>
std::string IVecPropertyLua<SIZE>::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string IVecPropertyLua<SIZE>::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "-- NOT IMPLEMENTED IVecProperty";
return ret;
}
......@@ -131,7 +131,7 @@ namespace campvis {
{
}
std::string IVec2PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string IVec2PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::ivec2 value = static_cast<IVec2Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......@@ -150,7 +150,7 @@ namespace campvis {
{
}
std::string IVec3PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string IVec3PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::ivec3 value = static_cast<IVec3Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......@@ -170,7 +170,7 @@ namespace campvis {
{
}
std::string IVec4PropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string IVec4PropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
cgt::ivec4 value = static_cast<IVec4Property*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......
......@@ -36,7 +36,7 @@ namespace campvis {
MetaPropertyLua::~MetaPropertyLua() {
}
std::string MetaPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string MetaPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
return PropertyCollectionLuaScriptGenerator::getLuaScript(propNamePrefix + _property->getName() + "::", luaProc);
}
......
......@@ -51,7 +51,7 @@ namespace campvis {
*/
virtual ~MetaPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
private:
MetaProperty* _property;
......
......@@ -35,11 +35,11 @@ namespace campvis {
OptionPropertyLua::~OptionPropertyLua() {
}
std::string OptionPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string OptionPropertyLua::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):setValue("
+ StringUtils::toString(static_cast<AbstractOptionProperty*>(_property)->getValue() ) + ")";
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):selectById(\""
+ StringUtils::toString(static_cast<AbstractOptionProperty*>(_property)->getOptionId() ) + "\")";
return ret;
}
......
......@@ -49,7 +49,7 @@ namespace campvis {
*/
virtual ~OptionPropertyLua();
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
std::string getLuaScript(const std::string& propNamePrefix, const std::string& luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
......@@ -64,7 +64,7 @@ namespace campvis {
}
}
std::string PropertyCollectionLuaScriptGenerator::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string PropertyCollectionLuaScriptGenerator::getLuaScript(const std::string& propNamePrefix, const std::string& luaProc) {
std::string ret = "";
for (std::map<AbstractProperty*, AbstractPropertyLua*>::iterator it = _luaMap.begin(); it != _luaMap.end(); ++it) {
ret += it->second->getLuaScript(propNamePrefix, luaProc) + "\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment