Skip to content

Commit

Permalink
#2531 Mohr Circle: Add Info text
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Cox committed Feb 27, 2018
1 parent 10bc5c9 commit f4d4a8a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 33 deletions.
75 changes: 58 additions & 17 deletions ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "qwt_plot_marker.h"
#include "qwt_plot_rescaler.h"
#include "qwt_plot_shapeitem.h"
#include "qwt_plot_textlabel.h"

#include <cmath>

Expand Down Expand Up @@ -102,6 +103,7 @@ void RiuMohrsCirclePlot::setPrincipalsAndRedrawPlot(double p1, double p2, double

redrawEnvelope();
redrawCircles();
addInfoLabel();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -140,6 +142,7 @@ void RiuMohrsCirclePlot::clearPlot()
{
deleteCircles();
deleteEnvelope();
deleteInfoLabel();

this->replot();
}
Expand Down Expand Up @@ -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;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -305,10 +348,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
clearPlot();
return;
}

setCohesion(geoMechView->geoMechCase()->cohesion());
setFrictionAngle(geoMechView->geoMechCase()->frictionAngleDeg());

RigFemPart* femPart = geoMechView->geoMechCase()->geoMechData()->femParts()->part(gridIndex);

size_t i, j, k;
Expand All @@ -317,23 +359,9 @@ void RiuMohrsCirclePlot::queryDataAndUpdatePlot(RimGeoMechView* geoMechView, siz
int elmId = femPart->elmId(cellIndex);

QString title;
QString resultPos;
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);
this->setTitle(title);
Expand Down Expand Up @@ -375,8 +403,13 @@ void RiuMohrsCirclePlot::setDefaults()

m_envolopePlotItem = nullptr;
m_transparentCurve = nullptr;

m_infoTextItem = nullptr;

m_cohesion = HUGE_VAL;
m_frictionAngle = HUGE_VAL;

m_factorOfSafety = 0;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -413,6 +446,14 @@ 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
//--------------------------------------------------------------------------------------------------
Expand Down
38 changes: 22 additions & 16 deletions ApplicationCode/UserInterface/RiuMohrsCirclePlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@

#include <array>

class RiuSelectionItem;
class RimGeoMechView;
class QwtRoundScaleDraw;
class QwtPlotRescaler;
class QWidget;
class QwtPlotCurve;
class QwtPlotRescaler;
class QwtPlotTextLabel;
class QwtRoundScaleDraw;
class RimGeoMechView;
class RiuSelectionItem;

//==================================================================================================
//
Expand All @@ -49,18 +50,6 @@ class RiuMohrsCirclePlot : public QwtPlot
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
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:
struct MohrCircle
{
Expand All @@ -73,11 +62,26 @@ class RiuMohrsCirclePlot : public QwtPlot
};

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 createMohrCircles();

void setFrictionAngle(double frictionAngle);
void setCohesion(double cohesion);
void setFactorOfSafety(double fos);

void updateTransparentCurveOnPrincipals();

Expand All @@ -101,5 +105,7 @@ class RiuMohrsCirclePlot : public QwtPlot
double m_cohesion;
double m_factorOfSafety;

QwtPlotTextLabel* m_infoTextItem;

QwtPlotRescaler* m_rescaler;
};

0 comments on commit f4d4a8a

Please sign in to comment.