Statistics case now has a prototype datamodel and Ui.

The data is not yet used to control the calculations.
p4#: 21116
This commit is contained in:
Jacob Støren 2013-04-03 16:13:49 +02:00
parent 770a81648d
commit ef6ee4a26c
14 changed files with 183 additions and 58 deletions

View File

@ -26,6 +26,7 @@
#include "RigCaseCellResultsData.h"
#include "RimStatisticsCaseEvaluator.h"
#include "RigMainGrid.h"
#include "cafPdmUiTextEditor.h"
namespace caf {
template<>
@ -48,22 +49,38 @@ RimStatisticsCase::RimStatisticsCase()
: RimCase()
{
CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", "");
CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Selected Properties", "", "", "");
m_selectionSummary.setIOWritable(false);
m_selectionSummary.setIOReadable(false);
m_selectionSummary.setUiReadOnly(true);
m_selectionSummary.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
m_selectionSummary.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitFieldNoDefault(&m_resultType, "ResultType", "Result Type", "", "", "");
m_resultType.setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_porosityModel, "PorosityModel", "Porosity Model", "", "", "");
m_porosityModel.setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedStaticProperties, "StaticPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "Dyn Prop", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedStaticProperties, "StaticPropertiesToCalculate", "Stat Prop", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureGeneratedProperties, "FractureGeneratedPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "", "", "", "");
m_selectedDynamicProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedStaticProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedGeneratedProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedInputProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedFractureDynamicProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedFractureStaticProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedFractureGeneratedProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_selectedFractureInputProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_percentileCalculationType, "PercentileCalculationType", "Method", "", "", "");
@ -72,8 +89,9 @@ RimStatisticsCase::RimStatisticsCase()
CAF_PDM_InitField(&m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", "");
CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", "");
updateSelectionListVisibilities();
updateSelectionSummaryLabel();
updatePercentileUiVisibility();
}
//--------------------------------------------------------------------------------------------------
@ -251,7 +269,27 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup()
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
{
uiOrdering.add(&caseName);
caf::PdmUiGroup * group = uiOrdering.addNewGroup("Property Selection");
group->add(&m_selectionSummary);
group->add(&m_resultType);
group->add(&m_porosityModel);
group->add(&m_selectedDynamicProperties);
group->add(&m_selectedStaticProperties);
group->add(&m_selectedGeneratedProperties);
group->add(&m_selectedInputProperties);
group->add(&m_selectedFractureDynamicProperties);
group->add(&m_selectedFractureStaticProperties);
group->add(&m_selectedFractureGeneratedProperties);
group->add(&m_selectedFractureInputProperties);
group = uiOrdering.addNewGroup("Percentiles");
group->add(&m_calculatePercentiles);
group->add(&m_percentileCalculationType);
group->add(&m_lowPercentile);
group->add(&m_midPercentile);
group->add(&m_highPercentile);
}
QList<caf::PdmOptionItemInfo> toOptionList(const QStringList& varList)
@ -334,6 +372,9 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField
{
updateSelectionListVisibilities();
}
updateSelectionSummaryLabel();
updatePercentileUiVisibility();
}
//--------------------------------------------------------------------------------------------------
@ -351,3 +392,79 @@ void RimStatisticsCase::updateSelectionListVisibilities()
m_selectedFractureGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::GENERATED));
m_selectedFractureInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::updateSelectionSummaryLabel()
{
QString html;
html += "<style> "
"p{margin-bottom:0px;} "
"p.indent{margin-left:20px; margin-top:0px;} "
"</style>";
if (m_selectedDynamicProperties().size())
{
html += "<p><b>Dynamic properties:</p></b><p class=indent>";
for (size_t pIdx = 0; pIdx < m_selectedDynamicProperties().size(); ++pIdx)
{
html += "" + m_selectedDynamicProperties()[pIdx] + "<br>";
}
html += "</p>";
}
if (m_selectedStaticProperties().size())
{
html += "<b>Static properties:</b><p class=indent>";
for (size_t pIdx = 0; pIdx < m_selectedStaticProperties().size(); ++pIdx)
{
html += " " + m_selectedStaticProperties()[pIdx] + "<br>";
}
html += "</p>";
}
if (m_selectedGeneratedProperties().size())
{
html += "<b>Generated properties:</b><p class=indent>";
for (size_t pIdx = 0; pIdx < m_selectedGeneratedProperties().size(); ++pIdx)
{
html += " " + m_selectedGeneratedProperties()[pIdx] + "<br>";
}
html += "</p>";
}
if (m_selectedInputProperties().size())
{
html += "<b>Input properties:</b><p class=indent>";
for (size_t pIdx = 0; pIdx < m_selectedInputProperties().size(); ++pIdx)
{
html += " " + m_selectedInputProperties()[pIdx] + "<br>";
}
html += "</p>";
}
m_selectionSummary = html;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (&m_selectionSummary == field)
{
caf::PdmUiTextEditorAttribute* textEditAttrib = dynamic_cast<caf::PdmUiTextEditorAttribute*> (attribute);
textEditAttrib->textMode = caf::PdmUiTextEditorAttribute::HTML;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::updatePercentileUiVisibility()
{
m_percentileCalculationType.setUiHidden( !m_calculatePercentiles());
m_lowPercentile .setUiHidden( !m_calculatePercentiles());
m_midPercentile .setUiHidden( !m_calculatePercentiles());
m_highPercentile.setUiHidden( !m_calculatePercentiles());
}

View File

@ -46,18 +46,11 @@ public:
void setMainGrid(RigMainGrid* mainGrid);
void computeStatistics();
virtual bool openEclipseGridFile();
RimCaseCollection* parentStatisticsCaseCollection();
// Pdm system overrides
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
enum PercentileCalcType
{
EXACT,
@ -70,25 +63,37 @@ private:
void getSourceCases(std::vector<RimCase*>& sourceCases);
void updateSelectionListVisibilities();
void updateSelectionSummaryLabel();
void updatePercentileUiVisibility();
// Pdm system overrides
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute );
// Fields
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType;
caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel;
caf::PdmField<std::vector<QString> > m_selectedDynamicProperties;
caf::PdmField<std::vector<QString> > m_selectedStaticProperties;
caf::PdmField<std::vector<QString> > m_selectedGeneratedProperties;
caf::PdmField<std::vector<QString> > m_selectedInputProperties;
caf::PdmField<QString> m_selectionSummary;
caf::PdmField<std::vector<QString> > m_selectedFractureDynamicProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureStaticProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureGeneratedProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureInputProperties;
caf::PdmField<std::vector<QString> > m_selectedDynamicProperties;
caf::PdmField<std::vector<QString> > m_selectedStaticProperties;
caf::PdmField<std::vector<QString> > m_selectedGeneratedProperties;
caf::PdmField<std::vector<QString> > m_selectedInputProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureDynamicProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureStaticProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureGeneratedProperties;
caf::PdmField<std::vector<QString> > m_selectedFractureInputProperties;
caf::PdmField< bool > m_calculatePercentiles;
caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType;
caf::PdmField<double > m_lowPercentile;
caf::PdmField<double > m_midPercentile;
caf::PdmField<double > m_highPercentile;
caf::PdmField< bool > m_calculatePercentiles;
caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType;
caf::PdmField<double > m_lowPercentile;
caf::PdmField<double > m_midPercentile;
caf::PdmField<double > m_highPercentile;
};

View File

@ -200,7 +200,7 @@ QString PdmUiItem::uiEditorTypeName(const QString& uiConfigName) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::Alignment PdmUiItem::labelAlignment(QString uiConfigName) const
PdmUiItemInfo::LabelPosType PdmUiItem::uiLabelPosition(QString uiConfigName) const
{
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
const PdmUiItemInfo* defInfo = defaultInfo();
@ -210,7 +210,7 @@ Qt::Alignment PdmUiItem::labelAlignment(QString uiConfigName) const
if (defInfo) return defInfo->m_labelAlignment;
if (sttInfo) return sttInfo->m_labelAlignment;
return Qt::AlignLeft;
return PdmUiItemInfo::LEFT;
}
//--------------------------------------------------------------------------------------------------

View File

@ -40,9 +40,11 @@ public:
PdmUiItemInfo( QString uiName, QIcon icon = QIcon(), QString toolTip = "", QString whatsThis = "")
: m_uiName(uiName), m_icon(icon), m_toolTip(toolTip), m_whatsThis(whatsThis),
m_editorTypeName(""), m_isHidden(false), m_isReadOnly(false), m_labelAlignment(Qt::AlignLeft)
m_editorTypeName(""), m_isHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT)
{ }
enum LabelPosType { LEFT, TOP, HIDDEN };
private:
friend class PdmUiItem;
QString m_uiName;
@ -52,7 +54,7 @@ private:
QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem
int m_isHidden; ///< UiItem should be hidden. -1 means not set
int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set.
Qt::Alignment m_labelAlignment;
LabelPosType m_labelAlignment;
};
//==================================================================================================
@ -115,9 +117,10 @@ public:
bool isUiReadOnly(QString uiConfigName = "");
void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; }
Qt::Alignment labelAlignment(QString uiConfigName = "") const;
void setLabelAlignment(Qt::Alignment alignment, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_labelAlignment = alignment; }
PdmUiItemInfo::LabelPosType
uiLabelPosition(QString uiConfigName = "") const;
void setUiLabelPosition(PdmUiItemInfo::LabelPosType alignment, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_labelAlignment = alignment; }
QString uiEditorTypeName(const QString& uiConfigName) const;
void setUiEditorTypeName(const QString& editorTypeName, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_editorTypeName = editorTypeName; }

