Setting opParameters in ofParameterGroup


#1

I want to pass an ofParameterGroup for storage of app settings around objects not only for read but also for writing to it - how can I write to a ofParameter that’s stored in a ofParameterGroup?


#2

you need to know it’s type and name and cast it like:

group.getFloat("floatParameter").set(...)

or if the type is not one of the directly supported:

group.get("weirdParameter").cast<uint64_t>().set(...)

#3

Thanks, this did the trick.


#4

One more thing, how can I add an ofParameter from a ofParameterGroup to an ofxDatGuiSlider?


#5

haven’t used ofxDatGui but ofParameter has shallow copy semantics so making a copy of it is just a reference which means that if you do:

ofParameter<float> p = group.getFloat("floatParameter");

p will be a reference to the parameter in the group and if you modify it it’ll modify the original too so you can pass it like that to ofxDatGui or simly just pass the return of group.get*()


#6

Thanks @arturo, it works


#7

Is it possible to add int values or strings to an ofParameterGroup?


#8

you can add any type of ofParameter or other ofParameterGroups but not raw values