Opened 8 years ago
Closed 8 years ago
#4081 closed defect (fixed)
OMEdit ignores modified displayUnit
Reported by: | Rüdiger Franke | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | high | Milestone: | 1.11.0 |
Component: | OMEdit | Version: | v1.11.0 |
Keywords: | Cc: |
Description
Open DisplayUnit.Test
in the diagram view and double click on the model m
. The parameter dialog will show the parameter T in degC
instead of the modified K
.
package DisplayUnit type Temperature = Real(unit = "K", displayUnit = "degC"); model M parameter Temperature T; end M; model Test M m(T(displayUnit = "K") = 300) annotation(Placement(visible = true, transformation(origin = {1, -1}, extent = {{-51, -51}, {51, 51}}, rotation = 0))); end Test; end DisplayUnit;
Change History (5)
comment:1 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Look at the slightly modified example (degF instead of K):
package DisplayUnitF type Temperature = Real(unit = "K", displayUnit = "degC"); model M parameter Temperature T; end M; model Test M m(T(displayUnit = "degF") = 300) annotation(Placement(visible = true, transformation(origin = {1, -1}, extent = {{-51, -51}, {51, 51}}, rotation = 0))); end Test; end DisplayUnitF;
It appears that the first check always returns an empty value (ComponentProperties.cpp:87ff):
/* Get displayUnit value * First check if displayUnit is defined with in the component modifier. * If no displayUnit is found then check it in the derived class modifier value. * A derived class can be inherited, so look recursively. */ QString displayUnit = mpComponent->getComponentInfo()->getModifiersMap(pOMCProxy, className, mpComponent).value("displayUnit"); if (displayUnit.isEmpty()) { ... seems to always arrive here ... }
comment:3 by , 8 years ago
No, that's not the problem. You are looking at a wrong place.
Basically we construct the drop down with two items i.e., K
and degC
. Then OMEdit reads the modifiers and got degF
. OMEdit then tries to find degF
in the drop down and fails.
ComponentProperties.cpp:896 - 903
if (modifiersIterator.key().compare(parameterName + ".displayUnit") == 0) { QString displayUnit = StringHandler::removeFirstLastQuotes(modifiersIterator.value()); int index = pParameter->getUnitComboBox()->findText(displayUnit, Qt::MatchExactly); if (index > -1) { pParameter->getUnitComboBox()->setCurrentIndex(index); pParameter->setDisplayUnit(displayUnit); } }
One idea is if index
is -1 then add the display unit to the drop down and select it. However, I am not sure what will happen if convertUnits
fails. OMEdit will show a wrong values then.
comment:5 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in d605fc7/OMEdit.