View File

@ -55,7 +55,6 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -69,7 +69,6 @@ void PdmUiColorEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes);

View File

@ -54,9 +54,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_comboBox->setEnabled(!field()->isUiReadOnly(uiConfigName));
// Demo code for attribute retreival when becoming relevant

View File

@ -258,29 +258,42 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
}
else
{
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
bool labelOnTop = field->labelAlignment(uiConfigName) & Qt::AlignTop;
PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition(uiConfigName);
bool labelOnTop = (labelPos == PdmUiItemInfo::TOP);
bool editorSpanBoth = labelOnTop;
if (fieldLabelWidget)
if (labelPos != PdmUiItemInfo::HIDDEN)
{
fieldLabelWidget->setParent(parent);
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
if (fieldLabelWidget )
{
fieldLabelWidget->setParent(parent);
// Label widget will span two columns if aligned on top
int colSpan = labelOnTop ? 2 : 1;
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop);
// Label widget will span two columns if aligned on top
int colSpan = labelOnTop ? 2 : 1;
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop);
fieldLabelWidget->show();
if (labelOnTop) currentRowIndex++;
if (labelOnTop) currentRowIndex++;
}
}
else
{
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
if (fieldLabelWidget ) fieldLabelWidget->hide();
editorSpanBoth = true; // To span both columns when there is no label
}
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
if (fieldEditorWidget)
{
fieldEditorWidget->setParent(parent); // To make sure this widget has the current group box as parent.
// Label widget will span two columns if aligned on top
int colSpan = labelOnTop ? 2 : 1;
int colIndex = labelOnTop ? 0 : 1;
int colSpan = editorSpanBoth ? 2 : 1;
int colIndex = editorSpanBoth ? 0 : 1;
parentLayout->addWidget(fieldEditorWidget, currentRowIndex, colIndex, 1, colSpan, Qt::AlignTop);
}

View File

@ -87,7 +87,6 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -62,7 +62,6 @@ void PdmUiFilePathEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -60,9 +60,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
PdmUiLineEditorAttribute leab;

View File

@ -111,9 +111,7 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(uiName);
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_listView->setEnabled(!field()->isUiReadOnly(uiConfigName));
/// Demo code Not used yet

View File

@ -55,7 +55,6 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
//m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -56,9 +56,7 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setVisible(!field()->isUiHidden(uiConfigName));
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName));