mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
114 lines
4.5 KiB
C++
114 lines
4.5 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 "RimTextAnnotationInView.h"
|
|
#include "RimAnnotationCollectionBase.h"
|
|
#include "RimAnnotationGroupCollection.h"
|
|
#include "RimTextAnnotation.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimTextAnnotationInView, "RimTextAnnotationInView" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimTextAnnotationInView::RimTextAnnotationInView()
|
|
{
|
|
CAF_PDM_InitObject( "TextAnnotationInView", ":/TextAnnotation16x16.png" );
|
|
|
|
// Register keyword alias for backward compatibility (old keyword was "IsActive", base uses "IsChecked")
|
|
m_isChecked.registerKeywordAlias( "IsActive" );
|
|
m_isChecked.uiCapability()->setUiHidden( true );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_sourceAnnotation, "SourceAnnotation", "Source Annotation" );
|
|
|
|
m_sourceAnnotation.uiCapability()->setUiHidden( true );
|
|
m_sourceAnnotation = nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimTextAnnotationInView::RimTextAnnotationInView( RimTextAnnotation* sourceAnnotation )
|
|
: RimTextAnnotationInView()
|
|
{
|
|
CVF_ASSERT( sourceAnnotation );
|
|
|
|
setCheckState( sourceAnnotation->isActive() );
|
|
m_sourceAnnotation = sourceAnnotation;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimTextAnnotationInView::setSourceAnnotation( RimTextAnnotation* annotation )
|
|
{
|
|
m_sourceAnnotation = annotation;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimTextAnnotation* RimTextAnnotationInView::sourceAnnotation() const
|
|
{
|
|
return m_sourceAnnotation;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Returns true if annotation can be displayed due to all toggles that affect this annotation
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimTextAnnotationInView::isVisible() const
|
|
{
|
|
auto coll = firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
|
|
|
bool visible = true;
|
|
if ( coll ) visible = coll->isVisible();
|
|
if ( visible && m_sourceAnnotation )
|
|
{
|
|
visible = m_sourceAnnotation->isVisible();
|
|
|
|
if ( visible )
|
|
{
|
|
auto globalColl = m_sourceAnnotation->firstAncestorOrThisOfType<RimAnnotationGroupCollection>();
|
|
if ( globalColl ) visible = globalColl->isVisible();
|
|
}
|
|
}
|
|
if ( visible ) visible = isChecked();
|
|
return visible;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimTextAnnotationInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
{
|
|
if ( changedField == objectToggleField() )
|
|
{
|
|
auto coll = firstAncestorOrThisOfType<RimAnnotationCollectionBase>();
|
|
|
|
if ( coll ) coll->scheduleRedrawOfRelevantViews();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
caf::PdmFieldHandle* RimTextAnnotationInView::userDescriptionField()
|
|
{
|
|
return m_sourceAnnotation ? m_sourceAnnotation->userDescriptionField() : nullptr;
|
|
}
|