From b26d199815109b9fc49f9df36349ebf0db32022c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 20 Nov 2015 09:12:07 +0100 Subject: [PATCH] (#639) Show E (x,1) on axis label As the space is limited, the text is compressed to "E-x1", "N-y2", "Z-3" --- .../ProjectDataModel/RimGeoMechView.cpp | 16 ++++++++++ .../ProjectDataModel/RimGeoMechView.h | 2 ++ ApplicationCode/UserInterface/RiuViewer.cpp | 32 ++++++++++++++++--- ApplicationCode/UserInterface/RiuViewer.h | 4 +++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 4fd8e0c4e7..9794c1dd0c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -155,6 +155,8 @@ void RimGeoMechView::loadDataAndUpdate() progress.setProgressDescription("Create Display model"); updateViewerWidget(); + setCustomAxisCrossLabels(); + this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters(); this->scheduleCreateDisplayModelAndRedraw(); @@ -481,6 +483,8 @@ void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c { bool generateDisplayModel = (viewer() == NULL); updateViewerWidget(); + setCustomAxisCrossLabels(); + if (generateDisplayModel) { scheduleCreateDisplayModelAndRedraw(); @@ -512,6 +516,18 @@ void RimGeoMechView::initAfterRead() this->updateUiIconFromToggleField(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::setCustomAxisCrossLabels() +{ + // Minimalistic - size of axis cross does not have to be adjusted + if (m_viewer) m_viewer->setAxisLabels("E-x1", "N-y2", "Z-3"); + + // A bit larger - size of axis cross is slightly larger + //if (m_viewer) m_viewer->setAxisLabels("E(x,1)", "N(y,2)", "Z(3)"); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 823e173b3d..4fe6dceea7 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -101,6 +101,8 @@ private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void initAfterRead(); + void setCustomAxisCrossLabels(); + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index cf76402a35..4bdc8831e2 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -77,10 +77,10 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) : caf::Viewer(format, parent) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); - cvf::OverlayAxisCross* axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont); - axisCross->setAxisLabels("E", "N", "Z"); - axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); - m_mainRendering->addOverlayItem(axisCross); + m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont); + m_axisCross->setAxisLabels("E", "N", "Z"); + m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + m_mainRendering->addOverlayItem(m_axisCross.p()); this->enableOverlyPainting(true); this->setReleaseOGLResourcesEachFrame(true); @@ -571,3 +571,27 @@ cvf::Model* RiuViewer::gridBoxModel() const { return m_gridBoxGenerator->model(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel) +{ + m_axisCross->setAxisLabels(xLabel, yLabel, zLabel); + + size_t maxAxisLabelLength = xLabel.size(); + if (yLabel.size() > maxAxisLabelLength) maxAxisLabelLength = yLabel.size(); + if (zLabel.size() > maxAxisLabelLength) maxAxisLabelLength = zLabel.size(); + + if (maxAxisLabelLength > 4) + { + if (maxAxisLabelLength < 6) + { + m_axisCross->setSize(cvf::Vec2ui(140, 140)); + } + else if (maxAxisLabelLength < 8) + { + m_axisCross->setSize(cvf::Vec2ui(160, 160)); + } + } +} diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 04b5c89376..3a52f93e66 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -42,6 +42,7 @@ namespace cvf class Model; class OverlayItem; class Part; + class OverlayAxisCross; } //================================================================================================== @@ -84,6 +85,8 @@ public: void setCurrentFrame(int frameIndex); + void setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel); + public slots: virtual void slotSetCurrentFrame(int frameIndex); virtual void slotEndAnimation(); @@ -109,6 +112,7 @@ private: QCDEStyle* m_progressBarStyle; + cvf::ref m_axisCross; cvf::Collection m_visibleLegends; caf::PdmPointer m_rimView;