diff --git a/GUI/coregui/Models/IntensityDataItem.cpp b/GUI/coregui/Models/IntensityDataItem.cpp index 037fd62a434c6a0d0f887d75292697152db90702..c438f185e13b13164262e8104800036998e7e314 100644 --- a/GUI/coregui/Models/IntensityDataItem.cpp +++ b/GUI/coregui/Models/IntensityDataItem.cpp @@ -41,7 +41,6 @@ const QString IntensityDataItem::T_MASKS = "Mask tag"; IntensityDataItem::IntensityDataItem() : SessionItem(Constants::IntensityDataType) { -// registerProperty(OBSOLETE_P_NAME, Constants::IntensityDataType).setHidden(); setItemName(Constants::IntensityDataType); ComboProperty units; @@ -63,14 +62,14 @@ IntensityDataItem::IntensityDataItem() addProperty(P_PROPERTY_PANEL_FLAG, false)->setVisible(false); - addGroupProperty(P_XAXIS, Constants::BasicAxisType); - getGroupItem(P_XAXIS)->getItem(BasicAxisItem::P_NBINS)->setVisible(false); + SessionItem *item = addGroupPropertyTmp(P_XAXIS, Constants::BasicAxisType); + item->getItem(BasicAxisItem::P_NBINS)->setVisible(false); - addGroupProperty(P_YAXIS, Constants::BasicAxisType); - getGroupItem(P_YAXIS)->getItem(BasicAxisItem::P_NBINS)->setVisible(false); + item = addGroupPropertyTmp(P_YAXIS, Constants::BasicAxisType); + item->getItem(BasicAxisItem::P_NBINS)->setVisible(false); - addGroupProperty(P_ZAXIS, Constants::AmplitudeAxisType); - getGroupItem(P_ZAXIS)->getItem(BasicAxisItem::P_NBINS)->setVisible(false); + item = addGroupPropertyTmp(P_ZAXIS, Constants::AmplitudeAxisType); + item->getItem(BasicAxisItem::P_NBINS)->setVisible(false); registerTag(T_MASKS, 0, -1, QStringList() << Constants::MaskContainerType); setDefaultTag(T_MASKS); @@ -110,12 +109,12 @@ void IntensityDataItem::setOutputData(OutputData<double> *data) double IntensityDataItem::getLowerX() const { - return getGroupItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); + return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); } double IntensityDataItem::getUpperX() const { - return getGroupItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); + return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); } double IntensityDataItem::getXmin() const @@ -132,12 +131,12 @@ double IntensityDataItem::getXmax() const double IntensityDataItem::getLowerY() const { - return getGroupItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); + return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); } double IntensityDataItem::getUpperY() const { - return getGroupItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); + return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); } double IntensityDataItem::getYmin() const @@ -154,12 +153,12 @@ double IntensityDataItem::getYmax() const double IntensityDataItem::getLowerZ() const { - return getGroupItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); + return getItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MIN).toDouble(); } double IntensityDataItem::getUpperZ() const { - return getGroupItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); + return getItem(P_ZAXIS)->getItemValue(BasicAxisItem::P_MAX).toDouble(); } QString IntensityDataItem::getGradient() const @@ -170,7 +169,7 @@ QString IntensityDataItem::getGradient() const bool IntensityDataItem::isLogz() const { - return getGroupItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_IS_LOGSCALE).toBool(); + return getItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_IS_LOGSCALE).toBool(); } bool IntensityDataItem::isInterpolated() const @@ -180,22 +179,22 @@ bool IntensityDataItem::isInterpolated() const QString IntensityDataItem::getXaxisTitle() const { - return getGroupItem(P_XAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); + return getItem(P_XAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } QString IntensityDataItem::getYaxisTitle() const { - return getGroupItem(P_YAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); + return getItem(P_YAXIS)->getItemValue(BasicAxisItem::P_TITLE).toString(); } bool IntensityDataItem::isZAxisLocked() const { - return getGroupItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX).toBool(); + return getItem(P_ZAXIS)->getItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX).toBool(); } void IntensityDataItem::setZAxisLocked(bool state) { - return getGroupItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX, state); + return getItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_LOCK_MIN_MAX, state); } //! Sets the name of intensity data item from proposed name. This name will be used to save file @@ -215,47 +214,47 @@ QString IntensityDataItem::getSelectedAxesUnits() const void IntensityDataItem::setLowerX(double xmin) { - getGroupItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MIN, xmin); + getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MIN, xmin); } void IntensityDataItem::setUpperX(double xmax) { - getGroupItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MAX, xmax); + getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_MAX, xmax); } void IntensityDataItem::setLowerY(double ymin) { - getGroupItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MIN, ymin); + getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MIN, ymin); } void IntensityDataItem::setUpperY(double ymax) { - getGroupItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MAX, ymax); + getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_MAX, ymax); } void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) { if(getLowerZ() != zmin) { - getGroupItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN, zmin); + getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN, zmin); } if(getUpperZ() != zmax) { - getGroupItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX, zmax); + getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX, zmax); } } void IntensityDataItem::setLowerZ(double zmin) { - getGroupItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN, zmin); + getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MIN, zmin); } void IntensityDataItem::setUpperZ(double zmax) { - getGroupItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX, zmax); + getItem(P_ZAXIS)->setItemValue(BasicAxisItem::P_MAX, zmax); } void IntensityDataItem::setLogz(bool logz) { - getGroupItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_IS_LOGSCALE, logz); + getItem(P_ZAXIS)->setItemValue(AmplitudeAxisItem::P_IS_LOGSCALE, logz); } void IntensityDataItem::setInterpolated(bool interp) @@ -265,12 +264,12 @@ void IntensityDataItem::setInterpolated(bool interp) void IntensityDataItem::setXaxisTitle(QString xtitle) { - getGroupItem(P_XAXIS)->setItemValue(BasicAxisItem::P_TITLE, xtitle); + getItem(P_XAXIS)->setItemValue(BasicAxisItem::P_TITLE, xtitle); } void IntensityDataItem::setYaxisTitle(QString ytitle) { - getGroupItem(P_YAXIS)->setItemValue(BasicAxisItem::P_TITLE, ytitle); + getItem(P_YAXIS)->setItemValue(BasicAxisItem::P_TITLE, ytitle); } //! set zoom range of x,y axes to axes of input data diff --git a/GUI/coregui/Models/SessionItem.cpp b/GUI/coregui/Models/SessionItem.cpp index cb0629159678128e623155226cf11ca6420ced30..85bfb8528c0e31dbef877f5e4188adbfcebec5d0 100644 --- a/GUI/coregui/Models/SessionItem.cpp +++ b/GUI/coregui/Models/SessionItem.cpp @@ -676,15 +676,27 @@ void SessionItem::setDefaultTag(const QString &tag) */ QString SessionItem::displayName() const { - if (m_parent) { + QString result = data(SessionModel::DisplayNameRole).toString(); + + if(modelType() == Constants::PropertyType || modelType() == Constants::GroupItemType || + modelType() == Constants::ParameterLabelType) return result; + + if(m_parent) { + QString tag = m_parent->tagFromItem(this); + SessionTagInfo info = m_parent->getTagInfo(tag); + // if only one child of this type is allowed, return name without change + if (info.min == 1 && info.max == 1 && info.childCount == 1) { + return result; + } + int index = m_parent->getCopyNumberOfChild(this); - if (index >= 0 && modelType() != Constants::PropertyType && - modelType() != Constants::GroupItemType && modelType() != Constants::ParameterLabelType - && modelType() != Constants::ParameterType) { - return data(SessionModel::DisplayNameRole).toString() + QString::number(index); + if(index > 0) { + return result + QString::number(index); } + } - return data(SessionModel::DisplayNameRole).toString(); + + return result; } /*! diff --git a/GUI/coregui/Models/SessionXML.cpp b/GUI/coregui/Models/SessionXML.cpp index f7688c46690fd96958f1a39557cec41b641c9cb6..07e3c3df49b68ab41d306c4e24e49cb8a5fda7b8 100644 --- a/GUI/coregui/Models/SessionXML.cpp +++ b/GUI/coregui/Models/SessionXML.cpp @@ -194,37 +194,6 @@ void SessionReader::readItems(QXmlStreamReader *reader, SessionItem *item, const if (reader->attributes().hasAttribute(SessionXML::DisplayNameAttribute)) { new_item->setDisplayName(reader->attributes().value(SessionXML::DisplayNameAttribute).toString()); } - - - -// qDebug() << "QQQ 1.3"; -// SessionItem *new_item = ItemFactory::createItem(model_type); -// qDebug() << "QQQ 1.3.1" << new_item << new_item->modelType(); -// Q_ASSERT(new_item); -// if (reader->attributes().hasAttribute(SessionXML::DisplayNameAttribute)) { -// new_item->setDisplayName(reader->attributes().value(SessionXML::DisplayNameAttribute).toString()); -// } -// if (tag == "") -// tag = item->defaultTag(); - -// qDebug() << "QQQ 1.3.2"; -// if (!item->insertItem(-1, new_item, tag)) { -// // this must be VectorItem or similar registered via addProperty mechanism -// qDebug() << "QQQ 1.3.3"; - -// SessionTagInfo info = item->getTagInfo(tag); -// if (info.max == info.childCount && info.childCount == 1) { -// qDebug() << "QQQ 1.3.4"; -// delete item->takeItem(0, tag); -// bool result = item->insertItem(-1, new_item, tag); -// qDebug() << "QQQ 1.3.5" << result; -// } else { -// throw GUIHelpers::Error("SessionReader::readItems -> Error. " -// "Can't insert item 1.2"); -// } - -// } - item = new_item; } if (!item) { diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMapPlot.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMapPlot.cpp index a44de840523da165b8593f57391640834942b715..272167802dde7e1d15b73b6829c086f177d1f648 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMapPlot.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMapPlot.cpp @@ -72,7 +72,7 @@ void ColorMapPlot::setItem(IntensityDataItem *item) mapper->setOnChildPropertyChange( [this](SessionItem* item, const QString name) { - if (item->parent() && item->parent()->modelType() == Constants::GroupItemType) +// if (item->parent() && item->parent()->modelType() == Constants::GroupItemType) onSubItemPropertyChanged(item->itemName(), name); }); } @@ -371,7 +371,7 @@ void ColorMapPlot::onSubItemPropertyChanged(const QString &property_group, setLogz(m_item->isLogz()); } else if (property_name == BasicAxisItem::P_IS_VISIBLE) { - setColorScaleVisible(m_item->getGroupItem(IntensityDataItem::P_ZAXIS) + setColorScaleVisible(m_item->getItem(IntensityDataItem::P_ZAXIS) ->getItemValue(BasicAxisItem::P_IS_VISIBLE).toBool()); } m_customPlot->replot(); @@ -511,7 +511,7 @@ void ColorMapPlot::plotItem(IntensityDataItem *intensityItem) ++it; } - setColorScaleVisible(intensityItem->getGroupItem(IntensityDataItem::P_ZAXIS) + setColorScaleVisible(intensityItem->getItem(IntensityDataItem::P_ZAXIS) ->getItemValue(BasicAxisItem::P_IS_VISIBLE).toBool()); m_colorMap->setGradient(m_gradient_map[intensityItem->getGradient()]); diff --git a/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp b/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp index 2c10ee7146bffcfedf8db2ef068aace6c03fc755..11555c500b1e3ea04055b8d3a87ea574fed74d91 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp +++ b/GUI/coregui/Views/PropertyEditor/ComponentEditor.cpp @@ -188,6 +188,11 @@ ComponentEditor::componentItems(SessionItem *item) const result.append(child); } + else if (child->modelType() == Constants::BasicAxisType || + child->modelType() == Constants::AmplitudeAxisType) { + result.append(child); + } + if (item->modelType() == Constants::GroupItemType) { foreach (SessionItem *childOfChild, child->childItems()) { result.append(childOfChild);