mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "RicPointTangentManipulatorPartMgr.h"
|
||||
#include "RivPartPriority.h"
|
||||
|
||||
#include "cafViewer.h"
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafViewer.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
@@ -36,73 +36,73 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulator::RicPointTangentManipulator(caf::Viewer* viewer)
|
||||
: m_viewer(viewer)
|
||||
RicPointTangentManipulator::RicPointTangentManipulator( caf::Viewer* viewer )
|
||||
: m_viewer( viewer )
|
||||
{
|
||||
m_partManager = new RicPointTangentManipulatorPartMgr;
|
||||
|
||||
m_viewer->installEventFilter(this);
|
||||
m_viewer->installEventFilter( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulator::~RicPointTangentManipulator()
|
||||
{
|
||||
if (m_viewer) m_viewer->removeEventFilter(this);
|
||||
if ( m_viewer ) m_viewer->removeEventFilter( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setOrigin(const cvf::Vec3d& origin)
|
||||
void RicPointTangentManipulator::setOrigin( const cvf::Vec3d& origin )
|
||||
{
|
||||
m_partManager->setOrigin(origin);
|
||||
m_partManager->setOrigin( origin );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setTangent(const cvf::Vec3d& tangent)
|
||||
void RicPointTangentManipulator::setTangent( const cvf::Vec3d& tangent )
|
||||
{
|
||||
m_partManager->setTangent(tangent);
|
||||
m_partManager->setTangent( tangent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::setHandleSize(double handleSize)
|
||||
void RicPointTangentManipulator::setHandleSize( double handleSize )
|
||||
{
|
||||
m_partManager->setHandleSize(handleSize);
|
||||
m_partManager->setHandleSize( handleSize );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulator::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
void RicPointTangentManipulator::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
m_partManager->appendPartsToModel(model);
|
||||
m_partManager->appendPartsToModel( model );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPointTangentManipulator::eventFilter(QObject *obj, QEvent* inputEvent)
|
||||
bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
|
||||
{
|
||||
if (inputEvent->type() == QEvent::MouseButtonPress)
|
||||
if ( inputEvent->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(inputEvent);
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
||||
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
if ( mouseEvent->button() == Qt::LeftButton )
|
||||
{
|
||||
cvf::HitItemCollection hitItems;
|
||||
if (m_viewer->rayPick(mouseEvent->x(), mouseEvent->y(), &hitItems))
|
||||
if ( m_viewer->rayPick( mouseEvent->x(), mouseEvent->y(), &hitItems ) )
|
||||
{
|
||||
m_partManager->tryToActivateManipulator(hitItems.firstItem());
|
||||
m_partManager->tryToActivateManipulator( hitItems.firstItem() );
|
||||
|
||||
if(m_partManager->isManipulatorActive())
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
emit notifySelected();
|
||||
|
||||
@@ -111,44 +111,45 @@ bool RicPointTangentManipulator::eventFilter(QObject *obj, QEvent* inputEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputEvent->type() == QEvent::MouseMove)
|
||||
else if ( inputEvent->type() == QEvent::MouseMove )
|
||||
{
|
||||
if (m_partManager->isManipulatorActive())
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(inputEvent);
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
||||
|
||||
//qDebug() << "Inside mouse move";
|
||||
//qDebug() << mouseEvent->pos();
|
||||
// qDebug() << "Inside mouse move";
|
||||
// qDebug() << mouseEvent->pos();
|
||||
|
||||
int translatedMousePosX = mouseEvent->pos().x();
|
||||
int translatedMousePosY = m_viewer->height() - mouseEvent->pos().y();
|
||||
|
||||
cvf::ref<cvf::Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
if (!ray.isNull())
|
||||
cvf::ref<cvf::Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates( translatedMousePosX,
|
||||
translatedMousePosY );
|
||||
if ( !ray.isNull() )
|
||||
{
|
||||
m_partManager->updateManipulatorFromRay(ray.p());
|
||||
m_partManager->updateManipulatorFromRay( ray.p() );
|
||||
|
||||
cvf::Vec3d origin;
|
||||
cvf::Vec3d tangent;
|
||||
m_partManager->originAndTangent(&origin, &tangent);
|
||||
m_partManager->originAndTangent( &origin, &tangent );
|
||||
|
||||
emit notifyUpdate(origin, tangent);
|
||||
emit notifyUpdate( origin, tangent );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputEvent->type() == QEvent::MouseButtonRelease)
|
||||
else if ( inputEvent->type() == QEvent::MouseButtonRelease )
|
||||
{
|
||||
if (m_partManager->isManipulatorActive())
|
||||
if ( m_partManager->isManipulatorActive() )
|
||||
{
|
||||
m_partManager->endManipulator();
|
||||
|
||||
cvf::Vec3d origin;
|
||||
cvf::Vec3d tangent;
|
||||
m_partManager->originAndTangent(&origin, &tangent);
|
||||
m_partManager->originAndTangent( &origin, &tangent );
|
||||
|
||||
emit notifyUpdate(origin, tangent);
|
||||
emit notifyUpdate( origin, tangent );
|
||||
emit notifyDragFinished();
|
||||
|
||||
return true;
|
||||
@@ -157,5 +158,3 @@ bool RicPointTangentManipulator::eventFilter(QObject *obj, QEvent* inputEvent)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
namespace cvf {
|
||||
class Model;
|
||||
class ModelBasicList;
|
||||
};
|
||||
namespace cvf
|
||||
{
|
||||
class Model;
|
||||
class ModelBasicList;
|
||||
}; // namespace cvf
|
||||
|
||||
|
||||
namespace caf {
|
||||
class Viewer;
|
||||
namespace caf
|
||||
{
|
||||
class Viewer;
|
||||
};
|
||||
|
||||
class QMouseEvent;
|
||||
@@ -49,26 +49,25 @@ class RicPointTangentManipulator : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RicPointTangentManipulator(caf::Viewer* viewer);
|
||||
explicit RicPointTangentManipulator( caf::Viewer* viewer );
|
||||
~RicPointTangentManipulator() override;
|
||||
|
||||
void setOrigin(const cvf::Vec3d& origin);
|
||||
void setTangent(const cvf::Vec3d& tangent);
|
||||
void setHandleSize(double handleSize);
|
||||
void setOrigin( const cvf::Vec3d& origin );
|
||||
void setTangent( const cvf::Vec3d& tangent );
|
||||
void setHandleSize( double handleSize );
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
void appendPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
signals:
|
||||
void notifySelected();
|
||||
void notifyDragFinished();
|
||||
void notifyUpdate(const cvf::Vec3d& origin, const cvf::Vec3d& tangent);
|
||||
void notifySelected();
|
||||
void notifyDragFinished();
|
||||
void notifyUpdate( const cvf::Vec3d& origin, const cvf::Vec3d& tangent );
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
bool eventFilter( QObject* obj, QEvent* event ) override;
|
||||
|
||||
private:
|
||||
QPointer<caf::Viewer> m_viewer;
|
||||
QPointer<caf::Viewer> m_viewer;
|
||||
|
||||
cvf::ref<RicPointTangentManipulatorPartMgr> m_partManager;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -27,13 +27,13 @@
|
||||
#include "cvfBoxGenerator.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfGeometryBuilderFaceList.h"
|
||||
#include "cvfHitItem.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cvfPlane.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfHitItem.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRay.h"
|
||||
|
||||
#include "cvfGeometryBuilderTriangles.h"
|
||||
#include "cvfGeometryUtils.h"
|
||||
@@ -41,68 +41,66 @@
|
||||
#include <QDebug>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr()
|
||||
: m_tangentOnStartManipulation(cvf::Vec3d::UNDEFINED),
|
||||
m_originOnStartManipulation(cvf::Vec3d::UNDEFINED),
|
||||
m_currentHandleIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_handleSize(1.0)
|
||||
RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr()
|
||||
: m_tangentOnStartManipulation( cvf::Vec3d::UNDEFINED )
|
||||
, m_originOnStartManipulation( cvf::Vec3d::UNDEFINED )
|
||||
, m_currentHandleIndex( cvf::UNDEFINED_SIZE_T )
|
||||
, m_handleSize( 1.0 )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPointTangentManipulatorPartMgr::~RicPointTangentManipulatorPartMgr()
|
||||
{
|
||||
}
|
||||
RicPointTangentManipulatorPartMgr::~RicPointTangentManipulatorPartMgr() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setOrigin(const cvf::Vec3d& origin)
|
||||
void RicPointTangentManipulatorPartMgr::setOrigin( const cvf::Vec3d& origin )
|
||||
{
|
||||
if (isManipulatorActive()) return;
|
||||
if ( isManipulatorActive() ) return;
|
||||
|
||||
m_origin = origin;
|
||||
if (m_originOnStartManipulation.isUndefined()) m_originOnStartManipulation = origin;
|
||||
if ( m_originOnStartManipulation.isUndefined() ) m_originOnStartManipulation = origin;
|
||||
|
||||
clearAllGeometryAndParts();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setTangent(const cvf::Vec3d& tangent)
|
||||
void RicPointTangentManipulatorPartMgr::setTangent( const cvf::Vec3d& tangent )
|
||||
{
|
||||
if(isManipulatorActive()) return;
|
||||
if ( isManipulatorActive() ) return;
|
||||
|
||||
m_tangent = tangent;
|
||||
if (m_tangentOnStartManipulation.isUndefined()) m_tangentOnStartManipulation = m_tangent;
|
||||
if ( m_tangentOnStartManipulation.isUndefined() ) m_tangentOnStartManipulation = m_tangent;
|
||||
|
||||
clearAllGeometryAndParts();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::setHandleSize(double handleSize)
|
||||
void RicPointTangentManipulatorPartMgr::setHandleSize( double handleSize )
|
||||
{
|
||||
m_handleSize = handleSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::originAndTangent(cvf::Vec3d* origin, cvf::Vec3d* tangent)
|
||||
void RicPointTangentManipulatorPartMgr::originAndTangent( cvf::Vec3d* origin, cvf::Vec3d* tangent )
|
||||
{
|
||||
*origin = m_origin;
|
||||
*origin = m_origin;
|
||||
*tangent = m_tangent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPointTangentManipulatorPartMgr::isManipulatorActive() const
|
||||
{
|
||||
@@ -110,107 +108,104 @@ bool RicPointTangentManipulatorPartMgr::isManipulatorActive() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
void RicPointTangentManipulatorPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
if (!m_handleParts.size())
|
||||
if ( !m_handleParts.size() )
|
||||
{
|
||||
recreateAllGeometryAndParts();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_handleParts.size(); i++)
|
||||
for ( size_t i = 0; i < m_handleParts.size(); i++ )
|
||||
{
|
||||
model->addPart(m_handleParts.at(i));
|
||||
model->addPart( m_handleParts.at( i ) );
|
||||
}
|
||||
|
||||
for (auto activeModePart: m_activeDragModeParts)
|
||||
for ( auto activeModePart : m_activeDragModeParts )
|
||||
{
|
||||
model->addPart(activeModePart.p());
|
||||
model->addPart( activeModePart.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::tryToActivateManipulator(const cvf::HitItem* hitItem)
|
||||
void RicPointTangentManipulatorPartMgr::tryToActivateManipulator( const cvf::HitItem* hitItem )
|
||||
{
|
||||
endManipulator();
|
||||
|
||||
if (!hitItem) return;
|
||||
if ( !hitItem ) return;
|
||||
|
||||
const cvf::Part* pickedPart = hitItem->part();
|
||||
const cvf::Part* pickedPart = hitItem->part();
|
||||
const cvf::Vec3d intersectionPoint = hitItem->intersectionPoint();
|
||||
|
||||
if (!pickedPart) return;
|
||||
if ( !pickedPart ) return;
|
||||
|
||||
for (size_t i = 0; i < m_handleParts.size(); i++)
|
||||
for ( size_t i = 0; i < m_handleParts.size(); i++ )
|
||||
{
|
||||
if (pickedPart == m_handleParts.at(i))
|
||||
if ( pickedPart == m_handleParts.at( i ) )
|
||||
{
|
||||
m_initialPickPoint = intersectionPoint;
|
||||
m_initialPickPoint = intersectionPoint;
|
||||
m_tangentOnStartManipulation = m_tangent;
|
||||
m_originOnStartManipulation = m_origin;
|
||||
m_currentHandleIndex = i;
|
||||
m_originOnStartManipulation = m_origin;
|
||||
m_currentHandleIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculate new origin and tangent based on the new ray position
|
||||
/// Clear geometry to trigger regeneration
|
||||
/// Clear geometry to trigger regeneration
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay(const cvf::Ray* newMouseRay)
|
||||
void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray* newMouseRay )
|
||||
{
|
||||
if (!isManipulatorActive()) return;
|
||||
if ( !isManipulatorActive() ) return;
|
||||
|
||||
if ( m_handleIds[m_currentHandleIndex] == HORIZONTAL_PLANE )
|
||||
if ( m_handleIds[m_currentHandleIndex] == HORIZONTAL_PLANE )
|
||||
{
|
||||
cvf::Plane plane;
|
||||
plane.setFromPointAndNormal(m_origin, cvf::Vec3d::Z_AXIS);
|
||||
plane.setFromPointAndNormal( m_origin, cvf::Vec3d::Z_AXIS );
|
||||
cvf::Vec3d newIntersection;
|
||||
newMouseRay->planeIntersect(plane, &newIntersection);
|
||||
newMouseRay->planeIntersect( plane, &newIntersection );
|
||||
|
||||
cvf::Vec3d newOrigin = m_originOnStartManipulation + (newIntersection - m_initialPickPoint);
|
||||
cvf::Vec3d newOrigin = m_originOnStartManipulation + ( newIntersection - m_initialPickPoint );
|
||||
|
||||
m_origin = newOrigin;
|
||||
}
|
||||
else if ( m_handleIds[m_currentHandleIndex] == VERTICAL_AXIS )
|
||||
else if ( m_handleIds[m_currentHandleIndex] == VERTICAL_AXIS )
|
||||
{
|
||||
cvf::Plane plane;
|
||||
cvf::Vec3d planeNormal = (newMouseRay->direction() ^ cvf::Vec3d::Z_AXIS) ^ cvf::Vec3d::Z_AXIS;
|
||||
double length = planeNormal.length();
|
||||
cvf::Vec3d planeNormal = ( newMouseRay->direction() ^ cvf::Vec3d::Z_AXIS ) ^ cvf::Vec3d::Z_AXIS;
|
||||
double length = planeNormal.length();
|
||||
|
||||
if (length < 1e-5) return;
|
||||
if ( length < 1e-5 ) return;
|
||||
|
||||
planeNormal /= length;
|
||||
plane.setFromPointAndNormal(m_initialPickPoint, planeNormal );
|
||||
plane.setFromPointAndNormal( m_initialPickPoint, planeNormal );
|
||||
cvf::Vec3d newIntersection;
|
||||
newMouseRay->planeIntersect(plane, &newIntersection);
|
||||
newMouseRay->planeIntersect( plane, &newIntersection );
|
||||
|
||||
cvf::Vec3d newOrigin = m_originOnStartManipulation;
|
||||
newOrigin.z() += (newIntersection.z() - m_initialPickPoint.z());
|
||||
newOrigin.z() += ( newIntersection.z() - m_initialPickPoint.z() );
|
||||
|
||||
m_origin = newOrigin;
|
||||
}
|
||||
//m_tangent = newTangent;
|
||||
// m_tangent = newTangent;
|
||||
|
||||
clearAllGeometryAndParts();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::endManipulator()
|
||||
{
|
||||
m_currentHandleIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::clearAllGeometryAndParts()
|
||||
{
|
||||
@@ -219,18 +214,16 @@ void RicPointTangentManipulatorPartMgr::clearAllGeometryAndParts()
|
||||
m_activeDragModeParts.clear();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts()
|
||||
{
|
||||
createAllHandleParts();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createAllHandleParts()
|
||||
{
|
||||
@@ -239,64 +232,63 @@ void RicPointTangentManipulatorPartMgr::createAllHandleParts()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle()
|
||||
void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle()
|
||||
{
|
||||
using namespace cvf;
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(6);
|
||||
|
||||
vertexArray->set(0, {-1, -1, 0} );
|
||||
vertexArray->set(1, { 1, -1, 0});
|
||||
vertexArray->set(2, { 1, 1, 0});
|
||||
vertexArray->set(3, {-1, -1, 0});
|
||||
vertexArray->set(4, { 1, 1, 0});
|
||||
vertexArray->set(5, {-1, 1, 0});
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray( 6 );
|
||||
|
||||
Vec3f origin(m_origin);
|
||||
for (cvf::Vec3f& vx: *vertexArray)
|
||||
vertexArray->set( 0, {-1, -1, 0} );
|
||||
vertexArray->set( 1, {1, -1, 0} );
|
||||
vertexArray->set( 2, {1, 1, 0} );
|
||||
vertexArray->set( 3, {-1, -1, 0} );
|
||||
vertexArray->set( 4, {1, 1, 0} );
|
||||
vertexArray->set( 5, {-1, 1, 0} );
|
||||
|
||||
Vec3f origin( m_origin );
|
||||
for ( cvf::Vec3f& vx : *vertexArray )
|
||||
{
|
||||
vx *= 0.5*m_handleSize;
|
||||
vx *= 0.5 * m_handleSize;
|
||||
vx += origin;
|
||||
}
|
||||
|
||||
ref<DrawableGeo> geo = createTriangelDrawableGeo(vertexArray.p());
|
||||
ref<DrawableGeo> geo = createTriangelDrawableGeo( vertexArray.p() );
|
||||
|
||||
HandleType handleId = HORIZONTAL_PLANE;
|
||||
cvf::Color4f color = cvf::Color4f(1.0f, 0.0f, 1.0f, 0.5f);
|
||||
cvf::String partName("PointTangentManipulator Horizontal Plane Handle");
|
||||
HandleType handleId = HORIZONTAL_PLANE;
|
||||
cvf::Color4f color = cvf::Color4f( 1.0f, 0.0f, 1.0f, 0.5f );
|
||||
cvf::String partName( "PointTangentManipulator Horizontal Plane Handle" );
|
||||
|
||||
addHandlePart(geo.p(), color, handleId, partName);
|
||||
addHandlePart( geo.p(), color, handleId, partName );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle()
|
||||
void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle()
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
cvf::ref< cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles;
|
||||
cvf::GeometryUtils::createBox({-0.3f, -0.3f, -1.0f}, { 0.3f, 0.3f, 1.0f}, 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)
|
||||
cvf::ref<cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles;
|
||||
cvf::GeometryUtils::createBox( {-0.3f, -0.3f, -1.0f}, {0.3f, 0.3f, 1.0f}, 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 *= 0.5 * m_handleSize;
|
||||
vx += origin;
|
||||
}
|
||||
|
||||
ref<DrawableGeo> geo = createIndexedTriangelDrawableGeo(vertexArray.p(), indexArray.p());
|
||||
ref<DrawableGeo> geo = createIndexedTriangelDrawableGeo( vertexArray.p(), indexArray.p() );
|
||||
|
||||
HandleType handleId = VERTICAL_AXIS;
|
||||
cvf::Color4f color = cvf::Color4f(0.0f, 0.2f, 0.8f, 0.5f);
|
||||
cvf::String partName("PointTangentManipulator Vertical Axis Handle");
|
||||
HandleType handleId = VERTICAL_AXIS;
|
||||
cvf::Color4f color = cvf::Color4f( 0.0f, 0.2f, 0.8f, 0.5f );
|
||||
cvf::String partName( "PointTangentManipulator Vertical Axis Handle" );
|
||||
|
||||
addHandlePart(geo.p(), color, handleId, partName);
|
||||
addHandlePart( geo.p(), color, handleId, partName );
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -332,91 +324,85 @@ void RicPointTangentManipulatorPartMgr::createAzimuthHandle()
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createIndexedTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray,
|
||||
cvf::UIntArray* triangleIndices)
|
||||
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);
|
||||
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->setVertexArray( triangleVertexArray );
|
||||
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::DrawableGeo>
|
||||
RicPointTangentManipulatorPartMgr::createTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray )
|
||||
{
|
||||
cvf::ref<cvf::Part> handlePart = createPart(geo, color, partName);
|
||||
using namespace cvf;
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
|
||||
m_handleParts.push_back(handlePart.p());
|
||||
m_handleIds.push_back(handleId);
|
||||
}
|
||||
geo->setVertexArray( triangleVertexArray );
|
||||
ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect( cvf::PT_TRIANGLES );
|
||||
primSet->setIndexCount( triangleVertexArray->size() );
|
||||
|
||||
geo->addPrimitiveSet( primSet.p() );
|
||||
geo->computeNormals();
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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());
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Part> RicPointTangentManipulatorPartMgr::createPart(cvf::DrawableGeo* geo,
|
||||
const cvf::Color4f& color,
|
||||
const cvf::String& partName)
|
||||
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.push_back( handlePart.p() );
|
||||
m_handleIds.push_back( handleId );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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->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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfCollection.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfColor4.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
|
||||
class ModelBasicList;
|
||||
class Part;
|
||||
class DrawableGeo;
|
||||
@@ -36,11 +34,12 @@ class Ray;
|
||||
class HitItem;
|
||||
class String;
|
||||
|
||||
template <typename> class Array;
|
||||
typedef Array<Vec3f> Vec3fArray;
|
||||
typedef Array<uint> UIntArray;
|
||||
template <typename>
|
||||
class Array;
|
||||
typedef Array<Vec3f> Vec3fArray;
|
||||
typedef Array<uint> UIntArray;
|
||||
|
||||
}
|
||||
} // namespace cvf
|
||||
|
||||
class RicPointTangentManipulatorPartMgr : public cvf::Object
|
||||
{
|
||||
@@ -49,7 +48,7 @@ public:
|
||||
{
|
||||
HORIZONTAL_PLANE,
|
||||
VERTICAL_AXIS,
|
||||
AZIMUTH,
|
||||
AZIMUTH,
|
||||
INCLINATION
|
||||
};
|
||||
|
||||
@@ -57,17 +56,17 @@ 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);
|
||||
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 tryToActivateManipulator( const cvf::HitItem* hitItem );
|
||||
void updateManipulatorFromRay( const cvf::Ray* ray );
|
||||
void endManipulator();
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
void appendPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
private:
|
||||
void createAllHandleParts();
|
||||
@@ -77,35 +76,27 @@ private:
|
||||
void createHorizontalPlaneHandle();
|
||||
void createVerticalAxisHandle();
|
||||
|
||||
void addHandlePart(cvf::DrawableGeo* geo,
|
||||
const cvf::Color4f& color,
|
||||
HandleType handleId,
|
||||
const cvf::String& partName);
|
||||
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);
|
||||
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 );
|
||||
|
||||
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:
|
||||
size_t m_currentHandleIndex;
|
||||
std::vector< HandleType > m_handleIds; // These arrays have the same length
|
||||
cvf::Collection<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;
|
||||
cvf::Vec3d m_initialPickPoint;
|
||||
cvf::Vec3d m_tangentOnStartManipulation;
|
||||
cvf::Vec3d m_originOnStartManipulation;
|
||||
|
||||
size_t m_currentHandleIndex;
|
||||
std::vector<HandleType> m_handleIds; // These arrays have the same length
|
||||
cvf::Collection<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;
|
||||
cvf::Vec3d m_initialPickPoint;
|
||||
cvf::Vec3d m_tangentOnStartManipulation;
|
||||
cvf::Vec3d m_originOnStartManipulation;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -25,50 +25,47 @@
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicPolyline3dEditor);
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicPolyline3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolyline3dEditor::RicPolyline3dEditor()
|
||||
{
|
||||
|
||||
}
|
||||
RicPolyline3dEditor::RicPolyline3dEditor() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolyline3dEditor::~RicPolyline3dEditor()
|
||||
{
|
||||
for (auto targetEditor: m_targetEditors)
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if (m_attribute.pickEventHandler != nullptr)
|
||||
if ( m_attribute.pickEventHandler != nullptr )
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolyline3dEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
auto* geomDef = dynamic_cast<RimUserDefinedPolylinesAnnotation*>(this->pdmObject());
|
||||
auto* geomDef = dynamic_cast<RimUserDefinedPolylinesAnnotation*>( this->pdmObject() );
|
||||
|
||||
for (auto targetEditor: m_targetEditors)
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
m_targetEditors.clear();
|
||||
|
||||
if (!geomDef) return;
|
||||
if ( !geomDef ) return;
|
||||
|
||||
geomDef->objectEditorAttribute("", &m_attribute);
|
||||
if (m_attribute.pickEventHandler != nullptr)
|
||||
geomDef->objectEditorAttribute( "", &m_attribute );
|
||||
if ( m_attribute.pickEventHandler != nullptr )
|
||||
{
|
||||
if (m_attribute.enablePicking)
|
||||
if ( m_attribute.enablePicking )
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
@@ -80,14 +77,12 @@ void RicPolyline3dEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
|
||||
std::vector<RimPolylineTarget*> targets = geomDef->activeTargets();
|
||||
|
||||
for (auto target: targets)
|
||||
for ( auto target : targets )
|
||||
{
|
||||
auto targetEditor = new RicPolylineTarget3dEditor;
|
||||
targetEditor->setViewer(ownerViewer());
|
||||
targetEditor->setPdmObject(target);
|
||||
m_targetEditors.push_back(targetEditor);
|
||||
targetEditor->setViewer( ownerViewer() );
|
||||
targetEditor->setPdmObject( target );
|
||||
m_targetEditors.push_back( targetEditor );
|
||||
targetEditor->updateUi();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -25,12 +25,11 @@
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PickEventHandler;
|
||||
class PickEventHandler;
|
||||
};
|
||||
|
||||
class RicPolylineTarget3dEditor;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -38,7 +37,7 @@ class RicPolyline3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicPolyline3dEditorAttribute()
|
||||
: enablePicking(false)
|
||||
: enablePicking( false )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,11 +58,9 @@ public:
|
||||
~RicPolyline3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
std::vector<RicPolylineTarget3dEditor*> m_targetEditors;
|
||||
RicPolyline3dEditorAttribute m_attribute;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "RimAnnotationCollectionBase.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimAnnotationCollectionBase.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
@@ -32,164 +32,152 @@
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicPolylineTarget3dEditor);
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicPolylineTarget3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTarget3dEditor::RicPolylineTarget3dEditor()
|
||||
{
|
||||
|
||||
}
|
||||
RicPolylineTarget3dEditor::RicPolylineTarget3dEditor() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor()
|
||||
{
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if (m_cvfModel.notNull() && ownerRiuViewer)
|
||||
if ( m_cvfModel.notNull() && ownerRiuViewer )
|
||||
{
|
||||
|
||||
// Could result in some circularities ....
|
||||
ownerRiuViewer->removeStaticModel(m_cvfModel.p());
|
||||
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor(this);
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
|
||||
delete m_manipulator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if ( !target || !target->isEnabled())
|
||||
if ( !target || !target->isEnabled() )
|
||||
{
|
||||
m_cvfModel->removeAllParts();
|
||||
return;
|
||||
}
|
||||
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted(polylineDef);
|
||||
target->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
target->targetPointUiCapability()->addFieldEditor(this);
|
||||
target->targetPointUiCapability()->addFieldEditor( this );
|
||||
|
||||
if (m_manipulator.isNull())
|
||||
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_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());
|
||||
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf;
|
||||
double handleSize = 1.0;
|
||||
double handleSize = 1.0;
|
||||
{
|
||||
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>(ownerRiuViewer->ownerReservoirView());
|
||||
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>( ownerRiuViewer->ownerReservoirView() );
|
||||
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
}
|
||||
|
||||
m_manipulator->setOrigin(dispXf->transformToDisplayCoord( target->targetPointXYZ()));
|
||||
//m_manipulator->setTangent(target->tangent());
|
||||
m_manipulator->setHandleSize(handleSize);
|
||||
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_manipulator->appendPartsToModel( m_cvfModel.p() );
|
||||
|
||||
m_cvfModel->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
|
||||
{
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( oldTarget )
|
||||
{
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor(this);
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::slotUpdated(const cvf::Vec3d& origin, const cvf::Vec3d& tangent)
|
||||
void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
|
||||
if ( !target)
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf;
|
||||
{
|
||||
RiuViewer* viewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
|
||||
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
|
||||
}
|
||||
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted(polylineDef);
|
||||
target->firstAncestorOrThisOfTypeAsserted( polylineDef );
|
||||
|
||||
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin);
|
||||
domainOrigin.z() = -domainOrigin.z();
|
||||
QVariant originVariant = caf::PdmValueFieldSpecialization < cvf::Vec3d >::convert(domainOrigin);
|
||||
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);
|
||||
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)
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel(target, caf::SelectionManager::FIRST_LEVEL);
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTarget3dEditor::slotDragFinished()
|
||||
{
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
if ( !target)
|
||||
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimAnnotationCollectionBase* annColl;
|
||||
target->firstAncestorOrThisOfTypeAsserted(annColl);
|
||||
target->firstAncestorOrThisOfTypeAsserted( annColl );
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
class RicPointTangentManipulator;
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf {
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
@@ -42,16 +42,15 @@ public:
|
||||
~RicPolylineTarget3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
void cleanupBeforeSettingPdmObject() override;
|
||||
|
||||
private slots:
|
||||
void slotUpdated(const cvf::Vec3d& origin, const cvf::Vec3d& tangent);
|
||||
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;
|
||||
cvf::ref<cvf::ModelBasicList> m_cvfModel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,67 +21,64 @@
|
||||
#include "RicWellPathGeometry3dEditor.h"
|
||||
#include "RicWellTarget3dEditor.h"
|
||||
|
||||
#include "RimWellPathTarget.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicWellPathGeometry3dEditor);
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellPathGeometry3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathGeometry3dEditor::RicWellPathGeometry3dEditor()
|
||||
{
|
||||
|
||||
}
|
||||
RicWellPathGeometry3dEditor::RicWellPathGeometry3dEditor() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellPathGeometry3dEditor::~RicWellPathGeometry3dEditor()
|
||||
{
|
||||
for (auto targetEditor: m_targetEditors)
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if (m_attribute.pickEventHandler)
|
||||
if ( m_attribute.pickEventHandler )
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellPathGeometry3dEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
void RicWellPathGeometry3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimWellPathGeometryDef* geomDef = dynamic_cast<RimWellPathGeometryDef*>(this->pdmObject());
|
||||
RimWellPathGeometryDef* geomDef = dynamic_cast<RimWellPathGeometryDef*>( this->pdmObject() );
|
||||
|
||||
for (auto targetEditor: m_targetEditors)
|
||||
for ( auto targetEditor : m_targetEditors )
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
m_targetEditors.clear();
|
||||
|
||||
if (!geomDef) return;
|
||||
if ( !geomDef ) return;
|
||||
|
||||
geomDef->objectEditorAttribute("", &m_attribute);
|
||||
geomDef->objectEditorAttribute( "", &m_attribute );
|
||||
|
||||
std::vector<RimWellPathTarget*> targets = geomDef->activeWellTargets();
|
||||
|
||||
for (auto target: targets)
|
||||
for ( auto target : targets )
|
||||
{
|
||||
auto targetEditor = new RicWellTarget3dEditor;
|
||||
targetEditor->setViewer(ownerViewer());
|
||||
targetEditor->setPdmObject(target);
|
||||
m_targetEditors.push_back(targetEditor);
|
||||
targetEditor->setViewer( ownerViewer() );
|
||||
targetEditor->setPdmObject( target );
|
||||
m_targetEditors.push_back( targetEditor );
|
||||
targetEditor->updateUi();
|
||||
}
|
||||
|
||||
if (m_attribute.pickEventHandler)
|
||||
if ( m_attribute.pickEventHandler )
|
||||
{
|
||||
if (m_attribute.enablePicking)
|
||||
if ( m_attribute.enablePicking )
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
@@ -91,5 +88,3 @@ void RicWellPathGeometry3dEditor::configureAndUpdateUi(const QString& uiConfigNa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -28,11 +28,13 @@ class PickEventHandler;
|
||||
|
||||
class RicWellTarget3dEditor;
|
||||
|
||||
|
||||
class RicWellPathGeometry3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicWellPathGeometry3dEditorAttribute() : enablePicking(false) {}
|
||||
RicWellPathGeometry3dEditorAttribute()
|
||||
: enablePicking( false )
|
||||
{
|
||||
}
|
||||
bool enablePicking;
|
||||
std::shared_ptr<caf::PickEventHandler> pickEventHandler;
|
||||
};
|
||||
@@ -46,11 +48,9 @@ public:
|
||||
~RicWellPathGeometry3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
|
||||
private:
|
||||
std::vector<RicWellTarget3dEditor*> m_targetEditors;
|
||||
RicWellPathGeometry3dEditorAttribute m_attribute;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
#include "RicPointTangentManipulator.h"
|
||||
|
||||
#include "RimWellPathTarget.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
#include "RimWellPathTarget.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
@@ -32,173 +32,161 @@
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicWellTarget3dEditor);
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellTarget3dEditor );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellTarget3dEditor::RicWellTarget3dEditor()
|
||||
{
|
||||
|
||||
}
|
||||
RicWellTarget3dEditor::RicWellTarget3dEditor() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicWellTarget3dEditor::~RicWellTarget3dEditor()
|
||||
{
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if (m_cvfModel.notNull() && ownerRiuViewer)
|
||||
if ( m_cvfModel.notNull() && ownerRiuViewer )
|
||||
{
|
||||
|
||||
// Could result in some circularities ....
|
||||
ownerRiuViewer->removeStaticModel(m_cvfModel.p());
|
||||
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
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);
|
||||
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)
|
||||
void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>(this->pdmObject());
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
|
||||
if ( !target || !target->isEnabled())
|
||||
if ( !target || !target->isEnabled() )
|
||||
{
|
||||
m_cvfModel->removeAllParts();
|
||||
return;
|
||||
}
|
||||
|
||||
RimWellPathGeometryDef* geomDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted(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);
|
||||
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())
|
||||
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_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());
|
||||
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p() );
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf;
|
||||
double handleSize = 1.0;
|
||||
double handleSize = 1.0;
|
||||
{
|
||||
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>(ownerRiuViewer->ownerReservoirView());
|
||||
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
|
||||
Rim3dView* view = dynamic_cast<Rim3dView*>( ownerRiuViewer->ownerReservoirView() );
|
||||
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
|
||||
}
|
||||
|
||||
m_manipulator->setOrigin(dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->referencePointXyz()));
|
||||
m_manipulator->setTangent(target->tangent());
|
||||
m_manipulator->setHandleSize(handleSize);
|
||||
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->referencePointXyz() ) );
|
||||
m_manipulator->setTangent( target->tangent() );
|
||||
m_manipulator->setHandleSize( handleSize );
|
||||
m_cvfModel->removeAllParts();
|
||||
m_manipulator->appendPartsToModel(m_cvfModel.p());
|
||||
m_manipulator->appendPartsToModel( m_cvfModel.p() );
|
||||
|
||||
m_cvfModel->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::cleanupBeforeSettingPdmObject()
|
||||
{
|
||||
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
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);
|
||||
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)
|
||||
void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>(this->pdmObject());
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
|
||||
if ( !target)
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> dispXf;
|
||||
{
|
||||
RiuViewer* viewer = dynamic_cast<RiuViewer*>(ownerViewer());
|
||||
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
|
||||
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
|
||||
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
|
||||
}
|
||||
|
||||
RimWellPathGeometryDef* geomDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted(geomDef);
|
||||
target->firstAncestorOrThisOfTypeAsserted( geomDef );
|
||||
|
||||
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin) - geomDef->referencePointXyz();
|
||||
domainOrigin.z() = -domainOrigin.z();
|
||||
QVariant originVariant = caf::PdmValueFieldSpecialization < cvf::Vec3d >::convert(domainOrigin);
|
||||
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin ) - geomDef->referencePointXyz();
|
||||
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);
|
||||
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)
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel(target, caf::SelectionManager::FIRST_LEVEL);
|
||||
caf::SelectionManager::instance()->setSelectedItemAtLevel( target, caf::SelectionManager::FIRST_LEVEL );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellTarget3dEditor::slotDragFinished()
|
||||
{
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>(this->pdmObject());
|
||||
if ( !target)
|
||||
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
|
||||
if ( !target )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimModeledWellPath* wellpath;
|
||||
target->firstAncestorOrThisOfTypeAsserted(wellpath);
|
||||
target->firstAncestorOrThisOfTypeAsserted( wellpath );
|
||||
wellpath->scheduleUpdateOfDependentVisualization();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
class RicPointTangentManipulator;
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
namespace cvf {
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
@@ -42,16 +42,15 @@ public:
|
||||
~RicWellTarget3dEditor() override;
|
||||
|
||||
protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
void cleanupBeforeSettingPdmObject() override;
|
||||
|
||||
private slots:
|
||||
void slotUpdated(const cvf::Vec3d& origin, const cvf::Vec3d& tangent);
|
||||
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;
|
||||
cvf::ref<cvf::ModelBasicList> m_cvfModel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user