mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3789 Annotations. Text appearance settings. New FontCache class
This commit is contained in:
@@ -11,6 +11,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiaFontCache.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -26,6 +27,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiaFontCache.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
|||||||
55
ApplicationCode/Application/RiaFontCache.cpp
Normal file
55
ApplicationCode/Application/RiaFontCache.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Statoil 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 "RiaFontCache.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::map<RiaFontCache::FontSize, cvf::ref<caf::FixedAtlasFont>> RiaFontCache::ms_fonts;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont(FontSize size)
|
||||||
|
{
|
||||||
|
if (ms_fonts.count(size) == 0)
|
||||||
|
{
|
||||||
|
auto newFont = new caf::FixedAtlasFont(mapToAtlasFontSize(size));
|
||||||
|
ms_fonts.insert(std::make_pair(size, newFont));
|
||||||
|
}
|
||||||
|
return ms_fonts[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
caf::FixedAtlasFont::FontSize RiaFontCache::mapToAtlasFontSize(FontSize fontSize)
|
||||||
|
{
|
||||||
|
switch (fontSize)
|
||||||
|
{
|
||||||
|
case FONT_SIZE_8: return caf::FixedAtlasFont::POINT_SIZE_8;
|
||||||
|
case FONT_SIZE_10: return caf::FixedAtlasFont::POINT_SIZE_10;
|
||||||
|
case FONT_SIZE_12: return caf::FixedAtlasFont::POINT_SIZE_12;
|
||||||
|
case FONT_SIZE_14: return caf::FixedAtlasFont::POINT_SIZE_14;
|
||||||
|
case FONT_SIZE_16: return caf::FixedAtlasFont::POINT_SIZE_16;
|
||||||
|
case FONT_SIZE_24: return caf::FixedAtlasFont::POINT_SIZE_24;
|
||||||
|
case FONT_SIZE_32: return caf::FixedAtlasFont::POINT_SIZE_32;
|
||||||
|
default: return caf::FixedAtlasFont::POINT_SIZE_16;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
ApplicationCode/Application/RiaFontCache.h
Normal file
51
ApplicationCode/Application/RiaFontCache.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Statoil 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 <cvfBase.h>
|
||||||
|
#include <cafFixedAtlasFont.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
class RimSummaryCaseCollection;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RiaFontCache
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum FontSize
|
||||||
|
{
|
||||||
|
FONT_SIZE_8,
|
||||||
|
FONT_SIZE_10,
|
||||||
|
FONT_SIZE_12,
|
||||||
|
FONT_SIZE_14,
|
||||||
|
FONT_SIZE_16,
|
||||||
|
FONT_SIZE_24,
|
||||||
|
FONT_SIZE_32
|
||||||
|
};
|
||||||
|
|
||||||
|
static cvf::ref<caf::FixedAtlasFont> getFont(FontSize size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static caf::FixedAtlasFont::FontSize mapToAtlasFontSize(FontSize fontSize);
|
||||||
|
|
||||||
|
static std::map<FontSize, cvf::ref<caf::FixedAtlasFont>> ms_fonts;
|
||||||
|
};
|
||||||
@@ -25,10 +25,12 @@
|
|||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaBoundingBoxTools.h"
|
#include "RiaBoundingBoxTools.h"
|
||||||
#include "RiaColorTools.h"
|
#include "RiaColorTools.h"
|
||||||
|
#include "RiaFontCache.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include "Rim3dView.h"
|
#include "Rim3dView.h"
|
||||||
#include "RimAnnotationInViewCollection.h"
|
#include "RimAnnotationInViewCollection.h"
|
||||||
|
#include "RimAnnotationTextAppearance.h"
|
||||||
#include "RimTextAnnotation.h"
|
#include "RimTextAnnotation.h"
|
||||||
#include "RimTextAnnotationInView.h"
|
#include "RimTextAnnotationInView.h"
|
||||||
|
|
||||||
@@ -93,6 +95,11 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
|
|||||||
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
|
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
|
||||||
QString text = rimAnnotation()->text();
|
QString text = rimAnnotation()->text();
|
||||||
|
|
||||||
|
auto fontSize = rimAnnotation()->appearance()->fontSize();
|
||||||
|
auto fontColor = rimAnnotation()->appearance()->fontColor();
|
||||||
|
auto backgroundColor = rimAnnotation()->appearance()->backgroundColor();
|
||||||
|
auto anchorLineColor = rimAnnotation()->appearance()->anchorLineColor();
|
||||||
|
|
||||||
// Line part
|
// Line part
|
||||||
{
|
{
|
||||||
std::vector<cvf::Vec3d> points = { anchorPosition, labelPosition };
|
std::vector<cvf::Vec3d> points = { anchorPosition, labelPosition };
|
||||||
@@ -102,7 +109,7 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
|
|||||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||||
part->setDrawable(drawableGeo.p());
|
part->setDrawable(drawableGeo.p());
|
||||||
|
|
||||||
caf::MeshEffectGenerator colorEffgen(cvf::Color3f::BLACK);
|
caf::MeshEffectGenerator colorEffgen(anchorLineColor);
|
||||||
cvf::ref<cvf::Effect> eff = colorEffgen.generateUnCachedEffect();
|
cvf::ref<cvf::Effect> eff = colorEffgen.generateUnCachedEffect();
|
||||||
|
|
||||||
part->setEffect(eff.p());
|
part->setEffect(eff.p());
|
||||||
@@ -114,20 +121,17 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
|
|||||||
|
|
||||||
// Text part
|
// Text part
|
||||||
{
|
{
|
||||||
auto app = RiaApplication::instance();
|
auto font = RiaFontCache::getFont(fontSize);
|
||||||
cvf::Font* font = app->customFont();
|
|
||||||
auto prefs = app->preferences();
|
|
||||||
|
|
||||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||||
drawableText->setFont(font);
|
drawableText->setFont(font.p());
|
||||||
drawableText->setCheckPosVisible(false);
|
drawableText->setCheckPosVisible(false);
|
||||||
drawableText->setUseDepthBuffer(true);
|
drawableText->setUseDepthBuffer(true);
|
||||||
drawableText->setDrawBorder(true);
|
drawableText->setDrawBorder(true);
|
||||||
drawableText->setDrawBackground(true);
|
drawableText->setDrawBackground(true);
|
||||||
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
|
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
|
||||||
drawableText->setBackgroundColor(prefs->defaultViewerBackgroundColor);
|
drawableText->setBackgroundColor(backgroundColor);
|
||||||
drawableText->setBorderColor(RiaColorTools::computeOffsetColor(prefs->defaultViewerBackgroundColor, 0.3f));
|
drawableText->setBorderColor(RiaColorTools::computeOffsetColor(backgroundColor, 0.3f));
|
||||||
drawableText->setTextColor(cvf::Color3f::BLACK);
|
drawableText->setTextColor(fontColor);
|
||||||
|
|
||||||
cvf::String cvfString = cvfqt::Utils::toString(text);
|
cvf::String cvfString = cvfqt::Utils::toString(text);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.h
|
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.h
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.h
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationTextAppearance.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimLineBasedAnnotation.h
|
${CMAKE_CURRENT_LIST_DIR}/RimLineBasedAnnotation.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.h
|
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.h
|
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.h
|
||||||
@@ -28,6 +29,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationLineAppearance.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationTextAppearance.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimLineBasedAnnotation.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimLineBasedAnnotation.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotationInView.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotationInView.cpp
|
||||||
|
|||||||
@@ -17,44 +17,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RimAnnotationLineAppearance.h"
|
#include "RimAnnotationLineAppearance.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
|
||||||
#include "RiaColorTables.h"
|
|
||||||
#include "RiaLogging.h"
|
|
||||||
#include "RiaPreferences.h"
|
|
||||||
#include "RiaWellNameComparer.h"
|
|
||||||
|
|
||||||
#include "RigEclipseCaseData.h"
|
|
||||||
#include "RigMainGrid.h"
|
|
||||||
#include "RigWellPath.h"
|
|
||||||
|
|
||||||
#include "RimAnnotationInViewCollection.h"
|
|
||||||
#include "RimEclipseCase.h"
|
|
||||||
#include "RimEclipseCaseCollection.h"
|
|
||||||
#include "RimGridView.h"
|
|
||||||
#include "RimOilField.h"
|
|
||||||
#include "RimProject.h"
|
|
||||||
#include "RimWellLogFile.h"
|
|
||||||
#include "RimWellPath.h"
|
|
||||||
#include "RimPerforationCollection.h"
|
|
||||||
|
|
||||||
#include "Riu3DMainWindowTools.h"
|
|
||||||
|
|
||||||
#include "RifWellPathFormationsImporter.h"
|
|
||||||
#include "RifWellPathImporter.h"
|
|
||||||
|
|
||||||
#include "cafPdmUiEditorHandle.h"
|
|
||||||
#include "cafProgressInfo.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <fstream>
|
|
||||||
#include "RimFileWellPath.h"
|
|
||||||
#include "RimModeledWellPath.h"
|
|
||||||
#include "RimAnnotationCollection.h"
|
#include "RimAnnotationCollection.h"
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
STYLE_SOLID,
|
STYLE_SOLID,
|
||||||
STYLE_DASH
|
STYLE_DASH
|
||||||
};
|
};
|
||||||
typedef caf::AppEnum<LineStyleEnum> LineStyle;
|
using LineStyle = caf::AppEnum<LineStyleEnum>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RimAnnotationLineAppearance();
|
RimAnnotationLineAppearance();
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018- 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 "RimAnnotationTextAppearance.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
|
#include "RimAnnotationCollection.h"
|
||||||
|
#include "RimAnnotationInViewCollection.h"
|
||||||
|
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT(RimAnnotationTextAppearance, "RimAnnotationTextAppearance");
|
||||||
|
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
void RimAnnotationTextAppearance::FontSize::setUp()
|
||||||
|
{
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_8, "FONT_SIZE_8", "8");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_10, "FONT_SIZE_10", "10");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_12, "FONT_SIZE_12", "12");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_14, "FONT_SIZE_14", "14");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_16, "FONT_SIZE_16", "16");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_24, "FONT_SIZE_24", "24");
|
||||||
|
addItem(RiaFontCache::FONT_SIZE_32, "FONT_SIZE_32", "32");
|
||||||
|
|
||||||
|
setDefault(RiaFontCache::FONT_SIZE_8);
|
||||||
|
}
|
||||||
|
} // namespace caf
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimAnnotationTextAppearance::RimAnnotationTextAppearance()
|
||||||
|
{
|
||||||
|
CAF_PDM_InitObject("TextAnnotation", ":/WellCollection.png", "", "");
|
||||||
|
|
||||||
|
auto prefs = RiaApplication::instance()->preferences();
|
||||||
|
auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor();
|
||||||
|
|
||||||
|
CAF_PDM_InitField(&m_fontSize, "FontSize", FontSize(), "Font Size", "", "", "");
|
||||||
|
CAF_PDM_InitField(&m_fontColor, "FontColor", cvf::Color3f(cvf::Color3f::BLACK), "Font Color", "", "", "");
|
||||||
|
CAF_PDM_InitField(&m_backgroundColor, "BackgroundColor", defaultBackgroundColor , "Background Color", "", "", "");
|
||||||
|
CAF_PDM_InitField(&m_anchorLineColor, "AnchorLineColor", cvf::Color3f(cvf::Color3f::BLACK), "Anchor Line Color", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::setFontSize(FontSize size)
|
||||||
|
{
|
||||||
|
m_fontSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::setFontColor(const cvf::Color3f& newColor)
|
||||||
|
{
|
||||||
|
m_fontColor = newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::setBackgroundColor(const cvf::Color3f& newColor)
|
||||||
|
{
|
||||||
|
m_backgroundColor = newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::setAnchorLineColor(const cvf::Color3f& newColor)
|
||||||
|
{
|
||||||
|
m_anchorLineColor = newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimAnnotationTextAppearance::FontSize RimAnnotationTextAppearance::fontSize() const
|
||||||
|
{
|
||||||
|
return m_fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::Color3f RimAnnotationTextAppearance::fontColor() const
|
||||||
|
{
|
||||||
|
return m_fontColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::Color3f RimAnnotationTextAppearance::backgroundColor() const
|
||||||
|
{
|
||||||
|
return m_backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::Color3f RimAnnotationTextAppearance::anchorLineColor() const
|
||||||
|
{
|
||||||
|
return m_anchorLineColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||||
|
{
|
||||||
|
uiOrdering.add(&m_fontSize);
|
||||||
|
uiOrdering.add(&m_fontColor);
|
||||||
|
uiOrdering.add(&m_backgroundColor);
|
||||||
|
uiOrdering.add(&m_anchorLineColor);
|
||||||
|
|
||||||
|
uiOrdering.skipRemainingFields(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnnotationTextAppearance::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||||
|
const QVariant& oldValue,
|
||||||
|
const QVariant& newValue)
|
||||||
|
{
|
||||||
|
RimAnnotationCollectionBase* annColl = nullptr;
|
||||||
|
this->firstAncestorOrThisOfTypeAsserted(annColl);
|
||||||
|
|
||||||
|
if (annColl)
|
||||||
|
{
|
||||||
|
annColl->scheduleRedrawOfRelevantViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018- 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 "RiaFontCache.h"
|
||||||
|
|
||||||
|
#include "cafPdmObject.h"
|
||||||
|
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
#include "cafAppEnum.h"
|
||||||
|
|
||||||
|
#include "cafPdmFieldCvfColor.h"
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RimAnnotationTextAppearance : public caf::PdmObject
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using FontSize = caf::AppEnum<RiaFontCache::FontSize>;
|
||||||
|
|
||||||
|
RimAnnotationTextAppearance();
|
||||||
|
|
||||||
|
void setFontSize(FontSize size);
|
||||||
|
void setFontColor(const cvf::Color3f& newColor);
|
||||||
|
void setBackgroundColor(const cvf::Color3f& newColor);
|
||||||
|
void setAnchorLineColor(const cvf::Color3f& newColor);
|
||||||
|
|
||||||
|
FontSize fontSize() const;
|
||||||
|
cvf::Color3f fontColor() const;
|
||||||
|
cvf::Color3f backgroundColor() const;
|
||||||
|
cvf::Color3f anchorLineColor() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
|
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
caf::PdmField<FontSize> m_fontSize;
|
||||||
|
caf::PdmField<cvf::Color3f> m_fontColor;
|
||||||
|
caf::PdmField<cvf::Color3f> m_backgroundColor;
|
||||||
|
caf::PdmField<cvf::Color3f> m_anchorLineColor;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimAnnotationCollection.h"
|
#include "RimAnnotationCollection.h"
|
||||||
#include "RimAnnotationGroupCollection.h"
|
#include "RimAnnotationGroupCollection.h"
|
||||||
|
#include "RimAnnotationTextAppearance.h"
|
||||||
|
|
||||||
#include "AnnotationCommands/RicTextAnnotation3dEditor.h"
|
#include "AnnotationCommands/RicTextAnnotation3dEditor.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +47,8 @@ RimTextAnnotation::RimTextAnnotation()
|
|||||||
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Is Active", "", "", "");
|
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Is Active", "", "", "");
|
||||||
m_isActive.uiCapability()->setUiHidden(true);
|
m_isActive.uiCapability()->setUiHidden(true);
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_textAppearance, "TextAppearance", "Text Appearance", "", "", "");
|
||||||
|
m_textAppearance = new RimAnnotationTextAppearance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -118,6 +122,9 @@ void RimTextAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
|
|||||||
uiOrdering.add(&m_labelPointXyd);
|
uiOrdering.add(&m_labelPointXyd);
|
||||||
uiOrdering.add(&m_text);
|
uiOrdering.add(&m_text);
|
||||||
|
|
||||||
|
auto appearanceGroup = uiOrdering.addNewGroup("Text Appearance");
|
||||||
|
m_textAppearance->uiOrdering(uiConfigName, *appearanceGroup);
|
||||||
|
|
||||||
uiOrdering.skipRemainingFields(true);
|
uiOrdering.skipRemainingFields(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +171,14 @@ bool RimTextAnnotation::isVisible() const
|
|||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimAnnotationTextAppearance* RimTextAnnotation::appearance() const
|
||||||
|
{
|
||||||
|
return m_textAppearance();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
class RimGridView;
|
class RimGridView;
|
||||||
|
class RimAnnotationTextAppearance;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@@ -64,6 +64,8 @@ public:
|
|||||||
bool isActive();
|
bool isActive();
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
|
RimAnnotationTextAppearance* appearance() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||||
@@ -78,5 +80,6 @@ friend class RicTextAnnotation3dEditor;
|
|||||||
caf::PdmField<QString> m_text;
|
caf::PdmField<QString> m_text;
|
||||||
caf::PdmField<bool> m_isActive;
|
caf::PdmField<bool> m_isActive;
|
||||||
|
|
||||||
|
caf::PdmChildField<RimAnnotationTextAppearance*> m_textAppearance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user