Newer
Older
/***************************************************************************
File : ApplicationWindow.cpp
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief,
Tilman Hoener zu Siederdissen,
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net,
knut.franke*gmx.de
Description : QtiPlot's main window
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#include "ApplicationWindow.h"
#include "ArrowMarker.h"
#include "AssociationsDialog.h"
#include "ColorBox.h"
#include "ColorMapDialog.h"
#include "ConfigDialog.h"
#include "Convolution.h"
#include "Correlation.h"
#include "CurveRangeDialog.h"
#include "CurvesDialog.h"
#include "CustomActionDialog.h"
#include "DataPickerTool.h"
#include "DataSetDialog.h"
#include "Differentiation.h"
#include "DockedWindow.h"
#include "ErrDialog.h"
#include "ExpDecayDialog.h"
#include "ExportDialog.h"
#include "FFTDialog.h"
#include "FFTFilter.h"
#include "FilterDialog.h"
#include "FindDialog.h"
#include "Fit.h"
#include "FloatingWindow.h"
#include "Folder.h"
#include "FunctionCurve.h"
#include "FunctionDialog.h"
#include "Graph.h"
#include "Grid.h"
#include "ImageExportDialog.h"
#include "ImageMarker.h"
#include "ImportASCIIDialog.h"
#include "Integration.h"
#include "InterpolationDialog.h"
#include "LayerDialog.h"
#include "LegendWidget.h"
#include "LineDialog.h"
#include "LogisticFit.h"
#include "MantidQtWidgets/Common/TSVSerialiser.h"
#include "MantidQtWidgets/LegacyQwt/ScaleEngine.h"
#include "MatrixCommand.h"
#include "MatrixModel.h"
#include "MatrixSizeDialog.h"
#include "MatrixValuesDialog.h"
#include "MdiSubWindow.h"
#include "MultiLayer.h"
#include "MultiPeakFit.h"
#include "NonLinearFit.h"
#include "OpenProjectDialog.h"
#include "Plot.h"
#include "Plot3DDialog.h"
#include "PlotDialog.h"
#include "PlotWizard.h"
#include "PolynomFitDialog.h"
#include "PolynomialFit.h"
#include "ProjectRecovery.h"
#include "ProjectSerialiser.h"
#include "QwtErrorPlotCurve.h"
#include "QwtHistogram.h"
#include "QwtPieCurve.h"
#include "RenameWindowDialog.h"
#include "ScriptFileInterpreter.h"
#include "ScriptingLangDialog.h"
#include "ScriptingWindow.h"
#include "SetColValuesDialog.h"
#include "SmoothCurveDialog.h"
#include "Spectrogram.h"
#include "SurfaceDialog.h"
#include "TableDialog.h"
#include "TableStatistics.h"
#include "TextDialog.h"
#include "TextEditor.h"
#include "importOPJ.h"
#include <MantidQtWidgets/Common/pixmaps.h>
// TODO: move tool-specific code to an extension manager
#include "ContourLinesEditor.h"
#include "LabelTool.h"
#include "Mantid/InstrumentWidget/InstrumentWindow.h"
#include "Mantid/MantidMatrix.h"
#include "Mantid/MantidMatrixCurve.h"
#include "Mantid/MantidTable.h"
#include "MultiPeakFitTool.h"
#include "PlotToolInterface.h"
#include "RangeSelectorTool.h"
#include "ScreenPickerTool.h"
#include "TranslateCurveTool.h"
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <QAction>
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
#include <QColorGroup>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDockWidget>
#include <QFontComboBox>
#include <QImageReader>
#include <QImageWriter>
#include <QKeySequence>
#include <QList>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QMenuItem>
#include <QPair>
#include <QPixmapCache>
#include <QPrintDialog>
#include <QPrinter>
#include <QPrinterInfo>
#include <QProgressDialog>
#include <QSettings>
#include <QSignalMapper>
#include <QSpinBox>
#include <QSplitter>
#include <QTextCodec>
#include <QToolBar>
#include <QTranslator>
#include <QVarLengthArray>
#include <QtAlgorithms>
#include <qwt_scale_engine.h>
#include <zlib.h>
#include <gsl/gsl_sort.h>
#include <Poco/Path.h>
#include "Mantid/FirstTimeSetup.h"
#include "Mantid/ManageInterfaceCategories.h"
#include "Mantid/MantidAbout.h"
#include "Mantid/MantidUI.h"
#include "Mantid/PeakPickerTool.h"
#include "MantidQtWidgets/Common/AlgorithmInputHistory.h"
#include "MantidQtWidgets/Common/InterfaceManager.h"
#include "MantidQtWidgets/Common/ManageUserDirectories.h"
#include "MantidQtWidgets/Common/MantidDesktopServices.h"
#include "MantidQtWidgets/Common/Message.h"
#include "MantidQtWidgets/Common/UserSubWindow.h"
#include "MantidQtWidgets/Common/CatalogHelper.h"
#include "MantidQtWidgets/Common/CatalogSearch.h"
#include "MantidQtWidgets/Common/FindFilesThreadPoolManager.h"
#include "MantidQtWidgets/Common/FitPropertyBrowser.h"
#include "MantidQtWidgets/Common/MessageDisplay.h"
#include "MantidQtWidgets/Common/MuonFitPropertyBrowser.h"
#include "MantidQtWidgets/Common/TrackedAction.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/InstrumentInfo.h"
#include "MantidKernel/LibraryManager.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/MantidVersion.h"
#include "MantidKernel/VectorHelper.h"
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/CatalogManager.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MultipleFileProperty.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidQtWidgets/Common/ScriptRepositoryView.h"
#ifdef MAKE_VATES
#include "vtkPVDisplayInformation.h"
#endif
using namespace Qwt3D;
using namespace MantidQt::API;
using Mantid::Kernel::ConfigService;
using Mantid::API::FrameworkManager;
using Mantid::Kernel::ConfigService;
using Mantid::Kernel::LibraryManager;
using Mantid::Kernel::Logger;
namespace {
/// static logger
Logger g_log("ApplicationWindow");
} // namespace
extern "C" {
void file_compress(const char *file, const char *mode);
void file_uncompress(const char *file);
}
ApplicationWindow::ApplicationWindow(bool factorySettings)
// Delegate with an empty string list for the arguments
: ApplicationWindow(factorySettings, QStringList{}) {}
ApplicationWindow::ApplicationWindow(bool factorySettings,
const QStringList &args)
: QMainWindow(), Scripted(ScriptingLangManager::newEnv(this)),
blockWindowActivation(false), m_enableQtiPlotFitting(false),
m_projectRecovery(this), m_exitCode(0),
settings(QSettings::IniFormat, QSettings::UserScope, "Mantid",
settings("Mantid", "MantidPlot")
/**
* This function is responsible for copying the old configuration
* information from the ISIS\MantidPlot area to the new Mantid\MantidPlot
* area. The old area is deleted once the transfer is complete. On subsequent
* runs, if the old configuration area is missing or empty, the copying
* is ignored.
*/
void ApplicationWindow::handleConfigDir() {
#ifdef Q_OS_WIN
// We use the registry for settings on Windows
QSettings oldSettings("ISIS", "MantidPlot");
QStringList keys = oldSettings.allKeys();
// If the keys are empty, we removed the MantidPlot entries
if (!keys.empty()) {
foreach (QString key, keys) {
settings.setValue(key, oldSettings.value(key));
}
// This unfortunately cannot remove the top-level entry
oldSettings.remove("");
}
#else
QFileInfo curConfig(settings.fileName());
QString oldPath = settings.fileName();
oldPath.replace("Mantid", "ISIS");
QFileInfo oldConfig(oldPath);
// If the old config directory exists, copy it's contents and
// then delete it
QDir oldConfigDir = oldConfig.dir();
if (oldConfigDir.exists()) {
QStringList entries = oldConfigDir.entryList();
foreach (QString entry, entries) {
if (!entry.startsWith(".")) {
QFileInfo oldFile(oldConfig.dir(), entry);
QFileInfo newFile(curConfig.dir(), entry);
// Qt will not overwrite files, so remove new one first
QFile::remove(newFile.filePath());
QFile::copy(oldFile.filePath(), newFile.filePath());
QFile::remove(oldFile.filePath());
}
}
oldConfigDir.rmdir(oldConfig.path());
}
/**
* Cache the working directory in the QSettings.
*
* store the working directory in the settings so it may be accessed
* elsewhere in the Qt layer.
*
*/
void ApplicationWindow::cacheWorkingDirectory() const {
QSettings settings;
settings.beginGroup("/Project");
settings.setValue("/WorkingDirectory", workingDir);
settings.endGroup();
}
/**
* Calls QCoreApplication::exit(m_exitCode)
*/
void ApplicationWindow::exitWithPresetCode() {
handleConfigDir();
void ApplicationWindow::init(bool factorySettings, const QStringList &args) {
QCoreApplication::setOrganizationName("Mantid");
QCoreApplication::setApplicationName("MantidPlot");
setAttribute(Qt::WA_DeleteOnClose);
#ifdef SHARED_MENUBAR
m_sharedMenuBar = new QMenuBar(nullptr);
m_sharedMenuBar->setNativeMenuBar(true);
#endif
setWindowTitle(tr("MantidPlot - untitled")); // Mantid
setObjectName("main application");
initGlobalConstants();
QPixmapCache::setCacheLimit(20 * QPixmapCache::cacheLimit());
// Logging as early as possible
logWindow = new QDockWidget(this);
logWindow->hide();
logWindow->setObjectName(
"logWindow"); // this is needed for QMainWindow::restoreState()
logWindow->setWindowTitle(tr("Results Log"));
addDockWidget(Qt::TopDockWidgetArea, logWindow);
Gigg, Martyn Anthony
committed
using MantidQt::MantidWidgets::Message;
using MantidQt::MantidWidgets::MessageDisplay;
Gigg, Martyn Anthony
committed
qRegisterMetaType<Message>("Message"); // Required to use it in signals-slots
resultsLog = new MessageDisplay(logWindow);
logWindow->setWidget(resultsLog);
connect(resultsLog, SIGNAL(errorReceived(const QString &)), logWindow,
SLOT(show()));
// Process all pending events before loading Mantid
// Helps particularly on Windows with cleaning up the
// splash screen after the 3D visualization dialog has closed
qApp->processEvents();
ConfigService::Instance(); // Starts logging
resultsLog->attachLoggingChannel(); // Must be done after logging starts
// Read settings early so that the log level is set before the framework
// starts
resultsLog->readSettings(settings);
// Load Mantid core libraries by starting the framework
FrameworkManager::Instance();
#ifdef MAKE_VATES
if (!vtkPVDisplayInformation::SupportsOpenGLLocally())
g_log.error("The OpenGL configuration does not support the VSI.");
#endif
// Create UI object
mantidUI = new MantidUI(this);
// Everything else...
tablesDepend = new QMenu(this);
explorerWindow = new QDockWidget(this);
explorerWindow->setWindowTitle(tr("Project Explorer"));
explorerWindow->setObjectName(
"explorerWindow"); // this is needed for QMainWindow::restoreState()
addDockWidget(Qt::BottomDockWidgetArea, explorerWindow);
actionSaveFile = nullptr;
actionSaveProject = nullptr;
actionSaveProjectAs = nullptr;
folders->setContextMenuPolicy(Qt::CustomContextMenu);
folders->setHeaderLabel("Folder");
folders->setRootIsDecorated(true);
folders->setSelectionMode(QAbstractItemView::SingleSelection);
connect(folders,
SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(folderItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(folders, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(showFolderPopupMenu(const QPoint &)));
connect(folders, SIGNAL(deleteSelection()), this,
SLOT(deleteSelectedItems()));
d_current_folder = new Folder(nullptr, tr("untitled"));
FolderListItem *fli = new FolderListItem(folders, d_current_folder);
d_current_folder->setFolderListItem(fli);
fli->setExpanded(true);
lv->setContextMenuPolicy(Qt::CustomContextMenu);
lv->setSelectionMode(QAbstractItemView::ExtendedSelection);
explorerSplitter = new QSplitter(Qt::Horizontal, explorerWindow);
explorerSplitter->addWidget(folders);
explorerSplitter->addWidget(lv);
explorerWindow->setWidget(explorerSplitter);
QList<int> splitterSizes;
explorerSplitter->setSizes(splitterSizes << 45 << 45);
explorerWindow->hide();
// Needs to be done after initialization of dock windows,
// because we now use QDockWidget::toggleViewAction()
createActions();
initToolBars();
initMainMenu();
d_workspace = new QMdiArea();
d_workspace->setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
d_workspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
d_workspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setCentralWidget(d_workspace);
setAcceptDrops(true);
hiddenWindows = new QList<QWidget *>();
scriptingWindow = nullptr;
d_text_editor = nullptr;
const QString scriptsDir = QString::fromStdString(
Mantid::Kernel::ConfigService::Instance().getString(
"mantidqt.python_interfaces_directory"));
// Parse the list of registered PyQt interfaces and their respective
// categories.
QString pyQtInterfacesProperty = QString::fromStdString(
Mantid::Kernel::ConfigService::Instance().getString(
"mantidqt.python_interfaces"));
foreach (const QString pyQtInterfaceInfo, pyQtInterfacesProperty.split(" ")) {
QString pyQtInterfaceFile;
QSet<QString> pyQtInterfaceCategories;
const QStringList tokens = pyQtInterfaceInfo.split("/");
if (tokens.size() == 0) // Empty token - ignore.
} else if (tokens.size() == 1) // Assume missing category.
pyQtInterfaceCategories += "Uncatagorised";
pyQtInterfaceFile = tokens[0];
} else if (tokens.size() ==
2) // Assume correct interface name and categories.
pyQtInterfaceCategories += tokens[0].split(";").toSet();
pyQtInterfaceFile = tokens[1];
} else // Too many forward slashes, or no space between two interfaces.
// Warn user and move on.
g_log.warning() << "The mantidqt.python_interfaces property contains an "
"unparsable value: "
<< pyQtInterfaceInfo.toStdString();
continue;
}
const QString scriptPath = scriptsDir + '/' + pyQtInterfaceFile;
if (QFileInfo(scriptPath).exists()) {
const QString pyQtInterfaceName =
QFileInfo(scriptPath).baseName().replace("_", " ");
m_interfaceNameDataPairs.append(qMakePair(pyQtInterfaceName, scriptPath));
// Keep track of the interface's categories as we go.
m_interfaceCategories[pyQtInterfaceName] = pyQtInterfaceCategories;
m_allCategories += pyQtInterfaceCategories;
} else {
g_log.warning() << "Could not find interface script: "
<< scriptPath.toAscii().data() << "\n";
MantidQt::API::InterfaceManager interfaceManager;
// Add all interfaces inherited from UserSubWindow.
foreach (const QString userSubWindowName,
interfaceManager.getUserSubWindowKeys()) {
m_interfaceNameDataPairs.append(
qMakePair(userSubWindowName, userSubWindowName));
const QSet<QString> categories =
UserSubWindowFactory::Instance().getInterfaceCategories(
userSubWindowName);
m_interfaceCategories[userSubWindowName] = categories;
m_allCategories += categories;
renamedTables = QStringList();
if (!factorySettings)
readSettings();
createLanguagesList();
insertTranslatedStrings();
disableToolbars();
actionNextWindow = new QAction(QIcon(getQPixmap("next_xpm")),
tr("&Next", "next window"), this);
actionNextWindow->setShortcut(tr("F5", "next window shortcut"));
connect(actionNextWindow, SIGNAL(triggered()), d_workspace,
SLOT(activateNextSubWindow()));
actionPrevWindow = new QAction(QIcon(getQPixmap("prev_xpm")),
tr("&Previous", "previous window"), this);
actionPrevWindow->setShortcut(tr("F6", "previous window shortcut"));
connect(actionPrevWindow, SIGNAL(triggered()), d_workspace,
SLOT(activatePreviousSubWindow()));
connect(tablesDepend, SIGNAL(triggered(QAction *)), this,
SLOT(showTable(QAction *)));
connect(this, SIGNAL(modified()), this, SLOT(modifiedProject()));
connect(d_workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
SLOT(windowActivated(QMdiSubWindow *)));
connect(lv, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(showWindowPopupMenu(const QPoint &)));
connect(lv, SIGNAL(deleteSelection()), this, SLOT(deleteSelectedItems()));
connect(recentProjectsMenu, SIGNAL(triggered(QAction *)), this,
SLOT(openRecentProject(QAction *)));
connect(recentFilesMenu, SIGNAL(triggered(QAction *)), this,
SLOT(openRecentFile(QAction *)));
// apply user settings
updateAppFonts();
setAppColors(workspaceColor, panelsColor, panelsTextColor, true);
// Scripting
m_script_envs = QHash<QString, ScriptingEnv *>();
setScriptingLanguage(defaultScriptingLang);
Gigg, Martyn Anthony
committed
m_interpreterDock = new QDockWidget(this);
m_interpreterDock->setObjectName(
"interpreterDock"); // this is needed for QMainWindow::restoreState()
m_interpreterDock->setWindowTitle("Script Interpreter");
runPythonScript("from ipython_widget import *\nw = "
"_qti.app._getInterpreterDock()\nw.setWidget("
"MantidIPythonWidget())",
false, true, true);
if (!restoreDockWidget(m_interpreterDock)) {
// Restoring the widget fails if the settings aren't found or read.
// Therefore, add it manually.
addDockWidget(Qt::BottomDockWidgetArea, m_interpreterDock);
catalogSearch.reset();
// Print a warning message if the scripting language is set to muParser
if (defaultScriptingLang == "muParser") {
g_log.warning("The scripting language is set to muParser. This is probably "
"not what you want! Change the default in "
"View->Preferences.");
// Need to show first time setup dialog?
// 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();
AlgorithmFactory::Instance().notificationCenter.postNotification(
new AlgorithmFactoryUpdateNotification);
/** Determines if the first time dialog should be shown
* @param commandArguments : all command line arguments.
* @returns true if the dialog should be shown
*/
bool ApplicationWindow::shouldWeShowFirstTimeSetup(
const QStringList &commandArguments) {
// Early check of execute and quit command arguments used by system tests.
foreach (str, commandArguments) {
if ((this->shouldExecuteAndQuit(str)) || (this->isSilentStartup(str))) {
// first check the facility and instrument
auto &config = ConfigService::Instance();
std::string facility = config.getString("default.facility");
std::string instrument = config.getString("default.instrument");
if (facility.empty() || instrument.empty()) {
} else {
// check we can get the facility and instrument
try {
const Mantid::Kernel::FacilityInfo &facilityInfo =
config.getFacility(facility);
const Mantid::Kernel::InstrumentInfo &instrumentInfo =
config.getInstrument(instrument);
g_log.information() << "Default facility '" << facilityInfo.name()
<< "', instrument '" << instrumentInfo.name()
<< "'\n";
} catch (Mantid::Kernel::Exception::NotFoundError &) {
// failed to find the facility or instrument
g_log.error() << "Could not find your default facility '" << facility
<< "' or instrument '" << instrument
<< "' in facilities.xml, showing please select again.\n";
QSettings settings;
settings.beginGroup("Mantid/FirstUse");
const bool doNotShowUntilNextRelease =
settings.value("DoNotShowUntilNextRelease", 0).toInt();
const QString lastVersion = settings.value("LastVersion", "").toString();
settings.endGroup();
if (!doNotShowUntilNextRelease) {
// Now check if the version has changed since last time
const QString version =
QString::fromStdString(Mantid::Kernel::MantidVersion::releaseNotes());
return (version != lastVersion);
void ApplicationWindow::initWindow() {
switch (d_init_window_type) {
case TableWindow:
newTable();
break;
case MatrixWindow:
newMatrix();
break;
case MultiLayerWindow:
newGraph();
break;
case NoteWindow:
newNote();
break;
default:
break;
}
}
void ApplicationWindow::initGlobalConstants() {
d_matrix_undo_stack_size = 10;
d_opening_file = false;
d_in_place_editing = true;
d_matrix_tool_bar = true;
d_standard_tool_bar = true;
d_column_tool_bar = true;
d_edit_tool_bar = true;
d_plot_tool_bar = true;
d_display_tool_bar = false;
d_format_tool_bar = true;
appStyle = qApp->style()->objectName();
d_app_rect = QRect();
projectname = "untitled";
lastCopiedLayer = nullptr;
d_text_copy = nullptr;
d_arrow_copy = nullptr;
d_image_copy = nullptr;
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
savingTimerId = 0;
autoSearchUpdatesRequest = false;
show_windows_policy = ActiveFolder;
d_init_window_type = NoWindow;
QString aux = qApp->applicationDirPath();
workingDir = aux;
d_translations_folder = aux + "/translations";
helpFilePath = aux + "/manual/index.html";
d_python_config_folder = aux;
fitPluginsPath = aux + "fitPlugins";
fitModelsPath = QString::null;
templatesDir = aux;
asciiDirPath = aux;
imagesDirPath = aux;
scriptsDirPath = aux;
customActionsDirPath = QString::null;
appFont = QFont();
QString family = appFont.family();
int pointSize = appFont.pointSize();
tableTextFont = appFont;
tableHeaderFont = appFont;
plotAxesFont = QFont(family, pointSize, QFont::Bold, false);
plotNumbersFont = QFont(family, pointSize);
plotTitleFont = QFont(family, pointSize + 2, QFont::Bold, false);
plot3DAxesFont = QFont(family, pointSize, QFont::Bold, false);
plot3DNumbersFont = QFont(family, pointSize);
plot3DTitleFont = QFont(family, pointSize + 2, QFont::Bold, false);
appLanguage = QLocale::system().name().section('_', 0, 0);
show_windows_policy = ApplicationWindow::ActiveFolder;
workspaceColor = QColor("darkGray");
panelsColor = QColor("#ffffff");
panelsTextColor = QColor("#000000");
tableBkgdColor = QColor("#ffffff");
tableTextColor = QColor("#000000");
tableHeaderColor = QColor("#000000");
plot3DColors = {"blue", "#000000", "#000000", "#000000",
"red", "#000000", "#000000", "#ffffff"};
d_graph_tick_labels_dist = 4;
d_graph_axes_labels_dist = 2;
autoSave = false;
autoSaveTime = 15;
d_backup_files = true;
defaultScriptingLang = "Python"; // Mantid M. Gigg
d_script_win_pos = QPoint(250, 200);
d_script_win_size = QSize(600, 660);
d_thousands_sep = true;
d_locale = QLocale::system().name();
if (!d_thousands_sep)
d_locale.setNumberOptions(QLocale::OmitGroupSeparator);
d_decimal_digits = 13;
d_extended_open_dialog = true;
d_extended_export_dialog = true;
d_extended_import_ASCII_dialog = true;
d_extended_plot_dialog = true;
d_add_curves_dialog_size = QSize(700, 400);
d_show_current_folder = false;
confirmCloseFolder = false;
confirmCloseTable = false;
confirmCloseMatrix = false;
confirmClosePlot2D = false;
confirmClosePlot3D = false;
confirmCloseNotes = false;
d_inform_delete_workspace = true;
confirmCloseInstrWindow = false;
d_show_table_comments = false;
titleOn = true;
// 'Factory' default is to show top & right axes but without labels
d_show_axes = QVector<bool>(QwtPlot::axisCnt, true);
d_show_axes_labels = QVector<bool>(QwtPlot::axisCnt, true);
d_show_axes_labels[1] = false;
d_show_axes_labels[3] = false;
autoDistribution1D = true;
canvasFrameWidth = 0;
defaultPlotMargin = 0;
drawBackbones = true;
// these settings are overridden, but the default axes scales are linear
d_axes_scales = QVector<QString>(QwtPlot::axisCnt, "linear");
axesLineWidth = 1;
autoscale2DPlots = true;
autoScaleFonts = true;
autoResizeLayers = true;
antialiasing2DPlots = true;
fixedAspectRatio2DPlots = false; // Mantid
d_scale_plots_on_print = false;
d_print_cropmarks = false;
d_synchronize_graph_scales = true;
defaultCurveStyle = static_cast<int>(GraphOptions::Line);
defaultCurveLineWidth = 1;
defaultSymbolSize = 7;
majTicksStyle = static_cast<int>(ScaleDraw::In);
minTicksStyle = static_cast<int>(ScaleDraw::In);
minTicksLength = 5;
majTicksLength = 9;
legendFrameStyle = static_cast<int>(LegendWidget::Line);
legendTextColor = Qt::black;
legendBackground = Qt::white;
legendBackground.setAlpha(255); // opaque by default;
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
defaultArrowLineWidth = 1;
defaultArrowColor = Qt::black;
defaultArrowHeadLength = 4;
defaultArrowHeadAngle = 45;
defaultArrowHeadFill = true;
defaultArrowLineStyle = Graph::getPenStyle("SolidLine");
showPlot3DLegend = true;
showPlot3DProjection = false;
smooth3DMesh = false;
plot3DResolution = 1;
orthogonal3DPlots = false;
autoscale3DPlots = true;
fit_output_precision = 13;
pasteFitResultsToPlot = false;
writeFitResultsToLog = true;
generateUniformFitPoints = true;
fitPoints = 100;
generatePeakCurves = true;
peakCurvesColor = 2;
fit_scale_errors = true;
d_2_linear_fit_points = true;
columnSeparator = "\t";
ignoredLines = 0;
renameColumns = true;
strip_spaces = false;
simplify_spaces = false;
d_ASCII_file_filter = "*";
d_ASCII_import_locale = QLocale::system().name();
d_import_dec_separators = true;
d_ASCII_import_mode = static_cast<int>(ImportASCIIDialog::NewTables);
d_ASCII_comment_string = "#";
d_ASCII_import_comments = false;
d_ASCII_import_read_only = false;
d_ASCII_import_preview = true;
d_preview_lines = 100;
#else
d_eol = LF;
#endif
d_export_col_names = false;
d_export_col_comment = false;
d_export_table_selection = false;
d_image_export_filter = ".png";
d_export_transparency = false;
d_export_quality = 100;
// MG: On Linux, if cups defines a printer queue that cannot be contact, the
// QPrinter constructor hangs and doesn't timeout.
d_export_color = true;
d_export_vector_size = static_cast<int>(QPrinter::Custom);
d_keep_plot_aspect = true;
}
QMenuBar *ApplicationWindow::myMenuBar() {
return m_sharedMenuBar == nullptr ? menuBar() : m_sharedMenuBar;
#else
return menuBar();
#endif
}
void ApplicationWindow::initToolBars() {
initPlot3DToolBar();
setWindowIcon(QIcon(":/MantidPlot_Icon_32offset.png"));
QPixmap openIcon, saveIcon;
standardTools = new QToolBar(tr("Standard Tools"), this);
standardTools->setObjectName(
"standardTools"); // this is needed for QMainWindow::restoreState()
standardTools->setIconSize(QSize(18, 20));
addToolBar(Qt::TopToolBarArea, standardTools);
standardTools->addAction(actionLoadFile);
standardTools->addSeparator();
standardTools->addAction(actionNewProject);
standardTools->addAction(actionOpenProj);
standardTools->addAction(actionSaveProject);
standardTools->addSeparator();
standardTools->addAction(actionShowLog);
standardTools->addAction(actionShowScriptWindow);
standardTools->addSeparator();
standardTools->addAction(actionManageDirs);
standardTools->addSeparator();
standardTools->addAction(actionCopySelection);
standardTools->addAction(actionPasteSelection);
plotTools = new QToolBar(tr("Plot"), this);
plotTools->setObjectName(
"plotTools"); // this is needed for QMainWindow::restoreState()
plotTools->setIconSize(QSize(16, 20));
addToolBar(plotTools);
dataTools = new QActionGroup(this);
dataTools->setExclusive(true);
btnPointer = new QAction(tr("Disable &Tools"), this);
btnPointer->setActionGroup(dataTools);
btnPointer->setCheckable(true);
btnPointer->setIcon(QIcon(getQPixmap("pointer_xpm")));
btnPointer->setChecked(true);
plotTools->addAction(btnPointer);
actionPanPlot->setActionGroup(dataTools);
actionPanPlot->setCheckable(true);
plotTools->addAction(actionPanPlot);
btnZoomIn = new QAction(tr("&Zoom In"), this);
btnZoomIn->setShortcut(tr("Ctrl++"));
btnZoomIn->setCheckable(true);
btnZoomIn->setIcon(QIcon(getQPixmap("zoom_xpm")));
plotTools->addAction(btnZoomIn);
btnZoomOut = new QAction(tr("&Zoom Out"), this);
btnZoomOut->setShortcut(tr("Ctrl+-"));
btnZoomOut->setCheckable(true);
btnZoomOut->setIcon(QIcon(getQPixmap("zoomOut_xpm")));
plotTools->addAction(actionUnzoom);
btnCursor = new QAction(tr("&Data Reader"), this);
btnCursor->setShortcut(tr("CTRL+D"));
btnCursor->setCheckable(true);
btnCursor->setIcon(QIcon(getQPixmap("select_xpm")));
btnPicker = new QAction(tr("S&creen Reader"), this);
btnPicker->setActionGroup(dataTools);
btnPicker->setCheckable(true);
btnPicker->setIcon(QIcon(getQPixmap("cursor_16_xpm")));
plotTools->addAction(btnPicker); // disabled until fixed (#2783)
actionDrawPoints = new QAction(tr("&Draw Data Points"), this);
actionDrawPoints->setActionGroup(dataTools);
actionDrawPoints->setCheckable(true);
actionDrawPoints->setIcon(QIcon(getQPixmap("draw_points_xpm")));
btnMovePoints = new QAction(tr("&Move Data Points..."), this);
btnMovePoints->setShortcut(tr("Ctrl+ALT+M"));
btnMovePoints->setCheckable(true);
btnMovePoints->setIcon(QIcon(getQPixmap("hand_xpm")));
btnRemovePoints = new QAction(tr("Remove &Bad Data Points..."), this);
btnRemovePoints->setShortcut(tr("Alt+B"));
btnRemovePoints->setActionGroup(dataTools);
btnRemovePoints->setCheckable(true);
btnRemovePoints->setIcon(QIcon(getQPixmap("gomme_xpm")));
if (mantidUI->fitFunctionBrowser()) {
btnMultiPeakPick = new QAction(tr("Select Multiple Peaks..."), this);
btnMultiPeakPick->setActionGroup(dataTools);
btnMultiPeakPick->setCheckable(true);
btnMultiPeakPick->setIcon(QIcon(getQPixmap("Fit_xpm")));
plotTools->addAction(btnMultiPeakPick);