#2337 Place legends aware of the possible edge axis border and enable the border by default in Intersection views

This commit is contained in:
Jacob Støren
2018-02-09 13:30:18 +01:00
parent 068adf6aa2
commit d86b6f690e
3 changed files with 36 additions and 9 deletions

View File

@@ -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);

View File

@@ -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<cvf::OverlayItem> RiuViewer::allOverlayItems()
{
cvf::Collection<cvf::OverlayItem> 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<caf::CategoryLegend*>(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<int>(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;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -149,7 +149,10 @@ private:
QCDEStyle* m_progressBarStyle;
cvf::ref<cvf::OverlayAxisCross> m_axisCross;
bool m_showAxisCross;
cvf::Collection<cvf::OverlayItem> m_visibleLegends;
cvf::Collection<cvf::OverlayItem> allOverlayItems();
caf::PdmInterfacePointer<RiuViewerToViewInterface> m_rimView;
QPoint m_lastMousePressPosition;
@@ -158,6 +161,7 @@ private:
RivGridBoxGenerator* m_gridBoxGenerator;
cvf::ref<RivWindowEdgeAxesOverlayItem> m_windowEdgeAxisOverlay;
bool m_showWindowEdgeAxes;
cvf::Vec3d m_cursorPositionDomainCoords;
bool m_isNavigationRotationEnabled;