mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Remove duplicated code
* Use annotation tools from part manager * Set version to 2023.06.01-dev.06
This commit is contained in:
parent
f4c61c9edb
commit
c22b8b2e1f
@ -581,36 +581,24 @@ 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;
|
||||
@ -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;
|
||||
}
|
||||
|
@ -88,15 +88,12 @@ void RivAnnotationTools::setCountHint( int countHint )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Part> RivAnnotationTools::createPartFromPolyline( const std::string& partName,
|
||||
const cvf::Color3f& color,
|
||||
const std::vector<cvf::Vec3d>& polyLine )
|
||||
cvf::ref<cvf::Part> RivAnnotationTools::createPartFromPolyline( const cvf::Color3f& color, const std::vector<cvf::Vec3d>& polyLine )
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( polyLine );
|
||||
if ( drawableGeo.isNull() ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::Part> 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<cvf::Part>&
|
||||
std::vector<cvf::Vec3d> 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::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;
|
||||
|
||||
@ -387,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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -60,14 +60,16 @@ public:
|
||||
// Create labels for the given collection of parts. The labels are added to the given model.
|
||||
void addAnnotationLabels( const cvf::Collection<cvf::Part>& partCollection, const cvf::Camera* camera, cvf::ModelBasicList* model );
|
||||
|
||||
static cvf::ref<cvf::Part>
|
||||
createPartFromPolyline( const std::string& partName, const cvf::Color3f& color, const std::vector<cvf::Vec3d>& polyLine );
|
||||
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 );
|
||||
|
||||
|
@ -98,17 +98,8 @@ void RivTextAnnotationPartMgr::buildParts( const caf::DisplayCoordTransform* dis
|
||||
{
|
||||
std::vector<cvf::Vec3d> points = { anchorPosition, labelPosition };
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( points );
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
auto part = RivAnnotationTools::createPartFromPolyline( anchorLineColor, points );
|
||||
part->setName( "RivTextAnnotationPartMgr" );
|
||||
part->setDrawable( drawableGeo.p() );
|
||||
|
||||
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() ) );
|
||||
|
||||
m_linePart = part;
|
||||
@ -116,30 +107,14 @@ void RivTextAnnotationPartMgr::buildParts( const caf::DisplayCoordTransform* dis
|
||||
|
||||
// Text part
|
||||
{
|
||||
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 );
|
||||
auto font = RiaFontCache::getFont( fontSize );
|
||||
|
||||
auto drawableText =
|
||||
RivAnnotationTools::createDrawableText( font.p(), fontColor, backgroundColor, text.toStdString(), cvf::Vec3f( labelPosition ) );
|
||||
|
||||
auto part = RivAnnotationTools::createPart( drawableText.p() );
|
||||
cvf::String cvfString = cvfqt::Utils::toString( text );
|
||||
|
||||
cvf::Vec3f textCoord( labelPosition );
|
||||
drawableText->addText( cvfString, textCoord );
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
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 );
|
||||
|
||||
m_labelPart = part;
|
||||
}
|
||||
|
@ -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 );
|
||||
@ -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;
|
||||
}
|
||||
|
@ -737,21 +737,13 @@ 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;
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user