#3876 Implement rotated labels on contour maps

This commit is contained in:
Gaute Lindkvist
2019-01-03 17:07:55 +01:00
parent 71cacc550f
commit 7a275be335
14 changed files with 593 additions and 208 deletions

View File

@@ -49,6 +49,7 @@ const cvf::Mat4d defaultViewMatrix(1, 0, 0, 0,
0, 0, 0, 1);
RimContourMapView::RimContourMapView()
: m_cameraPositionLastUpdate(cvf::Vec3d::UNDEFINED)
{
CAF_PDM_InitObject("Contour Map View", ":/2DMap16x16.png", "", "");
@@ -224,7 +225,9 @@ void RimContourMapView::updateGeometry()
appendWellsAndFracturesToModel();
createContourMapGeometry();
appendContourMapProjectionToModel();
appendContourLinesToModel();
appendPickPointVisToModel();
@@ -243,6 +246,17 @@ void RimContourMapView::setFaultVisParameters()
faultResultSettings()->customFaultResult()->setResultVariable("None");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContourMapView::createContourMapGeometry()
{
if (m_viewer && m_contourMapProjection->isChecked())
{
m_contourMapProjectionPartMgr->createProjectionGeometry();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -268,6 +282,31 @@ void RimContourMapView::appendContourMapProjectionToModel()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContourMapView::appendContourLinesToModel()
{
if (m_viewer && m_contourMapProjection->isChecked())
{
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (frameScene)
{
cvf::String name = "ContourMapLines";
this->removeModelByName(frameScene, name);
cvf::ref<cvf::ModelBasicList> contourMapLabelModelBasicList = new cvf::ModelBasicList;
contourMapLabelModelBasicList->setName(name);
cvf::ref<caf::DisplayCoordTransform> transForm = this->displayCoordTransform();
m_contourMapProjectionPartMgr->appendContourLinesToModel(viewer()->mainCamera(), contourMapLabelModelBasicList.p(), transForm.p());
contourMapLabelModelBasicList->updateBoundingBoxesRecursive();
frameScene->addModel(contourMapLabelModelBasicList.p());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -414,3 +453,26 @@ QWidget* RimContourMapView::createViewWidget(QWidget* mainWindowParent)
}
return widget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContourMapView::onViewNavigationChanged()
{
cvf::Vec3d currentCameraPosition = viewer()->mainCamera()->position();
if (m_cameraPositionLastUpdate.isUndefined() || zoomChangeAboveTreshold(currentCameraPosition))
{
appendContourLinesToModel();
m_cameraPositionLastUpdate = currentCameraPosition;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapView::zoomChangeAboveTreshold(const cvf::Vec3d& currentCameraPosition) const
{
double distance = std::max(std::fabs(m_cameraPositionLastUpdate.z()), std::fabs(currentCameraPosition.z()));
const double threshold = 0.01 * distance;
return (m_cameraPositionLastUpdate - currentCameraPosition).length() > threshold;
}