#3948 HoloLens labels : Add text label source info

This commit is contained in:
Magne Sjaastad 2019-01-15 10:53:54 +01:00
parent 6695cf2a39
commit 5222950476
8 changed files with 144 additions and 44 deletions

View File

@ -55,6 +55,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivTextLabelSourceInfo.h
) )
set (SOURCE_GROUP_SOURCE_FILES set (SOURCE_GROUP_SOURCE_FILES
@ -108,6 +109,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivTextLabelSourceInfo.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -35,6 +35,7 @@
#include "RimTernaryLegendConfig.h" #include "RimTernaryLegendConfig.h"
#include "RivFaultGeometryGenerator.h" #include "RivFaultGeometryGenerator.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivNNCGeometryGenerator.h" #include "RivNNCGeometryGenerator.h"
#include "RivPartPriority.h" #include "RivPartPriority.h"
#include "RivResultToTextureMapper.h" #include "RivResultToTextureMapper.h"
@ -42,9 +43,9 @@
#include "RivSourceInfo.h" #include "RivSourceInfo.h"
#include "RivTernaryScalarMapper.h" #include "RivTernaryScalarMapper.h"
#include "RivTernaryTextureCoordsCreator.h" #include "RivTernaryTextureCoordsCreator.h"
#include "RivTextLabelSourceInfo.h"
#include "RivTextureCoordsCreator.h" #include "RivTextureCoordsCreator.h"
#include "RivMeshLinesSourceInfo.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfDrawableText.h" #include "cvfDrawableText.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
@ -520,6 +521,8 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
labelPart->setEffect(eff.p()); labelPart->setEffect(eff.p());
labelPart->setPriority(RivPartPriority::PartType::Text); labelPart->setPriority(RivPartPriority::PartType::Text);
labelPart->setSourceInfo(new RivTextLabelSourceInfo(m_rimFault, cvfString, textCoord));
m_faultLabelPart = labelPart; m_faultLabelPart = labelPart;
} }

View File

@ -3,23 +3,21 @@
// Copyright (C) 2011- Statoil ASA // Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS // Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS // Copyright (C) 2011-2012 Ceetron AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // 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. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RivMeasurementPartMgr.h" #include "RivMeasurementPartMgr.h"
#include "RiaApplication.h" #include "RiaApplication.h"
@ -30,44 +28,43 @@
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h" #include "RimAnnotationInViewCollection.h"
#include "RimProject.h"
#include "RimMeasurement.h" #include "RimMeasurement.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RimPolylinesFromFileAnnotationInView.h" #include "RimPolylinesFromFileAnnotationInView.h"
#include "RimProject.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RivTextAnnotationPartMgr.h" #include "RivPartPriority.h"
#include "RivReachCircleAnnotationPartMgr.h"
#include "RivPolylineAnnotationPartMgr.h" #include "RivPolylineAnnotationPartMgr.h"
#include "RivPolylineGenerator.h" #include "RivPolylineGenerator.h"
#include "RivPartPriority.h" #include "RivReachCircleAnnotationPartMgr.h"
#include "RivTextAnnotationPartMgr.h"
#include "RivTextLabelSourceInfo.h"
#include <cvfModelBasicList.h> #include "cvfBoundingBox.h"
#include <cvfPart.h> #include "cvfDrawableGeo.h"
#include <cvfDrawableGeo.h> #include "cvfDrawableText.h"
#include <cvfDrawableText.h> #include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRenderStateDepth.h" #include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h" #include "cvfRenderStatePoint.h"
#include "cvfBoundingBox.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivMeasurementPartMgr::RivMeasurementPartMgr(Rim3dView* view) RivMeasurementPartMgr::RivMeasurementPartMgr(Rim3dView* view)
: m_rimView(view), m_measurement(nullptr) : m_rimView(view)
, m_measurement(nullptr)
{ {
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivMeasurementPartMgr::~RivMeasurementPartMgr() RivMeasurementPartMgr::~RivMeasurementPartMgr() {}
{
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -106,11 +103,11 @@ void RivMeasurementPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList*
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::clearGeometryCache() void RivMeasurementPartMgr::clearGeometryCache()
{ {
m_linePart = nullptr; m_linePart = nullptr;
m_pointPart = nullptr; m_pointPart = nullptr;
m_labelPart = nullptr; m_labelPart = nullptr;
} }
@ -177,15 +174,15 @@ void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform*
} }
// Text label // Text label
if(pointsInDisplay.size() > 1) if (pointsInDisplay.size() > 1)
{ {
auto fontSize = RiaFontCache::FONT_SIZE_8; auto fontSize = RiaFontCache::FONT_SIZE_8;
auto backgroundColor = RiaApplication::instance()->preferences()->defaultViewerBackgroundColor; auto backgroundColor = RiaApplication::instance()->preferences()->defaultViewerBackgroundColor;
auto fontColor = cvf::Color3f::BLACK; auto fontColor = cvf::Color3f::BLACK;
QString text = m_measurement->label(); QString text = m_measurement->label();
auto labelPosition = pointsInDisplay.back(); auto labelPosition = pointsInDisplay.back();
auto font = RiaFontCache::getFont(fontSize); auto font = RiaFontCache::getFont(fontSize);
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText; cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(font.p()); drawableText->setFont(font.p());
drawableText->setCheckPosVisible(false); drawableText->setCheckPosVisible(false);
@ -209,6 +206,8 @@ void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform*
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::Text); part->setPriority(RivPartPriority::PartType::Text);
part->setSourceInfo(new RivTextLabelSourceInfo(m_measurement, cvfString, textCoord));
m_labelPart = part; m_labelPart = part;
} }
} }

