2018-11-23 06:33:59 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2018-11-27 07:43:25 -06:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2018-11-23 06:33:59 -06:00
|
|
|
//
|
|
|
|
// 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 "RimAnnotationInViewCollection.h"
|
|
|
|
|
2018-11-27 08:43:44 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2018-11-30 01:59:22 -06:00
|
|
|
#include "RimCase.h"
|
2018-11-27 08:43:44 -06:00
|
|
|
#include "RimProject.h"
|
2018-11-23 06:33:59 -06:00
|
|
|
#include "RimGridView.h"
|
2018-11-26 07:48:06 -06:00
|
|
|
#include "RimTextAnnotation.h"
|
2018-11-23 06:33:59 -06:00
|
|
|
|
2018-11-30 01:59:22 -06:00
|
|
|
#include <cvfBoundingBox.h>
|
|
|
|
|
|
|
|
#include <cafPdmUiDoubleSliderEditor.h>
|
|
|
|
|
2018-11-23 06:33:59 -06:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimAnnotationInViewCollection, "Annotations");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimAnnotationInViewCollection::RimAnnotationInViewCollection()
|
|
|
|
{
|
2018-11-28 08:40:20 -06:00
|
|
|
CAF_PDM_InitObject("Annotations", ":/Annotations16x16.png", "", "");
|
2018-11-23 06:33:59 -06:00
|
|
|
|
2018-11-26 07:48:06 -06:00
|
|
|
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
|
2018-11-23 06:33:59 -06:00
|
|
|
m_isActive.uiCapability()->setUiHidden(true);
|
2018-11-29 03:13:19 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitField(&m_annotationPlaneDepth, "AnnotationPlaneDepth", 0.0, "Annotation Plane Depth", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_snapAnnotations, "SnapAnnotations", false, "Snap Annotations to Plane", "", "", "");
|
2018-11-30 01:59:22 -06:00
|
|
|
|
|
|
|
m_annotationPlaneDepth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
|
|
|
m_annotationPlaneDepth.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP);
|
2018-11-23 06:33:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimAnnotationInViewCollection::~RimAnnotationInViewCollection()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimAnnotationInViewCollection::isActive() const
|
|
|
|
{
|
|
|
|
return m_isActive();
|
|
|
|
}
|
|
|
|
|
2018-11-29 03:13:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RimAnnotationInViewCollection::annotationPlaneZ() const
|
|
|
|
{
|
|
|
|
return -m_annotationPlaneDepth();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimAnnotationInViewCollection::snapAnnotations() const
|
|
|
|
{
|
|
|
|
return m_snapAnnotations;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimAnnotationInViewCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_snapAnnotations);
|
2018-11-30 01:59:22 -06:00
|
|
|
if(m_snapAnnotations())
|
|
|
|
uiOrdering.add(&m_annotationPlaneDepth);
|
|
|
|
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
2018-11-29 03:13:19 -06:00
|
|
|
}
|
|
|
|
|
2018-11-23 06:33:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimAnnotationInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (&m_isActive == changedField)
|
|
|
|
{
|
|
|
|
this->updateUiIconFromToggleField();
|
|
|
|
}
|
2018-11-29 03:13:19 -06:00
|
|
|
scheduleRedrawOfRelevantViews();
|
2018-11-23 06:33:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimAnnotationInViewCollection::objectToggleField()
|
|
|
|
{
|
|
|
|
return &m_isActive;
|
|
|
|
}
|
2018-11-30 01:59:22 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimAnnotationInViewCollection::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute)
|
|
|
|
{
|
|
|
|
if (field == &m_annotationPlaneDepth)
|
|
|
|
{
|
|
|
|
auto* attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
|
|
|
|
|
|
|
|
if (attr)
|
|
|
|
{
|
|
|
|
RimCase* rimCase;
|
|
|
|
firstAncestorOrThisOfType(rimCase);
|
|
|
|
|
|
|
|
if (rimCase)
|
|
|
|
{
|
|
|
|
auto bb = rimCase->allCellsBoundingBox();
|
|
|
|
attr->m_minimum = -bb.max().z();
|
|
|
|
attr->m_maximum = -bb.min().z();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attr->m_minimum = 0;
|
|
|
|
attr->m_maximum = 10000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|