Merge branch 'dev' into measurement

This commit is contained in:
Magne Sjaastad
2019-01-02 14:32:17 +01:00
31 changed files with 263 additions and 269 deletions

View File

@@ -41,7 +41,11 @@ class RiuCalculationsContextMenuManager : public QObject
static const std::map<QString, std::set<QString>> MENU_MAP;
public:
RiuCalculationsContextMenuManager() { }
RiuCalculationsContextMenuManager()
: m_curveCalc(nullptr)
, m_textPosition(0)
{
}
void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc);

View File

@@ -39,7 +39,10 @@ class RiuExpressionContextMenuManager : public QObject
static const std::map<QString, std::set<QString>> MENU_MAP;
public:
RiuExpressionContextMenuManager() { }
RiuExpressionContextMenuManager()
: m_textPosition(0)
{
}
void attachTextEdit(QTextEdit* textEdit);

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,13 +27,14 @@
#include "RiaRegressionTestRunner.h"
#include "RimCase.h"
#include "RimProject.h"
#include "RimGridView.h"
#include "RimProject.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "RivGridBoxGenerator.h"
#include "RivTernarySaturationOverlayItem.h"
#include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h"
#include "RiuCadNavigation.h"
#include "RiuGeoQuestNavigation.h"
@@ -43,14 +44,14 @@
#include "cafPdmUiSelection3dEditorVisualizer.h"
#include "cafTitledOverlayFrame.h"
#include "cafCategoryLegend.h"
#include "cafOverlayScalarMapperLegend.h"
#include "cafCeetronPlusNavigation.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cafFrameAnimationControl.h"
#include "cafOverlayScalarMapperLegend.h"
#include "cafOverlayScaleLegend.h"
#include "cafTitledOverlayFrame.h"
#include "cvfCamera.h"
#include "cvfFont.h"
@@ -69,13 +70,11 @@
#include <QLabel>
#include <QMouseEvent>
#include <QProgressBar>
#include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h"
#include <algorithm>
using cvf::ManipulatorTrackball;
const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
//==================================================================================================
@@ -83,19 +82,19 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
/// \class RiuViewer
/// \ingroup ResInsight
///
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
: caf::Viewer(format, parent), m_isNavigationRotationEnabled(true)
: caf::Viewer(format, parent)
, m_isNavigationRotationEnabled(true)
{
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
m_axisCross->setAxisLabels("X", "Y", "Z");
m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT);
m_mainRendering->addOverlayItem(m_axisCross.p());
@@ -104,33 +103,32 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
this->enableOverlyPainting(true);
this->setReleaseOGLResourcesEachFrame(true);
QColor c;
QColor c;
QPalette p = QApplication::palette();
//QColor frameAndTextColor(255, 255, 255, 255);
// QColor frameAndTextColor(255, 255, 255, 255);
QColor frameAndTextColor(0, 0, 0, 255);
QColor progressAndHistogramColor(0,0,90,70); // Also Progressbar dark text color
QColor progressAndHistogramColor(0, 0, 90, 70); // Also Progress bar dark text color
//p.setColor(QPalette::Window, QColor(144, 173, 208, 180));
// p.setColor(QPalette::Window, QColor(144, 173, 208, 180));
p.setColor(QPalette::Window, QColor(255, 255, 255, 50));
p.setColor(QPalette::WindowText, frameAndTextColor);
c = p.color(QPalette::Base );
c = p.color(QPalette::Base);
c.setAlpha(100);
p.setColor(QPalette::Base, c);
//c = p.color(QPalette::AlternateBase );
//c.setAlpha(0);
//p.setColor(QPalette::AlternateBase, c);
// c = p.color(QPalette::AlternateBase );
// c.setAlpha(0);
// p.setColor(QPalette::AlternateBase, c);
//p.setColor(QPalette::Highlight, QColor(20, 20, 130, 40));
// p.setColor(QPalette::Highlight, QColor(20, 20, 130, 40));
p.setColor(QPalette::Highlight, progressAndHistogramColor);
//p.setColor(QPalette::HighlightedText, frameAndTextColor);
p.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 255)); //Progressbar light text color
// p.setColor(QPalette::HighlightedText, frameAndTextColor);
p.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 255)); // Progress bar light text color
//p.setColor(QPalette::Dark, QColor(230, 250, 255, 100));
// p.setColor(QPalette::Dark, QColor(230, 250, 255, 100));
p.setColor(QPalette::Dark, progressAndHistogramColor);
// Info Text
@@ -145,17 +143,17 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
m_versionInfoLabel->setFrameShape(QFrame::NoFrame);
m_versionInfoLabel->setAlignment(Qt::AlignRight);
m_versionInfoLabel->setText(QString("%1 v%2").arg(RI_APPLICATION_NAME, RiaApplication::getVersionStringApp(false)));
// Z scale label
m_zScaleLabel = new QLabel();
m_zScaleLabel->setFrameShape(QFrame::NoFrame);
m_zScaleLabel->setAlignment(Qt::AlignLeft);
m_zScaleLabel->setText(QString("Z: "));
m_showZScaleLabel = true;
m_showZScaleLabel = true;
m_hideZScaleCheckbox = false;
QPalette versionInfoPalette = p;
QColor versionInfoLabelColor = p.color(QPalette::Window);
QPalette versionInfoPalette = p;
QColor versionInfoLabelColor = p.color(QPalette::Window);
versionInfoLabelColor.setAlpha(0);
versionInfoPalette.setColor(QPalette::Window, versionInfoLabelColor);
m_versionInfoLabel->setPalette(versionInfoPalette);
@@ -202,8 +200,8 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
m_gridBoxGenerator = new RivGridBoxGenerator;
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont);
m_showWindowEdgeAxes = false;
m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont);
m_showWindowEdgeAxes = false;
m_selectionVisualizerManager = new caf::PdmUiSelection3dEditorVisualizer(this);
@@ -212,7 +210,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuViewer::~RiuViewer()
{
@@ -221,7 +219,7 @@ RiuViewer::~RiuViewer()
m_rimView->handleMdiWindowClosed();
m_rimView->setCameraPosition(m_mainCamera->viewMatrix());
m_rimView->setCameraPointOfInterest( pointOfInterest());
m_rimView->setCameraPointOfInterest(pointOfInterest());
}
delete m_infoLabel;
@@ -233,7 +231,6 @@ RiuViewer::~RiuViewer()
delete m_gridBoxGenerator;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -243,7 +240,7 @@ void RiuViewer::clearRimView()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setDefaultView()
{
@@ -251,7 +248,7 @@ void RiuViewer::setDefaultView()
if (!bb.isValid())
{
bb.add(cvf::Vec3d(-1, -1, -1));
bb.add(cvf::Vec3d( 1, 1, 1));
bb.add(cvf::Vec3d(1, 1, 1));
}
if (m_mainCamera->projection() == cvf::Camera::PERSPECTIVE)
@@ -269,9 +266,8 @@ void RiuViewer::setDefaultView()
m_mainCamera->fitView(bb, -cvf::Vec3d::Z_AXIS, cvf::Vec3d::Y_AXIS);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
{
@@ -299,7 +295,6 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
m_viewerCommands->handlePickAction(event->x(), event->y(), event->modifiers());
return;
}
else if (event->button() == Qt::RightButton)
{
@@ -316,7 +311,7 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::slotEndAnimation()
{
@@ -324,14 +319,14 @@ void RiuViewer::slotEndAnimation()
CVF_ASSERT(firstRendering);
if (m_rimView) m_rimView->endAnimation();
caf::Viewer::slotEndAnimation();
caf::EffectGenerator::releaseUnreferencedEffects();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::slotSetCurrentFrame(int frameIndex)
{
@@ -348,7 +343,7 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RiuViewer::pointOfInterest()
{
@@ -356,7 +351,7 @@ cvf::Vec3d RiuViewer::pointOfInterest()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setPointOfInterest(cvf::Vec3d poi)
{
@@ -364,9 +359,9 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setOwnerReservoirView(RiuViewerToViewInterface * owner)
void RiuViewer::setOwnerReservoirView(RiuViewerToViewInterface* owner)
{
m_rimView = owner;
@@ -374,7 +369,7 @@ void RiuViewer::setOwnerReservoirView(RiuViewerToViewInterface * owner)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setEnableMask(unsigned int mask)
{
@@ -382,17 +377,17 @@ void RiuViewer::setEnableMask(unsigned int mask)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
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 edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0;
int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0;
int margin = 5;
int yPos = margin + edgeAxisFrameBorderHeight;
int yPos = margin + edgeAxisFrameBorderHeight;
bool showAnimBar = false;
if (isAnimationActive() && frameCount() > 1) showAnimBar = true;
@@ -410,9 +405,8 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
m_animationProgress->setValue(currentFrameIndex());
m_animationProgress->resize(columnWidth, m_animationProgress->sizeHint().height());
m_animationProgress->render(painter,QPoint(columnPos, yPos));
yPos += m_animationProgress->height() + margin;
m_animationProgress->render(painter, QPoint(columnPos, yPos));
yPos += m_animationProgress->height() + margin;
}
if (m_showInfoText)
@@ -425,7 +419,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
m_infoLabelOverlayArea.setBottom(yPos + m_infoLabel->height());
m_infoLabelOverlayArea.setRight(columnPos + columnWidth);
yPos += m_infoLabel->height() + margin;
yPos += m_infoLabel->height() + margin;
}
else
{
@@ -435,14 +429,15 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
if (m_showHistogram)
{
m_histogramWidget->resize(columnWidth, 40);
m_histogramWidget->render(painter,QPoint(columnPos, yPos));
//yPos += m_histogramWidget->height() + margin;
m_histogramWidget->render(painter, QPoint(columnPos, yPos));
// yPos += m_histogramWidget->height() + margin;
}
if (m_showInfoText) // Version Label
{
QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height());
QPoint pos(this->width() - size.width() - margin - edgeAxisFrameBorderWidth, this->height() - size.height() - margin - edgeAxisFrameBorderHeight);
QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height());
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);
}
@@ -450,8 +445,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
if (m_showZScaleLabel) // Z scale Label
{
QSize size(m_zScaleLabel->sizeHint().width(), m_zScaleLabel->sizeHint().height());
QPoint pos(margin + edgeAxisFrameBorderWidth,
margin + edgeAxisFrameBorderHeight);
QPoint pos(margin + edgeAxisFrameBorderWidth, margin + edgeAxisFrameBorderHeight);
m_zScaleLabel->resize(size.width(), size.height());
m_zScaleLabel->render(painter, pos);
}
@@ -467,21 +461,23 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
cvf::Vec3d screenCoords;
if (mainCamera()->project(displayCoord, &screenCoords))
{
int translatedMousePosY = height() - screenCoords.y();
int translatedMousePosY = height() - screenCoords.y();
QPoint centerPos(screenCoords.x(), translatedMousePosY);
// Draw a cross hair marker
int markerHalfLength = 6;
painter->drawLine(centerPos.x(), centerPos.y() - markerHalfLength, centerPos.x(), centerPos.y() + markerHalfLength);
painter->drawLine(centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y());
painter->drawLine(
centerPos.x(), centerPos.y() - markerHalfLength, centerPos.x(), centerPos.y() + markerHalfLength);
painter->drawLine(
centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y());
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setInfoText(QString text)
{
@@ -513,7 +509,7 @@ void RiuViewer::setZScale(int scale)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showInfoText(bool enable)
{
@@ -521,7 +517,7 @@ void RiuViewer::showInfoText(bool enable)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setHistogram(double min, double max, const std::vector<size_t>& histogram)
{
@@ -529,7 +525,7 @@ void RiuViewer::setHistogram(double min, double max, const std::vector<size_t>&
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setHistogramPercentiles(double pmin, double pmax, double mean)
{
@@ -538,7 +534,7 @@ void RiuViewer::setHistogramPercentiles(double pmin, double pmax, double mean)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showGridBox(bool enable)
{
@@ -551,7 +547,7 @@ void RiuViewer::showGridBox(bool enable)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showAnimationProgress(bool enable)
{
@@ -559,7 +555,7 @@ void RiuViewer::showAnimationProgress(bool enable)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showHistogram(bool enable)
{
@@ -567,7 +563,7 @@ void RiuViewer::showHistogram(bool enable)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::mousePressEvent(QMouseEvent* event)
{
@@ -575,7 +571,7 @@ void RiuViewer::mousePressEvent(QMouseEvent* event)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::removeAllColorLegends()
{
@@ -588,13 +584,13 @@ void RiuViewer::removeAllColorLegends()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedLegend)
{
RiaApplication* app = RiaApplication::instance();
CVF_ASSERT(app);
RiaPreferences* preferences = app->preferences();
RiaPreferences* preferences = app->preferences();
cvf::Rendering* firstRendering = m_mainRendering.p();
CVF_ASSERT(preferences);
CVF_ASSERT(firstRendering);
@@ -602,10 +598,10 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedL
if (addedLegend)
{
cvf::Color4f backgroundColor = mainCamera()->viewport()->clearColor();
backgroundColor.a() = 0.8f;
backgroundColor.a() = 0.8f;
cvf::Color3f frameColor(backgroundColor.r(), backgroundColor.g(), backgroundColor.b());
updateLegendTextAndTickMarkColor(addedLegend);
firstRendering->addOverlayItem(addedLegend);
addedLegend->enableBackground(preferences->showLegendBackground());
addedLegend->setBackgroundColor(backgroundColor);
@@ -615,103 +611,109 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedL
}
updateLegendLayout();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateLegendLayout()
{
int viewPortHeight = static_cast<int>(m_mainCamera->viewport()->height());
const float maxFreeLegendHeight = 0.7f*viewPortHeight;
const int border = 3;
int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0;
int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0;
const float maxFreeLegendHeight = 0.7f * viewPortHeight;
const int border = 3;
int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0;
int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0;
int xPos = border + edgeAxisBorderWidth;
int yPos = border + edgeAxisBorderHeight;
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_visibleLegends )
{
cvf::Vec2ui prefSize = legend->preferredSize();
if (prefSize.y() > maxFreeLegendHeight)
int xPos = border + edgeAxisBorderWidth;
int yPos = border + edgeAxisBorderHeight;
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_visibleLegends)
{
int legendWidth = prefSize.x();
legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos));
legend->setRenderSize(cvf::Vec2ui(legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight));
xPos += legendWidth + border;
}
else
{
standardHeightLegends.push_back(legend.p());
}
}
// Place the rest of the legends in columns that fits within the screen height
int maxColumnWidht = 0;
std::vector<caf::TitledOverlayFrame*> columnLegends;
for ( caf::TitledOverlayFrame* legend : standardHeightLegends )
{
cvf::Vec2ui prefSize = legend->preferredSize();
// Check if we need a new column
if ((yPos + (int)prefSize.y() + border) > viewPortHeight)
{
xPos += border + maxColumnWidht;
yPos = border + edgeAxisBorderHeight;
// Set same width to all legends in the column
for (caf::TitledOverlayFrame* columnLegend : columnLegends )
cvf::Vec2ui prefSize = legend->preferredSize();
if (prefSize.y() > maxFreeLegendHeight)
{
columnLegend->setRenderSize(cvf::Vec2ui(maxColumnWidht, columnLegend->renderSize().y()));
int legendWidth = prefSize.x();
legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos));
legend->setRenderSize(cvf::Vec2ui(legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight));
xPos += legendWidth + border;
}
else
{
standardHeightLegends.push_back(legend.p());
}
maxColumnWidht = 0;
columnLegends.clear();
}
legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos));
legend->setRenderSize(cvf::Vec2ui(prefSize.x(), prefSize.y()));
columnLegends.push_back(legend);
// Place the rest of the legends in columns that fits within the screen height
yPos += legend->renderSize().y() + border;
maxColumnWidht = std::max(maxColumnWidht, (int)prefSize.x());
int maxColumnWidht = 0;
std::vector<caf::TitledOverlayFrame*> columnLegends;
for (caf::TitledOverlayFrame* legend : standardHeightLegends)
{
cvf::Vec2ui prefSize = legend->preferredSize();
// Check if we need a new column
if ((yPos + (int)prefSize.y() + border) > viewPortHeight)
{
xPos += border + maxColumnWidht;
yPos = border + edgeAxisBorderHeight;
// Set same width to all legends in the column
for (caf::TitledOverlayFrame* columnLegend : columnLegends)
{
columnLegend->setRenderSize(cvf::Vec2ui(maxColumnWidht, columnLegend->renderSize().y()));
}
maxColumnWidht = 0;
columnLegends.clear();
}
legend->setLayoutFixedPosition(cvf::Vec2i(xPos, 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());
}
// Set same width to all legends in the last column
for (caf::TitledOverlayFrame* legend : columnLegends)
{
legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y()));
}
}
// Set same width to all legends in the last column
for (caf::TitledOverlayFrame* legend : columnLegends )
{
legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y()));
}
int margin = 5;
auto scaleLegendSize = m_scaleLegend->renderSize();
auto otherItemsHeight = m_versionInfoLabel->sizeHint().height();
int margin = 5;
auto scaleLegendSize = m_scaleLegend->renderSize();
auto otherItemsHeight = m_versionInfoLabel->size().height();
m_scaleLegend->setLayoutFixedPosition({ width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth,
margin + edgeAxisBorderHeight + margin + otherItemsHeight});
const int xPos = width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth;
const int yPos = margin + edgeAxisBorderHeight + margin + otherItemsHeight;
m_scaleLegend->setLayoutFixedPosition({xPos, yPos});
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::enableNavigationRotation(bool enable)
{
auto tbNavPol = dynamic_cast<caf::TrackBallBasedNavigation*>(m_navigationPolicy.p());
auto tbNavPol = dynamic_cast<caf::TrackBallBasedNavigation*>(m_navigationPolicy.p());
m_isNavigationRotationEnabled = enable;
if (tbNavPol) tbNavPol->enableRotation(m_isNavigationRotationEnabled);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateNavigationPolicy()
{
@@ -742,7 +744,7 @@ void RiuViewer::updateNavigationPolicy()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::navigationPolicyUpdate()
{
@@ -759,7 +761,7 @@ void RiuViewer::navigationPolicyUpdate()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setCurrentFrame(int frameIndex)
{
@@ -767,14 +769,14 @@ void RiuViewer::setCurrentFrame(int frameIndex)
CVF_ASSERT(firstRendering);
if (m_rimView) m_rimView->setCurrentTimeStepAndUpdate(frameIndex);
animationControl()->setCurrentFrameOnly(frameIndex);
caf::Viewer::slotSetCurrentFrame(frameIndex);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showAxisCross(bool enable)
{
@@ -788,7 +790,7 @@ void RiuViewer::showAxisCross(bool enable)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuViewerToViewInterface* RiuViewer::ownerReservoirView()
{
@@ -796,15 +798,15 @@ RiuViewerToViewInterface* RiuViewer::ownerReservoirView()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuViewer::ownerViewWindow() const
{
return dynamic_cast<RimViewWindow*>( m_rimView.p());
return dynamic_cast<RimViewWindow*>(m_rimView.p());
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::optimizeClippingPlanes()
{
@@ -823,7 +825,7 @@ void RiuViewer::optimizeClippingPlanes()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::resizeGL(int width, int height)
{
@@ -832,7 +834,7 @@ void RiuViewer::resizeGL(int width, int height)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
{
@@ -845,7 +847,9 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
int translatedMousePosY = height() - mouseEvent->pos().y();
cvf::Vec3d displayCoord(0, 0, 0);
if (mainCamera()->unproject(cvf::Vec3d(static_cast<double>(translatedMousePosX), static_cast<double>(translatedMousePosY), 0), &displayCoord))
if (mainCamera()->unproject(
cvf::Vec3d(static_cast<double>(translatedMousePosX), static_cast<double>(translatedMousePosY), 0),
&displayCoord))
{
if (m_cursorPositionDomainCoords != cvf::Vec3d::UNDEFINED)
{
@@ -856,10 +860,10 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
update();
}
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord);
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord);
viewLinker->updateCursorPosition(dynamic_cast<RimGridView*>(m_rimView.p()) , domainCoord);
viewLinker->updateCursorPosition(dynamic_cast<RimGridView*>(m_rimView.p()), domainCoord);
}
}
}
@@ -868,9 +872,9 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::leaveEvent(QEvent *)
void RiuViewer::leaveEvent(QEvent*)
{
if (m_rimView && m_rimView->assosiatedViewLinker())
{
@@ -880,11 +884,11 @@ void RiuViewer::leaveEvent(QEvent *)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateGridBoxData(double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
void RiuViewer::updateGridBoxData(double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
const cvf::BoundingBox& domainCoordBoundingBox)
{
m_gridBoxGenerator->setScaleZ(scaleZ);
@@ -911,11 +915,14 @@ void RiuViewer::showEdgeTickMarksXY(bool enable, bool showAxisLines)
m_windowEdgeAxisOverlay->setShowAxisLines(showAxisLines);
m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p());
}
m_showWindowEdgeAxes = enable;
updateLegendLayout();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showEdgeTickMarksXZ(bool enable, bool showAxisLines)
{
@@ -928,11 +935,14 @@ void RiuViewer::showEdgeTickMarksXZ(bool enable, bool showAxisLines)
m_windowEdgeAxisOverlay->setShowAxisLines(showAxisLines);
m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p());
}
m_showWindowEdgeAxes = enable;
updateLegendLayout();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateAnnotationItems()
{
@@ -940,7 +950,7 @@ void RiuViewer::updateAnnotationItems()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel)
{
@@ -948,7 +958,7 @@ void RiuViewer::setAxisLabels(const cvf::String& xLabel, const cvf::String& yLab
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RiuViewer::lastPickPositionInDomainCoords() const
{
@@ -958,7 +968,7 @@ cvf::Vec3d RiuViewer::lastPickPositionInDomainCoords() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend(int winPosX, int winPosY)
{
@@ -978,7 +988,7 @@ cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend(int winPosX, int winPosY)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
{
@@ -991,7 +1001,7 @@ void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::ref<cvf::Part>> RiuViewer::visibleParts()
{
@@ -999,8 +1009,8 @@ std::vector<cvf::ref<cvf::Part>> RiuViewer::visibleParts()
if (m_mainRendering.notNull())
{
auto enableMask = m_mainRendering->enableMask();
cvf::Scene* scene = currentScene();
auto enableMask = m_mainRendering->enableMask();
cvf::Scene* scene = currentScene();
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
@@ -1031,7 +1041,7 @@ void RiuViewer::showScaleLegend(bool show)
{
if (show)
{
if(m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL)
if (m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL)
m_scaleLegend->setRenderSize({280, 45});
else
m_scaleLegend->setRenderSize({50, 280});
@@ -1042,10 +1052,12 @@ void RiuViewer::showScaleLegend(bool show)
{
m_mainRendering->removeOverlayItem(m_scaleLegend.p());
}
updateLegendLayout();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend)
{
@@ -1075,7 +1087,7 @@ void RiuViewer::updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateTextAndTickMarkColorForOverlayItems()
{
@@ -1088,7 +1100,7 @@ void RiuViewer::updateTextAndTickMarkColorForOverlayItems()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateAxisCrossTextColor()
{
@@ -1098,7 +1110,7 @@ void RiuViewer::updateAxisCrossTextColor()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RiuViewer::computeContrastColor() const
{
@@ -1106,8 +1118,8 @@ cvf::Color3f RiuViewer::computeContrastColor() const
if (m_rimView.notNull())
{
contrastColor = RiaColorTools::constrastColor(m_rimView->backgroundColor());
contrastColor = RiaColorTools::contrastColor(m_rimView->backgroundColor());
}
return contrastColor;
}

View File

@@ -178,12 +178,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
if (pickItemInfos.size())
{
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
if ( pickItemInfos.size() )
{
globalIntersectionPoint = pickItemInfos[0].globalPickedPoint();
}
cvf::Vec3d globalIntersectionPoint = pickItemInfos[0].globalPickedPoint();
for (const auto& pickItem : pickItemInfos)
{

View File

@@ -50,6 +50,7 @@ RiuWellPathComponentPlotItem::RiuWellPathComponentPlotItem(const RimWellPath* we
, m_componentType(RiaDefines::WELL_PATH)
, m_columnOffset(0.0)
, m_depthType(RimWellLogPlot::MEASURED_DEPTH)
, m_maxColumnOffset(0.0)
, m_showLabel(false)
{
CVF_ASSERT(wellPath);
@@ -68,6 +69,7 @@ RiuWellPathComponentPlotItem::RiuWellPathComponentPlotItem(const RimWellPath* we
: m_wellPath(wellPath)
, m_columnOffset(0.0)
, m_depthType(RimWellLogPlot::MEASURED_DEPTH)
, m_maxColumnOffset(0.0)
, m_showLabel(false)
{
CVF_ASSERT(wellPath && component);
@@ -306,7 +308,7 @@ QwtPlotItem* RiuWellPathComponentPlotItem::createMarker(double posX, double dept
QColor textColor = RiaColorTools::toQColor(baseColor.toColor3f(), 1.0);
if (contrastTextColor)
{
textColor = RiaColorTools::toQColor(RiaColorTools::constrastColor(baseColor.toColor3f()));
textColor = RiaColorTools::toQColor(RiaColorTools::contrastColor(baseColor.toColor3f()));
}
QwtPlotMarker* marker = new QwtPlotMarker(label);
RiuQwtSymbol* symbol = new RiuQwtSymbol(symbolType, "", RiuQwtSymbol::LabelRightOfSymbol);