mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2523 Mohr Circle: Improve circle appearence
This commit is contained in:
parent
28efe4661d
commit
bf1a621332
@ -482,6 +482,22 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors()
|
|||||||
return colorTable;
|
return colorTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const caf::ColorTable& RiaColorTables::mohrsCirclePaletteColors()
|
||||||
|
{
|
||||||
|
static std::vector<cvf::Color3ub> colors{
|
||||||
|
cvf::Color3ub::RED,
|
||||||
|
cvf::Color3ub::DARK_GREEN,
|
||||||
|
cvf::Color3ub::BLUE
|
||||||
|
};
|
||||||
|
|
||||||
|
static caf::ColorTable colorTable = caf::ColorTable(colors);
|
||||||
|
|
||||||
|
return colorTable;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
static const caf::ColorTable& wellLogPlotPaletteColors();
|
static const caf::ColorTable& wellLogPlotPaletteColors();
|
||||||
static const caf::ColorTable& selectionPaletteColors();
|
static const caf::ColorTable& selectionPaletteColors();
|
||||||
static const caf::ColorTable& timestepsPaletteColors();
|
static const caf::ColorTable& timestepsPaletteColors();
|
||||||
|
static const caf::ColorTable& mohrsCirclePaletteColors();
|
||||||
|
|
||||||
static cvf::Color3f undefinedCellColor();
|
static cvf::Color3f undefinedCellColor();
|
||||||
static cvf::Color3f perforationLengthColor();
|
static cvf::Color3f perforationLengthColor();
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
#include "RiuMohrsCirclePlot.h"
|
#include "RiuMohrsCirclePlot.h"
|
||||||
|
|
||||||
#include "qwt_round_scale_draw.h"
|
|
||||||
#include "qwt_symbol.h"
|
|
||||||
#include "RiuSelectionManager.h"
|
#include "RiuSelectionManager.h"
|
||||||
|
|
||||||
|
#include "RiaColorTables.h"
|
||||||
|
|
||||||
#include "RigFemPartCollection.h"
|
#include "RigFemPartCollection.h"
|
||||||
#include "RigFemPartResultsCollection.h"
|
#include "RigFemPartResultsCollection.h"
|
||||||
#include "RigGeoMechCaseData.h"
|
#include "RigGeoMechCaseData.h"
|
||||||
@ -33,6 +33,14 @@
|
|||||||
|
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "qwt_plot_layout.h"
|
||||||
|
#include "qwt_plot_marker.h"
|
||||||
|
#include "qwt_plot_rescaler.h"
|
||||||
|
#include "qwt_plot_shapeitem.h"
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
/// \class RiuMohrsCirclePlot
|
/// \class RiuMohrsCirclePlot
|
||||||
@ -47,8 +55,13 @@
|
|||||||
RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
|
RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
|
||||||
: QwtPlot(parent)
|
: QwtPlot(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
setDefaults();
|
setDefaults();
|
||||||
setPrincipalsAndRedrawCircles(320, 200, 150);
|
|
||||||
|
//setPrincipalsAndRedrawCircles(40, 30, 20);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -57,6 +70,7 @@ RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
|
|||||||
RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
|
RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
|
||||||
{
|
{
|
||||||
deleteCircles();
|
deleteCircles();
|
||||||
|
delete m_rescaler;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -141,21 +155,44 @@ void RiuMohrsCirclePlot::redrawCircles()
|
|||||||
deleteCircles();
|
deleteCircles();
|
||||||
createMohrCircles();
|
createMohrCircles();
|
||||||
|
|
||||||
for (MohrCircle circle : m_mohrCircles)
|
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++)
|
||||||
{
|
{
|
||||||
QwtSymbol* circleSymbol = new QwtSymbol(QwtSymbol::Ellipse);
|
MohrCircle* circle = &m_mohrCircles[i];
|
||||||
circleSymbol->setSize(2 * circle.radius, 2 * circle.radius);
|
QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle");
|
||||||
|
|
||||||
QwtPlotMarker* circlePlotItem = new QwtPlotMarker("Circle");
|
QPainterPath* circleDrawing = new QPainterPath();
|
||||||
circlePlotItem->setSymbol(circleSymbol);
|
QPointF center(circle->centerX, 0);
|
||||||
circlePlotItem->setXValue(circle.centerX);
|
circleDrawing->addEllipse(center, circle->radius, circle->radius);
|
||||||
circlePlotItem->setYValue(0);
|
plotItem->setPen(QPen(colors.cycledQColor(i)));
|
||||||
|
plotItem->setShape(*circleDrawing);
|
||||||
m_mohrCirclesMarkers.push_back(circlePlotItem);
|
plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true);
|
||||||
circlePlotItem->attach(this);
|
m_circlePlotItems.push_back(plotItem);
|
||||||
|
plotItem->attach(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
this->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
||||||
|
|
||||||
this->replot();
|
this->replot();
|
||||||
|
m_rescaler->rescale();
|
||||||
|
this->plotLayout()->setAlignCanvasToScales(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -163,13 +200,13 @@ void RiuMohrsCirclePlot::redrawCircles()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMohrsCirclePlot::deleteCircles()
|
void RiuMohrsCirclePlot::deleteCircles()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_mohrCirclesMarkers.size(); i++)
|
for (size_t i = 0; i < m_circlePlotItems.size(); i++)
|
||||||
{
|
{
|
||||||
m_mohrCirclesMarkers[i]->detach();
|
m_circlePlotItems[i]->detach();
|
||||||
delete m_mohrCirclesMarkers[i];
|
delete m_circlePlotItems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mohrCirclesMarkers.clear();
|
m_circlePlotItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -210,13 +247,16 @@ bool RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMohrsCirclePlot::setDefaults()
|
void RiuMohrsCirclePlot::setDefaults()
|
||||||
{
|
{
|
||||||
|
m_rescaler = new QwtPlotRescaler(this->canvas());
|
||||||
|
m_rescaler->setReferenceAxis(QwtPlot::yLeft);
|
||||||
|
m_rescaler->setAspectRatio(QwtPlot::xBottom, 1.0);
|
||||||
|
m_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed);
|
||||||
|
m_rescaler->setEnabled(true);
|
||||||
|
|
||||||
enableAxis(QwtPlot::xBottom, true);
|
enableAxis(QwtPlot::xBottom, true);
|
||||||
enableAxis(QwtPlot::yLeft, true);
|
enableAxis(QwtPlot::yLeft, true);
|
||||||
enableAxis(QwtPlot::xTop, false);
|
enableAxis(QwtPlot::xTop, false);
|
||||||
enableAxis(QwtPlot::yRight, false);
|
enableAxis(QwtPlot::yRight, false);
|
||||||
|
|
||||||
this->setAxisScale(QwtPlot::yLeft, -400, 400);
|
|
||||||
this->setAxisScale(QwtPlot::xBottom, 0, 400);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -19,14 +19,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qwt_plot.h"
|
#include "qwt_plot.h"
|
||||||
#include "qwt_plot_marker.h"
|
#include "qwt_plot_item.h"
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
class RiuSelectionItem;
|
class RiuSelectionItem;
|
||||||
class RimGeoMechView;
|
class RimGeoMechView;
|
||||||
|
class QwtRoundScaleDraw;
|
||||||
|
class QwtPlotRescaler;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -73,7 +75,10 @@ private:
|
|||||||
double m_principal1;
|
double m_principal1;
|
||||||
double m_principal2;
|
double m_principal2;
|
||||||
double m_principal3;
|
double m_principal3;
|
||||||
std::array<MohrCircle, 3> m_mohrCircles;
|
|
||||||
std::vector<QwtPlotMarker*> m_mohrCirclesMarkers;
|
|
||||||
|
|
||||||
|
std::array<MohrCircle, 3> m_mohrCircles;
|
||||||
|
|
||||||
|
std::vector<QwtPlotItem*> m_circlePlotItems;
|
||||||
|
|
||||||
|
QwtPlotRescaler* m_rescaler;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user