mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Rename ApplicationCode to ApplicationLibCode
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicToggleWellPathGrouping.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAutomaticWellPathGrouping.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateWellTargetsPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPolylineTargetsPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellPathGeometry3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicToggleWellPathGrouping.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAutomaticWellPathGrouping.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateWellTargetsPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPolylineTargetsPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellPathGeometry3dEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_QT_MOC_HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellPathGeometry3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
|
||||
)
|
||||
|
||||
source_group( "CommandFeature\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
||||
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Ric3dObjectEditorHandle.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dView* Ric3dObjectEditorHandle::mainOrComparisonView()
|
||||
{
|
||||
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if ( !viewer ) return nullptr;
|
||||
|
||||
if ( isInComparisonView() )
|
||||
{
|
||||
if ( viewer->currentScene( isInComparisonView() ) )
|
||||
{
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>( viewer->ownerReservoirView() );
|
||||
|
||||
if ( view )
|
||||
{
|
||||
return view->activeComparisonView();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dynamic_cast<Rim3dView*>( viewer->ownerReservoirView() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUi3dObjectEditorHandle.h"
|
||||
|
||||
class Rim3dView;
|
||||
|
||||
class Ric3dObjectEditorHandle : public caf::PdmUi3dObjectEditorHandle
|
||||
{
|
||||
protected:
|
||||
Rim3dView* mainOrComparisonView();
|
||||
};
|
||||
@@ -0,0 +1,161 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2013- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "RicPointTangentManipulatorPartMgr.h"
|
||||
#include "RivPartPriority.h"
|
||||
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafViewer.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfHitItemCollection.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cvfRayIntersectSpec.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulator::RicPointTangentManipulator( caf::Viewer* viewer )
|
||||
: m_viewer( viewer )
|
||||
{
|
||||
m_partManager = new RicPointTangentManipulatorPartMgr;
|
||||
|
||||
m_viewer->installEventFilter( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulator::~RicPointTangentManipulator()
|
||||
{
|
||||
if ( m_viewer ) m_viewer->removeEventFilter( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setOrigin( const cvf::Vec3d& origin )
|
||||
{
|
||||
m_partManager->setOrigin( origin );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setTangent( const cvf::Vec3d& tangent )
|
||||
{
|
||||
m_partManager->setTangent( tangent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setHandleSize( double handleSize )
|
||||
{
|
||||
m_partManager->setHandleSize( handleSize );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
m_partManager->appendPartsToModel( model );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
|
||||
{
|
||||
if ( inputEvent->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
||||
|
||||
if ( mouseEvent->button() == Qt::LeftButton )
|
||||
{
|
||||
cvf::HitItemCollection hitItems;
|
||||
if ( m_viewer->rayPick( mouseEvent->x(), mouseEvent->y(), &hitItems ) )
|
||||
{
|
||||
m_partManager->tryToActivateManipulator( hitItems.firstItem() );
|
||||
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
m_isDraggingInComparisonView =
|
||||
m_viewer->isMousePosWithinComparisonView( mouseEvent->x(), mouseEvent->y() );
|
||||
|
||||
emit notifySelected();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( inputEvent->type() == QEvent::MouseMove )
|
||||
{
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
||||
|
||||
cvf::ref<cvf::RayIntersectSpec> rayIs =
|
||||
m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(),
|
||||
mouseEvent->pos().y(),
|
||||
m_isDraggingInComparisonView );
|
||||
|
||||
if ( !rayIs.isNull() && rayIs->ray() )
|
||||
{
|
||||
m_partManager->updateManipulatorFromRay( rayIs->ray() );
|
||||
|
||||
cvf::Vec3d origin;
|
||||
cvf::Vec3d tangent;
|
||||
m_partManager->originAndTangent( &origin, &tangent );
|
||||
|
||||
emit notifyUpdate( origin, tangent );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( inputEvent->type() == QEvent::MouseButtonRelease )
|
||||
{
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
m_partManager->endManipulator();
|
||||
|
||||
cvf::Vec3d origin;
|
||||
cvf::Vec3d tangent;
|
||||
m_partManager->originAndTangent( &origin, &tangent );
|
||||
|
||||
emit notifyUpdate( origin, tangent );
|
||||
emit notifyDragFinished();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Model;
|
||||
class ModelBasicList;
|
||||
}; // namespace cvf
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class Viewer;
|
||||
};
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
class RicPointTangentManipulatorPartMgr;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicPointTangentManipulator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RicPointTangentManipulator( caf::Viewer* viewer );
|
||||
~RicPointTangentManipulator() override;
|
||||
|
||||
void setOrigin( const cvf::Vec3d& origin );
|
||||
void setTangent( const cvf::Vec3d& tangent );
|
||||
void setHandleSize( double handleSize );
|
||||
|
||||
void appendPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
signals:
|
||||
void notifySelected();
|
||||
void notifyDragFinished();
|
||||
void notifyUpdate( const cvf::Vec3d& origin, const cvf::Vec3d& tangent );
|
||||
|
||||
protected:
|
||||
bool eventFilter( QObject* obj, QEvent* event ) override;
|
||||
|
||||
private:
|
||||
QPointer<caf::Viewer> m_viewer;
|
||||
bool m_isDraggingInComparisonView = false;
|
||||
|
||||
cvf::ref<RicPointTangentManipulatorPartMgr> m_partManager;
|
||||
};
|
||||
@@ -0,0 +1,476 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicPointTangentManipulatorPartMgr.h"
|
||||
|
||||
#include "RivPartPriority.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafLine.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfBoxGenerator.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfGeometryBuilderFaceList.h"
|
||||
#include "cvfGeometryBuilderTriangles.h"
|
||||
#include "cvfGeometryUtils.h"
|
||||
#include "cvfHitItem.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPlane.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRay.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr()
|
||||
: m_tangentOnStartManipulation( cvf::Vec3d::UNDEFINED )
|
||||
, m_originOnStartManipulation( cvf::Vec3d::UNDEFINED )
|
||||
, m_activeHandle( NONE )
|
||||
, m_handleSize( 1.0 )
|
||||
, m_isGeometryUpdateNeeded( true )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulatorPartMgr::~RicPointTangentManipulatorPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setOrigin( const cvf::Vec3d& origin )
|
||||
{
|
||||
if ( isManipulatorActive() ) return;
|
||||
|
||||
m_origin = origin;
|
||||
if ( m_originOnStartManipulation.isUndefined() ) m_originOnStartManipulation = origin;
|
||||
|
||||
m_isGeometryUpdateNeeded = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setTangent( const cvf::Vec3d& tangent )
|
||||
{
|
||||
if ( isManipulatorActive() ) return;
|
||||
|
||||
m_tangent = tangent;
|
||||
if ( m_tangentOnStartManipulation.isUndefined() ) m_tangentOnStartManipulation = m_tangent;
|
||||
|
||||
m_isGeometryUpdateNeeded = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setHandleSize( double handleSize )
|
||||
{
|
||||
m_handleSize = handleSize;
|
||||
|
||||
m_isGeometryUpdateNeeded = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::originAndTangent( cvf::Vec3d* origin, cvf::Vec3d* tangent )
|
||||
{
|
||||
*origin = m_origin;
|
||||
*tangent = m_tangent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPointTangentManipulatorPartMgr::isManipulatorActive() const
|
||||
{
|
||||
return m_activeHandle != NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
if ( m_handleParts.empty() )
|
||||
{
|
||||
recreateAllGeometryAndParts();
|
||||
}
|
||||
|
||||
if ( m_isGeometryUpdateNeeded )
|
||||
{
|
||||
createGeometryOnly();
|
||||
}
|
||||
|
||||
for ( auto& idPartIt : m_handleParts )
|
||||
{
|
||||
model->addPart( idPartIt.second.p() );
|
||||
}
|
||||
|
||||
for ( auto activeModePart : m_activeDragModeParts )
|
||||
{
|
||||
model->addPart( activeModePart.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::tryToActivateManipulator( const cvf::HitItem* hitItem )
|
||||
{
|
||||
endManipulator();
|
||||
|
||||
if ( !hitItem ) return;
|
||||
|
||||
const cvf::Part* pickedPart = hitItem->part();
|
||||
const cvf::Vec3d intersectionPoint = hitItem->intersectionPoint();
|
||||
|
||||
if ( !pickedPart ) return;
|
||||
|
||||
for ( auto& idPartIt : m_handleParts )
|
||||
{
|
||||
if ( pickedPart == idPartIt.second.p() )
|
||||
{
|
||||
m_initialPickPoint = intersectionPoint;
|
||||
m_tangentOnStartManipulation = m_tangent;
|
||||
m_originOnStartManipulation = m_origin;
|
||||
m_activeHandle = idPartIt.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculate new origin and tangent based on the new ray position
|
||||
/// Clear geometry to trigger regeneration
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray* newMouseRay )
|
||||
{
|
||||
if ( !isManipulatorActive() ) return;
|
||||
|
||||
if ( m_activeHandle == HORIZONTAL_PLANE )
|
||||
{
|
||||
cvf::Plane plane;
|
||||
plane.setFromPointAndNormal( m_origin, cvf::Vec3d::Z_AXIS );
|
||||
cvf::Vec3d newIntersection;
|
||||
newMouseRay->planeIntersect( plane, &newIntersection );
|
||||
|
||||
cvf::Vec3d newOrigin = m_originOnStartManipulation + ( newIntersection - m_initialPickPoint );
|
||||
|
||||
m_origin = newOrigin;
|
||||
}
|
||||
else if ( m_activeHandle == VERTICAL_AXIS )
|
||||
{
|
||||
cvf::Plane plane;
|
||||
cvf::Vec3d planeNormal = ( newMouseRay->direction() ^ cvf::Vec3d::Z_AXIS ) ^ cvf::Vec3d::Z_AXIS;
|
||||
double length = planeNormal.length();
|
||||
|
||||
if ( length < 1e-5 ) return;
|
||||
|
||||
planeNormal /= length;
|
||||
plane.setFromPointAndNormal( m_initialPickPoint, planeNormal );
|
||||
cvf::Vec3d newIntersection;
|
||||
newMouseRay->planeIntersect( plane, &newIntersection );
|
||||
|
||||
cvf::Vec3d newOrigin = m_originOnStartManipulation;
|
||||
newOrigin.z() += ( newIntersection.z() - m_initialPickPoint.z() );
|
||||
|
||||
m_origin = newOrigin;
|
||||
}
|
||||
// m_tangent = newTangent;
|
||||
|
||||
m_isGeometryUpdateNeeded = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::endManipulator()
|
||||
{
|
||||
m_activeHandle = NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts()
|
||||
{
|
||||
createHorizontalPlaneHandle();
|
||||
createVerticalAxisHandle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createGeometryOnly()
|
||||
{
|
||||
m_handleParts[HORIZONTAL_PLANE]->setDrawable( createHorizontalPlaneGeo().p() );
|
||||
m_handleParts[VERTICAL_AXIS]->setDrawable( createVerticalAxisGeo().p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle()
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
ref<cvf::DrawableGeo> geo = createHorizontalPlaneGeo();
|
||||
|
||||
HandleType handleId = HORIZONTAL_PLANE;
|
||||
cvf::Color4f color = cvf::Color4f( 1.0f, 0.0f, 1.0f, 0.7f );
|
||||
cvf::String partName( "PointTangentManipulator Horizontal Plane Handle" );
|
||||
|
||||
addHandlePart( geo.p(), color, handleId, partName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createHorizontalPlaneGeo()
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray( 16 );
|
||||
cvf::ref<cvf::Vec3fArray> triangleVertexArray = new cvf::Vec3fArray( 16 * 3 );
|
||||
|
||||
float cos_pi_12 = cvf::Math::cos( 0.5 * cvf::PI_F / 12 );
|
||||
float sin_pi_12 = cvf::Math::sin( 0.5 * cvf::PI_F / 12 );
|
||||
float cos_3pi_12 = cvf::Math::cos( 3 * cvf::PI_F / 12 );
|
||||
float sin_3pi_12 = cvf::Math::sin( 3 * cvf::PI_F / 12 );
|
||||
float cos_5pi_12 = cvf::Math::cos( 5.5 * cvf::PI_F / 12 );
|
||||
float sin_5pi_12 = cvf::Math::sin( 5.5 * cvf::PI_F / 12 );
|
||||
|
||||
vertexArray->set( 0, { 1.25, 0, 0 } );
|
||||
vertexArray->set( 1, { cos_pi_12, sin_pi_12, 0 } );
|
||||
vertexArray->set( 2, { cos_3pi_12, sin_3pi_12, 0 } );
|
||||
vertexArray->set( 3, { cos_5pi_12, sin_5pi_12, 0 } );
|
||||
vertexArray->set( 4, { 0, 1.25, 0 } );
|
||||
vertexArray->set( 5, { -cos_5pi_12, sin_5pi_12, 0 } );
|
||||
vertexArray->set( 6, { -cos_3pi_12, sin_3pi_12, 0 } );
|
||||
vertexArray->set( 7, { -cos_pi_12, sin_pi_12, 0 } );
|
||||
vertexArray->set( 8, { -1.25, 0, 0 } );
|
||||
vertexArray->set( 9, { -cos_pi_12, -sin_pi_12, 0 } );
|
||||
vertexArray->set( 10, { -cos_3pi_12, -sin_3pi_12, 0 } );
|
||||
vertexArray->set( 11, { -cos_5pi_12, -sin_5pi_12, 0 } );
|
||||
vertexArray->set( 12, { 0, -1.25, 0 } );
|
||||
vertexArray->set( 13, { cos_5pi_12, -sin_5pi_12, 0 } );
|
||||
vertexArray->set( 14, { cos_3pi_12, -sin_3pi_12, 0 } );
|
||||
vertexArray->set( 15, { cos_pi_12, -sin_pi_12, 0 } );
|
||||
|
||||
Vec3f origin( m_origin );
|
||||
for ( cvf::Vec3f& vx : *vertexArray )
|
||||
{
|
||||
vx *= 0.4 * m_handleSize;
|
||||
vx += origin;
|
||||
}
|
||||
|
||||
unsigned tVxIdx = 0;
|
||||
for ( unsigned vxIdx = 0; vxIdx < vertexArray->size(); ++vxIdx )
|
||||
{
|
||||
cvf::Vec3f vx = ( *vertexArray )[vxIdx];
|
||||
|
||||
unsigned idx2 = vxIdx + 1;
|
||||
if ( idx2 >= vertexArray->size() ) idx2 = 0;
|
||||
|
||||
cvf::Vec3f vx2 = ( *vertexArray )[idx2];
|
||||
|
||||
triangleVertexArray->set( tVxIdx, origin );
|
||||
tVxIdx++;
|
||||
triangleVertexArray->set( tVxIdx, vx );
|
||||
tVxIdx++;
|
||||
triangleVertexArray->set( tVxIdx, vx2 );
|
||||
tVxIdx++;
|
||||
}
|
||||
|
||||
return createTriangelDrawableGeo( triangleVertexArray.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle()
|
||||
{
|
||||
using namespace cvf;
|
||||
cvf::ref<cvf::DrawableGeo> geo = createVerticalAxisGeo();
|
||||
|
||||
HandleType handleId = VERTICAL_AXIS;
|
||||
cvf::Color4f color = cvf::Color4f( 0.0f, 0.7f, 0.8f, 0.7f );
|
||||
cvf::String partName( "PointTangentManipulator Vertical Axis Handle" );
|
||||
|
||||
addHandlePart( geo.p(), color, handleId, partName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createVerticalAxisGeo()
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
cvf::ref<cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles;
|
||||
|
||||
cvf::GeometryUtils::createObliqueCylinder( 0.3f, 0.05f, 1.0f, 0.0f, 0.0, 12, true, true, true, 1, geomBuilder.p() );
|
||||
|
||||
float s = 0.5 * m_handleSize;
|
||||
Vec3f origin( m_origin );
|
||||
|
||||
geomBuilder->transformVertexRange( 0, geomBuilder->vertexCount() - 1, cvf::Mat4f::fromScaling( { s, s, s } ) );
|
||||
geomBuilder->transformVertexRange( 0, geomBuilder->vertexCount() - 1, cvf::Mat4f::fromTranslation( origin ) );
|
||||
|
||||
unsigned vxArraySizeFirstCylinder = geomBuilder->vertexCount();
|
||||
|
||||
cvf::GeometryUtils::createObliqueCylinder( 0.05f, 0.3f, 1.0f, 0.0f, 0.0, 12, true, true, true, 1, geomBuilder.p() );
|
||||
|
||||
geomBuilder->transformVertexRange( vxArraySizeFirstCylinder,
|
||||
geomBuilder->vertexCount() - 1,
|
||||
cvf::Mat4f::fromTranslation( { 0.0f, 0.0f, -1.0f } ) );
|
||||
geomBuilder->transformVertexRange( vxArraySizeFirstCylinder,
|
||||
geomBuilder->vertexCount() - 1,
|
||||
cvf::Mat4f::fromScaling( { s, s, s } ) );
|
||||
geomBuilder->transformVertexRange( vxArraySizeFirstCylinder,
|
||||
geomBuilder->vertexCount() - 1,
|
||||
cvf::Mat4f::fromTranslation( origin ) );
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = geomBuilder->vertices();
|
||||
cvf::ref<cvf::UIntArray> indexArray = geomBuilder->triangles();
|
||||
|
||||
return createIndexedTriangelDrawableGeo( vertexArray.p(), indexArray.p() );
|
||||
}
|
||||
|
||||
#if 0
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createAzimuthHandle()
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
cvf::ref< cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles;
|
||||
cvf::GeometryUtils::createDisc(1.3, 1.1, 16, geomBuilder.p());
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = geomBuilder->vertices();
|
||||
cvf::ref<cvf::UIntArray> indexArray = geomBuilder->triangles();
|
||||
|
||||
Vec3f origin(m_origin);
|
||||
for (cvf::Vec3f& vx: *vertexArray)
|
||||
{
|
||||
vx *= 0.5*m_handleSize;
|
||||
vx += origin;
|
||||
}
|
||||
|
||||
ref<DrawableGeo> geo = createIndexedTriangelDrawableGeo(vertexArray.p(), indexArray.p());
|
||||
|
||||
HandleType handleId = AZIMUTH;
|
||||
cvf::Color4f color = cvf::Color4f(0.0f, 0.2f, 0.8f, 0.5f);
|
||||
cvf::String partName("PointTangentManipulator Azimuth Handle");
|
||||
|
||||
addHandlePart(geo.p(), color, handleId, partName);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RicPointTangentManipulatorPartMgr::createIndexedTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray,
|
||||
cvf::UIntArray* triangleIndices )
|
||||
{
|
||||
using namespace cvf;
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt( PT_TRIANGLES, triangleIndices );
|
||||
|
||||
geo->setVertexArray( triangleVertexArray );
|
||||
geo->addPrimitiveSet( primSet.p() );
|
||||
geo->computeNormals();
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray )
|
||||
{
|
||||
using namespace cvf;
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
|
||||
geo->setVertexArray( triangleVertexArray );
|
||||
ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect( cvf::PT_TRIANGLES );
|
||||
primSet->setIndexCount( triangleVertexArray->size() );
|
||||
|
||||
geo->addPrimitiveSet( primSet.p() );
|
||||
geo->computeNormals();
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::addHandlePart( cvf::DrawableGeo* geo,
|
||||
const cvf::Color4f& color,
|
||||
HandleType handleId,
|
||||
const cvf::String& partName )
|
||||
{
|
||||
cvf::ref<cvf::Part> handlePart = createPart( geo, color, partName );
|
||||
m_handleParts[handleId] = handlePart;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::addActiveModePart( cvf::DrawableGeo* geo,
|
||||
const cvf::Color4f& color,
|
||||
HandleType handleId,
|
||||
const cvf::String& partName )
|
||||
{
|
||||
cvf::ref<cvf::Part> handlePart = createPart( geo, color, partName );
|
||||
|
||||
m_activeDragModeParts.push_back( handlePart.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Part> RicPointTangentManipulatorPartMgr::createPart( cvf::DrawableGeo* geo,
|
||||
const cvf::Color4f& color,
|
||||
const cvf::String& partName )
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName( partName );
|
||||
part->setDrawable( geo );
|
||||
part->updateBoundingBox();
|
||||
|
||||
caf::SurfaceEffectGenerator surfaceGen( color, caf::PO_1 );
|
||||
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
|
||||
part->setEffect( eff.p() );
|
||||
if ( color.a() < 1.0 ) part->setPriority( RivPartPriority::Transparent );
|
||||
|
||||
return part;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cvfCollection.h"
|
||||
#include "cvfColor4.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
class Part;
|
||||
class DrawableGeo;
|
||||
class Ray;
|
||||
class HitItem;
|
||||
class String;
|
||||
|
||||
template <typename>
|
||||
class Array;
|
||||
typedef Array<Vec3f> Vec3fArray;
|
||||
typedef Array<uint> UIntArray;
|
||||
|
||||
} // namespace cvf
|
||||
|
||||
class RicPointTangentManipulatorPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
enum HandleType
|
||||
{
|
||||
HORIZONTAL_PLANE,
|
||||
VERTICAL_AXIS,
|
||||
AZIMUTH,
|
||||
INCLINATION,
|
||||
NONE
|
||||
};
|
||||
|
||||
public:
|
||||
RicPointTangentManipulatorPartMgr();
|
||||
~RicPointTangentManipulatorPartMgr() override;
|
||||
|
||||
void setOrigin( const cvf::Vec3d& origin );
|
||||
void setTangent( const cvf::Vec3d& tangent );
|
||||
void setHandleSize( double handleSize );
|
||||
void originAndTangent( cvf::Vec3d* origin, cvf::Vec3d* tangent );
|
||||
|
||||
bool isManipulatorActive() const;
|
||||
void tryToActivateManipulator( const cvf::HitItem* hitItem );
|
||||
void updateManipulatorFromRay( const cvf::Ray* ray );
|
||||
void endManipulator();
|
||||
|
||||
void appendPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
private:
|
||||
void createGeometryOnly();
|
||||
void recreateAllGeometryAndParts();
|
||||
|
||||
void createHorizontalPlaneHandle();
|
||||
cvf::ref<cvf::DrawableGeo> createHorizontalPlaneGeo();
|
||||
|
||||
void createVerticalAxisHandle();
|
||||
cvf::ref<cvf::DrawableGeo> createVerticalAxisGeo();
|
||||
|
||||
void addHandlePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
|
||||
|
||||
void addActiveModePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
|
||||
|
||||
static cvf::ref<cvf::DrawableGeo> createTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray );
|
||||
static cvf::ref<cvf::DrawableGeo> createIndexedTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray,
|
||||
cvf::UIntArray* triangleIndices );
|
||||
static cvf::ref<cvf::Part> createPart( cvf::DrawableGeo* geo, const cvf::Color4f& color, const cvf::String& partName );
|
||||
|
||||
private:
|
||||
std::map<HandleType, cvf::ref<cvf::Part>> m_handleParts; // These arrays have the same length
|
||||
cvf::Collection<cvf::Part> m_activeDragModeParts;
|
||||
|
||||
cvf::Vec3d m_origin;
|
||||
cvf::Vec3d m_tangent;
|
||||
double m_handleSize;
|
||||
bool m_isGeometryUpdateNeeded;
|
||||
|
||||
HandleType m_activeHandle;
|
||||
cvf::Vec3d m_initialPickPoint;
|
||||
cvf::Vec3d m_tangentOnStartManipulation;
|
||||
cvf::Vec3d m_originOnStartManipulation;
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicPolyline3dEditor.h"
|
||||
|
||||
#include "RicPolylineTarget3dEditor.h"
|
||||
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicPolyline3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolyline3dEditor::RicPolyline3dEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolyline3dEditor::~RicPolyline3dEditor()
|
||||
{
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if ( m_attribute.pickEventHandler != nullptr )
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
auto* geomDef = dynamic_cast<RimUserDefinedPolylinesAnnotation*>( this->pdmObject() );
|
||||
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
m_targetEditors.clear();
|
||||
|
||||
if ( !geomDef ) return;
|
||||
|
||||
geomDef->objectEditorAttribute( "", &m_attribute );
|
||||
if ( m_attribute.pickEventHandler != nullptr )
|
||||
{
|
||||
if ( m_attribute.enablePicking )
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RimPolylineTarget*> targets = geomDef->activeTargets();
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
auto targetEditor = new RicPolylineTarget3dEditor;
|
||||
targetEditor->setViewer( ownerViewer(), isInComparisonView() );
|
||||
targetEditor->setPdmObject( target );
|
||||
m_targetEditors.push_back( targetEditor );
|
||||
targetEditor->updateUi();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUi3dObjectEditorHandle.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PickEventHandler;
|
||||
};
|
||||
|
||||
class RicPolylineTarget3dEditor;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPolyline3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicPolyline3dEditorAttribute()
|
||||
: enablePicking( false )
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool enablePicking;
|
||||
std::shared_ptr<caf::PickEventHandler> pickEventHandler;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPolyline3dEditor : public caf::PdmUi3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
Q_OBJECT
|
||||
public:
|
||||
RicPolyline3dEditor();
|
||||
~RicPolyline3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
|
||||
private:
|
||||
std::vector<RicPolylineTarget3dEditor*> m_targetEditors;
|
||||
RicPolyline3dEditorAttribute m_attribute;
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicPolylineTarget3dEditor.h"
|
||||
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimAnnotationCollectionBase.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicPolylineTarget3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTarget3dEditor::RicPolylineTarget3dEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor()
|
||||
{
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if ( m_cvfModel.notNull() && ownerRiuViewer )
|
||||
{
|
||||
// Could result in some circularities ....
|
||||
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
|
||||
delete m_manipulator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
Rim3dView* view = mainOrComparisonView();
|
||||
|
||||
if ( !target || !target->isEnabled() || !view )
|
||||
{
|
||||
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
target->targetPointUiCapability()->addFieldEditor( this );
|
||||
|
||||
if ( m_manipulator.isNull() )
|
||||
{
|
||||
m_manipulator = new RicPointTangentManipulator( ownerRiuViewer );
|
||||
QObject::connect( m_manipulator,
|
||||
SIGNAL( notifyUpdate( const cvf::Vec3d&, const cvf::Vec3d& ) ),
|
||||
this,
|
||||
SLOT( slotUpdated( const cvf::Vec3d&, const cvf::Vec3d& ) ) );
|
||||
QObject::connect( m_manipulator, SIGNAL( notifySelected() ), this, SLOT( slotSelectedIn3D() ) );
|
||||
QObject::connect( m_manipulator, SIGNAL( notifyDragFinished() ), this, SLOT( slotDragFinished() ) );
|
||||
m_cvfModel = new cvf::ModelBasicList;
|
||||
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
|
||||
double handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
|
||||
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) );
|
||||
// m_manipulator->setTangent(target->tangent());
|
||||
m_manipulator->setHandleSize( handleSize );
|
||||
m_cvfModel->removeAllParts();
|
||||
m_manipulator->appendPartsToModel( m_cvfModel.p() );
|
||||
|
||||
m_cvfModel->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
|
||||
{
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
Rim3dView* view = mainOrComparisonView();
|
||||
|
||||
if ( !target || !view )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
|
||||
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin );
|
||||
domainOrigin.z() = -domainOrigin.z();
|
||||
QVariant originVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( domainOrigin );
|
||||
|
||||
target->enableFullUpdate( false );
|
||||
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( target->targetPointUiCapability(), originVariant );
|
||||
target->enableFullUpdate( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::slotSelectedIn3D()
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::slotDragFinished()
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimAnnotationCollectionBase* annColl;
|
||||
target->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Ric3dObjectEditorHandle.h"
|
||||
|
||||
class RicPointTangentManipulator;
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
class QString;
|
||||
#include <QPointer>
|
||||
|
||||
class RicPolylineTarget3dEditor : public Ric3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
Q_OBJECT
|
||||
public:
|
||||
RicPolylineTarget3dEditor();
|
||||
~RicPolylineTarget3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
void cleanupBeforeSettingPdmObject() override;
|
||||
|
||||
private slots:
|
||||
void slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent );
|
||||
void slotSelectedIn3D();
|
||||
void slotDragFinished();
|
||||
|
||||
private:
|
||||
QPointer<RicPointTangentManipulator> m_manipulator;
|
||||
cvf::ref<cvf::ModelBasicList> m_cvfModel;
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathGeometry3dEditor.h"
|
||||
|
||||
#include "RicWellPathGeometry3dEditor.h"
|
||||
#include "RicWellTarget3dEditor.h"
|
||||
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathLateralGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellPathGeometry3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathGeometry3dEditor::RicWellPathGeometry3dEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathGeometry3dEditor::~RicWellPathGeometry3dEditor()
|
||||
{
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if ( m_attribute.pickEventHandler )
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathGeometry3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimWellPathGeometryDefInterface* geomDef = dynamic_cast<RimWellPathGeometryDefInterface*>( this->pdmObject() );
|
||||
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
m_targetEditors.clear();
|
||||
|
||||
if ( !geomDef ) return;
|
||||
|
||||
geomDef->objectEditorAttribute( "", &m_attribute );
|
||||
|
||||
std::vector<RimWellPathTarget*> targets = geomDef->activeWellTargets();
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
auto targetEditor = new RicWellTarget3dEditor;
|
||||
targetEditor->setViewer( ownerViewer(), isInComparisonView() );
|
||||
targetEditor->setPdmObject( target );
|
||||
m_targetEditors.push_back( targetEditor );
|
||||
targetEditor->updateUi();
|
||||
}
|
||||
|
||||
if ( m_attribute.pickEventHandler )
|
||||
{
|
||||
if ( m_attribute.enablePicking )
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "cafPdmUi3dObjectEditorHandle.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
#include <memory>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PickEventHandler;
|
||||
}
|
||||
|
||||
class RicWellTarget3dEditor;
|
||||
|
||||
class RicWellPathGeometry3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicWellPathGeometry3dEditorAttribute()
|
||||
: enablePicking( false )
|
||||
{
|
||||
}
|
||||
bool enablePicking;
|
||||
std::shared_ptr<caf::PickEventHandler> pickEventHandler;
|
||||
};
|
||||
|
||||
class RicWellPathGeometry3dEditor : public caf::PdmUi3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
Q_OBJECT
|
||||
public:
|
||||
RicWellPathGeometry3dEditor();
|
||||
~RicWellPathGeometry3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
|
||||
private:
|
||||
std::vector<RicWellTarget3dEditor*> m_targetEditors;
|
||||
RicWellPathGeometry3dEditorAttribute m_attribute;
|
||||
};
|
||||
@@ -0,0 +1,194 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellTarget3dEditor.h"
|
||||
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathLateralGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellTarget3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellTarget3dEditor::RicWellTarget3dEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellTarget3dEditor::~RicWellTarget3dEditor()
|
||||
{
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if ( m_cvfModel.notNull() && ownerRiuViewer )
|
||||
{
|
||||
// Could result in some circularities ....
|
||||
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->m_targetType.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_azimuth.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_inclination.uiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
|
||||
delete m_manipulator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
Rim3dView* view = mainOrComparisonView();
|
||||
|
||||
if ( !target || !target->isEnabled() || !view )
|
||||
{
|
||||
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RimWellPathGeometryDefInterface* geomDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted( geomDef );
|
||||
|
||||
target->m_targetType.uiCapability()->addFieldEditor( this );
|
||||
target->m_targetPoint.uiCapability()->addFieldEditor( this );
|
||||
target->m_azimuth.uiCapability()->addFieldEditor( this );
|
||||
target->m_inclination.uiCapability()->addFieldEditor( this );
|
||||
|
||||
if ( m_manipulator.isNull() )
|
||||
{
|
||||
m_manipulator = new RicPointTangentManipulator( ownerRiuViewer );
|
||||
|
||||
QObject::connect( m_manipulator,
|
||||
SIGNAL( notifyUpdate( const cvf::Vec3d&, const cvf::Vec3d& ) ),
|
||||
this,
|
||||
SLOT( slotUpdated( const cvf::Vec3d&, const cvf::Vec3d& ) ) );
|
||||
|
||||
QObject::connect( m_manipulator, SIGNAL( notifySelected() ), this, SLOT( slotSelectedIn3D() ) );
|
||||
QObject::connect( m_manipulator, SIGNAL( notifyDragFinished() ), this, SLOT( slotDragFinished() ) );
|
||||
|
||||
m_cvfModel = new cvf::ModelBasicList;
|
||||
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
|
||||
double handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
|
||||
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->anchorPointXyz() ) );
|
||||
m_manipulator->setTangent( target->tangent() );
|
||||
m_manipulator->setHandleSize( handleSize );
|
||||
|
||||
m_cvfModel->removeAllParts();
|
||||
m_manipulator->appendPartsToModel( m_cvfModel.p() );
|
||||
|
||||
m_cvfModel->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::cleanupBeforeSettingPdmObject()
|
||||
{
|
||||
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->m_targetType.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_azimuth.uiCapability()->removeFieldEditor( this );
|
||||
oldTarget->m_inclination.uiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
Rim3dView* view = mainOrComparisonView();
|
||||
|
||||
if ( !target || !view )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
|
||||
|
||||
RimWellPathGeometryDefInterface* geomDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted( geomDef );
|
||||
|
||||
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin ) - geomDef->anchorPointXyz();
|
||||
domainOrigin.z() = -domainOrigin.z();
|
||||
QVariant originVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( domainOrigin );
|
||||
|
||||
target->enableFullUpdate( false );
|
||||
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( target->m_targetPoint.uiCapability(), originVariant );
|
||||
target->enableFullUpdate( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::slotSelectedIn3D()
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::slotDragFinished()
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
target->onMoved();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Ric3dObjectEditorHandle.h"
|
||||
|
||||
class RicPointTangentManipulator;
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
class QString;
|
||||
#include <QPointer>
|
||||
|
||||
class RicWellTarget3dEditor : public Ric3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
Q_OBJECT
|
||||
public:
|
||||
RicWellTarget3dEditor();
|
||||
~RicWellTarget3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
void cleanupBeforeSettingPdmObject() override;
|
||||
|
||||
private slots:
|
||||
void slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent );
|
||||
void slotSelectedIn3D();
|
||||
void slotDragFinished();
|
||||
|
||||
private:
|
||||
QPointer<RicPointTangentManipulator> m_manipulator;
|
||||
cvf::ref<cvf::ModelBasicList> m_cvfModel;
|
||||
};
|
||||
@@ -0,0 +1,139 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicAutomaticWellPathGrouping.h"
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGroup.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QRegExp>
|
||||
|
||||
RICF_SOURCE_INIT( RicAutomaticWellPathGrouping, "RicAutomaticWellPathGroupingFeature", "autoGroupWellPaths" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicAutomaticWellPathGrouping::RicAutomaticWellPathGrouping()
|
||||
{
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPaths, "wellPaths", "", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmScriptResponse RicAutomaticWellPathGrouping::execute()
|
||||
{
|
||||
caf::PdmScriptResponse response;
|
||||
|
||||
auto wellPaths = m_wellPaths.ptrReferencedObjects();
|
||||
if ( wellPaths.empty() )
|
||||
{
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_WARNING, "No well paths provided" );
|
||||
}
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
if ( project )
|
||||
{
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
if ( oilField )
|
||||
{
|
||||
oilField->wellPathCollection->groupWellPaths( wellPaths, true );
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
}
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, "No project open" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAutomaticWellPathGrouping::isCommandEnabled()
|
||||
{
|
||||
return !selectedWellPaths().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAutomaticWellPathGrouping::onActionTriggered( bool isChecked )
|
||||
{
|
||||
m_wellPaths.setValue( selectedWellPaths() );
|
||||
execute();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAutomaticWellPathGrouping::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
auto wellPathCollection = caf::SelectionManager::instance()->selectedItemOfType<RimWellPathCollection>();
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
actionToSetup->setText( "Automatically Create Multi-Lateral Wells" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellPathGroup.svg" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
actionToSetup->setText( "Automatically Create Multi-Lateral Wells from Selected Paths" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellPathGroup.svg" ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RicAutomaticWellPathGrouping::selectedWellPaths()
|
||||
{
|
||||
std::vector<RimWellPath*> wellPaths;
|
||||
|
||||
auto wellPathCollection = caf::SelectionManager::instance()->selectedItemOfType<RimWellPathCollection>();
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
wellPaths = wellPathCollection->allWellPaths();
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::SelectionManager::instance()->objectsByTypeStrict( &wellPaths );
|
||||
}
|
||||
|
||||
QString multiLateralWellPathPattern = RiaPreferences::current()->multiLateralWellNamePattern();
|
||||
QRegExp re( multiLateralWellPathPattern, Qt::CaseInsensitive, QRegExp::Wildcard );
|
||||
|
||||
std::vector<RimWellPath*> multiLateralWellPaths;
|
||||
for ( auto wellPath : wellPaths )
|
||||
{
|
||||
if ( re.exactMatch( wellPath->name() ) )
|
||||
{
|
||||
multiLateralWellPaths.push_back( wellPath );
|
||||
}
|
||||
}
|
||||
|
||||
return multiLateralWellPaths;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CommandFileInterface/Core/RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAutomaticWellPathGrouping : public caf::CmdFeature, public RicfCommandObject
|
||||
{
|
||||
RICF_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicAutomaticWellPathGrouping();
|
||||
caf::PdmScriptResponse execute() override;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static std::vector<RimWellPath*> selectedWellPaths();
|
||||
|
||||
protected:
|
||||
caf::PdmPtrArrayField<RimWellPath*> m_wellPaths;
|
||||
};
|
||||
@@ -0,0 +1,454 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicCreateWellTargetsPickEventHandler.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigHexIntersectionTools.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathLateralGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "RiuViewerCommands.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
#include "RivSourceInfo.h"
|
||||
#include "RivWellPathSourceInfo.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler(
|
||||
gsl::not_null<RimWellPathGeometryDefInterface*> wellGeometryDef )
|
||||
: m_geometryToAddTargetsTo( wellGeometryDef )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreateWellTargetsPickEventHandler::~RicCreateWellTargetsPickEventHandler()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::registerAsPickEventHandler()
|
||||
{
|
||||
RiaGuiApplication::instance()->setOverrideCursor( Qt::CrossCursor );
|
||||
Ric3dViewPickEventHandler::registerAsPickEventHandler();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::notifyUnregistered()
|
||||
{
|
||||
RiaGuiApplication::instance()->restoreOverrideCursor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
|
||||
{
|
||||
if ( m_geometryToAddTargetsTo )
|
||||
{
|
||||
Rim3dView* rimView = eventObject.m_view;
|
||||
cvf::Vec3d targetPointInDomain = cvf::Vec3d::ZERO;
|
||||
|
||||
// If clicked on an other well path, snap target point to well path center line
|
||||
auto firstPickItem = eventObject.m_pickItemInfos.front();
|
||||
|
||||
auto intersectionPointInDomain =
|
||||
rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalPickedPoint() );
|
||||
|
||||
double azimuth = std::numeric_limits<double>::infinity();
|
||||
double inclination = std::numeric_limits<double>::infinity();
|
||||
|
||||
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( firstPickItem.sourceInfo() );
|
||||
|
||||
if ( isValidWellPathSourceObject( wellPathSourceInfo ) )
|
||||
{
|
||||
calculateWellPathGeometryAtPickPoint( firstPickItem,
|
||||
wellPathSourceInfo,
|
||||
intersectionPointInDomain,
|
||||
&targetPointInDomain,
|
||||
&azimuth,
|
||||
&inclination );
|
||||
}
|
||||
else if ( isGridSourceObject( firstPickItem.sourceInfo() ) )
|
||||
{
|
||||
targetPointInDomain = calculateGridPickPoint( rimView, firstPickItem, intersectionPointInDomain );
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPointInDomain = intersectionPointInDomain;
|
||||
}
|
||||
|
||||
if ( auto wellPathGeometryDef = dynamic_cast<RimWellPathGeometryDef*>( m_geometryToAddTargetsTo.p() );
|
||||
wellPathGeometryDef )
|
||||
{
|
||||
addNewTargetToModeledWellPath( firstPickItem,
|
||||
wellPathGeometryDef,
|
||||
intersectionPointInDomain,
|
||||
targetPointInDomain,
|
||||
azimuth,
|
||||
inclination );
|
||||
}
|
||||
else if ( auto wellPathLateralGeometryDef =
|
||||
dynamic_cast<RimWellPathLateralGeometryDef*>( m_geometryToAddTargetsTo.p() );
|
||||
wellPathLateralGeometryDef )
|
||||
{
|
||||
addNewTargetToModeledWellPathLateral( firstPickItem,
|
||||
wellPathLateralGeometryDef,
|
||||
intersectionPointInDomain,
|
||||
targetPointInDomain,
|
||||
azimuth,
|
||||
inclination );
|
||||
}
|
||||
|
||||
return true; // Todo: See if we really should eat the event instead
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::calculateAzimuthAndInclinationAtMd( double measuredDepth,
|
||||
gsl::not_null<const RigWellPath*> wellPathGeometry,
|
||||
double* azimuth,
|
||||
double* inclination ) const
|
||||
{
|
||||
int mdIndex = -1;
|
||||
auto mdList = wellPathGeometry->measuredDepths();
|
||||
|
||||
for ( int i = 0; i < (int)mdList.size(); i++ )
|
||||
{
|
||||
if ( mdList[i] > measuredDepth )
|
||||
{
|
||||
mdIndex = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto ptList = wellPathGeometry->wellPathPoints();
|
||||
if ( mdIndex > 0 && mdIndex < (int)ptList.size() - 2 )
|
||||
{
|
||||
auto v1 = cvf::Vec3d( ptList[mdIndex - 1] );
|
||||
auto v2 = cvf::Vec3d( ptList[mdIndex] );
|
||||
auto v3 = cvf::Vec3d( ptList[mdIndex + 1] );
|
||||
auto v4 = cvf::Vec3d( ptList[mdIndex + 2] );
|
||||
|
||||
auto v21 = v2 - v1;
|
||||
auto v32 = v3 - v2;
|
||||
auto v43 = v4 - v3;
|
||||
|
||||
v21.normalize();
|
||||
v32.normalize();
|
||||
v43.normalize();
|
||||
|
||||
auto v13mean = ( v21 + v32 ) / 2;
|
||||
auto v24mean = ( v32 + v43 ) / 2;
|
||||
|
||||
double weight = ( measuredDepth - mdList[mdIndex] ) / ( mdList[mdIndex + 1] - mdList[mdIndex] );
|
||||
auto vTan = v13mean * weight + v24mean * ( 1 - weight );
|
||||
|
||||
RiaOffshoreSphericalCoords coords( vTan );
|
||||
*azimuth = coords.azi();
|
||||
*inclination = coords.inc();
|
||||
return true;
|
||||
}
|
||||
|
||||
*azimuth = 0.0;
|
||||
*inclination = 0.0;
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::calculateWellPathGeometryAtPickPoint(
|
||||
const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<const RivWellPathSourceInfo*> wellPathSourceInfo,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
gsl::not_null<cvf::Vec3d*> targetPointInDomain,
|
||||
gsl::not_null<double*> azimuth,
|
||||
gsl::not_null<double*> inclination ) const
|
||||
{
|
||||
*targetPointInDomain = wellPathSourceInfo->closestPointOnCenterLine( pickItem.faceIdx(), intersectionPointInDomain );
|
||||
|
||||
bool doSetAzimuthAndInclination = false;
|
||||
|
||||
auto wellPathGeometry = wellPathSourceInfo->wellPath()->wellPathGeometry();
|
||||
if ( wellPathGeometry )
|
||||
{
|
||||
double md = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
|
||||
|
||||
doSetAzimuthAndInclination = calculateAzimuthAndInclinationAtMd( md, wellPathGeometry, azimuth, inclination );
|
||||
double rkbDiff = wellPathGeometry->rkbDiff();
|
||||
auto wellPathGeometryDef = dynamic_cast<RimWellPathGeometryDef*>( m_geometryToAddTargetsTo.p() );
|
||||
if ( wellPathGeometryDef && wellPathGeometryDef->airGap() == 0.0 &&
|
||||
rkbDiff != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
wellPathGeometryDef->setAirGap( rkbDiff );
|
||||
}
|
||||
}
|
||||
return doSetAzimuthAndInclination;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RicCreateWellTargetsPickEventHandler::calculateGridPickPoint( gsl::not_null<const Rim3dView*> rimView,
|
||||
const RiuPickItemInfo& pickItem,
|
||||
const cvf::Vec3d& intersectionPointInDomain ) const
|
||||
{
|
||||
auto targetPointInDomain = intersectionPointInDomain;
|
||||
|
||||
cvf::Vec3d domainRayOrigin = rimView->displayCoordTransform()->transformToDomainCoord( pickItem.globalRayOrigin() );
|
||||
cvf::Vec3d domainRayEnd = targetPointInDomain + ( targetPointInDomain - domainRayOrigin );
|
||||
|
||||
cvf::Vec3d hexElementIntersection = findHexElementIntersection( rimView, pickItem, domainRayOrigin, domainRayEnd );
|
||||
CVF_TIGHT_ASSERT( !hexElementIntersection.isUndefined() );
|
||||
if ( !hexElementIntersection.isUndefined() )
|
||||
{
|
||||
targetPointInDomain = hexElementIntersection;
|
||||
}
|
||||
return targetPointInDomain;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::addNewTargetToModeledWellPath( const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<RimWellPathGeometryDef*> wellPathGeometryDef,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
const cvf::Vec3d& targetPointInDomain,
|
||||
double azimuth,
|
||||
double inclination )
|
||||
{
|
||||
if ( !m_geometryToAddTargetsTo->firstActiveTarget() )
|
||||
{
|
||||
wellPathGeometryDef->setReferencePointXyz( targetPointInDomain );
|
||||
|
||||
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( pickItem.sourceInfo() );
|
||||
if ( wellPathSourceInfo )
|
||||
{
|
||||
double mdAtFirstTarget = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
|
||||
|
||||
RimModeledWellPath* modeledWellPath = dynamic_cast<RimModeledWellPath*>( wellPathSourceInfo->wellPath() );
|
||||
if ( modeledWellPath )
|
||||
{
|
||||
mdAtFirstTarget += modeledWellPath->geometryDefinition()->mdAtFirstTarget();
|
||||
}
|
||||
|
||||
wellPathGeometryDef->setMdAtFirstTarget( mdAtFirstTarget );
|
||||
}
|
||||
}
|
||||
|
||||
cvf::Vec3d referencePoint = wellPathGeometryDef->anchorPointXyz();
|
||||
cvf::Vec3d relativeTargetPoint = targetPointInDomain - referencePoint;
|
||||
|
||||
RimWellPathTarget* newTarget = new RimWellPathTarget;
|
||||
|
||||
bool doSetAzimuthAndInclination = azimuth != std::numeric_limits<double>::infinity() &&
|
||||
inclination != std::numeric_limits<double>::infinity();
|
||||
if ( doSetAzimuthAndInclination )
|
||||
{
|
||||
newTarget->setAsPointXYZAndTangentTarget( relativeTargetPoint, azimuth, inclination );
|
||||
}
|
||||
else
|
||||
{
|
||||
newTarget->setAsPointTargetXYD(
|
||||
cvf::Vec3d( relativeTargetPoint.x(), relativeTargetPoint.y(), -relativeTargetPoint.z() ) );
|
||||
}
|
||||
|
||||
m_geometryToAddTargetsTo->insertTarget( nullptr, newTarget );
|
||||
m_geometryToAddTargetsTo->updateConnectedEditors();
|
||||
m_geometryToAddTargetsTo->updateWellPathVisualization( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::addNewTargetToModeledWellPathLateral(
|
||||
const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<RimWellPathLateralGeometryDef*> wellPathLateralGeometryDef,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
const cvf::Vec3d& targetPointInDomain,
|
||||
double azimuth,
|
||||
double inclination )
|
||||
{
|
||||
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( pickItem.sourceInfo() );
|
||||
if ( wellPathSourceInfo )
|
||||
{
|
||||
double mdAtConnection = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
|
||||
|
||||
wellPathLateralGeometryDef->setParentGeometry( wellPathSourceInfo->wellPath()->wellPathGeometry() );
|
||||
wellPathLateralGeometryDef->setMdAtConnection( mdAtConnection );
|
||||
}
|
||||
cvf::Vec3d referencePoint = wellPathLateralGeometryDef->anchorPointXyz();
|
||||
cvf::Vec3d relativeTargetPoint = targetPointInDomain - referencePoint;
|
||||
|
||||
RimWellPathTarget* newTarget = new RimWellPathTarget;
|
||||
|
||||
bool doSetAzimuthAndInclination = azimuth != std::numeric_limits<double>::infinity() &&
|
||||
inclination != std::numeric_limits<double>::infinity();
|
||||
if ( doSetAzimuthAndInclination )
|
||||
{
|
||||
newTarget->setAsPointXYZAndTangentTarget( cvf::Vec3d( relativeTargetPoint.x(),
|
||||
relativeTargetPoint.y(),
|
||||
relativeTargetPoint.z() ),
|
||||
azimuth,
|
||||
inclination );
|
||||
}
|
||||
else
|
||||
{
|
||||
newTarget->setAsPointTargetXYD(
|
||||
cvf::Vec3d( relativeTargetPoint.x(), relativeTargetPoint.y(), -relativeTargetPoint.z() ) );
|
||||
}
|
||||
|
||||
m_geometryToAddTargetsTo->insertTarget( nullptr, newTarget );
|
||||
m_geometryToAddTargetsTo->updateConnectedEditors();
|
||||
m_geometryToAddTargetsTo->updateWellPathVisualization( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::isGridSourceObject( const cvf::Object* object )
|
||||
{
|
||||
auto sourceInfo = dynamic_cast<const RivSourceInfo*>( object );
|
||||
auto femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>( object );
|
||||
return sourceInfo || femSourceInfo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::isValidWellPathSourceObject( const RivWellPathSourceInfo* wellPathSourceInfo )
|
||||
{
|
||||
return wellPathSourceInfo && wellPathSourceInfo->wellPath() && wellPathSourceInfo->wellPath()->wellPathGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl::not_null<const Rim3dView*> view,
|
||||
const RiuPickItemInfo& pickItem,
|
||||
const cvf::Vec3d& domainRayOrigin,
|
||||
const cvf::Vec3d& domainRayEnd )
|
||||
{
|
||||
auto sourceInfo = dynamic_cast<const RivSourceInfo*>( pickItem.sourceInfo() );
|
||||
auto femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>( pickItem.sourceInfo() );
|
||||
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
std::array<cvf::Vec3d, 8> cornerVertices;
|
||||
if ( sourceInfo )
|
||||
{
|
||||
size_t gridIndex = sourceInfo->gridIndex();
|
||||
if ( sourceInfo->hasCellFaceMapping() )
|
||||
{
|
||||
cellIndex = sourceInfo->m_cellFaceFromTriangleMapper->cellIndex( pickItem.faceIdx() );
|
||||
|
||||
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>( view.get() );
|
||||
if ( eclipseView && eclipseView->mainGrid() )
|
||||
{
|
||||
RigGridBase* hitGrid = eclipseView->mainGrid()->gridByIndex( gridIndex );
|
||||
hitGrid->cellCornerVertices( cellIndex, cornerVertices.data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( femSourceInfo )
|
||||
{
|
||||
size_t femPartIndex = femSourceInfo->femPartIndex();
|
||||
if ( femSourceInfo->triangleToElmMapper() )
|
||||
{
|
||||
size_t elementIndex = femSourceInfo->triangleToElmMapper()->elementIndex( pickItem.faceIdx() );
|
||||
|
||||
const RimGeoMechView* geoMechView = dynamic_cast<const RimGeoMechView*>( view.get() );
|
||||
if ( geoMechView && geoMechView->femParts() )
|
||||
{
|
||||
const RigFemPart* femPart = geoMechView->femParts()->part( femPartIndex );
|
||||
RigElementType elType = femPart->elementType( elementIndex );
|
||||
|
||||
if ( elType == HEX8 || elType == HEX8P )
|
||||
{
|
||||
cellIndex = elementIndex;
|
||||
const RigFemPartGrid* femGrid = femPart->getOrCreateStructGrid();
|
||||
femGrid->cellCornerVertices( cellIndex, cornerVertices.data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( cellIndex )
|
||||
{
|
||||
std::vector<HexIntersectionInfo> intersectionInfo;
|
||||
RigHexIntersectionTools::lineHexCellIntersection( domainRayOrigin,
|
||||
domainRayEnd,
|
||||
cornerVertices.data(),
|
||||
cellIndex,
|
||||
&intersectionInfo );
|
||||
if ( !intersectionInfo.empty() )
|
||||
{
|
||||
// Sort intersection on distance to ray origin
|
||||
CVF_ASSERT( intersectionInfo.size() > 1 );
|
||||
std::sort( intersectionInfo.begin(),
|
||||
intersectionInfo.end(),
|
||||
[&domainRayOrigin]( const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs ) {
|
||||
return ( lhs.m_intersectionPoint - domainRayOrigin ).lengthSquared() <
|
||||
( rhs.m_intersectionPoint - domainRayOrigin ).lengthSquared();
|
||||
} );
|
||||
const double eps = 1.0e-2;
|
||||
cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint -
|
||||
intersectionInfo.front().m_intersectionPoint;
|
||||
cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps;
|
||||
CVF_ASSERT( RigHexIntersectionTools::isPointInCell( newPoint, cornerVertices.data() ) );
|
||||
return newPoint;
|
||||
}
|
||||
}
|
||||
return cvf::Vec3d::UNDEFINED;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Ric3dViewPickEventHandler.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
class RimWellPathGeometryDefInterface;
|
||||
class RigWellPath;
|
||||
class RiuPickItemInfo;
|
||||
class RivWellPathSourceInfo;
|
||||
class RimWellPathGeometryDef;
|
||||
class RimWellPathLateralGeometryDef;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCreateWellTargetsPickEventHandler : public Ric3dViewPickEventHandler
|
||||
{
|
||||
public:
|
||||
RicCreateWellTargetsPickEventHandler( gsl::not_null<RimWellPathGeometryDefInterface*> wellGeometryDef );
|
||||
~RicCreateWellTargetsPickEventHandler();
|
||||
|
||||
void registerAsPickEventHandler() override;
|
||||
|
||||
protected:
|
||||
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
|
||||
void notifyUnregistered() override;
|
||||
|
||||
private:
|
||||
bool calculateAzimuthAndInclinationAtMd( double measuredDepth,
|
||||
gsl::not_null<const RigWellPath*> wellPathGeometry,
|
||||
double* azimuth,
|
||||
double* inclination ) const;
|
||||
bool calculateWellPathGeometryAtPickPoint( const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<const RivWellPathSourceInfo*> sourceInfo,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
gsl::not_null<cvf::Vec3d*> targetPointInDomain,
|
||||
gsl::not_null<double*> azimuth,
|
||||
gsl::not_null<double*> inclination ) const;
|
||||
|
||||
cvf::Vec3d calculateGridPickPoint( gsl::not_null<const Rim3dView*> rimView,
|
||||
const RiuPickItemInfo& pickItem,
|
||||
const cvf::Vec3d& intersectionPointInDomain ) const;
|
||||
|
||||
void addNewTargetToModeledWellPath( const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<RimWellPathGeometryDef*> wellPathGeometryDef,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
const cvf::Vec3d& targetPointInDomain,
|
||||
double azimuth,
|
||||
double inclination );
|
||||
|
||||
void addNewTargetToModeledWellPathLateral( const RiuPickItemInfo& pickItem,
|
||||
gsl::not_null<RimWellPathLateralGeometryDef*> wellPathLateralGeometryDef,
|
||||
const cvf::Vec3d& intersectionPointInDomain,
|
||||
const cvf::Vec3d& targetPointInDomain,
|
||||
double azimuth,
|
||||
double inclination );
|
||||
|
||||
static bool isGridSourceObject( const cvf::Object* object );
|
||||
static bool isValidWellPathSourceObject( const RivWellPathSourceInfo* sourceInfo );
|
||||
static cvf::Vec3d findHexElementIntersection( gsl::not_null<const Rim3dView*> view,
|
||||
const RiuPickItemInfo& pickItem,
|
||||
const cvf::Vec3d& domainRayOrigin,
|
||||
const cvf::Vec3d& domainRayEnd );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellPathGeometryDefInterface> m_geometryToAddTargetsTo;
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicDeletePolylineTargetFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeletePolylineTargetFeature, "RicDeletePolylineTargetFeature" );
|
||||
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeletePolylineTargetFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimPolylineTarget*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( !objects.empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeletePolylineTargetFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimPolylineTarget*> targets;
|
||||
caf::SelectionManager::instance()->objectsByType( &targets, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( !targets.empty() )
|
||||
{
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef = nullptr;
|
||||
targets[0]->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
polylineDef->deleteTarget( target );
|
||||
}
|
||||
|
||||
polylineDef->updateConnectedEditors();
|
||||
polylineDef->updateVisualization();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeletePolylineTargetFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Delete Target" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeletePolylineTargetFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicDeleteWellPathAttributeFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttribute.h"
|
||||
#include "RimWellPathAttributeCollection.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteWellPathAttributeFeature, "RicDeleteWellPathAttributeFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteWellPathAttributeFeature::isCommandEnabled()
|
||||
{
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> attributes;
|
||||
caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL );
|
||||
RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr;
|
||||
if ( attributes.size() > 0 )
|
||||
{
|
||||
attributes[0]->firstAncestorOrThisOfTypeAsserted( wellPathAttributeCollection );
|
||||
for ( RimWellPathAttribute* attributeToDelete : attributes )
|
||||
{
|
||||
wellPathAttributeCollection->deleteAttribute( attributeToDelete );
|
||||
}
|
||||
wellPathAttributeCollection->updateAllRequiredEditors();
|
||||
}
|
||||
else
|
||||
{
|
||||
wellPathAttributeCollection =
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>();
|
||||
if ( wellPathAttributeCollection )
|
||||
{
|
||||
wellPathAttributeCollection->deleteAllAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
if ( wellPathAttributeCollection )
|
||||
{
|
||||
if ( wellPathAttributeCollection->attributes().empty() )
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
wellPath->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( wellPath );
|
||||
}
|
||||
|
||||
RimProject* proj = nullptr;
|
||||
wellPathAttributeCollection->firstAncestorOrThisOfType( proj );
|
||||
if ( proj )
|
||||
{
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellPathAttributeFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> attributes;
|
||||
caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL );
|
||||
if ( attributes.size() > 0 )
|
||||
{
|
||||
actionToSetup->setText( "Delete Attribute" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||
}
|
||||
else if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>() )
|
||||
{
|
||||
actionToSetup->setText( "Delete Casing Design" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteWellPathAttributeFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicDeleteWellPathTargetFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteWellPathTargetFeature, "RicDeleteWellPathTargetFeature" );
|
||||
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteWellPathTargetFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimWellPathTarget*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellPathTargetFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellPathTarget*> targets;
|
||||
caf::SelectionManager::instance()->objectsByType( &targets, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( targets.size() > 0 )
|
||||
{
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
targets[0]->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
|
||||
for ( auto target : targets )
|
||||
{
|
||||
wellGeomDef->deleteTarget( target );
|
||||
}
|
||||
|
||||
wellGeomDef->updateConnectedEditors();
|
||||
wellGeomDef->updateWellPathVisualization( false );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellPathTargetFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Delete Target" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteWellPathTargetFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "RicImportGroupedWellPaths.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimFileWellPath.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
|
||||
RICF_SOURCE_INIT( RicImportGroupedWellPaths, "RicImportGroupedWellPathsFeature", "importGroupedWellPaths" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicImportGroupedWellPaths::RicImportGroupedWellPaths()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportGroupedWellPaths::onActionTriggered( bool isChecked )
|
||||
{
|
||||
// Open dialog box to select well path files
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString lastUsedGridFolder = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "WELLPATH_DIR", lastUsedGridFolder );
|
||||
|
||||
QString nameList = QString( "Well Paths (%1);;All Files (*.*)" ).arg( wellPathNameFilters().join( " " ) );
|
||||
|
||||
QStringList wellPathFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Import Well Paths",
|
||||
defaultDir,
|
||||
nameList );
|
||||
|
||||
if ( wellPathFilePaths.size() >= 1 )
|
||||
{
|
||||
m_importGrouped = true;
|
||||
m_wellPathFiles.v() = std::vector<QString>( wellPathFilePaths.begin(), wellPathFilePaths.end() );
|
||||
caf::PdmScriptResponse response = execute();
|
||||
QStringList messages = response.messages();
|
||||
|
||||
if ( !messages.empty() )
|
||||
{
|
||||
QString displayMessage = QString( "Problem loading well path files:\n%2" ).arg( messages.join( "\n" ) );
|
||||
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "Well Path Loading", displayMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportGroupedWellPaths::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Import &Grouped Well Paths from File" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellPathGroup.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicImportWellPaths.h"
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportGroupedWellPaths : public RicImportWellPaths
|
||||
{
|
||||
RICF_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicImportGroupedWellPaths();
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicImportWellMeasurementsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "RicWellMeasurementImportTools.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicImportWellMeasurementsFeature, "RicImportWellMeasurementsFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportWellMeasurementsFeature::isCommandEnabled()
|
||||
{
|
||||
return ( RicWellMeasurementImportTools::selectedWellPathCollection() != nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = RicWellMeasurementImportTools::selectedWellPathCollection();
|
||||
CVF_ASSERT( wellPathCollection );
|
||||
|
||||
// Open dialog box to select well path files
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" );
|
||||
QStringList wellPathFilePaths =
|
||||
RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Import Well Measurements",
|
||||
defaultDir,
|
||||
"Well Measurements (*.csv);;All Files (*.*)" );
|
||||
|
||||
if ( wellPathFilePaths.size() < 1 ) return;
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() );
|
||||
|
||||
RicWellMeasurementImportTools::importWellMeasurementsFromFiles( wellPathFilePaths, wellPathCollection );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportWellMeasurementsFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Import Measurements" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellMeasurement16x16.png" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportWellMeasurementsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,247 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicImportWellPaths.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimFileWellPath.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportWellPathsResult : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicImportWellPathsResult()
|
||||
{
|
||||
CAF_PDM_InitObject( "well_path_result", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &wellPathNames, "wellPathNames", "", "", "", "" );
|
||||
}
|
||||
|
||||
public:
|
||||
caf::PdmField<std::vector<QString>> wellPathNames;
|
||||
};
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RicImportWellPathsResult, "importWellPathsResult" );
|
||||
RICF_SOURCE_INIT( RicImportWellPaths, "RicWellPathsImportFileFeature", "importWellPaths" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicImportWellPaths::RicImportWellPaths()
|
||||
{
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFolder, "wellPathFolder", "", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPathFiles, "wellPathFiles", "", "", "", "" );
|
||||
CAF_PDM_InitScriptableField( &m_importGrouped, "importGrouped", false, "", "", "", "" );
|
||||
}
|
||||
|
||||
caf::PdmScriptResponse RicImportWellPaths::execute()
|
||||
{
|
||||
QStringList errorMessages, warningMessages;
|
||||
QStringList wellPathFiles;
|
||||
|
||||
QDir wellPathDir;
|
||||
if ( m_wellPathFolder().isEmpty() )
|
||||
{
|
||||
wellPathDir = QDir( RiaApplication::instance()->startDir() );
|
||||
}
|
||||
else
|
||||
{
|
||||
wellPathDir = QDir( m_wellPathFolder );
|
||||
}
|
||||
|
||||
if ( !m_wellPathFolder().isEmpty() )
|
||||
{
|
||||
if ( wellPathDir.exists() )
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << RicImportWellPaths::wellPathNameFilters();
|
||||
QStringList relativePaths = wellPathDir.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot );
|
||||
for ( QString relativePath : relativePaths )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathDir.absoluteFilePath( relativePath ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( wellPathDir.absolutePath() + " does not exist" );
|
||||
}
|
||||
}
|
||||
|
||||
for ( QString wellPathFile : m_wellPathFiles() )
|
||||
{
|
||||
if ( QFileInfo::exists( wellPathFile ) )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathFile );
|
||||
}
|
||||
else if ( QFileInfo::exists( wellPathDir.absoluteFilePath( wellPathFile ) ) )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathDir.absoluteFilePath( wellPathFile ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( wellPathFile + " does not exist" );
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmScriptResponse response;
|
||||
if ( !wellPathFiles.empty() )
|
||||
{
|
||||
std::vector<RimWellPath*> importedWellPaths = importWellPaths( wellPathFiles, m_importGrouped(), &warningMessages );
|
||||
if ( !importedWellPaths.empty() )
|
||||
{
|
||||
RicImportWellPathsResult* wellPathsResult = new RicImportWellPathsResult;
|
||||
for ( RimWellPath* wellPath : importedWellPaths )
|
||||
{
|
||||
wellPathsResult->wellPathNames.v().push_back( wellPath->name() );
|
||||
}
|
||||
|
||||
response.setResult( wellPathsResult );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warningMessages << "No well paths found";
|
||||
}
|
||||
|
||||
for ( QString warningMessage : warningMessages )
|
||||
{
|
||||
response.updateStatus( caf::PdmScriptResponse::COMMAND_WARNING, warningMessage );
|
||||
}
|
||||
|
||||
for ( QString errorMessage : errorMessages )
|
||||
{
|
||||
response.updateStatus( caf::PdmScriptResponse::COMMAND_ERROR, errorMessage );
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths,
|
||||
bool importGrouped,
|
||||
QStringList* errorMessages )
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() );
|
||||
|
||||
std::vector<RimWellPath*> wellPaths = app->addWellPathsToModel( wellPathFilePaths, importGrouped, errorMessages );
|
||||
|
||||
RimProject* project = app->project();
|
||||
|
||||
if ( project )
|
||||
{
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
if ( oilField && oilField->wellPathCollection->topLevelWellPaths().size() > 0 )
|
||||
{
|
||||
RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath();
|
||||
if ( wellPath )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( wellPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
return wellPaths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RicImportWellPaths::wellPathNameFilters()
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.json"
|
||||
<< "*.asc"
|
||||
<< " *.asci"
|
||||
<< "*.ascii"
|
||||
<< "*.dev";
|
||||
return nameFilters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportWellPaths::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportWellPaths::onActionTriggered( bool isChecked )
|
||||
{
|
||||
// Open dialog box to select well path files
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString lastUsedGridFolder = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "WELLPATH_DIR", lastUsedGridFolder );
|
||||
|
||||
QString nameList = QString( "Well Paths (%1);;All Files (*.*)" ).arg( wellPathNameFilters().join( " " ) );
|
||||
|
||||
QStringList wellPathFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Import Well Paths",
|
||||
defaultDir,
|
||||
nameList );
|
||||
|
||||
if ( wellPathFilePaths.size() >= 1 )
|
||||
{
|
||||
m_wellPathFiles.v() = std::vector<QString>( wellPathFilePaths.begin(), wellPathFilePaths.end() );
|
||||
caf::PdmScriptResponse response = execute();
|
||||
QStringList messages = response.messages();
|
||||
|
||||
if ( !messages.empty() )
|
||||
{
|
||||
QString displayMessage = QString( "Problem loading well path files:\n%2" ).arg( messages.join( "\n" ) );
|
||||
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "Well Path Loading", displayMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportWellPaths::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Import &Well Paths from File" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CommandFileInterface/Core/RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportWellPaths : public caf::CmdFeature, public RicfCommandObject
|
||||
{
|
||||
RICF_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicImportWellPaths();
|
||||
caf::PdmScriptResponse execute() override;
|
||||
|
||||
protected:
|
||||
static std::vector<RimWellPath*>
|
||||
importWellPaths( const QStringList& wellPathFilePaths, bool importGrouped, QStringList* errorMessages );
|
||||
static QStringList wellPathNameFilters();
|
||||
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
protected:
|
||||
caf::PdmField<QString> m_wellPathFolder;
|
||||
caf::PdmField<std::vector<QString>> m_wellPathFiles;
|
||||
caf::PdmField<bool> m_importGrouped;
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicIntersectionPickEventHandler.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimExtrudedCurveIntersection.h"
|
||||
#include "RimGridView.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicIntersectionPickEventHandler* RicIntersectionPickEventHandler::instance()
|
||||
{
|
||||
static RicIntersectionPickEventHandler* singleton = new RicIntersectionPickEventHandler;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
|
||||
{
|
||||
std::vector<RimExtrudedCurveIntersection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
if ( selection.size() == 1 )
|
||||
{
|
||||
{
|
||||
RimExtrudedCurveIntersection* intersection = selection[0];
|
||||
|
||||
RimGridView* gridView = nullptr;
|
||||
intersection->firstAncestorOrThisOfTypeAsserted( gridView );
|
||||
|
||||
if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = gridView->displayCoordTransform();
|
||||
|
||||
cvf::Vec3d domainCoord =
|
||||
transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );
|
||||
|
||||
if ( intersection->inputPolyLineFromViewerEnabled() )
|
||||
{
|
||||
intersection->appendPointToPolyLine( domainCoord );
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if ( intersection->inputExtrusionPointsFromViewerEnabled() )
|
||||
{
|
||||
intersection->appendPointToExtrusionDirection( domainCoord );
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() )
|
||||
{
|
||||
intersection->appendPointToAzimuthLine( domainCoord );
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicPickEventHandler.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicIntersectionPickEventHandler : public RicDefaultPickEventHandler
|
||||
{
|
||||
public:
|
||||
static RicIntersectionPickEventHandler* instance();
|
||||
|
||||
protected:
|
||||
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
|
||||
};
|
||||
@@ -0,0 +1,103 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewEditableWellPathFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewEditableWellPathFeature, "RicNewEditableWellPathFeature" );
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewEditableWellPathFeature::isCommandEnabled()
|
||||
{
|
||||
{
|
||||
std::vector<RimWellPath*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<RimWellPathCollection*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewEditableWellPathFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimProject* project = RimProject::current();
|
||||
if ( project && RimProject::current()->activeOilField() )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
|
||||
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
std::vector<RimWellPath*> newWellPaths;
|
||||
auto newModeledWellPath = new RimModeledWellPath();
|
||||
newWellPaths.push_back( newModeledWellPath );
|
||||
|
||||
newModeledWellPath->setUnitSystem( project->commonUnitSystemForAllCases() );
|
||||
|
||||
size_t modelledWellpathCount = wellPathCollection->modelledWellPathCount();
|
||||
|
||||
newWellPaths.back()->setName( "Well-" + QString::number( modelledWellpathCount + 1 ) );
|
||||
newModeledWellPath->setWellPathColor(
|
||||
RiaColorTables::editableWellPathsPaletteColors().cycledColor3f( modelledWellpathCount ) );
|
||||
|
||||
wellPathCollection->addWellPaths( newWellPaths, false );
|
||||
wellPathCollection->uiCapability()->updateConnectedEditors();
|
||||
|
||||
newModeledWellPath->geometryDefinition()->enableTargetPointPicking( true );
|
||||
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewEditableWellPathFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Well Path" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewEditableWellPathFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,170 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewPolylineTargetFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewPolylineTargetFeature, "RicNewPolylineTargetFeature" );
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewPolylineTargetFeature::isCommandEnabled()
|
||||
{
|
||||
{
|
||||
std::vector<RimUserDefinedPolylinesAnnotation*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
if ( !objects.empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<RimPolylineTarget*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( !objects.empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimPolylineTarget*> selectedTargets;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL );
|
||||
if ( !selectedTargets.empty() )
|
||||
{
|
||||
auto firstTarget = selectedTargets.front();
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
auto afterBeforePair = polylineDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( !afterBeforePair.first && afterBeforePair.second )
|
||||
{
|
||||
newPos = afterBeforePair.second->targetPointXYZ();
|
||||
|
||||
// Small displacement to separate the targets
|
||||
newPos.x() -= 50;
|
||||
newPos.y() -= 50;
|
||||
}
|
||||
else if ( afterBeforePair.first && afterBeforePair.second )
|
||||
{
|
||||
newPos = 0.5 * ( afterBeforePair.first->targetPointXYZ() + afterBeforePair.second->targetPointXYZ() );
|
||||
}
|
||||
else if ( afterBeforePair.first && !afterBeforePair.second )
|
||||
{
|
||||
std::vector<RimPolylineTarget*> activeTargets = polylineDef->activeTargets();
|
||||
size_t targetCount = activeTargets.size();
|
||||
if ( targetCount > 1 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
|
||||
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
|
||||
newPos += 0.5 * nextLastToLast;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPos = afterBeforePair.first->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
|
||||
}
|
||||
}
|
||||
|
||||
auto* newTarget = new RimPolylineTarget;
|
||||
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
|
||||
|
||||
polylineDef->insertTarget( firstTarget, newTarget );
|
||||
polylineDef->updateConnectedEditors();
|
||||
polylineDef->updateVisualization();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<RimUserDefinedPolylinesAnnotation*> polylineDefs;
|
||||
caf::SelectionManager::instance()->objectsByType( &polylineDefs );
|
||||
if ( !polylineDefs.empty() )
|
||||
{
|
||||
auto* polylineDef = polylineDefs[0];
|
||||
std::vector<RimPolylineTarget*> activeTargets = polylineDef->activeTargets();
|
||||
|
||||
size_t targetCount = activeTargets.size();
|
||||
|
||||
if ( targetCount == 0 )
|
||||
{
|
||||
auto defaultPos = cvf::Vec3d::ZERO;
|
||||
|
||||
// Set decent position
|
||||
std::vector<RimGridView*> gridViews;
|
||||
RimProject::current()->allVisibleGridViews( gridViews );
|
||||
if ( !gridViews.empty() )
|
||||
{
|
||||
auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min();
|
||||
defaultPos = minPos;
|
||||
}
|
||||
|
||||
polylineDef->appendTarget( defaultPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( targetCount > 1 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
|
||||
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
|
||||
newPos += 0.5 * nextLastToLast;
|
||||
}
|
||||
else if ( targetCount > 0 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
|
||||
}
|
||||
|
||||
auto* newTarget = new RimPolylineTarget;
|
||||
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
|
||||
polylineDef->insertTarget( nullptr, newTarget );
|
||||
}
|
||||
|
||||
polylineDef->updateConnectedEditors();
|
||||
polylineDef->updateVisualization();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewPolylineTargetFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "New Target" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewPolylineTargetFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,132 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewWellPathAttributeFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttribute.h"
|
||||
#include "RimWellPathAttributeCollection.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewWellPathAttributeFeature, "RicNewWellPathAttributeFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewWellPathAttributeFeature::isCommandEnabled()
|
||||
{
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPath>() ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathAttributeFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> attributes;
|
||||
caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
RimWellPathAttribute* attribute = nullptr;
|
||||
if ( attributes.size() == 1u )
|
||||
{
|
||||
RimWellPathAttributeCollection* attributeCollection = nullptr;
|
||||
attributes[0]->firstAncestorOrThisOfTypeAsserted( attributeCollection );
|
||||
|
||||
attribute = new RimWellPathAttribute;
|
||||
RimWellPath* wellPath = nullptr;
|
||||
attributeCollection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
|
||||
attribute->setDepthsFromWellPath( wellPath );
|
||||
attributeCollection->insertAttribute( attributes[0], attribute );
|
||||
|
||||
attributeCollection->updateAllRequiredEditors();
|
||||
}
|
||||
else
|
||||
{
|
||||
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
||||
if ( wellPath )
|
||||
{
|
||||
std::vector<RimWellPathAttributeCollection*> attributeCollections;
|
||||
wellPath->descendantsIncludingThisOfType( attributeCollections );
|
||||
if ( !attributeCollections.empty() )
|
||||
{
|
||||
attribute = new RimWellPathAttribute;
|
||||
attribute->setDepthsFromWellPath( wellPath );
|
||||
|
||||
attributeCollections[0]->insertAttribute( nullptr, attribute );
|
||||
attributeCollections[0]->updateAllRequiredEditors();
|
||||
|
||||
wellPath->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( attributeCollections[0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( attribute )
|
||||
{
|
||||
RimProject* project = nullptr;
|
||||
attribute->firstAncestorOrThisOfTypeAsserted( project );
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathAttributeFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
std::vector<RimWellPathAttribute*> attributes;
|
||||
caf::SelectionManager::instance()->objectsByType( &attributes, caf::SelectionManager::FIRST_LEVEL );
|
||||
if ( attributes.size() == 1u )
|
||||
{
|
||||
actionToSetup->setText( QString( "Insert New Attribute before %1" ).arg( attributes[0]->componentTypeLabel() ) );
|
||||
actionToSetup->setIcon( QIcon( ":/CasingDesign16x16.png" ) );
|
||||
}
|
||||
else if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPathAttributeCollection>() )
|
||||
{
|
||||
actionToSetup->setText( "Append New Attribute" );
|
||||
actionToSetup->setIcon( QIcon( ":/CasingDesign16x16.png" ) );
|
||||
}
|
||||
else if ( caf::SelectionManager::instance()->selectedItemOfType<RimWellPath>() )
|
||||
{
|
||||
actionToSetup->setText( "Create Casing Design" );
|
||||
actionToSetup->setIcon( QIcon( ":/CasingDesign16x16.png" ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewWellPathAttributeFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewWellPathLateralAtDepthFeature.h"
|
||||
|
||||
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
#include "RimFishbonesCollection.h"
|
||||
#include "RimFishbonesMultipleSubs.h"
|
||||
#include "RimModeledWellPathLateral.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGroup.h"
|
||||
#include "RimWellPathLateralGeometryDef.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "Riu3dSelectionManager.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewWellPathLateralAtDepthFeature, "RicNewWellPathLateralAtDepthFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewWellPathLateralAtDepthFeature::isCommandEnabled()
|
||||
{
|
||||
if ( wellPathSelectionItem() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathLateralAtDepthFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiuWellPathSelectionItem* wellPathSelItem = wellPathSelectionItem();
|
||||
CVF_ASSERT( wellPathSelItem );
|
||||
|
||||
RimWellPath* wellPath = wellPathSelItem->m_wellpath;
|
||||
CVF_ASSERT( wellPath );
|
||||
RimWellPathGroup* wellPathGroup = nullptr;
|
||||
wellPath->firstAncestorOrThisOfType( wellPathGroup );
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
if ( project && RimProject::current()->activeOilField() )
|
||||
{
|
||||
RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
|
||||
|
||||
if ( wellPathCollection )
|
||||
{
|
||||
auto newModeledWellPath = new RimModeledWellPathLateral();
|
||||
|
||||
auto [pointVector, measuredDepths] =
|
||||
wellPath->wellPathGeometry()->clippedPointSubset( wellPath->wellPathGeometry()->measuredDepths().front(),
|
||||
wellPathSelItem->m_measuredDepth );
|
||||
if ( pointVector.size() < 2u ) return;
|
||||
|
||||
newModeledWellPath->geometryDefinition()->setParentGeometry( wellPath->wellPathGeometry() );
|
||||
newModeledWellPath->geometryDefinition()->setMdAtConnection( wellPathSelItem->m_measuredDepth );
|
||||
newModeledWellPath->geometryDefinition()->createTargetAtConnectionPoint(
|
||||
pointVector[pointVector.size() - 1u] - pointVector[pointVector.size() - 2u] );
|
||||
|
||||
newModeledWellPath->geometryDefinition()->enableTargetPointPicking( true );
|
||||
newModeledWellPath->createWellPathGeometry();
|
||||
if ( wellPathGroup )
|
||||
{
|
||||
wellPathGroup->addChildWellPath( newModeledWellPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
wellPathCollection->addWellPath( newModeledWellPath, false );
|
||||
wellPathCollection->groupWellPaths( { wellPath, newModeledWellPath } );
|
||||
}
|
||||
newModeledWellPath->firstAncestorOrThisOfTypeAsserted( wellPathGroup );
|
||||
wellPathGroup->updateAllRequiredEditors();
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathLateralAtDepthFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Well Path Lateral at this Depth" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellPathSelectionItem* RicNewWellPathLateralAtDepthFeature::wellPathSelectionItem()
|
||||
{
|
||||
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
|
||||
RiuSelectionItem* selItem = riuSelManager->selectedItem( Riu3dSelectionManager::RUI_TEMPORARY );
|
||||
|
||||
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>( selItem );
|
||||
|
||||
return wellPathItem;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RiuWellPathSelectionItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewWellPathLateralAtDepthFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static RiuWellPathSelectionItem* wellPathSelectionItem();
|
||||
};
|
||||
@@ -0,0 +1,201 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicNewWellPathListTargetFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewWellPathListTargetFeature, "RicNewWellPathListTargetFeature" );
|
||||
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewWellPathListTargetFeature::isCommandEnabled()
|
||||
{
|
||||
{
|
||||
std::vector<RimWellPathGeometryDef*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<RimWellPathTarget*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( objects.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathListTargetFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellPathTarget*> selectedTargets;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL );
|
||||
if ( selectedTargets.size() > 0 )
|
||||
{
|
||||
RimWellPathTarget* firstTarget = selectedTargets.front();
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
|
||||
auto afterBeforePair = wellGeomDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
|
||||
|
||||
bool isSeaLevelTarget = false;
|
||||
|
||||
if ( !afterBeforePair.first && afterBeforePair.second )
|
||||
{
|
||||
if ( afterBeforePair.second->targetPointXYZ().z() == -wellGeomDef->anchorPointXyz().z() )
|
||||
{
|
||||
return; // We already have a target at sealevel.
|
||||
}
|
||||
|
||||
cvf::Vec3d targetTangent = afterBeforePair.second->tangent();
|
||||
double radius = afterBeforePair.second->radius1();
|
||||
|
||||
cvf::Vec3d tangentInHorizontalPlane = targetTangent;
|
||||
tangentInHorizontalPlane[2] = 0.0;
|
||||
tangentInHorizontalPlane.normalize();
|
||||
|
||||
RiaOffshoreSphericalCoords sphTangent( targetTangent );
|
||||
double inc = sphTangent.inc();
|
||||
double horizontalLengthFromTarget = radius - radius * cvf::Math::cos( inc );
|
||||
|
||||
newPos = afterBeforePair.second->targetPointXYZ() - horizontalLengthFromTarget * tangentInHorizontalPlane;
|
||||
newPos.z() = -wellGeomDef->anchorPointXyz().z();
|
||||
|
||||
isSeaLevelTarget = true;
|
||||
}
|
||||
else if ( afterBeforePair.first && afterBeforePair.second )
|
||||
{
|
||||
newPos = 0.5 * ( afterBeforePair.first->targetPointXYZ() + afterBeforePair.second->targetPointXYZ() );
|
||||
}
|
||||
else if ( afterBeforePair.first && !afterBeforePair.second )
|
||||
{
|
||||
std::vector<RimWellPathTarget*> activeTargets = wellGeomDef->activeWellTargets();
|
||||
size_t targetCount = activeTargets.size();
|
||||
if ( targetCount > 1 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
|
||||
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
|
||||
newPos += 0.5 * nextLastToLast;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPos = afterBeforePair.first->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
|
||||
}
|
||||
}
|
||||
|
||||
RimWellPathTarget* newTarget = new RimWellPathTarget;
|
||||
if ( isSeaLevelTarget )
|
||||
{
|
||||
newTarget->setAsPointXYZAndTangentTarget( { newPos[0], newPos[1], newPos[2] }, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
|
||||
}
|
||||
|
||||
wellGeomDef->insertTarget( firstTarget, newTarget );
|
||||
wellGeomDef->updateConnectedEditors();
|
||||
wellGeomDef->updateWellPathVisualization( false );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<RimWellPathGeometryDef*> geomDefs;
|
||||
caf::SelectionManager::instance()->objectsByType( &geomDefs );
|
||||
if ( geomDefs.size() > 0 )
|
||||
{
|
||||
RimWellPathGeometryDef* wellGeomDef = geomDefs[0];
|
||||
std::vector<RimWellPathTarget*> activeTargets = wellGeomDef->activeWellTargets();
|
||||
|
||||
size_t targetCount = activeTargets.size();
|
||||
|
||||
if ( targetCount == 0 )
|
||||
{
|
||||
wellGeomDef->appendTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( targetCount > 1 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
|
||||
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
|
||||
newPos += 0.5 * nextLastToLast;
|
||||
}
|
||||
else if ( targetCount > 0 )
|
||||
{
|
||||
newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
|
||||
}
|
||||
|
||||
RimWellPathTarget* newTarget = new RimWellPathTarget;
|
||||
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
|
||||
wellGeomDef->insertTarget( nullptr, newTarget );
|
||||
}
|
||||
|
||||
wellGeomDef->updateConnectedEditors();
|
||||
wellGeomDef->updateWellPathVisualization( false );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathListTargetFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
std::vector<RimWellPathTarget*> selectedTargets;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectedTargets, caf::SelectionManager::FIRST_LEVEL );
|
||||
|
||||
if ( selectedTargets.size() > 0 )
|
||||
{
|
||||
auto firstTarget = selectedTargets.front();
|
||||
RimWellPathGeometryDef* wellGeomDef = nullptr;
|
||||
firstTarget->firstAncestorOrThisOfTypeAsserted( wellGeomDef );
|
||||
|
||||
auto afterBeforePair = wellGeomDef->findActiveTargetsAroundInsertionPoint( firstTarget );
|
||||
|
||||
if ( !afterBeforePair.first )
|
||||
{
|
||||
actionToSetup->setText( "Insert New Target At Sea Level" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellTargets.png" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
actionToSetup->setText( "Insert New Target Above" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellTargets.png" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewWellPathListTargetFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicPolylineTargetsPickEventHandler.h"
|
||||
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
#include "RiuViewerCommands.h"
|
||||
|
||||
#include "RivPolylinesAnnotationSourceInfo.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTargetsPickEventHandler::RicPolylineTargetsPickEventHandler( RimUserDefinedPolylinesAnnotation* polylineDef )
|
||||
: m_polylineDef( polylineDef )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTargetsPickEventHandler::~RicPolylineTargetsPickEventHandler()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler()
|
||||
{
|
||||
RiuViewer::setHoverCursor( Qt::CrossCursor );
|
||||
Ric3dViewPickEventHandler::registerAsPickEventHandler();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTargetsPickEventHandler::notifyUnregistered()
|
||||
{
|
||||
RiuViewer::clearHoverCursor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPolylineTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
|
||||
{
|
||||
if ( m_polylineDef )
|
||||
{
|
||||
Rim3dView* rimView = eventObject.m_view;
|
||||
|
||||
auto firstPickItem = eventObject.m_pickItemInfos.front();
|
||||
auto targetPointInDomain =
|
||||
rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalPickedPoint() );
|
||||
|
||||
auto* newTarget = new RimPolylineTarget();
|
||||
newTarget->setAsPointTargetXYD(
|
||||
cvf::Vec3d( targetPointInDomain.x(), targetPointInDomain.y(), -targetPointInDomain.z() ) );
|
||||
|
||||
m_polylineDef->insertTarget( nullptr, newTarget );
|
||||
m_polylineDef->updateConnectedEditors();
|
||||
m_polylineDef->updateVisualization();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Ric3dViewPickEventHandler.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimUserDefinedPolylinesAnnotation;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPolylineTargetsPickEventHandler : public Ric3dViewPickEventHandler
|
||||
{
|
||||
public:
|
||||
RicPolylineTargetsPickEventHandler( RimUserDefinedPolylinesAnnotation* polylineDef );
|
||||
~RicPolylineTargetsPickEventHandler();
|
||||
|
||||
void registerAsPickEventHandler() override;
|
||||
|
||||
protected:
|
||||
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
|
||||
void notifyUnregistered() override;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimUserDefinedPolylinesAnnotation> m_polylineDef;
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018 Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicShowWellPlanFeature.h"
|
||||
|
||||
#include "ApplicationCommands/RicShowPlotDataFeature.h"
|
||||
|
||||
#include "RimModeledWellPath.h"
|
||||
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicShowWellPlanFeature, "RicShowWellPlanFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
/// RicShowPlotDataFeature
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicShowWellPlanFeature::isCommandEnabled()
|
||||
{
|
||||
auto selectedWellPaths = caf::selectedObjectsByType<RimModeledWellPath*>();
|
||||
if ( selectedWellPaths.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowWellPlanFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
std::vector<RimModeledWellPath*> selectedWellPaths = caf::selectedObjectsByType<RimModeledWellPath*>();
|
||||
|
||||
if ( selectedWellPaths.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( auto wellPath : selectedWellPaths )
|
||||
{
|
||||
QString title = "Well Plan for " + wellPath->name();
|
||||
|
||||
RiuTextDialog* textDialog = new RiuTextDialog();
|
||||
textDialog->setMinimumSize( 800, 600 );
|
||||
textDialog->setWindowTitle( title );
|
||||
textDialog->setText( wellPath->wellPlanText() );
|
||||
textDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowWellPlanFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Show Well Plan" );
|
||||
actionToSetup->setIcon( QIcon( ":/PlotWindow.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018 Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicShowWellPlanFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicToggleWellPathGrouping.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGroup.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
RICF_SOURCE_INIT( RicToggleWellPathGrouping, "RicToggleWellPathGroupingFeature", "groupWellPaths" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicToggleWellPathGrouping::RicToggleWellPathGrouping()
|
||||
{
|
||||
CAF_PDM_InitScriptableField( &m_groupWellPaths, "group", false, "", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPaths, "wellPaths", "", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmScriptResponse RicToggleWellPathGrouping::execute()
|
||||
{
|
||||
caf::PdmScriptResponse response;
|
||||
|
||||
auto wellPaths = m_wellPaths.ptrReferencedObjects();
|
||||
if ( wellPaths.empty() )
|
||||
{
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_WARNING, "No well paths provided" );
|
||||
}
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
if ( project )
|
||||
{
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
if ( oilField )
|
||||
{
|
||||
if ( m_groupWellPaths() )
|
||||
{
|
||||
oilField->wellPathCollection->groupWellPaths( wellPaths );
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
oilField->wellPathCollection->ungroupWellPaths( wellPaths );
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, "No project open" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::isCommandEnabled()
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
if ( wellPaths.size() > 1u && containsUngroupedWellPathsWithCommonGeometry( wellPaths ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( !wellPaths.empty() && containsGroupedWellPaths( wellPaths ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleWellPathGrouping::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
|
||||
if ( containsUngroupedWellPathsWithCommonGeometry( wellPaths ) )
|
||||
{
|
||||
m_groupWellPaths = true;
|
||||
}
|
||||
else if ( containsGroupedWellPaths( wellPaths ) )
|
||||
{
|
||||
m_groupWellPaths = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_wellPaths.setValue( wellPaths );
|
||||
execute();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleWellPathGrouping::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
if ( containsUngroupedWellPathsWithCommonGeometry( wellPaths ) )
|
||||
{
|
||||
actionToSetup->setText( "Create Multi-Lateral Wells from Selected Well Paths" );
|
||||
actionToSetup->setIcon( QIcon( ":/WellPathGroup.svg" ) );
|
||||
}
|
||||
else if ( containsGroupedWellPaths( wellPaths ) )
|
||||
{
|
||||
actionToSetup->setText( "Detach Selected Well Paths from Multi-Lateral Wells" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RicToggleWellPathGrouping::selectedWellPaths()
|
||||
{
|
||||
std::vector<RimWellPath*> wellPaths;
|
||||
caf::SelectionManager::instance()->objectsByTypeStrict( &wellPaths );
|
||||
return wellPaths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::containsGroupedWellPaths( const std::vector<RimWellPath*>& wellPaths )
|
||||
{
|
||||
return std::any_of( wellPaths.begin(), wellPaths.end(), []( RimWellPath* wellPath ) {
|
||||
RimWellPathGroup* group = nullptr;
|
||||
wellPath->firstAncestorOrThisOfType( group );
|
||||
return group != nullptr;
|
||||
} );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::containsUngroupedWellPathsWithCommonGeometry( const std::vector<RimWellPath*>& wellPaths )
|
||||
{
|
||||
std::vector<const RigWellPath*> geometries;
|
||||
for ( auto wellPath : wellPaths )
|
||||
{
|
||||
RimWellPathGroup* group = nullptr;
|
||||
wellPath->firstAncestorOrThisOfType( group );
|
||||
if ( !group )
|
||||
{
|
||||
geometries.push_back( wellPath->wellPathGeometry() );
|
||||
}
|
||||
}
|
||||
if ( geometries.empty() ) return false;
|
||||
|
||||
cvf::ref<RigWellPath> commonGeometry = RigWellPath::commonGeometry( geometries );
|
||||
return commonGeometry.notNull() && !commonGeometry->wellPathPoints().empty();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CommandFileInterface/Core/RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicToggleWellPathGrouping : public caf::CmdFeature, public RicfCommandObject
|
||||
{
|
||||
RICF_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicToggleWellPathGrouping();
|
||||
caf::PdmScriptResponse execute() override;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static std::vector<RimWellPath*> selectedWellPaths();
|
||||
static bool containsGroupedWellPaths( const std::vector<RimWellPath*>& wellPaths );
|
||||
static bool containsUngroupedWellPathsWithCommonGeometry( const std::vector<RimWellPath*>& wellPaths );
|
||||
|
||||
protected:
|
||||
caf::PdmField<bool> m_groupWellPaths;
|
||||
caf::PdmPtrArrayField<RimWellPath*> m_wellPaths;
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathFormationsImportFileFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuFileDialogTools.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicWellPathFormationsImportFileFeature, "RicWellPathFormationsImportFileFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicWellPathFormationsImportFileFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathFormationsImportFileFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
// Open dialog box to select well path formations files
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->lastUsedDialogDirectory( "WELLPATHFORMATIONS_DIR" );
|
||||
QStringList wellPathFormationsFilePaths =
|
||||
RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Import Well Picks",
|
||||
defaultDir,
|
||||
"Well Picks (*.csv);;All Files (*.*)" );
|
||||
|
||||
if ( wellPathFormationsFilePaths.size() < 1 ) return;
|
||||
|
||||
// Remember the path to next time
|
||||
app->setLastUsedDialogDirectory( "WELLPATHFORMATIONS_DIR",
|
||||
QFileInfo( wellPathFormationsFilePaths.last() ).absolutePath() );
|
||||
|
||||
app->addWellPathFormationsToModel( wellPathFormationsFilePaths );
|
||||
|
||||
RimProject* project = app->project();
|
||||
|
||||
if ( project )
|
||||
{
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
if ( project->mainPlotCollection() )
|
||||
{
|
||||
project->mainPlotCollection->updatePlotsWithFormations();
|
||||
}
|
||||
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
if ( !oilField ) return;
|
||||
|
||||
if ( oilField->wellPathCollection->topLevelWellPaths().size() > 0 )
|
||||
{
|
||||
RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath();
|
||||
if ( wellPath )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( wellPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathFormationsImportFileFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Import Well Picks" );
|
||||
actionToSetup->setIcon( QIcon( ":/Formations16x16.png" ) );
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicWellPathFormationsImportFileFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -0,0 +1,242 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathPickEventHandler.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellMeasurementInView.h"
|
||||
#include "RimWellMeasurementInViewCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttribute.h"
|
||||
#include "RimWellPathAttributeCollection.h"
|
||||
#include "RimWellPathValve.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "RivObjectSourceInfo.h"
|
||||
#include "RivWellPathSourceInfo.h"
|
||||
|
||||
#include "RivExtrudedCurveIntersectionPartMgr.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathPickEventHandler* RicWellPathPickEventHandler::instance()
|
||||
{
|
||||
static RicWellPathPickEventHandler* singleton = new RicWellPathPickEventHandler;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
|
||||
{
|
||||
if ( eventObject.m_pickItemInfos.empty() ) return false;
|
||||
|
||||
const caf::PdmObject* objectToSelect = nullptr;
|
||||
|
||||
cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
const RivWellPathSourceInfo* wellPathSourceInfo = nullptr;
|
||||
|
||||
if ( !eventObject.m_pickItemInfos.empty() )
|
||||
{
|
||||
const auto& firstPickedItem = eventObject.m_pickItemInfos.front();
|
||||
const cvf::Part* firstPickedPart = firstPickedItem.pickedPart();
|
||||
|
||||
if ( firstPickedPart )
|
||||
{
|
||||
const RivObjectSourceInfo* sourceInfo =
|
||||
dynamic_cast<const RivObjectSourceInfo*>( firstPickedPart->sourceInfo() );
|
||||
if ( sourceInfo )
|
||||
{
|
||||
if ( dynamic_cast<RimPerforationInterval*>( sourceInfo->object() ) )
|
||||
{
|
||||
objectToSelect = sourceInfo->object();
|
||||
|
||||
if ( eventObject.m_pickItemInfos.size() > 1 )
|
||||
{
|
||||
const auto& secondPickedItem = eventObject.m_pickItemInfos[1];
|
||||
const cvf::Part* secondPickedPart = secondPickedItem.pickedPart();
|
||||
if ( secondPickedPart )
|
||||
{
|
||||
auto wellPathSourceCandidate =
|
||||
dynamic_cast<const RivWellPathSourceInfo*>( secondPickedPart->sourceInfo() );
|
||||
if ( wellPathSourceCandidate )
|
||||
{
|
||||
RimWellPath* perforationWellPath = nullptr;
|
||||
objectToSelect->firstAncestorOrThisOfType( perforationWellPath );
|
||||
if ( perforationWellPath == wellPathSourceCandidate->wellPath() )
|
||||
{
|
||||
wellPathSourceInfo =
|
||||
dynamic_cast<const RivWellPathSourceInfo*>( secondPickedPart->sourceInfo() );
|
||||
wellPathTriangleIndex = secondPickedItem.faceIdx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RimWellPathValve*>( sourceInfo->object() ) )
|
||||
{
|
||||
objectToSelect = sourceInfo->object();
|
||||
RimWellPath* wellPath = nullptr;
|
||||
objectToSelect->firstAncestorOrThisOfType( wellPath );
|
||||
|
||||
RimWellPathValve* valve = static_cast<RimWellPathValve*>( sourceInfo->object() );
|
||||
|
||||
QString valveText = QString( "Well Path: %1\nValve: %2\nTemplate: %3" )
|
||||
.arg( wellPath->name() )
|
||||
.arg( valve->name() )
|
||||
.arg( valve->valveTemplate()->name() );
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo( valveText );
|
||||
RiuMainWindow::instance()->selectAsCurrentItem( objectToSelect );
|
||||
}
|
||||
else if ( dynamic_cast<RimWellPathAttribute*>( sourceInfo->object() ) )
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
|
||||
RimWellPathAttribute* attribute = static_cast<RimWellPathAttribute*>( sourceInfo->object() );
|
||||
RimWellPathAttributeCollection* collection = nullptr;
|
||||
attribute->firstAncestorOrThisOfTypeAsserted( collection );
|
||||
collection->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
|
||||
QString attrText = QString( "Well Path: %1\nCasing Design Attribute: %2" )
|
||||
.arg( wellPath->name() )
|
||||
.arg( attribute->componentLabel() );
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo( attrText );
|
||||
RiuMainWindow::instance()->selectAsCurrentItem( collection );
|
||||
}
|
||||
else if ( dynamic_cast<RimWellMeasurement*>( sourceInfo->object() ) )
|
||||
{
|
||||
RimWellMeasurement* measurement = dynamic_cast<RimWellMeasurement*>( sourceInfo->object() );
|
||||
RimWellMeasurementCollection* collection = nullptr;
|
||||
measurement->firstAncestorOrThisOfTypeAsserted( collection );
|
||||
|
||||
QString measurementText = QString( "Well path name: %1\n" ).arg( measurement->wellName() );
|
||||
measurementText += QString( "Measured Depth: %1\n" ).arg( measurement->MD() );
|
||||
measurementText += QString( "Value: %1\n" ).arg( measurement->value() );
|
||||
measurementText += QString( "Date: %1\n" ).arg( measurement->date().toString() );
|
||||
|
||||
if ( !measurement->kind().isEmpty() )
|
||||
{
|
||||
measurementText += QString( "Kind: %1\n" ).arg( measurement->kind() );
|
||||
}
|
||||
|
||||
if ( measurement->quality() > 0 )
|
||||
{
|
||||
measurementText += QString( "Quality: %1\n" ).arg( measurement->quality() );
|
||||
}
|
||||
|
||||
if ( !measurement->remark().isEmpty() )
|
||||
{
|
||||
measurementText += QString( "Remark: %1\n" ).arg( measurement->remark() );
|
||||
}
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo( measurementText );
|
||||
|
||||
Rim3dView* rimView = RiaApplication::instance()->activeReservoirView();
|
||||
if ( rimView )
|
||||
{
|
||||
// Find the RimWellMeasurementInView which matches the selection
|
||||
std::vector<RimWellMeasurementInViewCollection*> wellMeasurementInViewCollections;
|
||||
rimView->descendantsIncludingThisOfType( wellMeasurementInViewCollections );
|
||||
if ( !wellMeasurementInViewCollections.empty() )
|
||||
{
|
||||
RimWellMeasurementInView* wellMeasurementInView =
|
||||
wellMeasurementInViewCollections[0]->getWellMeasurementInView( measurement );
|
||||
if ( wellMeasurementInView )
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem( wellMeasurementInView );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( dynamic_cast<const RivWellPathSourceInfo*>( firstPickedPart->sourceInfo() ) )
|
||||
{
|
||||
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( firstPickedPart->sourceInfo() );
|
||||
wellPathTriangleIndex = firstPickedItem.faceIdx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( wellPathSourceInfo )
|
||||
{
|
||||
Rim3dView* rimView = RiaApplication::instance()->activeReservoirView();
|
||||
if ( !rimView ) return false;
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d pickedPositionInUTM =
|
||||
transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );
|
||||
|
||||
if ( auto intersectionView = dynamic_cast<Rim2dIntersectionView*>( rimView ) )
|
||||
{
|
||||
if ( intersectionView->flatIntersectionPartMgr() )
|
||||
{
|
||||
pickedPositionInUTM = intersectionView->transformToUtm( pickedPositionInUTM );
|
||||
}
|
||||
}
|
||||
|
||||
double measuredDepth = wellPathSourceInfo->measuredDepth( wellPathTriangleIndex, pickedPositionInUTM );
|
||||
|
||||
// NOTE: This computation was used to find the location for a fracture when clicking on a well path
|
||||
// It turned out that the computation was a bit inaccurate
|
||||
// Consider to use code in RigSimulationWellCoordsAndMD instead
|
||||
cvf::Vec3d trueVerticalDepth =
|
||||
wellPathSourceInfo->closestPointOnCenterLine( wellPathTriangleIndex, pickedPositionInUTM );
|
||||
|
||||
QString wellPathText;
|
||||
wellPathText += QString( "Well path name : %1\n" ).arg( wellPathSourceInfo->wellPath()->name() );
|
||||
wellPathText += QString( "Measured depth : %1\n" ).arg( measuredDepth );
|
||||
|
||||
QString formattedText = QString( "Intersection point : [E: %1, N: %2, Depth: %3]" )
|
||||
.arg( trueVerticalDepth.x(), 5, 'f', 2 )
|
||||
.arg( trueVerticalDepth.y(), 5, 'f', 2 )
|
||||
.arg( -trueVerticalDepth.z(), 5, 'f', 2 );
|
||||
wellPathText += formattedText;
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo( wellPathText );
|
||||
|
||||
if ( objectToSelect )
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem( objectToSelect );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem( wellPathSourceInfo->wellPath() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicPickEventHandler.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicWellPathPickEventHandler : public RicDefaultPickEventHandler
|
||||
{
|
||||
public:
|
||||
static RicWellPathPickEventHandler* instance();
|
||||
|
||||
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathsUnitSystemSettingsImpl.h"
|
||||
|
||||
#include "RicWellPathsUnitSystemSettingsUi.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( RimWellPath* wellPath )
|
||||
{
|
||||
if ( wellPath->unitSystem() != RiaEclipseUnitTools::UnitSystem::UNITS_UNKNOWN )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RicWellPathsUnitSystemSettingsUi settings;
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
&settings,
|
||||
"Select Unit System for Well Path",
|
||||
"" );
|
||||
if ( propertyDialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
wellPath->setUnitSystem( settings.unitSystem() );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaEclipseUnitTools.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicWellPathsUnitSystemSettingsImpl
|
||||
{
|
||||
public:
|
||||
static bool ensureHasUnitSystem( RimWellPath* wellPath );
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellPathsUnitSystemSettingsUi.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RicWellPathsUnitSystemSettingsUi, "RicWellPathsUnitSystemSettingsUi" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathsUnitSystemSettingsUi::RicWellPathsUnitSystemSettingsUi()
|
||||
{
|
||||
CAF_PDM_InitObject( "RimWellPathsUnitSystemSettings", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &unitSystem, "UnitSystem", "Unit System", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RicWellPathsUnitSystemSettingsUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( fieldNeedingOptions == &unitSystem )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( RiaEclipseUnitTools::UnitSystemType::uiText(
|
||||
RiaEclipseUnitTools::UnitSystem::UNITS_METRIC ),
|
||||
RiaEclipseUnitTools::UnitSystem::UNITS_METRIC ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( RiaEclipseUnitTools::UnitSystemType::uiText(
|
||||
RiaEclipseUnitTools::UnitSystem::UNITS_FIELD ),
|
||||
RiaEclipseUnitTools::UnitSystem::UNITS_FIELD ) );
|
||||
}
|
||||
return options;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaEclipseUnitTools.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicWellPathsUnitSystemSettingsUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicWellPathsUnitSystemSettingsUi();
|
||||
|
||||
caf::PdmField<RiaEclipseUnitTools::UnitSystemType> unitSystem;
|
||||
|
||||
protected:
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
};
|
||||
Reference in New Issue
Block a user