View File

@ -34,18 +34,20 @@
#include "RimTextAnnotation.h" #include "RimTextAnnotation.h"
#include "RimTextAnnotationInView.h" #include "RimTextAnnotationInView.h"
#include "RivPolylineGenerator.h" #include "RivObjectSourceInfo.h"
#include "RivPartPriority.h" #include "RivPartPriority.h"
#include "RivPolylineGenerator.h"
#include "RivTextAnnotationSourceInfo.h" #include "RivTextAnnotationSourceInfo.h"
#include "RivTextLabelSourceInfo.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfDrawableText.h" #include "cvfDrawableText.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "cafDisplayCoordTransform.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -83,8 +85,6 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
{ {
clearAllGeometry(); clearAllGeometry();
cvf::ref<RivTextAnnotationSourceInfo> sourceInfo = new RivTextAnnotationSourceInfo(rimAnnotation());
auto collection = annotationCollection(); auto collection = annotationCollection();
if (!collection) return; if (!collection) return;
@ -114,7 +114,7 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::MeshLines); part->setPriority(RivPartPriority::PartType::MeshLines);
part->setSourceInfo(sourceInfo.p()); part->setSourceInfo(new RivObjectSourceInfo(rimAnnotation()));
m_linePart = part; m_linePart = part;
} }
@ -145,7 +145,8 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
cvf::ref<cvf::Effect> eff = new cvf::Effect(); cvf::ref<cvf::Effect> eff = new cvf::Effect();
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::MeshLines); part->setPriority(RivPartPriority::PartType::MeshLines);
part->setSourceInfo(sourceInfo.p());
part->setSourceInfo(new RivTextLabelSourceInfo(rimAnnotation(), cvfString, textCoord));
m_labelPart = part; m_labelPart = part;
} }

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RivTextLabelSourceInfo.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextLabelSourceInfo::RivTextLabelSourceInfo(caf::PdmObject* pdmObject, const cvf::String& text, const cvf::Vec3f& position)
: RivObjectSourceInfo(pdmObject)
, m_text(text)
, m_position(position)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String RivTextLabelSourceInfo::text() const
{
return m_text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RivTextLabelSourceInfo::textPosition() const
{
return m_position;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RivObjectSourceInfo.h"
#include "cvfArray.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfString.h"
//==================================================================================================
///
///
//==================================================================================================
class RivTextLabelSourceInfo : public RivObjectSourceInfo
{
public:
explicit RivTextLabelSourceInfo(caf::PdmObject* pdmObject, const cvf::String& text, const cvf::Vec3f& position);
cvf::String text() const;
cvf::Vec3f textPosition() const;
private:
cvf::String m_text;
cvf::Vec3f m_position;
};

View File

@ -35,11 +35,14 @@
#include "RimSimWellInViewCollection.h" #include "RimSimWellInViewCollection.h"
#include "RimSimWellInView.h" #include "RimSimWellInView.h"
#include "RivPipeGeometryGenerator.h"
#include "RivPartPriority.h" #include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h"
#include "RivSectionFlattner.h"
#include "RivSimWellPipeSourceInfo.h" #include "RivSimWellPipeSourceInfo.h"
#include "RivTextLabelSourceInfo.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cvfArrowGenerator.h" #include "cvfArrowGenerator.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
@ -49,8 +52,6 @@
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfTransform.h" #include "cvfTransform.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "cafDisplayCoordTransform.h"
#include "RivSectionFlattner.h"
@ -319,7 +320,8 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex,
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::Text); part->setPriority(RivPartPriority::PartType::Text);
part->setSourceInfo(sourceInfo.p());
part->setSourceInfo(new RivTextLabelSourceInfo(m_rimWell, cvfString, textCoord));
m_wellHeadLabelPart = part; m_wellHeadLabelPart = part;
} }

View File

@ -56,6 +56,7 @@
#include "RivWellFracturePartMgr.h" #include "RivWellFracturePartMgr.h"
#include "RivWellPathPartMgr.h" #include "RivWellPathPartMgr.h"
#include "RivWellPathSourceInfo.h" #include "RivWellPathSourceInfo.h"
#include "RivTextLabelSourceInfo.h"
#include "RiuViewer.h" #include "RiuViewer.h"
@ -635,6 +636,8 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setPriority(RivPartPriority::Text); part->setPriority(RivPartPriority::Text);
part->setSourceInfo(new RivTextLabelSourceInfo(m_rimWellPath, cvfString, textCoord));
m_wellLabelPart = part; m_wellLabelPart = part;
} }