Skip to main content
15-Moonstone
April 28, 2020
Solved

Vuforia State Formatting issue

  • April 28, 2020
  • 1 reply
  • 4679 views

Hello. I'm trying to implement a dashboard in Vuforia Studio which contains several 3D labels which are connected to real-time information through Thingworx Composer.

I'm interested in applying State Formatting to the 3D labels. My use case is this: I have a value that represents the production quantity, and a boolean property which indicates whether the production is on target or not. I'm interested in binding the value to the 3D label and apply state formatting through another property (the boolean value). This can be perfectly done in Thingworx's Mashups.

 

In Vuforia Studio, however, if I enable State Based Formatting for a label, I have a Dependent Field, and I can choose which State Definition to apply to it. If I leave the Dependent Field value as default ("text"), then it compares the actual text-value of the 3D label to the values that are inside the State Definition, and then applies the corresponding colour. This is not what I need, because I need to apply State Formatting through the boolean property.

 

So I tried binding said property to the Dependent Field, but the colour of the 3D Label is the one shown in the Default state. I went with my intuition, and removed the value binding of the 3D Label text, and replaced it with "true". And, as I anticipated, the label turned green.

 

The conclusion is that the Dependent Field property inside the State Formatting compares the actual String value attached to the 3D Label to the State Definition values INSTEAD OF comparing the bound property value (which in my case, is a boolean property) to the State Definition values.

 

In Thingworx, it is possible to change the colour of a Value Display through a boolean property, and still be able to display the number.

 

In the screenshots below, you can see the 3D Label number being blue when I tried binding the isOnTarget property to the Dependent Field, because it compared 33 to "true" and "false", they don't match, and goes into default colour, which is blue.
actualGreen shows when the number binding is removed and replaced with a static "true" string, it matches the "true" in the State Definition, so it shows green.

I also attached the State Definition, which turns the text green if true, red if false, and blue for default.

 

Has anyone worked with Vuforia State Formatting before and can lend me a hand in this problem?

Best answer by RolandRaytchev

additionaly for state based fromating you review the following posts:

Using Connection Filters for state-based rendering and value formatting

 

One of the ways when you try to use state based formatting  would be to use a different property for the state format comparison (because the value you try to check and the value for the display are different), and then bind the value from the data to both the new property and to the display value.   The display value still gets the filter to add the units, but the other value keeps it as-is.
So for example for gauge the value to a new hidden property:
   setWidgetProp('gauge-1',  'hiddenValue', value)

And then set the dependent field to be  'hiddenValue':
  setWidgetProp('gauge-1',  'stateFormatValue' 'hiddenValue')


1 reply

14-Alexandrite
April 28, 2020

Hi @Radu,

 

I did notice that the  state does not honour the value of "Dependent Field" when "Dependent Field" is bound to other property (not based on 3D label text). Hopefully someone from technical support can solve the mystery. 

 

As a workaround, it is easy to achieve your requirement through code (without state formatting).

 

You can define an application parameter to hold your boolean property value. In the following code sample, I called it "BooleanProperty".   Replace "3DLabel-1" with your 3D label widget name.

 

 

 

$scope.$watch('app.params.BooleanProperty', function(val) {
 
 switch (val) {
 case "true":
 $scope.view.wdg['3DLabel-1']['fontColor'] = "rgba(0,255,0,1)";
 
 break;
 
 	case "false":
 $scope.view.wdg['3DLabel-1']['fontColor'] = "rgba(255,0,0,1)";
 
 break;
 
 }
 $scope.$applyAsync();
});

 

 

 

Hope this helps.

21-Topaz I
April 30, 2020

Hi @Radu ,

one option you c an try is in the solution code to replace:

 $scope.view.wdg['3DLabel-1']['fontColor'] = "rgba(255,0,0,1)";

by $scope.setWidgetProp e.g.  :

 $scope.setWidgetProp(3DLabel-1','fontColor, "rgba(255,0,0,1)");

 

21-Topaz I
May 4, 2020

Hi @Radu ,

in generally may be two possible options:

1.) after setting of property call $scope.applyAssync();

2.) set a value to an application parameter and bind the parameter (if required using filter) to the property

In this case in the javaScript you will set the application parameter - which will update the property via the binding