1
/***************************************************************************
3
* copyright : (C) 2007 The University of Toronto *
4
* netterfield@astro.utoronto.ca *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
***************************************************************************/
13
#include "mainwindow.h"
15
#include "datamanager.h"
16
#include "debugdialog.h"
17
#include "debugnotifier.h"
19
#include "ellipseitem.h"
20
#include "exportgraphicsdialog.h"
21
#include "exportvectorsdialog.h"
22
#include "logdialog.h"
23
#include "application.h"
25
#include "labelitem.h"
27
#include "circleitem.h"
28
#include "arrowitem.h"
29
#include "memorywidget.h"
30
#include "objectstore.h"
31
#include "pictureitem.h"
33
#include "plotitemmanager.h"
35
#include "tabwidget.h"
36
#include "sharedaxisboxitem.h"
37
#include "ui_aboutdialog.h"
38
#include "viewvectordialog.h"
39
#include "viewmatrixdialog.h"
40
#include "viewprimitivedialog.h"
42
#include "applicationsettings.h"
43
#include "updatemanager.h"
44
#include "datasourcepluginmanager.h"
45
#include "pluginmenuitemaction.h"
47
#include "applicationsettingsdialog.h"
48
#include "differentiatecurvesdialog.h"
49
#include "choosecolordialog.h"
50
#include "changedatasampledialog.h"
51
#include "changefiledialog.h"
52
#include "bugreportwizard.h"
53
#include "datawizard.h"
54
#include "aboutdialog.h"
55
#include "datavector.h"
56
#include "commandlineparser.h"
57
#include "dialogdefaults.h"
59
#include "dialoglauncher.h"
66
MainWindow::MainWindow() :
71
_differentiateCurvesDialog(0),
72
_chooseColorDialog(0),
73
_changeDataSampleDialog(0),
76
_applicationSettingsDialog(0),
78
_highlightPoint(false)
80
_doc = new Document(this);
81
_tabWidget = new TabWidget(this);
82
_undoGroup = new QUndoGroup(this);
83
_debugDialog = new DebugDialog(this);
84
Debug::self()->setHandler(_debugDialog);
86
setWindowTitle("Kst");
93
_tabWidget->createView();
95
setCentralWidget(_tabWidget);
96
connect(_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentViewChanged()));
97
connect(_tabWidget, SIGNAL(currentViewModeChanged()), this, SLOT(currentViewModeChanged()));
98
connect(PlotItemManager::self(), SIGNAL(tiedZoomRemoved()), this, SLOT(tiedZoomRemoved()));
99
connect(PlotItemManager::self(), SIGNAL(allPlotsTiedZoom()), this, SLOT(allPlotsTiedZoom()));
102
connect(UpdateManager::self(), SIGNAL(objectsUpdated(qint64)), this, SLOT(updateViewItems(qint64)));
104
QTimer::singleShot(0, this, SLOT(performHeavyStartupActions()));
106
updateRecentKstFiles();
110
MainWindow::~MainWindow() {
118
void MainWindow::performHeavyStartupActions() {
119
// Set the timer for the UpdateManager.
120
UpdateManager::self()->setMinimumUpdatePeriod(ApplicationSettings::self()->minimumUpdatePeriod());
122
DataSourcePluginManager::init();
126
void MainWindow::cleanup() {
127
if (document() && document()->objectStore()) {
128
document()->objectStore()->clear();
133
void MainWindow::setLayoutMode(bool layoutMode) {
134
View *v = tabWidget()->currentView();
138
v->setViewMode(View::Layout);
139
_highlightPointAct->setEnabled(false);
140
_tiedZoomAct->setEnabled(false);
142
v->setViewMode(View::Data);
143
_highlightPointAct->setEnabled(true);
144
_tiedZoomAct->setEnabled(true);
148
void MainWindow::setHighlightPoint(bool highlight) {
149
_highlightPoint = highlight;
152
void MainWindow::changeZoomOnlyMode(QAction* act) {
153
if (act == _layoutModeAct && act->isChecked()) {
156
setLayoutMode(false);
158
tabWidget()->currentView()->setZoomOnly((View::ZoomOnlyMode)act->data().toInt());
161
void MainWindow::toggleTiedZoom() {
162
PlotItemManager::self()->toggleAllTiedZoom(tabWidget()->currentView());
166
void MainWindow::tiedZoomRemoved() {
167
_tiedZoomAct->setChecked(false);
171
void MainWindow::allPlotsTiedZoom() {
172
_tiedZoomAct->setChecked(true);
176
bool MainWindow::promptSave() {
177
int rc = QMessageBox::warning(this, tr("Kst"), tr("Your document has been modified.\nSave changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
178
if (rc == QMessageBox::Save) {
180
} else if (rc == QMessageBox::Cancel) {
187
void MainWindow::closeEvent(QCloseEvent *e) {
188
if (_doc->isChanged() && !promptSave()) {
193
QMainWindow::closeEvent(e);
197
Document *MainWindow::document() const {
202
QUndoGroup *MainWindow::undoGroup() const {
207
TabWidget *MainWindow::tabWidget() const {
212
void MainWindow::save() {
213
if (_doc->isOpen()) {
221
void MainWindow::saveAs() {
222
QString fn = QFileDialog::getSaveFileName(this, tr("Kst: Save File"), _doc->fileName(), tr("Kst Sessions (*.kst)"));
226
QString restorePath = QDir::currentPath();
227
QString kstfiledir = fn.left(fn.lastIndexOf('/')) + '/';
228
QDir::setCurrent(kstfiledir);
229
QString currentP = QDir::currentPath();
231
QDir::setCurrent(restorePath);
232
setWindowTitle("Kst - " + fn);
233
updateRecentKstFiles(fn);
237
void MainWindow::newDoc() {
238
bool clearApproved = false;
239
if (_doc->isChanged()) {
240
clearApproved = promptSave();
242
int rc = QMessageBox::warning(this, tr("Kst"), tr("Delete everything?"), QMessageBox::Ok, QMessageBox::Cancel);
243
clearApproved = (rc == QMessageBox::Ok);
250
_doc = new Document(this);
255
tabWidget()->clear();
256
tabWidget()->createView();
259
void MainWindow::open() {
260
if (_doc->isChanged() && !promptSave()) {
263
QSettings settings("Kst2");
264
const QString lastKey = "lastOpenedKstFile";
265
QString fn = settings.value(lastKey).toString();
267
fn = _doc->fileName();
269
fn = QFileDialog::getOpenFileName(this, tr("Kst: Open File"), fn, tr("Kst Sessions (*.kst)"));
273
settings.setValue(lastKey, fn);
279
QAction* MainWindow::createRecentFileAction(const QString& filename, int idx, const QString& name, const char* openslot)
281
QAction* action = new QAction(this);
282
QString text = tr("&%1 %2").arg(idx).arg(name);
283
action->setText(text);
284
action->setData(filename);
285
action->setStatusTip(filename);
286
action->setVisible(true);
287
connect(action, SIGNAL(triggered()), this, openslot);
292
void MainWindow::updateRecentKstFiles(const QString& filename)
294
updateRecentFiles("recentKstFileList", _fileMenu, _bottomRecentKstActions, _recentKstFilesMenu, filename, SLOT(openRecentKstFile()));
298
void MainWindow::updateRecentDataFiles(const QString& filename)
300
updateRecentFiles("recentDataFileList", _toolsMenu, _bottomRecentDataActions, _recentDataFilesMenu, filename, SLOT(openRecentDataFile()));
301
if (!filename.isEmpty()) {
302
_dialogDefaults->setValue("vector/datasource", filename);
307
void MainWindow::updateRecentFiles(const QString& key, QMenu* menu, QList<QAction*>& actions, QMenu* submenu, const QString& newfilename, const char* openslot)
309
foreach(QAction* it, actions) {
310
menu->removeAction(it);
314
QSettings settings("Kst2");
315
QStringList recentFiles = settings.value(key).toStringList();
316
if (recentFiles.removeDuplicates() > 0) {
317
settings.setValue(key, recentFiles);
319
if (!newfilename.isEmpty()) {
320
recentFiles.removeOne(newfilename);
321
recentFiles.push_front(newfilename);
322
recentFiles = recentFiles.mid(0, 30);
323
settings.setValue(key, recentFiles);
327
QAction* check = new QAction(this);
328
check->setText("&Cleanup Non-Existent Files");
330
check->setVisible(true);
331
connect(check, SIGNAL(triggered()), this, SLOT(checkRecentFilesOnExistence()));
332
submenu->addAction(check);
333
submenu->addSeparator();
335
foreach(const QString& it, recentFiles) {
338
// don't make file menu to wide, show complete path in statusbar
339
QAction* action = createRecentFileAction(it, i, QFileInfo(it).fileName(), openslot);
341
menu->addAction(action);
343
submenu->addAction(createRecentFileAction(it, i, it, openslot));
348
void MainWindow::openRecentKstFile()
350
QAction *action = qobject_cast<QAction *>(sender());
352
openFile(action->data().toString());
357
void MainWindow::checkRecentFilesOnExistence()
359
QAction *action = qobject_cast<QAction *>(sender());
361
QSettings settings("Kst2");
362
QStringList recentFiles = settings.value(action->data().toString()).toStringList();
363
recentFiles.removeDuplicates();
364
foreach(const QString& it, recentFiles) {
365
if (!QFileInfo(it).exists()) {
366
recentFiles.removeOne(it);
369
settings.setValue(action->data().toString(), recentFiles);
370
updateRecentKstFiles();
371
updateRecentDataFiles();
377
bool MainWindow::initFromCommandLine() {
379
_doc = new Document(this);
381
CommandLineParser P(_doc, this);
383
bool ok = _doc->initFromCommandLine(&P);
384
if (!P.pngFile().isEmpty()) {
385
exportGraphicsFile(P.pngFile(), "png", 1280, 1024,0);
388
if (!P.printFile().isEmpty()) {
389
printFromCommandLine(P.printFile());
392
if (!P.kstFileName().isEmpty()) {
393
setWindowTitle("Kst - " + P.kstFileName());
395
_doc->setChanged(false);
399
void MainWindow::openFile(const QString &file) {
400
QDir::setCurrent(file.left(file.lastIndexOf('/')) + '/');
401
QDir::setCurrent(file.left(file.lastIndexOf('/')));
403
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
407
_doc = new Document(this);
409
bool ok = _doc->open(file);
410
QApplication::restoreOverrideCursor();
413
QMessageBox::critical(this, tr("Kst"),
414
tr("Error opening document '%1':\n%2\n"
415
"Maybe it is a Kst 1 file which could not be read by Kst 2.").arg(file, _doc->lastError()));
417
_doc = new Document(this);
420
setWindowTitle("Kst - " + file);
421
updateRecentKstFiles(file);
425
void MainWindow::exportGraphicsFile(
426
const QString &filename, const QString &format, int width, int height, int display) {
428
int n_views = _tabWidget->views().size();
429
foreach (View *view, _tabWidget->views()) {
432
size.setWidth(width);
433
size.setHeight(height);
434
} else if (display == 1) {
435
size.setWidth(width);
436
size.setHeight(width);
437
} else if (display == 2) {
438
QSize sizeWindow(view->geometry().size());
440
size.setWidth(width);
441
size.setHeight((int)((double)width * (double)sizeWindow.height() / (double)sizeWindow.width()));
443
QSize sizeWindow(view->geometry().size());
445
size.setHeight(height);
446
size.setWidth((int)((double)height * (double)sizeWindow.width() / (double)sizeWindow.height()));
449
QImage image(size, QImage::Format_ARGB32);
451
QPainter painter(&image);
452
QSize currentSize(view->size());
454
view->processResize(size);
455
view->setPrinting(true);
456
view->render(&painter);
457
view->setPrinting(false);
458
view->resize(currentSize);
459
view->processResize(currentSize);
461
QString file = filename;
463
QFileInfo QFI(filename);
464
file = QFI.completeBaseName() +
466
QString::number(viewCount+1) + '.' +
470
QImageWriter imageWriter(file, format.toLatin1());
471
imageWriter.write(image);
476
void MainWindow::exportLog(const QString &imagename, QString &msgfilename, const QString &format, int x_size, int y_size,
477
int size_option_index, const QString &message) {
478
View *view = _tabWidget->currentView();
481
if (size_option_index == 0) {
482
size.setWidth(x_size);
483
size.setHeight(y_size);
484
} else if (size_option_index == 1) {
485
size.setWidth(x_size);
486
size.setHeight(y_size);
487
} else if (size_option_index == 2) {
488
QSize sizeWindow(view->geometry().size());
490
size.setWidth(x_size);
491
size.setHeight((int)((double)x_size * (double)sizeWindow.height() / (double)sizeWindow.width()));
493
QSize sizeWindow(view->geometry().size());
495
size.setHeight(y_size);
496
size.setWidth((int)((double)y_size * (double)sizeWindow.width() / (double)sizeWindow.height()));
499
QImage image(size, QImage::Format_ARGB32);
501
QPainter painter(&image);
502
QSize currentSize(view->size());
504
view->processResize(size);
505
view->setPrinting(true);
506
view->render(&painter);
507
view->setPrinting(false);
508
view->resize(currentSize);
509
view->processResize(currentSize);
511
QImageWriter imageWriter(imagename, format.toLatin1());
512
imageWriter.write(image);
514
QFile file(msgfilename);
516
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
517
QTextStream out(&file);
524
void MainWindow::printToPrinter(QPrinter *printer) {
526
QPainter painter(printer);
529
switch (printer->printRange()) {
530
case QPrinter::PageRange:
531
if (printer->fromPage()>0) {
532
for (int i_page = printer->fromPage(); i_page<=printer->toPage(); i_page++) {
533
pages.append(_tabWidget->views().at(i_page-1));
537
case QPrinter::AllPages:
538
foreach (View *view, _tabWidget->views()) {
542
case QPrinter::Selection:
544
pages.append(_tabWidget->currentView());
548
QSize printerPageSize = printer->pageRect().size();
549
for (int i = 0; i < printer->numCopies(); ++i) {
550
for (int i_page = 0; i_page<pages.count(); i_page++) {
551
View *view = pages.at(i_page);
552
QSize currentSize(view->size());
553
view->resize(printerPageSize);
554
view->processResize(printerPageSize);
555
view->setPrinting(true);
556
view->render(&painter);
557
view->setPrinting(false);
558
view->resize(currentSize);
559
view->processResize(currentSize);
560
if (i_page<pages.count()-1)
567
void MainWindow::printFromCommandLine(const QString &printFileName) {
568
QPrinter printer(QPrinter::ScreenResolution);
569
printer.setOutputFileName(printFileName);
570
setPrinterDefaults(&printer);
572
printer.setPrintRange(QPrinter::AllPages);
573
printToPrinter(&printer);
576
void MainWindow::setPrinterDefaults(QPrinter *printer) {
577
if (_dialogDefaults->value("print/landscape",true).toBool()) {
578
printer->setOrientation(QPrinter::Landscape);
580
printer->setOrientation(QPrinter::Portrait);
583
printer->setPaperSize(QPrinter::PaperSize(_dialogDefaults->value("print/paperSize", QPrinter::Letter).toInt()));
585
QPointF topLeft =_dialogDefaults->value("print/topLeftMargin", QPointF(15.0,15.0)).toPointF();
586
QPointF bottomRight =_dialogDefaults->value("print/bottomRightMargin", QPointF(15.0,15.0)).toPointF();
588
printer->setPageMargins(topLeft.x(), topLeft.y(), bottomRight.x(), bottomRight.y(), QPrinter::Millimeter);
589
// Apparent Qt bug: setting the page margins here doesn't set the correspoding values in the print
590
// dialog->printer-options sub-dialog under linux. If you don't open the printer-options sub-dialog,
591
// the values here are honored.
594
void MainWindow::savePrinterDefaults(QPrinter *printer) {
595
_dialogDefaults->setValue("print/landscape", printer->orientation() == QPrinter::Landscape);
596
_dialogDefaults->setValue("print/paperSize", int(printer->paperSize()));
598
double left, top, right, bottom;
599
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
600
_dialogDefaults->setValue("print/topLeftMargin", QPointF(left, top));
601
_dialogDefaults->setValue("print/bottomRightMargin", QPointF(right, bottom));
605
void MainWindow::print() {
606
// line widths in pixels make sense when using ScreenResolution
607
// FIXME: come up with a better definition of line width!
608
QPrinter printer(QPrinter::ScreenResolution);
609
//QPrinter printer(QPrinter::HighResolution);
611
setPrinterDefaults(&printer);
613
QPointer<QPrintDialog> pd = new QPrintDialog(&printer, this);
614
#if QT_VERSION >= 0x040500
615
pd->setOption(QPrintDialog::PrintToFile);
616
pd->setOption(QPrintDialog::PrintPageRange, true);
617
pd->setOption(QAbstractPrintDialog::PrintShowPageSize,true);
620
if (pd->exec() == QDialog::Accepted) {
621
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
622
printToPrinter(&printer);
623
QApplication::restoreOverrideCursor();
624
savePrinterDefaults(&printer);
629
void MainWindow::currentViewChanged() {
630
if(!_tabWidget->currentView())
632
_undoGroup->setActiveStack(_tabWidget->currentView()->undoStack());
633
currentViewModeChanged();
637
void MainWindow::currentViewModeChanged() {
638
if(!_tabWidget->currentView())
640
_layoutModeAct->setChecked(_tabWidget->currentView()->viewMode() == View::Layout);
643
void MainWindow::aboutToQuit() {
648
void MainWindow::about() {
650
_aboutDialog = new AboutDialog(this);
652
if (_aboutDialog->isVisible()) {
653
_aboutDialog->raise();
654
_aboutDialog->activateWindow();
656
_aboutDialog->show();
660
void MainWindow::clearDrawingMarker() {
661
_createBoxAct->setChecked(false);
662
_createSharedAxisBoxAct->setChecked(false);
663
_createCircleAct->setChecked(false);
664
_createEllipseAct->setChecked(false);
665
_createLabelAct->setChecked(false);
666
_createLineAct->setChecked(false);
667
_createArrowAct->setChecked(false);
668
_createPictureAct->setChecked(false);
669
_createPlotAct->setChecked(false);
670
_createSvgAct->setChecked(false);
674
void MainWindow::createBox() {
675
if (_createBoxAct->isChecked()) {
676
clearDrawingMarker();
677
_createBoxAct->setChecked(true);
678
CreateBoxCommand *cmd = new CreateBoxCommand;
681
_tabWidget->currentView()->setMouseMode(View::Default);
687
void MainWindow::createSharedAxisBox() {
688
if (_createSharedAxisBoxAct->isChecked()) {
689
clearDrawingMarker();
690
_createSharedAxisBoxAct->setChecked(true);
691
CreateSharedAxisBoxCommand *cmd = new CreateSharedAxisBoxCommand;
694
_tabWidget->currentView()->setMouseMode(View::Default);
698
void MainWindow::createVector() {
700
DialogLauncher::self()->showVectorDialog(tmp);
704
void MainWindow::createMatrix() {
706
DialogLauncher::self()->showMatrixDialog(tmp);
710
void MainWindow::createScalar() {
712
DialogLauncher::self()->showScalarDialog(scalarName);
716
void MainWindow::createString() {
718
DialogLauncher::self()->showStringDialog(stringName);
722
void MainWindow::createCircle() {
723
if (_createCircleAct->isChecked()) {
724
clearDrawingMarker();
725
_createCircleAct->setChecked(true);
726
CreateCircleCommand *cmd = new CreateCircleCommand;
729
_tabWidget->currentView()->setMouseMode(View::Default);
734
void MainWindow::createEllipse() {
735
if (_createEllipseAct->isChecked()) {
736
clearDrawingMarker();
737
_createEllipseAct->setChecked(true);
738
CreateEllipseCommand *cmd = new CreateEllipseCommand;
741
_tabWidget->currentView()->setMouseMode(View::Default);
746
void MainWindow::createLabel() {
747
if (_createLabelAct->isChecked()) {
748
clearDrawingMarker();
749
_createLabelAct->setChecked(true);
750
CreateLabelCommand *cmd = new CreateLabelCommand;
753
_tabWidget->currentView()->setMouseMode(View::Default);
758
void MainWindow::createLine() {
759
if (_createLineAct->isChecked()) {
760
clearDrawingMarker();
761
_createLineAct->setChecked(true);
762
CreateLineCommand *cmd = new CreateLineCommand;
765
_tabWidget->currentView()->setMouseMode(View::Default);
770
void MainWindow::createArrow() {
771
if (_createArrowAct->isChecked()) {
772
clearDrawingMarker();
773
_createArrowAct->setChecked(true);
774
CreateArrowCommand *cmd = new CreateArrowCommand;
777
_tabWidget->currentView()->setMouseMode(View::Default);
782
void MainWindow::createPicture() {
783
if (_createPictureAct->isChecked()) {
784
clearDrawingMarker();
785
_createPictureAct->setChecked(true);
786
CreatePictureCommand *cmd = new CreatePictureCommand;
789
_tabWidget->currentView()->setMouseMode(View::Default);
794
void MainWindow::createPlot() {
795
if (_createPlotAct->isChecked()) {
796
clearDrawingMarker();
797
_createPlotAct->setChecked(true);
798
CreatePlotCommand *cmd = new CreatePlotCommand;
801
_tabWidget->currentView()->setMouseMode(View::Default);
806
void MainWindow::createSvg() {
807
if (_createSvgAct->isChecked()) {
808
clearDrawingMarker();
809
_createSvgAct->setChecked(true);
810
CreateSvgCommand *cmd = new CreateSvgCommand;
813
_tabWidget->currentView()->setMouseMode(View::Default);
817
void MainWindow::createCurve() {
818
DialogLauncher::self()->showCurveDialog();
821
void MainWindow::createPSD() {
822
DialogLauncher::self()->showPowerSpectrumDialog();
825
void MainWindow::createEquation() {
826
DialogLauncher::self()->showEquationDialog();
829
void MainWindow::createHistogram() {
830
DialogLauncher::self()->showHistogramDialog();
833
void MainWindow::createImage() {
834
DialogLauncher::self()->showImageDialog();
837
void MainWindow::createSpectogram() {
838
DialogLauncher::self()->showCSDDialog();
841
void MainWindow::createEventMonitor() {
842
DialogLauncher::self()->showEventMonitorDialog();
845
void MainWindow::createActions() {
846
// ***************************** File actions ******************************** //
847
_openAct = new QAction(tr("&Open..."), this);
848
_openAct->setStatusTip(tr("Open a new session"));
849
_openAct->setShortcut(tr("Ctrl+O"));
850
_openAct->setIcon(QPixmap(":document-open.png"));
851
connect(_openAct, SIGNAL(triggered()), this, SLOT(open()));
853
_saveAct = new QAction(tr("&Save"), this);
854
_saveAct->setStatusTip(tr("Save the current session"));
855
_saveAct->setShortcut(tr("Ctrl+S"));
856
_saveAct->setIcon(QPixmap(":document-save.png"));
857
connect(_saveAct, SIGNAL(triggered()), this, SLOT(save()));
859
_saveAsAct = new QAction(tr("Save &as..."), this);
860
_saveAsAct->setStatusTip(tr("Save the current session"));
861
_saveAsAct->setIcon(QPixmap(":document-save-as.png"));
862
connect(_saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
864
_closeAct = new QAction(tr("C&lose"), this);
865
_closeAct->setStatusTip(tr("Close current session"));
866
_closeAct->setIcon(QPixmap(":document-close.png"));
867
connect(_closeAct, SIGNAL(triggered()), this, SLOT(newDoc()));
869
_reloadAct = new QAction(tr("Reload All &Data Sources"), this);
870
_reloadAct->setStatusTip(tr("Reload all data sources"));
871
_reloadAct->setIcon(QPixmap(":kst_reload.png"));
872
connect(_reloadAct, SIGNAL(triggered()), this, SLOT(reload()));
874
_printAct = new QAction(tr("&Print..."), this);
875
_printAct->setStatusTip(tr("Print the current view"));
876
_printAct->setIcon(QPixmap(":document-print.png"));
877
connect(_printAct, SIGNAL(triggered()), this, SLOT(print()));
879
_exportGraphicsAct = new QAction(tr("&Export as Image..."), this);
880
_exportGraphicsAct->setStatusTip(tr("Export graphics to disk"));
881
_exportGraphicsAct->setIcon(QPixmap(":image-x-generic.png"));
882
connect(_exportGraphicsAct, SIGNAL(triggered()), this, SLOT(showExportGraphicsDialog()));
884
_exportVectorsAct = new QAction(tr("Save &Vectors to Disk..."), this);
885
_exportVectorsAct->setStatusTip(tr("Export vectors to ascii file"));
886
_exportVectorsAct->setIcon(QPixmap(":save-vectors.png"));
887
connect(_exportVectorsAct, SIGNAL(triggered()), this, SLOT(showExportVectorsDialog()));
889
_logAct = new QAction(tr("&Log Entry..."), this);
890
_logAct->setStatusTip(tr("Commit a log entry"));
891
_logAct->setIcon(QPixmap(":new-log-event.png"));
892
connect(_logAct, SIGNAL(triggered()), this, SLOT(showLogDialog()));
894
_newTabAct = new QAction(tr("&New Tab"), this);
895
_newTabAct->setStatusTip(tr("Create a new tab"));
896
_newTabAct->setIcon(QPixmap(":tab-new.png"));
897
connect(_newTabAct, SIGNAL(triggered()), tabWidget(), SLOT(createView()));
899
_closeTabAct = new QAction(tr("&Close Tab"), this);
900
_closeTabAct->setStatusTip(tr("Close the current tab"));
901
_closeTabAct->setIcon(QPixmap(":tab-close.png"));
902
connect(_closeTabAct, SIGNAL(triggered()), tabWidget(), SLOT(closeCurrentView()));
904
_exitAct = new QAction(tr("E&xit"), this);
905
_exitAct->setShortcut(tr("Ctrl+Q"));
906
_exitAct->setStatusTip(tr("Exit the application"));
907
_exitAct->setIcon(QPixmap(":application-exit.png"));
908
connect(_exitAct, SIGNAL(triggered()), this, SLOT(close()));
910
// ************************** Edit Actions ******************************* //
911
_undoAct = _undoGroup->createUndoAction(this);
912
_undoAct->setShortcut(tr("Ctrl+Z"));
913
_undoAct->setIcon(QPixmap(":edit-undo.png"));
914
_redoAct = _undoGroup->createRedoAction(this);
915
_redoAct->setShortcut(tr("Ctrl+Shift+Z"));
916
_redoAct->setIcon(QPixmap(":edit-redo.png"));
918
// ********************* View Actions ********************************** //
919
_vectorEditorAct = new QAction(tr("&Vectors"), this);
920
_vectorEditorAct->setStatusTip(tr("Show all vectors in a spreadsheet"));
921
connect(_vectorEditorAct, SIGNAL(triggered()), this, SLOT(showVectorEditor()));
923
_scalarEditorAct = new QAction(tr("&Scalars"), this);
924
_scalarEditorAct->setStatusTip(tr("Show all scalars in a spreadsheet"));
925
connect(_scalarEditorAct, SIGNAL(triggered()), this, SLOT(showScalarEditor()));
927
_matrixEditorAct = new QAction(tr("&Matrices"), this);
928
_matrixEditorAct->setStatusTip(tr("Show all matrices in a spreadsheet"));
929
connect(_matrixEditorAct, SIGNAL(triggered()), this, SLOT(showMatrixEditor()));
931
_stringEditorAct = new QAction(tr("S&trings"), this);
932
_stringEditorAct->setStatusTip(tr("Show all strings in a spreadsheet"));
933
connect(_stringEditorAct, SIGNAL(triggered()), this, SLOT(showStringEditor()));
935
// ************************ Data Range 1 click Actions ************************** //
936
_backAct = new QAction(tr("&Back One Screen"), this);
937
_backAct->setStatusTip(tr("Back one screen"));
938
_backAct->setIcon(QPixmap(":page-previous.png"));
939
connect(_backAct, SIGNAL(triggered()), this, SLOT(back()));
941
_forwardAct = new QAction(tr("&Forward One Screen"), this);
942
_forwardAct->setStatusTip(tr("Forward one screen"));
943
_forwardAct->setIcon(QPixmap(":page-next.png"));
944
connect(_forwardAct, SIGNAL(triggered()), this, SLOT(forward()));
946
_readFromEndAct = new QAction(tr("&Count from End"), this);
947
_readFromEndAct->setStatusTip(tr("Set all data vectors to count from end mode"));
948
_readFromEndAct->setIcon(QPixmap(":count-from-end.png"));
949
connect(_readFromEndAct, SIGNAL(triggered()), this, SLOT(readFromEnd()));
951
_readToEndAct = new QAction(tr("&Read to End"), this);
952
_readToEndAct->setStatusTip(tr("Set all data vectors to read to end mode"));
953
_readToEndAct->setIcon(QPixmap(":read-to-end.png"));
954
connect(_readToEndAct, SIGNAL(triggered()), this, SLOT(readToEnd()));
956
_pauseAct = new QAction(tr("&Pause"), this);
957
_pauseAct->setStatusTip(tr("Toggle pause updates of data sources"));
958
_pauseAct->setIcon(QPixmap(":pause.png"));
959
_pauseAct->setCheckable(true);
960
_pauseAct->setShortcut(QString("p"));
961
connect(_pauseAct, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
963
_changeDataSampleDialogAct = new QAction(tr("Change Data &Sample Range..."), this);
964
_changeDataSampleDialogAct->setStatusTip(tr("Show Kst's Change Data Sample Range Dialog"));
965
_changeDataSampleDialogAct->setIcon(QPixmap(":kst_changenpts.png"));
966
connect(_changeDataSampleDialogAct, SIGNAL(triggered()), this, SLOT(showChangeDataSampleDialog()));
968
// ************************ Create Actions ************************** //
969
_createPlotAct = new QAction(tr("&Plot"), this);
970
_createPlotAct->setStatusTip(tr("Create a plot for the current view"));
971
_createPlotAct->setIcon(QPixmap(":office-chart-area-stacked.png"));
972
_createPlotAct->setShortcut(QString("F11"));
973
_createPlotAct->setCheckable(true);
974
connect(_createPlotAct, SIGNAL(triggered()), this, SLOT(createPlot()));
976
_newScalarAct = new QAction(tr("&Scalar"), this);
977
connect(_newScalarAct, SIGNAL(triggered()), this, SLOT(createScalar()));
979
_newVectorAct = new QAction(tr("&Vector"), this);
980
connect(_newVectorAct, SIGNAL(triggered()), this, SLOT(createVector()));
982
_newMatrixAct = new QAction(tr("&Matrix"), this);
983
connect(_newMatrixAct, SIGNAL(triggered()), this, SLOT(createMatrix()));
985
_newStringAct = new QAction(tr("Strin&g"), this);
986
connect(_newStringAct, SIGNAL(triggered()), this, SLOT(createString()));
988
_newCurveAct = new QAction(tr("&Curve"), this);
989
connect(_newCurveAct, SIGNAL(triggered()), this, SLOT(createCurve()));
991
_newEquationAct = new QAction(tr("&Equation"), this);
992
connect(_newEquationAct, SIGNAL(triggered()), this, SLOT(createEquation()));
994
_newPSDAct = new QAction(tr("Po&wer Spectrum"), this);
995
connect(_newPSDAct, SIGNAL(triggered()), this, SLOT(createPSD()));
997
_newHistogramAct = new QAction(tr("&Histogram"), this);
998
connect(_newHistogramAct, SIGNAL(triggered()), this, SLOT(createHistogram()));
1000
_newImageAct = new QAction(tr("&Image"), this);
1001
connect(_newImageAct, SIGNAL(triggered()), this, SLOT(createImage()));
1003
_newSpectrogramAct = new QAction(tr("Spectr&ogram"), this);
1004
connect(_newSpectrogramAct, SIGNAL(triggered()), this, SLOT(createSpectogram()));
1006
_newEventMonitorAct = new QAction(tr("Eve&nt Monitor"), this);
1007
connect(_newEventMonitorAct, SIGNAL(triggered()), this, SLOT(createEventMonitor()));
1010
_createLabelAct = new QAction(tr("&Label"), this);
1011
_createLabelAct->setStatusTip(tr("Create a label for the current view"));
1012
_createLabelAct->setIcon(QPixmap(":kst_gfx_label.png"));
1013
_createLabelAct->setShortcut(QString("F3"));
1014
_createLabelAct->setCheckable(true);
1015
connect(_createLabelAct, SIGNAL(triggered()), this, SLOT(createLabel()));
1017
_createBoxAct = new QAction(tr("&Box"), this);
1018
_createBoxAct->setStatusTip(tr("Create a box for the current view"));
1019
_createBoxAct->setIcon(QPixmap(":kst_gfx_rectangle.png"));
1020
_createBoxAct->setShortcut(QString("F4"));
1021
_createBoxAct->setCheckable(true);
1022
connect(_createBoxAct, SIGNAL(triggered()), this, SLOT(createBox()));
1024
_createCircleAct = new QAction(tr("&Circle"), this);
1025
_createCircleAct->setStatusTip(tr("Create a circle for the current view"));
1026
_createCircleAct->setIcon(QPixmap(":kst_gfx_circle.png"));
1027
_createCircleAct->setShortcut(QString("F5"));
1028
_createCircleAct->setCheckable(true);
1029
connect(_createCircleAct, SIGNAL(triggered()), this, SLOT(createCircle()));
1031
_createEllipseAct = new QAction(tr("&Ellipse"), this);
1032
_createEllipseAct->setStatusTip(tr("Create an ellipse for the current view"));
1033
_createEllipseAct->setIcon(QPixmap(":kst_gfx_ellipse.png"));
1034
_createEllipseAct->setShortcut(QString("F6"));
1035
_createEllipseAct->setCheckable(true);
1036
connect(_createEllipseAct, SIGNAL(triggered()), this, SLOT(createEllipse()));
1038
_createLineAct = new QAction(tr("&Line"), this);
1039
_createLineAct->setStatusTip(tr("Create a line for the current view"));
1040
_createLineAct->setIcon(QPixmap(":kst_gfx_line.png"));
1041
_createLineAct->setShortcut(QString("F7"));
1042
_createLineAct->setCheckable(true);
1043
connect(_createLineAct, SIGNAL(triggered()), this, SLOT(createLine()));
1045
_createArrowAct = new QAction(tr("&Arrow"), this);
1046
_createArrowAct->setStatusTip(tr("Create a arrow for the current view"));
1047
_createArrowAct->setIcon(QPixmap(":kst_gfx_arrow.png"));
1048
_createArrowAct->setShortcut(QString("F8"));
1049
_createArrowAct->setCheckable(true);
1050
connect(_createArrowAct, SIGNAL(triggered()), this, SLOT(createArrow()));
1052
_createPictureAct = new QAction(tr("&Picture"), this);
1053
_createPictureAct->setStatusTip(tr("Create a picture for the current view"));
1054
_createPictureAct->setIcon(QPixmap(":image-x-generic.png"));
1055
_createPictureAct->setShortcut(QString("F9"));
1056
_createPictureAct->setCheckable(true);
1057
connect(_createPictureAct, SIGNAL(triggered()), this, SLOT(createPicture()));
1059
_createSvgAct = new QAction(tr("&Svg"), this);
1060
_createSvgAct->setStatusTip(tr("Create a svg for the current view"));
1061
_createSvgAct->setIcon(QPixmap(":draw-bezier-curves.png"));
1062
_createSvgAct->setShortcut(QString("F10"));
1063
_createSvgAct->setCheckable(true);
1064
connect(_createSvgAct, SIGNAL(triggered()), this, SLOT(createSvg()));
1066
_createSharedAxisBoxAct = new QAction(tr("Shared Axis &Box"), this);
1067
_createSharedAxisBoxAct->setStatusTip(tr("Create a shared axis box for the current item"));
1068
_createSharedAxisBoxAct->setIcon(QPixmap(":kst_gfx_sharedaxisbox.png"));
1069
_createSharedAxisBoxAct->setCheckable(true);
1070
//_createSharedAxisBoxAct->setEnabled(false);
1071
connect(_createSharedAxisBoxAct, SIGNAL(triggered()), this, SLOT(createSharedAxisBox()));
1073
// ************************** Mode Actions ******************************* //
1074
// First, general options
1075
_tiedZoomAct = new QAction(tr("&Toggle Tied Zoom"), this);
1076
_tiedZoomAct->setStatusTip(tr("Toggle the current view's tied zoom"));
1077
_tiedZoomAct->setIcon(QPixmap(":tied-zoom.png"));
1078
_tiedZoomAct->setCheckable(false);
1079
_tiedZoomAct->setShortcut(QString("t"));
1080
connect(_tiedZoomAct, SIGNAL(triggered()), this, SLOT(toggleTiedZoom()));
1082
_tabTiedAct = new QAction(tr("Tie &Across All Tabs"), this);
1083
_tabTiedAct->setStatusTip(tr("Tied zoom applies between tabs"));
1084
//_tiedZoomAct->setIcon(QPixmap(":tied-zoom.png"));
1085
_tabTiedAct->setCheckable(true);
1086
//connect(_tiedZoomAct, SIGNAL(triggered()), this, SLOT(toggleTiedZoom()));
1089
_highlightPointAct = new QAction(tr("&Highlight Data Points"), this);
1090
_highlightPointAct->setStatusTip(tr("Highlight closest data point"));
1091
_highlightPointAct->setIcon(QPixmap(":kst_datamode.png"));
1092
_highlightPointAct->setCheckable(true);
1093
connect(_highlightPointAct, SIGNAL(toggled(bool)), this, SLOT(setHighlightPoint(bool)));
1096
// Then, exclusive interaction modes
1097
QActionGroup* _interactionModeGroup = new QActionGroup(this);
1099
_standardZoomAct = _interactionModeGroup->addAction(tr("X-Y &Zoom/Scroll"));
1100
_standardZoomAct->setStatusTip(tr("Zoom arbitrarily in X- or Y-direction"));
1101
//TODO _standardZoomAct->setShortcut(QString("a"));
1102
_standardZoomAct->setCheckable(true);
1103
_standardZoomAct->setData(View::ZoomOnlyDisabled);
1104
_standardZoomAct->setIcon(QPixmap(":xy-zoom.png"));
1106
_xOnlyZoomAct = _interactionModeGroup->addAction(tr("&X-only Zoom"));
1107
_xOnlyZoomAct->setStatusTip(tr("Zoom only in X direction"));
1108
//TODO _xOnlyZoomAct->setShortcut(QString("x"));
1109
_xOnlyZoomAct->setCheckable(true);
1110
_xOnlyZoomAct->setData(View::ZoomOnlyX);
1111
_xOnlyZoomAct->setIcon(QPixmap(":x-zoom.png"));
1113
_yOnlyZoomAct = _interactionModeGroup->addAction(tr("&Y-only Zoom"));
1114
_yOnlyZoomAct->setStatusTip(tr("Zoom only in X direction"));
1115
//TODO _yOnlyZoomAct->setShortcut(QString("y"));
1116
_yOnlyZoomAct->setData(View::ZoomOnlyY);
1117
_yOnlyZoomAct->setCheckable(true);
1118
_yOnlyZoomAct->setIcon(QPixmap(":y-zoom.png"));
1120
_layoutModeAct = _interactionModeGroup->addAction(tr("&Layout Mode"));
1121
_layoutModeAct->setStatusTip(tr("Toggle the current view's layout mode"));
1122
_layoutModeAct->setIcon(QPixmap(":transform-move.png"));
1123
_layoutModeAct->setCheckable(true);
1124
_layoutModeAct->setShortcut(QString("F2"));
1125
connect(_layoutModeAct, SIGNAL(toggled(bool)), this, SLOT(setLayoutMode(bool)));
1127
_interactionModeGroup->setExclusive(true);
1128
connect(_interactionModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeZoomOnlyMode(QAction*)));
1130
// *********************** Tools actions ************************************** //
1131
_dataManagerAct = new QAction(tr("Data &Manager"), this);
1132
_dataManagerAct->setStatusTip(tr("Show Kst's data manager window"));
1133
_dataManagerAct->setIcon(QPixmap(":data-manager.png"));
1134
_dataManagerAct->setShortcut(QString("d"));
1135
connect(_dataManagerAct, SIGNAL(triggered()), this, SLOT(showDataManager()));
1137
_dataWizardAct = new QAction(tr("&Data Wizard"), this);
1138
_dataWizardAct->setStatusTip(tr("Show Kst's Data Wizard"));
1139
_dataWizardAct->setIcon(QPixmap(":tools-wizard.png"));
1140
_dataWizardAct->setShortcut(QString("w"));
1141
connect(_dataWizardAct, SIGNAL(triggered()), this, SLOT(showDataWizard()));
1143
_changeFileDialogAct = new QAction(tr("Change Data &File"), this);
1144
_changeFileDialogAct->setStatusTip(tr("Show Kst's Change Data File Dialog"));
1145
_changeFileDialogAct->setIcon(QPixmap(":change-data-file.png"));
1146
_changeFileDialogAct->setShortcut(QString("f"));
1147
connect(_changeFileDialogAct, SIGNAL(triggered()), this, SLOT(showChangeFileDialog()));
1149
_chooseColorDialogAct = new QAction(tr("Assign Curve &Color per File"), this);
1150
_chooseColorDialogAct->setStatusTip(tr("Show Kst's Choose Color Dialog"));
1151
_chooseColorDialogAct->setIcon(QPixmap(":code-class.png"));
1152
connect(_chooseColorDialogAct, SIGNAL(triggered()), this, SLOT(showChooseColorDialog()));
1154
_differentiateCurvesDialogAct = new QAction(tr("D&ifferentiate Curves"), this);
1155
_differentiateCurvesDialogAct->setStatusTip(tr("Show Kst's Differentiate Curves Dialog"));
1156
_differentiateCurvesDialogAct->setIcon(QPixmap(":kst_differentiatecurves.png"));
1157
connect(_differentiateCurvesDialogAct, SIGNAL(triggered()), this, SLOT(showDifferentiateCurvesDialog()));
1159
// *********************** Settings actions ************************************** //
1160
_settingsDialogAct = new QAction(tr("&Configure Kst"), this);
1161
_settingsDialogAct->setStatusTip(tr("Show Kst's Configuration Dialog"));
1162
_settingsDialogAct->setIcon(QPixmap(":configure.png"));
1163
connect(_settingsDialogAct, SIGNAL(triggered()), this, SLOT(showSettingsDialog()));
1165
// *********************** Help actions ************************************** //
1166
_debugDialogAct = new QAction(tr("&Debug Dialog"), this);
1167
_debugDialogAct->setStatusTip(tr("Show the Kst debugging dialog"));
1168
_debugDialogAct->setIcon(QPixmap(":text-x-log.png"));
1169
connect(_debugDialogAct, SIGNAL(triggered()), this, SLOT(showDebugDialog()));
1171
_bugReportWizardAct = new QAction(tr("&Bug Report Wizard"), this);
1172
_bugReportWizardAct->setStatusTip(tr("Show Kst's Bug Report Wizard"));
1173
_bugReportWizardAct->setIcon(QPixmap(":kbugbuster.png"));
1174
connect(_bugReportWizardAct, SIGNAL(triggered()), this, SLOT(showBugReportWizard()));
1176
_aboutAct = new QAction(tr("&About"), this);
1177
_aboutAct->setStatusTip(tr("Show Kst's About box"));
1178
_aboutAct->setIcon(QPixmap(":dialog-information.png"));
1179
connect(_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
1183
void MainWindow::createMenus() {
1184
_fileMenu = menuBar()->addMenu(tr("&File"));
1185
// Session operations
1186
_fileMenu->addAction(_openAct);
1187
_fileMenu->addAction(_saveAct);
1188
_fileMenu->addAction(_saveAsAct);
1189
_fileMenu->addAction(_closeAct);
1190
_fileMenu->addSeparator();
1191
_recentKstFilesMenu = _fileMenu->addMenu(tr("&Recent Sessions"));
1192
_recentDataFilesMenu = _fileMenu->addMenu("Recent Data &Files");
1193
_fileMenu->addSeparator();
1194
// Reload, isolate it a bit from the other entries to avoid inadvertent triggering
1195
_fileMenu->addAction(_reloadAct);
1196
_fileMenu->addSeparator();
1198
_fileMenu->addAction(_printAct);
1199
_fileMenu->addAction(_exportGraphicsAct);
1200
_fileMenu->addAction(_exportVectorsAct);
1201
_fileMenu->addAction(_logAct);
1202
_fileMenu->addSeparator();
1204
_fileMenu->addAction(_newTabAct);
1205
_fileMenu->addAction(_closeTabAct);
1206
_fileMenu->addSeparator();
1208
_fileMenu->addAction(_exitAct);
1210
_fileMenu->addSeparator();
1211
updateRecentKstFiles();
1214
_editMenu = menuBar()->addMenu(tr("&Edit"));
1215
_editMenu->addAction(_undoAct);
1216
_editMenu->addAction(_redoAct);
1217
// Cut/Copy/Paste will come here
1219
_viewMenu = menuBar()->addMenu(tr("&View"));
1220
_viewMenu->addAction(_vectorEditorAct);
1221
_viewMenu->addAction(_scalarEditorAct);
1222
_viewMenu->addAction(_matrixEditorAct);
1223
_viewMenu->addAction(_stringEditorAct);
1225
_rangeMenu = menuBar()->addMenu(tr("&Range"));
1226
_rangeMenu->addAction(_backAct);
1227
_rangeMenu->addAction(_forwardAct);
1228
_rangeMenu->addSeparator();
1229
_rangeMenu->addAction(_readFromEndAct);
1230
_rangeMenu->addAction(_readToEndAct);
1231
_rangeMenu->addAction(_pauseAct);
1232
_rangeMenu->addSeparator();
1233
_rangeMenu->addAction(_changeDataSampleDialogAct);
1235
_createMenu = menuBar()->addMenu(tr("&Create"));
1237
_createMenu->addAction(_createPlotAct);
1238
_createMenu->addAction(_createSharedAxisBoxAct);
1239
_createMenu->addSeparator();
1241
_createMenu->addAction(_newScalarAct);
1242
_createMenu->addAction(_newVectorAct);
1243
_createMenu->addAction(_newMatrixAct);
1244
_createMenu->addAction(_newStringAct);
1245
_createMenu->addSeparator();
1247
_createMenu->addAction(_newCurveAct);
1248
_createMenu->addAction(_newEquationAct);
1249
_createMenu->addAction(_newPSDAct);
1250
_createMenu->addAction(_newHistogramAct);
1251
_createMenu->addAction(_newImageAct);
1252
_createMenu->addAction(_newSpectrogramAct);
1253
_createMenu->addAction(_newEventMonitorAct);
1254
_createMenu->addSeparator();
1255
// Now, create the dynamic plugin menus
1256
QMenu* _pluginsMenu = _createMenu->addMenu(tr("Standard P&lugin"));
1257
QMenu* _fitPluginsMenu = _createMenu->addMenu(tr("Fit Pl&ugin"));
1258
QMenu* _filterPluginsMenu = _createMenu->addMenu(tr("Fil&ter Plugin"));
1259
PluginMenuItemAction* action;
1260
foreach (QString pluginName, DataObject::dataObjectPluginList()) {
1261
action = new PluginMenuItemAction(pluginName, this);
1262
connect(action, SIGNAL(triggered(QString&)), this, SLOT(showPluginDialog(QString&)));
1263
_pluginsMenu->addAction(action);
1265
foreach (QString pluginName, DataObject::fitsPluginList()) {
1266
action = new PluginMenuItemAction(pluginName, this);
1267
connect(action, SIGNAL(triggered(QString&)), this, SLOT(showPluginDialog(QString&)));
1268
_fitPluginsMenu->addAction(action);
1270
foreach (QString pluginName, DataObject::filterPluginList()) {
1271
action = new PluginMenuItemAction(pluginName, this);
1272
connect(action, SIGNAL(triggered(QString&)), this, SLOT(showPluginDialog(QString&)));
1273
_filterPluginsMenu->addAction(action);
1275
_createMenu->addSeparator();
1276
// Annotation objects
1277
QMenu* annotations = _createMenu->addMenu(tr("&Annotation"));
1278
annotations->addAction(_createLabelAct);
1279
annotations->addAction(_createBoxAct);
1280
annotations->addAction(_createCircleAct);
1281
annotations->addAction(_createEllipseAct);
1282
annotations->addAction(_createLineAct);
1283
annotations->addAction(_createArrowAct);
1284
annotations->addAction(_createPictureAct);
1285
annotations->addAction(_createSvgAct);
1287
_modeMenu = menuBar()->addMenu(tr("&Mode"));
1289
_modeMenu->addSeparator()->setText(tr("Interaction mode"));
1290
_modeMenu->addAction(_standardZoomAct);
1291
_modeMenu->addAction(_xOnlyZoomAct);
1292
_modeMenu->addAction(_yOnlyZoomAct);
1293
_modeMenu->addAction(_layoutModeAct);
1294
_standardZoomAct->setChecked(true);
1295
_modeMenu->addSeparator();
1296
// Tied zoom options
1297
_modeMenu->addAction(_tiedZoomAct);
1298
_modeMenu->addAction(_tabTiedAct);
1299
_modeMenu->addSeparator();
1301
_modeMenu->addAction(_highlightPointAct);
1303
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
1304
_toolsMenu->addAction(_dataManagerAct);
1305
_toolsMenu->addAction(_dataWizardAct);
1306
_toolsMenu->addAction(_changeFileDialogAct);
1307
_toolsMenu->addAction(_chooseColorDialogAct);
1308
_toolsMenu->addAction(_differentiateCurvesDialogAct);
1309
_toolsMenu->addSeparator();
1310
updateRecentDataFiles();
1312
_settingsMenu = menuBar()->addMenu(tr("&Settings"));
1313
_settingsMenu->addAction(_settingsDialogAct);
1315
menuBar()->addSeparator();
1317
_helpMenu = menuBar()->addMenu(tr("&Help"));
1318
_helpMenu->addAction(_debugDialogAct);
1319
_helpMenu->addAction(_bugReportWizardAct);
1320
_helpMenu->addSeparator();
1321
_helpMenu->addAction(_aboutAct);
1326
void MainWindow::createToolBars() {
1327
setToolButtonStyle(Qt::ToolButtonIconOnly);
1329
_fileToolBar = addToolBar(tr("File"));
1330
_fileToolBar->setObjectName("File Toolbar");
1331
_fileToolBar->addAction(_openAct);
1332
_fileToolBar->addAction(_saveAct);
1333
_fileToolBar->addAction(_reloadAct);
1334
_fileToolBar->addAction(_printAct);
1335
_fileToolBar->addAction(_logAct);
1337
_editToolBar = addToolBar(tr("Edit"));
1338
_editToolBar->setObjectName("Edit Toolbar");
1339
_editToolBar->addAction(_undoAct);
1340
_editToolBar->addAction(_redoAct);
1342
_toolsToolBar = addToolBar(tr("Tools"));
1343
_toolsToolBar->setObjectName("Tools Toolbar");
1344
_toolsToolBar->addAction(_dataManagerAct);
1345
_toolsToolBar->addAction(_dataWizardAct);
1346
_toolsToolBar->addAction(_changeDataSampleDialogAct);
1347
_toolsToolBar->addAction(_changeFileDialogAct);
1349
_rangeToolBar = addToolBar(tr("Data Range"));
1350
_rangeToolBar->setObjectName("Data Range Toolbar");
1351
_rangeToolBar->addAction(_backAct);
1352
_rangeToolBar->addAction(_forwardAct);
1353
_rangeToolBar->addAction(_readFromEndAct);
1354
_rangeToolBar->addAction(_readToEndAct);
1355
_rangeToolBar->addAction(_pauseAct);
1357
_modeToolBar = addToolBar(tr("Mode"));
1358
_modeToolBar->setObjectName("Mode Toolbar");
1359
_modeToolBar->addAction(_tiedZoomAct);
1360
_modeToolBar->addAction(_highlightPointAct);
1361
_modeToolBar->addSeparator();
1362
_modeToolBar->addAction(_standardZoomAct);
1363
_modeToolBar->addAction(_xOnlyZoomAct);
1364
_modeToolBar->addAction(_yOnlyZoomAct);
1365
_modeToolBar->addAction(_layoutModeAct);
1367
_annotationToolBar = addToolBar(tr("Advanced Layout"));
1368
_annotationToolBar->setObjectName("Advanced Layout Toolbar");
1369
_annotationToolBar->addAction(_createSharedAxisBoxAct);
1370
_annotationToolBar->addSeparator();
1371
_annotationToolBar->addAction(_createLabelAct);
1372
_annotationToolBar->addAction(_createBoxAct);
1373
_annotationToolBar->addAction(_createCircleAct);
1374
_annotationToolBar->addAction(_createEllipseAct);
1375
_annotationToolBar->addAction(_createLineAct);
1376
_annotationToolBar->addAction(_createArrowAct);
1377
_annotationToolBar->addAction(_createPictureAct);
1378
_annotationToolBar->addAction(_createSvgAct);
1383
void MainWindow::createStatusBar() {
1384
_messageLabel = new QLabel(statusBar());
1385
statusBar()->addWidget(_messageLabel);
1386
setStatusMessage(tr("Ready"));
1388
_progressBar = new QProgressBar(statusBar());
1389
_progressBar->hide();
1390
statusBar()->addPermanentWidget(_progressBar);
1391
MemoryWidget *mw = new MemoryWidget(statusBar());
1392
statusBar()->addPermanentWidget(mw);
1393
DebugNotifier *dn = new DebugNotifier(statusBar());
1394
connect(dn, SIGNAL(showDebugLog()), this, SLOT(showDebugDialog()));
1395
connect(_debugDialog, SIGNAL(notifyOfError()), dn, SLOT(reanimate()));
1396
connect(_debugDialog, SIGNAL(notifyAllClear()), dn, SLOT(close()));
1397
statusBar()->addPermanentWidget(dn);
1400
void MainWindow::setStatusMessage(QString message) {
1401
_messageLabel->setText(message);
1404
QProgressBar *MainWindow::progressBar() const {
1405
return _progressBar;
1408
void MainWindow::readFromEnd() {
1414
DataVectorList dataVectors = document()->objectStore()->getObjects<DataVector>();
1416
foreach (DataVectorPtr v, dataVectors) {
1418
nf = v->reqNumFrames();
1420
nf = v->numFrames();
1423
do_skip = v->doSkip();
1424
do_filter = v->doAve();
1428
v->changeFrames(-1, nf, skip, do_skip, do_filter);
1429
v->registerChange();
1432
UpdateManager::self()->doUpdates(true);
1433
_dialogDefaults->setValue("vector/range", nf);
1434
_dialogDefaults->setValue("vector/countFromEnd", true);
1435
_dialogDefaults->setValue("vector/readToEnd", false);
1438
void MainWindow::readToEnd() {
1444
DataVectorList dataVectors = document()->objectStore()->getObjects<DataVector>();
1446
foreach (DataVectorPtr v, dataVectors) {
1448
f0 = v->startFrame();
1450
do_skip = v->doSkip();
1451
do_filter = v->doAve();
1455
v->changeFrames(f0, -1, skip, do_skip, do_filter);
1456
v->registerChange();
1459
_dialogDefaults->setValue("vector/start", f0);
1460
_dialogDefaults->setValue("vector/countFromEnd", false);
1461
_dialogDefaults->setValue("vector/readToEnd", true);
1462
UpdateManager::self()->doUpdates(true);
1465
void MainWindow::pause(bool pause) {
1466
UpdateManager::self()->setPaused(pause);
1469
foreach (DataSourcePtr s, document()->objectStore()->dataSourceList()) {
1475
void MainWindow::forward() {
1480
bool count_from_end;
1485
DataVectorList dataVectors = document()->objectStore()->getObjects<DataVector>();
1487
foreach (DataVectorPtr v, dataVectors) {
1489
f0 = v->startFrame();
1490
nf = v->numFrames();
1491
count_from_end = v->countFromEOF();
1492
read_to_end = v->readToEOF();
1493
filelength = v->fileLength();
1496
do_skip = v->doSkip();
1497
do_filter = v->doAve();
1500
if ((!count_from_end) && (!read_to_end)) {
1502
if (f0+nf>=filelength) {
1503
f0 = filelength - nf;
1507
v->changeFrames(f0, nf, skip, do_skip, do_filter);
1508
v->registerChange();
1512
_dialogDefaults->setValue("vector/range", nf);
1513
_dialogDefaults->setValue("vector/start", f0);
1514
_dialogDefaults->setValue("vector/countFromEnd", false);
1515
_dialogDefaults->setValue("vector/readToEnd", false);
1517
UpdateManager::self()->doUpdates(true);
1520
void MainWindow::back() {
1525
bool count_from_end;
1530
DataVectorList dataVectors = document()->objectStore()->getObjects<DataVector>();
1532
foreach (DataVectorPtr v, dataVectors) {
1534
f0 = v->startFrame();
1535
nf = v->numFrames();
1536
count_from_end = v->countFromEOF();
1537
read_to_end = v->readToEOF();
1538
filelength = v->fileLength();
1541
do_skip = v->doSkip();
1542
do_filter = v->doAve();
1546
if (count_from_end) {
1547
f0 = filelength - nf;
1550
nf = filelength - f0;
1558
v->changeFrames(f0, nf, skip, do_skip, do_filter);
1559
v->registerChange();
1563
_dialogDefaults->setValue("vector/range", nf);
1564
_dialogDefaults->setValue("vector/start", f0);
1565
_dialogDefaults->setValue("vector/countFromEnd", false);
1566
_dialogDefaults->setValue("vector/readToEnd", false);
1567
UpdateManager::self()->doUpdates(true);
1570
void MainWindow::reload() {
1571
document()->objectStore()->rebuildDataSourceList();
1572
UpdateManager::self()->doUpdates(true);
1573
//document()->setChanged(true);
1576
void MainWindow::showDataManager() {
1577
if (!_dataManager) {
1578
_dataManager = new DataManager(this, _doc);
1580
if (_dataManager->isVisible()) {
1581
_dataManager->raise();
1582
_dataManager->activateWindow();
1584
_dataManager->show();
1588
void MainWindow::updateViewItems(qint64 serial) {
1590
QList<PlotItem *> plots = ViewItem::getItems<PlotItem>();
1592
bool changed = false;
1593
foreach (PlotItem *plot, plots) {
1594
changed |= plot->handleChangedInputs(serial);
1598
_tabWidget->currentView()->update();
1601
QTimer::singleShot(20, UpdateManager::self(), SLOT(viewItemUpdateFinished()));
1604
void MainWindow::showVectorEditor() {
1605
ViewVectorDialog *viewVectorDialog = new ViewVectorDialog(this, _doc);
1606
viewVectorDialog->show();
1610
void MainWindow::showScalarEditor() {
1611
ViewPrimitiveDialog *viewScalarDialog = new ViewScalarDialog(this, _doc);
1612
viewScalarDialog->show();
1616
void MainWindow::showStringEditor() {
1617
ViewPrimitiveDialog *viewStringDialog = new ViewStringDialog(this, _doc);
1618
viewStringDialog->show();
1621
void MainWindow::showMatrixEditor() {
1622
ViewMatrixDialog *viewMatrixDialog = new ViewMatrixDialog(this, _doc);
1623
viewMatrixDialog->show();
1627
void MainWindow::showDebugDialog() {
1628
if (!_debugDialog) {
1629
_debugDialog = new DebugDialog(this);
1631
_debugDialog->setObjectStore(document()->objectStore());
1632
if (_debugDialog->isVisible()) {
1633
_debugDialog->raise();
1634
_debugDialog->activateWindow();
1636
_debugDialog->show();
1640
void MainWindow::showExportGraphicsDialog() {
1641
if (!_exportGraphics) {
1642
_exportGraphics = new ExportGraphicsDialog(this);
1643
connect(_exportGraphics, SIGNAL(exportGraphics(const QString &, const QString &, int, int, int)),
1644
this, SLOT(exportGraphicsFile(const QString &, const QString &, int, int, int)));
1646
if (_exportGraphics->isVisible()) {
1647
_exportGraphics->raise();
1648
_exportGraphics->activateWindow();
1650
_exportGraphics->show();
1654
void MainWindow::showExportVectorsDialog() {
1655
if (!_exportVectors) {
1656
_exportVectors = new ExportVectorsDialog(this);
1657
//connect(_exportVectors, SIGNAL(exportGraphics(const QString &, const QString &, int, int, int)),
1658
// this, SLOT(exportGraphicsFile(const QString &, const QString &, int, int, int)));
1660
if (_exportVectors->isVisible()) {
1661
_exportVectors->raise();
1662
_exportVectors->activateWindow();
1664
_exportVectors->show();
1668
void MainWindow::showLogDialog() {
1670
_logDialog = new LogDialog(this);
1671
//connect(_logDialog, SIGNAL(exportLog(const QString &, time_t, const QString &, int, int, int, const QString &)),
1672
// this, SLOT(exportLog(const QString &, time_t, const QString &, int, int, int, const QString &)));
1674
if (_logDialog->isVisible()) {
1675
_logDialog->raise();
1676
_logDialog->activateWindow();
1682
void MainWindow::showSettingsDialog() {
1683
if (!_applicationSettingsDialog) {
1684
_applicationSettingsDialog = new ApplicationSettingsDialog(this);
1686
if (_applicationSettingsDialog->isVisible()) {
1687
_applicationSettingsDialog->raise();
1688
_applicationSettingsDialog->activateWindow();
1690
_applicationSettingsDialog->show();
1694
void MainWindow::showDifferentiateCurvesDialog() {
1695
if (!_differentiateCurvesDialog) {
1696
_differentiateCurvesDialog = new DifferentiateCurvesDialog(this);
1698
if (_differentiateCurvesDialog->isVisible()) {
1699
_differentiateCurvesDialog->raise();
1700
_differentiateCurvesDialog->activateWindow();
1702
_differentiateCurvesDialog->show();
1706
void MainWindow::showChooseColorDialog() {
1707
if (!_chooseColorDialog) {
1708
_chooseColorDialog = new ChooseColorDialog(this);
1710
if (_chooseColorDialog->isVisible()) {
1711
_chooseColorDialog->raise();
1712
_chooseColorDialog->activateWindow();
1714
_chooseColorDialog->show();
1718
void MainWindow::showChangeDataSampleDialog() {
1719
if (!_changeDataSampleDialog) {
1720
_changeDataSampleDialog = new ChangeDataSampleDialog(this);
1722
if (_changeDataSampleDialog->isVisible()) {
1723
_changeDataSampleDialog->raise();
1724
_changeDataSampleDialog->activateWindow();
1726
_changeDataSampleDialog->show();
1730
void MainWindow::showDataWizard() {
1731
DataWizard *dataWizard = new DataWizard(this);
1732
connect(dataWizard, SIGNAL(dataSourceLoaded(const QString&)), this, SLOT(updateRecentDataFiles(const QString&)));
1737
void MainWindow::openRecentDataFile()
1739
QAction *action = qobject_cast<QAction *>(sender());
1741
DataWizard *dataWizard = new DataWizard(this, action->data().toString());
1742
connect(dataWizard, SIGNAL(dataSourceLoaded(const QString&)), this, SLOT(updateRecentDataFiles(const QString&)));
1748
void MainWindow::showBugReportWizard() {
1749
if (!_bugReportWizard) {
1750
_bugReportWizard = new BugReportWizard(this);
1752
if (_bugReportWizard->isVisible()) {
1753
_bugReportWizard->raise();
1754
_bugReportWizard->activateWindow();
1756
_bugReportWizard->show();
1759
void MainWindow::showChangeFileDialog() {
1760
if (!_changeFileDialog) {
1761
_changeFileDialog = new ChangeFileDialog(this);
1763
if (_changeFileDialog->isVisible()) {
1764
_changeFileDialog->raise();
1765
_changeFileDialog->activateWindow();
1767
_changeFileDialog->show();
1770
void MainWindow::showPluginDialog(QString &pluginName) {
1771
DialogLauncher::self()->showBasicPluginDialog(pluginName);
1774
bool MainWindow::isTiedTabs() {
1775
return _tabTiedAct->isChecked();
1778
void MainWindow::readSettings() {
1779
QSettings settings("Kst2");
1780
QByteArray geo = settings.value("geometry").toByteArray();
1781
if (!geo.isEmpty()) {
1782
restoreGeometry(geo);
1784
setGeometry(50, 50, 800, 600);
1786
restoreState(settings.value("toolbarState").toByteArray());
1787
_tabTiedAct->setChecked(settings.value("tieTabs").toBool());
1791
void MainWindow::writeSettings() {
1792
QSettings settings("Kst2");
1793
settings.setValue("geometry", saveGeometry());
1794
settings.setValue("toolbarState", saveState());
1795
settings.setValue("tieTabs", _tabTiedAct->isChecked());
1798
void MainWindow::setWidgetFlags(QWidget* widget)
1801
// Make sure the dialog gets maximize and minimize buttons under Windows
1802
widget->QWidget::setWindowFlags((Qt::WindowFlags) Qt::Dialog | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint
1803
#if QT_VERSION >= 0x040500
1804
| Qt::WindowCloseButtonHint
1812
// vim: ts=2 sw=2 et