From d86b6f690e644d3c3528d005e4ab8e8048e03a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 9 Feb 2018 13:30:18 +0100 Subject: [PATCH] #2337 Place legends aware of the possible edge axis border and enable the border by default in Intersection views --- .../Rim2dIntersectionView.cpp | 2 +- ApplicationCode/UserInterface/RiuViewer.cpp | 39 +++++++++++++++---- ApplicationCode/UserInterface/RiuViewer.h | 4 ++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 7c28f53f48..9202d68142 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -383,7 +383,7 @@ void Rim2dIntersectionView::resetLegendsInViewer() m_viewer->showAnimationProgress(true); m_viewer->showHistogram(false); m_viewer->showInfoText(false); - m_viewer->showEdgeTickMarks(false); + m_viewer->showEdgeTickMarks(true); m_viewer->setMainScene(new cvf::Scene()); m_viewer->enableNavigationRotation(false); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 6b03547d5b..66be9f6478 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -87,6 +87,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_axisCross->setAxisLabels("X", "Y", "Z"); m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); m_mainRendering->addOverlayItem(m_axisCross.p()); + m_showAxisCross = true; this->enableOverlyPainting(true); this->setReleaseOGLResourcesEachFrame(true); @@ -177,6 +178,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED; m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont); + m_showWindowEdgeAxes = false; } @@ -352,6 +354,8 @@ void RiuViewer::paintOverlayItems(QPainter* painter) //} int columnWidth = 200; + int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; int margin = 5; int yPos = margin; @@ -361,7 +365,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) //if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width()); if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_infoLabel->sizeHint().width()); - int columnPos = this->width() - columnWidth - margin; + int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth; if (showAnimBar && m_showAnimProgress) { @@ -404,7 +408,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) if (m_showInfoText) // Version Label { QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height()); - QPoint pos(this->width() - size.width() - margin, this->height() - size.height() - margin); + QPoint pos(this->width() - size.width() - margin - edgeAxisFrameBorderWidth, this->height() - size.height() - margin - edgeAxisFrameBorderHeight); m_versionInfoLabel->resize(size.width(), size.height()); m_versionInfoLabel->render(painter, pos); } @@ -505,6 +509,19 @@ void RiuViewer::mousePressEvent(QMouseEvent* event) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Collection RiuViewer::allOverlayItems() +{ + cvf::Collection allOverLays; + for (size_t oIdx = 0; oIdx < m_mainRendering->overlayItemCount(); ++oIdx) + { + allOverLays.push_back(m_mainRendering->overlayItem(oIdx)); + } + return allOverLays; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -544,6 +561,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) { legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); if (catLegend) { @@ -562,23 +580,25 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) } } - if (categoryLegends.size() > 0) + if (categoryLegends.size() > 0 || m_showWindowEdgeAxes) { const int border = 3; const int categoryWidth = 150; + int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; // This value is taken from OverlayAxisCross, as the axis cross is always shown in the lower left corner - const int axisCrossHeight = 120; + const int axisCrossHeight = m_showAxisCross? 120 : 0; int height = static_cast(m_mainCamera->viewport()->height()); - int xPos = border; + int xPos = border + edgeAxisBorderWidth; - int yPos = axisCrossHeight + 2*border; + int yPos = axisCrossHeight + 2*border + edgeAxisBorderHeight; for (auto catLegend : categoryLegends) { catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight)); + catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight - edgeAxisBorderHeight)); xPos += categoryWidth + border; } @@ -587,7 +607,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) { item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - yPos += item->sizeHint().y() + border; + yPos += item->sizeHint().y() + border + edgeAxisBorderHeight; } } } @@ -677,6 +697,7 @@ void RiuViewer::showAxisCross(bool enable) { m_mainRendering->addOverlayItem(m_axisCross.p()); } + m_showAxisCross = enable; } //-------------------------------------------------------------------------------------------------- @@ -804,6 +825,8 @@ void RiuViewer::showEdgeTickMarks(bool enable) { m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p()); } + + m_showWindowEdgeAxes = enable; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index dbc51eeb7a..ebee202195 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -149,7 +149,10 @@ private: QCDEStyle* m_progressBarStyle; cvf::ref m_axisCross; + bool m_showAxisCross; cvf::Collection m_visibleLegends; + cvf::Collection allOverlayItems(); + caf::PdmInterfacePointer m_rimView; QPoint m_lastMousePressPosition; @@ -158,6 +161,7 @@ private: RivGridBoxGenerator* m_gridBoxGenerator; cvf::ref m_windowEdgeAxisOverlay; + bool m_showWindowEdgeAxes; cvf::Vec3d m_cursorPositionDomainCoords; bool m_isNavigationRotationEnabled;