Skip to content

Commit

Permalink
Use more from annotation tools
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 13, 2023
1 parent 13d26a8 commit 92b4840
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 56 deletions.
26 changes: 7 additions & 19 deletions ApplicationLibCode/ModelVisualization/Faults/RivFaultPartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,44 +581,32 @@ void RivFaultPartMgr::createLabelWithAnchorLine( const cvf::Part* part )

cvf::Font* font = app->defaultWellLabelFont();

cvf::ref<cvf::DrawableText> 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<RimFaultInViewCollection>();
if ( parentObject )
{
auto parentObject = m_rimFault->firstAncestorOrThisOfType<RimFaultInViewCollection>();
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<cvf::Part> labelPart = new cvf::Part;
labelPart->setName( "RivFaultPart : text " + cvfString );
labelPart->setName( "RivFaultPart : text " + m_rimFault->name().toStdString() );
labelPart->setDrawable( drawableText.p() );

cvf::ref<cvf::Effect> eff = new cvf::Effect;

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;
}
Expand Down
31 changes: 26 additions & 5 deletions ApplicationLibCode/ModelVisualization/RivAnnotationTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ void RivAnnotationTools::addAnnotationLabels( const cvf::Collection<cvf::Part>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableText> RivAnnotationTools::createDrawableText( cvf::Font* font,
cvf::Color3f textColor,
cvf::Color3f backgroundColor,
const std::string& text,
const cvf::Vec3f& position )
cvf::ref<cvf::DrawableText> 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;

Expand All @@ -386,6 +386,27 @@ cvf::ref<cvf::DrawableText> RivAnnotationTools::createDrawableText( cvf::Font*
return drawableText;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableText> RivAnnotationTools::createDrawableTextNoBackground( cvf::Font* font,
const cvf::Color3f& textColor,
const std::string& text,
const cvf::Vec3f& position )
{
cvf::ref<cvf::DrawableText> 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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions ApplicationLibCode/ModelVisualization/RivAnnotationTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ class RivAnnotationTools

static cvf::ref<cvf::Part> createPartFromPolyline( const cvf::Color3f& color, const std::vector<cvf::Vec3d>& polyLine );

static cvf::ref<cvf::DrawableText> createDrawableText( cvf::Font* font,
cvf::Color3f textColor,
cvf::Color3f backgroundColor,
const std::string& text,
const cvf::Vec3f& position );
static cvf::ref<cvf::DrawableText> createDrawableText( cvf::Font* font,
const cvf::Color3f& textColor,
const cvf::Color3f& backgroundColor,
const std::string& text,
const cvf::Vec3f& position );

static cvf::ref<cvf::DrawableText>
createDrawableTextNoBackground( cvf::Font* font, const cvf::Color3f& textColor, const std::string& text, const cvf::Vec3f& position );

static cvf::ref<cvf::Part> createPart( cvf::DrawableText* drawableText );

Expand Down
19 changes: 6 additions & 13 deletions ApplicationLibCode/ModelVisualization/RivWellHeadPartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cvf::DrawableText> 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<cvf::Part> part = new cvf::Part;
part->setName( "RivWellHeadPartMgr: text " + cvfString );
Expand All @@ -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;
}
Expand Down
20 changes: 6 additions & 14 deletions ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,29 +737,21 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d
{
cvf::Font* font = RiaGuiApplication::instance()->defaultWellLabelFont();

cvf::ref<cvf::DrawableText> 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<cvf::Part> part = new cvf::Part;
part->setName( "RivWellHeadPartMgr: text " + cvfString );
part->setName( "RivWellHeadPartMgr: text " + m_rimWellPath->name().toStdString() );
part->setDrawable( drawableText.p() );

cvf::ref<cvf::Effect> eff = new cvf::Effect;

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;
}
Expand Down

0 comments on commit 92b4840

Please sign in to comment.