mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
158 lines
6.2 KiB
C++
158 lines
6.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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 "RimReachCircleAnnotation.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "RimAnnotationCollection.h"
|
|
#include "RimAnnotationInViewCollection.h"
|
|
#include "RimAnnotationLineAppearance.h"
|
|
#include "RimGridView.h"
|
|
#include "RimProject.h"
|
|
|
|
#include "RicVec3dPickEventHandler.h"
|
|
|
|
#include "cafPdmUiPickableLineEditor.h"
|
|
#include "cafPdmUiPushButtonEditor.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimReachCircleAnnotation, "RimReachCircleAnnotation" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimReachCircleAnnotation::RimReachCircleAnnotation()
|
|
{
|
|
CAF_PDM_InitObject( "CircleAnnotation", ":/ReachCircle16x16.png" );
|
|
|
|
m_isChecked.registerKeywordAlias( "IsActive" );
|
|
m_isChecked.uiCapability()->setUiHidden( true );
|
|
|
|
nameField()->registerKeywordAlias( "Name" );
|
|
setName( "Circle Annotation" );
|
|
|
|
CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point" );
|
|
m_centerPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
|
|
CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "" );
|
|
m_centerPointPickEnabled.xmlCapability()->disableIO();
|
|
m_centerPointPickEnabled.uiCapability()->setUiHidden( true );
|
|
|
|
CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" );
|
|
|
|
m_appearance = new RimReachCircleLineAppearance();
|
|
m_appearance.uiCapability()->setUiTreeChildrenHidden( true );
|
|
|
|
m_centerPointEventHandler = std::make_shared<RicVec3dPickEventHandler>( &m_centerPointXyd );
|
|
|
|
setDeletable( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimReachCircleAnnotation::isActive()
|
|
{
|
|
return isChecked();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimReachCircleAnnotation::isVisible()
|
|
{
|
|
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
|
|
|
return coll && coll->isActive() && isChecked();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimReachCircleAnnotation::enablePicking( bool enable )
|
|
{
|
|
m_centerPointPickEnabled = enable;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
cvf::Vec3d RimReachCircleAnnotation::centerPoint() const
|
|
{
|
|
auto pos = m_centerPointXyd();
|
|
pos.z() = -pos.z();
|
|
return pos;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimReachCircleAnnotation::radius() const
|
|
{
|
|
return m_radius;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimReachCircleLineAppearance* RimReachCircleAnnotation::appearance() const
|
|
{
|
|
return m_appearance;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimReachCircleAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
{
|
|
uiOrdering.add( nameField() );
|
|
uiOrdering.add( &m_centerPointXyd );
|
|
m_centerPointXyd.uiCapability()->setAttribute( caf::PdmUiPickableLineEditor::Keys::PICK_EVENT_HANDLER, m_centerPointEventHandler );
|
|
m_centerPointXyd.uiCapability()->setAttribute( caf::PdmUiPickableLineEditor::Keys::ENABLE_PICKING,
|
|
m_centerPointPickEnabled() || m_centerPointXyd().isZero() );
|
|
uiOrdering.addNewButton( m_centerPointPickEnabled ? "Stop" : "Pick",
|
|
[this]()
|
|
{
|
|
m_centerPointPickEnabled = !m_centerPointPickEnabled;
|
|
updateConnectedEditors();
|
|
},
|
|
{ .newRow = false, .totalColumnSpan = 1 } );
|
|
uiOrdering.add( &m_radius );
|
|
|
|
auto appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
|
|
appearance()->uiOrdering( uiConfigName, *appearanceGroup );
|
|
|
|
uiOrdering.skipRemainingFields( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimReachCircleAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
{
|
|
if ( changedField == &m_centerPointXyd )
|
|
{
|
|
m_centerPointPickEnabled = false;
|
|
updateConnectedEditors();
|
|
}
|
|
auto annColl = firstAncestorOrThisOfTypeAsserted<RimAnnotationCollection>();
|
|
|
|
annColl->scheduleRedrawOfRelevantViews();
|
|
}
|