Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************
File : ApplicationWindow.cpp
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief,
Tilman Hoener zu Siederdissen,
Knut Franke
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 "globals.h"
#include "ApplicationWindow.h"
#include "pixmaps.h"
#include "CurvesDialog.h"
#include "PlotDialog.h"
#include "AxesDialog.h"
#include "LineDialog.h"
#include "TextDialog.h"
#include "ExportDialog.h"
#include "TableDialog.h"
#include "SetColValuesDialog.h"
#include "ErrDialog.h"
#include "LegendWidget.h"
#include "ArrowMarker.h"
#include "ImageMarker.h"
#include "Graph.h"
#include "Plot.h"
#include "Grid.h"
#include "PlotWizard.h"
#include "PolynomFitDialog.h"
#include "ExpDecayDialog.h"
#include "FunctionDialog.h"
#include "FitDialog.h"
#include "SurfaceDialog.h"
#include "Graph3D.h"
#include "Plot3DDialog.h"
#include "ImageDialog.h"
#include "MultiLayer.h"
#include "LayerDialog.h"
#include "DataSetDialog.h"
#include "IntDialog.h"
#include "ConfigDialog.h"
#include "MatrixDialog.h"
#include "MatrixSizeDialog.h"
#include "MatrixValuesDialog.h"
#include "MatrixModel.h"
#include "MatrixCommand.h"
#include "importOPJ.h"
#include "AssociationsDialog.h"
#include "RenameWindowDialog.h"
#include "QwtErrorPlotCurve.h"
#include "InterpolationDialog.h"
#include "ImportASCIIDialog.h"
#include "ImageExportDialog.h"
#include "SmoothCurveDialog.h"
#include "FilterDialog.h"
#include "FFTDialog.h"
#include "Note.h"
#include "Folder.h"
#include "FindDialog.h"
#include "ScaleDraw.h"
#include "plot2D/ScaleEngine.h"
#include "ScriptingLangDialog.h"
#include "ScriptingWindow.h"
Gigg, Martyn Anthony
committed
#include "CommandLineInterpreter.h"
#include "ScriptFileInterpreter.h"
#include "TableStatistics.h"
#include "Fit.h"
#include "MultiPeakFit.h"
#include "PolynomialFit.h"
#include "SigmoidalFit.h"
#include "LogisticFit.h"
#include "NonLinearFit.h"
#include "FunctionCurve.h"
#include "QwtPieCurve.h"
#include "Spectrogram.h"
#include "Integration.h"
#include "Differentiation.h"
#include "SmoothFilter.h"
#include "FFTFilter.h"
#include "Convolution.h"
#include "Correlation.h"
#include "CurveRangeDialog.h"
#include "ColorBox.h"
#include "QwtHistogram.h"
#include "OpenProjectDialog.h"
#include "ColorMapDialog.h"
#include "TextEditor.h"
#include "SymbolDialog.h"
#include "CustomActionDialog.h"
#include "MdiSubWindow.h"
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// TODO: move tool-specific code to an extension manager
#include "ScreenPickerTool.h"
#include "DataPickerTool.h"
#include "TranslateCurveTool.h"
#include "MultiPeakFitTool.h"
#include "LineProfileTool.h"
#include "RangeSelectorTool.h"
#include "PlotToolInterface.h"
#include "Mantid/MantidMatrix.h"
#include "Mantid/MantidTable.h"
#include "Mantid/MantidMatrixCurve.h"
#include "ContourLinesEditor.h"
#include "Mantid/InstrumentWidget/InstrumentWindow.h"
#include "Mantid/RemoveErrorsDialog.h"
#include <stdio.h>
#include <stdlib.h>
#include <qwt_scale_engine.h>
#include <QFileDialog>
#include <QInputDialog>
#include <QProgressDialog>
#include <QPrintDialog>
#include <QPixmapCache>
#include <QMenuBar>
#include <QClipboard>
#include <QTranslator>
#include <QSplitter>
#include <QSettings>
#include <QApplication>
#include <QMessageBox>
#include <QPrinter>
#include <QPrinterInfo>
#include <QActionGroup>
#include <QAction>
#include <QToolBar>
#include <QKeySequence>
#include <QImageReader>
#include <QImageWriter>
#include <QDateTime>
#include <QShortcut>
#include <QDockWidget>
#include <QTextStream>
#include <QVarLengthArray>
#include <QList>
#include <QUrl>
#include <QFontComboBox>
#include <QSpinBox>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QUndoStack>
#include <QUndoView>
#include <QSignalMapper>
#include <QDesktopWidget>
#include <zlib.h>
#include <gsl/gsl_sort.h>
//Mantid
#include "ScriptingWindow.h"
#include "Mantid/MantidUI.h"
#include "Mantid/MantidAbout.h"
#include "Mantid/PeakPickerTool.h"
#include "Mantid/ManageCustomMenus.h"
#include "Mantid/FirstTimeSetup.h"
#include "Mantid/SetUpParaview.h"
#include "MantidQtAPI/InterfaceManager.h"
#include "MantidQtAPI/UserSubWindow.h"
#include "MantidQtAPI/AlgorithmInputHistory.h"
#include "MantidQtAPI/ManageUserDirectories.h"
#include "MantidQtMantidWidgets/ICatSearch.h"
#include "MantidQtMantidWidgets/ICatMyDataSearch.h"
#include "MantidQtMantidWidgets/ICatAdvancedSearch.h"
#include "MantidQtMantidWidgets/FitPropertyBrowser.h"
#include "MantidQtMantidWidgets/MuonFitPropertyBrowser.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/MantidVersion.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/AnalysisDataService.h"
using namespace Qwt3D;
using namespace MantidQt::API;
extern "C"
{
void file_compress(const char *file, const char *mode);
void file_uncompress(const char *file);
}
ApplicationWindow::ApplicationWindow(bool factorySettings)
: QMainWindow(),
Scripted(ScriptingLangManager::newEnv(this)),
blockWindowActivation(false),
m_enableQtiPlotFitting(false),
m_exitCode(0),
#ifdef Q_OS_MAC // Mac
settings(QSettings::IniFormat,QSettings::UserScope, "ISIS", "MantidPlot")
#else
settings("ISIS", "MantidPlot")
#endif
{
QStringList empty;
init(factorySettings, empty);
}
ApplicationWindow::ApplicationWindow(bool factorySettings, const QStringList& args)
: QMainWindow(),
Scripted(ScriptingLangManager::newEnv(this)),
blockWindowActivation(false),
m_enableQtiPlotFitting(false),
m_exitCode(0),
#ifdef Q_OS_MAC // Mac
settings(QSettings::IniFormat,QSettings::UserScope, "ISIS", "MantidPlot")
#else
settings("ISIS", "MantidPlot")
}
/**
* Calls QCoreApplication::exit(m_exitCode)
*/
void ApplicationWindow::exitWithPresetCode()
{
QCoreApplication::exit(m_exitCode);
}
void ApplicationWindow::init(bool factorySettings, const QStringList& args)
QCoreApplication::setOrganizationName("ISIS");
QCoreApplication::setApplicationName("MantidPlot");
#ifdef SHARED_MENUBAR
m_sharedMenuBar = new QMenuBar(NULL);
//setMenuBar(m_sharedMenuBar);
m_sharedMenuBar->setNativeMenuBar(true);
#endif
mantidUI = new MantidUI(this);
setAttribute(Qt::WA_DeleteOnClose);
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
setWindowTitle(tr("MantidPlot - untitled"));//Mantid
setObjectName("main application");
initGlobalConstants();
QPixmapCache::setCacheLimit(20*QPixmapCache::cacheLimit ());
tablesDepend = new QMenu(this);
explorerWindow = new QDockWidget( this );
explorerWindow->setWindowTitle(tr("Project Explorer"));
explorerWindow->setObjectName("explorerWindow"); // this is needed for QMainWindow::restoreState()
explorerWindow->setMinimumHeight(150);
addDockWidget( Qt::BottomDockWidgetArea, explorerWindow );
actionSaveFile=NULL;
actionSaveProject=NULL;
folders = new FolderListView(this);
folders->header()->setClickEnabled( false );
folders->addColumn( tr("Folder") );
folders->setRootIsDecorated( true );
folders->setResizeMode(Q3ListView::LastColumn);
folders->header()->hide();
folders->setSelectionMode(Q3ListView::Single);
connect(folders, SIGNAL(currentChanged(Q3ListViewItem *)),
this, SLOT(folderItemChanged(Q3ListViewItem *)));
connect(folders, SIGNAL(itemRenamed(Q3ListViewItem *, int, const QString &)),
this, SLOT(renameFolder(Q3ListViewItem *, int, const QString &)));
connect(folders, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)),
this, SLOT(showFolderPopupMenu(Q3ListViewItem *, const QPoint &, int)));
connect(folders, SIGNAL(dragItems(QList<Q3ListViewItem *>)),
this, SLOT(dragFolderItems(QList<Q3ListViewItem *>)));
connect(folders, SIGNAL(dropItems(Q3ListViewItem *)),
this, SLOT(dropFolderItems(Q3ListViewItem *)));
connect(folders, SIGNAL(renameItem(Q3ListViewItem *)),
this, SLOT(startRenameFolder(Q3ListViewItem *)));
connect(folders, SIGNAL(addFolderItem()), this, SLOT(addFolder()));
connect(folders, SIGNAL(deleteSelection()), this, SLOT(deleteSelectedItems()));
current_folder = new Folder( 0, tr("UNTITLED"));
FolderListItem *fli = new FolderListItem(folders, current_folder);
current_folder->setFolderListItem(fli);
fli->setOpen( true );
lv = new FolderListView();
lv->addColumn (tr("Name"),-1 );
lv->addColumn (tr("Type"),-1 );
lv->addColumn (tr("View"),-1 );
lv->addColumn (tr("Size"),-1 );
lv->addColumn (tr("Created"),-1);
lv->addColumn (tr("Label"),-1);
lv->setResizeMode(Q3ListView::LastColumn);
lv->setMinimumHeight(80);
lv->setSelectionMode(Q3ListView::Extended);
lv->setDefaultRenameAction (Q3ListView::Accept);
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();
logWindow = new QDockWidget(this);
logWindow->setObjectName("logWindow"); // this is needed for QMainWindow::restoreState()
logWindow->setWindowTitle(tr("Results Log"));
addDockWidget( Qt::TopDockWidgetArea, logWindow );
results=new QTextEdit(logWindow);
results->setReadOnly (true);
results->setContextMenuPolicy(Qt::CustomContextMenu);
connect(results, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(showLogWindowContextMenu(const QPoint &)));
logWindow->setWidget(results);
logWindow->hide();
consoleWindow = new QDockWidget(this);
consoleWindow->setObjectName("consoleWindow"); // this is needed for QMainWindow::restoreState()
consoleWindow->setWindowTitle(tr("Scripting Console"));
addDockWidget( Qt::TopDockWidgetArea, consoleWindow );
console = new QTextEdit(consoleWindow);
console->setReadOnly(true);
console->setContextMenuPolicy(Qt::CustomContextMenu);
connect(console, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(showScriptConsoleContextMenu(const QPoint &)));
consoleWindow->setWidget(console);
consoleWindow->hide();
m_interpreterDock = new QDockWidget(this);
m_interpreterDock->setObjectName("interpreterDock"); // this is needed for QMainWindow::restoreState()
m_interpreterDock->setWindowTitle("Script Interpreter");
addDockWidget( Qt::BottomDockWidgetArea, m_interpreterDock );
// This is a temporary widget so that when the settings are read the dock's visible state is correct.
// It gets replaced with the script widget after the scripting language has been read and set
m_interpreterDock->setWidget(new QTextEdit);
m_interpreterDock->hide();
undoStackWindow = new QDockWidget(this);
undoStackWindow->setObjectName("undoStackWindow"); // this is needed for QMainWindow::restoreState()
undoStackWindow->setWindowTitle(tr("Undo Stack"));
addDockWidget(Qt::RightDockWidgetArea, undoStackWindow);
d_undo_view = new QUndoView(undoStackWindow);
d_undo_view->setCleanIcon(QIcon(getQPixmap("filesave_xpm")));
undoStackWindow->setWidget(d_undo_view);
undoStackWindow->hide();
/*
If applicable, set the Paraview path BEFORE libaries are loaded. Doing it here, before the call to MantidUI::init() prevents
the logs being poluted with library loading errors.
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
//Initialize Mantid
// MG: 01/02/2009 - Moved this to before scripting so that the logging is connected when
// we register Python algorithms
mantidUI->init();
// 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 = NULL;
d_text_editor = NULL;
// List of registered PyQt interfaces
QString pyqt_interfaces_as_str = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("mantidqt.python_interfaces"));
pyqt_interfaces = QStringList::split(" ", pyqt_interfaces_as_str);
renamedTables = QStringList();
if (!factorySettings)
readSettings();
createLanguagesList();
insertTranslatedStrings();
disableToolbars();
// assistant = new QAssistantClient( QString(), this );
actionNextWindow = new QAction(QIcon(getQPixmap("next_xpm")), tr("&Next","next window"), this);
actionNextWindow->setShortcut( tr("F5","next window shortcut") );
connect(actionNextWindow, SIGNAL(activated()), 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(activated()), d_workspace, SLOT(activatePreviousSubWindow()));
connect(tablesDepend, SIGNAL(activated(int)), this, SLOT(showTable(int)));
connect(this, SIGNAL(modified()),this, SLOT(modifiedProject()));
connect(d_workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)),
this, SLOT(windowActivated(QMdiSubWindow*)));
connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
this, SLOT(activateWindow(Q3ListViewItem *)));
connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
this, SLOT(folderItemDoubleClicked(Q3ListViewItem *)));
connect(lv, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)),
this, SLOT(showWindowPopupMenu(Q3ListViewItem *, const QPoint &, int)));
connect(lv, SIGNAL(dragItems(QList<Q3ListViewItem *>)),
this, SLOT(dragFolderItems(QList<Q3ListViewItem *>)));
connect(lv, SIGNAL(dropItems(Q3ListViewItem *)),
this, SLOT(dropFolderItems(Q3ListViewItem *)));
connect(lv, SIGNAL(renameItem(Q3ListViewItem *)),
this, SLOT(startRenameFolder(Q3ListViewItem *)));
connect(lv, SIGNAL(addFolderItem()), this, SLOT(addFolder()));
connect(lv, SIGNAL(deleteSelection()), this, SLOT(deleteSelectedItems()));
connect(lv, SIGNAL(itemRenamed(Q3ListViewItem *, int, const QString &)),
this, SLOT(renameWindow(Q3ListViewItem *, int, const QString &)));
connect(recent, SIGNAL(activated(int)), this, SLOT(openRecentProject(int)));
//connect(&http, SIGNAL(done(bool)), this, SLOT(receivedVersionFile(bool)));
//apply user settings
updateAppFonts();
setAppColors(workspaceColor, panelsColor, panelsTextColor, true);
//Scripting
m_script_envs = QHash<QString, ScriptingEnv*>();
setScriptingLanguage(defaultScriptingLang);
m_scriptInterpreter = new CommandLineInterpreter(*scriptingEnv(), m_interpreterDock);
delete m_interpreterDock->widget();
m_interpreterDock->setWidget(m_scriptInterpreter);
m_iface_script = NULL;
loadCustomActions();
// Print a warning message if the scripting language is set to muParser
if (defaultScriptingLang == "muParser")
{
logWindow->show();
results->setTextColor(Qt::blue);
results->insertPlainText("The scripting language is set to muParser. This is probably not what you want! Change the default in View->Preferences.");
results->setTextColor(Qt::black);
}
actionIPythonConsole->setVisible(testForIPython());
// Need to show first time setup dialog?
Mantid::Kernel::ConfigServiceImpl& config = Mantid::Kernel::ConfigService::Instance();
std::string facility = config.getString("default.facility");
std::string instrument = config.getString("default.instrument");
if ( facility.empty() || instrument.empty() )
{
showFirstTimeSetup();
}
using namespace Mantid::API;
// Do this as late as possible to avoid unnecessary updates
AlgorithmFactory::Instance().enableNotifications();
AlgorithmFactory::Instance().notificationCenter.postNotification(new AlgorithmFactoryUpdateNotification);
/*
Function tries to set the paraview path.
This is a windows only feature. the PATH enviromental variable can be set at runtime on windows.
- Abort if Vates libraries do not seem to be present.
- Othwerise, if the paraview.path is already in the properties file, use it.
- Otherwise, if the user is not using executeandquit command arguments launch the Setup gui.
@param commandArguments : all command line arguments.
*/
void ApplicationWindow::trySetParaviewPath(const QStringList& commandArguments)
{
if(this->hasVatesAvailable())//TODO: This condition is redundant since Vates will be shipped by default.
Mantid::Kernel::ConfigServiceImpl& confService = Mantid::Kernel::ConfigService::Instance();
//Early check of execute and quit command arguments used by system tests.
QString str;
bool b_skipDialog = false;
{
if(this->shouldExecuteAndQuit(str))
{
b_skipDialog = true;
break;
}
}
//ONLY If skipping is not already selected
if(!b_skipDialog)
{
//If the ignore property exists and is set to true, then skip the dialog.
const std::string paraviewIgnoreProperty = "paraview.ignore";
b_skipDialog = confService.hasProperty(paraviewIgnoreProperty) && QString(confService.getString(paraviewIgnoreProperty).c_str()).toInt() > 0;
if(this->hasParaviewPath())
{
//Already have a path in the properties file, just apply it.
std::string path = confService.getString("paraview.path");
confService.setParaviewLibraryPath(path);
}
else
{
//Only run the following if skipping is not implied.
if(!b_skipDialog)
{
//Launch the dialog to set the PV path.
SetUpParaview pv(SetUpParaview::FirstLaunch);
#else
UNUSED_ARG(commandArguments)
#endif
/*
Getter to determine if the vates paraview plugins are available.
The code below may be used before MantidUI::init is called and therefore the implementation
must not rely on the Vates Libraries to be loaded in order to determine whether Vates is available.
@return TRUE if vates is available
*/
bool ApplicationWindow::hasVatesAvailable() const
{
return Mantid::Kernel::ConfigService::Instance().quickVatesCheck();
}
/*
Getter to determine if the paraview path has been set.
*/
bool ApplicationWindow::hasParaviewPath() const
{
Mantid::Kernel::ConfigServiceImpl& config = Mantid::Kernel::ConfigService::Instance();
return config.hasProperty("paraview.path");
}
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
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
void ApplicationWindow::showLogWindowContextMenu(const QPoint & p)
{
(void)p; //Avoid compiler warning
QMenu *menu = results->createStandardContextMenu();
if(!menu) return;
if(results->text().isEmpty())
{
actionClearLogInfo->setEnabled(false);
}
else
{
actionClearLogInfo->setEnabled(true);
}
menu->addAction(actionClearLogInfo);
//Mantid log level changes
QMenu *logLevelMenu = menu->addMenu("&Log Level");
logLevelMenu->addAction(actionLogLevelError);
logLevelMenu->addAction(actionLogLevelWarning);
logLevelMenu->addAction(actionLogLevelNotice);
logLevelMenu->addAction(actionLogLevelInformation);
logLevelMenu->addAction(actionLogLevelDebug);
//check the right level
int level = Mantid::Kernel::Logger::get("").getLevel(); //get the root logger logging level
if (level == Poco::Message::PRIO_ERROR)
actionLogLevelError->setChecked(true);
if (level == Poco::Message::PRIO_WARNING)
actionLogLevelWarning->setChecked(true);
if (level == Poco::Message::PRIO_NOTICE)
actionLogLevelNotice->setChecked(true);
if (level == Poco::Message::PRIO_INFORMATION)
actionLogLevelInformation->setChecked(true);
if (level == Poco::Message::PRIO_DEBUG)
actionLogLevelDebug->setChecked(true);
//Mantid log level changes
menu->popup(QCursor::pos());
}
void ApplicationWindow::setLogLevel(int level)
{
//set the log level
Mantid::Kernel::Logger::setLevelForAll(level);
}
void ApplicationWindow::showScriptConsoleContextMenu(const QPoint &p)
{
(void)p;
QMenu *menu = results->createStandardContextMenu();
menu->addAction(actionClearConsole);
menu->popup(QCursor::pos());
}
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_auto_update_table_values = true;
d_active_window = NULL;
d_matrix_undo_stack_size = 10;
d_opening_file = false;
d_in_place_editing = true;
d_matrix_tool_bar = true;
d_file_tool_bar = true;
d_table_tool_bar = true;
d_column_tool_bar = true;
d_edit_tool_bar = true;
d_plot_tool_bar = true;
d_plot3D_tool_bar = true;
d_display_tool_bar = false;
d_format_tool_bar = true;
appStyle = qApp->style()->objectName();
d_app_rect = QRect();
projectname = "untitled";
lastCopiedLayer = 0;
d_text_copy = NULL;
d_arrow_copy = NULL;
d_image_copy = NULL;
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 );
plotLegendFont = appFont;
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);
autoSearchUpdates = 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 = QStringList();
plot3DColors << "blue";
plot3DColors << "#000000";
plot3DColors << "#000000";
plot3DColors << "#000000";
plot3DColors << "red";
plot3DColors << "#000000";
plot3DColors << "#000000";
plot3DColors << "#ffffff";
d_graph_tick_labels_dist = 4;
d_graph_axes_labels_dist = 2;
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
autoSave = false;
autoSaveTime = 15;
d_backup_files = true;
defaultScriptingLang = "Python"; //Mantid M. Gigg
// Scripting window geometry
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_rename_table = false;
confirmCloseInstrWindow=false;
d_show_table_comments = false;
titleOn = true;
d_show_axes = QVector<bool> (QwtPlot::axisCnt, true);
// 'Factory' default is to not show top & right axes
d_show_axes[1] = false;
d_show_axes[3] = false;
d_show_axes_labels = QVector<bool> (QwtPlot::axisCnt, 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 = false; //Mantid
fixedAspectRatio2DPlots = false; //Mantid
d_scale_plots_on_print = false;
d_print_cropmarks = false;
d_synchronize_graph_scales = true;
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
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
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
defaultCurveStyle = static_cast<int>(Graph::Line);
defaultCurveLineWidth = 1;
defaultSymbolSize = 7;
majTicksStyle = static_cast<int>(ScaleDraw::Out);
minTicksStyle = static_cast<int>(ScaleDraw::Out);
minTicksLength = 5;
majTicksLength = 9;
legendFrameStyle = static_cast<int>(LegendWidget::Line);
legendTextColor = Qt::black;
legendBackground = Qt::white;
legendBackground.setAlpha(0); // transparent by default;
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;
d_ASCII_end_line = LF;
d_eol = LF;
#ifdef Q_OS_MAC
d_ASCII_end_line = CR;
d_eol = CR;
#endif
d_export_col_separator = "\t";
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.
// QPrinterInfo::availablePrinters();
// d_export_resolution = QPrinter().resolution();
d_export_color = true;
d_export_vector_size = static_cast<int>(QPrinter::Custom);
d_keep_plot_aspect = true;
}
QMenuBar* ApplicationWindow::myMenuBar()
{
#ifdef SHARED_MENUBAR
return m_sharedMenuBar == NULL ? menuBar() : m_sharedMenuBar;
#else
return menuBar();
#endif
}
void ApplicationWindow::initToolBars()
{
initPlot3DToolBar();
// setWindowIcon(QIcon(getQPixmap("logo_xpm")));
setWindowIcon(QIcon(":/MantidPlot_Icon_32offset.png"));
QPixmap openIcon, saveIcon;
fileTools = new QToolBar(tr( "File" ), this);
fileTools->setObjectName("fileTools"); // this is needed for QMainWindow::restoreState()
fileTools->setIconSize( QSize(18,20) );
addToolBar( Qt::TopToolBarArea, fileTools );
fileTools->addAction(actionNewProject);
fileTools->addAction(actionNewFolder);
fileTools->addAction(actionNewTable);
fileTools->addAction(actionNewMatrix);
fileTools->addAction(actionNewNote);
fileTools->addAction(actionNewGraph);
fileTools->addAction(actionNewFunctionPlot);
fileTools->addAction(actionNewSurfacePlot);
fileTools->addSeparator ();
fileTools->addAction(actionManageDirs);
fileTools->addSeparator ();
fileTools->addAction(actionOpenProj);
fileTools->addAction(actionLoadFile);
fileTools->addAction(actionSaveProject);
fileTools->addSeparator ();
fileTools->addAction(actionLoad);
fileTools->addSeparator ();
fileTools->addAction(actionCopyWindow);
fileTools->addAction(actionPrint);
fileTools->addAction(actionExportPDF);
fileTools->addSeparator();
fileTools->addAction(actionShowExplorer);
fileTools->addAction(actionShowLog);
#ifdef SCRIPTING_PYTHON
fileTools->addAction(actionShowScriptWindow);
#endif
editTools = new QToolBar(tr("Edit"), this);
editTools->setObjectName("editTools"); // this is needed for QMainWindow::restoreState()
editTools->setIconSize( QSize(18,20) );
addToolBar( editTools );
editTools->addAction(actionUndo);
editTools->addAction(actionRedo);
editTools->addAction(actionCutSelection);
editTools->addAction(actionCopySelection);
editTools->addAction(actionPasteSelection);
editTools->addAction(actionClearSelection);
plotTools = new QToolBar(tr("Plot"), this);
plotTools->setObjectName("plotTools"); // this is needed for QMainWindow::restoreState()
plotTools->setIconSize( QSize(16,20) );
addToolBar( plotTools );
plotTools->addAction(actionAddLayer);
plotTools->addAction(actionShowLayerDialog);
plotTools->addAction(actionAutomaticLayout);
plotTools->addSeparator();
plotTools->addAction(actionAddErrorBars);
plotTools->addAction(actionRemoveErrorBars);
plotTools->addAction(actionShowCurvesDialog);
plotTools->addAction(actionAddFunctionCurve);
plotTools->addAction(actionNewLegend);
plotTools->addSeparator ();
plotTools->addAction(actionUnzoom);
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);
actionMagnify->setActionGroup(dataTools);
actionMagnify->setCheckable( true );
plotTools->addAction(actionMagnify);
btnZoomIn = new QAction(tr("&Zoom In"), this);
btnZoomIn->setShortcut( tr("Ctrl++") );
btnZoomIn->setActionGroup(dataTools);
btnZoomIn->setCheckable( true );
btnZoomIn->setIcon(QIcon(getQPixmap("zoom_xpm")) );
plotTools->addAction(btnZoomIn);
btnZoomOut = new QAction(tr("&Zoom Out"), this);
btnZoomOut->setShortcut( tr("Ctrl+-") );
btnZoomOut->setActionGroup(dataTools);
btnZoomOut->setCheckable( true );
btnZoomOut->setIcon(QIcon(getQPixmap("zoomOut_xpm")) );
plotTools->addAction(btnZoomOut);
btnCursor = new QAction(tr("&Data Reader"), this);
btnCursor->setShortcut( tr("CTRL+D") );
btnCursor->setActionGroup(dataTools);
btnCursor->setCheckable( true );
btnCursor->setIcon(QIcon(getQPixmap("select_xpm")) );
//plotTools->addAction(btnCursor); disabled until fixed (#2783)
btnSelect = new QAction(tr("&Select Data Range"), this);
btnSelect->setShortcut( tr("ALT+S") );
btnSelect->setActionGroup(dataTools);
btnSelect->setCheckable( true );
btnSelect->setIcon(QIcon(getQPixmap("cursors_xpm")) );
//plotTools->addAction(btnSelect); disabled until fixed (#2783)
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")) );