Git commit 2da178f3536026f2de0d5eb3b484fa4342e0e593 by Stefan Gerlach. Committed on 07/09/2016 at 18:23. Pushed by sgerlach into branch 'frameworks'.
fixed merge conflicts M +26 -2 doc/index.docbook M +6 -0 src/CMakeLists.txt M +10 -14 src/backend/core/AbstractAspect.cpp M +0 -2 src/backend/core/Folder.cpp M +5 -0 src/backend/core/Project.cpp M +22 -6 src/backend/worksheet/plots/cartesian/CartesianPlot.cpp M +2 -1 src/commonfrontend/widgets/TreeViewComboBox.cpp M +22 -15 src/commonfrontend/worksheet/WorksheetView.cpp M +5 -3 src/commonfrontend/worksheet/WorksheetView.h M +38 -20 src/kdefrontend/GuiObserver.cpp M +7 -11 src/kdefrontend/LabPlot.cpp M +62 -66 src/kdefrontend/MainWin.cpp M +4 -2 src/kdefrontend/MainWin.h M +1 -1 src/kdefrontend/TemplateHandler.cpp M +533 -0 src/kdefrontend/dockwidgets/XYDataReductionCurveDock.cpp http://commits.kde.org/labplot/2da178f3536026f2de0d5eb3b484fa4342e0e593 diff --cc src/backend/core/Folder.cpp index 48c06f1,f1f84de..153692f --- a/src/backend/core/Folder.cpp +++ b/src/backend/core/Folder.cpp @@@ -52,10 -49,8 +52,8 @@@ Folder::Folder(const QString &name) : AbstractAspect(name) {} - Folder::~Folder(){} - QIcon Folder::icon() const { - return KIcon("folder"); + return QIcon::fromTheme("folder"); } /** diff --cc src/backend/worksheet/plots/cartesian/CartesianPlot.cpp index 25e46c8,9f198bf..ae735a7 --- a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp +++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp @@@ -347,22 -347,24 +348,23 @@@ void CartesianPlot::initDefault(Type ty void CartesianPlot::initActions() { //"add new" actions - addCurveAction = new KAction(KIcon("labplot-xy-curve"), i18n("xy-curve"), this); - addEquationCurveAction = new KAction(KIcon("labplot-xy-equation-curve"), i18n("xy-curve from a mathematical equation"), this); + addCurveAction = new QAction(QIcon::fromTheme("labplot-xy-curve"), i18n("xy-curve"), this); + addEquationCurveAction = new QAction(QIcon::fromTheme("labplot-xy-equation-curve"), i18n("xy-curve from a mathematical equation"), this); // no icons yet - addDataReductionCurveAction = new KAction(i18n("xy-curve from a data reduction"), this); - addInterpolationCurveAction = new KAction(i18n("xy-curve from an interpolation"), this); - addSmoothCurveAction = new KAction(i18n("xy-curve from a smooth"), this); - addFitCurveAction = new KAction(KIcon("labplot-xy-fit-curve"), i18n("xy-curve from a fit to data"), this); - addFourierFilterCurveAction = new KAction(i18n("xy-curve from a Fourier filter"), this); - addFourierTransformCurveAction = new KAction(i18n("xy-curve from a Fourier transform"), this); -// addInterpolationCurveAction = new KAction(KIcon("labplot-xy-interpolation-curve"), i18n("xy-curve from an interpolation"), this); -// addSmoothCurveAction = new KAction(KIcon("labplot-xy-smooth-curve"), i18n("xy-curve from a smooth"), this); -// addFourierFilterCurveAction = new KAction(KIcon("labplot-xy-fourier_filter-curve"), i18n("xy-curve from a Fourier filter"), this); -// addFourierTransformCurveAction = new KAction(KIcon("labplot-xy-fourier_transform-curve"), i18n("xy-curve from a Fourier transform"), this); - - addLegendAction = new KAction(KIcon("text-field"), i18n("legend"), this); - addHorizontalAxisAction = new KAction(KIcon("labplot-axis-horizontal"), i18n("horizontal axis"), this); - addVerticalAxisAction = new KAction(KIcon("labplot-axis-vertical"), i18n("vertical axis"), this); - addCustomPointAction = new KAction(KIcon("draw-cross"), i18n("custom point"), this); ++ addDataReductionCurveAction = new QAction(i18n("xy-curve from a data reduction"), this); + addInterpolationCurveAction = new QAction(i18n("xy-curve from an interpolation"), this); + addSmoothCurveAction = new QAction(i18n("xy-curve from a smooth"), this); + addFitCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fit-curve"), i18n("xy-curve from a fit to data"), this); + addFourierFilterCurveAction = new QAction(i18n("xy-curve from a Fourier filter"), this); + addFourierTransformCurveAction = new QAction(i18n("xy-curve from a Fourier transform"), this); +// addInterpolationCurveAction = new QAction(QIcon::fromTheme("labplot-xy-interpolation-curve"), i18n("xy-curve from an interpolation"), this); +// addSmoothCurveAction = new QAction(QIcon::fromTheme("labplot-xy-smooth-curve"), i18n("xy-curve from a smooth"), this); +// addFourierFilterCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_filter-curve"), i18n("xy-curve from a Fourier filter"), this); +// addFourierTransformCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_transform-curve"), i18n("xy-curve from a Fourier transform"), this); + addLegendAction = new QAction(QIcon::fromTheme("text-field"), i18n("legend"), this); + addHorizontalAxisAction = new QAction(QIcon::fromTheme("labplot-axis-horizontal"), i18n("horizontal axis"), this); + addVerticalAxisAction = new QAction(QIcon::fromTheme("labplot-axis-vertical"), i18n("vertical axis"), this); + addCustomPointAction = new QAction(QIcon::fromTheme("draw-cross"), i18n("custom point"), this); connect(addCurveAction, SIGNAL(triggered()), SLOT(addCurve())); connect(addEquationCurveAction, SIGNAL(triggered()), SLOT(addEquationCurve())); diff --cc src/commonfrontend/worksheet/WorksheetView.cpp index 9dbcc8c,e3fad56..3602b09 --- a/src/commonfrontend/worksheet/WorksheetView.cpp +++ b/src/commonfrontend/worksheet/WorksheetView.cpp @@@ -272,62 -272,64 +272,64 @@@ void WorksheetView::initActions() connect(cartesianPlotMouseModeActionGroup, SIGNAL(triggered(QAction*)), SLOT(cartesianPlotMouseModeChanged(QAction*))); QActionGroup* cartesianPlotAddNewActionGroup = new QActionGroup(this); - addCurveAction = new KAction(KIcon("labplot-xy-curve"), i18n("xy-curve"), cartesianPlotAddNewActionGroup); - addEquationCurveAction = new KAction(KIcon("labplot-xy-equation-curve"), i18n("xy-curve from a mathematical equation"), cartesianPlotAddNewActionGroup); + addCurveAction = new QAction(QIcon::fromTheme("labplot-xy-curve"), i18n("xy-curve"), cartesianPlotAddNewActionGroup); + addEquationCurveAction = new QAction(QIcon::fromTheme("labplot-xy-equation-curve"), i18n("xy-curve from a mathematical equation"), cartesianPlotAddNewActionGroup); // no icons yet - addDataReductionCurveAction = new KAction(i18n("xy-curve from a data reduction"), cartesianPlotAddNewActionGroup); - addInterpolationCurveAction = new KAction(i18n("xy-curve from an interpolation"), cartesianPlotAddNewActionGroup); - addSmoothCurveAction = new KAction(i18n("xy-curve from a smooth"), cartesianPlotAddNewActionGroup); - addFourierFilterCurveAction = new KAction(i18n("xy-curve from a Fourier filter"), cartesianPlotAddNewActionGroup); - addFourierTransformCurveAction = new KAction(i18n("xy-curve from a Fourier transform"), cartesianPlotAddNewActionGroup); -// addInterpolationCurveAction = new KAction(KIcon("labplot-xy-interpolation-curve"), i18n("xy-curve from an interpolation"), cartesianPlotAddNewActionGroup); -// addSmoothCurveAction = new KAction(KIcon("labplot-xy-smooth-curve"), i18n("xy-curve from a smooth"), cartesianPlotAddNewActionGroup); - addFitCurveAction = new KAction(KIcon("labplot-xy-fit-curve"), i18n("xy-curve from a fit to data"), cartesianPlotAddNewActionGroup); -// addFourierFilterCurveAction = new KAction(KIcon("labplot-xy-fourier_filter-curve"), i18n("xy-curve from a Fourier filter"), cartesianPlotAddNewActionGroup); -// addFourierTransformCurveAction = new KAction(KIcon("labplot-xy-fourier_transform-curve"), i18n("xy-curve from a Fourier transform"), cartesianPlotAddNewActionGroup); - addLegendAction = new KAction(KIcon("text-field"), i18n("legend"), cartesianPlotAddNewActionGroup); - addHorizontalAxisAction = new KAction(KIcon("labplot-axis-horizontal"), i18n("horizontal axis"), cartesianPlotAddNewActionGroup); - addVerticalAxisAction = new KAction(KIcon("labplot-axis-vertical"), i18n("vertical axis"), cartesianPlotAddNewActionGroup); - addCustomPointAction = new KAction(KIcon("draw-cross"), i18n("custom point"), cartesianPlotAddNewActionGroup); ++ addDataReductionCurveAction = new QAction(i18n("xy-curve from a data reduction"), cartesianPlotAddNewActionGroup); + addInterpolationCurveAction = new QAction(i18n("xy-curve from an interpolation"), cartesianPlotAddNewActionGroup); + addSmoothCurveAction = new QAction(i18n("xy-curve from a smooth"), cartesianPlotAddNewActionGroup); + addFitCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fit-curve"), i18n("xy-curve from a fit to data"), cartesianPlotAddNewActionGroup); + addFourierFilterCurveAction = new QAction(i18n("xy-curve from a Fourier filter"), cartesianPlotAddNewActionGroup); + addFourierTransformCurveAction = new QAction(i18n("xy-curve from a Fourier transform"), cartesianPlotAddNewActionGroup); +// addInterpolationCurveAction = new QAction(QIcon::fromTheme("labplot-xy-interpolation-curve"), i18n("xy-curve from an interpolation"), cartesianPlotAddNewActionGroup); +// addSmoothCurveAction = new QAction(QIcon::fromTheme("labplot-xy-smooth-curve"), i18n("xy-curve from a smooth"), cartesianPlotAddNewActionGroup); +// addFourierFilterCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_filter-curve"), i18n("xy-curve from a Fourier filter"), cartesianPlotAddNewActionGroup); +// addFourierTransformCurveAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_transform-curve"), i18n("xy-curve from a Fourier transform"), cartesianPlotAddNewActionGroup); + addLegendAction = new QAction(QIcon::fromTheme("text-field"), i18n("legend"), cartesianPlotAddNewActionGroup); + addHorizontalAxisAction = new QAction(QIcon::fromTheme("labplot-axis-horizontal"), i18n("horizontal axis"), cartesianPlotAddNewActionGroup); + addVerticalAxisAction = new QAction(QIcon::fromTheme("labplot-axis-vertical"), i18n("vertical axis"), cartesianPlotAddNewActionGroup); + addCustomPointAction = new QAction(QIcon::fromTheme("draw-cross"), i18n("custom point"), cartesianPlotAddNewActionGroup); connect(cartesianPlotAddNewActionGroup, SIGNAL(triggered(QAction*)), SLOT(cartesianPlotAddNew(QAction*))); // Analysis menu // no icons yet - addDataReductionAction = new KAction(i18n("Data reduction"), cartesianPlotAddNewActionGroup); - addInterpolationAction = new KAction(i18n("Interpolation"), cartesianPlotAddNewActionGroup); - addSmoothAction = new KAction(i18n("Smooth"), cartesianPlotAddNewActionGroup); - addFitAction = new KAction(KIcon("labplot-xy-fit-curve"), i18n("Data fitting"), cartesianPlotAddNewActionGroup); - addFourierFilterAction = new KAction(i18n("Fourier filter"), cartesianPlotAddNewActionGroup); - addFourierTransformAction = new KAction(i18n("Fourier transform"), cartesianPlotAddNewActionGroup); -// addInterpolationAction = new KAction(KIcon("labplot-xy-interpolation-curve"), i18n("Interpolation"), cartesianPlotAddNewActionGroup); -// addSmoothAction = new KAction(KIcon("labplot-xy-smooth-curve"), i18n("Smooth"), cartesianPlotAddNewActionGroup); -// addFourierFilterAction = new KAction(KIcon("labplot-xy-fourier_filter-curve"), i18n("Fourier filter"), cartesianPlotAddNewActionGroup); -// addFourierTransformAction = new KAction(KIcon("labplot-xy-fourier_transform-curve"), i18n("Fourier transform"), cartesianPlotAddNewActionGroup); ++ addDataReductionAction = new QAction(i18n("Data reduction"), cartesianPlotAddNewActionGroup); + addInterpolationAction = new QAction(i18n("Interpolation"), cartesianPlotAddNewActionGroup); + addSmoothAction = new QAction(i18n("Smooth"), cartesianPlotAddNewActionGroup); + addFitAction = new QAction(QIcon::fromTheme("labplot-xy-fit-curve"), i18n("Data fitting"), cartesianPlotAddNewActionGroup); + addFourierFilterAction = new QAction(i18n("Fourier filter"), cartesianPlotAddNewActionGroup); + addFourierTransformAction = new QAction(i18n("Fourier transform"), cartesianPlotAddNewActionGroup); +// addInterpolationAction = new QAction(QIcon::fromTheme("labplot-xy-interpolation-curve"), i18n("Interpolation"), cartesianPlotAddNewActionGroup); +// addSmoothAction = new QAction(QIcon::fromTheme("labplot-xy-smooth-curve"), i18n("Smooth"), cartesianPlotAddNewActionGroup); +// addFourierFilterAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_filter-curve"), i18n("Fourier filter"), cartesianPlotAddNewActionGroup); +// addFourierTransformAction = new QAction(QIcon::fromTheme("labplot-xy-fourier_transform-curve"), i18n("Fourier transform"), cartesianPlotAddNewActionGroup); QActionGroup* cartesianPlotNavigationGroup = new QActionGroup(this); - scaleAutoAction = new KAction(KIcon("labplot-auto-scale-all"), i18n("auto scale"), cartesianPlotNavigationGroup); + scaleAutoAction = new QAction(QIcon::fromTheme("labplot-auto-scale-all"), i18n("auto scale"), cartesianPlotNavigationGroup); scaleAutoAction->setData(CartesianPlot::ScaleAuto); - scaleAutoXAction = new KAction(KIcon("labplot-auto-scale-x"), i18n("auto scale X"), cartesianPlotNavigationGroup); + scaleAutoXAction = new QAction(QIcon::fromTheme("labplot-auto-scale-x"), i18n("auto scale X"), cartesianPlotNavigationGroup); scaleAutoXAction->setData(CartesianPlot::ScaleAutoX); - scaleAutoYAction = new KAction(KIcon("labplot-auto-scale-y"), i18n("auto scale Y"), cartesianPlotNavigationGroup); + scaleAutoYAction = new QAction(QIcon::fromTheme("labplot-auto-scale-y"), i18n("auto scale Y"), cartesianPlotNavigationGroup); scaleAutoYAction->setData(CartesianPlot::ScaleAutoY); - zoomInAction = new KAction(KIcon("zoom-in"), i18n("zoom in"), cartesianPlotNavigationGroup); + zoomInAction = new QAction(QIcon::fromTheme("zoom-in"), i18n("zoom in"), cartesianPlotNavigationGroup); zoomInAction->setData(CartesianPlot::ZoomIn); - zoomOutAction = new KAction(KIcon("zoom-out"), i18n("zoom out"), cartesianPlotNavigationGroup); + zoomOutAction = new QAction(QIcon::fromTheme("zoom-out"), i18n("zoom out"), cartesianPlotNavigationGroup); zoomOutAction->setData(CartesianPlot::ZoomOut); - zoomInXAction = new KAction(KIcon("labplot-zoom-in-x"), i18n("zoom in X"), cartesianPlotNavigationGroup); + zoomInXAction = new QAction(QIcon::fromTheme("labplot-zoom-in-x"), i18n("zoom in X"), cartesianPlotNavigationGroup); zoomInXAction->setData(CartesianPlot::ZoomInX); - zoomOutXAction = new KAction(KIcon("labplot-zoom-out-x"), i18n("zoom out X"), cartesianPlotNavigationGroup); + zoomOutXAction = new QAction(QIcon::fromTheme("labplot-zoom-out-x"), i18n("zoom out X"), cartesianPlotNavigationGroup); zoomOutXAction->setData(CartesianPlot::ZoomOutX); - zoomInYAction = new KAction(KIcon("labplot-zoom-in-y"), i18n("zoom in Y"), cartesianPlotNavigationGroup); + zoomInYAction = new QAction(QIcon::fromTheme("labplot-zoom-in-y"), i18n("zoom in Y"), cartesianPlotNavigationGroup); zoomInYAction->setData(CartesianPlot::ZoomInY); - zoomOutYAction = new KAction(KIcon("labplot-zoom-out-y"), i18n("zoom out Y"), cartesianPlotNavigationGroup); + zoomOutYAction = new QAction(QIcon::fromTheme("labplot-zoom-out-y"), i18n("zoom out Y"), cartesianPlotNavigationGroup); zoomOutYAction->setData(CartesianPlot::ZoomOutY); - shiftLeftXAction = new KAction(KIcon("labplot-shift-left-x"), i18n("shift left X"), cartesianPlotNavigationGroup); + shiftLeftXAction = new QAction(QIcon::fromTheme("labplot-shift-left-x"), i18n("shift left X"), cartesianPlotNavigationGroup); shiftLeftXAction->setData(CartesianPlot::ShiftLeftX); - shiftRightXAction = new KAction(KIcon("labplot-shift-right-x"), i18n("shift right X"), cartesianPlotNavigationGroup); + shiftRightXAction = new QAction(QIcon::fromTheme("labplot-shift-right-x"), i18n("shift right X"), cartesianPlotNavigationGroup); shiftRightXAction->setData(CartesianPlot::ShiftRightX); - shiftUpYAction = new KAction(KIcon("labplot-shift-up-y"), i18n("shift up Y"), cartesianPlotNavigationGroup); + shiftUpYAction = new QAction(QIcon::fromTheme("labplot-shift-up-y"), i18n("shift up Y"), cartesianPlotNavigationGroup); shiftUpYAction->setData(CartesianPlot::ShiftUpY); - shiftDownYAction = new KAction(KIcon("labplot-shift-down-y"), i18n("shift down Y"), cartesianPlotNavigationGroup); + shiftDownYAction = new QAction(QIcon::fromTheme("labplot-shift-down-y"), i18n("shift down Y"), cartesianPlotNavigationGroup); shiftDownYAction->setData(CartesianPlot::ShiftDownY); connect(cartesianPlotNavigationGroup, SIGNAL(triggered(QAction*)), SLOT(cartesianPlotNavigationChanged(QAction*))); @@@ -445,11 -450,10 +448,10 @@@ void WorksheetView::initMenus() m_cartesianPlotMenu->addSeparator(); m_cartesianPlotMenu->addMenu(m_cartesianPlotActionModeMenu); - // Filter menu? - //m_filterMenu = new QMenu(i18n("Filter")); - //TODO: filter icon - // m_filterMenu->setIcon(QIcon::fromTheme("zoom-draw")); - // m_filterMenu->addAction(addFourierFilterAction); + // Data manipulation menu + m_dataManipulationMenu = new QMenu(i18n("Data Manipulation")); - m_dataManipulationMenu->setIcon(KIcon("zoom-draw")); ++ m_dataManipulationMenu->setIcon(QIcon::fromTheme("zoom-draw")); + m_dataManipulationMenu->addAction(addDataReductionAction); } /*! diff --cc src/kdefrontend/LabPlot.cpp index 64618b5,958b945..fe0ddcb --- a/src/kdefrontend/LabPlot.cpp +++ b/src/kdefrontend/LabPlot.cpp @@@ -39,38 -38,28 +39,34 @@@ #include "backend/core/AbstractColumn.h" int main (int argc, char *argv[]) { - KAboutData aboutData( "labplot2", "labplot2", - ki18n("LabPlot2"), LVERSION, - ki18n("LabPlot2 is a KDE-application for interactive graphing and analysis of scientific data."), - KAboutData::License_GPL, - ki18n("(c) 2007-2016") ); - aboutData.setHomepage("http://www.labplot.sourceforge.net"); - aboutData.addAuthor(ki18n("Stefan Gerlach"), ki18n("developer"), "[email protected]", 0); - aboutData.addAuthor(ki18n("Alexander Semke"), ki18n("developer"), "[email protected]", 0); - aboutData.addAuthor(ki18n("Andreas Kainz"), ki18n("icon designer"), "[email protected]", 0); - aboutData.addCredit(ki18n("Yuri Chornoivan"), ki18n("Help on many questions about the KDE-infrastructure and translation related topics"), "[email protected]", 0); + KAboutData aboutData( QStringLiteral("labplot2"), QString("labplot2"), - LVERSION, - i18n("LabPlot2 is a KDE-application for interactive graphing and analysis of scientific data."), - KAboutLicense::GPL, - i18n("(c) 2007-2016"), - QString(), - QStringLiteral("http://www.labplot.sourceforge.net")); ++ LVERSION, i18n("LabPlot2 is a KDE-application for interactive graphing and analysis of scientific data."), ++ KAboutLicense::GPL,i18n("(c) 2007-2016"), QString(), QStringLiteral("http://www.labplot.sourceforge.net")); - KCmdLineArgs::init( argc, argv, &aboutData ); - KCmdLineOptions options; - options.add("no-splash",ki18n("do not show the splash screen")); - options.add("+[file]",ki18n("open a project file")); - KCmdLineArgs::addCmdLineOptions( options ); + aboutData.addAuthor(i18n("Stefan Gerlach"), i18n("developer"), "[email protected]", 0); + aboutData.addAuthor(i18n("Alexander Semke"), i18n("developer"), "[email protected]", 0); + aboutData.addAuthor(i18n("Andreas Kainz"), i18n("icon designer"), "[email protected]", 0); + aboutData.addCredit(i18n("Yuri Chornoivan"), i18n("Help on many questions about the KDE-infrastructure and translation related topics"), "[email protected]", 0); + aboutData.addCredit(i18n("Garvit Khatri"), i18n("Porting LabPlot2 to KF5 and Integration with Cantor"), "[email protected]", 0); + KAboutData::setApplicationData(aboutData); - KApplication app; - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + QApplication app(argc, argv); + QCoreApplication::setApplicationVersion(QLatin1String(LVERSION)); + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption nosplashOption("no-splash", i18n("disable splash screen")); + parser.addOption(nosplashOption); + + parser.addPositionalArgument("+[file]", i18n( "open a project file")); + + aboutData.setupCommandLine(&parser); + parser.process(app); + aboutData.processCommandLine(&parser); + const QStringList args = parser.positionalArguments(); QString filename; - if (args->count() > 0) - filename = args->arg(0); + if (args.count() > 0) + filename = args[0]; if(!filename.isEmpty() ) { if ( !QFile::exists(filename)) { diff --cc src/kdefrontend/MainWin.cpp index 8c3c49a,f53f0c6..ddbaef3 --- a/src/kdefrontend/MainWin.cpp +++ b/src/kdefrontend/MainWin.cpp @@@ -95,45 -83,43 +95,45 @@@ */ MainWin::MainWin(QWidget *parent, const QString& filename) - : KXmlGuiWindow(parent), - m_currentSubWindow(0), - m_project(0), - m_aspectTreeModel(0), - m_projectExplorer(0), - m_projectExplorerDock(0), - m_propertiesDock(0), - m_currentAspect(0), - m_currentFolder(0), - m_suppressCurrentSubWindowChangedEvent(false), - m_closing(false), - m_autoSaveActive(false), - m_visibilityMenu(0), - m_newMenu(0), - m_editMenu(0), - axisDock(0), - notesDock(0), - cartesianPlotDock(0), - cartesianPlotLegendDock(0), - columnDock(0), - matrixDock(0), - spreadsheetDock(0), - projectDock(0), - xyCurveDock(0), - xyEquationCurveDock(0), - xyInterpolationCurveDock(0), - xySmoothCurveDock(0), - xyFitCurveDock(0), - xyFourierFilterCurveDock(0), - xyFourierTransformCurveDock(0), - worksheetDock(0), - textLabelDock(0), - customPointDock(0), - datapickerImageDock(0), - datapickerCurveDock(0), + : KXmlGuiWindow(parent), + m_currentSubWindow(0), + m_project(0), + m_aspectTreeModel(0), + m_projectExplorer(0), + m_projectExplorerDock(0), + m_propertiesDock(0), + m_currentAspect(0), + m_currentFolder(0), + m_suppressCurrentSubWindowChangedEvent(false), + m_closing(false), + m_autoSaveActive(false), + m_visibilityMenu(0), + m_newMenu(0), + m_editMenu(0), + axisDock(0), + notesDock(0), + cartesianPlotDock(0), + cartesianPlotLegendDock(0), + columnDock(0), + matrixDock(0), + spreadsheetDock(0), + projectDock(0), + xyCurveDock(0), + xyEquationCurveDock(0), - xyDataReductionCurveDock(0), + xyInterpolationCurveDock(0), + xySmoothCurveDock(0), + xyFitCurveDock(0), + xyFourierFilterCurveDock(0), + xyFourierTransformCurveDock(0), + worksheetDock(0), + textLabelDock(0), + customPointDock(0), + datapickerImageDock(0), + datapickerCurveDock(0), +#ifdef HAVE_CANTOR_LIBS + cantorWorksheetDock(0), +#endif - m_guiObserver(0) { + m_guiObserver(0) { // QTimer::singleShot( 0, this, SLOT(initGUI(filename)) ); //TODO doesn't work anymore initGUI(filename); @@@ -169,19 -155,13 +169,19 @@@ void MainWin::initGUI(const QString& fi m_mdiArea = new QMdiArea; setCentralWidget(m_mdiArea); connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), - this, SLOT(handleCurrentSubWindowChanged(QMdiSubWindow*))); + this, SLOT(handleCurrentSubWindowChanged(QMdiSubWindow*))); - +#ifdef _WIN32 + QIcon::setThemeName("hicolor"); +#endif statusBar()->showMessage(i18nc("%1 is the LabPlot version", "Welcome to LabPlot %1", QLatin1String(LVERSION))); initActions(); +#ifdef __APPLE__ + setupGUI(Default, QLatin1String("/Applications/labplot2.app/Contents/share/labplot2ui.rc")); +#else + setupGUI(Default, QLatin1String("labplot2ui.rc")); +#endif initMenus(); - setupGUI(); - setWindowIcon(KIcon("LabPlot2")); + setWindowIcon(QIcon::fromTheme("LabPlot2")); setAttribute( Qt::WA_DeleteOnClose ); //make the status bar of a fixed size in order to avoid height changes when placing a ProgressBar there. @@@ -955,8 -873,9 +955,8 @@@ bool MainWin::saveProject() bool MainWin::saveProjectAs() { KConfigGroup conf(KSharedConfig::openConfig(), "MainWin"); QString dir = conf.readEntry("LastOpenDir", ""); - QString fileName = KFileDialog::getSaveFileName(KUrl(dir), - i18n("LabPlot Projects (*.lml *.lml.gz *.lml.bz2 *.lml.xz *.LML *.LML.GZ *.LML.BZ2 *.LML.XZ)"), - this, i18n("Save project as")); + QString fileName = QFileDialog::getSaveFileName(this, i18n("Save project as"), dir, - i18n("LabPlot Projects (*.lml *.lml.gz *.lml.bz2 *.lml.xz *.LML *.LML.GZ *.LML.BZ2 *.LML.XZ)")); ++ i18n("LabPlot Projects (*.lml *.lml.gz *.lml.bz2 *.lml.xz *.LML *.LML.GZ *.LML.BZ2 *.LML.XZ)")); if (fileName.isEmpty())// "Cancel" was clicked return false; diff --cc src/kdefrontend/MainWin.h index 604d99a,6ab2c00..660688a --- a/src/kdefrontend/MainWin.h +++ b/src/kdefrontend/MainWin.h @@@ -239,14 -227,9 +241,14 @@@ private slots void historyDialog(); void importFileDialog(const QString& fileName = QString()); void exportDialog(); - void editFitsFileDialog(); + void editFitsFileDialog(); void settingsDialog(); void projectChanged(); + + //Cantor + #ifdef HAVE_CANTOR_LIBS + void newCantorWorksheet(QAction* action); + #endif void newFolder(); void newWorkbook(); diff --cc src/kdefrontend/dockwidgets/XYDataReductionCurveDock.cpp index 0000000,56cbd71..9cbeaa7 mode 000000,100644..100644 --- a/src/kdefrontend/dockwidgets/XYDataReductionCurveDock.cpp +++ b/src/kdefrontend/dockwidgets/XYDataReductionCurveDock.cpp @@@ -1,0 -1,533 +1,533 @@@ + /*************************************************************************** + File : XYDataReductionCurveDock.cpp + Project : LabPlot + -------------------------------------------------------------------- + Copyright : (C) 2016 Stefan Gerlach ([email protected]) + Description : widget for editing properties of data reduction curves + + ***************************************************************************/ + + /*************************************************************************** + * * + * 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 "XYDataReductionCurveDock.h" + #include "backend/core/AspectTreeModel.h" + #include "backend/core/Project.h" + #include "backend/worksheet/plots/cartesian/XYDataReductionCurve.h" + #include "commonfrontend/widgets/TreeViewComboBox.h" + + #include <QMenu> + #include <QWidgetAction> + #include <QStandardItemModel> + #ifndef NDEBUG + #include <QDebug> + #endif + + #include <cmath> // isnan + + /*! + \class XYDataReductionCurveDock + \brief Provides a widget for editing the properties of the XYDataReductionCurves + (2D-curves defined by an data reduction) currently selected in + the project explorer. + + If more then one curves are set, the properties of the first column are shown. + The changes of the properties are applied to all curves. + The exclusions are the name, the comment and the datasets (columns) of + the curves - these properties can only be changed if there is only one single curve. + + \ingroup kdefrontend + */ + + XYDataReductionCurveDock::XYDataReductionCurveDock(QWidget *parent): + XYCurveDock(parent), cbXDataColumn(0), cbYDataColumn(0), m_dataReductionCurve(0) { + + //hide the line connection type + ui.cbLineType->setDisabled(true); + + //remove the tab "Error bars" + ui.tabWidget->removeTab(5); + } + + /*! + * // Tab "General" + */ + void XYDataReductionCurveDock::setupGeneral() { + QWidget* generalTab = new QWidget(ui.tabGeneral); + uiGeneralTab.setupUi(generalTab); + + QGridLayout* gridLayout = dynamic_cast<QGridLayout*>(generalTab->layout()); + if (gridLayout) { + gridLayout->setContentsMargins(2,2,2,2); + gridLayout->setHorizontalSpacing(2); + gridLayout->setVerticalSpacing(2); + } + + cbXDataColumn = new TreeViewComboBox(generalTab); + gridLayout->addWidget(cbXDataColumn, 4, 3, 1, 2); + cbYDataColumn = new TreeViewComboBox(generalTab); + gridLayout->addWidget(cbYDataColumn, 5, 3, 1, 2); + + for (int i=0; i < NSL_GEOM_LINESIM_TYPE_COUNT; i++) + uiGeneralTab.cbType->addItem(i18n(nsl_geom_linesim_type_name[i])); + uiGeneralTab.cbType->setItemData(nsl_geom_linesim_type_visvalingam_whyatt, i18n("This method is much slower than any other"), Qt::ToolTipRole); + - uiGeneralTab.pbRecalculate->setIcon(KIcon("run-build")); ++ uiGeneralTab.pbRecalculate->setIcon(QIcon::fromTheme("run-build")); + + QHBoxLayout* layout = new QHBoxLayout(ui.tabGeneral); + layout->setMargin(0); + layout->addWidget(generalTab); + + //Slots + connect( uiGeneralTab.leName, SIGNAL(returnPressed()), this, SLOT(nameChanged()) ); + connect( uiGeneralTab.leComment, SIGNAL(returnPressed()), this, SLOT(commentChanged()) ); + connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); + + connect( uiGeneralTab.cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(typeChanged()) ); + connect( uiGeneralTab.chkAuto, SIGNAL(clicked(bool)), this, SLOT(autoToleranceChanged()) ); + connect( uiGeneralTab.sbTolerance, SIGNAL(valueChanged(double)), this, SLOT(toleranceChanged()) ); + connect( uiGeneralTab.chkAuto2, SIGNAL(clicked(bool)), this, SLOT(autoTolerance2Changed()) ); + connect( uiGeneralTab.sbTolerance2, SIGNAL(valueChanged(double)), this, SLOT(tolerance2Changed()) ); + + connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalculateClicked()) ); + } + + void XYDataReductionCurveDock::initGeneralTab() { + //if there are more then one curve in the list, disable the tab "general" + if (m_curvesList.size()==1) { + uiGeneralTab.lName->setEnabled(true); + uiGeneralTab.leName->setEnabled(true); + uiGeneralTab.lComment->setEnabled(true); + uiGeneralTab.leComment->setEnabled(true); + + uiGeneralTab.leName->setText(m_curve->name()); + uiGeneralTab.leComment->setText(m_curve->comment()); + }else { + uiGeneralTab.lName->setEnabled(false); + uiGeneralTab.leName->setEnabled(false); + uiGeneralTab.lComment->setEnabled(false); + uiGeneralTab.leComment->setEnabled(false); + + uiGeneralTab.leName->setText(""); + uiGeneralTab.leComment->setText(""); + } + + //show the properties of the first curve + m_dataReductionCurve = dynamic_cast<XYDataReductionCurve*>(m_curve); + Q_ASSERT(m_dataReductionCurve); + XYCurveDock::setModelIndexFromColumn(cbXDataColumn, m_dataReductionCurve->xDataColumn()); + XYCurveDock::setModelIndexFromColumn(cbYDataColumn, m_dataReductionCurve->yDataColumn()); + // update list of selectable types + xDataColumnChanged(cbXDataColumn->currentModelIndex()); + + uiGeneralTab.cbType->setCurrentIndex(m_dataReductionData.type); + this->typeChanged(); + uiGeneralTab.chkAuto->setChecked(m_dataReductionData.autoTolerance); + this->autoToleranceChanged(); + uiGeneralTab.sbTolerance->setValue(m_dataReductionData.tolerance); + this->toleranceChanged(); + uiGeneralTab.chkAuto2->setChecked(m_dataReductionData.autoTolerance2); + this->autoTolerance2Changed(); + uiGeneralTab.sbTolerance2->setValue(m_dataReductionData.tolerance2); + this->tolerance2Changed(); + + this->showDataReductionResult(); + + //enable the "recalculate"-button if the source data was changed since the last dataReduction + uiGeneralTab.pbRecalculate->setEnabled(m_dataReductionCurve->isSourceDataChangedSinceLastDataReduction()); + + uiGeneralTab.chkVisible->setChecked( m_curve->isVisible() ); + + //Slots + connect(m_dataReductionCurve, SIGNAL(aspectDescriptionChanged(const AbstractAspect*)), this, SLOT(curveDescriptionChanged(const AbstractAspect*))); + connect(m_dataReductionCurve, SIGNAL(xDataColumnChanged(const AbstractColumn*)), this, SLOT(curveXDataColumnChanged(const AbstractColumn*))); + connect(m_dataReductionCurve, SIGNAL(yDataColumnChanged(const AbstractColumn*)), this, SLOT(curveYDataColumnChanged(const AbstractColumn*))); + connect(m_dataReductionCurve, SIGNAL(dataReductionDataChanged(XYDataReductionCurve::DataReductionData)), this, SLOT(curveDataReductionDataChanged(XYDataReductionCurve::DataReductionData))); + connect(m_dataReductionCurve, SIGNAL(sourceDataChangedSinceLastDataReduction()), this, SLOT(enableRecalculate())); + } + + void XYDataReductionCurveDock::setModel() { + QList<const char*> list; + list<<"Folder"<<"Workbook"<<"Datapicker"<<"DatapickerCurve"<<"Spreadsheet" + <<"FileDataSource"<<"Column"<<"Worksheet"<<"CartesianPlot"<<"XYFitCurve"; + cbXDataColumn->setTopLevelClasses(list); + cbYDataColumn->setTopLevelClasses(list); + + list.clear(); + list<<"Column"; + cbXDataColumn->setSelectableClasses(list); + cbYDataColumn->setSelectableClasses(list); + + connect( cbXDataColumn, SIGNAL(currentModelIndexChanged(QModelIndex)), this, SLOT(xDataColumnChanged(QModelIndex)) ); + connect( cbYDataColumn, SIGNAL(currentModelIndexChanged(QModelIndex)), this, SLOT(yDataColumnChanged(QModelIndex)) ); + + cbXDataColumn->setModel(m_aspectTreeModel); + cbYDataColumn->setModel(m_aspectTreeModel); + + XYCurveDock::setModel(); + } + + /*! + sets the curves. The properties of the curves in the list \c list can be edited in this widget. + */ + void XYDataReductionCurveDock::setCurves(QList<XYCurve*> list) { + m_initializing=true; + m_curvesList=list; + m_curve=list.first(); + m_dataReductionCurve = dynamic_cast<XYDataReductionCurve*>(m_curve); + Q_ASSERT(m_dataReductionCurve); + m_aspectTreeModel = new AspectTreeModel(m_curve->project()); + this->setModel(); + m_dataReductionData = m_dataReductionCurve->dataReductionData(); + initGeneralTab(); + initTabs(); + m_initializing=false; + + //hide the "skip gaps" option after the curves were set + ui.lLineSkipGaps->hide(); + ui.chkLineSkipGaps->hide(); + } + + //************************************************************* + //**** SLOTs for changes triggered in XYFitCurveDock ***** + //************************************************************* + void XYDataReductionCurveDock::nameChanged() { + if (m_initializing) + return; + + m_curve->setName(uiGeneralTab.leName->text()); + } + + void XYDataReductionCurveDock::commentChanged() { + if (m_initializing) + return; + + m_curve->setComment(uiGeneralTab.leComment->text()); + } + + void XYDataReductionCurveDock::updateTolerance() { + const AbstractColumn *xDataColumn = dynamic_cast<XYDataReductionCurve*>(m_curve)->xDataColumn(); + const AbstractColumn *yDataColumn = dynamic_cast<XYDataReductionCurve*>(m_curve)->yDataColumn(); + if(xDataColumn == 0 || yDataColumn == 0) + return; + + //copy all valid data points for calculating tolerance to temporary vectors + QVector<double> xdataVector; + QVector<double> ydataVector; + for (int row=0; row<xDataColumn->rowCount(); ++row) { + //only copy those data where _all_ values (for x and y, if given) are valid + if (!std::isnan(xDataColumn->valueAt(row)) && !std::isnan(yDataColumn->valueAt(row)) + && !xDataColumn->isMasked(row) && !yDataColumn->isMasked(row)) { + xdataVector.append(xDataColumn->valueAt(row)); + ydataVector.append(yDataColumn->valueAt(row)); + } + } + + if(xdataVector.size() > 1) { + uiGeneralTab.cbType->setEnabled(true); + } else { + uiGeneralTab.cbType->setEnabled(false); + return; + } + + nsl_geom_linesim_type type = (nsl_geom_linesim_type)uiGeneralTab.cbType->currentIndex(); + if (type == nsl_geom_linesim_type_raddist || type == nsl_geom_linesim_type_opheim) + m_dataReductionData.tolerance = nsl_geom_linesim_radial_tol(xdataVector.data(), ydataVector.data(), xdataVector.size()); + else if (type == nsl_geom_linesim_type_visvalingam_whyatt) + m_dataReductionData.tolerance = nsl_geom_linesim_area_tol(xdataVector.data(), ydataVector.data(), xdataVector.size()); + else + m_dataReductionData.tolerance = nsl_geom_linesim_perpendicular_tol(xdataVector.data(), ydataVector.data(), xdataVector.size()); + uiGeneralTab.sbTolerance->setValue(m_dataReductionData.tolerance); + } + + void XYDataReductionCurveDock::updateTolerance2() { + nsl_geom_linesim_type type = (nsl_geom_linesim_type)uiGeneralTab.cbType->currentIndex(); + + if (type == nsl_geom_linesim_type_perpdist) + uiGeneralTab.sbTolerance2->setValue(10); + else if (type == nsl_geom_linesim_type_opheim) + uiGeneralTab.sbTolerance2->setValue(5*uiGeneralTab.sbTolerance->value()); + else if (type == nsl_geom_linesim_type_lang) + uiGeneralTab.sbTolerance2->setValue(10); + } + + void XYDataReductionCurveDock::xDataColumnChanged(const QModelIndex& index) { + if (m_initializing) + return; + + AbstractAspect* aspect = static_cast<AbstractAspect*>(index.internalPointer()); + AbstractColumn* column = 0; + if (aspect) { + column = dynamic_cast<AbstractColumn*>(aspect); + Q_ASSERT(column); + } + + foreach(XYCurve* curve, m_curvesList) + dynamic_cast<XYDataReductionCurve*>(curve)->setXDataColumn(column); + + updateTolerance(); + updateTolerance2(); + } + + void XYDataReductionCurveDock::yDataColumnChanged(const QModelIndex& index) { + if (m_initializing) + return; + + AbstractAspect* aspect = static_cast<AbstractAspect*>(index.internalPointer()); + AbstractColumn* column = 0; + if (aspect) { + column = dynamic_cast<AbstractColumn*>(aspect); + Q_ASSERT(); + } + + foreach(XYCurve* curve, m_curvesList) + dynamic_cast<XYDataReductionCurve*>(curve)->setYDataColumn(column); + + updateTolerance(); + updateTolerance2(); + } + + void XYDataReductionCurveDock::typeChanged() { + nsl_geom_linesim_type type = (nsl_geom_linesim_type)uiGeneralTab.cbType->currentIndex(); + m_dataReductionData.type = type; + + switch (type) { + case nsl_geom_linesim_type_douglas_peucker: + case nsl_geom_linesim_type_raddist: + case nsl_geom_linesim_type_interp: + case nsl_geom_linesim_type_reumann_witkam: + uiGeneralTab.lOption->setText(i18n("Tolerance (distance)")); + uiGeneralTab.sbTolerance->setDecimals(6); + uiGeneralTab.sbTolerance->setMinimum(0); + uiGeneralTab.sbTolerance->setSingleStep(0.01); + uiGeneralTab.lOption2->hide(); + uiGeneralTab.chkAuto2->hide(); + uiGeneralTab.sbTolerance2->hide(); + if (uiGeneralTab.chkAuto->isChecked()) + updateTolerance(); + break; + case nsl_geom_linesim_type_nthpoint: + uiGeneralTab.lOption->setText(i18n("Step size")); + uiGeneralTab.sbTolerance->setValue(10); + uiGeneralTab.sbTolerance->setDecimals(0); + uiGeneralTab.sbTolerance->setMinimum(1); + uiGeneralTab.sbTolerance->setSingleStep(1); + uiGeneralTab.lOption2->hide(); + uiGeneralTab.chkAuto2->hide(); + uiGeneralTab.sbTolerance2->hide(); + break; + case nsl_geom_linesim_type_perpdist: // repeat option + uiGeneralTab.lOption->setText(i18n("Tolerance (distance)")); + uiGeneralTab.sbTolerance->setDecimals(6); + uiGeneralTab.sbTolerance->setMinimum(0); + uiGeneralTab.sbTolerance->setSingleStep(0.01); + uiGeneralTab.sbTolerance2->show(); + uiGeneralTab.lOption2->show(); + uiGeneralTab.chkAuto2->show(); + uiGeneralTab.lOption2->setText(i18n("Repeats")); + uiGeneralTab.sbTolerance2->setDecimals(0); + uiGeneralTab.sbTolerance2->setMinimum(1); + uiGeneralTab.sbTolerance2->setSingleStep(1); + if (uiGeneralTab.chkAuto->isChecked()) + updateTolerance(); + if (uiGeneralTab.chkAuto2->isChecked()) + updateTolerance2(); + break; + case nsl_geom_linesim_type_visvalingam_whyatt: + uiGeneralTab.lOption->setText(i18n("Tolerance (area)")); + uiGeneralTab.sbTolerance->setDecimals(6); + uiGeneralTab.sbTolerance->setMinimum(0); + uiGeneralTab.sbTolerance->setSingleStep(0.01); + uiGeneralTab.lOption2->hide(); + uiGeneralTab.chkAuto2->hide(); + uiGeneralTab.sbTolerance2->hide(); + if (uiGeneralTab.chkAuto->isChecked()) + updateTolerance(); + break; + case nsl_geom_linesim_type_opheim: // min/max tol options + uiGeneralTab.lOption->setText(i18n(" Min. Tolerance")); + uiGeneralTab.sbTolerance->setDecimals(6); + uiGeneralTab.sbTolerance->setMinimum(0); + uiGeneralTab.sbTolerance->setSingleStep(0.01); + uiGeneralTab.lOption2->setText(i18n("Max. Tolerance")); + uiGeneralTab.lOption2->show(); + uiGeneralTab.chkAuto2->show(); + uiGeneralTab.sbTolerance2->show(); + uiGeneralTab.sbTolerance2->setDecimals(6); + uiGeneralTab.sbTolerance2->setMinimum(0); + uiGeneralTab.sbTolerance2->setSingleStep(0.01); + if (uiGeneralTab.chkAuto->isChecked()) + updateTolerance(); + if (uiGeneralTab.chkAuto2->isChecked()) + updateTolerance2(); + break; + case nsl_geom_linesim_type_lang: // distance/region + uiGeneralTab.lOption->setText(i18n("Tolerance (distance)")); + uiGeneralTab.sbTolerance->setDecimals(6); + uiGeneralTab.sbTolerance->setMinimum(0); + uiGeneralTab.sbTolerance->setSingleStep(0.01); + uiGeneralTab.lOption2->setText(i18n("Search region")); + uiGeneralTab.lOption2->show(); + uiGeneralTab.chkAuto2->show(); + uiGeneralTab.sbTolerance2->show(); + uiGeneralTab.sbTolerance2->setDecimals(0); + uiGeneralTab.sbTolerance2->setMinimum(1); + uiGeneralTab.sbTolerance2->setSingleStep(1); + if (uiGeneralTab.chkAuto->isChecked()) + updateTolerance(); + if (uiGeneralTab.chkAuto2->isChecked()) + updateTolerance2(); + break; + } + + uiGeneralTab.pbRecalculate->setEnabled(true); + } + + void XYDataReductionCurveDock::autoToleranceChanged() { + bool autoTolerance = (bool)uiGeneralTab.chkAuto->isChecked(); + m_dataReductionData.autoTolerance = autoTolerance; + + if (autoTolerance) { + uiGeneralTab.sbTolerance->setEnabled(false); + updateTolerance(); + } else { + uiGeneralTab.sbTolerance->setEnabled(true); + } + } + + void XYDataReductionCurveDock::toleranceChanged() { + m_dataReductionData.tolerance = uiGeneralTab.sbTolerance->value(); + + uiGeneralTab.pbRecalculate->setEnabled(true); + } + + void XYDataReductionCurveDock::autoTolerance2Changed() { + bool autoTolerance2 = (bool)uiGeneralTab.chkAuto2->isChecked(); + m_dataReductionData.autoTolerance2 = autoTolerance2; + + if (autoTolerance2) { + uiGeneralTab.sbTolerance2->setEnabled(false); + updateTolerance2(); + } else { + uiGeneralTab.sbTolerance2->setEnabled(true); + } + } + + void XYDataReductionCurveDock::tolerance2Changed() { + m_dataReductionData.tolerance2 = uiGeneralTab.sbTolerance2->value(); + + uiGeneralTab.pbRecalculate->setEnabled(true); + } + + void XYDataReductionCurveDock::recalculateClicked() { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + + foreach (XYCurve* curve, m_curvesList) + dynamic_cast<XYDataReductionCurve*>(curve)->setDataReductionData(m_dataReductionData); + + uiGeneralTab.pbRecalculate->setEnabled(false); + QApplication::restoreOverrideCursor(); + } + + void XYDataReductionCurveDock::enableRecalculate() const { + if (m_initializing) + return; + + //no dataReductioning possible without the x- and y-data + AbstractAspect* aspectX = static_cast<AbstractAspect*>(cbXDataColumn->currentModelIndex().internalPointer()); + AbstractAspect* aspectY = static_cast<AbstractAspect*>(cbYDataColumn->currentModelIndex().internalPointer()); + bool data = (aspectX!=0 && aspectY!=0); + + uiGeneralTab.pbRecalculate->setEnabled(data); + } + + /*! + * show the result and details of the dataReduction + */ + void XYDataReductionCurveDock::showDataReductionResult() { + const XYDataReductionCurve::DataReductionResult& dataReductionResult = m_dataReductionCurve->dataReductionResult(); + if (!dataReductionResult.available) { + uiGeneralTab.teResult->clear(); + return; + } + + //const XYDataReductionCurve::DataReductionData& dataReductionData = m_dataReductionCurve->dataReductionData(); + QString str = i18n("status:") + ' ' + dataReductionResult.status + "<br>"; + + if (!dataReductionResult.valid) { + uiGeneralTab.teResult->setText(str); + return; //result is not valid, there was an error which is shown in the status-string, nothing to show more. + } + + if (dataReductionResult.elapsedTime>1000) + str += i18n("calculation time: %1 s").arg(QString::number(dataReductionResult.elapsedTime/1000)) + "<br>"; + else + str += i18n("calculation time: %1 ms").arg(QString::number(dataReductionResult.elapsedTime)) + "<br>"; + + str += "<br>"; + + str += i18n("number of points: %1").arg(QString::number(dataReductionResult.npoints)) + "<br>"; + str += i18n("positional squared error: %1").arg(QString::number(dataReductionResult.posError)) + "<br>"; + str += i18n("area error: %1").arg(QString::number(dataReductionResult.areaError)) + "<br>"; + + uiGeneralTab.teResult->setText(str); + } + + //************************************************************* + //*********** SLOTs for changes triggered in XYCurve ********** + //************************************************************* + //General-Tab + void XYDataReductionCurveDock::curveDescriptionChanged(const AbstractAspect* aspect) { + if (m_curve != aspect) + return; + + m_initializing = true; + if (aspect->name() != uiGeneralTab.leName->text()) { + uiGeneralTab.leName->setText(aspect->name()); + } else if (aspect->comment() != uiGeneralTab.leComment->text()) { + uiGeneralTab.leComment->setText(aspect->comment()); + } + m_initializing = false; + } + + void XYDataReductionCurveDock::curveXDataColumnChanged(const AbstractColumn* column) { + m_initializing = true; + XYCurveDock::setModelIndexFromColumn(cbXDataColumn, column); + m_initializing = false; + } + + void XYDataReductionCurveDock::curveYDataColumnChanged(const AbstractColumn* column) { + m_initializing = true; + XYCurveDock::setModelIndexFromColumn(cbYDataColumn, column); + m_initializing = false; + } + + void XYDataReductionCurveDock::curveDataReductionDataChanged(const XYDataReductionCurve::DataReductionData& data) { + m_initializing = true; + m_dataReductionData = data; + //uiGeneralTab.cbType->setCurrentIndex(m_dataReductionData.type); + //this->typeChanged(); + + this->showDataReductionResult(); + m_initializing = false; + } + + void XYDataReductionCurveDock::dataChanged() { + this->enableRecalculate(); + }
