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
/***************************************************************************
File : ConfigDialog.cpp
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
Description : Preferences dialog
***************************************************************************/
/***************************************************************************
* *
* 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 "ConfigDialog.h"
#include "ApplicationWindow.h"
#include "MultiLayer.h"
#include "Graph.h"
#include "Matrix.h"
#include "ColorButton.h"
#include "ColorBox.h"
#include "pixmaps.h"
#include "DoubleSpinBox.h"
#include <QLocale>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QFont>
#include <QFontDialog>
#include <QTabWidget>
#include <QStackedWidget>
#include <QWidget>
#include <QComboBox>
#include <QSpinBox>
#include <QRadioButton>
#include <QStyleFactory>
#include <QRegExp>
#include <QMessageBox>
#include <QTranslator>
#include <QApplication>
#include <QDir>
#include <QPixmap>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListWidget>
#include <QFontMetrics>
#include <QFileDialog>
Gigg, Martyn Anthony
committed
#include <QRegExp>
#include <QMouseEvent>
Gigg, Martyn Anthony
committed
#include "MantidKernel/ConfigService.h"
Gigg, Martyn Anthony
committed
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/IBackgroundFunction.h"
Roman Tolchenov
committed
#include "MantidAPI/IPeakFunction.h"
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
static const char* choose_folder_xpm[]={
"16 16 11 1",
"# c #000000",
"g c #c0c0c0",
"e c #303030",
"a c #ffa858",
"b c #808080",
"d c #a0a0a4",
"f c #585858",
"c c #ffdca8",
"h c #dcdcdc",
"i c #ffffff",
". c None",
"....###.........",
"....#ab##.......",
"....#acab####...",
"###.#acccccca#..",
"#ddefaaaccccca#.",
"#bdddbaaaacccab#",
".eddddbbaaaacab#",
".#bddggdbbaaaab#",
"..edgdggggbbaab#",
"..#bgggghghdaab#",
"...ebhggghicfab#",
"....#edhhiiidab#",
"......#egiiicfb#",
"........#egiibb#",
"..........#egib#",
"............#ee#"};
ConfigDialog::ConfigDialog( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
// get current values from app window
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
plot3DTitleFont = app->plot3DTitleFont;
plot3DNumbersFont = app->plot3DNumbersFont;
plot3DAxesFont = app->plot3DAxesFont;
textFont = app->tableTextFont;
headerFont = app->tableHeaderFont;
appFont = app->appFont;
axesFont = app->plotAxesFont;
numbersFont = app->plotNumbersFont;
legendFont = app->plotLegendFont;
titleFont = app->plotTitleFont;
// create the GUI
generalDialog = new QStackedWidget();
itemsList = new QListWidget();
itemsList->setSpacing(10);
itemsList->setAlternatingRowColors( true );
initAppPage();
Gigg, Martyn Anthony
committed
initMantidPage();
initTablesPage();
initPlotsPage();
initPlots3DPage();
initFittingPage();
generalDialog->addWidget(appTabWidget);
Gigg, Martyn Anthony
committed
generalDialog->addWidget(mtdTabWidget);
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
generalDialog->addWidget(tables);
generalDialog->addWidget(plotsTabWidget);
generalDialog->addWidget(plots3D);
generalDialog->addWidget(fitPage);
QVBoxLayout * rightLayout = new QVBoxLayout();
lblPageHeader = new QLabel();
QFont fnt = this->font();
fnt.setPointSize(fnt.pointSize() + 3);
fnt.setBold(true);
lblPageHeader->setFont(fnt);
lblPageHeader->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QPalette pal = lblPageHeader->palette();
pal.setColor( QPalette::Window, app->panelsColor );
lblPageHeader->setPalette(pal);
lblPageHeader->setAutoFillBackground( true );
rightLayout->setSpacing(10);
rightLayout->addWidget( lblPageHeader );
rightLayout->addWidget( generalDialog );
QHBoxLayout * topLayout = new QHBoxLayout();
topLayout->setSpacing(5);
topLayout->setMargin(5);
topLayout->addWidget( itemsList );
topLayout->addLayout( rightLayout );
QHBoxLayout * bottomButtons = new QHBoxLayout();
bottomButtons->addStretch();
buttonApply = new QPushButton();
buttonApply->setAutoDefault( true );
bottomButtons->addWidget( buttonApply );
buttonOk = new QPushButton();
buttonOk->setAutoDefault( true );
buttonOk->setDefault( true );
bottomButtons->addWidget( buttonOk );
buttonCancel = new QPushButton();
buttonCancel->setAutoDefault( true );
bottomButtons->addWidget( buttonCancel );
QVBoxLayout * mainLayout = new QVBoxLayout( this );
mainLayout->addLayout(topLayout);
mainLayout->addLayout(bottomButtons);
languageChange();
// signals and slots connections
connect( itemsList, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int)));
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( buttonTextFont, SIGNAL( clicked() ), this, SLOT( pickTextFont() ) );
connect( buttonHeaderFont, SIGNAL( clicked() ), this, SLOT( pickHeaderFont() ) );
setCurrentPage(0);
}
void ConfigDialog::setCurrentPage(int index)
{
generalDialog->setCurrentIndex(index);
if(itemsList->currentItem())
lblPageHeader->setText(itemsList->currentItem()->text());
}
void ConfigDialog::initTablesPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
tables = new QWidget();
QHBoxLayout * topLayout = new QHBoxLayout();
topLayout->setSpacing(5);
lblSeparator = new QLabel();
topLayout->addWidget( lblSeparator );
boxSeparator = new QComboBox();
boxSeparator->setEditable( true );
topLayout->addWidget( boxSeparator );
QString help = tr("The column separator can be customized. \nThe following special codes can be used:\n\\t for a TAB character \n\\s for a SPACE");
help += "\n"+tr("The separator must not contain the following characters: \n0-9eE.+-");
boxSeparator->setWhatsThis(help);
boxSeparator->setToolTip(help);
lblSeparator->setWhatsThis(help);
lblSeparator->setToolTip(help);
groupBoxTableCol = new QGroupBox();
QGridLayout * colorsLayout = new QGridLayout(groupBoxTableCol);
lblTableBackground = new QLabel();
colorsLayout->addWidget( lblTableBackground, 0, 0 );
buttonBackground= new ColorButton();
buttonBackground->setColor(app->tableBkgdColor);
colorsLayout->addWidget( buttonBackground, 0, 1 );
lblTextColor = new QLabel();
colorsLayout->addWidget( lblTextColor, 1, 0 );
buttonText = new ColorButton();
buttonText->setColor(app->tableTextColor);
colorsLayout->addWidget( buttonText, 1, 1 );
lblHeaderColor = new QLabel();
colorsLayout->addWidget( lblHeaderColor, 2, 0 );
buttonHeader= new ColorButton();
buttonHeader->setColor(app->tableHeaderColor);
colorsLayout->addWidget( buttonHeader, 2, 1 );
groupBoxTableFonts = new QGroupBox();
QHBoxLayout * bottomLayout = new QHBoxLayout( groupBoxTableFonts );
buttonTextFont= new QPushButton();
bottomLayout->addWidget( buttonTextFont );
buttonHeaderFont= new QPushButton();
bottomLayout->addWidget( buttonHeaderFont );
boxTableComments = new QCheckBox();
boxTableComments->setChecked(app->d_show_table_comments);
boxUpdateTableValues = new QCheckBox();
boxUpdateTableValues->setChecked(app->autoUpdateTableValues());
QVBoxLayout * tablesPageLayout = new QVBoxLayout( tables );
tablesPageLayout->addLayout(topLayout,1);
tablesPageLayout->addWidget(groupBoxTableCol);
tablesPageLayout->addWidget(groupBoxTableFonts);
tablesPageLayout->addWidget(boxTableComments);
tablesPageLayout->addWidget(boxUpdateTableValues);
tablesPageLayout->addStretch();
}
void ConfigDialog::initPlotsPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
plotsTabWidget = new QTabWidget();
initOptionsPage();
initAxesPage();
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
373
374
375
376
377
378
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
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
initCurvesPage();
plotsTabWidget->addTab( curves, QString() );
plotTicks = new QWidget();
QVBoxLayout * plotTicksLayout = new QVBoxLayout( plotTicks );
QGroupBox * ticksGroupBox = new QGroupBox();
QGridLayout * ticksLayout = new QGridLayout( ticksGroupBox );
plotTicksLayout->addWidget( ticksGroupBox );
lblMajTicks = new QLabel();
ticksLayout->addWidget( lblMajTicks, 0, 0 );
boxMajTicks = new QComboBox();
ticksLayout->addWidget( boxMajTicks, 0, 1 );
lblMajTicksLength = new QLabel();
ticksLayout->addWidget( lblMajTicksLength, 0, 2 );
boxMajTicksLength = new QSpinBox();
boxMajTicksLength->setRange(0, 100);
boxMajTicksLength->setValue(app->majTicksLength);
ticksLayout->addWidget( boxMajTicksLength, 0, 3 );
lblMinTicks = new QLabel();
ticksLayout->addWidget( lblMinTicks, 1, 0 );
boxMinTicks = new QComboBox();
ticksLayout->addWidget( boxMinTicks, 1, 1 );
lblMinTicksLength = new QLabel();
ticksLayout->addWidget( lblMinTicksLength, 1, 2 );
boxMinTicksLength = new QSpinBox();
boxMinTicksLength->setRange(0, 100);
boxMinTicksLength->setValue(app->minTicksLength);
ticksLayout->addWidget( boxMinTicksLength, 1, 3 );
ticksLayout->setRowStretch( 4, 1 );
plotsTabWidget->addTab( plotTicks, QString() );
plotFonts = new QWidget();
QVBoxLayout * plotFontsLayout = new QVBoxLayout( plotFonts );
QGroupBox * groupBox2DFonts = new QGroupBox();
plotFontsLayout->addWidget( groupBox2DFonts );
QVBoxLayout * fontsLayout = new QVBoxLayout( groupBox2DFonts );
buttonTitleFont= new QPushButton();
fontsLayout->addWidget( buttonTitleFont );
buttonLegendFont= new QPushButton();
fontsLayout->addWidget( buttonLegendFont );
buttonAxesFont= new QPushButton();
fontsLayout->addWidget( buttonAxesFont );
buttonNumbersFont= new QPushButton();
fontsLayout->addWidget( buttonNumbersFont );
fontsLayout->addStretch();
plotsTabWidget->addTab( plotFonts, QString() );
plotPrint = new QWidget();
QVBoxLayout *printLayout = new QVBoxLayout( plotPrint );
boxScaleLayersOnPrint = new QCheckBox();
boxScaleLayersOnPrint->setChecked(app->d_scale_plots_on_print);
printLayout->addWidget( boxScaleLayersOnPrint );
boxPrintCropmarks = new QCheckBox();
boxPrintCropmarks->setChecked(app->d_print_cropmarks);
printLayout->addWidget( boxPrintCropmarks );
printLayout->addStretch();
plotsTabWidget->addTab(plotPrint, QString());
connect( boxResize, SIGNAL( clicked() ), this, SLOT( enableScaleFonts() ) );
connect( boxFrame, SIGNAL( toggled(bool) ), this, SLOT( showFrameWidth(bool) ) );
connect( buttonAxesFont, SIGNAL( clicked() ), this, SLOT( pickAxesFont() ) );
connect( buttonNumbersFont, SIGNAL( clicked() ), this, SLOT( pickNumbersFont() ) );
connect( buttonLegendFont, SIGNAL( clicked() ), this, SLOT( pickLegendFont() ) );
connect( buttonTitleFont, SIGNAL( clicked() ), this, SLOT( pickTitleFont() ) );
}
void ConfigDialog::enableScaleFonts()
{
if(boxResize->isChecked())
boxScaleFonts->setEnabled(false);
else
boxScaleFonts->setEnabled(true);
}
void ConfigDialog::showFrameWidth(bool ok)
{
if (!ok)
{
boxFrameWidth->hide();
labelFrameWidth->hide();
}
else
{
boxFrameWidth->show();
labelFrameWidth->show();
}
}
void ConfigDialog::initPlots3DPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
plots3D = new QWidget();
QGroupBox * topBox = new QGroupBox();
QGridLayout * topLayout = new QGridLayout( topBox );
topLayout->setSpacing(5);
lblResolution = new QLabel();
topLayout->addWidget( lblResolution, 0, 0 );
boxResolution = new QSpinBox();
boxResolution->setRange(1, 100);
boxResolution->setValue(app->plot3DResolution);
topLayout->addWidget( boxResolution, 0, 1 );
boxShowLegend = new QCheckBox();
boxShowLegend->setChecked(app->showPlot3DLegend);
topLayout->addWidget( boxShowLegend, 1, 0 );
boxShowProjection = new QCheckBox();
boxShowProjection->setChecked(app->showPlot3DProjection);
topLayout->addWidget( boxShowProjection, 1, 1 );
boxSmoothMesh = new QCheckBox();
boxSmoothMesh->setChecked(app->smooth3DMesh);
topLayout->addWidget( boxSmoothMesh, 2, 0 );
boxOrthogonal = new QCheckBox();
boxOrthogonal->setChecked(app->orthogonal3DPlots);
topLayout->addWidget( boxOrthogonal, 2, 1 );
boxAutoscale3DPlots = new QCheckBox();
boxAutoscale3DPlots->setChecked(app->autoscale3DPlots);
topLayout->addWidget( boxAutoscale3DPlots, 3, 0 );
groupBox3DCol = new QGroupBox();
QGridLayout * middleLayout = new QGridLayout( groupBox3DCol );
QStringList plot3DColors = app->plot3DColors;
btnFromColor = new ColorButton();
btnFromColor->setColor(QColor(plot3DColors[4]));
middleLayout->addWidget( btnFromColor, 0, 0 );
btnLabels = new ColorButton();
btnLabels->setColor(QColor(plot3DColors[1]));
middleLayout->addWidget( btnLabels, 0, 1 );
btnMesh = new ColorButton();
btnMesh->setColor(QColor(plot3DColors[2]));
middleLayout->addWidget( btnMesh, 0, 2 );
btnGrid = new ColorButton();
btnGrid->setColor(QColor(plot3DColors[3]));
middleLayout->addWidget( btnGrid, 0, 3 );
btnToColor = new ColorButton();
btnToColor->setColor(QColor(plot3DColors[0]));
middleLayout->addWidget( btnToColor, 1, 0 );
btnNumbers = new ColorButton();
btnNumbers->setColor(QColor(plot3DColors[5]));
middleLayout->addWidget( btnNumbers, 1, 1 );
btnAxes = new ColorButton();
btnAxes->setColor(QColor(plot3DColors[6]));
middleLayout->addWidget( btnAxes, 1, 2 );
btnBackground3D = new ColorButton();
btnBackground3D->setColor(QColor(plot3DColors[7]));
middleLayout->addWidget( btnBackground3D, 1, 3 );
groupBox3DFonts = new QGroupBox();
QHBoxLayout * bottomLayout = new QHBoxLayout( groupBox3DFonts );
btnTitleFnt = new QPushButton();
bottomLayout->addWidget( btnTitleFnt );
btnLabelsFnt = new QPushButton();
bottomLayout->addWidget( btnLabelsFnt );
btnNumFnt = new QPushButton();
bottomLayout->addWidget( btnNumFnt );
QVBoxLayout * plots3DPageLayout = new QVBoxLayout( plots3D );
plots3DPageLayout->addWidget(topBox);
plots3DPageLayout->addWidget(groupBox3DCol);
plots3DPageLayout->addWidget(groupBox3DFonts);
plots3DPageLayout->addStretch();
connect( btnNumFnt, SIGNAL( clicked() ), this, SLOT(pick3DNumbersFont() ) );
connect( btnTitleFnt, SIGNAL( clicked() ), this, SLOT(pick3DTitleFont() ) );
connect( btnLabelsFnt, SIGNAL( clicked() ), this, SLOT(pick3DAxesFont() ) );
}
void ConfigDialog::initAppPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
appTabWidget = new QTabWidget(generalDialog);
appTabWidget->setUsesScrollButtons(false);
application = new QWidget();
QVBoxLayout * applicationLayout = new QVBoxLayout( application );
QGroupBox * groupBoxApp = new QGroupBox();
applicationLayout->addWidget(groupBoxApp);
QGridLayout * topBoxLayout = new QGridLayout( groupBoxApp );
lblLanguage = new QLabel();
topBoxLayout->addWidget( lblLanguage, 0, 0 );
boxLanguage = new QComboBox();
insertLanguagesList();
topBoxLayout->addWidget( boxLanguage, 0, 1 );
lblStyle = new QLabel();
topBoxLayout->addWidget( lblStyle, 1, 0 );
boxStyle = new QComboBox();
topBoxLayout->addWidget( boxStyle, 1, 1 );
QStringList styles = QStyleFactory::keys();
styles.sort();
boxStyle->addItems(styles);
boxStyle->setCurrentIndex(boxStyle->findText(app->appStyle,Qt::MatchWildcard));
lblFonts = new QLabel();
topBoxLayout->addWidget( lblFonts, 2, 0 );
fontsBtn= new QPushButton();
topBoxLayout->addWidget( fontsBtn, 2, 1 );
lblScriptingLanguage = new QLabel();
topBoxLayout->addWidget( lblScriptingLanguage, 3, 0 );
boxScriptingLanguage = new QComboBox();
QStringList llist = ScriptingLangManager::languages();
boxScriptingLanguage->insertStringList(llist);
boxScriptingLanguage->setCurrentItem(llist.findIndex(app->defaultScriptingLang));
topBoxLayout->addWidget( boxScriptingLanguage, 3, 1 );
lblUndoStackSize = new QLabel();
topBoxLayout->addWidget( lblUndoStackSize, 4, 0 );
undoStackSizeBox = new QSpinBox();
undoStackSizeBox->setValue(app->matrixUndoStackSize());
topBoxLayout->addWidget( undoStackSizeBox, 4, 1 );
lblEndOfLine = new QLabel();
topBoxLayout->addWidget(lblEndOfLine, 5, 0 );
boxEndLine = new QComboBox();
boxEndLine->addItem(tr("LF (Unix)"));
boxEndLine->addItem(tr("CRLF (Windows)"));
boxEndLine->addItem(tr("CR (Mac)"));
boxEndLine->setCurrentIndex((int)app->d_eol);
topBoxLayout->addWidget(boxEndLine, 5, 1);
lblInitWindow = new QLabel();
topBoxLayout->addWidget( lblInitWindow, 6, 0 );
boxInitWindow = new QComboBox();
topBoxLayout->addWidget( boxInitWindow, 6, 1 );
boxSave= new QCheckBox();
boxSave->setChecked(app->autoSave);
topBoxLayout->addWidget( boxSave, 7, 0 );
boxMinutes = new QSpinBox();
boxMinutes->setRange(1, 100);
boxMinutes->setValue(app->autoSaveTime);
boxMinutes->setEnabled(app->autoSave);
topBoxLayout->addWidget( boxMinutes, 7, 1 );
boxBackupProject = new QCheckBox();
boxBackupProject->setChecked(app->d_backup_files);
topBoxLayout->addWidget( boxBackupProject, 8, 0, 1, 2 );
boxSearchUpdates = new QCheckBox();
boxSearchUpdates->setChecked(app->autoSearchUpdates);
topBoxLayout->addWidget( boxSearchUpdates, 9, 0, 1, 2 );
topBoxLayout->setRowStretch(10, 1);
appTabWidget->addTab(application, QString());
initConfirmationsPage();
appTabWidget->addTab( confirm, QString() );
appColors = new QWidget();
QVBoxLayout * appColorsLayout = new QVBoxLayout( appColors );
QGroupBox * groupBoxAppCol = new QGroupBox();
appColorsLayout->addWidget( groupBoxAppCol );
QGridLayout * colorsBoxLayout = new QGridLayout( groupBoxAppCol );
lblWorkspace = new QLabel();
colorsBoxLayout->addWidget( lblWorkspace, 0, 0 );
btnWorkspace = new ColorButton();
btnWorkspace->setColor(app->workspaceColor);
colorsBoxLayout->addWidget( btnWorkspace, 0, 1 );
lblPanels = new QLabel();
colorsBoxLayout->addWidget( lblPanels, 1, 0 );
btnPanels = new ColorButton();
colorsBoxLayout->addWidget( btnPanels, 1, 1 );
btnPanels->setColor(app->panelsColor);
lblPanelsText = new QLabel();
colorsBoxLayout->addWidget( lblPanelsText, 2, 0 );
btnPanelsText = new ColorButton();
colorsBoxLayout->addWidget( btnPanelsText, 2, 1 );
btnPanelsText->setColor(app->panelsTextColor);
colorsBoxLayout->setRowStretch( 3, 1 );
appTabWidget->addTab( appColors, QString() );
numericFormatPage = new QWidget();
QVBoxLayout *numLayout = new QVBoxLayout( numericFormatPage );
QGroupBox *numericFormatBox = new QGroupBox();
numLayout->addWidget( numericFormatBox );
QGridLayout *numericFormatLayout = new QGridLayout( numericFormatBox );
lblAppPrecision = new QLabel();
numericFormatLayout->addWidget(lblAppPrecision, 0, 0);
boxAppPrecision = new QSpinBox();
boxAppPrecision->setRange(0, 14);
boxAppPrecision->setValue(app->d_decimal_digits);
numericFormatLayout->addWidget(boxAppPrecision, 0, 1);
lblDecimalSeparator = new QLabel();
numericFormatLayout->addWidget(lblDecimalSeparator, 1, 0 );
boxDecimalSeparator = new QComboBox();
boxDecimalSeparator->addItem(tr("System Locale Setting"));
boxDecimalSeparator->addItem("1,000.0");
boxDecimalSeparator->addItem("1.000,0");
boxDecimalSeparator->addItem("1 000,0");
numericFormatLayout->addWidget(boxDecimalSeparator, 1, 1);
boxThousandsSeparator = new QCheckBox();
boxThousandsSeparator->setChecked(app->locale().numberOptions() & QLocale::OmitGroupSeparator);
numericFormatLayout->addWidget(boxThousandsSeparator, 2, 0);
boxUpdateSeparators = new QCheckBox();
boxUpdateSeparators->setChecked(true);
numericFormatLayout->addWidget(boxUpdateSeparators, 3, 0);
numericFormatLayout->setRowStretch(4, 1);
appTabWidget->addTab( numericFormatPage, QString() );
initFileLocationsPage();
connect( boxLanguage, SIGNAL( activated(int) ), this, SLOT( switchToLanguage(int) ) );
connect( fontsBtn, SIGNAL( clicked() ), this, SLOT( pickApplicationFont() ) );
connect( boxSave, SIGNAL( toggled(bool) ), boxMinutes, SLOT( setEnabled(bool) ) );
}
Gigg, Martyn Anthony
committed
/**
* Configure a Mantid page on the config dialog
*/
void ConfigDialog::initMantidPage()
{
mtdTabWidget = new QTabWidget(generalDialog);
mtdTabWidget->setUsesScrollButtons(false);
Gigg, Martyn Anthony
committed
instrumentPage = new QWidget();
QVBoxLayout *instrTabLayout = new QVBoxLayout(instrumentPage);
Gigg, Martyn Anthony
committed
QGroupBox *frame = new QGroupBox();
instrTabLayout->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
Gigg, Martyn Anthony
committed
mtdTabWidget->addTab(instrumentPage, QString());
Gigg, Martyn Anthony
committed
facility = new QComboBox();
grid->addWidget(new QLabel("Facility"), 0, 0);
grid->addWidget(facility, 0, 1);
Gigg, Martyn Anthony
committed
knownInstruments = new QLineEdit();
connect(knownInstruments, SIGNAL(textChanged(const QString&)), this, SLOT(updateDefInstrList()));
grid->addWidget(new QLabel("Instrument Prefixes"), 1, 0);
grid->addWidget(knownInstruments, 1, 1);
Gigg, Martyn Anthony
committed
instrPrefix = new QComboBox();
Gigg, Martyn Anthony
committed
grid->addWidget(new QLabel("Default Prefix"), 2, 0);
grid->addWidget(instrPrefix, 2, 1);
grid->setRowStretch(3,1);
Gigg, Martyn Anthony
committed
// Populate boxes
Mantid::Kernel::ConfigServiceImpl & mantid_config = Mantid::Kernel::ConfigService::Instance();
QString property = QString::fromStdString(mantid_config.getString("supported.facilities"));
QStringList prop_list = property.split(";", QString::SkipEmptyParts);
facility->addItems(prop_list);
// Set default property
property = QString::fromStdString(mantid_config.getString("default.facility"));
int index = facility->findText(property);
if( index < 0 )
{
index = 0;
}
Gigg, Martyn Anthony
committed
facility->setCurrentIndex(index);
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
property = QString::fromStdString(mantid_config.getString("instrument.prefixes." + property.toStdString()));
knownInstruments->setText(property);
Gigg, Martyn Anthony
committed
property = QString::fromStdString(mantid_config.getString("default.instrument"));
index = instrPrefix->findText(property);
if( index < 0 )
{
index = 0;
}
instrPrefix->setCurrentIndex(index);
Gigg, Martyn Anthony
committed
initDirSearchTab();
initCurveFittingTab();
}
Roman Tolchenov
committed
Gigg, Martyn Anthony
committed
void ConfigDialog::initDirSearchTab()
{
Roman Tolchenov
committed
directoriesPage = new QWidget();
QVBoxLayout *dirTabLayout = new QVBoxLayout(directoriesPage);
Gigg, Martyn Anthony
committed
QGroupBox *frame = new QGroupBox();
Roman Tolchenov
committed
dirTabLayout->addWidget(frame);
Gigg, Martyn Anthony
committed
QGridLayout *grid = new QGridLayout(frame);
Roman Tolchenov
committed
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
mtdTabWidget->addTab(directoriesPage, "Directories");
/// datasearch.directories
QLabel* label = new QLabel(tr("Data search"));
grid->addWidget(label, 0, 0);
std::string str = Mantid::Kernel::ConfigService::Instance().getString("datasearch.directories");
leDataSearchDirs = new QLineEdit();
leDataSearchDirs->setText(QString::fromStdString(str));
grid->addWidget(leDataSearchDirs, 0, 1);
QPushButton *button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 0, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addDataSearchDirs()) );
/// defaultsave.directory
label = new QLabel(tr("Default save"));
grid->addWidget(label, 1, 0);
str = Mantid::Kernel::ConfigService::Instance().getString("defaultsave.directory");
leDefaultSaveDir = new QLineEdit();
leDefaultSaveDir->setText(QString::fromStdString(str));
grid->addWidget(leDefaultSaveDir, 1, 1);
button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 1, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addDefaultSaveDir()) );
Roman Tolchenov
committed
720
721
722
723
724
725
726
727
728
729
730
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
765
766
767
/// pythonscripts.directories
label = new QLabel(tr("Python scripts"));
grid->addWidget(label, 2, 0);
str = Mantid::Kernel::ConfigService::Instance().getString("pythonscripts.directories");
lePythonScriptsDirs = new QLineEdit();
lePythonScriptsDirs->setText(QString::fromStdString(str));
grid->addWidget(lePythonScriptsDirs, 2, 1);
button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 2, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addPythonScriptsDirs()) );
/// pythonscripts.directories
label = new QLabel(tr("Python algorithms"));
grid->addWidget(label, 3, 0);
str = Mantid::Kernel::ConfigService::Instance().getString("pythonalgorithms.directories");
lePythonAlgorithmsDirs = new QLineEdit();
lePythonAlgorithmsDirs->setText(QString::fromStdString(str));
grid->addWidget(lePythonAlgorithmsDirs, 3, 1);
button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 3, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addPythonAlgorithmsDirs()) );
/// instrumentDefinition.directory
label = new QLabel(tr("Instrument definitions"));
grid->addWidget(label, 4, 0);
str = Mantid::Kernel::ConfigService::Instance().getString("instrumentDefinition.directory");
leInstrumentDir = new QLineEdit();
leInstrumentDir->setText(QString::fromStdString(str));
grid->addWidget(leInstrumentDir, 4, 1);
button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 4, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addInstrumentDir()) );
/// parameterDefinition.directory
Steve Williams
committed
label = new QLabel(tr("Parameter definitions"));
Roman Tolchenov
committed
grid->addWidget(label, 5, 0);
str = Mantid::Kernel::ConfigService::Instance().getString("parameterDefinition.directory");
leParameterDir = new QLineEdit();
leParameterDir->setText(QString::fromStdString(str));
grid->addWidget(leParameterDir, 5, 1);
Steve Williams
committed
Roman Tolchenov
committed
button = new QPushButton();
button->setIcon(QIcon(QPixmap(choose_folder_xpm)));
grid->addWidget(button, 5, 2);
connect( button, SIGNAL(clicked()), this, SLOT(addParameterDir()) );
grid->setRowStretch(6,1);
Gigg, Martyn Anthony
committed
}
Gigg, Martyn Anthony
committed
void ConfigDialog::initCurveFittingTab()
{
curveFittingPage = new QWidget();
QVBoxLayout *curveTabLayout = new QVBoxLayout(curveFittingPage);
QGroupBox *frame = new QGroupBox();
curveTabLayout->addWidget(frame);
QGridLayout *grid = new QGridLayout(frame);
mtdTabWidget->addTab(curveFittingPage, "Curve Fitting");
// Background functions list
grid->addWidget(new QLabel(tr("Auto background")),0,0);
backgroundFunctions = new QComboBox();
grid->addWidget(backgroundFunctions, 0, 1);
Gigg, Martyn Anthony
committed
QLabel *label = new QLabel(tr("Background arguments"));
QString tip = tr("A space-separated list of name=value arguments, \n"
"i.e. a=1 b=2");
label->setToolTip(tip);
grid->addWidget(label,1,0);
Gigg, Martyn Anthony
committed
functionArguments = new QLineEdit();
Gigg, Martyn Anthony
committed
functionArguments->setToolTip(tip);
Gigg, Martyn Anthony
committed
grid->addWidget(functionArguments, 1,1);
Roman Tolchenov
committed
grid->addWidget(new QLabel(tr("Default peak shape")),2,0);
defaultPeakShape = new QComboBox();
grid->addWidget(defaultPeakShape, 2,1);
grid->addWidget(new QLabel(tr("FindPeaks FWHM")),3,0);
findPeaksFWHM = new QSpinBox();
grid->addWidget(findPeaksFWHM, 3,1);
grid->addWidget(new QLabel(tr("FindPeaks Tolerance")),4,0);
findPeaksTolerance = new QSpinBox();
grid->addWidget(findPeaksTolerance, 4,1);
grid->setRowStretch(5,1);
Gigg, Martyn Anthony
committed
label = new QLabel("<span style=\"font-weight:600;\">Note: Changes will not take effect until MantidPlot has been restarted.</span>");
curveTabLayout->addWidget(label);
Gigg, Martyn Anthony
committed
// Find list of background functions
// Add none option
backgroundFunctions->addItem("None");
Mantid::API::FunctionFactoryImpl & function_creator = Mantid::API::FunctionFactory::Instance();
std::vector<std::string> allfunctions = function_creator.getKeys();
size_t nfuncs = allfunctions.size();
for( size_t i = 0; i < nfuncs; ++i )
{
std::string name = allfunctions[i];
Mantid::API::IFunction* function = function_creator.createUnwrapped(name);
if( dynamic_cast<Mantid::API::IBackgroundFunction*>(function) )
{
backgroundFunctions->addItem(QString::fromStdString(name));
}
Roman Tolchenov
committed
if( dynamic_cast<Mantid::API::IPeakFunction*>(function) )
{
defaultPeakShape->addItem(QString::fromStdString(name));
}
Gigg, Martyn Anthony
committed
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
}
// Set the correct default property
QString setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("CurveFitting.AutoBackground"));
QStringList value = setting.split(' ');
int index(-1);
if( value.isEmpty() )
{
index = 0;
}
else
{
index = backgroundFunctions->findText(value[0], Qt::MatchFixedString);// Case insensitive
if( value.size() > 1 )
{
value.removeFirst();
QString args = value.join(" ");
functionArguments->setText(args);
}
}
if( index < 0 )
{
backgroundFunctions->setCurrentIndex(0);
}
else
{
backgroundFunctions->setCurrentIndex(index);
}
Roman Tolchenov
committed
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
setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("CurveFitting.DefaultPeak"));
if (setting.isEmpty()) setting = "Gaussian";
index = defaultPeakShape->findText(setting);
if (index >= 0)
{
defaultPeakShape->setCurrentIndex(index);
}
setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("CurveFitting.FindPeaksFWHM"));
if (!setting.isEmpty())
{
findPeaksFWHM->setValue(setting.toInt());
}
else
{
findPeaksFWHM->setValue(7);
}
setting = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("CurveFitting.FindPeaksTolerance"));
if (!setting.isEmpty())
{
findPeaksTolerance->setValue(setting.toInt());
}
else
{
findPeaksTolerance->setValue(4);
}
Gigg, Martyn Anthony
committed
}
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
void ConfigDialog::initOptionsPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
plotOptions = new QWidget();
QVBoxLayout * optionsTabLayout = new QVBoxLayout( plotOptions );
optionsTabLayout->setSpacing(5);
QGroupBox * groupBoxOptions = new QGroupBox();
optionsTabLayout->addWidget( groupBoxOptions );
QGridLayout * optionsLayout = new QGridLayout( groupBoxOptions );
boxAutoscaling = new QCheckBox();
boxAutoscaling->setChecked(app->autoscale2DPlots);
optionsLayout->addWidget( boxAutoscaling, 0, 0 );
boxScaleFonts = new QCheckBox();
boxScaleFonts->setChecked(app->autoScaleFonts);
optionsLayout->addWidget( boxScaleFonts, 0, 1 );
boxTitle = new QCheckBox();
boxTitle->setChecked(app->titleOn);
optionsLayout->addWidget( boxTitle, 1, 0 );
boxAntialiasing = new QCheckBox();
boxAntialiasing->setChecked(app->antialiasing2DPlots);
optionsLayout->addWidget( boxAntialiasing, 1, 1 );
boxFrame = new QCheckBox();
boxFrame->setChecked(app->canvasFrameWidth > 0);
optionsLayout->addWidget( boxFrame, 2, 0 );
labelFrameWidth = new QLabel();
optionsLayout->addWidget( labelFrameWidth, 3, 0 );
boxFrameWidth= new QSpinBox();
optionsLayout->addWidget( boxFrameWidth, 3, 1 );
boxFrameWidth->setRange(1, 100);
boxFrameWidth->setValue(app->canvasFrameWidth);
if (!app->canvasFrameWidth)
{
labelFrameWidth->hide();
boxFrameWidth->hide();
}
lblMargin = new QLabel();
optionsLayout->addWidget( lblMargin, 4, 0 );
boxMargin= new QSpinBox();
boxMargin->setRange(0, 1000);
boxMargin->setSingleStep(5);
boxMargin->setValue(app->defaultPlotMargin);
optionsLayout->addWidget( boxMargin, 4, 1 );
optionsLayout->setRowStretch( 7, 1 );
boxResize = new QCheckBox();
boxResize->setChecked(!app->autoResizeLayers);
if(boxResize->isChecked())
boxScaleFonts->setEnabled(false);
optionsTabLayout->addWidget( boxResize );
boxLabelsEditing = new QCheckBox();
boxLabelsEditing->setChecked(!app->d_in_place_editing);
optionsTabLayout->addWidget(boxLabelsEditing);
plotsTabWidget->addTab( plotOptions, QString() );
}
void ConfigDialog::initAxesPage()
{
ApplicationWindow *app = (ApplicationWindow *)parentWidget();
plotAxes = new QWidget();
plotsTabWidget->addTab( plotAxes, QString() );
QGroupBox * axesGroupBox = new QGroupBox();
QGridLayout * axisBoxLayout = new QGridLayout( axesGroupBox );
lblXLogLin = new QLabel();
axisBoxLayout->addWidget( lblXLogLin, 0, 0 );
cbXLog = new QComboBox();
cbXLog->addItem(tr("linear"));
cbXLog->addItem("log");
if ( app->xaxisScale == "log" )
{
cbXLog->setCurrentIndex(1);
}
else
{
cbXLog->setCurrentIndex(0);
}
axisBoxLayout->addWidget(cbXLog, 0, 1);
lblYLogLin = new QLabel();
axisBoxLayout->addWidget( lblYLogLin, 1, 0 );