mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-03 20:20:48 -06:00
#4196 Apply background color, well label color and z-scale automatically from preferences
* Ask to change existing views if their values are different from the previous Preferences default
This commit is contained in:
parent
69b01bcca7
commit
7d78956781
@ -22,6 +22,7 @@
|
||||
|
||||
#include "RiaArgumentParser.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaFilePathTools.h"
|
||||
#include "RiaFontCache.h"
|
||||
#include "RiaImportEclipseCaseTools.h"
|
||||
@ -61,6 +62,7 @@
|
||||
#include "RimRftPlotCollection.h"
|
||||
#include "RimSaturationPressurePlot.h"
|
||||
#include "RimSaturationPressurePlotCollection.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimStimPlanColors.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
@ -1963,7 +1965,7 @@ RiaPreferences* RiaApplication::preferences()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::applyPreferences()
|
||||
void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
|
||||
{
|
||||
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
||||
{
|
||||
@ -1998,14 +2000,91 @@ void RiaApplication::applyPreferences()
|
||||
std::vector<Rim3dView*> visibleViews;
|
||||
this->project()->allVisibleViews(visibleViews);
|
||||
|
||||
bool existingViewsWithCustomColors = false;
|
||||
bool existingViewsWithCustomZScale = false;
|
||||
if (oldPreferences)
|
||||
{
|
||||
for (auto view : visibleViews)
|
||||
{
|
||||
if (view->backgroundColor() != oldPreferences->defaultViewerBackgroundColor())
|
||||
{
|
||||
existingViewsWithCustomColors = true;
|
||||
}
|
||||
if (view->scaleZ() != static_cast<double>(oldPreferences->defaultScaleFactorZ))
|
||||
{
|
||||
existingViewsWithCustomZScale = true;
|
||||
}
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(view);
|
||||
if (eclipseView)
|
||||
{
|
||||
if (eclipseView->wellCollection()->wellLabelColor() != oldPreferences->defaultWellLabelColor())
|
||||
{
|
||||
existingViewsWithCustomColors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool applySettingsToAllViews = false;
|
||||
if (existingViewsWithCustomColors || existingViewsWithCustomZScale)
|
||||
{
|
||||
QStringList changedData;
|
||||
if (existingViewsWithCustomColors) changedData << "Colors";
|
||||
if (existingViewsWithCustomZScale) changedData << "Z-Scale";
|
||||
|
||||
QString listString = changedData.takeLast();
|
||||
if (!changedData.empty())
|
||||
{
|
||||
listString = changedData.join(", ") + " and " + listString;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::question(m_mainWindow,
|
||||
QString("Apply %1 to Existing Views?").arg(listString),
|
||||
QString("You have changed default %1 and have existing views with different settings.\n").arg(listString) +
|
||||
QString("Do you want to apply the new default settings to all existing views?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
applySettingsToAllViews = (reply == QMessageBox::Ok);
|
||||
}
|
||||
|
||||
for (auto view : visibleViews)
|
||||
{
|
||||
std::set<caf::PdmUiItem*> uiItemsToUpdate;
|
||||
|
||||
if (oldPreferences && (applySettingsToAllViews || view->backgroundColor() == oldPreferences->defaultViewerBackgroundColor()))
|
||||
{
|
||||
view->setAndApplyBackgroundColor(m_preferences->defaultViewerBackgroundColor());
|
||||
uiItemsToUpdate.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);
|
||||
if (view == activeViewWindow())
|
||||
{
|
||||
RiuMainWindow::instance()->updateScaleValue();
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
eclipseView->scheduleReservoirGridGeometryRegen();
|
||||
}
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
|
||||
for (caf::PdmUiItem* uiItem : uiItemsToUpdate)
|
||||
{
|
||||
uiItem->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
void waitForProcess() const;
|
||||
|
||||
RiaPreferences* preferences();
|
||||
void applyPreferences();
|
||||
void applyPreferences(const RiaPreferences* oldPreferences = nullptr);
|
||||
|
||||
cvf::Font* standardFont();
|
||||
cvf::Font* customFont();
|
||||
|
@ -1,6 +1,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
// Copyright (C) 2011-2018 Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
@ -20,6 +21,7 @@
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RifReaderSettings.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
@ -65,14 +67,14 @@ RiaPreferences::RiaPreferences(void)
|
||||
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
|
||||
CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", "");
|
||||
CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", cvf::Color3f(0.92f, 0.92f, 0.92f), "Mesh Color", "", "", "");
|
||||
CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", cvf::Color3f(0.08f, 0.08f, 0.08f), "Mesh Color Along Faults", "", "", "");
|
||||
CAF_PDM_InitField(&defaultWellLabelColor, "defaultWellLableColor", cvf::Color3f(0.92f, 0.92f, 0.92f), "Well Label Color", "", "The default well label color in new views", "");
|
||||
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", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer Background", "", "The viewer background color for 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_InitFieldNoDefault(&fontSizeInScene, "fontSizeInScene", "Font Size", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showLasCurveWithoutTvdWarning, "showLasCurveWithoutTvdWarning", true, "Show LAS Curve Without TVD Warning", "", "", "");
|
||||
showLasCurveWithoutTvdWarning.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
// Copyright (C) 2011-2018 Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
|
@ -541,6 +541,39 @@ RiaColorTables::WellPathComponentColors RiaColorTables::wellPathComponentColors(
|
||||
{RiaDefines::UNDEFINED_COMPONENT, cvf::Color3::MAGENTA}};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RiaColorTables::defaultGridLineColor()
|
||||
{
|
||||
return cvf::Color3f(0.92f, 0.92f, 0.92f);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RiaColorTables::defaultFaultLineColor()
|
||||
{
|
||||
return cvf::Color3f(0.08f, 0.08f, 0.08f);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RiaColorTables::defaultWellLabelColor()
|
||||
{
|
||||
return cvf::Color3f(0.92f, 0.92f, 0.92f);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RiaColorTables::defaultViewerBackgroundColor()
|
||||
{
|
||||
return cvf::Color3f(0.69f, 0.77f, 0.87f);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -64,6 +64,13 @@ public:
|
||||
|
||||
static WellPathComponentColors wellPathComponentColors();
|
||||
|
||||
// Default 3d View colors
|
||||
static cvf::Color3f defaultGridLineColor();
|
||||
static cvf::Color3f defaultFaultLineColor();
|
||||
static cvf::Color3f defaultWellLabelColor();
|
||||
static cvf::Color3f defaultViewerBackgroundColor();
|
||||
|
||||
|
||||
static caf::ColorTable createBrightnessBasedColorTable(cvf::Color3ub baseColor, int brightnessLevelCount);
|
||||
private:
|
||||
static std::vector<cvf::Color3ub> categoryColors();
|
||||
|
@ -47,12 +47,15 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
QStringList tabNames = app->preferences()->tabNames();
|
||||
|
||||
std::unique_ptr<RiaPreferences> oldPreferences = clonePreferences(app->preferences());
|
||||
|
||||
RiuPropertyViewTabWidget propertyDialog(nullptr, app->preferences(), "Preferences", tabNames);
|
||||
if (propertyDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(app->preferences());
|
||||
app->applyPreferences();
|
||||
app->applyPreferences(oldPreferences.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -68,3 +71,14 @@ void RicEditPreferencesFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("&Preferences...");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<RiaPreferences> RicEditPreferencesFeature::clonePreferences(const RiaPreferences* preferences)
|
||||
{
|
||||
caf::PdmObjectHandle* pdmClone =
|
||||
preferences->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance());
|
||||
|
||||
return std::unique_ptr<RiaPreferences>(dynamic_cast<RiaPreferences*>(pdmClone));
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include <memory>
|
||||
|
||||
class RiaPreferences;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -27,12 +29,14 @@
|
||||
class RicEditPreferencesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static std::unique_ptr<RiaPreferences> clonePreferences(const RiaPreferences* preferences);
|
||||
};
|
||||
|
||||
|
||||
|
@ -590,31 +590,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const
|
||||
}
|
||||
else if (changedField == &scaleZ)
|
||||
{
|
||||
if (scaleZ < 1) scaleZ = 1;
|
||||
|
||||
this->updateGridBoxData();
|
||||
|
||||
if (m_viewer)
|
||||
{
|
||||
cvf::Vec3d poi = m_viewer->pointOfInterest();
|
||||
cvf::Vec3d eye, dir, up;
|
||||
eye = m_viewer->mainCamera()->position();
|
||||
dir = m_viewer->mainCamera()->direction();
|
||||
up = m_viewer->mainCamera()->up();
|
||||
|
||||
eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]);
|
||||
poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2);
|
||||
|
||||
m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up);
|
||||
m_viewer->setPointOfInterest(poi);
|
||||
|
||||
updateScaleTransform();
|
||||
createDisplayModelAndRedraw();
|
||||
|
||||
m_viewer->update();
|
||||
|
||||
updateZScaleLabel();
|
||||
}
|
||||
updateScaling();
|
||||
|
||||
RiuMainWindow::instance()->updateScaleValue();
|
||||
}
|
||||
@ -819,6 +795,38 @@ void Rim3dView::updateAnnotationItems()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateScaling()
|
||||
{
|
||||
if (scaleZ < 1) scaleZ = 1;
|
||||
|
||||
this->updateGridBoxData();
|
||||
|
||||
if (m_viewer)
|
||||
{
|
||||
cvf::Vec3d poi = m_viewer->pointOfInterest();
|
||||
cvf::Vec3d eye, dir, up;
|
||||
eye = m_viewer->mainCamera()->position();
|
||||
dir = m_viewer->mainCamera()->direction();
|
||||
up = m_viewer->mainCamera()->up();
|
||||
|
||||
eye[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]);
|
||||
poi[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()(2, 2);
|
||||
|
||||
m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up);
|
||||
m_viewer->setPointOfInterest(poi);
|
||||
|
||||
updateScaleTransform();
|
||||
createDisplayModelAndRedraw();
|
||||
|
||||
m_viewer->update();
|
||||
|
||||
updateZScaleLabel();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -887,6 +895,15 @@ void Rim3dView::setBackgroundColor(const cvf::Color3f& newBackgroundColor)
|
||||
m_backgroundColor = newBackgroundColor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setAndApplyBackgroundColor(const cvf::Color3f& newBackgroundColor)
|
||||
{
|
||||
setBackgroundColor(newBackgroundColor);
|
||||
applyBackgroundColor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
void setFaultMeshSurfDrawstyle();
|
||||
void setSurfaceDrawstyle();
|
||||
void setBackgroundColor(const cvf::Color3f& newBackgroundColor);
|
||||
void setAndApplyBackgroundColor(const cvf::Color3f& newBackgroundColor);
|
||||
void setShowGridBox(bool showGridBox);
|
||||
|
||||
void disableLighting(bool disable);
|
||||
@ -143,6 +144,7 @@ public:
|
||||
void createHighlightAndGridBoxDisplayModelWithRedraw();
|
||||
void updateGridBoxData();
|
||||
void updateAnnotationItems();
|
||||
void updateScaling();
|
||||
void updateZScaleLabel();
|
||||
void updateMeasurement();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user