Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 3dviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jan 27, 2017
2 parents 5511336 + 4bf74df commit 3bd67d9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -783,7 +783,7 @@ QVariant ShapeAnnotation::getDynamicValue(QString name)
VariablesTreeModel *pVariablesTreeModel = pMainWindow->getVariablesWidget()->getVariablesTreeModel();
VariablesTreeItem *pVariablesTreeItem = pVariablesTreeModel->findVariablesTreeItem(fullName, pVariablesTreeModel->getRootVariablesTreeItem());
if (pVariablesTreeItem != NULL) {
dynamicValue = pVariablesTreeItem->getValue(pVariablesTreeItem->getUnit(), pMainWindow->getOMCProxy());
dynamicValue = pVariablesTreeItem->getValue(pVariablesTreeItem->getPreviousUnit(), pVariablesTreeItem->getUnit());
}
}
}
Expand Down
32 changes: 31 additions & 1 deletion OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -2170,7 +2170,37 @@ void LibraryTreeModel::readLibraryTreeItemClassTextFromText(LibraryTreeItem *pLi
} else if (lineNumber > pLibraryTreeItem->mClassInformation.lineNumberEnd) {
after += currentLine + "\n";
} else if (pLibraryTreeItem->inRange(lineNumber)) {
text += currentLine + "\n";
/* Ticket #4233
* We could have code like this,
*
* package P
* package Q
* model M1
* end M1;
*
* model M2
* end M2; end Q;
* end P;
*
* So we need to conside column start and end.
*/
if (lineNumber == pLibraryTreeItem->mClassInformation.lineNumberStart) {
QString leftStr = currentLine.left(pLibraryTreeItem->mClassInformation.columnNumberStart - 1);
int nonSpaceIndex = TabSettings::firstNonSpace(leftStr);
/* If there is no other text on the first line of class then take the whole line.
*/
if (nonSpaceIndex >= pLibraryTreeItem->mClassInformation.columnNumberStart - 1) {
text += currentLine + "\n";
} else {
before += currentLine.left(pLibraryTreeItem->mClassInformation.columnNumberStart - 1);
text += currentLine.mid(pLibraryTreeItem->mClassInformation.columnNumberStart - 1) + "\n";
}
} else if (lineNumber == pLibraryTreeItem->mClassInformation.lineNumberEnd) {
text += currentLine.left(pLibraryTreeItem->mClassInformation.columnNumberEnd);
after += currentLine.mid(pLibraryTreeItem->mClassInformation.columnNumberEnd) + "\n";
} else {
text += currentLine + "\n";
}
}
lineNumber++;
}
Expand Down
32 changes: 20 additions & 12 deletions OMEdit/OMEditGUI/Plotting/VariablesWidget.cpp
Expand Up @@ -247,15 +247,17 @@ VariablesTreeItem* VariablesTreeItem::rootParent()
* \brief VariablesTreeItem::getValue
* Returns the value in the desired unit or
* an empty value in case of conversion error.
* \param fromUnit
* \param toUnit
* \return
*/
QVariant VariablesTreeItem::getValue(QString unit, OMCProxy *pOMCProxy)
QVariant VariablesTreeItem::getValue(QString fromUnit, QString toUnit)
{
QString value = "";
if (mPreviousUnit.compare(unit) == 0) {
if (fromUnit.compare(toUnit) == 0) {
value = mValue;
}
else {
OMCInterface::convertUnits_res convertUnit = pOMCProxy->convertUnits(mPreviousUnit, unit);
} else {
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(fromUnit, toUnit);
if (convertUnit.unitsCompatible) {
bool ok = false;
qreal realValue = mValue.toDouble(&ok);
Expand Down Expand Up @@ -1094,7 +1096,8 @@ void VariablesWidget::readVariablesAndUpdateXML(VariablesTreeItem *pVariablesTre
/* Ticket #2250, 4031
* We need to convert the value to base unit since the values stored in init xml are always in base unit.
*/
QString value = pChildVariablesTreeItem->getValue(pChildVariablesTreeItem->getUnit(), MainWindow::instance()->getOMCProxy()).toString();
QString value = pChildVariablesTreeItem->getValue(pChildVariablesTreeItem->getDisplayUnit(),
pChildVariablesTreeItem->getUnit()).toString();
QString variableToFind = pChildVariablesTreeItem->getVariableName();
variableToFind.remove(QRegExp(outputFileName + "."));
QHash<QString, QString> hash;
Expand Down Expand Up @@ -1244,15 +1247,20 @@ void VariablesWidget::plotVariables(const QModelIndex &index, qreal curveThickne
pPlotWindow->setUnit(pVariablesTreeItem->getUnit());
pPlotWindow->setDisplayUnit(pVariablesTreeItem->getDisplayUnit());
pPlotWindow->plot(pPlotCurve);
/* Ticket:4231
* Only update the variables browser value and unit when updating some curve not when checking/unchecking variable.
*/
if (pPlotCurve) {
/* Ticket:2250
* Update the value of Variables Browser display unit according to the display unit of already plotted curve.
*/
pVariablesTreeItem->setData(3, pPlotCurve->getDisplayUnit(), Qt::EditRole);
QString value = pVariablesTreeItem->getValue(pVariablesTreeItem->getPreviousUnit(), pVariablesTreeItem->getDisplayUnit()).toString();
pVariablesTreeItem->setData(1, value, Qt::EditRole);
}
if (!pPlotCurve) {
pPlotCurve = pPlotWindow->getPlot()->getPlotCurvesList().last();
}
/* Ticket:2250
* Update the value of Variables Browser display unit according to the display unit of already plotted curve.
*/
pVariablesTreeItem->setData(3, pPlotCurve->getDisplayUnit(), Qt::EditRole);
QString value = pVariablesTreeItem->getValue(pVariablesTreeItem->getDisplayUnit(), MainWindow::instance()->getOMCProxy()).toString();
pVariablesTreeItem->setData(1, value, Qt::EditRole);
if (pPlotCurve && pVariablesTreeItem->getUnit().compare(pVariablesTreeItem->getDisplayUnit()) != 0) {
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(pVariablesTreeItem->getUnit(),
pVariablesTreeItem->getDisplayUnit());
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Plotting/VariablesWidget.h
Expand Up @@ -78,7 +78,7 @@ class VariablesTreeItem
VariablesTreeItem* parent() {return mpParentVariablesTreeItem;}
VariablesTreeItem* parent() const {return mpParentVariablesTreeItem;}
VariablesTreeItem* rootParent();
QVariant getValue(QString unit, OMCProxy *pOMCProxy);
QVariant getValue(QString fromUnit, QString toUnit);
private:
QList<VariablesTreeItem*> mChildren;
VariablesTreeItem *mpParentVariablesTreeItem;
Expand Down

0 comments on commit 3bd67d9

Please sign in to comment.