diff --git a/GUI/coregui/Models/AxesItems.cpp b/GUI/coregui/Models/AxesItems.cpp index 591d905a94ff7e5f90439e2020b3142b3a4f1305..c11d5536454adfadf5fb347976c66e8d5e50028a 100644 --- a/GUI/coregui/Models/AxesItems.cpp +++ b/GUI/coregui/Models/AxesItems.cpp @@ -21,7 +21,7 @@ const QString BasicAxisItem::P_NBINS = "Nbins"; const QString BasicAxisItem::P_MIN = "Min"; const QString BasicAxisItem::P_MAX = "Max"; const QString BasicAxisItem::P_TITLE = "title"; -//const QString BasicAxisItem::P_TITLE_IS_VISIBLE = "Title Visibility"; +const QString BasicAxisItem::P_TITLE_IS_VISIBLE = "Title Visibility"; static const int max_detector_pixels = 65536; @@ -45,6 +45,7 @@ void BasicAxisItem::register_basic_properties() addProperty(P_MAX, -1.0)->setDecimals(3); getItem(P_MAX)->setLimits(RealLimits::limitless()); addProperty(P_TITLE, QString()); + addProperty(P_TITLE_IS_VISIBLE, true)->setVisible(false); } // ---------------------------------------------------------------------------------------------- // diff --git a/GUI/coregui/Models/AxesItems.h b/GUI/coregui/Models/AxesItems.h index 384a4950d49354af1ac50d12cb5559332c2b50f7..a6c5ac751d5748ee80d43e87a7e67fa4c2e79b0d 100644 --- a/GUI/coregui/Models/AxesItems.h +++ b/GUI/coregui/Models/AxesItems.h @@ -27,7 +27,7 @@ public: static const QString P_MIN; static const QString P_MAX; static const QString P_TITLE; -// static const QString P_TITLE_IS_VISIBLE; + static const QString P_TITLE_IS_VISIBLE; explicit BasicAxisItem(const QString &type=Constants::BasicAxisType); // bool isAxisLabelVisible() const; diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp index bfd22d32f87f3ad43ae10134e3f17e1cc00239d9..7bdd1d2d97e2df4eba1458a3af8e1d0ac418b28b 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.cpp @@ -166,7 +166,6 @@ void FitComparisonWidget::processJobItemItem(JobItem *jobItem) }, this); m_realDataItem = m_currentJobItem->realDataItem()->intensityDataItem(); - backupLabels(m_realDataItem); } void FitComparisonWidget::onResetViewAction() @@ -201,8 +200,6 @@ void FitComparisonWidget::setSimulatedDataItem(IntensityDataItem *simulatedDataI m_simulatedDataItem = 0; }, this); - backupLabels(simulatedDataItem); - } //! Creates an IntensityDataItem which will hold relative difference map between simulation @@ -237,27 +234,15 @@ void FitComparisonWidget::calculateRelativeDifference() } -//! Backup axes labels for given item. Labels will be returned back when FitComparisonWidget -//! is hidden. - -void FitComparisonWidget::backupLabels(IntensityDataItem *intensityItem) -{ - LabelBackup data; - data.xlabel = intensityItem->xAxisItem()->getItemValue(BasicAxisItem::P_TITLE).toString(); - data.ylabel = intensityItem->yAxisItem()->getItemValue(BasicAxisItem::P_TITLE).toString(); - m_labelBackup[intensityItem] = data; -} - //! Restores item labels from the backup. void FitComparisonWidget::restoreLabels(IntensityDataItem *intensityItem) { - QMap<IntensityDataItem *, LabelBackup>::iterator it = m_labelBackup.find(intensityItem); - if(it != m_labelBackup.end()) { - LabelBackup lb = it.value(); - intensityItem->xAxisItem()->setItemValue(BasicAxisItem::P_TITLE, lb.xlabel); - intensityItem->yAxisItem()->setItemValue(BasicAxisItem::P_TITLE, lb.ylabel); - } + if(!intensityItem) + return; + + intensityItem->xAxisItem()->setItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE, true); + intensityItem->yAxisItem()->setItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE, true); } //! Removes axes label from item. This is because they occupy too much space on this dense widget. @@ -267,6 +252,6 @@ void FitComparisonWidget::removeLabels(IntensityDataItem *intensityItem) if(!intensityItem) return; - intensityItem->xAxisItem()->setItemValue(BasicAxisItem::P_TITLE, QString()); - intensityItem->yAxisItem()->setItemValue(BasicAxisItem::P_TITLE, QString()); + intensityItem->xAxisItem()->setItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE, false); + intensityItem->yAxisItem()->setItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE, false); } diff --git a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h index 4824988a28351176b6fbd771905d598a31bdedf0..5f305b60098d92c0c0d42143463acadc1aec7e6e 100644 --- a/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h +++ b/GUI/coregui/Views/FitWidgets/FitComparisonWidget.h @@ -53,16 +53,11 @@ protected: private: - struct LabelBackup { - QString xlabel, ylabel; - }; - void processJobItemItem(JobItem *jobItem); void setSimulatedDataItem(IntensityDataItem *simulatedDataItem); IntensityDataItem *createRelativeDifferenceItem(); void calculateRelativeDifference(); - void backupLabels(IntensityDataItem *intensityItem); void restoreLabels(IntensityDataItem *intensityItem); void removeLabels(IntensityDataItem *intensityItem); @@ -70,7 +65,6 @@ private: ColorMapCanvas *m_simulatedDataPlot; ColorMapCanvas *m_relativeDiffPlot; - FitFlowWidget *m_fitFlowWidget; ColorMapLabel *m_statusLabel; @@ -82,7 +76,6 @@ private: QAction *m_resetViewAction; SessionModel *m_tempIntensityDataModel; - QMap<IntensityDataItem *, LabelBackup> m_labelBackup; }; #endif // FITCOMPARISONWIDGET_H diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp index f5a1ea80e3ec78fed7b767209335b69938670dcd..ee6684fe6a17ebd43e3bd0585834d634931dcebe 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp @@ -156,18 +156,18 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro if (m_block_update) return; + if (propertyName == BasicAxisItem::P_TITLE || + propertyName == BasicAxisItem::P_TITLE_IS_VISIBLE) { + setAxesLabelsFromItem(intensityItem()); + replot(); + } + if (axisName == IntensityDataItem::P_XAXIS) { if (propertyName == BasicAxisItem::P_MIN || propertyName == BasicAxisItem::P_MAX) { setAxesRangeConnected(false); m_customPlot->xAxis->setRange(ColorMapUtils::itemZoomX(intensityItem())); setAxesRangeConnected(true); replot(); - } else if (propertyName == BasicAxisItem::P_TITLE) { - m_customPlot->xAxis->setLabel(intensityItem()->getXaxisTitle()); - m_colorScale->setMargins(QMargins(0, 0, 0, 0)); - // a hack to make MarginGroup working - // m_customPlot->plotLayout()->simplify(); - replot(); } } else if (axisName == IntensityDataItem::P_YAXIS) { if (propertyName == BasicAxisItem::P_MIN || propertyName == BasicAxisItem::P_MAX) { @@ -175,9 +175,6 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro m_customPlot->yAxis->setRange(ColorMapUtils::itemZoomY(intensityItem())); setAxesRangeConnected(true); replot(); - } else if (propertyName == BasicAxisItem::P_TITLE) { - m_customPlot->yAxis->setLabel(intensityItem()->getYaxisTitle()); - replot(); } } @@ -349,7 +346,7 @@ void ColorMap::setColorMapFromItem(IntensityDataItem* intensityItem) setAxesRangeFromItem(intensityItem); setAxesZoomFromItem(intensityItem); - setLabelsFromItem(intensityItem); + setAxesLabelsFromItem(intensityItem); setDataFromItem(intensityItem); setColorScaleAppearanceFromItem(intensityItem); setDataRangeFromItem(intensityItem); @@ -381,10 +378,22 @@ void ColorMap::setAxesZoomFromItem(IntensityDataItem* item) //! Sets X,Y axes labels from item -void ColorMap::setLabelsFromItem(IntensityDataItem* item) +void ColorMap::setAxesLabelsFromItem(IntensityDataItem* item) { - m_customPlot->xAxis->setLabel(item->getXaxisTitle()); - m_customPlot->yAxis->setLabel(item->getYaxisTitle()); + auto xaxis = item->xAxisItem(); + if(xaxis->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) + m_customPlot->xAxis->setLabel(item->getXaxisTitle()); + else + m_customPlot->xAxis->setLabel(QString()); + + m_colorScale->setMargins(QMargins(0, 0, 0, 0)); + + auto yaxis = item->yAxisItem(); + if(yaxis->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) + m_customPlot->yAxis->setLabel(item->getYaxisTitle()); + else + m_customPlot->yAxis->setLabel(QString()); + } //! Sets the intensity values to ColorMap. diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h index 413fed75dedb0138136a5901e121c07bbde183fa..dbd9089b260185b4604fefb17f1d0509e97a4665 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.h @@ -107,7 +107,7 @@ private: void setColorMapFromItem(IntensityDataItem* intensityItem); void setAxesRangeFromItem(IntensityDataItem* item); void setAxesZoomFromItem(IntensityDataItem* item); - void setLabelsFromItem(IntensityDataItem* item); + void setAxesLabelsFromItem(IntensityDataItem* item); void setDataFromItem(IntensityDataItem* item); void setColorScaleAppearanceFromItem(IntensityDataItem* item); void setDataRangeFromItem(IntensityDataItem* item); diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp index 1930c107aebfdf6d2fd7dc60bce1998d03c86492..cb94d4607ccced89d370e1af1e4c52eb9e96c5de 100644 --- a/auto/Wrap/libBornAgainCore_wrap.cpp +++ b/auto/Wrap/libBornAgainCore_wrap.cpp @@ -5984,7 +5984,7 @@ SWIG_AsVal_std_complex_Sl_double_Sg_ (PyObject *o, std::complex<double>* val) SWIGINTERNINLINE PyObject* -SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/usr/share/swig3.0/typemaps/swigmacros.swg,104,%ifcplusplus@*/ +SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/home/pospelov/software/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ const std::complex<double>& diff --git a/auto/Wrap/libBornAgainFit_wrap.cpp b/auto/Wrap/libBornAgainFit_wrap.cpp index 182abc5541c99f92f98a78439a7f630a79c6657c..980a19744c597e8ce4355eef1f3bbad544cc94ca 100644 --- a/auto/Wrap/libBornAgainFit_wrap.cpp +++ b/auto/Wrap/libBornAgainFit_wrap.cpp @@ -5627,7 +5627,7 @@ SWIG_AsVal_std_complex_Sl_double_Sg_ (PyObject *o, std::complex<double>* val) SWIGINTERNINLINE PyObject* -SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/usr/share/swig3.0/typemaps/swigmacros.swg,104,%ifcplusplus@*/ +SWIG_From_std_complex_Sl_double_Sg_ (/*@SWIG:/home/pospelov/software/local/share/swig/3.0.8/typemaps/swigmacros.swg,104,%ifcplusplus@*/ const std::complex<double>&