From bef1d8ce7e5225a40e8320d70ef78473c5c32524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 26 Sep 2013 10:41:08 +0200 Subject: [PATCH 1/3] caf: Enabled the Tooltips. Seems to have been forgotten. --- Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp | 1 + Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp | 2 ++ Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp | 3 +++ Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp | 3 +++ Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp | 2 ++ Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp | 5 +++++ Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp | 2 ++ 7 files changed, 18 insertions(+) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp index 952fea8265..748cf69a9a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxEditor.cpp @@ -77,6 +77,7 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setToolTip(field()->uiToolTip(uiConfigName)); m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_checkBox->setToolTip(field()->uiToolTip(uiConfigName)); PdmUiCheckBoxEditorAttribute attributes; field()->ownerObject()->editorAttribute(field(), uiConfigName, &attributes); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp index 3a1cf5f2d9..1b3f92c7b7 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFilePathEditor.cpp @@ -81,8 +81,10 @@ void PdmUiFilePathEditor::configureAndUpdateUi(const QString& uiConfigName) } m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_lineEdit->setToolTip(field()->uiToolTip(uiConfigName)); field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 6264738415..fbcc9c26da 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -79,7 +79,10 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) } m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); + m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_lineEdit->setToolTip(field()->uiToolTip(uiConfigName)); PdmUiLineEditorAttribute leab; field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 56bb5a5412..059d7e4c52 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -130,7 +130,10 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName) } m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); + m_listView->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_listView->setToolTip(field()->uiToolTip(uiConfigName)); /// Demo code Not used yet // PdmUiListEditorAttribute attributes; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp index 4fabc348dd..67fdfa6384 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -77,6 +77,8 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) //m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_pushButton->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_pushButton->setToolTip(field()->uiToolTip(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); PdmUiPushButtonEditorAttribute attributes; field()->ownerObject()->editorAttribute(field(), uiConfigName, &attributes); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp index 48c08aaf51..c395611f10 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp @@ -75,8 +75,13 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName) } m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); + m_spinBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_spinBox->setToolTip(field()->uiToolTip(uiConfigName)); + m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_slider->setToolTip(field()->uiToolTip(uiConfigName)); field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp index e8eb28a1af..6771e82559 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp @@ -80,9 +80,11 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName) } //m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_label->setToolTip(field()->uiToolTip(uiConfigName)); m_textEdit->setReadOnly(field()->isUiReadOnly(uiConfigName)); //m_textEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); // Neccesary ? + m_textEdit->setToolTip(field()->uiToolTip(uiConfigName)); PdmUiTextEditorAttribute leab; field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab); From a283d6ac234155864a15bb36c9def3e9edd6422e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 26 Sep 2013 10:44:20 +0200 Subject: [PATCH 2/3] Legend: Now number format is really based on number of Significant digits. Brushed up the labels and organized the ui into two groups. Added some tooltips as well. --- .../ProjectDataModel/RimLegendConfig.cpp | 40 +++++++++++++++---- .../ProjectDataModel/RimLegendConfig.h | 5 ++- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 52c5d7f18f..7e917ed8fc 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -106,13 +106,13 @@ RimLegendConfig::RimLegendConfig() m_localAutoNegClosestToZero(0) { CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "",""); - CAF_PDM_InitField(&m_precision, "Precision", 2, "Precision", "", "",""); - CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Precision", "", "",""); + CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "A hint on how many tick marks you whish.",""); + CAF_PDM_InitField(&m_precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); + CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); - CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Color range", "", "", ""); + CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", ""); CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", ""); - CAF_PDM_InitField(&m_rangeMode, "RangeType", caf::AppEnum(AUTOMATIC_ALLTIMESTEPS), "Legend range type", "", "Switches between automatic and user defined range on the legend", ""); + CAF_PDM_InitField(&m_rangeMode, "RangeType", caf::AppEnum(AUTOMATIC_ALLTIMESTEPS), "Range type", "", "Switches between automatic and user defined range on the legend", ""); CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Min value of the legend", ""); CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Max value of the legend", ""); CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", ""); @@ -366,12 +366,14 @@ void RimLegendConfig::updateLegend() if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE) { - decadesInRange = abs(adjustedMin - adjustedMax) ? abs(adjustedMin) : abs(adjustedMax); + // For log mapping, use the min value as reference for num valid digits + decadesInRange = abs(adjustedMin) < abs(adjustedMax) ? abs(adjustedMin) : abs(adjustedMax); decadesInRange = log10(decadesInRange); } else { - double absRange = abs(adjustedMax - adjustedMin); + // For linear mapping, use the max value as reference for num valid digits + double absRange = CVF_MAX(abs(adjustedMax), abs(adjustedMin)); decadesInRange = log10(absRange); } @@ -382,7 +384,11 @@ void RimLegendConfig::updateLegend() m_legend->setTickFormat((cvf::OverlayScalarMapperLegend::NumberFormat)nft); // Set the fixed number of digits after the decimal point to the number needed to show all the significant digits. - int numDecimalDigits = m_precision() - decadesInRange; + int numDecimalDigits = m_precision(); + if (nft != SCIENTIFIC) + { + numDecimalDigits -= decadesInRange; + } m_legend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); @@ -569,3 +575,21 @@ void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, doub updateLegend(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiOrdering * formatGr = uiOrdering.addNewGroup("Format"); + formatGr->add(&m_numLevels); + formatGr->add(&m_precision); + formatGr->add(&m_tickNumberFormat); + formatGr->add(&m_colorRangeMode); + + caf::PdmUiOrdering * mappingGr = uiOrdering.addNewGroup("Mapping"); + mappingGr->add(&m_mappingMode); + mappingGr->add(&m_rangeMode); + mappingGr->add(&m_userDefinedMaxValue); + mappingGr->add(&m_userDefinedMinValue); +} + diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index a98341298c..3b4e1cdd92 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -98,11 +98,14 @@ public: protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void initAfterRead(); + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); private: void updateFieldVisibility(); cvf::ref interpolateColorArray(const cvf::Color3ubArray& colorArray, cvf::uint targetColorCount); double roundToNumSignificantDigits(double value, double precision); - + + + private: caf::PdmPointer m_reservoirView; From a4bcbf6115f78819cdf987e8f49afb62f3b21891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 26 Sep 2013 11:48:41 +0200 Subject: [PATCH 3/3] Merge from origin --- .../cafPdmUiTreeViewEditor.cpp | 20 +++++++++---------- .../cafUserInterface/cafUiTreeModelPdm.cpp | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index c1f2c32702..f2653ed19f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -54,19 +54,19 @@ class MySortFilterProxyModel : public QSortFilterProxyModel { public: - MySortFilterProxyModel(QObject *parent = 0) - : QSortFilterProxyModel(parent) - { - - } - - void notifyModelChanged() - { + MySortFilterProxyModel(QObject *parent = 0) + : QSortFilterProxyModel(parent) + { + + } + + void notifyModelChanged() + { QModelIndex startModelIdx = index(0,0); QModelIndex endModelIdx = index(rowCount(startModelIdx), 0); emit dataChanged(startModelIdx, endModelIdx); - } + } }; @@ -112,7 +112,7 @@ QWidget* PdmUiTreeViewEditor::createWidget(QWidget* parent) m_proxyTreeModelPdm->setSourceModel(m_treeModelPdm); m_treeView->setModel(m_proxyTreeModelPdm); - m_treeView->setSortingEnabled(true); + m_treeView->setSortingEnabled(true); m_treeView->sortByColumn(1, Qt::AscendingOrder); diff --git a/Fwk/AppFwk/cafUserInterface/cafUiTreeModelPdm.cpp b/Fwk/AppFwk/cafUserInterface/cafUiTreeModelPdm.cpp index 03005d6698..5c5718e878 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafUiTreeModelPdm.cpp @@ -503,7 +503,7 @@ void UiTreeModelPdm::notifyModelChanged() //-------------------------------------------------------------------------------------------------- QVariant UiTreeModelPdm::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole */) const { - if (role != Qt::DisplayRole) + if (role != Qt::DisplayRole) return QVariant(); if (section < m_columnHeaders.size())