Skip to content

Commit

Permalink
Do not allow setting start value for inputs (#12059)
Browse files Browse the repository at this point in the history
Fixes #11608
  • Loading branch information
adeas31 committed Mar 4, 2024
1 parent d9aa256 commit c0f2cbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp
Expand Up @@ -236,7 +236,7 @@ Parameter::Parameter(ModelInstance::Element *pElement, ElementParameters *pEleme
mConnectorSizing = dialogAnnotation.isConnectorSizing();

// If mShowStartAttribute is not set then check for start modifier
if (!mShowStartAndFixed && !isParameter() && mpModelInstanceElement->getModifier()) {
if (!mShowStartAndFixed && !isParameter() && !isInput() && mpModelInstanceElement->getModifier()) {
mShowStartAndFixed = mpModelInstanceElement->getModifier()->hasModifier("start");
}
/* if mShowStartAndFixed and group name is empty then set group name to Initialization.
Expand Down Expand Up @@ -377,6 +377,20 @@ bool Parameter::isParameter() const
}
}

/*!
* \brief Parameter::isInput
* Returns true if input
* \return
*/
bool Parameter::isInput() const
{
if (mpModelInstanceElement) {
return mpModelInstanceElement->getDirectionPrefix().compare(QStringLiteral("input")) == 0;
} else {
return mpElement->getElementInfo()->getCausality().compare("input") == 0;
}
}

/*!
* \brief Parameter::updateNameLabel
* Updates the name label.
Expand Down Expand Up @@ -1309,11 +1323,11 @@ void ElementParameters::applyFinalStartFixedAndDisplayUnitModifiers(Parameter *p
if (MainWindow::instance()->getOMCProxy()->isBuiltinType(pParameter->getModelInstanceElement()->getRootType())) {
const QString value = pModifier->getValue();
// if value is not empty then use it otherwise try to read start and fixed modifiers
if (pParameter->isShowStartAttribute() || (value.isEmpty() && !pParameter->isParameter())) {
if (pParameter->isShowStartAttribute() || (value.isEmpty() && !pParameter->isParameter() && !pParameter->isInput())) {
bool hasStart = pModifier->hasModifier("start");
bool hasFixed = pModifier->hasModifier("fixed");
if (hasStart || hasFixed) {
if (!pParameter->isGroupDefined() && !pParameter->isParameter()) {
if (!pParameter->isGroupDefined() && !pParameter->isParameter() && !pParameter->isInput()) {
pParameter->setGroup("Initialization");
}
pParameter->setShowStartAndFixed(true);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Element/ElementProperties.h
Expand Up @@ -81,6 +81,7 @@ class Parameter : public QObject
Element* getElement() {return mpElement;}
ModelInstance::Element* getModelInstanceElement() {return mpModelInstanceElement;}
bool isParameter() const;
bool isInput() const;
void setTab(QString tab) {mTab = tab;}
const StringAnnotation &getTab() {return mTab;}
void setGroup(QString group) {mGroup = group;}
Expand Down

0 comments on commit c0f2cbf

Please sign in to comment.