diff --git a/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp index 31ab2c05d9..2e418bfde1 100644 --- a/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp @@ -581,36 +581,24 @@ void RivFaultPartMgr::createLabelWithAnchorLine( const cvf::Part* part ) cvf::Font* font = app->defaultWellLabelFont(); - cvf::ref drawableText = new cvf::DrawableText; - drawableText->setFont( font ); - drawableText->setCheckPosVisible( false ); - drawableText->setDrawBorder( false ); - drawableText->setDrawBackground( false ); - drawableText->setVerticalAlignment( cvf::TextDrawer::CENTER ); - cvf::Color3f defWellLabelColor = app->preferences()->defaultWellLabelColor(); { + auto parentObject = m_rimFault->firstAncestorOrThisOfType(); + if ( parentObject ) { - auto parentObject = m_rimFault->firstAncestorOrThisOfType(); - if ( parentObject ) - { - defWellLabelColor = parentObject->faultLabelColor(); - } + defWellLabelColor = parentObject->faultLabelColor(); } } - drawableText->setTextColor( defWellLabelColor ); - - cvf::String cvfString = cvfqt::Utils::toString( m_rimFault->name() ); - cvf::Vec3f textCoord( labelPosition ); double characteristicCellSize = bb.extent().z() / 20; textCoord.z() += characteristicCellSize; - drawableText->addText( cvfString, textCoord ); + auto drawableText = + RivAnnotationTools::createDrawableTextNoBackground( font, defWellLabelColor, m_rimFault->name().toStdString(), textCoord ); cvf::ref labelPart = new cvf::Part; - labelPart->setName( "RivFaultPart : text " + cvfString ); + labelPart->setName( "RivFaultPart : text " + m_rimFault->name().toStdString() ); labelPart->setDrawable( drawableText.p() ); cvf::ref eff = new cvf::Effect; @@ -618,7 +606,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine( const cvf::Part* part ) labelPart->setEffect( eff.p() ); labelPart->setPriority( RivPartPriority::PartType::Text ); - labelPart->setSourceInfo( new RivTextLabelSourceInfo( m_rimFault, cvfString, textCoord ) ); + labelPart->setSourceInfo( new RivTextLabelSourceInfo( m_rimFault, m_rimFault->name().toStdString(), textCoord ) ); m_faultLabelPart = labelPart; } diff --git a/ApplicationLibCode/ModelVisualization/RivAnnotationTools.cpp b/ApplicationLibCode/ModelVisualization/RivAnnotationTools.cpp index dc763ef564..bc6ba8fe03 100644 --- a/ApplicationLibCode/ModelVisualization/RivAnnotationTools.cpp +++ b/ApplicationLibCode/ModelVisualization/RivAnnotationTools.cpp @@ -88,15 +88,12 @@ void RivAnnotationTools::setCountHint( int countHint ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivAnnotationTools::createPartFromPolyline( const std::string& partName, - const cvf::Color3f& color, - const std::vector& polyLine ) +cvf::ref RivAnnotationTools::createPartFromPolyline( const cvf::Color3f& color, const std::vector& polyLine ) { cvf::ref drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( polyLine ); if ( drawableGeo.isNull() ) return nullptr; cvf::ref part = new cvf::Part; - part->setName( partName ); part->setDrawable( drawableGeo.p() ); caf::MeshEffectGenerator colorEffgen( color ); @@ -333,9 +330,11 @@ void RivAnnotationTools::addAnnotationLabels( const cvf::Collection& std::vector points = { lineAnchorPosition, labelPosition }; auto anchorLineColor = cvf::Color3f::BLACK; - auto part = RivAnnotationTools::createPartFromPolyline( "AnnotationObjectAnchorPoints", anchorLineColor, points ); + auto part = RivAnnotationTools::createPartFromPolyline( anchorLineColor, points ); + if ( part.notNull() ) { + part->setName( "AnnotationObjectAnchorPoints" ); model->addPart( part.p() ); } } @@ -365,11 +364,11 @@ void RivAnnotationTools::addAnnotationLabels( const cvf::Collection& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivAnnotationTools::createDrawableText( cvf::Font* font, - cvf::Color3f textColor, - cvf::Color3f backgroundColor, - const std::string& text, - const cvf::Vec3f& position ) +cvf::ref RivAnnotationTools::createDrawableText( cvf::Font* font, + const cvf::Color3f& textColor, + const cvf::Color3f& backgroundColor, + const std::string& text, + const cvf::Vec3f& position ) { auto drawableText = new cvf::DrawableText; @@ -387,6 +386,27 @@ cvf::ref RivAnnotationTools::createDrawableText( cvf::Font* return drawableText; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivAnnotationTools::createDrawableTextNoBackground( cvf::Font* font, + const cvf::Color3f& textColor, + const std::string& text, + const cvf::Vec3f& position ) +{ + cvf::ref drawableText = new cvf::DrawableText; + + drawableText->setFont( font ); + drawableText->setCheckPosVisible( false ); + drawableText->setDrawBorder( false ); + drawableText->setDrawBackground( false ); + drawableText->setVerticalAlignment( cvf::TextDrawer::CENTER ); + drawableText->setTextColor( textColor ); + drawableText->addText( cvf::String( text ), position ); + + return drawableText; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ModelVisualization/RivAnnotationTools.h b/ApplicationLibCode/ModelVisualization/RivAnnotationTools.h index 9f412fbe5a..13b98980c8 100644 --- a/ApplicationLibCode/ModelVisualization/RivAnnotationTools.h +++ b/ApplicationLibCode/ModelVisualization/RivAnnotationTools.h @@ -60,14 +60,16 @@ class RivAnnotationTools // Create labels for the given collection of parts. The labels are added to the given model. void addAnnotationLabels( const cvf::Collection& partCollection, const cvf::Camera* camera, cvf::ModelBasicList* model ); - static cvf::ref - createPartFromPolyline( const std::string& partName, const cvf::Color3f& color, const std::vector& polyLine ); + static cvf::ref createPartFromPolyline( const cvf::Color3f& color, const std::vector& polyLine ); - static cvf::ref createDrawableText( cvf::Font* font, - cvf::Color3f textColor, - cvf::Color3f backgroundColor, - const std::string& text, - const cvf::Vec3f& position ); + static cvf::ref createDrawableText( cvf::Font* font, + const cvf::Color3f& textColor, + const cvf::Color3f& backgroundColor, + const std::string& text, + const cvf::Vec3f& position ); + + static cvf::ref + createDrawableTextNoBackground( cvf::Font* font, const cvf::Color3f& textColor, const std::string& text, const cvf::Vec3f& position ); static cvf::ref createPart( cvf::DrawableText* drawableText ); diff --git a/ApplicationLibCode/ModelVisualization/RivTextAnnotationPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivTextAnnotationPartMgr.cpp index 3e5ce4c590..782b993e3c 100644 --- a/ApplicationLibCode/ModelVisualization/RivTextAnnotationPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivTextAnnotationPartMgr.cpp @@ -98,17 +98,8 @@ void RivTextAnnotationPartMgr::buildParts( const caf::DisplayCoordTransform* dis { std::vector points = { anchorPosition, labelPosition }; - cvf::ref drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( points ); - - cvf::ref part = new cvf::Part; + auto part = RivAnnotationTools::createPartFromPolyline( anchorLineColor, points ); part->setName( "RivTextAnnotationPartMgr" ); - part->setDrawable( drawableGeo.p() ); - - caf::MeshEffectGenerator colorEffgen( anchorLineColor ); - cvf::ref eff = colorEffgen.generateUnCachedEffect(); - - part->setEffect( eff.p() ); - part->setPriority( RivPartPriority::PartType::MeshLines ); part->setSourceInfo( new RivObjectSourceInfo( rimAnnotation() ) ); m_linePart = part; @@ -116,30 +107,14 @@ void RivTextAnnotationPartMgr::buildParts( const caf::DisplayCoordTransform* dis // Text part { - auto font = RiaFontCache::getFont( fontSize ); - cvf::ref 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 ); + auto font = RiaFontCache::getFont( fontSize ); - cvf::String cvfString = cvfqt::Utils::toString( text ); + auto drawableText = + RivAnnotationTools::createDrawableText( font.p(), fontColor, backgroundColor, text.toStdString(), cvf::Vec3f( labelPosition ) ); - cvf::Vec3f textCoord( labelPosition ); - drawableText->addText( cvfString, textCoord ); - - cvf::ref part = new cvf::Part; + auto part = RivAnnotationTools::createPart( drawableText.p() ); + cvf::String cvfString = cvfqt::Utils::toString( text ); part->setName( "RivTextAnnotationPartMgr: " + cvfString ); - part->setDrawable( drawableText.p() ); - - cvf::ref eff = new cvf::Effect(); - part->setEffect( eff.p() ); - part->setPriority( RivPartPriority::PartType::MeshLines ); m_labelPart = part; } diff --git a/ApplicationLibCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellHeadPartMgr.cpp index 83bbccdacc..dd911735fb 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -290,20 +290,13 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ // well disk labels are preferred since they have more info. if ( well->showWellLabel() && !well->name().isEmpty() && !well->showWellDisks() ) { - cvf::Font* font = RiaGuiApplication::instance()->defaultWellLabelFont(); - - cvf::ref drawableText = new cvf::DrawableText; - drawableText->setFont( font ); - drawableText->setCheckPosVisible( false ); - drawableText->setDrawBorder( false ); - drawableText->setDrawBackground( false ); - drawableText->setVerticalAlignment( cvf::TextDrawer::CENTER ); - drawableText->setTextColor( simWellInViewCollection()->wellLabelColor() ); - + cvf::Font* font = RiaGuiApplication::instance()->defaultWellLabelFont(); cvf::String cvfString = cvfqt::Utils::toString( m_rimWell->name() ); - cvf::Vec3f textCoord( textPosition ); - drawableText->addText( cvfString, textCoord ); + auto drawableText = RivAnnotationTools::createDrawableTextNoBackground( font, + simWellInViewCollection()->wellLabelColor(), + m_rimWell->name().toStdString(), + cvf::Vec3f( textPosition ) ); cvf::ref part = new cvf::Part; part->setName( "RivWellHeadPartMgr: text " + cvfString ); @@ -314,7 +307,7 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ part->setEffect( eff.p() ); part->setPriority( RivPartPriority::PartType::Text ); - part->setSourceInfo( new RivTextLabelSourceInfo( m_rimWell, cvfString, textCoord ) ); + part->setSourceInfo( new RivTextLabelSourceInfo( m_rimWell, cvfString, cvf::Vec3f( textPosition ) ) ); m_wellHeadLabelPart = part; } diff --git a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp index 80ffedb372..5d5654a5aa 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -737,21 +737,13 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d { cvf::Font* font = RiaGuiApplication::instance()->defaultWellLabelFont(); - cvf::ref drawableText = new cvf::DrawableText; - drawableText->setFont( font ); - drawableText->setCheckPosVisible( false ); - drawableText->setDrawBorder( false ); - drawableText->setDrawBackground( false ); - drawableText->setVerticalAlignment( cvf::TextDrawer::CENTER ); - drawableText->setTextColor( wellPathCollection->wellPathLabelColor() ); - - cvf::String cvfString = cvfqt::Utils::toString( m_rimWellPath->name() ); - - cvf::Vec3f textCoord( textPosition ); - drawableText->addText( cvfString, textCoord ); + auto drawableText = RivAnnotationTools::createDrawableTextNoBackground( font, + wellPathCollection->wellPathLabelColor(), + m_rimWellPath->name().toStdString(), + cvf::Vec3f( textPosition ) ); cvf::ref part = new cvf::Part; - part->setName( "RivWellHeadPartMgr: text " + cvfString ); + part->setName( "RivWellHeadPartMgr: text " + m_rimWellPath->name().toStdString() ); part->setDrawable( drawableText.p() ); cvf::ref eff = new cvf::Effect; @@ -759,7 +751,7 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d part->setEffect( eff.p() ); part->setPriority( RivPartPriority::Text ); - part->setSourceInfo( new RivTextLabelSourceInfo( m_rimWellPath, cvfString, textCoord ) ); + part->setSourceInfo( new RivTextLabelSourceInfo( m_rimWellPath, m_rimWellPath->name().toStdString(), cvf::Vec3f( textPosition ) ) ); m_wellLabelPart = part; } diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 35f88eb8b9..a77b2bb647 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev") # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -set(RESINSIGHT_DEV_VERSION ".05") +set(RESINSIGHT_DEV_VERSION ".06") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")