mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4256 Update fonts in Project and views when changing preferences
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
#include "RimAnnotationTextAppearance.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCommandObject.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
@@ -70,6 +72,8 @@
|
||||
#include "RimSummaryCrossPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimTextAnnotation.h"
|
||||
#include "RimTextAnnotationInView.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
#include "RimWellLogFile.h"
|
||||
@@ -227,10 +231,6 @@ RiaApplication::RiaApplication(int& argc, char** argv)
|
||||
|
||||
setLastUsedDialogDirectory("MULTICASEIMPORT", "/");
|
||||
|
||||
// The creation of a font is time consuming, so make sure you really need your own font
|
||||
// instead of using the application font
|
||||
m_standardFont = RiaFontCache::getFont(RiaFontCache::FONT_SIZE_8);
|
||||
|
||||
m_recentFileActionProvider = std::unique_ptr<RiuRecentFileActionProvider>(new RiuRecentFileActionProvider);
|
||||
|
||||
// Create main windows
|
||||
@@ -1988,23 +1988,37 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
mainPlotWindow()->projectTreeView()->enableAppendOfClassNameToUiItemText(m_preferences->appendClassNameToUiText());
|
||||
}
|
||||
|
||||
RiaFontCache::FontSize fontSizeType = m_preferences->fontSizeInScene();
|
||||
m_customFont = RiaFontCache::getFont(fontSizeType);
|
||||
// The creation of a font is time consuming, so make sure you really need your own font
|
||||
// instead of using the application font
|
||||
RiaFontCache::FontSize sceneFontSize = m_preferences->defaultFontSizeInScene();
|
||||
m_defaultSceneFont = RiaFontCache::getFont(sceneFontSize);
|
||||
RiaFontCache::FontSize annotationFontSize = m_preferences->defaultAnnotationFontSize();
|
||||
m_defaultAnnotationFont = RiaFontCache::getFont(annotationFontSize);
|
||||
RiaFontCache::FontSize wellLabelFontSize = m_preferences->defaultWellLabelFontSize();
|
||||
m_defaultWellLabelFont = RiaFontCache::getFont(wellLabelFontSize);
|
||||
|
||||
if (this->project())
|
||||
{
|
||||
this->project()->setScriptDirectories(m_preferences->scriptDirectories());
|
||||
this->project()->updateConnectedEditors();
|
||||
|
||||
RimWellPathCollection* wellPathCollection = this->project()->activeOilField()->wellPathCollection();
|
||||
|
||||
std::vector<Rim3dView*> visibleViews;
|
||||
this->project()->allVisibleViews(visibleViews);
|
||||
|
||||
bool existingViewsWithCustomColors = false;
|
||||
bool existingViewsWithCustomZScale = false;
|
||||
bool existingViewsWithDifferentMeshLines = false;
|
||||
bool existingViewsWithCustomColors = false;
|
||||
bool existingViewsWithCustomZScale = false;
|
||||
bool existingObjectsWithCustomFonts = false;
|
||||
if (oldPreferences)
|
||||
{
|
||||
for (auto view : visibleViews)
|
||||
{
|
||||
if (view->meshMode() != oldPreferences->defaultMeshModeType())
|
||||
{
|
||||
existingViewsWithDifferentMeshLines = true;
|
||||
}
|
||||
if (view->backgroundColor() != oldPreferences->defaultViewerBackgroundColor())
|
||||
{
|
||||
existingViewsWithCustomColors = true;
|
||||
@@ -2014,6 +2028,12 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
existingViewsWithCustomZScale = true;
|
||||
}
|
||||
|
||||
RimGridView* gridView = dynamic_cast<RimGridView*>(view);
|
||||
if (gridView)
|
||||
{
|
||||
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultAnnotationFontSize();
|
||||
existingObjectsWithCustomFonts = gridView->annotationCollection()->hasTextAnnotationsWithCustomFontSize(oldFontSize);
|
||||
}
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(view);
|
||||
if (eclipseView)
|
||||
{
|
||||
@@ -2022,15 +2042,22 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
existingViewsWithCustomColors = true;
|
||||
}
|
||||
}
|
||||
if (wellPathCollection->wellPathLabelColor() != oldPreferences->defaultWellLabelColor())
|
||||
{
|
||||
existingViewsWithCustomColors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool applySettingsToAllViews = false;
|
||||
if (existingViewsWithCustomColors || existingViewsWithCustomZScale)
|
||||
if (existingViewsWithCustomColors || existingViewsWithCustomZScale ||
|
||||
existingViewsWithDifferentMeshLines || existingObjectsWithCustomFonts)
|
||||
{
|
||||
QStringList changedData;
|
||||
if (existingViewsWithDifferentMeshLines) changedData << "Mesh Visibility";
|
||||
if (existingViewsWithCustomColors) changedData << "Colors";
|
||||
if (existingViewsWithCustomZScale) changedData << "Z-Scale";
|
||||
if (existingObjectsWithCustomFonts) changedData << "Fonts Sizes";
|
||||
|
||||
QString listString = changedData.takeLast();
|
||||
if (!changedData.empty())
|
||||
@@ -2046,45 +2073,98 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
applySettingsToAllViews = (reply == QMessageBox::Ok);
|
||||
}
|
||||
|
||||
|
||||
std::set<caf::PdmUiItem*> uiEditorsToUpdate;
|
||||
|
||||
for (auto view : visibleViews)
|
||||
{
|
||||
std::set<caf::PdmUiItem*> uiItemsToUpdate;
|
||||
bool applyBackgroundOrFonts = false;
|
||||
|
||||
if (oldPreferences && (applySettingsToAllViews || view->meshMode() == oldPreferences->defaultMeshModeType()))
|
||||
{
|
||||
view->meshMode = m_preferences->defaultMeshModeType();
|
||||
}
|
||||
|
||||
if (oldPreferences && (applySettingsToAllViews || view->backgroundColor() == oldPreferences->defaultViewerBackgroundColor()))
|
||||
{
|
||||
view->setAndApplyBackgroundColor(m_preferences->defaultViewerBackgroundColor());
|
||||
uiItemsToUpdate.insert(view);
|
||||
view->setBackgroundColor(m_preferences->defaultViewerBackgroundColor());
|
||||
applyBackgroundOrFonts = true;
|
||||
uiEditorsToUpdate.insert(view);
|
||||
}
|
||||
|
||||
if (oldPreferences && (applySettingsToAllViews || view->scaleZ == static_cast<double>(oldPreferences->defaultScaleFactorZ())))
|
||||
{
|
||||
view->scaleZ = static_cast<double>(m_preferences->defaultScaleFactorZ());
|
||||
view->updateScaling();
|
||||
uiItemsToUpdate.insert(view);
|
||||
uiEditorsToUpdate.insert(view);
|
||||
if (view == activeViewWindow())
|
||||
{
|
||||
RiuMainWindow::instance()->updateScaleValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (oldPreferences && oldPreferences->defaultFontSizeInScene() != sceneFontSize)
|
||||
{
|
||||
applyBackgroundOrFonts = true;
|
||||
}
|
||||
|
||||
if (oldPreferences && oldPreferences->defaultAnnotationFontSize() != annotationFontSize)
|
||||
{
|
||||
RimGridView* gridView = dynamic_cast<RimGridView*>(view);
|
||||
if (gridView)
|
||||
{
|
||||
auto annotations = gridView->annotationCollection();
|
||||
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultAnnotationFontSize();
|
||||
bool applyFontSizes = applySettingsToAllViews ||
|
||||
!annotations->hasTextAnnotationsWithCustomFontSize(oldFontSize);
|
||||
|
||||
if (applyFontSizes)
|
||||
{
|
||||
annotations->applyFontSizeToAllTextAnnotations(annotationFontSize);
|
||||
for (auto annotation : annotations->globalTextAnnotations())
|
||||
{
|
||||
uiEditorsToUpdate.insert(annotation);
|
||||
}
|
||||
for (auto annotation : annotations->textAnnotations())
|
||||
{
|
||||
uiEditorsToUpdate.insert(annotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(view);
|
||||
if (eclipseView)
|
||||
{
|
||||
if (oldPreferences && (applySettingsToAllViews || eclipseView->wellCollection()->wellLabelColor() == oldPreferences->defaultWellLabelColor()))
|
||||
{
|
||||
eclipseView->wellCollection()->wellLabelColor = m_preferences->defaultWellLabelColor();
|
||||
uiItemsToUpdate.insert(eclipseView->wellCollection());
|
||||
uiEditorsToUpdate.insert(eclipseView->wellCollection());
|
||||
}
|
||||
eclipseView->scheduleReservoirGridGeometryRegen();
|
||||
}
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
|
||||
for (caf::PdmUiItem* uiItem : uiItemsToUpdate)
|
||||
if (applyBackgroundOrFonts)
|
||||
{
|
||||
uiItem->updateConnectedEditors();
|
||||
view->applyBackgroundColorAndFontChanges();
|
||||
}
|
||||
}
|
||||
|
||||
if (oldPreferences)
|
||||
{
|
||||
bool matchingColor = wellPathCollection->wellPathLabelColor() == oldPreferences->defaultWellLabelColor();
|
||||
if (applySettingsToAllViews || matchingColor)
|
||||
{
|
||||
wellPathCollection->wellPathLabelColor = oldPreferences->defaultWellLabelColor();
|
||||
uiEditorsToUpdate.insert(wellPathCollection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (caf::PdmUiItem* uiItem : uiEditorsToUpdate)
|
||||
{
|
||||
uiItem->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmUiItem::enableExtraDebugText(m_preferences->appendFieldKeywordToToolTipText());
|
||||
@@ -2255,24 +2335,34 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectF
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Font* RiaApplication::standardFont()
|
||||
cvf::Font* RiaApplication::defaultSceneFont()
|
||||
{
|
||||
CVF_ASSERT(m_standardFont.notNull());
|
||||
CVF_ASSERT(m_defaultSceneFont.notNull());
|
||||
|
||||
// The creation of a font is time consuming, so make sure you really need your own font
|
||||
// instead of using the application font
|
||||
|
||||
return m_standardFont.p();
|
||||
return m_defaultSceneFont.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Font* RiaApplication::customFont()
|
||||
cvf::Font* RiaApplication::defaultAnnotationFont()
|
||||
{
|
||||
CVF_ASSERT(m_customFont.notNull());
|
||||
CVF_ASSERT(m_defaultAnnotationFont.notNull());
|
||||
|
||||
return m_customFont.p();
|
||||
return m_defaultAnnotationFont.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Font* RiaApplication::defaultWellLabelFont()
|
||||
{
|
||||
CVF_ASSERT(m_defaultWellLabelFont.notNull());
|
||||
|
||||
return m_defaultWellLabelFont.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -169,8 +169,9 @@ public:
|
||||
RiaPreferences* preferences();
|
||||
void applyPreferences(const RiaPreferences* oldPreferences = nullptr);
|
||||
|
||||
cvf::Font* standardFont();
|
||||
cvf::Font* customFont();
|
||||
cvf::Font* defaultSceneFont();
|
||||
cvf::Font* defaultAnnotationFont();
|
||||
cvf::Font* defaultWellLabelFont();
|
||||
|
||||
QString commandLineParameterHelp() const;
|
||||
void showFormattedTextInMessageBox(const QString& text);
|
||||
@@ -254,8 +255,9 @@ private:
|
||||
std::map<QString, QString> m_fileDialogDefaultDirectories;
|
||||
QString m_startupDefaultDirectory;
|
||||
|
||||
cvf::ref<cvf::Font> m_standardFont;
|
||||
cvf::ref<cvf::Font> m_customFont;
|
||||
cvf::ref<cvf::Font> m_defaultSceneFont;
|
||||
cvf::ref<cvf::Font> m_defaultAnnotationFont;
|
||||
cvf::ref<cvf::Font> m_defaultWellLabelFont;
|
||||
|
||||
QMap<QString, QVariant> m_sessionCache; // Session cache used to store username/passwords per session
|
||||
|
||||
|
@@ -73,6 +73,15 @@ void caf::AppEnum<RiaDefines::WellPathComponentType>::setUp()
|
||||
addItem(RiaDefines::UNDEFINED_COMPONENT, "UNDEFINED", "Undefined Component");
|
||||
setDefault(RiaDefines::WELL_PATH);
|
||||
}
|
||||
|
||||
template<>
|
||||
void caf::AppEnum<RiaDefines::MeshModeType>::setUp()
|
||||
{
|
||||
addItem(RiaDefines::FULL_MESH, "FULL_MESH", "All");
|
||||
addItem(RiaDefines::FAULTS_MESH, "FAULTS_MESH", "Faults only");
|
||||
addItem(RiaDefines::NO_MESH, "NO_MESH", "None");
|
||||
setDefault(RiaDefines::FULL_MESH);
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -59,6 +59,13 @@ namespace RiaDefines
|
||||
UNDEFINED_COMPONENT
|
||||
};
|
||||
|
||||
enum MeshModeType
|
||||
{
|
||||
FULL_MESH,
|
||||
FAULTS_MESH,
|
||||
NO_MESH
|
||||
};
|
||||
|
||||
bool isPerCellFaceResult(const QString& resultName);
|
||||
bool isNativeCategoryResult(const QString& resultName);
|
||||
|
||||
@@ -162,5 +169,6 @@ namespace RiaDefines
|
||||
|
||||
ImportFileType obtainFileTypeFromFileName(const QString& fileName);
|
||||
QString defaultDirectoryLabel(ImportFileType fileTypes);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -81,3 +81,29 @@ cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont(FontSize size)
|
||||
}
|
||||
return ms_fonts[size];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaFontCache::getPointSize(FontSize fontSize)
|
||||
{
|
||||
switch (fontSize)
|
||||
{
|
||||
case RiaFontCache::FONT_SIZE_8:
|
||||
return 8;
|
||||
case RiaFontCache::FONT_SIZE_10:
|
||||
return 10;
|
||||
case RiaFontCache::FONT_SIZE_12:
|
||||
return 12;
|
||||
case RiaFontCache::FONT_SIZE_14:
|
||||
return 14;
|
||||
case RiaFontCache::FONT_SIZE_16:
|
||||
return 16;
|
||||
case RiaFontCache::FONT_SIZE_24:
|
||||
return 24;
|
||||
case RiaFontCache::FONT_SIZE_32:
|
||||
return 32;
|
||||
default:
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,8 @@ public:
|
||||
|
||||
typedef caf::AppEnum<FontSize> FontSizeType;
|
||||
|
||||
static cvf::ref<caf::FixedAtlasFont> getFont(FontSize size);
|
||||
static cvf::ref<caf::FixedAtlasFont> getFont(FontSize fontSize);
|
||||
static int getPointSize(FontSize fontSize);
|
||||
|
||||
private:
|
||||
static std::map<FontSize, cvf::ref<caf::FixedAtlasFont>> ms_fonts;
|
||||
|
@@ -66,15 +66,19 @@ RiaPreferences::RiaPreferences(void)
|
||||
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "SSIHUB Address", "", "", "");
|
||||
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
|
||||
CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines", "", "", "");
|
||||
CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", RiaColorTables::defaultGridLineColor(), "Mesh Color", "", "", "");
|
||||
CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", RiaColorTables::defaultFaultLineColor(), "Mesh Color Along Faults", "", "", "");
|
||||
CAF_PDM_InitField(&defaultWellLabelColor, "defaultWellLableColor", RiaColorTables::defaultWellLabelColor(), "Well Label Color", "", "The default well label color in new views", "");
|
||||
|
||||
CAF_PDM_InitField(&defaultViewerBackgroundColor, "defaultViewerBackgroundColor", RiaColorTables::defaultViewerBackgroundColor(), "Viewer Background", "", "The viewer background color for new views", "");
|
||||
|
||||
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&fontSizeInScene, "fontSizeInScene", "Font Size", "", "", "");
|
||||
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&defaultFontSizeInScene, "fontSizeInScene", "Viewer Font", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&defaultAnnotationFontSize, "defaultAnnotationFontSize", "Annotation Font Size", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&defaultWellLabelFontSize, "wellLabelFontSize", "Well Label Font Size", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&defaultPlotFontSize, "defaultPlotFontSize", "Plot Font Size", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showLasCurveWithoutTvdWarning, "showLasCurveWithoutTvdWarning", true, "Show LAS Curve Without TVD Warning", "", "", "");
|
||||
showLasCurveWithoutTvdWarning.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
@@ -92,7 +96,8 @@ RiaPreferences::RiaPreferences(void)
|
||||
CAF_PDM_InitField(&m_includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, "Include Fracture Debug Info for Completion Export", "", "", "");
|
||||
m_includeFractureDebugInfoFile.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&showLegendBackground, "showLegendBackground", true, "Enable Legend Background", "", "", "");
|
||||
CAF_PDM_InitField(&showLegendBackground, "showLegendBackground", true, "Show Box around Legends", "", "", "");
|
||||
showLegendBackground.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
|
||||
lastUsedProjectFileName.uiCapability()->setUiHidden(true);
|
||||
@@ -168,7 +173,8 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
|
||||
field == &showLasCurveWithoutTvdWarning ||
|
||||
field == &holoLensDisableCertificateVerification ||
|
||||
field == &m_showProjectChangedDialog ||
|
||||
field == &m_showOctaveWarningForMultipleInstances)
|
||||
field == &m_showOctaveWarningForMultipleInstances ||
|
||||
field == &showLegendBackground)
|
||||
{
|
||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
@@ -193,26 +199,30 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
{
|
||||
if (uiConfigName == m_tabNames[0])
|
||||
{
|
||||
caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default Settings");
|
||||
defaultSettingsGroup->add(&defaultViewerBackgroundColor);
|
||||
defaultSettingsGroup->add(&defaultGridLines);
|
||||
defaultSettingsGroup->add(&defaultGridLineColors);
|
||||
defaultSettingsGroup->add(&defaultFaultGridLineColors);
|
||||
defaultSettingsGroup->add(&defaultWellLabelColor);
|
||||
defaultSettingsGroup->add(&fontSizeInScene);
|
||||
defaultSettingsGroup->add(&defaultScaleFactorZ);
|
||||
defaultSettingsGroup->add(&showLegendBackground);
|
||||
caf::PdmUiGroup* colorGroup = uiOrdering.addNewGroup("Default Colors");
|
||||
colorGroup->add(&defaultViewerBackgroundColor);
|
||||
colorGroup->add(&defaultGridLineColors);
|
||||
colorGroup->add(&defaultFaultGridLineColors);
|
||||
colorGroup->add(&defaultWellLabelColor);
|
||||
|
||||
caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D Views");
|
||||
caf::PdmUiGroup* fontGroup = uiOrdering.addNewGroup("Default Font Sizes");
|
||||
fontGroup->add(&defaultFontSizeInScene);
|
||||
fontGroup->add(&defaultAnnotationFontSize, false);
|
||||
fontGroup->add(&defaultWellLabelFontSize);
|
||||
fontGroup->add(&defaultPlotFontSize, false);
|
||||
|
||||
caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3d Views");
|
||||
viewsGroup->add(&defaultMeshModeType);
|
||||
viewsGroup->add(&navigationPolicy);
|
||||
viewsGroup->add(&defaultScaleFactorZ);
|
||||
viewsGroup->add(&showLegendBackground);
|
||||
viewsGroup->add(&useShaders);
|
||||
viewsGroup->add(&showHud);
|
||||
|
||||
|
||||
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other");
|
||||
otherGroup->add(&ssihubAddress);
|
||||
otherGroup->add(&showLasCurveWithoutTvdWarning);
|
||||
otherGroup->add(&holoLensDisableCertificateVerification);
|
||||
|
||||
}
|
||||
else if (uiConfigName == m_tabNames[1])
|
||||
{
|
||||
|
@@ -22,9 +22,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
@@ -71,14 +72,20 @@ public: // Pdm Fields
|
||||
|
||||
caf::PdmField<QString> ssihubAddress;
|
||||
|
||||
caf::PdmField<int> defaultScaleFactorZ;
|
||||
caf::PdmField<bool> defaultGridLines;
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::MeshModeType>> defaultMeshModeType;
|
||||
|
||||
caf::PdmField<int> defaultScaleFactorZ;
|
||||
caf::PdmField<cvf::Color3f> defaultGridLineColors;
|
||||
caf::PdmField<cvf::Color3f> defaultFaultGridLineColors;
|
||||
caf::PdmField<cvf::Color3f> defaultViewerBackgroundColor;
|
||||
caf::PdmField<cvf::Color3f> defaultWellLabelColor;
|
||||
caf::PdmField<bool> showLasCurveWithoutTvdWarning;
|
||||
caf::PdmField<FontSizeType> fontSizeInScene;
|
||||
caf::PdmField<bool> showLasCurveWithoutTvdWarning;
|
||||
|
||||
caf::PdmField<FontSizeType> defaultFontSizeInScene;
|
||||
caf::PdmField<FontSizeType> defaultWellLabelFontSize;
|
||||
caf::PdmField<FontSizeType> defaultAnnotationFontSize;
|
||||
caf::PdmField<FontSizeType> defaultPlotFontSize;
|
||||
|
||||
caf::PdmField<bool> showLegendBackground;
|
||||
|
||||
caf::PdmField<bool> useShaders;
|
||||
@@ -112,4 +119,5 @@ private:
|
||||
caf::PdmField<bool> m_includeFractureDebugInfoFile;
|
||||
caf::PdmField<QString> m_holoLensExportFolder;
|
||||
QStringList m_tabNames;
|
||||
|
||||
};
|
||||
|
@@ -51,6 +51,7 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
|
||||
std::unique_ptr<RiaPreferences> oldPreferences = clonePreferences(app->preferences());
|
||||
|
||||
RiuPropertyViewTabWidget propertyDialog(nullptr, app->preferences(), "Preferences", tabNames);
|
||||
propertyDialog.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
|
@@ -639,7 +639,7 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
||||
|
||||
cvf::ref<cvf::DrawableText> geo = new cvf::DrawableText;
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
|
||||
geo->setFont(standardFont);
|
||||
geo->setTextColor(m_gridLegendColor);
|
||||
|
@@ -606,8 +606,8 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<Q
|
||||
|
||||
if (!(eclipseView && faultInViewColl->showFaultLabel())) return;
|
||||
|
||||
cvf::Color3f defWellLabelColor = faultInViewColl->faultLabelColor();
|
||||
cvf::Font* font = RiaApplication::instance()->customFont();
|
||||
cvf::Color3f faultLabelColor = faultInViewColl->faultLabelColor();
|
||||
cvf::Font* font = RiaApplication::instance()->defaultSceneFont();
|
||||
|
||||
std::vector<cvf::Vec3f> lineVertices;
|
||||
|
||||
@@ -618,7 +618,7 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<Q
|
||||
drawableText->setDrawBorder(false);
|
||||
drawableText->setDrawBackground(false);
|
||||
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
|
||||
drawableText->setTextColor(defWellLabelColor);
|
||||
drawableText->setTextColor(faultLabelColor);
|
||||
}
|
||||
|
||||
cvf::BoundingBox bb = m_crossSectionFaces->boundingBox();
|
||||
|
@@ -482,7 +482,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
|
||||
// Fault label
|
||||
if (!m_rimFault->name().isEmpty())
|
||||
{
|
||||
cvf::Font* font = RiaApplication::instance()->customFont();
|
||||
cvf::Font* font = RiaApplication::instance()->defaultWellLabelFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(font);
|
||||
|
@@ -190,7 +190,7 @@ void RivMeasurementPartMgr::buildPolyLineParts(const cvf::Camera* camera,
|
||||
auto fontColor = cvf::Color3f::BLACK;
|
||||
QString text = m_measurement->label();
|
||||
auto labelPosition = pointsInDisplay.back();
|
||||
auto font = RiaApplication::instance()->customFont();
|
||||
auto font = RiaApplication::instance()->defaultWellLabelFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(font);
|
||||
|
@@ -297,7 +297,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex,
|
||||
|
||||
if (well->showWellLabel() && !well->name().isEmpty())
|
||||
{
|
||||
cvf::Font* font = RiaApplication::instance()->customFont();
|
||||
cvf::Font* font = RiaApplication::instance()->defaultWellLabelFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(font);
|
||||
|
@@ -612,7 +612,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di
|
||||
|
||||
if (wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty())
|
||||
{
|
||||
cvf::Font* font = RiaApplication::instance()->customFont();
|
||||
cvf::Font* font = RiaApplication::instance()->defaultWellLabelFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(font);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimAnnotationGroupCollection.h"
|
||||
#include "RimAnnotationTextAppearance.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimGridView.h"
|
||||
@@ -234,6 +235,46 @@ size_t RimAnnotationInViewCollection::annotationsCount() const
|
||||
return m_textAnnotations->m_annotations.size() + allGlobalPdmAnnotations().size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimAnnotationInViewCollection::hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) const
|
||||
{
|
||||
for (auto annotation : textAnnotations())
|
||||
{
|
||||
if (annotation->appearance()->fontSize() != defaultFontSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto annotationInView : globalTextAnnotations())
|
||||
{
|
||||
if (annotationInView->sourceAnnotation()->appearance()->fontSize() != defaultFontSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationInViewCollection::applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize)
|
||||
{
|
||||
for (auto annotation : textAnnotations())
|
||||
{
|
||||
annotation->appearance()->setFontSize(fontSize);
|
||||
}
|
||||
|
||||
for (auto annotationInView : globalTextAnnotations())
|
||||
{
|
||||
annotationInView->sourceAnnotation()->appearance()->setFontSize(fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
#include "RimAnnotationCollectionBase.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
@@ -59,6 +60,9 @@ public:
|
||||
void onGlobalCollectionChanged(const RimAnnotationCollection* globalCollection);
|
||||
size_t annotationsCount() const;
|
||||
|
||||
bool hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) const;
|
||||
void applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize);
|
||||
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
@@ -38,7 +38,7 @@ RimAnnotationTextAppearance::RimAnnotationTextAppearance()
|
||||
auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_fontSize, "FontSize", "Font Size", "", "", "");
|
||||
m_fontSize = prefs->fontSizeInScene();
|
||||
m_fontSize = prefs->defaultAnnotationFontSize();
|
||||
|
||||
CAF_PDM_InitField(&m_fontColor, "FontColor", cvf::Color3f(cvf::Color3f::BLACK), "Font Color", "", "", "");
|
||||
CAF_PDM_InitField(&m_backgroundColor, "BackgroundColor", defaultBackgroundColor , "Background Color", "", "", "");
|
||||
|
@@ -60,15 +60,6 @@
|
||||
|
||||
namespace caf {
|
||||
|
||||
template<>
|
||||
void caf::AppEnum< Rim3dView::MeshModeType >::setUp()
|
||||
{
|
||||
addItem(Rim3dView::FULL_MESH, "FULL_MESH", "All");
|
||||
addItem(Rim3dView::FAULTS_MESH, "FAULTS_MESH", "Faults only");
|
||||
addItem(Rim3dView::NO_MESH, "NO_MESH", "None");
|
||||
setDefault(Rim3dView::FULL_MESH);
|
||||
}
|
||||
|
||||
template<>
|
||||
void caf::AppEnum< Rim3dView::SurfaceModeType >::setUp()
|
||||
{
|
||||
@@ -120,8 +111,7 @@ Rim3dView::Rim3dView(void)
|
||||
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "");
|
||||
m_currentTimeStep.uiCapability()->setUiHidden(true);
|
||||
|
||||
caf::AppEnum<Rim3dView::MeshModeType> defaultMeshType = NO_MESH;
|
||||
if (preferences->defaultGridLines) defaultMeshType = FULL_MESH;
|
||||
caf::AppEnum<RiaDefines::MeshModeType> defaultMeshType = preferences->defaultMeshModeType();
|
||||
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", "");
|
||||
|
||||
@@ -505,7 +495,7 @@ void Rim3dView::setupBeforeSave()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setMeshOnlyDrawstyle()
|
||||
{
|
||||
meshMode.setValueWithFieldChanged(FULL_MESH);
|
||||
meshMode.setValueWithFieldChanged(RiaDefines::FULL_MESH);
|
||||
surfaceMode.setValueWithFieldChanged(NO_SURFACE);
|
||||
}
|
||||
|
||||
@@ -515,7 +505,7 @@ void Rim3dView::setMeshOnlyDrawstyle()
|
||||
void Rim3dView::setMeshSurfDrawstyle()
|
||||
{
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
meshMode.setValueWithFieldChanged(FULL_MESH);
|
||||
meshMode.setValueWithFieldChanged(RiaDefines::FULL_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -524,7 +514,7 @@ void Rim3dView::setMeshSurfDrawstyle()
|
||||
void Rim3dView::setFaultMeshSurfDrawstyle()
|
||||
{
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
meshMode.setValueWithFieldChanged(FAULTS_MESH);
|
||||
meshMode.setValueWithFieldChanged(RiaDefines::FAULTS_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -533,7 +523,7 @@ void Rim3dView::setFaultMeshSurfDrawstyle()
|
||||
void Rim3dView::setSurfOnlyDrawstyle()
|
||||
{
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
meshMode.setValueWithFieldChanged(NO_MESH);
|
||||
meshMode.setValueWithFieldChanged(RiaDefines::NO_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -640,7 +630,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const
|
||||
}
|
||||
else if (changedField == &m_backgroundColor)
|
||||
{
|
||||
this->applyBackgroundColor();
|
||||
this->applyBackgroundColorAndFontChanges();
|
||||
}
|
||||
else if (changedField == &maximumFrameRate)
|
||||
{
|
||||
@@ -895,15 +885,6 @@ void Rim3dView::setBackgroundColor(const cvf::Color3f& newBackgroundColor)
|
||||
m_backgroundColor = newBackgroundColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setAndApplyBackgroundColor(const cvf::Color3f& newBackgroundColor)
|
||||
{
|
||||
setBackgroundColor(newBackgroundColor);
|
||||
applyBackgroundColor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -915,11 +896,12 @@ void Rim3dView::setShowGridBox(bool showGridBox)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::applyBackgroundColor()
|
||||
void Rim3dView::applyBackgroundColorAndFontChanges()
|
||||
{
|
||||
if (m_viewer != nullptr)
|
||||
{
|
||||
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
|
||||
m_viewer->updateFonts();
|
||||
}
|
||||
updateGridBoxData();
|
||||
updateAnnotationItems();
|
||||
@@ -974,14 +956,14 @@ void Rim3dView::updateDisplayModelVisibility()
|
||||
mask |= intersectionCellFaceBit;
|
||||
}
|
||||
|
||||
if (meshMode == FULL_MESH)
|
||||
if (meshMode == RiaDefines::FULL_MESH)
|
||||
{
|
||||
mask |= uintMeshSurfaceBit;
|
||||
mask |= uintMeshFaultBit;
|
||||
mask |= intersectionCellMeshBit;
|
||||
mask |= intersectionFaultMeshBit;
|
||||
}
|
||||
else if (meshMode == FAULTS_MESH)
|
||||
else if (meshMode == RiaDefines::FAULTS_MESH)
|
||||
{
|
||||
mask |= uintMeshFaultBit;
|
||||
mask |= intersectionFaultMeshBit;
|
||||
|
@@ -18,6 +18,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiuViewerToViewInterface.h"
|
||||
#include "RimNameConfig.h"
|
||||
#include "RimViewWindow.h"
|
||||
@@ -95,11 +96,10 @@ public:
|
||||
|
||||
// Draw style
|
||||
|
||||
enum MeshModeType { FULL_MESH, FAULTS_MESH, NO_MESH };
|
||||
enum SurfaceModeType { SURFACE, FAULTS, NO_SURFACE };
|
||||
|
||||
caf::PdmField< caf::AppEnum< MeshModeType > > meshMode;
|
||||
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
|
||||
caf::PdmField< caf::AppEnum< RiaDefines::MeshModeType > > meshMode;
|
||||
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
|
||||
|
||||
RiuViewer* viewer() const;
|
||||
|
||||
@@ -114,9 +114,10 @@ public:
|
||||
void setFaultMeshSurfDrawstyle();
|
||||
void setSurfaceDrawstyle();
|
||||
void setBackgroundColor(const cvf::Color3f& newBackgroundColor);
|
||||
void setAndApplyBackgroundColor(const cvf::Color3f& newBackgroundColor);
|
||||
void setShowGridBox(bool showGridBox);
|
||||
|
||||
void applyBackgroundColorAndFontChanges();
|
||||
|
||||
void disableLighting(bool disable);
|
||||
bool isLightingDisabled() const;
|
||||
|
||||
@@ -126,8 +127,8 @@ public:
|
||||
virtual bool showActiveCellsOnly();
|
||||
virtual bool isUsingFormationNames() const = 0;
|
||||
|
||||
QImage snapshotWindowContent() override;
|
||||
void zoomAll() override;
|
||||
QImage snapshotWindowContent() override;
|
||||
void zoomAll() override;
|
||||
void forceShowWindowOn();
|
||||
|
||||
// Animation
|
||||
@@ -179,9 +180,6 @@ protected:
|
||||
|
||||
void createHighlightAndGridBoxDisplayModel();
|
||||
|
||||
// Implementation of RiuViewerToViewInterface
|
||||
void applyBackgroundColor();
|
||||
|
||||
// Implementation of RimNameConfigHolderInterface
|
||||
void performAutoNameUpdate() override;
|
||||
|
||||
|
@@ -167,7 +167,7 @@ void RimEclipseContourMapView::initAfterRead()
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
disablePerspectiveProjectionField();
|
||||
setShowGridBox(false);
|
||||
meshMode.setValue(NO_MESH);
|
||||
meshMode.setValue(RiaDefines::NO_MESH);
|
||||
surfaceMode.setValue(FAULTS);
|
||||
setFaultVisParameters();
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
|
@@ -178,7 +178,7 @@ void RimGeoMechContourMapView::initAfterRead()
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
disablePerspectiveProjectionField();
|
||||
setShowGridBox(false);
|
||||
meshMode.setValue(NO_MESH);
|
||||
meshMode.setValue(RiaDefines::NO_MESH);
|
||||
surfaceMode.setValue(FAULTS);
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
@@ -315,7 +315,7 @@ void RimGridView::initAfterRead()
|
||||
// Current : Grid visualization mode is directly defined by m_gridCollection->isActive
|
||||
// This change was introduced in https://github.com/OPM/ResInsight/commit/f7bfe8d0
|
||||
|
||||
bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RimGridView::FULL_MESH));
|
||||
bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RiaDefines::FULL_MESH));
|
||||
|
||||
m_gridCollection->setActive(isGridVisualizationModeBefore_2018_1_1);
|
||||
if (!isGridVisualizationModeBefore_2018_1_1)
|
||||
@@ -324,7 +324,7 @@ void RimGridView::initAfterRead()
|
||||
// If was showing with mesh and/or surfaces, turn to full mesh/surf mode to show the mesh,
|
||||
// and to avoid a strange setup when dropping out into grid mode again
|
||||
if (surfaceMode() != RimGridView::NO_SURFACE) surfaceMode = RimGridView::SURFACE;
|
||||
if (meshMode() != RimGridView::NO_MESH) meshMode = RimGridView::FULL_MESH;
|
||||
if (meshMode() != RiaDefines::NO_MESH) meshMode = RiaDefines::FULL_MESH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -150,7 +150,7 @@ RimRegularLegendConfig::RimRegularLegendConfig()
|
||||
|
||||
m_categoryMapper = new caf::CategoryMapper;
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont);
|
||||
m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p());
|
||||
|
||||
@@ -553,7 +553,7 @@ void RimRegularLegendConfig::recreateLegend()
|
||||
// has been removed, (and thus the opengl resources has been deleted) The text in
|
||||
// the legend disappeared because of this, so workaround: recreate the legend when needed:
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont);
|
||||
m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p());
|
||||
|
||||
|
@@ -110,7 +110,7 @@ RimScaleLegendConfig::RimScaleLegendConfig()
|
||||
CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
|
||||
resultVariableName.uiCapability()->setUiHidden(true);
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_scaleLegend = new caf::OverlayScaleLegend(standardFont);
|
||||
|
||||
updateFieldVisibility();
|
||||
@@ -343,7 +343,7 @@ void RimScaleLegendConfig::recreateLegend()
|
||||
// has been removed, (and thus the opengl resources has been deleted) The text in
|
||||
// the legend disappeared because of this, so workaround: recreate the legend when needed:
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_scaleLegend = new caf::OverlayScaleLegend(standardFont);
|
||||
|
||||
updateLegend();
|
||||
|
@@ -226,7 +226,7 @@ void RimTernaryLegendConfig::recreateLegend()
|
||||
// has been removed, (and thus the opengl resources has been deleted) The text in
|
||||
// the legend disappeared because of this, so workaround: recreate the legend when needed:
|
||||
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_legend = new RivTernarySaturationOverlayItem(standardFont);
|
||||
m_legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT);
|
||||
|
||||
|
@@ -93,7 +93,10 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
: caf::Viewer(format, parent)
|
||||
, m_isNavigationRotationEnabled(true)
|
||||
{
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
QFont font = QApplication::font();
|
||||
font.setPointSize(RiaFontCache::getPointSize(RiaApplication::instance()->preferences()->defaultFontSizeInScene()));
|
||||
|
||||
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
|
||||
m_axisCross->setAxisLabels("X", "Y", "Z");
|
||||
m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT);
|
||||
@@ -109,6 +112,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
m_infoLabel->setFrameShape(QFrame::Box);
|
||||
m_infoLabel->setFrameShadow(QFrame::Plain);
|
||||
m_infoLabel->setMinimumWidth(275);
|
||||
m_infoLabel->setFont(font);
|
||||
m_showInfoText = true;
|
||||
|
||||
// Version info label
|
||||
@@ -116,6 +120,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
m_versionInfoLabel->setFrameShape(QFrame::NoFrame);
|
||||
m_versionInfoLabel->setAlignment(Qt::AlignRight);
|
||||
m_versionInfoLabel->setText(QString("%1 v%2").arg(RI_APPLICATION_NAME, RiaApplication::getVersionStringApp(false)));
|
||||
m_versionInfoLabel->setFont(font);
|
||||
m_showVersionInfo = true;
|
||||
|
||||
// Z scale label
|
||||
@@ -123,6 +128,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
m_zScaleLabel->setFrameShape(QFrame::NoFrame);
|
||||
m_zScaleLabel->setAlignment(Qt::AlignLeft);
|
||||
m_zScaleLabel->setText(QString("Z: "));
|
||||
m_zScaleLabel->setFont(font);
|
||||
m_showZScaleLabel = true;
|
||||
m_hideZScaleCheckbox = false;
|
||||
|
||||
@@ -132,6 +138,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
m_animationProgress->setTextVisible(true);
|
||||
m_animationProgress->setAlignment(Qt::AlignCenter);
|
||||
m_animationProgress->setObjectName("AnimationProgress");
|
||||
m_animationProgress->setFont(font);
|
||||
|
||||
m_showAnimProgress = false;
|
||||
|
||||
@@ -572,6 +579,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedL
|
||||
addedLegend->enableBackground(preferences->showLegendBackground());
|
||||
addedLegend->setBackgroundColor(backgroundColor);
|
||||
addedLegend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(frameColor, 0.3f), 0.9f));
|
||||
addedLegend->setFont(app->defaultSceneFont());
|
||||
|
||||
m_visibleLegends.push_back(addedLegend);
|
||||
}
|
||||
@@ -1051,6 +1059,29 @@ void RiuViewer::clearHoverCursor()
|
||||
s_hoverCursor.reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::updateFonts()
|
||||
{
|
||||
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
|
||||
m_mainRendering->removeOverlayItem(m_axisCross.p());
|
||||
|
||||
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
|
||||
m_axisCross->setAxisLabels("X", "Y", "Z");
|
||||
m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT);
|
||||
m_mainRendering->addOverlayItem(m_axisCross.p());
|
||||
m_showAxisCross = true;
|
||||
|
||||
QFont font = QApplication::font();
|
||||
font.setPointSize(RiaFontCache::getPointSize(RiaApplication::instance()->preferences()->defaultFontSizeInScene()));
|
||||
|
||||
m_zScaleLabel->setFont(font);
|
||||
m_infoLabel->setFont(font);
|
||||
m_animationProgress->setFont(font);
|
||||
m_versionInfoLabel->setFont(font);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -131,6 +131,8 @@ public:
|
||||
static void setHoverCursor(const QCursor& cursor);
|
||||
static void clearHoverCursor();
|
||||
|
||||
void updateFonts();
|
||||
|
||||
public slots:
|
||||
void slotSetCurrentFrame(int frameIndex) override;
|
||||
void slotEndAnimation() override;
|
||||
|
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "cafFactory.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QColor>
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
@@ -81,36 +82,75 @@ void PdmUiColorEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
if (uiObject)
|
||||
{
|
||||
uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, &m_attributes);
|
||||
|
||||
if (m_attributes.showLabel)
|
||||
{
|
||||
m_colorTextLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_colorTextLabel->hide();
|
||||
}
|
||||
}
|
||||
|
||||
QColor col = uiField()->uiValue().value<QColor>();
|
||||
setColorOnWidget(col);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QMargins PdmUiColorEditor::calculateLabelContentMargins() const
|
||||
{
|
||||
QSize editorSize = m_colorSelectionButton->sizeHint();
|
||||
QSize labelSize = m_label->sizeHint();
|
||||
int heightDiff = editorSize.height() - labelSize.height();
|
||||
|
||||
QMargins contentMargins = m_label->contentsMargins();
|
||||
if (heightDiff > 0)
|
||||
{
|
||||
contentMargins.setTop(contentMargins.top() + heightDiff / 2);
|
||||
contentMargins.setBottom(contentMargins.bottom() + heightDiff / 2);
|
||||
}
|
||||
return contentMargins;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiColorEditor::createEditorWidget(QWidget * parent)
|
||||
{
|
||||
{
|
||||
QWidget* placeholder = new QWidget(parent);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout(placeholder);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
m_colorPixmapLabel = new QLabel(parent);
|
||||
m_colorTextLabel = new QLabel(parent);
|
||||
|
||||
QToolButton* button = new QToolButton(parent);
|
||||
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
|
||||
button->setText(QLatin1String("..."));
|
||||
m_colorSelectionButton = new QToolButton(parent);
|
||||
m_colorSelectionButton->setObjectName("ColorSelectionButton");
|
||||
m_colorSelectionButton->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
||||
m_colorSelectionButton->setLayout(buttonLayout);
|
||||
QMargins buttonMargins(3, 3, 3, 3);
|
||||
buttonLayout->setContentsMargins(buttonMargins);
|
||||
|
||||
m_colorPreviewLabel = new QLabel(m_colorSelectionButton);
|
||||
m_colorPreviewLabel->setObjectName("ColorPreviewLabel");
|
||||
m_colorPreviewLabel->setText(QLatin1String("..."));
|
||||
m_colorPreviewLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
QFontMetrics fontMetrics = QApplication::fontMetrics();
|
||||
|
||||
buttonLayout->addWidget(m_colorPreviewLabel);
|
||||
m_colorSelectionButton->setMinimumWidth(fontMetrics.width(m_colorPreviewLabel->text()) + 20);
|
||||
|
||||
layout->addWidget(m_colorPixmapLabel);
|
||||
layout->addWidget(m_colorTextLabel);
|
||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
||||
layout->addWidget(button);
|
||||
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(colorSelectionClicked()));
|
||||
layout->addWidget(m_colorSelectionButton);
|
||||
|
||||
connect(m_colorSelectionButton, SIGNAL(clicked()), this, SLOT(colorSelectionClicked()));
|
||||
|
||||
return placeholder;
|
||||
}
|
||||
@@ -135,7 +175,7 @@ void PdmUiColorEditor::colorSelectionClicked()
|
||||
flags |= QColorDialog::ShowAlphaChannel;
|
||||
}
|
||||
|
||||
QColor newColor = QColorDialog::getColor(m_color, m_colorPixmapLabel, "Select color", flags);
|
||||
QColor newColor = QColorDialog::getColor(m_color, m_colorSelectionButton, "Select color", flags);
|
||||
if (newColor.isValid() && newColor != m_color)
|
||||
{
|
||||
setColorOnWidget(newColor);
|
||||
@@ -154,17 +194,19 @@ void PdmUiColorEditor::setColorOnWidget(const QColor& color)
|
||||
{
|
||||
m_color = color;
|
||||
|
||||
QPixmap tmp(16, 16);
|
||||
tmp.fill(m_color);
|
||||
m_colorPixmapLabel->setPixmap(tmp);
|
||||
|
||||
QString colorString;
|
||||
if (!color.isValid())
|
||||
{
|
||||
colorString = "Undefined";
|
||||
m_colorSelectionButton->setStyleSheet("");
|
||||
}
|
||||
else
|
||||
{
|
||||
QColor fontColor = getFontColor(m_color);
|
||||
QString styleTemplate = "QLabel#ColorPreviewLabel { background-color: %1; color: %2; border: 1px solid %2; }";
|
||||
QString styleSheet = QString(styleTemplate).arg(m_color.name()).arg(fontColor.name());
|
||||
|
||||
m_colorPreviewLabel->setStyleSheet(styleSheet);
|
||||
colorString = QString("[%1, %2, %3]").arg(QString::number(color.red())).arg(QString::number(color.green())).arg(QString::number(color.blue()));
|
||||
|
||||
if (m_attributes.showAlpha)
|
||||
@@ -172,11 +214,23 @@ void PdmUiColorEditor::setColorOnWidget(const QColor& color)
|
||||
colorString += QString(" (%4)").arg(QString::number(color.alpha()));
|
||||
}
|
||||
}
|
||||
|
||||
m_colorTextLabel->setText(colorString);
|
||||
if (m_attributes.showLabel)
|
||||
{
|
||||
m_colorTextLabel->setText(colorString);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Based on http://www.codeproject.com/cs/media/IdealTextColor.asp
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QColor PdmUiColorEditor::getFontColor(const QColor& backgroundColor) const
|
||||
{
|
||||
const int THRESHOLD = 105;
|
||||
int backgroundDelta = (backgroundColor.red() * 0.299) + (backgroundColor.green() * 0.587) + (backgroundColor.blue() * 0.114);
|
||||
return QColor((255 - backgroundDelta < THRESHOLD) ? Qt::black : Qt::white);
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@@ -56,11 +56,13 @@ class PdmUiColorEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
bool showAlpha;
|
||||
bool showLabel;
|
||||
|
||||
public:
|
||||
PdmUiColorEditorAttribute()
|
||||
{
|
||||
showAlpha = false;
|
||||
showLabel = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,19 +84,23 @@ protected:
|
||||
QWidget* createLabelWidget(QWidget * parent) override;
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
|
||||
|
||||
QMargins calculateLabelContentMargins() const override;
|
||||
|
||||
protected slots:
|
||||
void colorSelectionClicked();
|
||||
|
||||
private:
|
||||
void setColorOnWidget(const QColor& c);
|
||||
|
||||
QColor getFontColor(const QColor& backgroundColor) const;
|
||||
private:
|
||||
QPointer<QShortenedLabel> m_label;
|
||||
|
||||
QColor m_color;
|
||||
QPointer<QLabel> m_colorPixmapLabel;
|
||||
QPointer<QLabel> m_colorTextLabel;
|
||||
|
||||
QColor m_color;
|
||||
QPointer<QLabel> m_colorTextLabel;
|
||||
QPointer<QToolButton> m_colorSelectionButton;
|
||||
QPointer<QLabel> m_colorPreviewLabel;
|
||||
|
||||
PdmUiColorEditorAttribute m_attributes;
|
||||
};
|
||||
|
||||
|
@@ -87,6 +87,14 @@ namespace caf {
|
||||
m_textColor = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void TitledOverlayFrame::setFont(cvf::Font* font)
|
||||
{
|
||||
m_font = font;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -62,6 +62,7 @@ namespace caf {
|
||||
cvf::Vec2ui renderSize() const;
|
||||
|
||||
void setTextColor(const cvf::Color3f& color);
|
||||
void setFont(cvf::Font* font);
|
||||
void setLineColor(const cvf::Color3f& lineColor);
|
||||
void setLineWidth(int lineWidth);
|
||||
|
||||
|
Reference in New Issue
Block a user