Skip to content

Commit

Permalink
Move the setting for graph normalization to the properties file
Browse files Browse the repository at this point in the history
This allows it to be set globally on a machine.
Refs #11055
  • Loading branch information
martyngigg committed Apr 9, 2015
1 parent 98b8926 commit 44a1644
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 60 deletions.
10 changes: 8 additions & 2 deletions Code/Mantid/Framework/Properties/Mantid.properties.template
Expand Up @@ -16,7 +16,7 @@ default.facility = ISIS
default.instrument =

# Set of PyQt interfaces to add to the Interfaces menu, separated by a space. Interfaces are seperated from their respective categories by a "/".
mantidqt.python_interfaces = Direct/DGS_Reduction.py SANS/ORNL_SANS.py Reflectometry/REFL_Reduction.py Reflectometry/REFL_SF_Calculator.py Reflectometry/REFM_Reduction.py Utility/TofConverter.py Reflectometry/ISIS_Reflectometry.py Diffraction/Powder_Diffraction_Reduction.py Utility/FilterEvents.py
mantidqt.python_interfaces = Direct/DGS_Reduction.py SANS/ORNL_SANS.py Reflectometry/REFL_Reduction.py Reflectometry/REFL_SF_Calculator.py Reflectometry/REFM_Reduction.py Utility/TofConverter.py Reflectometry/ISIS_Reflectometry.py Diffraction/Powder_Diffraction_Reduction.py Utility/FilterEvents.py
mantidqt.python_interfaces_directory = @MANTID_ROOT@/scripts

# Where to find mantid plugin libraries
Expand Down Expand Up @@ -114,7 +114,7 @@ curvefitting.findPeaksFWHM=7
curvefitting.findPeaksTolerance=4

# Allows the system proxy to be overridden (leave commented out to use the system proxy
# proxy.host =
# proxy.host =
# proxy.port = 8080
# This is to force https proxy requests to use the http proxy (current necessary)
proxy.httpsTargetUrl = http://www.mantidproject.org
Expand All @@ -129,6 +129,12 @@ MantidOptions.InvisibleWorkspaces=0
# Change to Off to disable OpenGL and use normal windows graphics.
MantidOptions.InstrumentView.UseOpenGL = On

# Controls the default normalization mode for graph plotting
# Allowed values are:
# On: Normalize to the bin width for plots
# Off: Do not normalize
graph1d.autodistribution = On

#Uncommenting the line below will enable algorithm chain re-running whenever a
#workspace is replaced. Uncommenting and setting it to 0 will also turn it off
#enabling this is currently discouraged as it could cause race conditions with python scripts
Expand Down
35 changes: 27 additions & 8 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Expand Up @@ -217,6 +217,7 @@

using namespace Qwt3D;
using namespace MantidQt::API;
using Mantid::Kernel::ConfigService;

namespace
{
Expand Down Expand Up @@ -363,7 +364,6 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args)
// splash screen after the 3D visualization dialog has closed
qApp->processEvents();

using Mantid::Kernel::ConfigService;
auto & config = ConfigService::Instance(); // Starts logging
resultsLog->attachLoggingChannel(); // Must be done after logging starts
using Mantid::API::FrameworkManager;
Expand Down Expand Up @@ -594,7 +594,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args)
// It is raised in the about2start method as on OS X if the event loop is not running then raise()
// does not push the dialog to the top of the stack
d_showFirstTimeSetup = shouldWeShowFirstTimeSetup(args);

using namespace Mantid::API;
// Do this as late as possible to avoid unnecessary updates
AlgorithmFactory::Instance().enableNotifications();
Expand Down Expand Up @@ -627,7 +627,7 @@ bool ApplicationWindow::shouldWeShowFirstTimeSetup(const QStringList& commandArg

//first check the facility and instrument
using Mantid::Kernel::ConfigService;
auto & config = ConfigService::Instance();
auto & config = ConfigService::Instance();
std::string facility = config.getString("default.facility");
std::string instrument = config.getString("default.instrument");
if ( facility.empty() || instrument.empty() )
Expand All @@ -641,13 +641,13 @@ bool ApplicationWindow::shouldWeShowFirstTimeSetup(const QStringList& commandArg
{
const Mantid::Kernel::FacilityInfo& facilityInfo = config.getFacility(facility);
const Mantid::Kernel::InstrumentInfo& instrumentInfo = config.getInstrument(instrument);
g_log.information()<<"Default facility '" << facilityInfo.name()
g_log.information()<<"Default facility '" << facilityInfo.name()
<< "', instrument '" << instrumentInfo.name() << "'" << std::endl;
}
catch (Mantid::Kernel::Exception::NotFoundError&)
{
//failed to find the facility or instrument
g_log.error()<<"Could not find your default facility '" << facility
g_log.error()<<"Could not find your default facility '" << facility
<<"' or instrument '" << instrument << "' in facilities.xml, showing please select again." << std::endl;
return true;
}
Expand Down Expand Up @@ -5221,7 +5221,27 @@ void ApplicationWindow::readSettings()

settings.beginGroup("/General");
titleOn = settings.value("/Title", true).toBool();
autoDistribution1D = settings.value("/AutoDistribution1D", true).toBool();
// The setting for this was originally stored as a QSetting but then was migrated to
// the Mantid ConfigService and is now saved by the ConfigDialog
auto & cfgSvc = ConfigService::Instance();
if ( settings.contains("/AutoDistribution1D") ) {
// if the setting was false then the user changed it
// sync this to the new location and remove the key for the future
bool qsettingsFlag = settings.value("/AutoDistribution1D", true).toBool();
if(qsettingsFlag == false) {
cfgSvc.setString("graph1d.autodistribution", "Off");
try {
cfgSvc.saveConfig( cfgSvc.getUserFilename());
} catch(std::runtime_error&) {
g_log.warning("Unable to update autodistribution property from ApplicationWindow");
}
}
settings.remove("/AutoDistribution1D");
}
// Pull default from config service
const std::string propStr = cfgSvc.getString("graph1d.autodistribution");
autoDistribution1D = (propStr == "On");

canvasFrameWidth = settings.value("/CanvasFrameWidth", 0).toInt();
defaultPlotMargin = settings.value("/Margin", 0).toInt();
drawBackbones = settings.value("/AxesBackbones", true).toBool();
Expand Down Expand Up @@ -5600,7 +5620,6 @@ void ApplicationWindow::saveSettings()
settings.beginGroup("/2DPlots");
settings.beginGroup("/General");
settings.setValue("/Title", titleOn);
settings.setValue("/AutoDistribution1D", autoDistribution1D);
settings.setValue("/CanvasFrameWidth", canvasFrameWidth);
settings.setValue("/Margin", defaultPlotMargin);
settings.setValue("/AxesBackbones", drawBackbones);
Expand Down Expand Up @@ -15637,7 +15656,7 @@ ApplicationWindow::~ApplicationWindow()
}
delete d_current_folder;



btnPointer->setChecked(true);
delete mantidUI;
Expand Down

0 comments on commit 44a1644

Please sign in to comment.