#2344 Tensor Vectors: Vector visualization code

This commit is contained in:
Rebecca Cox
2018-02-08 16:43:18 +01:00
parent 778119bf62
commit bd0d23520b
15 changed files with 774 additions and 32 deletions
@@ -48,6 +48,7 @@
#include "RivGeoMechPartMgrCache.h"
#include "RivGeoMechVizLogic.h"
#include "RivSingleCellPartGenerator.h"
#include "RivTensorResultPartMgr.h"
#include "cafCadNavigation.h"
#include "cafCeetronPlusNavigation.h"
@@ -93,6 +94,7 @@ RimGeoMechView::RimGeoMechView(void)
m_scaleTransform = new cvf::Transform();
m_vizLogic = new RivGeoMechVizLogic(this);
m_tensorPartMgr = new RivTensorResultPartMgr(this);
}
//--------------------------------------------------------------------------------------------------
@@ -212,6 +214,7 @@ void RimGeoMechView::createDisplayModel()
cvf::ref<cvf::ModelBasicList> mainSceneGridVizModel = new cvf::ModelBasicList;
mainSceneGridVizModel->setName("GridModel");
m_vizLogic->appendNoAnimPartsToModel(mainSceneGridVizModel.p());
mainSceneGridVizModel->updateBoundingBoxesRecursive();
mainScene->addModel(mainSceneGridVizModel.p());
@@ -287,6 +290,19 @@ void RimGeoMechView::updateCurrentTimeStep()
frameScene->addModel(wellPathModelBasicList.p());
}
{
// Tensors
cvf::String name = "Tensor";
this->removeModelByName(frameScene, name);
cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
frameParts->setName(name);
m_tensorPartMgr->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep);
frameParts->updateBoundingBoxesRecursive();
frameScene->addModel(frameParts.p());
}
}
}
@@ -428,6 +444,22 @@ void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, in
legendConfig->setTitle(legendTitle);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::ref<RivGeoMechVizLogic> RimGeoMechView::vizLogic() const
{
return m_vizLogic;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimTensorResults* RimGeoMechView::tensorResults() const
{
return m_tensorResults;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -43,6 +43,7 @@ class RiuViewer;
class RivGeoMechPartMgr;
class RivGeoMechVizLogic;
class RimLegendConfig;
class RivTensorResultPartMgr;
namespace cvf {
class CellRangeFilter;
@@ -88,6 +89,9 @@ public:
void updateLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex);
const cvf::ref<RivGeoMechVizLogic> vizLogic() const;
const RimTensorResults* tensorResults() const;
protected:
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual void onLoadDataAndUpdate() override;
@@ -119,5 +123,6 @@ private:
cvf::ref<RivGeoMechVizLogic> m_vizLogic;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::ref<RivTensorResultPartMgr> m_tensorPartMgr;
};
@@ -18,13 +18,40 @@
#include "RimTensorResults.h"
#include "RigFemResultAddress.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "cafAppEnum.h"
#include "cafPdmUiListEditor.h"
CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults");
namespace caf
{
template<>
void AppEnum< RimTensorResults::TensorColors >::setUp()
{
addItem(RimTensorResults::WHITE_GRAY_BLACK , "WHITE_GRAY_BLACK", "White, Gray, Black");
addItem(RimTensorResults::MAGENTA_BROWN_BLACK, "MAGENTA_BROWN_BLACK", "Magenta, Brown, Black");
addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors");
setDefault(RimTensorResults::WHITE_GRAY_BLACK);
}
template<>
void AppEnum< RimTensorResults::ScaleMethod >::setUp()
{
addItem(RimTensorResults::RESULT, "RESULT", "Result");
addItem(RimTensorResults::CONSTANT, "CONSTANT", "Constant");
setDefault(RimTensorResults::RESULT);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -52,16 +79,17 @@ RimTensorResults::RimTensorResults()
CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", "");
CAF_PDM_InitField(&m_principal3, "Principal3", true, "Principal 3", "", "", "");
CAF_PDM_InitField(&m_threshold, "Threshold", 0.0, "Threshold", "", "", "");
CAF_PDM_InitField(&m_threshold, "Threshold", 0.0f, "Threshold", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", "");
CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0, "Size Scale", "", "", "");
CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", "");
m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_resultPositionTypeUiField = RIG_ELEMENT_NODAL;
m_resultPositionType = RIG_ELEMENT_NODAL;
m_resultPositionTypeUiField = m_resultPositionType;
}
//--------------------------------------------------------------------------------------------------
@@ -72,6 +100,78 @@ RimTensorResults::~RimTensorResults()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultAddress RimTensorResults::selectedTensorResult() const
{
return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimTensorResults::showTensors() const
{
return m_showTensors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimTensorResults::showPrincipal1() const
{
return m_principal1();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimTensorResults::showPrincipal2() const
{
return m_principal2();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimTensorResults::showPrincipal3() const
{
return m_principal3();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RimTensorResults::threshold() const
{
return m_threshold();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RimTensorResults::sizeScale() const
{
return m_sizeScale();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTensorResults::TensorColors RimTensorResults::vectorColors() const
{
return m_vectorColor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const
{
return m_scaleMethod();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -106,7 +206,12 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
if (changedField == &m_resultFieldNameUiField)
{
m_resultPositionType = m_resultPositionTypeUiField;
m_resultFieldName = m_resultFieldNameUiField;
}
RimGeoMechView* view;
firstAncestorOrThisOfType(view);
view->loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
@@ -145,17 +250,6 @@ QList<caf::PdmOptionItemInfo> RimTensorResults::calculateValueOptions(const caf:
}
}
else if (fieldNeedingOptions == &m_vectorColor)
{
options.push_back(caf::PdmOptionItemInfo("White, Gray, Black", nullptr));
options.push_back(caf::PdmOptionItemInfo("Magenta, Brown, Black", nullptr));
options.push_back(caf::PdmOptionItemInfo("Result Colors", nullptr));
}
else if (fieldNeedingOptions == &m_scaleMethod)
{
options.push_back(caf::PdmOptionItemInfo("Result", nullptr));
options.push_back(caf::PdmOptionItemInfo("Constant", nullptr));
}
return options;
}
@@ -191,4 +285,19 @@ void RimTensorResults::initAfterRead()
{
m_resultPositionTypeUiField = m_resultPositionType;
m_resultFieldNameUiField = m_resultFieldName();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_resultFieldNameUiField)
{
caf::PdmUiListEditorAttribute* listEditAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>(attribute);
if (listEditAttr)
{
listEditAttr->m_heightHint = 50;
}
}
}
@@ -27,6 +27,7 @@
#include <vector>
class RigFemResultAddress;
//==================================================================================================
///
@@ -36,10 +37,34 @@ class RimTensorResults : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum TensorColors
{
WHITE_GRAY_BLACK,
MAGENTA_BROWN_BLACK,
RESULT_COLORS
};
enum ScaleMethod
{
RESULT,
CONSTANT
};
public:
RimTensorResults();
virtual ~RimTensorResults();
RigFemResultAddress selectedTensorResult() const;
bool showTensors() const;
bool showPrincipal1() const;
bool showPrincipal2() const;
bool showPrincipal3() const;
float threshold() const;
float sizeScale() const;
TensorColors vectorColors() const;
ScaleMethod scaleMethod() const;
private:
std::vector<std::string> getResultMetaDataForUIFieldSetting();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
@@ -47,9 +72,9 @@ private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void initAfterRead() override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<bool> m_showTensors;
caf::PdmField<caf::AppEnum<RigFemResultPosEnum>> m_resultPositionType;
@@ -62,11 +87,10 @@ private:
caf::PdmField<bool> m_principal2;
caf::PdmField<bool> m_principal3;
caf::PdmField<double> m_threshold;
caf::PdmField<float> m_threshold;
caf::PdmField<QString> m_vectorColor;
caf::PdmField<QString> m_scaleMethod;
caf::PdmField<double> m_sizeScale;
caf::PdmField<caf::AppEnum<TensorColors>> m_vectorColor;
caf::PdmField<caf::AppEnum<ScaleMethod>> m_scaleMethod;
caf::PdmField<float> m_sizeScale;
};