Skip to content

Commit

Permalink
Add annotation label data structures
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 12, 2023
1 parent eb47e4c commit 3b7f871
Show file tree
Hide file tree
Showing 5 changed files with 659 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ApplicationLibCode/ModelVisualization/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.h
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationSourceInfo.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -113,6 +115,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationSourceInfo.cpp
)

list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand Down
115 changes: 115 additions & 0 deletions ApplicationLibCode/ModelVisualization/RivAnnotationSourceInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// 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 "RivAnnotationSourceInfo.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivAnnotationSourceInfo::RivAnnotationSourceInfo( const std::string& text, const std::vector<cvf::Vec3d>& displayCoords )
: m_text( text )
, m_showColor( false )
, m_color( cvf::Color3f( cvf::Color3f::BLACK ) )
, m_labelPositionHint( RivAnnotationTools::LabelPositionStrategy::RIGHT )
, m_anchorPointsInDisplayCoords( displayCoords )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivAnnotationSourceInfo::RivAnnotationSourceInfo( const std::vector<std::string>& texts, const std::vector<cvf::Vec3d>& displayCoords )
: m_showColor( false )
, m_color( cvf::Color3f( cvf::Color3f::BLACK ) )
, m_labelPositionHint( RivAnnotationTools::LabelPositionStrategy::COUNT_HINT )
, m_anchorPointsInDisplayCoords( displayCoords )
, m_texts( texts )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivAnnotationTools::LabelPositionStrategy RivAnnotationSourceInfo::labelPositionStrategyHint() const
{
return m_labelPositionHint;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivAnnotationSourceInfo::setLabelPositionStrategyHint( RivAnnotationTools::LabelPositionStrategy strategy )
{
m_labelPositionHint = strategy;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RivAnnotationSourceInfo::text() const
{
return m_text;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RivAnnotationSourceInfo::texts() const
{
return m_texts;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RivAnnotationSourceInfo::anchorPointsInDisplayCoords() const
{
return m_anchorPointsInDisplayCoords;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivAnnotationSourceInfo::showColor() const
{
return m_showColor;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivAnnotationSourceInfo::setShowColor( bool showColor )
{
m_showColor = showColor;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RivAnnotationSourceInfo::color() const
{
return m_color;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivAnnotationSourceInfo::setColor( const cvf::Color3f& color )
{
m_color = color;
}
60 changes: 60 additions & 0 deletions ApplicationLibCode/ModelVisualization/RivAnnotationSourceInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "RivAnnotationTools.h"

#include "cvfObject.h"
#include "cvfVector3.h"

//==================================================================================================
///
///
//==================================================================================================
class RivAnnotationSourceInfo : public cvf::Object
{
public:
// Construct an object used to display a single text that can be positioned at several candidate positions. Can be used to display a
// label for a long and narrow structure like a surface intersection line.
RivAnnotationSourceInfo( const std::string& text, const std::vector<cvf::Vec3d>& displayCoords );

// Construct an object used to display a text at a single position. Can be used to display measured depth as labels along a well path.
RivAnnotationSourceInfo( const std::vector<std::string>& texts, const std::vector<cvf::Vec3d>& displayCoords );

RivAnnotationTools::LabelPositionStrategy labelPositionStrategyHint() const;
void setLabelPositionStrategyHint( RivAnnotationTools::LabelPositionStrategy strategy );

std::string text() const;
std::vector<std::string> texts() const;
std::vector<cvf::Vec3d> anchorPointsInDisplayCoords() const;

bool showColor() const;
void setShowColor( bool showColor );

cvf::Color3f color() const;
void setColor( const cvf::Color3f& color );

private:
std::string m_text;
bool m_showColor;
cvf::Color3f m_color;
RivAnnotationTools::LabelPositionStrategy m_labelPositionHint;
std::vector<cvf::Vec3d> m_anchorPointsInDisplayCoords;
std::vector<std::string> m_texts;
};
Loading

0 comments on commit 3b7f871

Please sign in to comment.