mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3757 Add selection of text annotations by picking
This commit is contained in:
parent
e984b06ea6
commit
a13201e42e
@ -1,7 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2015- Statoil ASA
|
// Copyright (C) 2018- equinor ASA
|
||||||
// Copyright (C) 2015- Ceetron Solutions AS
|
|
||||||
//
|
//
|
||||||
// ResInsight is free software: you can redistribute it and/or modify
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@ -19,15 +18,13 @@
|
|||||||
|
|
||||||
#include "RivTextAnnotationSourceInfo.h"
|
#include "RivTextAnnotationSourceInfo.h"
|
||||||
|
|
||||||
#include "RimEclipseView.h"
|
|
||||||
#include "RimAnnotationInViewCollection.h"
|
|
||||||
#include "RimTextAnnotation.h"
|
#include "RimTextAnnotation.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RivTextAnnotationSourceInfo::RivTextAnnotationSourceInfo(RimTextAnnotation* annotation)
|
RivTextAnnotationSourceInfo::RivTextAnnotationSourceInfo(RimTextAnnotation* annotation)
|
||||||
: m_annotation(annotation)
|
: RivObjectSourceInfo(annotation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,5 +33,5 @@ RivTextAnnotationSourceInfo::RivTextAnnotationSourceInfo(RimTextAnnotation* anno
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimTextAnnotation* RivTextAnnotationSourceInfo::annotation() const
|
RimTextAnnotation* RivTextAnnotationSourceInfo::annotation() const
|
||||||
{
|
{
|
||||||
return m_annotation.p();
|
return dynamic_cast<RimTextAnnotation*>( this->object() );
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2015- Statoil ASA
|
// Copyright (C) 2018- equinor ASA
|
||||||
// Copyright (C) 2015- Ceetron Solutions AS
|
|
||||||
//
|
//
|
||||||
// ResInsight is free software: you can redistribute it and/or modify
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@ -19,14 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cvfBase.h"
|
#include "RivObjectSourceInfo.h"
|
||||||
#include "cvfObject.h"
|
|
||||||
#include "cafPdmPointer.h"
|
|
||||||
|
|
||||||
//class RimAnnotationInView;
|
|
||||||
class RimTextAnnotation;
|
class RimTextAnnotation;
|
||||||
|
|
||||||
class RivTextAnnotationSourceInfo : public cvf::Object
|
class RivTextAnnotationSourceInfo : public RivObjectSourceInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RivTextAnnotationSourceInfo(RimTextAnnotation* annotation);
|
RivTextAnnotationSourceInfo(RimTextAnnotation* annotation);
|
||||||
|
@ -100,6 +100,11 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include "cvfScene.h"
|
||||||
|
#include "RivPartPriority.h"
|
||||||
|
#include "cvfDrawableText.h"
|
||||||
|
#include "cvfRay.h"
|
||||||
|
#include "RimTextAnnotation.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +116,6 @@
|
|||||||
RicPickEventHandler* RiuViewerCommands::sm_overridingPickHandler = nullptr;
|
RicPickEventHandler* RiuViewerCommands::sm_overridingPickHandler = nullptr;
|
||||||
|
|
||||||
std::vector<RicDefaultPickEventHandler*> RiuViewerCommands::sm_defaultPickEventHandlers;
|
std::vector<RicDefaultPickEventHandler*> RiuViewerCommands::sm_defaultPickEventHandlers;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -522,12 +526,14 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
|||||||
std::vector<RiuPickItemInfo> pickItemInfos;
|
std::vector<RiuPickItemInfo> pickItemInfos;
|
||||||
{
|
{
|
||||||
cvf::HitItemCollection hitItems;
|
cvf::HitItemCollection hitItems;
|
||||||
if ( m_viewer->rayPick(winPosX, winPosY, &hitItems) )
|
m_viewer->rayPick(winPosX, winPosY, &hitItems);
|
||||||
|
|
||||||
|
// Do specialized text pick, since vizfwk does not hit text
|
||||||
|
handleTextPicking(winPosX, winPosY, &hitItems);
|
||||||
|
|
||||||
|
if ( hitItems.count() )
|
||||||
{
|
{
|
||||||
if ( hitItems.count() )
|
pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
|
||||||
{
|
|
||||||
pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,54 +626,62 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
|||||||
if (rivObjectSourceInfo)
|
if (rivObjectSourceInfo)
|
||||||
{
|
{
|
||||||
RimFracture* fracture = dynamic_cast<RimFracture*>(rivObjectSourceInfo->object());
|
RimFracture* fracture = dynamic_cast<RimFracture*>(rivObjectSourceInfo->object());
|
||||||
|
if ( fracture )
|
||||||
{
|
{
|
||||||
bool blockSelectionOfFracture = false;
|
|
||||||
if (fracture)
|
|
||||||
{
|
{
|
||||||
std::vector<caf::PdmUiItem*> uiItems;
|
bool blockSelectionOfFracture = false;
|
||||||
RiuMainWindow::instance()->projectTreeView()->selectedUiItems(uiItems);
|
|
||||||
|
|
||||||
if (uiItems.size() == 1)
|
|
||||||
{
|
{
|
||||||
auto selectedFractureTemplate = dynamic_cast<RimFractureTemplate*>(uiItems[0]);
|
std::vector<caf::PdmUiItem*> uiItems;
|
||||||
|
RiuMainWindow::instance()->projectTreeView()->selectedUiItems(uiItems);
|
||||||
|
|
||||||
if (selectedFractureTemplate != nullptr && selectedFractureTemplate == fracture->fractureTemplate())
|
if ( uiItems.size() == 1 )
|
||||||
{
|
{
|
||||||
blockSelectionOfFracture = true;
|
auto selectedFractureTemplate = dynamic_cast<RimFractureTemplate*>(uiItems[0]);
|
||||||
|
|
||||||
|
if ( selectedFractureTemplate != nullptr && selectedFractureTemplate == fracture->fractureTemplate() )
|
||||||
|
{
|
||||||
|
blockSelectionOfFracture = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !blockSelectionOfFracture )
|
||||||
|
{
|
||||||
|
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blockSelectionOfFracture)
|
|
||||||
|
RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast<RimStimPlanFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
|
||||||
|
RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast<RimEllipseFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
|
||||||
|
if ( stimPlanTempl || ellipseTempl )
|
||||||
{
|
{
|
||||||
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
// Set fracture resultInfo text
|
||||||
|
QString resultInfoText;
|
||||||
|
|
||||||
|
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
|
||||||
|
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(globalIntersectionPoint);
|
||||||
|
|
||||||
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||||
|
RivWellFracturePartMgr* partMgr = fracture->fracturePartManager();
|
||||||
|
if ( eclView ) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord);
|
||||||
|
|
||||||
|
// Set intersection point result text
|
||||||
|
QString intersectionPointText;
|
||||||
|
|
||||||
|
intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
|
||||||
|
resultInfoText.append(intersectionPointText);
|
||||||
|
|
||||||
|
// Display result info text
|
||||||
|
RiuMainWindow::instance()->setResultInfo(resultInfoText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RimTextAnnotation* textAnnot = dynamic_cast<RimTextAnnotation*>(rivObjectSourceInfo->object());
|
||||||
RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast<RimStimPlanFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
|
if (textAnnot)
|
||||||
RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast<RimEllipseFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
|
|
||||||
if (stimPlanTempl || ellipseTempl)
|
|
||||||
{
|
{
|
||||||
// Set fracture resultInfo text
|
RiuMainWindow::instance()->selectAsCurrentItem(textAnnot, true);
|
||||||
QString resultInfoText;
|
|
||||||
|
|
||||||
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
|
|
||||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(globalIntersectionPoint);
|
|
||||||
|
|
||||||
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
|
||||||
RivWellFracturePartMgr* partMgr = fracture->fracturePartManager();
|
|
||||||
if (eclView) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord);
|
|
||||||
|
|
||||||
// Set intersection point result text
|
|
||||||
QString intersectionPointText;
|
|
||||||
|
|
||||||
intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
|
|
||||||
resultInfoText.append(intersectionPointText);
|
|
||||||
|
|
||||||
// Display result info text
|
|
||||||
RiuMainWindow::instance()->setResultInfo(resultInfoText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,3 +1138,41 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuViewerCommands::handleTextPicking(int winPosX, int winPosY, cvf::HitItemCollection* hitItems)
|
||||||
|
{
|
||||||
|
using namespace cvf;
|
||||||
|
|
||||||
|
int translatedMousePosX = winPosX;
|
||||||
|
int translatedMousePosY = m_viewer->height() - winPosY;
|
||||||
|
|
||||||
|
Scene* scene = m_viewer->currentScene();
|
||||||
|
Collection<Part> partCollection;
|
||||||
|
scene->allParts(&partCollection);
|
||||||
|
|
||||||
|
ref<Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||||
|
|
||||||
|
for (size_t pIdx = 0; pIdx < partCollection.size(); ++pIdx)
|
||||||
|
{
|
||||||
|
if (partCollection[pIdx]->priority() == RivPartPriority::PartType::Text) // Just trying to avoid dyncasting all drawables
|
||||||
|
{
|
||||||
|
DrawableText* textDrawable = dynamic_cast<DrawableText*> (partCollection[pIdx]->drawable());
|
||||||
|
if (textDrawable)
|
||||||
|
{
|
||||||
|
cvf::Vec3d ppoint;
|
||||||
|
if (textDrawable->rayIntersect(*ray, *( m_viewer->mainCamera()), &ppoint))
|
||||||
|
{
|
||||||
|
cvf::ref<HitItem> hitItem = new HitItem(0, ppoint);
|
||||||
|
hitItem->setPart(partCollection[pIdx].p());
|
||||||
|
hitItems->add(hitItem.p());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hitItems->sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -89,4 +89,5 @@ private:
|
|||||||
|
|
||||||
static RicPickEventHandler* sm_overridingPickHandler;
|
static RicPickEventHandler* sm_overridingPickHandler;
|
||||||
static std::vector<RicDefaultPickEventHandler*> sm_defaultPickEventHandlers;
|
static std::vector<RicDefaultPickEventHandler*> sm_defaultPickEventHandlers;
|
||||||
|
void handleTextPicking(int winPosX, int winPosY, cvf::HitItemCollection* hitItems);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user