mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Code cleanup
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -45,36 +45,31 @@
|
||||
///
|
||||
/// \class RiuMohrsCirclePlot
|
||||
///
|
||||
///
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
|
||||
: QwtPlot(parent)
|
||||
: QwtPlot(parent)
|
||||
{
|
||||
|
||||
|
||||
setDefaults();
|
||||
|
||||
//setPrincipalsAndRedrawCircles(40, 30, 20);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
|
||||
{
|
||||
deleteCircles();
|
||||
|
||||
delete m_rescaler;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3)
|
||||
{
|
||||
@@ -87,7 +82,7 @@ void RiuMohrsCirclePlot::setPrincipals(double p1, double p2, double p3)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, double p3)
|
||||
{
|
||||
@@ -97,12 +92,12 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawCircles(double p1, double p2, dou
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* selectionItem)
|
||||
{
|
||||
const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast<const RiuGeoMechSelectionItem*>(selectionItem);
|
||||
|
||||
|
||||
RimGeoMechView* geoMechView = geoMechSelectionItem ? geoMechSelectionItem->m_view : nullptr;
|
||||
|
||||
bool mustClearPlot = true;
|
||||
@@ -124,7 +119,7 @@ void RiuMohrsCirclePlot::updateOnSelectionChanged(const RiuSelectionItem* select
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::clearPlot()
|
||||
{
|
||||
@@ -132,7 +127,7 @@ void RiuMohrsCirclePlot::clearPlot()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuMohrsCirclePlot::sizeHint() const
|
||||
{
|
||||
@@ -140,7 +135,7 @@ QSize RiuMohrsCirclePlot::sizeHint() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuMohrsCirclePlot::minimumSizeHint() const
|
||||
{
|
||||
@@ -148,32 +143,22 @@ QSize RiuMohrsCirclePlot::minimumSizeHint() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::redrawCircles()
|
||||
{
|
||||
deleteCircles();
|
||||
createMohrCircles();
|
||||
|
||||
QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX");
|
||||
lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine);
|
||||
lineXPlotMarker->setYValue(0);
|
||||
lineXPlotMarker->attach(this);
|
||||
|
||||
QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY");
|
||||
lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
lineYPlotMarker->setXValue(0);
|
||||
lineYPlotMarker->attach(this);
|
||||
|
||||
caf::ColorTable colors = RiaColorTables::mohrsCirclePaletteColors();
|
||||
|
||||
for (size_t i = 0; i < m_mohrCircles.size(); i++)
|
||||
{
|
||||
MohrCircle* circle = &m_mohrCircles[i];
|
||||
MohrCircle* circle = &m_mohrCircles[i];
|
||||
QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle");
|
||||
|
||||
QPainterPath* circleDrawing = new QPainterPath();
|
||||
QPointF center(circle->centerX, 0);
|
||||
QPointF center(circle->centerX, 0);
|
||||
circleDrawing->addEllipse(center, circle->radius, circle->radius);
|
||||
plotItem->setPen(QPen(colors.cycledQColor(i)));
|
||||
plotItem->setShape(*circleDrawing);
|
||||
@@ -182,21 +167,20 @@ void RiuMohrsCirclePlot::redrawCircles()
|
||||
plotItem->attach(this);
|
||||
}
|
||||
|
||||
double yHeight = 0.6*(m_principal1 - m_principal3);
|
||||
double yHeight = 0.6 * (m_principal1 - m_principal3);
|
||||
this->setAxisScale(QwtPlot::yLeft, -yHeight, yHeight);
|
||||
|
||||
double xMin = m_principal3 < 0 ? 1.1*m_principal3 : -1;
|
||||
double xMax = m_principal1 < 0 ? 1 : 1.1*m_principal1;
|
||||
double xMin = m_principal3 < 0 ? 1.1 * m_principal3 : -1;
|
||||
double xMax = m_principal1 < 0 ? 1 : 1.1 * m_principal1;
|
||||
this->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
||||
|
||||
this->replot();
|
||||
m_rescaler->rescale();
|
||||
this->plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::deleteCircles()
|
||||
{
|
||||
@@ -210,22 +194,22 @@ void RiuMohrsCirclePlot::deleteCircles()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex)
|
||||
{
|
||||
if (!geoMechView) return false;
|
||||
|
||||
|
||||
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
|
||||
if (!resultCollection) return false;
|
||||
|
||||
int frameIdx = geoMechView->currentTimeStep();
|
||||
|
||||
|
||||
RigFemResultAddress currentAddress = geoMechView->cellResult->resultAddress();
|
||||
|
||||
//TODO: All tensors are calculated everytime this function is called. FIX
|
||||
// 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);
|
||||
RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);
|
||||
|
||||
caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)cellIndex, 0)];
|
||||
for (int i = 1; i < 8; i++)
|
||||
@@ -243,7 +227,7 @@ bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::setDefaults()
|
||||
{
|
||||
@@ -257,22 +241,32 @@ void RiuMohrsCirclePlot::setDefaults()
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
enableAxis(QwtPlot::xTop, false);
|
||||
enableAxis(QwtPlot::yRight, false);
|
||||
|
||||
QwtPlotMarker* lineXPlotMarker = new QwtPlotMarker("LineX");
|
||||
lineXPlotMarker->setLineStyle(QwtPlotMarker::HLine);
|
||||
lineXPlotMarker->setYValue(0);
|
||||
lineXPlotMarker->attach(this);
|
||||
|
||||
QwtPlotMarker* lineYPlotMarker = new QwtPlotMarker("LineY");
|
||||
lineYPlotMarker->setLineStyle(QwtPlotMarker::VLine);
|
||||
lineYPlotMarker->setXValue(0);
|
||||
lineYPlotMarker->attach(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMohrsCirclePlot::createMohrCircles()
|
||||
{
|
||||
m_mohrCircles[0].component = 2;
|
||||
m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2;
|
||||
m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2;
|
||||
m_mohrCircles[0].radius = (m_principal1 - m_principal3) / 2;
|
||||
m_mohrCircles[0].centerX = (m_principal1 + m_principal3) / 2;
|
||||
|
||||
m_mohrCircles[1].component = 1;
|
||||
m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2;
|
||||
m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2;
|
||||
m_mohrCircles[1].radius = (m_principal2 - m_principal3) / 2;
|
||||
m_mohrCircles[1].centerX = (m_principal2 + m_principal3) / 2;
|
||||
|
||||
m_mohrCircles[2].component = 3;
|
||||
m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2;
|
||||
m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2;
|
||||
m_mohrCircles[2].radius = (m_principal1 - m_principal2) / 2;
|
||||
m_mohrCircles[2].centerX = (m_principal1 + m_principal2) / 2;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include "qwt_date_scale_draw.h"
|
||||
|
||||
@@ -61,8 +61,8 @@ public:
|
||||
void deleteAllCurves();
|
||||
|
||||
protected:
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize minimumSizeHint() const;
|
||||
virtual QSize sizeHint() const override;
|
||||
virtual QSize minimumSizeHint() const override;
|
||||
virtual void contextMenuEvent(QContextMenuEvent *) override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user