Wondering if there are any knowledgeable Qt developers out there? Least I assume it would need Qt programming.
What I would like to see is a facility for setting a set of FreeCAD object properties. What I envisage is an option to create a pie chart
with 2 to n parameters and allow the user to drag/rotate the division between the different values. That is I have a number of situations where
a FreeCAD object has 2 to n parameters that have to add up to 100%. How difficult would this be to implement? Rather than have a heavy
learning curve it would be great if somebody with existing knowledge was able to implement something.
I might be wrong but with the current ability to change properties I can only see having to check values and issue warning message if
values do not add up to 100.
Thanks in anticipation.
Any clever QT programmers out there?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Any clever QT programmers out there?
hmm. i think you should provide some concept art on what you want to get implemented.
also learning curve is not that steep. mostly copy-paste
https://doc.qt.io/qtforpython/tutorials ... ialog.html
also learning curve is not that steep. mostly copy-paste
https://doc.qt.io/qtforpython/tutorials ... ialog.html
Re: Any clever QT programmers out there?
G'day Keith
I asked my mates Phil, Trevor , Jagger and Simon what they thought. They just stared back at me, vomited up their dinner into their mouths, chewed it again for a bit and then swallowed it again......the only verbal response they gave was "Moooo".....but they are steers. Sorry but I couldn't help myself,...more cow references.
But seriously, now some questions. How would these work? Is it your intention to store this as a single FreeCAD object property containing a list or tuple etc. of values or "n" inter dependent separate properties? If the first I assume you would have to fire up a dialogue if someone tried to edit via the standard property editor to ensure that the total did not exceed 100%, sounds complex. If the second, then for the case of n=2, it seems to me a simple solution could be to simple make property 1 editable in a spinbox in the normal property editor like some other properties and then make property 2 read only and derived from "100%-property 1".
Do your users ever need to be able to directly edit the value of "n value" or can it always just be read only derived from "100%- (sum of 1 to n-1)"?
Where n>2, if you change one, where does it deduct its portion from? What is the logic? For example, do the n values have a hierarchy where gains in one are deducted from the next value until that next value reaches 0 at which point it remains 0 and further increases in the original are then deducted from the next+1 value, etc.? Or would the increase in one value be deducted from all other values, if so then on what basis? Lineally or proportionally to the other values proportion of the remainder?
It is possible to have unlimited semi-independent number like placement angle XZY today where 45 degrees with XYZ all = 1 gives the same result as xyz all =10, where the percentage is calculated on the properties proportion of the total of the N values. But I doubt you would want to do that.
Jim
i am definitely not one of those, however I have some questions, I have been thinking about your post all evening. I have some questions.
I asked my mates Phil, Trevor , Jagger and Simon what they thought. They just stared back at me, vomited up their dinner into their mouths, chewed it again for a bit and then swallowed it again......the only verbal response they gave was "Moooo".....but they are steers. Sorry but I couldn't help myself,...more cow references.
But seriously, now some questions. How would these work? Is it your intention to store this as a single FreeCAD object property containing a list or tuple etc. of values or "n" inter dependent separate properties? If the first I assume you would have to fire up a dialogue if someone tried to edit via the standard property editor to ensure that the total did not exceed 100%, sounds complex. If the second, then for the case of n=2, it seems to me a simple solution could be to simple make property 1 editable in a spinbox in the normal property editor like some other properties and then make property 2 read only and derived from "100%-property 1".
Do your users ever need to be able to directly edit the value of "n value" or can it always just be read only derived from "100%- (sum of 1 to n-1)"?
Where n>2, if you change one, where does it deduct its portion from? What is the logic? For example, do the n values have a hierarchy where gains in one are deducted from the next value until that next value reaches 0 at which point it remains 0 and further increases in the original are then deducted from the next+1 value, etc.? Or would the increase in one value be deducted from all other values, if so then on what basis? Lineally or proportionally to the other values proportion of the remainder?
It is possible to have unlimited semi-independent number like placement angle XZY today where 45 degrees with XYZ all = 1 gives the same result as xyz all =10, where the percentage is calculated on the properties proportion of the total of the N values. But I doubt you would want to do that.
Jim
- tanderson69
- Veteran
- Posts: 1626
- Joined: Thu Feb 18, 2010 1:07 am
Re: Any clever QT programmers out there?
You could create some kind 'pie' control, but you would probably have to get into custom drawing of control. I think a simpler solution is to use sliders that modify other sliders equally to maintain your desired sum. You could also lock values so other slider changes wouldn't affect those locked values.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Any clever QT programmers out there?
Okay let me elaborate.
The situation is occurring trying to deal with GDML materials and elements
Here is an example of how each is defined in GDML i.e. an XML file.
In both cases the sum of fractions need to add upto one. i.e. 100%
Currently as there is a variable number of fractions I implement these as groups
I would therefore see the facility as working on groups i.e. an edit option for the group.
The situation is occurring trying to deal with GDML materials and elements
Here is an example of how each is defined in GDML i.e. an XML file.
Code: Select all
<element name="Iron0x56070eea0880">
<fraction n="0.05845" ref="Fe540x56070ee87130" />
<fraction n="0.91754" ref="Fe560x56070ee95300" />
<fraction n="0.02119" ref="Fe570x56070ee8eff0" />
<fraction n="0.00282" ref="Fe580x56070ee8d300" />
</element>
Code: Select all
<material name="SSteel0x56070ee87d10">
<T unit="K" value="293.15" />
<MEE unit="eV" value="282.530633667015" />
<D unit="g/cm3" value="1.286547719061e-18" />
<fraction n="0.74" ref="Iron0x56070eea0880" />
<fraction n="0.18" ref="Chromium0x56070eea004" />
<fraction n="0.08" ref="Nickel0x56070ee81420" />
</material>
Currently as there is a variable number of fractions I implement these as groups
I would therefore see the facility as working on groups i.e. an edit option for the group.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Any clever QT programmers out there?
Can one display the current value of the slider?tanderson69 wrote: ↑Fri Aug 02, 2019 5:26 pm You could create some kind 'pie' control, but you would probably have to get into custom drawing of control. I think a simpler solution is to use sliders that modify other sliders equally to maintain your desired sum. You could also lock values so other slider changes wouldn't affect those locked values.
sliders.png
Think it would have to work on the basis if I change one slider it also adjust the one immediately below so that they all add up to one or 100%
Think evenly adjusting all the other values not being adjusted would make it HARD for the user to get to a desired result.
- tanderson69
- Veteran
- Posts: 1626
- Joined: Thu Feb 18, 2010 1:07 am
Re: Any clever QT programmers out there?
Sure and make it an edit box so user can type in a value also.
That is what the 'lock' is for.keithsloan52 wrote: ↑Tue Aug 06, 2019 3:46 am Think evenly adjusting all the other values not being adjusted would make it HARD for the user to get to a desired result.
Re: Any clever QT programmers out there?
So..., I kind off made an implementation to explore the concept. https://github.com/exargon/Qt-PieChartWidget
Probably more elegant ways to implement it, but it is a working implementation you could use as a starting point or inspiration.
A few notes:
I made an abstract base class with the logic. It could be used for other visualizations (e.g. a linear version more aligned with normal sliders).
I only implemented color as the visual for the different sectors (as well as their index I guess), as string labels are more complicated to visualize nicely.
The widget should accept simple styling, but it has no custom styleoptions.
I made an example widget (you can make it with example.pro) that you can use to experiment with the inputs and outputs of the widget.
Probably more elegant ways to implement it, but it is a working implementation you could use as a starting point or inspiration.
A few notes:
I made an abstract base class with the logic. It could be used for other visualizations (e.g. a linear version more aligned with normal sliders).
I only implemented color as the visual for the different sectors (as well as their index I guess), as string labels are more complicated to visualize nicely.
The widget should accept simple styling, but it has no custom styleoptions.
I made an example widget (you can make it with example.pro) that you can use to experiment with the inputs and outputs of the widget.