I’m currently trying to create a viewpoint that will change some existing components background color based on some conditions and I’m not sure what would be the best approach. As far as possible, I would like this operation to be a kind of “background” task permanently running, so it seems to be that some sort of listener would fit the need, maybe a ResourceSetListener as suggested in this post
First I went through basic viewpoints code (price, mass, perf) but I dont want to add an extension to existing elements, just read their PVMT values and change background color according to value. Moreover, from what I pulled from Git I did not get any services.vptext file, though the whole viewpoints logic is in their, so I was not able to debug as much as I would have like.
Second approach, I added my logic in a service rule, so that I can run it on demand. However I did not succeed to modify the appearence of components and the more I dig in Capella and EMF code the more I get confused. Below is what I’ve tried to so far :
But the components are never updated. This code is inspired from :
It seems to me that I’m definetly not editing the good element.
In addition I’ve also tried to use and was also wondering what was the “good” approach. So, what would be the correct approach to edit component background color and where I can find relevant documentation ? (Sirus, Kitalpha, EMF, Capella ?)
Thanks in advance for any help !
I finally succeeded to do what I wanted. Below is the code I used if it can be of any help. I did not notice any behavior difference between and so I don’t know what should be prefered.
Did you already hear about PVMT(Property Value Management Tool) and DiagramStyler? The first one is used to define a PV metamodel and apply it on elements depending on scopes. The second one change the element style in sirius diagram depending on PV values.
You can have a look to help you:
I’m well aware of PVMT but style customizations features are not wide enough for my needs. I ended up using a custom .odesign for this project.