#2531 Mohr Circle: Add Info text

This commit is contained in:
Rebecca Cox committed 2018-02-27 12:40:36 +01:00
1 parent 10bc5c92ab
commit f4d4a8aa46
2 files changed
+80 -33

No files matched your search

@@ -44,6 +44,7 @@
#include "qwt_plot_marker.h" #include "qwt_plot_marker.h"
#include "qwt_plot_rescaler.h" #include "qwt_plot_rescaler.h"
#include "qwt_plot_shapeitem.h" #include "qwt_plot_shapeitem.h"
#include "qwt_plot_textlabel.h"
#include <cmath> #include <cmath>
@@ -102,6 +103,7 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double
redrawEnvelope(); redrawEnvelope();
redrawCircles(); redrawCircles();
addInfoLabel();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -140,6 +142,7 @@ void RiuMohrsCirclePlot::clearPlot()
{ {
deleteCircles(); deleteCircles();
deleteEnvelope(); deleteEnvelope();
deleteInfoLabel();
this->replot(); this->replot();
} }
@@ -281,6 +284,46 @@ void RiuMohrsCirclePlot::deleteEnvelope()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::addInfoLabel()
{
deleteInfoLabel();
QString textBuilder;
textBuilder.append(QString("<b>Factor of Safety</b>: %1<br>").arg("Coming soon"));
textBuilder.append(QString("<b>Friction Angle</b>: %1<br>").arg(m_frictionAngle));
textBuilder.append(QString("<b>Cohesion</b>: %1<br>").arg(m_cohesion));
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;
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -305,10 +348,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
clearPlot(); clearPlot();
return; return;
} }
setCohesion(geoMechView->geoMechCase()->cohesion()); setCohesion(geoMechView->geoMechCase()->cohesion());
setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg()); setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg());
RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex); RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);
size_t i, j, k; size_t i, j, k;
@@ -317,23 +359,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
int elmId = femPart->elmId(cellIndex); int elmId = femPart->elmId(cellIndex);
QString title; QString title;
QString resultPos;
QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName();
switch (geoMechView->cellResultResultDefinition()->resultPositionType())
{
case RIG_ELEMENT_NODAL:
resultPos = "Element Nodal";
break;
case RIG_INTEGRATION_POINT:
resultPos = "Integration Point";
break;
default:
break;
}
title += QString("%1, %2").arg(resultPos).arg(fieldName); title += QString("%1").arg(fieldName);
title += QString(", Element Id[%1], ijk[%2,%3,%4]").arg(elmId).arg(i).arg(j).arg(k); title += QString(", Element Id[%1], ijk[%2,%3,%4]").arg(elmId).arg(i).arg(j).arg(k);
this->setTitle(title); this->setTitle(title);
@@ -375,8 +403,13 @@ void RiuMohrsCirclePlot::setDefaults()
m_envolopePlotItem = nullptr; m_envolopePlotItem = nullptr;
m_transparentCurve = nullptr; m_transparentCurve = nullptr;
m_infoTextItem = nullptr;
m_cohesion = HUGE_VAL; m_cohesion = HUGE_VAL;
m_frictionAngle = HUGE_VAL; m_frictionAngle = HUGE_VAL;
m_factorOfSafety = 0;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -413,6 +446,14 @@ void RiuMohrsCirclePlot::setCohesion(double cohesion)
m_cohesion = 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 /// Add a transparent curve to make tooltip available on principals crossing the x-axis
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -23,12 +23,13 @@
#include <array> #include <array>
class RiuSelectionItem;
class RimGeoMechView;
class QwtRoundScaleDraw;
class QwtPlotRescaler;
class QWidget; class QWidget;
class QwtPlotCurve; class QwtPlotCurve;
class QwtPlotRescaler;
class QwtPlotTextLabel;
class QwtRoundScaleDraw;
class RimGeoMechView;
class RiuSelectionItem;
//================================================================================================== //==================================================================================================
// //
@@ -49,18 +50,6 @@ public:
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void clearPlot(); void clearPlot();
protected:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
void redrawCircles();
void deleteCircles();
void redrawEnvelope();
void deleteEnvelope();
void queryDataAndUpdatePlot(RimGeoMechView* geoMechView, size_t gridIndex, size_t cellIndex);
private: private:
struct MohrCircle struct MohrCircle
{ {
@@ -73,11 +62,26 @@ private:
}; };
private: 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);
void setDefaults(); void setDefaults();
void createMohrCircles(); void createMohrCircles();
void setFrictionAngle(double frictionAngle); void setFrictionAngle(double frictionAngle);
void setCohesion(double cohesion); void setCohesion(double cohesion);
void setFactorOfSafety(double fos);
void updateTransparentCurveOnPrincipals(); void updateTransparentCurveOnPrincipals();
@@ -101,5 +105,7 @@ private:
double m_cohesion; double m_cohesion;
double m_factorOfSafety; double m_factorOfSafety;
QwtPlotTextLabel* m_infoTextItem;
QwtPlotRescaler* m_rescaler; QwtPlotRescaler* m_rescaler;
}; };