#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -3,23 +3,21 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivTextAnnotationPartMgr.h"
#include "RiaApplication.h"
@@ -38,8 +36,8 @@
#include "RivPartPriority.h"
#include "RivPolylineGenerator.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cafFixedAtlasFont.h"
#include "cvfDrawableGeo.h"
@@ -48,102 +46,100 @@
#include "cvfPart.h"
#include "cvfqtUtils.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotationLocal)
: m_rimView(view), m_rimAnnotationLocal(annotationLocal), m_rimAnnotationInView(nullptr)
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr( Rim3dView* view, RimTextAnnotation* annotationLocal )
: m_rimView( view )
, m_rimAnnotationLocal( annotationLocal )
, m_rimAnnotationInView( nullptr )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotationInView* annotationInView)
: m_rimView(view)
, m_rimAnnotationLocal(nullptr)
, m_rimAnnotationInView(annotationInView)
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr( Rim3dView* view, RimTextAnnotationInView* annotationInView )
: m_rimView( view )
, m_rimAnnotationLocal( nullptr )
, m_rimAnnotationInView( annotationInView )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::~RivTextAnnotationPartMgr()
{
}
RivTextAnnotationPartMgr::~RivTextAnnotationPartMgr() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * displayXf,
bool doFlatten,
double xOffset)
void RivTextAnnotationPartMgr::buildParts( const caf::DisplayCoordTransform* displayXf, bool doFlatten, double xOffset )
{
clearAllGeometry();
auto collection = annotationCollection();
if (!collection) return;
if ( !collection ) return;
cvf::Vec3d anchorPositionInDomain = getAnchorPointInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
cvf::Vec3d labelPositionInDomain = getLabelPointInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
cvf::Vec3d anchorPositionInDomain = getAnchorPointInDomain( collection->snapAnnotations(),
collection->annotationPlaneZ() );
cvf::Vec3d labelPositionInDomain = getLabelPointInDomain( collection->snapAnnotations(),
collection->annotationPlaneZ() );
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord(anchorPositionInDomain);
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
QString text = rimAnnotation()->text();
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord( anchorPositionInDomain );
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord( labelPositionInDomain );
QString text = rimAnnotation()->text();
auto fontSize = rimAnnotation()->appearance()->fontSize();
auto fontColor = rimAnnotation()->appearance()->fontColor();
auto fontSize = rimAnnotation()->appearance()->fontSize();
auto fontColor = rimAnnotation()->appearance()->fontColor();
auto backgroundColor = rimAnnotation()->appearance()->backgroundColor();
auto anchorLineColor = rimAnnotation()->appearance()->anchorLineColor();
// Line part
{
std::vector<cvf::Vec3d> points = { anchorPosition, labelPosition };
std::vector<cvf::Vec3d> points = {anchorPosition, labelPosition};
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(points);
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( points );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(drawableGeo.p());
part->setDrawable( drawableGeo.p() );
caf::MeshEffectGenerator colorEffgen(anchorLineColor);
cvf::ref<cvf::Effect> eff = colorEffgen.generateUnCachedEffect();
caf::MeshEffectGenerator colorEffgen( anchorLineColor );
cvf::ref<cvf::Effect> eff = colorEffgen.generateUnCachedEffect();
part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::MeshLines);
part->setSourceInfo(new RivObjectSourceInfo(rimAnnotation()));
part->setEffect( eff.p() );
part->setPriority( RivPartPriority::PartType::MeshLines );
part->setSourceInfo( new RivObjectSourceInfo( rimAnnotation() ) );
m_linePart = part;
}
// Text part
{
auto font = RiaFontCache::getFont(fontSize);
auto font = RiaFontCache::getFont( fontSize );
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(font.p());
drawableText->setCheckPosVisible(false);
drawableText->setUseDepthBuffer(true);
drawableText->setDrawBorder(true);
drawableText->setDrawBackground(true);
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
drawableText->setBackgroundColor(backgroundColor);
drawableText->setBorderColor(RiaColorTools::computeOffsetColor(backgroundColor, 0.3f));
drawableText->setTextColor(fontColor);
drawableText->setFont( font.p() );
drawableText->setCheckPosVisible( false );
drawableText->setUseDepthBuffer( true );
drawableText->setDrawBorder( true );
drawableText->setDrawBackground( true );
drawableText->setVerticalAlignment( cvf::TextDrawer::BASELINE );
drawableText->setBackgroundColor( backgroundColor );
drawableText->setBorderColor( RiaColorTools::computeOffsetColor( backgroundColor, 0.3f ) );
drawableText->setTextColor( fontColor );
cvf::String cvfString = cvfqt::Utils::toString(text);
cvf::String cvfString = cvfqt::Utils::toString( text );
cvf::Vec3f textCoord(labelPosition);
drawableText->addText(cvfString, textCoord);
cvf::Vec3f textCoord( labelPosition );
drawableText->addText( cvfString, textCoord );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivTextAnnotationPartMgr: " + cvfString);
part->setDrawable(drawableText.p());
part->setName( "RivTextAnnotationPartMgr: " + cvfString );
part->setDrawable( drawableText.p() );
cvf::ref<cvf::Effect> eff = new cvf::Effect();
part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::MeshLines);
part->setEffect( eff.p() );
part->setPriority( RivPartPriority::PartType::MeshLines );
m_labelPart = part;
}
@@ -152,11 +148,11 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain(bool snapToPlaneZ, double planeZ)
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain( bool snapToPlaneZ, double planeZ )
{
auto pt = rimAnnotation()->anchorPoint();
if (snapToPlaneZ)
if ( snapToPlaneZ )
{
pt.z() = planeZ;
}
@@ -166,11 +162,11 @@ RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getLabelPointInDomain(bool snapToPlaneZ, double planeZ)
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getLabelPointInDomain( bool snapToPlaneZ, double planeZ )
{
auto pt = rimAnnotation()->labelPoint();
if (snapToPlaneZ)
if ( snapToPlaneZ )
{
pt.z() = planeZ;
}
@@ -180,49 +176,50 @@ RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getLabelPointInDomain(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::isTextInBoundingBox(const cvf::BoundingBox& boundingBox)
bool RivTextAnnotationPartMgr::isTextInBoundingBox( const cvf::BoundingBox& boundingBox )
{
auto coll = annotationCollection();
if (!coll) return false;
if ( !coll ) return false;
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3);
if (effectiveBoundingBox.contains(getAnchorPointInDomain(coll->snapAnnotations(), coll->annotationPlaneZ())) ||
effectiveBoundingBox.contains(getLabelPointInDomain(coll->snapAnnotations(), coll->annotationPlaneZ()))) return true;
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate( boundingBox, 3 );
if ( effectiveBoundingBox.contains( getAnchorPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) ) ||
effectiveBoundingBox.contains( getLabelPointInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) ) )
return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivTextAnnotationPartMgr::clearAllGeometry()
{
m_linePart = nullptr;
m_linePart = nullptr;
m_labelPart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTextAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform * displayXf,
const cvf::BoundingBox& boundingBox)
{
if (!rimAnnotation() || !isAnnotationVisible()) return;
// Check bounding box
if (!isTextInBoundingBox(boundingBox)) return;
if (!validateAnnotation(rimAnnotation())) return;
buildParts(displayXf, false, 0.0);
model->addPart(m_linePart.p());
model->addPart(m_labelPart.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::validateAnnotation(const RimTextAnnotation* annotation) const
void RivTextAnnotationPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox )
{
if ( !rimAnnotation() || !isAnnotationVisible() ) return;
// Check bounding box
if ( !isTextInBoundingBox( boundingBox ) ) return;
if ( !validateAnnotation( rimAnnotation() ) ) return;
buildParts( displayXf, false, 0.0 );
model->addPart( m_linePart.p() );
model->addPart( m_labelPart.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::validateAnnotation( const RimTextAnnotation* annotation ) const
{
return rimAnnotation()->anchorPoint() != cvf::Vec3d::ZERO && !rimAnnotation()->text().isEmpty();
}
@@ -233,7 +230,7 @@ bool RivTextAnnotationPartMgr::validateAnnotation(const RimTextAnnotation* annot
RimAnnotationInViewCollection* RivTextAnnotationPartMgr::annotationCollection() const
{
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType(colls);
m_rimView->descendantsIncludingThisOfType( colls );
return !colls.empty() ? colls.front() : nullptr;
}
@@ -242,7 +239,7 @@ RimAnnotationInViewCollection* RivTextAnnotationPartMgr::annotationCollection()
//--------------------------------------------------------------------------------------------------
RimTextAnnotation* RivTextAnnotationPartMgr::rimAnnotation() const
{
if (m_rimAnnotationLocal) return m_rimAnnotationLocal;
if ( m_rimAnnotationLocal ) return m_rimAnnotationLocal;
return m_rimAnnotationInView->sourceAnnotation();
}
@@ -252,9 +249,7 @@ RimTextAnnotation* RivTextAnnotationPartMgr::rimAnnotation() const
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::isAnnotationVisible() const
{
if (m_rimAnnotationLocal)
return m_rimAnnotationLocal->isVisible();
if(m_rimAnnotationInView)
return m_rimAnnotationInView->isVisible();
if ( m_rimAnnotationLocal ) return m_rimAnnotationLocal->isVisible();
if ( m_rimAnnotationInView ) return m_rimAnnotationInView->isVisible();
return false;
}