Merge branch 'dev' into cmake-improvements

This commit is contained in:
Magne Sjaastad
2018-02-28 08:33:39 +01:00
141 changed files with 1097 additions and 804 deletions

View File

@@ -65,6 +65,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h
${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuTools.h
${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.h
${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -130,6 +132,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.cpp
${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "Riu3DMainWindowTools.h"
#include "RiuMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* Riu3DMainWindowTools::mainWindowWidget()
{
return RiuMainWindow::instance();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow)
{
RiuMainWindow::instance()->setActiveViewer(subWindow);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
{
RiuMainWindow::instance()->setExpanded(uiItem, expanded);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
{
RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange);
}

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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
class QWidget;
namespace caf
{
class PdmUiItem;
class PdmObject;
}
class Riu3DMainWindowTools
{
public:
static QWidget* mainWindowWidget();
static void setActiveViewer(QWidget* subWindow) ;
static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
};

View File

@@ -576,14 +576,6 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer)
m_blockSlotSubWindowActivated = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmUiTreeView* RiuMainPlotWindow::projectTreeView()
{
return m_projectTreeView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -631,22 +623,22 @@ void RiuMainPlotWindow::selectedObjectsChanged()
{
firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>(uiItems[0]);
}
m_pdmUiPropertyView->showProperties(firstSelectedObject);
if (uiItems.size() == 1)
if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection)
{
// Find the reservoir view or the Plot that the selected item is within
if (!firstSelectedObject)
{
caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>(uiItems[0]);
if (selectedField)
firstSelectedObject = selectedField->ownerObject();
if (selectedField) firstSelectedObject = selectedField->ownerObject();
}
if (!firstSelectedObject)
return;
if (!firstSelectedObject) return;
RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>(firstSelectedObject);
if (!selectedWindow)
{
@@ -714,13 +706,6 @@ void RiuMainPlotWindow::restoreTreeViewState()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::selectAsCurrentItem(caf::PdmObject* object)
{
m_projectTreeView->selectAsCurrentItem(object);
}
//--------------------------------------------------------------------------------------------------
///
@@ -730,14 +715,6 @@ void RiuMainPlotWindow::setDefaultWindowSize()
resize(1000, 810);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainPlotWindow::setExpanded(const caf::PdmUiItem* uiItem, bool expanded)
{
m_projectTreeView->setExpanded(uiItem, expanded);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -55,7 +55,7 @@ class RiuMainPlotWindow : public RiuMainWindowBase
public:
RiuMainPlotWindow();
virtual QString mainWindowName();
QString mainWindowName() override;
void initializeGuiNewProjectLoaded();
void cleanupGuiBeforeProjectClose();
@@ -65,15 +65,10 @@ public:
void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override;
void setActiveViewer(QWidget* subWindow) override;
caf::PdmUiTreeView* projectTreeView();
void hideAllDockWindows();
void selectAsCurrentItem(caf::PdmObject* object);
void setDefaultWindowSize();
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override;
@@ -87,7 +82,7 @@ public:
void updateSummaryPlotToolBar();
protected:
virtual void closeEvent(QCloseEvent* event);
void closeEvent(QCloseEvent* event) override;
private:
void setPdmRoot(caf::PdmObject* pdmRoot);
@@ -121,7 +116,6 @@ private:
QMenu* m_windowMenu;
caf::PdmUiTreeView* m_projectTreeView;
caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;

View File

@@ -149,6 +149,14 @@ RiuMainWindow* RiuMainWindow::instance()
return sm_mainWindowInstance;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuMainWindow::mainWindowName()
{
return "RiuMainWindow";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1297,7 +1305,7 @@ void RiuMainWindow::selectedObjectsChanged()
m_pdmUiPropertyView->showProperties(firstSelectedObject);
if (uiItems.size() == 1)
if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection)
{
// Find the reservoir view or the Plot that the selected item is within
@@ -1619,14 +1627,6 @@ void RiuMainWindow::showProcessMonitorDockPanel()
showDockPanel(DOCK_PANEL_NAME_PROCESS_MONITOR);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::selectAsCurrentItem(const caf::PdmObject* object)
{
m_projectTreeView->selectAsCurrentItem(object);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -78,7 +78,7 @@ public:
static RiuMainWindow* instance();
virtual QString mainWindowName() { return "RiuMainWindow"; }
QString mainWindowName() override;
void initializeGuiNewProjectLoaded();
void cleanupGuiCaseClose();
@@ -93,12 +93,10 @@ public:
void refreshAnimationActions();
void updateScaleValue();
caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;}
RiuProcessMonitor* processMonitor();
void hideAllDockWindows();
void selectAsCurrentItem(const caf::PdmObject* object);
void selectedCases(std::vector<RimCase*>& cases);
@@ -108,7 +106,7 @@ public:
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer);
RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override;
void tileWindows();
bool isAnyMdiSubWindowVisible();
@@ -247,7 +245,6 @@ private slots:
public:
void setPdmRoot(caf::PdmObject* pdmRoot);
private:
caf::PdmUiTreeView* m_projectTreeView;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;

View File

@@ -21,11 +21,15 @@
#include "RiaVersionInfo.h"
#include <QSettings>
#include "cafPdmUiTreeView.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainWindowBase::RiuMainWindowBase()
: m_projectTreeView(nullptr)
, m_allowActiveViewChangeFromSelection(true)
{
setDockNestingEnabled(true);
}
@@ -96,3 +100,21 @@ QString RiuMainWindowBase::registryFolderName()
QString regFolder = QString("%1/%2").arg(versionName).arg(mainWindowName());
return regFolder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange)
{
m_allowActiveViewChangeFromSelection = allowActiveViewChange;
m_projectTreeView->selectAsCurrentItem(object);
m_allowActiveViewChangeFromSelection = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded)
{
m_projectTreeView->setExpanded(uiItem, expanded);
}

View File

@@ -22,6 +22,13 @@
struct RimMdiWindowGeometry;
namespace caf
{
class PdmObject;
class PdmUiTreeView;
class PdmUiItem;
}
//==================================================================================================
///
//==================================================================================================
@@ -44,6 +51,16 @@ public:
void saveWinGeoAndDockToolBarLayout();
void showWindow();
caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;}
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
protected:
caf::PdmUiTreeView* m_projectTreeView;
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
// whether to select the corresponding active view or not
private:
QString registryFolderName();
};

View File

@@ -19,11 +19,13 @@
#include "RiuMohrsCirclePlot.h"
#include "RiuSelectionManager.h"
#include "RiuSummaryQwtPlot.h"
#include "RiaColorTables.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultPosEnum.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechCase.h"
@@ -36,10 +38,14 @@
#include <QPainterPath>
#include <QWidget>
#include "qwt_plot_curve.h"
#include "qwt_plot_layout.h"
#include "qwt_plot_marker.h"
#include "qwt_plot_rescaler.h"
#include "qwt_plot_shapeitem.h"
#include "qwt_plot_textlabel.h"
#include <cmath>
//==================================================================================================
///
@@ -73,22 +79,30 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3)
{
CVF_ASSERT(p1 > p2);
CVF_ASSERT(p2 > p3);
m_principal1 = p1;
m_principal2 = p2;
m_principal3 = p3;
if (isValidPrincipals(p1, p2, p3))
{
m_principal1 = p1;
m_principal2 = p2;
m_principal3 = p3;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, double p3)
void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double p3)
{
if (!isValidPrincipals(p1, p2, p3))
{
clearPlot();
return;
}
setPrincipals(p1, p2, p3);
redrawEnvelope();
redrawCircles();
addInfoLabel();
}
//--------------------------------------------------------------------------------------------------
@@ -126,6 +140,10 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select
void RiuMohrsCirclePlot::clearPlot()
{
deleteCircles();
deleteEnvelope();
deleteInfoLabel();
this->replot();
}
//--------------------------------------------------------------------------------------------------
@@ -152,71 +170,22 @@ void RiuMohrsCirclePlot::redrawCircles()
deleteCircles();
createMohrCircles();
caf::ColorTable colors = RiaColorTables::mohrsCirclePaletteColors();
for (size_t i = 0; i < m_mohrCircles.size(); i++)
for (const MohrCircle& circle : m_mohrCircles)
{
MohrCircle* circle = &m_mohrCircles[i];
QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle");
QPainterPath* circleDrawing = new QPainterPath();
QPointF center(circle->centerX, 0);
circleDrawing->addEllipse(center, circle->radius, circle->radius);
QPointF center(circle.centerX, 0);
circleDrawing->addEllipse(center, circle.radius, circle.radius);
plotItem->setPen(QPen(colors.cycledQColor(i)));
plotItem->setShape(*circleDrawing);
plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true);
m_circlePlotItems.push_back(plotItem);
plotItem->attach(this);
m_circlePlotItems.push_back(plotItem);
}
double yHeight = 0.6 * (m_principal1 - m_principal3);
this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight);
// Scale the x-axis to show the y-axis if the largest circle's leftmost intersection of the
// x-axis (principal 3) is to the right of the y-axis
//The following examples shows the largest of the three Mohr circles
// Ex 1: xMin will be set to 1.1 * m_principal3 to be able to see the whole circle
// |y
// _|____
// / | \
// / | \
//--|---|-------|------- x
// \ | /
// \_|_____/
// |
// |
// Ex 2: xMin will be set to -1 to be able to see the y-axis
// |y
// | _______
// | / \
// | / \
// -|-------------|-----------|---------- x
// | \ /
// | \_______/
// |
// |
double xMin;
if (m_principal3 < 0)
{
xMin = 1.1 * m_principal3;
}
else
{
xMin = -1;
}
// When using the rescaler, xMax is ignored
double xMax = 0;
this->setAxisScale(QwtPlot::xBottom, xMin, xMax);
this->replot();
m_rescaler->rescale();
this->plotLayout()->setAlignCanvasToScales(true);
replotAndScaleAxis();
}
//--------------------------------------------------------------------------------------------------
@@ -231,6 +200,124 @@ void RiuMohrsCirclePlot::deleteCircles()
}
m_circlePlotItems.clear();
if (m_transparentCurve)
{
m_transparentCurve->detach();
delete m_transparentCurve;
m_transparentCurve = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::redrawEnvelope()
{
deleteEnvelope();
if (m_cohesion == HUGE_VAL || m_frictionAngle == HUGE_VAL)
{
this->replot();
return;
}
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
std::vector<double> xVals;
std::vector<double> yVals;
double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(m_frictionAngle)));
if (tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL)
{
this->replot();
delete qwtCurve;
return;
}
double x = m_cohesion/tanFrictionAngle;
if (m_principal1 < 0)
{
xVals.push_back(x);
xVals.push_back(m_principal3*1.1);
}
else
{
xVals.push_back(-x);
xVals.push_back(m_principal1*1.1);
}
yVals.push_back(0);
yVals.push_back((x + cvf::Math::abs(m_principal1) * 1.05) * tanFrictionAngle);
qwtCurve->setSamples(xVals.data(), yVals.data(), 2);
qwtCurve->setStyle(QwtPlotCurve::Lines);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
const QPen curvePen(QColor(236, 118, 0));
qwtCurve->setPen(curvePen);
qwtCurve->attach(this);
m_envolopePlotItem = qwtCurve;
replotAndScaleAxis();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::deleteEnvelope()
{
if (m_envolopePlotItem)
{
m_envolopePlotItem->detach();
delete m_envolopePlotItem;
m_envolopePlotItem = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::addInfoLabel()
{
deleteInfoLabel();
QString textBuilder;
textBuilder.append(QString("<b>Friction Angle</b>: %1<br>").arg(m_frictionAngle));
textBuilder.append(QString("<b>Cohesion</b>: %1<br><br>").arg(m_cohesion));
textBuilder.append(QString("<b>Factor of Safety</b>: %1<br>").arg(QString::number(m_factorOfSafety, 'f', 2)));
textBuilder.append(QString("<b>&sigma;<sub>1</sub></b>: %1<br>").arg(m_principal1));
textBuilder.append(QString("<b>&sigma;<sub>2</sub></b>: %1<br>").arg(m_principal2));
textBuilder.append(QString("<b>&sigma;<sub>3</sub></b>: %1<br>").arg(m_principal3));
QwtText text = textBuilder;
text.setRenderFlags(Qt::AlignLeft | Qt::AlignTop);
m_infoTextItem = new QwtPlotTextLabel();
m_infoTextItem->setText(text);
m_infoTextItem->attach(this);
this->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::deleteInfoLabel()
{
if (m_infoTextItem)
{
m_infoTextItem->detach();
delete m_infoTextItem;
m_infoTextItem = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
@@ -243,12 +330,25 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
int frameIdx = geoMechView->currentTimeStep();
RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "");
RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress();
// TODO: All tensors are calculated every time this function is called. FIX
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors(address, 0, frameIdx);
if (vertexTensors.empty())
{
clearPlot();
return;
}
// TODO: All tensors are calculated everytime this function is called. FIX
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors(currentAddress, 0, frameIdx);
RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);
setCohesion(geoMechView->geoMechCase()->cohesion());
setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg());
RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);
size_t i, j, k;
femPart->structGrid()->ijkFromCellIndex(cellIndex, &i, &j, &k);
QString title = QString("SE, Element Id[%1], ijk[%2,%3,%4]").arg(femPart->elmId(cellIndex)).arg(i).arg(j).arg(k);
this->setTitle(title);
caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)];
for (int i = 1; i < 8; i++)
@@ -261,7 +361,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
cvf::Vec3f principalDirs[3];
cvf::Vec3f elmPrincipals = elmTensor.calculatePrincipals(principalDirs);
setPrincipalsAndRedrawCircles(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]);
setFactorOfSafety(calculateFOS(elmTensor));
setPrincipalsAndRedrawPlot(elmPrincipals[0], elmPrincipals[1], elmPrincipals[2]);
}
//--------------------------------------------------------------------------------------------------
@@ -269,6 +371,8 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setDefaults()
{
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
m_rescaler = new QwtPlotRescaler(this->canvas());
m_rescaler->setReferenceAxis(QwtPlot::yLeft);
m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0);
@@ -280,15 +384,18 @@ void RiuMohrsCirclePlot::setDefaults()
enableAxis(QwtPlot::xTop, false);
enableAxis(QwtPlot::yRight, false);
QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX");
lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine);
lineXPlotMarker->setYValue(0);
lineXPlotMarker->attach(this);
setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress");
setAxisTitle(QwtPlot::yLeft, "Shear Stress");
QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY");
lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine);
lineYPlotMarker->setXValue(0);
lineYPlotMarker->attach(this);
m_envolopePlotItem = nullptr;
m_transparentCurve = nullptr;
m_infoTextItem = nullptr;
m_cohesion = HUGE_VAL;
m_frictionAngle = HUGE_VAL;
m_factorOfSafety = HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
@@ -296,15 +403,151 @@ void RiuMohrsCirclePlot::setDefaults()
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::createMohrCircles()
{
m_mohrCircles[0].component = 2;
m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2.0;
m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2.0;
m_mohrCircles[1].component = 1;
m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2.0;
m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2.0;
m_mohrCircles[2].component = 3;
m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2.0;
m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setFrictionAngle(double frictionAngle)
{
m_frictionAngle = frictionAngle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setCohesion(double cohesion)
{
m_cohesion = cohesion;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::setFactorOfSafety(double fos)
{
m_factorOfSafety = fos;
}
//--------------------------------------------------------------------------------------------------
/// Add a transparent curve to make tooltip available on principals crossing the x-axis
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::updateTransparentCurveOnPrincipals()
{
if (m_transparentCurve)
{
m_transparentCurve->detach();
delete m_transparentCurve;
}
m_transparentCurve = new QwtPlotCurve();
QVector<QPointF> qVectorPoints;
qVectorPoints.push_back(QPointF(m_principal1, 0));
qVectorPoints.push_back(QPointF(m_principal2, 0));
qVectorPoints.push_back(QPointF(m_principal3, 0));
m_transparentCurve->setSamples(qVectorPoints);
m_transparentCurve->setYAxis(QwtPlot::yLeft);
m_transparentCurve->setStyle(QwtPlotCurve::NoCurve);
m_transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
m_transparentCurve->attach(this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::replotAndScaleAxis()
{
double maxYEnvelope = -HUGE_VAL;
if (m_envolopePlotItem)
{
maxYEnvelope = m_envolopePlotItem->maxYValue();
}
double yHeight = std::max(maxYEnvelope, 0.6 * (m_principal1 - m_principal3));
this->setAxisScale(QwtPlot::yLeft, 0, yHeight);
double minXEvelope = 0;
if (m_envolopePlotItem)
{
minXEvelope = m_envolopePlotItem->minXValue();
}
double xMin;
if (minXEvelope < 0)
{
xMin = minXEvelope;
}
else
{
xMin = 1.1 * m_principal3;
}
// When using the rescaler, xMax is ignored
this->setAxisScale(QwtPlot::xBottom, xMin, 0);
updateTransparentCurveOnPrincipals();
this->replot();
m_rescaler->rescale();
this->plotLayout()->setAlignCanvasToScales(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMohrsCirclePlot::isValidPrincipals(double p1, double p2, double p3)
{
//Inf
if (p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL)
{
return false;
}
//Nan
if ((p1 != p1) || (p2 != p2) || p3 != p3)
{
return false;
}
//Principal rules:
if ((p1 < p2) || (p2 < p3))
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RiuMohrsCirclePlot::calculateFOS(const caf::Ten3f& tensor)
{
cvf::Vec3f dirs[3];
cvf::Vec3f principals = tensor.calculatePrincipals(dirs);
float se1 = principals[0];
float se3 = principals[2];
float tanFricAng = tan(cvf::Math::toRadians(m_frictionAngle));
float cohPrTanFricAngle = (float)(m_cohesion / tanFricAng);
float pi_4 = 0.785398163397448309616f;
float rho = 2.0f * (atan(sqrt((se1 + cohPrTanFricAngle) / (se3 + cohPrTanFricAngle))) - pi_4);
return tanFricAng / tan(rho);
}

View File

@@ -21,13 +21,17 @@
#include "qwt_plot.h"
#include "qwt_plot_item.h"
#include "cafTensor3.h"
#include <array>
class RiuSelectionItem;
class RimGeoMechView;
class QwtRoundScaleDraw;
class QwtPlotRescaler;
class QWidget;
class QwtPlotCurve;
class QwtPlotRescaler;
class QwtPlotTextLabel;
class QwtRoundScaleDraw;
class RimGeoMechView;
class RiuSelectionItem;
//==================================================================================================
//
@@ -43,34 +47,51 @@ public:
~RiuMohrsCirclePlot();
void setPrincipals(double p1, double p2, double p3);
void setPrincipalsAndRedrawCircles(double p1, double p2, double p3);
void setPrincipalsAndRedrawPlot(double p1, double p2, double p3);
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void clearPlot();
protected:
private:
struct MohrCircle
{
MohrCircle(double radius, double centerX)
: radius(radius), centerX(centerX) {}
MohrCircle() {};
double radius;
double centerX;
};
private:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
void redrawCircles();
void deleteCircles();
void redrawEnvelope();
void deleteEnvelope();
void addInfoLabel();
void deleteInfoLabel();
void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex);
private:
struct MohrCircle
{
MohrCircle(size_t component, double radius, double centerX)
: component(component), radius(radius), centerX(centerX) {}
MohrCircle() {};
size_t component; //1, 2 or 3
double radius;
double centerX;
};
private:
void setDefaults();
void createMohrCircles();
void setFrictionAngle(double frictionAngle);
void setCohesion(double cohesion);
void setFactorOfSafety(double fos);
void updateTransparentCurveOnPrincipals();
void replotAndScaleAxis();
static bool isValidPrincipals(double p1, double p2, double p3);
float calculateFOS(const caf::Ten3f& tensor);
private:
double m_principal1;
double m_principal2;
@@ -79,6 +100,15 @@ private:
std::array<MohrCircle, 3> m_mohrCircles;
std::vector<QwtPlotItem*> m_circlePlotItems;
QwtPlotCurve* m_envolopePlotItem;
QwtPlotCurve* m_transparentCurve;
double m_frictionAngle;
double m_cohesion;
double m_factorOfSafety;
QwtPlotTextLabel* m_infoTextItem;
QwtPlotRescaler* m_rescaler;
};

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RiuPlotMainWindowTools.h"
#include "RiaApplication.h"
#include "RiuMainPlotWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::showPlotMainWindow()
{
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow)
{
RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow();
if (mpw) mpw->setActiveViewer(subWindow);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
{
RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow();
if (mpw) mpw->setExpanded(uiItem, expanded);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
{
RiuMainPlotWindow* mpw = RiaApplication::instance()->mainPlotWindow();
if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange);
}

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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
class QWidget;
namespace caf
{
class PdmUiItem;
class PdmObject;
}
class RiuPlotMainWindowTools
{
public:
static void showPlotMainWindow();
static void setActiveViewer(QWidget* subWindow) ;
static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
};

View File

@@ -26,7 +26,7 @@
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuMainPlotWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
@@ -368,7 +368,8 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
if(proj && selectedCurve)
{
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve);
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve);
}
}
}

View File

@@ -357,9 +357,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png"));
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
menuBuilder << "RicNewWellPathFractureAtPosFeature";
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature";
menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature";
@@ -402,9 +400,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder.addSeparator();
menuBuilder << "RicShowContributingWellsFeature";
menuBuilder.addSeparator();
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
menuBuilder << "RicNewSimWellFractureAtPosFeature";
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
menuBuilder.addSeparator();
menuBuilder << "RicNewSimWellIntersectionFeature";
}
@@ -500,7 +496,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
if (rivObjectSourceInfo)
{
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
RimFracture* fracture = dynamic_cast<RimFracture*>(rivObjectSourceInfo->object());
{
bool blockSelectionOfFracture = false;
@@ -550,7 +545,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
// Display result info text
RiuMainWindow::instance()->setResultInfo(resultInfoText);
}
#endif //USE_PROTOTYPE_FEATURE_FRACTURES
}
if (rivSourceInfo)
@@ -577,11 +571,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
intersectionHit = true;
intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex);
if (!dynamic_cast<Rim2dIntersectionView*>(m_viewer->ownerViewWindow()))
{
RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection());
}
bool allowActiveViewChange = dynamic_cast<Rim2dIntersectionView*>(m_viewer->ownerViewWindow()) == nullptr;
RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection(), allowActiveViewChange);
}
else if (intersectionBoxSourceInfo)
{

View File

@@ -25,7 +25,7 @@
#include "RimWellLogTrack.h"
#include "RimWellLogCurve.h"
#include "RiuMainPlotWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtCurvePointTracker.h"
#include "qwt_legend.h"
@@ -220,13 +220,15 @@ void RiuWellLogTrack::selectClosestCurve(const QPoint& pos)
RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve(closestCurve);
if (selectedCurve)
{
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve);
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve);
return;
}
}
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(m_plotTrackDefinition);
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(m_plotTrackDefinition);
}
//--------------------------------------------------------------------------------------------------