#2102 Statistics dialog. Adjust text edit height to its contents

This commit is contained in:
Bjørn Erik Jensen 2017-11-17 08:30:23 +01:00
parent 30e3622ad4
commit 41db3e8b10
3 changed files with 17 additions and 2 deletions

View File

@ -67,6 +67,7 @@ RicGridStatisticsDialog::RicGridStatisticsDialog(QWidget* parent)
QVBoxLayout* plotLayout = new QVBoxLayout(); QVBoxLayout* plotLayout = new QVBoxLayout();
plotLayout->setSpacing(0); plotLayout->setSpacing(0);
//plotLayout->addStretch();
plotLayout->addWidget(m_historgramPlot); plotLayout->addWidget(m_historgramPlot);
plotLayout->addWidget(m_aggregatedPlot); plotLayout->addWidget(m_aggregatedPlot);
layout->addLayout(plotLayout); layout->addLayout(plotLayout);
@ -102,6 +103,7 @@ void RicGridStatisticsDialog::setInfoText(RimView* view)
text = overlayInfo->caseInfoText(); text = overlayInfo->caseInfoText();
text += overlayInfo->resultInfoText(overlayInfo->histogramData()); text += overlayInfo->resultInfoText(overlayInfo->histogramData());
m_textEdit->setText(text); m_textEdit->setText(text);
adjustTextEditHeightToContent();
} }
} }
@ -223,6 +225,15 @@ QwtPlotMarker* RicGridStatisticsDialog::createVerticalPlotMarker(const QColor& c
return marker; return marker;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicGridStatisticsDialog::adjustTextEditHeightToContent()
{
int docHeight = m_textEdit->document()->size().height();
m_textEdit->setFixedHeight(docHeight + 10);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -49,6 +49,7 @@ private:
void deletePlotItems(QwtPlot* plot); void deletePlotItems(QwtPlot* plot);
static void setMarkers(const Rim3dOverlayInfoConfig::HistogramData& histData, QwtPlot* plot); static void setMarkers(const Rim3dOverlayInfoConfig::HistogramData& histData, QwtPlot* plot);
static QwtPlotMarker* createVerticalPlotMarker(const QColor& color, double xValue); static QwtPlotMarker* createVerticalPlotMarker(const QColor& color, double xValue);
void adjustTextEditHeightToContent();
private slots: private slots:
void slotDialogFinished(); void slotDialogFinished();

View File

@ -592,11 +592,14 @@ void Rim3dOverlayInfoConfig::showStatisticsInfoDialog()
{ {
if (m_viewDef) if (m_viewDef)
{ {
// Show dialog before setting data due to text edit auto height setting
m_gridStatisticsDialog->resize(600, 800);
m_gridStatisticsDialog->show();
m_gridStatisticsDialog->setLabel("Grid statistics"); m_gridStatisticsDialog->setLabel("Grid statistics");
m_gridStatisticsDialog->setInfoText(m_viewDef); m_gridStatisticsDialog->setInfoText(m_viewDef);
m_gridStatisticsDialog->setHistogramData(m_viewDef); m_gridStatisticsDialog->setHistogramData(m_viewDef);
m_gridStatisticsDialog->resize(600, 800);
m_gridStatisticsDialog->show();
m_gridStatisticsDialog->raise(); m_gridStatisticsDialog->raise();
} }
} }