mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4995 Place legends from comparison view to the right.
Adjust the axiscross to follow the legends
This commit is contained in:
parent
331361e2b2
commit
a9dc07ddc9
@ -679,7 +679,7 @@ void Rim2dIntersectionView::onUpdateLegends()
|
||||
|
||||
if ( legend )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( legend );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( legend, isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,8 @@ void RimEclipseContourMapView::onUpdateLegends()
|
||||
m_contourMapProjection->updateLegend();
|
||||
if ( projectionLegend->showLegend() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1232,8 +1232,9 @@ void RimEclipseView::onUpdateLegends()
|
||||
|
||||
this->cellEdgeResult()->legendConfig()->setTitle( QString( "Edge Results: \n" ) +
|
||||
this->cellEdgeResult()->resultVariableUiShortName() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner(
|
||||
this->cellEdgeResult()->legendConfig()->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()
|
||||
->addColorLegendToBottomLeftCorner( this->cellEdgeResult()->legendConfig()->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1266,7 +1267,8 @@ void RimEclipseView::onUpdateLegends()
|
||||
|
||||
if ( fractureColors()->isChecked() && stimPlanLegend->titledOverlayFrame() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( stimPlanLegend->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( stimPlanLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1277,7 +1279,8 @@ void RimEclipseView::onUpdateLegends()
|
||||
updateVirtualConnectionLegendRanges();
|
||||
|
||||
RimRegularLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig();
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( virtLegend->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( virtLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1307,7 +1310,8 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView( QString
|
||||
}
|
||||
|
||||
resultColors->legendConfig()->setTitle( title );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( resultColors->legendConfig()->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( resultColors->legendConfig()->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
|
||||
@ -1317,8 +1321,9 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView( QString
|
||||
resultColors->ternaryLegendConfig()->titledOverlayFrame() )
|
||||
{
|
||||
resultColors->ternaryLegendConfig()->setTitle( legendLabel );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner(
|
||||
resultColors->ternaryLegendConfig()->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()
|
||||
->addColorLegendToBottomLeftCorner( resultColors->ternaryLegendConfig()->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,8 @@ void RimGeoMechContourMapView::onUpdateLegends()
|
||||
m_contourMapProjection->updateLegend();
|
||||
if ( projectionLegend->showLegend() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +451,8 @@ void RimGeoMechView::onUpdateLegends()
|
||||
|
||||
if ( cellResult()->hasResult() && cellResult()->legendConfig()->showLegend() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( cellResult()->legendConfig->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( cellResult()->legendConfig->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
if ( tensorResults()->showTensors() )
|
||||
@ -461,8 +462,9 @@ void RimGeoMechView::onUpdateLegends()
|
||||
if ( tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS &&
|
||||
tensorResults()->arrowColorLegendConfig()->showLegend() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner(
|
||||
m_tensorResults->arrowColorLegendConfig->titledOverlayFrame() );
|
||||
nativeOrOverrideViewer()
|
||||
->addColorLegendToBottomLeftCorner( m_tensorResults->arrowColorLegendConfig->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,14 +582,19 @@ void RiuViewer::removeAllColorLegends()
|
||||
{
|
||||
overlayItemsRendering()->removeOverlayItem( m_visibleLegends[i].p() );
|
||||
}
|
||||
for ( auto legend : m_visibleComparisonLegends )
|
||||
{
|
||||
overlayItemsRendering()->removeOverlayItem( legend.p() );
|
||||
}
|
||||
|
||||
m_visibleLegends.clear();
|
||||
m_visibleComparisonLegends.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* addedLegend )
|
||||
void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* addedLegend, bool isForComparisonView )
|
||||
{
|
||||
if ( !addedLegend || m_visibleLegends.contains( addedLegend ) ) return;
|
||||
|
||||
@ -612,7 +617,15 @@ void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* added
|
||||
addedLegend->setFont( app->defaultSceneFont() );
|
||||
|
||||
overlayRendering->addOverlayItem( addedLegend );
|
||||
m_visibleLegends.push_back( addedLegend );
|
||||
|
||||
if ( isForComparisonView )
|
||||
{
|
||||
m_visibleComparisonLegends.push_back( addedLegend );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_visibleLegends.push_back( addedLegend );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -622,6 +635,7 @@ void RiuViewer::removeColorLegend( caf::TitledOverlayFrame* legend )
|
||||
{
|
||||
overlayItemsRendering()->removeOverlayItem( legend );
|
||||
m_visibleLegends.erase( legend );
|
||||
m_visibleComparisonLegends.erase( legend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -636,6 +650,7 @@ void RiuViewer::updateLegendLayout()
|
||||
int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0;
|
||||
int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0;
|
||||
|
||||
// Place the main view legends from left to right
|
||||
{
|
||||
int xPos = border + edgeAxisBorderWidth;
|
||||
int yPos = border + edgeAxisBorderHeight;
|
||||
@ -701,6 +716,90 @@ void RiuViewer::updateLegendLayout()
|
||||
}
|
||||
}
|
||||
|
||||
// Place the comparison view legends from right to left
|
||||
{
|
||||
int viewPortWidth = static_cast<int>( m_mainCamera->viewport()->width() );
|
||||
|
||||
int xPos = viewPortWidth - border + edgeAxisBorderWidth;
|
||||
int yPosStart = border + edgeAxisBorderHeight + m_versionInfoLabel->sizeHint().height() + 5;
|
||||
int yPos = yPosStart;
|
||||
|
||||
std::vector<caf::TitledOverlayFrame*> standardHeightLegends;
|
||||
|
||||
// Place the legends needing the full height, and sort out the standard height legends
|
||||
|
||||
for ( cvf::ref<caf::TitledOverlayFrame> legend : m_visibleComparisonLegends )
|
||||
{
|
||||
cvf::Vec2ui prefSize = legend->preferredSize();
|
||||
if ( prefSize.y() > maxFreeLegendHeight )
|
||||
{
|
||||
int legendWidth = prefSize.x();
|
||||
legend->setLayoutFixedPosition( cvf::Vec2i( xPos - legendWidth, yPos ) );
|
||||
legend->setRenderSize(
|
||||
cvf::Vec2ui( legendWidth, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) );
|
||||
xPos -= legendWidth + border;
|
||||
}
|
||||
else
|
||||
{
|
||||
standardHeightLegends.push_back( legend.p() );
|
||||
}
|
||||
}
|
||||
|
||||
// Place the rest of the legends in columns that fits within the screen height
|
||||
|
||||
std::vector<caf::TitledOverlayFrame*> columnLegends;
|
||||
|
||||
int maxColumnWidht = 0;
|
||||
|
||||
for ( caf::TitledOverlayFrame* legend : standardHeightLegends )
|
||||
{
|
||||
cvf::Vec2ui prefSize = legend->preferredSize();
|
||||
|
||||
// Check if we need a new column
|
||||
if ( ( yPos + (int)prefSize.y() + border ) > viewPortHeight )
|
||||
{
|
||||
// Finish the previous column setting same width to all legends and correcting the xposition accordingly
|
||||
for ( caf::TitledOverlayFrame* columnLegend : columnLegends )
|
||||
{
|
||||
columnLegend->setRenderSize( cvf::Vec2ui( maxColumnWidht, columnLegend->renderSize().y() ) );
|
||||
columnLegend->setLayoutFixedPosition(
|
||||
cvf::Vec2i( xPos - maxColumnWidht, columnLegend->fixedPosition().y() ) );
|
||||
}
|
||||
|
||||
// Increment to make ready for a new column
|
||||
xPos -= border + maxColumnWidht;
|
||||
yPos = yPosStart;
|
||||
|
||||
maxColumnWidht = 0;
|
||||
columnLegends.clear();
|
||||
}
|
||||
|
||||
legend->setLayoutFixedPosition( cvf::Vec2i( xPos - prefSize.x(), yPos ) );
|
||||
legend->setRenderSize( cvf::Vec2ui( prefSize.x(), prefSize.y() ) );
|
||||
columnLegends.push_back( legend );
|
||||
|
||||
yPos += legend->renderSize().y() + border;
|
||||
maxColumnWidht = std::max( maxColumnWidht, (int)prefSize.x() );
|
||||
}
|
||||
|
||||
// Finish the last column setting same width to all legends and correcting the xposition accordingly
|
||||
|
||||
for ( caf::TitledOverlayFrame* columnLegend : columnLegends )
|
||||
{
|
||||
columnLegend->setRenderSize( cvf::Vec2ui( maxColumnWidht, columnLegend->renderSize().y() ) );
|
||||
columnLegend->setLayoutFixedPosition( cvf::Vec2i( xPos - maxColumnWidht, columnLegend->fixedPosition().y() ) );
|
||||
}
|
||||
|
||||
xPos -= maxColumnWidht;
|
||||
|
||||
// Set axis cross position at the bottom besides the last column
|
||||
{
|
||||
m_axisCross->setLayoutFixedPosition(
|
||||
cvf::Vec2i( xPos + border - m_axisCross->sizeHint().x(), edgeAxisBorderHeight ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Set the position of the scale bar used in contour map views
|
||||
{
|
||||
int margin = 5;
|
||||
auto scaleLegendSize = m_scaleLegend->renderSize();
|
||||
@ -1016,6 +1115,18 @@ cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend( int winPosX, int winPosY
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto overlayItem : m_visibleComparisonLegends )
|
||||
{
|
||||
if ( overlayItem->layoutScheme() == cvf::OverlayItem::FIXED_POSITION &&
|
||||
overlayItem->pick( translatedMousePosX,
|
||||
translatedMousePosY,
|
||||
overlayItem->fixedPosition(),
|
||||
overlayItem->renderSize() ) )
|
||||
{
|
||||
return overlayItem.p();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1166,6 +1277,11 @@ void RiuViewer::updateTextAndTickMarkColorForOverlayItems()
|
||||
updateLegendTextAndTickMarkColor( m_visibleLegends.at( i ) );
|
||||
}
|
||||
|
||||
for ( auto legend : m_visibleComparisonLegends )
|
||||
{
|
||||
updateLegendTextAndTickMarkColor( legend.p() );
|
||||
}
|
||||
|
||||
updateAxisCrossTextColor();
|
||||
|
||||
updateOverlayItemsStyle();
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
void showAnimationProgress( bool enable );
|
||||
|
||||
void removeAllColorLegends();
|
||||
void addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* legend );
|
||||
void addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* legend, bool isForComparisonView );
|
||||
void removeColorLegend( caf::TitledOverlayFrame* legend );
|
||||
|
||||
void enableNavigationRotation( bool disable );
|
||||
@ -185,6 +185,7 @@ private:
|
||||
cvf::ref<cvf::OverlayAxisCross> m_axisCross;
|
||||
bool m_showAxisCross;
|
||||
cvf::Collection<caf::TitledOverlayFrame> m_visibleLegends;
|
||||
cvf::Collection<caf::TitledOverlayFrame> m_visibleComparisonLegends;
|
||||
|
||||
caf::PdmInterfacePointer<RiuViewerToViewInterface> m_rimView;
|
||||
QPoint m_lastMousePressPosition;
|
||||
|
Loading…
Reference in New Issue
Block a user