Jump to content

Dynamic changes to Switch PropertyParameters


photo

Recommended Posts

Hello there,

I am using following in my C++ component code.

PROP_PARAM(Switch, sub_device_id, 0, "None", "SubDevice ID", "VIDEO I/O port Index", "General");

When I create this property I am assigning None. When My component will get activated after User assigns property to any node, I want to enumerate the probable values for this property parameter.

Suppose I will do this in Init method. Now I want to set the enumerated values to the switch parameter. Can I do this?

and another close question related to this.

How can I add callback to this sub_device_id?

Regards,

Rohit

Link to comment

Please advise about Switch Property Parameter.

Quote

How can I add callback to this sub_device_id?

This I have fixed with simple getters from ComponentVaribale. 

Rohit

 

Link to comment

Hi Rohit,

I see a small mistake. Please change your PROP_PARAM to this:

PROP_PARAM(Switch, sub_device_id, 0, "None,SubDevice ID,VIDEO I/O port Index,General");

All items must be in a one string with "," letter as a separator without spaces.

I want to enumerate the probable values for this property parameter
You can do it as follows:

PropertyParameterPtr parameter = property->getParameterPtr(sub_device_id.getID());
for (int i = 0; i < parameter->getSwitchNumItems(); i++)
	Log::message("%d) %s = %d\n", i, parameter->getSwitchItemName(i), parameter->getSwitchItemValue(i));

 

Best regards,
Alexander

Link to comment

Dear Alexander,

You did not understand my question. I want to make it dynamic. I didn't find any API supporting this. But this would be very essential thing for handling many dynamic scenarios with properties.

I have already started it like this which is a static approach for my work.

PROP_PARAM(Switch, sub_device_id, 0, "None,Device-1,Device-2,Device-3,Device-4,Device-5,Device-6,Device-7,Device-8,Device-9,Device-10", "SubDevice ID", "BMD cards Sub Device Index:: I/O port Index", "General");

My Question is Suppose in my property I make it "None" as items.

When I put This component on Node. The init will call. Now I enumerate some Capture cards installed in the system. If there are one capture card with one Device(I/O) and another with 4 Devices. Then combined I need to show "None, Device-1,....Device-5"

I want this thing to happen to switch parameters where we can change the items at runtime. Like we can do with arrays parameters.

I hope you understand my problem now.

Regards,

Rohit

Link to comment
  • 3 weeks later...

Hi!

The main purpose of property is comfortable scene logic creation in the Editor - https://developer.unigine.com/en/docs/future/code/formats/property_format?rlang=cpp

As I understand you want to change items of switch parameter in realtime, probably in Editor. If you want do it you should decline Component System and write your own property generator. For Editor you can do this via UnigineScript or custom C++ plugin.

Link to comment

Dear @moroz,

Quote

As I understand you want to change items of switch parameter in realtime, probably in Editor. 

You guessed my exact requirement accurately. But when I see the properties structure and component way of working is just great. Even the array thing is dynamic and works charm in editor. I can resize it in real time. If one such functionality come for switch. It will be a great addition to the dynamic nature of component system and everything will be just awesome.

In a small way, if switch property parameter holds a vector of strings, things can be easily made dynamic like arrays.  [ I am still unaware of internals but a suggestion].

I think many applications would require this dynamic nature of switch parameter. Right now I am just working on my things with this limitation, but It would be appreciated to have this feature. Otherwise custom implementation would always be required.

Regards,

Rohit

Link to comment
×
×
  • Create New...