mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3876 Implement rotated labels on contour maps
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ protected:
|
||||
void updateCurrentTimeStep() override;
|
||||
void updateGeometry();
|
||||
void setFaultVisParameters();
|
||||
void createContourMapGeometry();
|
||||
void appendContourMapProjectionToModel();
|
||||
void appendContourLinesToModel();
|
||||
void appendPickPointVisToModel();
|
||||
void updateLegends() override;
|
||||
void updateViewWidgetAfterCreation() override;
|
||||
@@ -57,10 +59,14 @@ protected:
|
||||
|
||||
QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
|
||||
void onViewNavigationChanged() override;
|
||||
|
||||
bool zoomChangeAboveTreshold(const cvf::Vec3d& currentCameraPosition) const;
|
||||
private:
|
||||
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
|
||||
caf::PdmChildField<RimContourMapProjection*> m_contourMapProjection;
|
||||
caf::PdmField<bool> m_showAxisLines;
|
||||
caf::PdmField<bool> m_showScaleLegend;
|
||||
cvf::Vec3d m_cameraPositionLastUpdate;
|
||||
};
|
||||
|
||||
|
||||
@@ -155,6 +155,21 @@ RimMdiWindowGeometry RimViewWindow::mdiWindowGeometry()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewWindow::viewNavigationChanged()
|
||||
{
|
||||
onViewNavigationChanged();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Default implementation of virtual method to trigger updates on view navigation (zoom, camera move, etc)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewWindow::onViewNavigationChanged()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -207,7 +222,6 @@ void RimViewWindow::setAsMdiWindow(int mainWindowID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
virtual QImage snapshotWindowContent() = 0;
|
||||
virtual void zoomAll() = 0;
|
||||
|
||||
void viewNavigationChanged();
|
||||
|
||||
protected:
|
||||
void removeMdiWindowFromMdiArea();
|
||||
|
||||
@@ -75,6 +77,7 @@ protected:
|
||||
virtual void updateMdiWindowTitle(); // Has real default implementation
|
||||
virtual void deleteViewWidget() = 0;
|
||||
virtual void onLoadDataAndUpdate() = 0;
|
||||
virtual void onViewNavigationChanged();
|
||||
virtual bool isWindowVisible() { return m_showWindow();} // Virtual To allow special visibility control
|
||||
//////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user