mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
Merge remote-tracking branch 'origin/dev' into summary-text-edit-in-toolbar
This commit is contained in:
@@ -46,7 +46,9 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QWheelEvent>
|
||||
|
||||
|
||||
@@ -198,11 +200,18 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
|
||||
m_comboBox->blockSignals(true);
|
||||
m_comboBox->clear();
|
||||
QListView* listView = dynamic_cast<QListView*>(m_comboBox->view());
|
||||
if (listView)
|
||||
{
|
||||
listView->setSpacing(2);
|
||||
}
|
||||
|
||||
if (!options.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < options.size(); i++)
|
||||
for (const auto& option : options)
|
||||
{
|
||||
m_comboBox->addItem(options[i].icon(), options[i].optionUiText());
|
||||
m_comboBox->addItem(option.icon(), option.optionUiText());
|
||||
m_comboBox->setIconSize(m_attributes.iconSize);
|
||||
}
|
||||
m_comboBox->setCurrentIndex(uiField()->uiValue().toInt());
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
minimumContentsLength = 8;
|
||||
enableEditableContent = false;
|
||||
minimumWidth = -1;
|
||||
iconSize = QSize(14, 14);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -75,6 +76,8 @@ public:
|
||||
int minimumWidth;
|
||||
QString nextButtonText;
|
||||
QString prevButtonText;
|
||||
|
||||
QSize iconSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -171,6 +171,14 @@ void PdmUiTreeView::selectAsCurrentItem(const PdmUiItem* uiItem)
|
||||
m_treeViewEditor->selectAsCurrentItem(uiItem);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeView::selectItems(const std::vector<const PdmUiItem*>& uiItems)
|
||||
{
|
||||
m_treeViewEditor->selectItems(uiItems);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
|
||||
void selectedUiItems(std::vector<PdmUiItem*>& objects); // TODO: rename
|
||||
void selectAsCurrentItem(const PdmUiItem* uiItem);
|
||||
void selectItems(const std::vector<const PdmUiItem*>& uiItems);
|
||||
void setExpanded(const PdmUiItem* uiItem, bool doExpand) const ;
|
||||
|
||||
// QModelIndex access
|
||||
|
||||
@@ -316,9 +316,36 @@ PdmChildArrayFieldHandle* PdmUiTreeViewEditor::currentChildArrayFieldHandle()
|
||||
void PdmUiTreeViewEditor::selectAsCurrentItem(const PdmUiItem* uiItem)
|
||||
{
|
||||
QModelIndex index = m_treeViewModel->findModelIndex(uiItem);
|
||||
QModelIndex currentIndex = m_treeView->currentIndex();
|
||||
|
||||
m_treeView->clearSelection();
|
||||
|
||||
m_treeView->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeViewEditor::selectItems(std::vector<const PdmUiItem*> uiItems)
|
||||
{
|
||||
m_treeView->clearSelection();
|
||||
|
||||
if (uiItems.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex index = findModelIndex(uiItems.back());
|
||||
m_treeView->setCurrentIndex(index);
|
||||
|
||||
for (const PdmUiItem* uiItem : uiItems)
|
||||
{
|
||||
QModelIndex itemIndex = findModelIndex(uiItem);
|
||||
m_treeView->selectionModel()->select(itemIndex, QItemSelectionModel::Select);
|
||||
}
|
||||
m_treeView->setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -391,7 +418,6 @@ void PdmUiTreeViewEditor::updateSelectionManager()
|
||||
{
|
||||
std::vector<PdmUiItem*> items;
|
||||
this->selectedUiItems(items);
|
||||
|
||||
SelectionManager::instance()->setSelectedItems(items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public:
|
||||
bool isTreeItemEditWidgetActive() const;
|
||||
|
||||
void selectAsCurrentItem(const PdmUiItem* uiItem);
|
||||
void selectItems(std::vector<const PdmUiItem*> uiItems);
|
||||
void selectedUiItems(std::vector<PdmUiItem*>& objects);
|
||||
void setExpanded(const PdmUiItem* uiItem, bool doExpand) const;
|
||||
|
||||
|
||||
@@ -79,18 +79,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
|
||||
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled())
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
this->pickAndSetPointOfInterest(me->x(), me->y());
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_roationSensitivityCalculator.init(me);
|
||||
|
||||
@@ -81,18 +81,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
|
||||
if (me->button() == Qt::RightButton && isRotationEnabled())
|
||||
{
|
||||
cvf::HitItemCollection hic;
|
||||
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
this->pickAndSetPointOfInterest(me->x(), me->y());
|
||||
|
||||
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
|
||||
m_roationSensitivityCalculator.init(me);
|
||||
|
||||
@@ -157,21 +157,22 @@ void caf::TrackBallBasedNavigation::setPointOfInterest(cvf::Vec3d poi)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(int zoomX, int zoomY)
|
||||
void caf::TrackBallBasedNavigation::pickAndSetPointOfInterest(int winPosX, int winPosY)
|
||||
{
|
||||
bool hitSomething = false;
|
||||
cvf::HitItemCollection hic;
|
||||
if (shouldRaytraceForNewPoiDuringWheelZoom(zoomX, zoomY))
|
||||
{
|
||||
hitSomething = m_viewer->rayPick(zoomX, zoomY, &hic);
|
||||
updateWheelZoomPosition(zoomX, zoomY);
|
||||
}
|
||||
bool hitSomething = m_viewer->rayPick( winPosX, winPosY, &hic);
|
||||
|
||||
if (hitSomething)
|
||||
{
|
||||
{
|
||||
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
|
||||
|
||||
if (m_viewer->isMousePosWithinComparisonView( winPosX, winPosY ))
|
||||
{
|
||||
pointOfInterest -= m_viewer->comparisonViewEyePointOffset();
|
||||
}
|
||||
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
else
|
||||
@@ -180,6 +181,22 @@ void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(i
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updatePointOfInterestDuringZoomIfNecessary(int winPosX, int winPosY)
|
||||
{
|
||||
if (shouldRaytraceForNewPoiDuringWheelZoom(winPosX, winPosY))
|
||||
{
|
||||
this->pickAndSetPointOfInterest(winPosX, winPosY);
|
||||
updateWheelZoomPosition(winPosX, winPosY);
|
||||
}
|
||||
else
|
||||
{
|
||||
initializeRotationCenter();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -271,24 +288,24 @@ cvf::ref<cvf::Ray> caf::TrackBallBasedNavigation::createZoomRay(int cvfXPos, int
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::TrackBallBasedNavigation::updateWheelZoomPosition(int zoomX, int zoomY)
|
||||
void caf::TrackBallBasedNavigation::updateWheelZoomPosition(int winPosX, int winPosY)
|
||||
{
|
||||
m_lastWheelZoomPosX = zoomX;
|
||||
m_lastWheelZoomPosY = zoomY;
|
||||
m_lastWheelZoomPosX = winPosX;
|
||||
m_lastWheelZoomPosY = winPosY;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::TrackBallBasedNavigation::shouldRaytraceForNewPoiDuringWheelZoom(int zoomX, int zoomY) const
|
||||
bool caf::TrackBallBasedNavigation::shouldRaytraceForNewPoiDuringWheelZoom(int winPosX, int winPosY) const
|
||||
{
|
||||
// Raytrace if the last zoom position isn't set
|
||||
if (m_lastWheelZoomPosX == -1 || m_lastWheelZoomPosY == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int diffX = zoomX - m_lastWheelZoomPosX;
|
||||
int diffY = zoomY - m_lastWheelZoomPosY;
|
||||
int diffX = winPosX - m_lastWheelZoomPosX;
|
||||
int diffY = winPosY - m_lastWheelZoomPosY;
|
||||
|
||||
const int pixelThreshold = 5;
|
||||
if (diffX * diffX + diffY * diffY > pixelThreshold * pixelThreshold)
|
||||
|
||||
@@ -107,7 +107,8 @@ protected:
|
||||
void setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ) override;
|
||||
cvf::Vec3d pointOfInterest() override;
|
||||
void setPointOfInterest(cvf::Vec3d poi) override;
|
||||
void updatePointOfInterestDuringZoomIfNecessary(int zoomX, int zoomY);
|
||||
void pickAndSetPointOfInterest(int winPosX, int winPosY);
|
||||
void updatePointOfInterestDuringZoomIfNecessary(int winPosX, int winPosY);
|
||||
void forcePointOfInterestUpdateDuringNextWheelZoom();
|
||||
|
||||
// Track ball navigation specific
|
||||
@@ -134,8 +135,8 @@ protected:
|
||||
bool isRotationEnabled() { return m_isRotationEnabled; }
|
||||
|
||||
private:
|
||||
void updateWheelZoomPosition(int zoomX, int zoomY);
|
||||
bool shouldRaytraceForNewPoiDuringWheelZoom(int zoomX, int zoomY) const;
|
||||
void updateWheelZoomPosition(int winPosX, int winPosY);
|
||||
bool shouldRaytraceForNewPoiDuringWheelZoom(int winPosX, int winPosY) const;
|
||||
|
||||
private:
|
||||
bool m_consumeEvents;
|
||||
|
||||
@@ -131,7 +131,8 @@ caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent)
|
||||
m_offscreenViewportHeight(0),
|
||||
m_parallelProjectionLightDirection(0, 0, -1), // Light directly from behind
|
||||
m_comparisonViewOffset(0, 0, 0),
|
||||
m_comparisonWindowNormalizedRect(0.5f, 0.0f, 0.5f, 1.0f)
|
||||
m_comparisonWindowNormalizedRect(0.5f, 0.0f, 0.5f, 1.0f),
|
||||
m_isComparisonFollowingAnimation(true)
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
m_layoutWidget = new QWidget(parent);
|
||||
@@ -474,6 +475,7 @@ void caf::Viewer::optimizeClippingPlanes()
|
||||
camEye += m_comparisonViewOffset;
|
||||
camViewRefPoint += m_comparisonViewOffset;
|
||||
m_comparisonMainCamera->setFromLookAt(camEye, camViewRefPoint, camUp);
|
||||
navPointOfinterest += m_comparisonViewOffset;
|
||||
|
||||
if ( calculateNearFarPlanes(m_comparisonMainRendering.p(), navPointOfinterest, &farPlaneDist, &nearPlaneDist) )
|
||||
{
|
||||
@@ -650,10 +652,14 @@ bool caf::Viewer::rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pick
|
||||
int translatedMousePosX = winPosX;
|
||||
int translatedMousePosY = height() - winPosY;
|
||||
|
||||
cvf::ref<cvf::RayIntersectSpec> ris = m_mainRendering->rayIntersectSpecFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
bool mousePosIsWithinComparisonView = isMousePosWithinComparisonView(winPosX, winPosY);
|
||||
|
||||
cvf::Rendering* renderingToInvestigate = mousePosIsWithinComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
||||
|
||||
cvf::ref<cvf::RayIntersectSpec> ris = renderingToInvestigate->rayIntersectSpecFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
if (ris.notNull())
|
||||
{
|
||||
bool retVal = m_mainRendering->rayIntersect(*ris, pickedPoints);
|
||||
bool retVal = renderingToInvestigate->rayIntersect(*ris, pickedPoints);
|
||||
if (retVal && globalRayOrigin)
|
||||
{
|
||||
CVF_ASSERT(ris->ray() != nullptr);
|
||||
@@ -665,8 +671,35 @@ bool caf::Viewer::rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pick
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::Viewer::isMousePosWithinComparisonView(int winPosX, int winPosY)
|
||||
{
|
||||
bool mousePosIsWithinComparisonView = false;
|
||||
|
||||
int translatedMousePosX = winPosX;
|
||||
int translatedMousePosY = height() - winPosY;
|
||||
|
||||
if ( m_comparisonMainRendering.notNull() && m_comparisonMainRendering->scene() )
|
||||
{
|
||||
if ( cvf::RenderingScissor* sciss = m_comparisonMainRendering->renderingScissor() )
|
||||
{
|
||||
cvf::Recti scissorRect(sciss->x(), sciss->y(), sciss->width(), sciss->height());
|
||||
if ( scissorRect.contains(cvf::Vec2i(translatedMousePosX, translatedMousePosY)) )
|
||||
{
|
||||
mousePosIsWithinComparisonView = true;
|
||||
}
|
||||
}
|
||||
else // Whole screen is covered
|
||||
{
|
||||
mousePosIsWithinComparisonView = true;
|
||||
}
|
||||
}
|
||||
|
||||
return mousePosIsWithinComparisonView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -933,6 +966,40 @@ bool caf::Viewer::isAnimationActive()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::Viewer::setCurrentComparisonFrame(int frameIndex)
|
||||
{
|
||||
if (m_frameScenes.size() == 0) return;
|
||||
|
||||
int clampedFrameIndex = clampFrameIndex(frameIndex);
|
||||
|
||||
if (m_releaseOGLResourcesEachFrame)
|
||||
{
|
||||
releaseOGlResourcesForCurrentFrame();
|
||||
}
|
||||
|
||||
if ( m_comparisonFrameScenes.size() > clampedFrameIndex && m_comparisonFrameScenes.at(clampedFrameIndex) != nullptr )
|
||||
{
|
||||
m_comparisonMainRendering->setScene(m_comparisonFrameScenes.at(clampedFrameIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comparisonMainRendering->setScene(nullptr);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::Viewer::setComparisonViewToFollowAnimation(bool isToFollow)
|
||||
{
|
||||
m_isComparisonFollowingAnimation = isToFollow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -957,14 +1024,19 @@ void caf::Viewer::slotSetCurrentFrame(int frameIndex)
|
||||
{
|
||||
m_mainRendering->setScene(nullptr);
|
||||
}
|
||||
if (m_comparisonFrameScenes.size() > clampedFrameIndex && m_comparisonFrameScenes.at(clampedFrameIndex) != nullptr )
|
||||
|
||||
if ( m_isComparisonFollowingAnimation )
|
||||
{
|
||||
m_comparisonMainRendering->setScene(m_comparisonFrameScenes.at(clampedFrameIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comparisonMainRendering->setScene(nullptr);
|
||||
if ( m_comparisonFrameScenes.size() > clampedFrameIndex && m_comparisonFrameScenes.at(clampedFrameIndex) != nullptr )
|
||||
{
|
||||
m_comparisonMainRendering->setScene(m_comparisonFrameScenes.at(clampedFrameIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comparisonMainRendering->setScene(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,8 @@ public:
|
||||
bool canRender() const;
|
||||
|
||||
bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints, cvf::Vec3d* rayGlobalOrigin = nullptr) ;
|
||||
bool isMousePosWithinComparisonView(int winPosX, int winPosY);
|
||||
|
||||
cvf::OverlayItem* overlayItem(int winPosX, int winPosY);
|
||||
|
||||
// QPainter based drawing on top of the OpenGL graphics
|
||||
@@ -172,6 +174,9 @@ public:
|
||||
|
||||
static void copyCameraView(cvf::Camera* srcCamera, cvf::Camera* dstCamera);
|
||||
|
||||
void setCurrentComparisonFrame(int frameIndex);
|
||||
void setComparisonViewToFollowAnimation(bool isToFollow);
|
||||
|
||||
public slots:
|
||||
virtual void slotSetCurrentFrame(int frameIndex);
|
||||
virtual void slotEndAnimation();
|
||||
@@ -255,6 +260,7 @@ private:
|
||||
cvf::ref<cvf::Scene> m_comparisonMainScene;
|
||||
cvf::Collection<cvf::Scene> m_comparisonFrameScenes;
|
||||
cvf::Collection<cvf::Model> m_comparisonStaticModels;
|
||||
bool m_isComparisonFollowingAnimation;
|
||||
|
||||
cvf::Vec3d m_comparisonViewOffset;
|
||||
cvf::ref<cvf::RenderingScissor> m_comparisonRenderingScissor;
|
||||
|
||||
Reference in New Issue
Block a user