mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2194 RelPerm Plot: Added context menu to show ascii text version of current plot data. Refactor of existing RicTextWidget into RiuTextDialog.
This commit is contained in:
@@ -46,7 +46,6 @@ ${SOURCE_GROUP_SOURCE_FILES}
|
||||
|
||||
set (QT_MOC_HEADERS
|
||||
${QT_MOC_HEADERS}
|
||||
${CEE_CURRENT_LIST_DIR}RicShowPlotDataFeature.h
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -25,146 +25,15 @@
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
#include "RiuTools.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QBoxLayout>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicShowPlotDataFeature, "RicShowPlotDataFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
/// RiuQPlainTextEdit
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if ( e->key() == Qt::Key_C && e->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
slotCopyContentToClipboard();
|
||||
e->setAccepted(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPlainTextEdit::keyPressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotCopyContentToClipboard()
|
||||
{
|
||||
QTextCursor cursor(this->textCursor());
|
||||
|
||||
QString textForClipboard;
|
||||
|
||||
QString selText = cursor.selectedText();
|
||||
if (!selText.isEmpty())
|
||||
{
|
||||
QTextDocument doc;
|
||||
doc.setPlainText(selText);
|
||||
|
||||
textForClipboard = doc.toPlainText();
|
||||
}
|
||||
|
||||
if (textForClipboard.isEmpty())
|
||||
{
|
||||
textForClipboard = this->toPlainText();
|
||||
}
|
||||
|
||||
if (!textForClipboard.isEmpty())
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
clipboard->setText(textForClipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotSelectAll()
|
||||
{
|
||||
this->selectAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
/// RicTextWidget
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicTextWidget::RicTextWidget(QWidget* parent)
|
||||
: QDialog(parent, RiuTools::defaultDialogFlags())
|
||||
{
|
||||
m_textEdit = new RiuQPlainTextEdit(this);
|
||||
m_textEdit->setReadOnly(true);
|
||||
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
|
||||
QFont font("Courier", 8);
|
||||
m_textEdit->setFont(font);
|
||||
|
||||
m_textEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(m_textEdit);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTextWidget::setText(const QString& text)
|
||||
{
|
||||
m_textEdit->setPlainText(text);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicTextWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
{
|
||||
QAction* actionToSetup = new QAction(this);
|
||||
|
||||
actionToSetup->setText("Copy");
|
||||
actionToSetup->setIcon(QIcon(":/Copy.png"));
|
||||
actionToSetup->setShortcuts(QKeySequence::Copy);
|
||||
|
||||
connect(actionToSetup, SIGNAL(triggered()), m_textEdit, SLOT(slotCopyContentToClipboard()));
|
||||
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
{
|
||||
QAction* actionToSetup = new QAction(this);
|
||||
|
||||
actionToSetup->setText("Select All");
|
||||
actionToSetup->setShortcuts(QKeySequence::SelectAll);
|
||||
|
||||
connect(actionToSetup, SIGNAL(triggered()), m_textEdit, SLOT(slotSelectAll()));
|
||||
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -239,7 +108,7 @@ void RicShowPlotDataFeature::showTextWindow(const QString& title, const QString&
|
||||
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow();
|
||||
CVF_ASSERT(plotwindow);
|
||||
|
||||
RicTextWidget* textWiget = new RicTextWidget();
|
||||
RiuTextDialog* textWiget = new RiuTextDialog();
|
||||
textWiget->setMinimumSize(400, 600);
|
||||
|
||||
textWiget->setWindowTitle(title);
|
||||
|
||||
@@ -20,44 +20,6 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
|
||||
class RiuQPlainTextEdit : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RiuQPlainTextEdit(QWidget *parent = 0) : QPlainTextEdit(parent) {}
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void slotCopyContentToClipboard();
|
||||
void slotSelectAll();
|
||||
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RicTextWidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RicTextWidget(QWidget* parent = 0);
|
||||
|
||||
void setText(const QString& text);
|
||||
|
||||
private:
|
||||
RiuQPlainTextEdit* m_textEdit;
|
||||
protected:
|
||||
virtual void contextMenuEvent(QContextMenuEvent *) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
@@ -37,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuSelectionManager.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuTextDialog.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.h
|
||||
@@ -101,6 +102,7 @@ ${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuSelectionManager.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuTextDialog.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.cpp
|
||||
@@ -147,6 +149,7 @@ ${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuTextDialog.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuViewer.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.h
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "RiuRelativePermeabilityPlotUpdater.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "RigFlowDiagSolverInterface.h"
|
||||
|
||||
@@ -40,6 +41,8 @@
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QButtonGroup>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -166,7 +169,7 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText)
|
||||
void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString caseName, QString cellReferenceText)
|
||||
{
|
||||
//cvf::Trace::show("Set RelPerm plot data");
|
||||
|
||||
@@ -174,6 +177,7 @@ void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSyst
|
||||
m_allCurvesArr = relPermCurves;
|
||||
m_swat = swat;
|
||||
m_sgas = sgas;
|
||||
m_caseName = caseName;
|
||||
m_cellReferenceText = cellReferenceText;
|
||||
|
||||
plotUiSelectedCurves();
|
||||
@@ -195,6 +199,7 @@ void RiuRelativePermeabilityPlotPanel::clearPlot()
|
||||
m_allCurvesArr.clear();
|
||||
m_swat = HUGE_VAL;
|
||||
m_sgas = HUGE_VAL;
|
||||
m_caseName.clear();
|
||||
m_cellReferenceText.clear();
|
||||
|
||||
plotCurvesInQwt(m_unitSystem, m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, false, m_qwtPlot, &m_myPlotMarkers);
|
||||
@@ -213,26 +218,9 @@ RiuRelativePermeabilityPlotUpdater* RiuRelativePermeabilityPlotPanel::plotUpdate
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
|
||||
{
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves;
|
||||
|
||||
// Determine which curves to actually plot based on selection in GUI
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode epsModeToShow = m_showUnscaledCheckBox->isChecked() ? RigFlowDiagSolverInterface::RelPermCurve::EPS_OFF : RigFlowDiagSolverInterface::RelPermCurve::EPS_ON;
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves = gatherUiSelectedCurves();
|
||||
|
||||
const bool useLogScale = m_logarithmicScaleKrAxisCheckBox->isChecked() ? true : false;
|
||||
|
||||
for (size_t i = 0; i < m_allCurvesArr.size(); i++)
|
||||
{
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::Ident curveIdent = m_allCurvesArr[i].ident;
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode curveEpsMode = m_allCurvesArr[i].epsMode;
|
||||
|
||||
if (curveEpsMode == epsModeToShow) {
|
||||
if (m_selectedCurvesButtonGroup->button(curveIdent) && m_selectedCurvesButtonGroup->button(curveIdent)->isChecked())
|
||||
{
|
||||
selectedCurves.push_back(m_allCurvesArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plotCurvesInQwt(m_unitSystem, selectedCurves, m_swat, m_sgas, m_cellReferenceText, useLogScale, m_qwtPlot, &m_myPlotMarkers);
|
||||
}
|
||||
|
||||
@@ -254,7 +242,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
|
||||
myPlotMarkers->clear();
|
||||
|
||||
|
||||
//ValueRange leftYAxisValueRange;
|
||||
bool shouldEnableRightYAxis = false;
|
||||
|
||||
for (size_t i = 0; i < curveArr.size(); i++)
|
||||
@@ -268,11 +255,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
|
||||
plotOnWhichYAxis = RIGHT_YAXIS;
|
||||
}
|
||||
|
||||
//if (plotOnWhichYAxis == LEFT_YAXIS)
|
||||
//{
|
||||
// leftYAxisValueRange.add(calcValueRange(curve.yVals, logScaleLeftAxis));
|
||||
//}
|
||||
|
||||
|
||||
//QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str());
|
||||
RiuLineSegmentQwtPlotCurve* qwtCurve = new RiuLineSegmentQwtPlotCurve(curve.name.c_str());
|
||||
@@ -363,11 +345,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
|
||||
plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
|
||||
//plot->setAxisAutoScale(QwtPlot::yLeft, true);
|
||||
}
|
||||
|
||||
//if (leftYAxisValueRange.min <= leftYAxisValueRange.max)
|
||||
//{
|
||||
// //plot->setAxisScale(QwtPlot::yLeft, leftYAxisValueRange.min, leftYAxisValueRange.max);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -472,37 +449,6 @@ void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuRelativePermeabilityPlotPanel::ValueRange RiuRelativePermeabilityPlotPanel::calcValueRange(const std::vector<double>& valueArr, bool includePositiveValuesOnly)
|
||||
{
|
||||
ValueRange range;
|
||||
|
||||
for (double v : valueArr)
|
||||
{
|
||||
if (v == HUGE_VAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (includePositiveValuesOnly && v <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v < range.min)
|
||||
{
|
||||
range.min = v;
|
||||
}
|
||||
if (v > range.max)
|
||||
{
|
||||
range.max = v;
|
||||
}
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Assumes that all the x-values are ordered in increasing order
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -543,6 +489,124 @@ double RiuRelativePermeabilityPlotPanel::interpolatedCurveYValue(const std::vect
|
||||
return y;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> RiuRelativePermeabilityPlotPanel::gatherUiSelectedCurves() const
|
||||
{
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves;
|
||||
|
||||
// Determine which curves to actually plot based on selection in GUI
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode epsModeToShow = m_showUnscaledCheckBox->isChecked() ? RigFlowDiagSolverInterface::RelPermCurve::EPS_OFF : RigFlowDiagSolverInterface::RelPermCurve::EPS_ON;
|
||||
|
||||
for (size_t i = 0; i < m_allCurvesArr.size(); i++)
|
||||
{
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::Ident curveIdent = m_allCurvesArr[i].ident;
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode curveEpsMode = m_allCurvesArr[i].epsMode;
|
||||
|
||||
if (curveEpsMode == epsModeToShow) {
|
||||
if (m_selectedCurvesButtonGroup->button(curveIdent) && m_selectedCurvesButtonGroup->button(curveIdent)->isChecked())
|
||||
{
|
||||
selectedCurves.push_back(m_allCurvesArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selectedCurves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuRelativePermeabilityPlotPanel::asciiDataForUiSelectedCurves() const
|
||||
{
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves = gatherUiSelectedCurves();
|
||||
|
||||
QString outTxt;
|
||||
|
||||
// Info header
|
||||
outTxt += m_caseName + ", " + m_cellReferenceText + "\n";
|
||||
|
||||
// Column headers
|
||||
for (size_t icurve = 0; icurve < selectedCurves.size(); icurve++)
|
||||
{
|
||||
if (icurve > 0) outTxt += "\t";
|
||||
|
||||
const RigFlowDiagSolverInterface::RelPermCurve& curve = selectedCurves[icurve];
|
||||
outTxt += "Saturation";
|
||||
outTxt += "\t";
|
||||
outTxt += curve.name.c_str();
|
||||
}
|
||||
|
||||
// Table data
|
||||
size_t sampleIndex = 0;
|
||||
bool iterationContributedData = true;
|
||||
while (iterationContributedData)
|
||||
{
|
||||
iterationContributedData = false;
|
||||
|
||||
QString lineStr = "\n";
|
||||
|
||||
for (size_t icurve = 0; icurve < selectedCurves.size(); icurve++)
|
||||
{
|
||||
if (icurve > 0) lineStr += "\t";
|
||||
|
||||
const RigFlowDiagSolverInterface::RelPermCurve& curve = selectedCurves[icurve];
|
||||
if (sampleIndex < curve.saturationVals.size() && sampleIndex < curve.yVals.size())
|
||||
{
|
||||
lineStr += QString::number(curve.saturationVals[sampleIndex], 'g', 6);
|
||||
lineStr += "\t";
|
||||
lineStr += QString::number(curve.yVals[sampleIndex], 'g', 6);
|
||||
|
||||
iterationContributedData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lineStr += "\t";
|
||||
}
|
||||
}
|
||||
|
||||
if (iterationContributedData)
|
||||
{
|
||||
outTxt += lineStr;
|
||||
}
|
||||
|
||||
sampleIndex++;
|
||||
}
|
||||
|
||||
return outTxt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
const int curveCount = m_qwtPlot->itemList(QwtPlotItem::Rtti_PlotCurve).count();
|
||||
|
||||
QAction* act = menu.addAction("Show Plot Data", this, SLOT(slotCurrentPlotDataInTextDialog()));
|
||||
act->setEnabled(curveCount > 0);
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::slotCurrentPlotDataInTextDialog()
|
||||
{
|
||||
QString outTxt = asciiDataForUiSelectedCurves();
|
||||
|
||||
RiuTextDialog* textDialog = new RiuTextDialog(this);
|
||||
textDialog->setMinimumSize(400, 600);
|
||||
textDialog->setWindowTitle("Relative Permeability Data");
|
||||
textDialog->setText(outTxt);
|
||||
textDialog->show();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
RiuRelativePermeabilityPlotPanel(QDockWidget* parent);
|
||||
virtual ~RiuRelativePermeabilityPlotPanel();
|
||||
|
||||
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText);
|
||||
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString caseName, QString cellReferenceText);
|
||||
void clearPlot();
|
||||
RiuRelativePermeabilityPlotUpdater* plotUpdater();
|
||||
|
||||
@@ -75,18 +75,24 @@ private:
|
||||
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);
|
||||
static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
|
||||
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
|
||||
static ValueRange calcValueRange(const std::vector<double>& valueArr, bool includePositiveValuesOnly);
|
||||
static double interpolatedCurveYValue(const std::vector<double>& xVals, const std::vector<double>& yVals, double x);
|
||||
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> gatherUiSelectedCurves() const;
|
||||
QString asciiDataForUiSelectedCurves() const;
|
||||
|
||||
virtual void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void slotButtonInButtonGroupClicked(int);
|
||||
void slotSomeCheckBoxStateChanged(int);
|
||||
void slotCurrentPlotDataInTextDialog();
|
||||
|
||||
private:
|
||||
RiaEclipseUnitTools::UnitSystem m_unitSystem;
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr;
|
||||
double m_swat;
|
||||
double m_sgas;
|
||||
QString m_caseName;
|
||||
QString m_cellReferenceText;
|
||||
QwtPlot* m_qwtPlot;
|
||||
std::vector<QwtPlotMarker*> m_myPlotMarkers;
|
||||
|
||||
@@ -153,8 +153,9 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse
|
||||
//cvf::Trace::show("cellSWAT = %f cellSGAS = %f cellSATNUM = %f", cellSWAT, cellSGAS, cellSATNUM);
|
||||
|
||||
QString cellRefText = constructCellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex, cellSATNUM);
|
||||
QString caseName = eclipseResultCase->caseUserDescription;
|
||||
|
||||
plotPanel->setPlotData(eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, cellRefText);
|
||||
plotPanel->setPlotData(eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, caseName, cellRefText);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
158
ApplicationCode/UserInterface/RiuTextDialog.cpp
Normal file
158
ApplicationCode/UserInterface/RiuTextDialog.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuTextDialog.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
/// RiuQPlainTextEdit
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if ( e->key() == Qt::Key_C && e->modifiers() == Qt::ControlModifier )
|
||||
{
|
||||
slotCopyContentToClipboard();
|
||||
e->setAccepted(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPlainTextEdit::keyPressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotCopyContentToClipboard()
|
||||
{
|
||||
QTextCursor cursor(this->textCursor());
|
||||
|
||||
QString textForClipboard;
|
||||
|
||||
QString selText = cursor.selectedText();
|
||||
if (!selText.isEmpty())
|
||||
{
|
||||
QTextDocument doc;
|
||||
doc.setPlainText(selText);
|
||||
|
||||
textForClipboard = doc.toPlainText();
|
||||
}
|
||||
|
||||
if (textForClipboard.isEmpty())
|
||||
{
|
||||
textForClipboard = this->toPlainText();
|
||||
}
|
||||
|
||||
if (!textForClipboard.isEmpty())
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
clipboard->setText(textForClipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotSelectAll()
|
||||
{
|
||||
this->selectAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
/// RiuTextDialog
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuTextDialog::RiuTextDialog(QWidget* parent)
|
||||
: QDialog(parent, RiuTools::defaultDialogFlags())
|
||||
{
|
||||
m_textEdit = new RiuQPlainTextEdit(this);
|
||||
m_textEdit->setReadOnly(true);
|
||||
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
|
||||
QFont font("Courier", 8);
|
||||
m_textEdit->setFont(font);
|
||||
|
||||
m_textEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(m_textEdit);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTextDialog::setText(const QString& text)
|
||||
{
|
||||
m_textEdit->setPlainText(text);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTextDialog::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
{
|
||||
QAction* actionToSetup = new QAction(this);
|
||||
|
||||
actionToSetup->setText("Copy");
|
||||
actionToSetup->setIcon(QIcon(":/Copy.png"));
|
||||
actionToSetup->setShortcuts(QKeySequence::Copy);
|
||||
|
||||
connect(actionToSetup, SIGNAL(triggered()), m_textEdit, SLOT(slotCopyContentToClipboard()));
|
||||
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
{
|
||||
QAction* actionToSetup = new QAction(this);
|
||||
|
||||
actionToSetup->setText("Select All");
|
||||
actionToSetup->setShortcuts(QKeySequence::SelectAll);
|
||||
|
||||
connect(actionToSetup, SIGNAL(triggered()), m_textEdit, SLOT(slotSelectAll()));
|
||||
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
60
ApplicationCode/UserInterface/RiuTextDialog.h
Normal file
60
ApplicationCode/UserInterface/RiuTextDialog.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
|
||||
class RiuQPlainTextEdit : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RiuQPlainTextEdit(QWidget *parent = 0) : QPlainTextEdit(parent) {}
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void slotCopyContentToClipboard();
|
||||
void slotSelectAll();
|
||||
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuTextDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RiuTextDialog(QWidget* parent = 0);
|
||||
|
||||
void setText(const QString& text);
|
||||
|
||||
private:
|
||||
RiuQPlainTextEdit* m_textEdit;
|
||||
protected:
|
||||
virtual void contextMenuEvent(QContextMenuEvent *) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user