Merge lp:~valavanisalex/ubuntu/maverick/qtiplot/qtiplot-fix-605025 into lp:ubuntu/maverick/qtiplot

Proposed by Alex Valavanis
Status: Work in progress
Proposed branch: lp:~valavanisalex/ubuntu/maverick/qtiplot/qtiplot-fix-605025
Merge into: lp:ubuntu/maverick/qtiplot
Diff against target: 445833 lines (+58032/-191127)
368 files modified
.pc/.version (+1/-0)
.pc/01_build_system.diff/qtiplot.pro (+7/-0)
.pc/01_build_system.diff/qtiplot/qtiplot.pro (+241/-0)
.pc/01_build_system.diff/qtiplot/src/origin/origin.pri (+27/-0)
.pc/02_fix_paths.diff/qtiplot/src/core/ApplicationWindow.cpp (+18381/-0)
.pc/applied-patches (+3/-0)
3rdparty/liborigin/FORMAT (+0/-77)
3rdparty/liborigin/Origin750Parser.cpp (+0/-2413)
3rdparty/liborigin/Origin750Parser.h (+0/-65)
3rdparty/liborigin/OriginDefaultParser.cpp (+0/-481)
3rdparty/liborigin/OriginDefaultParser.h (+0/-47)
3rdparty/liborigin/OriginFile.cpp (+0/-175)
3rdparty/liborigin/OriginFile.h (+0/-75)
3rdparty/liborigin/OriginObj.h (+0/-703)
3rdparty/liborigin/OriginParser.cpp (+0/-189)
3rdparty/liborigin/OriginParser.h (+0/-67)
3rdparty/liborigin/copying (+0/-674)
3rdparty/liborigin/doc/Doxyfile (+0/-236)
3rdparty/liborigin/doc/liborigin2.dox (+0/-66)
3rdparty/liborigin/endianfstream.hh (+0/-225)
3rdparty/liborigin/liborigin.pro (+0/-26)
3rdparty/liborigin/logging.hpp (+0/-619)
3rdparty/liborigin/readme (+0/-27)
3rdparty/liborigin/tree.hh (+0/-2663)
3rdparty/qwtplot3d/3rdparty/gl2ps/COPYING.GL2PS (+0/-25)
3rdparty/qwtplot3d/3rdparty/gl2ps/COPYING.LGPL (+0/-482)
3rdparty/qwtplot3d/3rdparty/gl2ps/gl2ps.c (+0/-6061)
3rdparty/qwtplot3d/3rdparty/gl2ps/gl2ps.h (+0/-199)
3rdparty/qwtplot3d/include/qwt3d_autoptr.h (+0/-75)
3rdparty/qwtplot3d/include/qwt3d_autoscaler.h (+0/-51)
3rdparty/qwtplot3d/include/qwt3d_axis.h (+0/-127)
3rdparty/qwtplot3d/include/qwt3d_color.h (+0/-63)
3rdparty/qwtplot3d/include/qwt3d_colorlegend.h (+0/-80)
3rdparty/qwtplot3d/include/qwt3d_coordsys.h (+0/-125)
3rdparty/qwtplot3d/include/qwt3d_curve.h (+258/-0)
3rdparty/qwtplot3d/include/qwt3d_drawable.h (+0/-70)
3rdparty/qwtplot3d/include/qwt3d_enrichment.h (+0/-62)
3rdparty/qwtplot3d/include/qwt3d_enrichment_std.h (+0/-116)
3rdparty/qwtplot3d/include/qwt3d_extglwidget.h (+203/-0)
3rdparty/qwtplot3d/include/qwt3d_function.h (+0/-41)
3rdparty/qwtplot3d/include/qwt3d_global.h (+0/-58)
3rdparty/qwtplot3d/include/qwt3d_graphplot.h (+0/-24)
3rdparty/qwtplot3d/include/qwt3d_gridmapping.h (+0/-34)
3rdparty/qwtplot3d/include/qwt3d_helper.h (+0/-36)
3rdparty/qwtplot3d/include/qwt3d_io.h (+0/-141)
3rdparty/qwtplot3d/include/qwt3d_io_gl2ps.h (+0/-94)
3rdparty/qwtplot3d/include/qwt3d_io_reader.h (+0/-35)
3rdparty/qwtplot3d/include/qwt3d_label.h (+0/-78)
3rdparty/qwtplot3d/include/qwt3d_mapping.h (+0/-27)
3rdparty/qwtplot3d/include/qwt3d_multiplot.h (+0/-24)
3rdparty/qwtplot3d/include/qwt3d_openglhelper.h (+0/-130)
3rdparty/qwtplot3d/include/qwt3d_parametricsurface.h (+0/-44)
3rdparty/qwtplot3d/include/qwt3d_plot.h (+0/-320)
3rdparty/qwtplot3d/include/qwt3d_portability.h (+0/-91)
3rdparty/qwtplot3d/include/qwt3d_scale.h (+0/-89)
3rdparty/qwtplot3d/include/qwt3d_surfaceplot.h (+0/-130)
3rdparty/qwtplot3d/include/qwt3d_types.h (+0/-455)
3rdparty/qwtplot3d/include/qwt3d_volumeplot.h (+0/-24)
3rdparty/qwtplot3d/qwtplot3d.pri (+0/-71)
3rdparty/qwtplot3d/qwtplot3d.pro (+0/-96)
3rdparty/qwtplot3d/src/qwt3d_autoscaler.cpp (+0/-253)
3rdparty/qwtplot3d/src/qwt3d_axis.cpp (+0/-359)
3rdparty/qwtplot3d/src/qwt3d_color.cpp (+0/-63)
3rdparty/qwtplot3d/src/qwt3d_colorlegend.cpp (+0/-229)
3rdparty/qwtplot3d/src/qwt3d_coordsys.cpp (+0/-725)
3rdparty/qwtplot3d/src/qwt3d_curve.cpp (+741/-0)
3rdparty/qwtplot3d/src/qwt3d_dataviews.cpp (+0/-10)
3rdparty/qwtplot3d/src/qwt3d_drawable.cpp (+0/-140)
3rdparty/qwtplot3d/src/qwt3d_enrichment_std.cpp (+0/-347)
3rdparty/qwtplot3d/src/qwt3d_extglwidget.cpp (+136/-0)
3rdparty/qwtplot3d/src/qwt3d_function.cpp (+0/-102)
3rdparty/qwtplot3d/src/qwt3d_gridmapping.cpp (+0/-32)
3rdparty/qwtplot3d/src/qwt3d_gridplot.cpp (+0/-595)
3rdparty/qwtplot3d/src/qwt3d_io.cpp (+0/-365)
3rdparty/qwtplot3d/src/qwt3d_io_gl2ps.cpp (+0/-417)
3rdparty/qwtplot3d/src/qwt3d_io_reader.cpp (+0/-225)
3rdparty/qwtplot3d/src/qwt3d_label.cpp (+0/-304)
3rdparty/qwtplot3d/src/qwt3d_lighting.cpp (+0/-192)
3rdparty/qwtplot3d/src/qwt3d_meshplot.cpp (+0/-318)
3rdparty/qwtplot3d/src/qwt3d_mousekeyboard.cpp (+0/-387)
3rdparty/qwtplot3d/src/qwt3d_movements.cpp (+0/-106)
3rdparty/qwtplot3d/src/qwt3d_parametricsurface.cpp (+0/-104)
3rdparty/qwtplot3d/src/qwt3d_plot.cpp (+0/-500)
3rdparty/qwtplot3d/src/qwt3d_scale.cpp (+0/-312)
3rdparty/qwtplot3d/src/qwt3d_surfaceplot.cpp (+0/-183)
3rdparty/qwtplot3d/src/qwt3d_types.cpp (+0/-222)
3rdparty/zlib/README.txt (+0/-29)
3rdparty/zlib/minigzip.c (+0/-258)
3rdparty/zlib/zconf.h (+0/-332)
3rdparty/zlib/zlib.h (+0/-1357)
README.html (+5/-1)
build.conf.example (+38/-7)
debian/build.conf (+12/-1)
debian/changelog (+37/-0)
debian/control (+8/-5)
debian/patches/01_build_system.diff (+57/-64)
debian/patches/02_docbook_stylesheet.diff (+0/-11)
debian/patches/02_fix_paths.diff (+11/-0)
debian/patches/03_fix_qti_wordlist.txt_path.diff (+0/-13)
debian/patches/04_add_includes.diff (+0/-10)
debian/patches/debian-changes-0.9.7.14-1 (+187/-0)
debian/patches/series (+2/-2)
debian/rules (+6/-8)
debian/source/format (+1/-0)
fitPlugins/exp_saturation/exp_saturation.c (+0/-70)
fitPlugins/exp_saturation/exp_saturation.pro (+0/-29)
fitPlugins/explin/explin.c (+0/-76)
fitPlugins/explin/explin.pro (+0/-29)
fitPlugins/fitPlugins.pro (+0/-7)
fitPlugins/fitRational0/fitRational0.cpp (+32/-0)
fitPlugins/fitRational1/fitRational1.cpp (+32/-0)
fitPlugins/planck_wavelength/planck_wavelength.c (+0/-70)
fitPlugins/planck_wavelength/planck_wavelength.pro (+0/-27)
manual/docbook-en/appendix.docbook (+14/-2)
manual/docbook-en/dialogs.docbook (+85/-62)
manual/docbook-en/index.docbook (+7/-7)
manual/docbook-en/scripting.docbook (+252/-21)
manual/html/icons/icons.qrc (+225/-0)
manual/html/qtiplot.adp (+381/-367)
qtiplot.pro (+3/-4)
qtiplot/examples/python/filter_table.py (+0/-50)
qtiplot/examples/python/strd_nist_fit.py (+0/-163)
qtiplot/icons/axes_icons.h (+0/-1275)
qtiplot/icons/pixmaps.h (+0/-12630)
qtiplot/python-includepath.py (+28/-0)
qtiplot/python-libs-win.py (+28/-0)
qtiplot/python-sipcmd.py (+28/-0)
qtiplot/qtiUtil.py (+29/-0)
qtiplot/qti_wordlist.txt (+24/-0)
qtiplot/qtiplot.pro (+64/-29)
qtiplot/qtiplot.rc (+40/-0)
qtiplot/qtiplotrc.py (+37/-17)
qtiplot/src/analysis/Convolution.cpp (+1/-1)
qtiplot/src/analysis/Correlation.cpp (+1/-1)
qtiplot/src/analysis/FFT.cpp (+1/-1)
qtiplot/src/analysis/Filter.cpp (+106/-58)
qtiplot/src/analysis/Filter.h (+4/-3)
qtiplot/src/analysis/Fit.cpp (+35/-25)
qtiplot/src/analysis/Fit.h (+2/-2)
qtiplot/src/analysis/Integration.cpp (+21/-13)
qtiplot/src/analysis/Interpolation.cpp (+81/-74)
qtiplot/src/analysis/MultiPeakFit.cpp (+48/-20)
qtiplot/src/analysis/MultiPeakFit.h (+4/-3)
qtiplot/src/analysis/NonLinearFit.cpp (+47/-14)
qtiplot/src/analysis/NonLinearFit.h (+2/-2)
qtiplot/src/analysis/SmoothFilter.cpp (+1/-1)
qtiplot/src/analysis/analysis.pri (+0/-70)
qtiplot/src/analysis/dialogs/ExpDecayDialog.cpp (+17/-16)
qtiplot/src/analysis/dialogs/ExpDecayDialog.h (+2/-2)
qtiplot/src/analysis/dialogs/FFTDialog.cpp (+11/-3)
qtiplot/src/analysis/dialogs/FilterDialog.cpp (+10/-7)
qtiplot/src/analysis/dialogs/FilterDialog.h (+2/-2)
qtiplot/src/analysis/dialogs/FitDialog.cpp (+163/-146)
qtiplot/src/analysis/dialogs/FitDialog.h (+10/-6)
qtiplot/src/analysis/dialogs/FrequencyCountDialog.cpp (+1/-1)
qtiplot/src/analysis/dialogs/IntDialog.cpp (+26/-26)
qtiplot/src/analysis/dialogs/IntDialog.h (+2/-2)
qtiplot/src/analysis/dialogs/InterpolationDialog.cpp (+19/-20)
qtiplot/src/analysis/dialogs/InterpolationDialog.h (+2/-2)
qtiplot/src/analysis/dialogs/PolynomFitDialog.cpp (+14/-12)
qtiplot/src/analysis/dialogs/PolynomFitDialog.h (+2/-2)
qtiplot/src/analysis/dialogs/SmoothCurveDialog.cpp (+22/-19)
qtiplot/src/analysis/dialogs/SmoothCurveDialog.h (+5/-5)
qtiplot/src/analysis/dialogs/SubtractDataDialog.cpp (+337/-0)
qtiplot/src/analysis/dialogs/SubtractDataDialog.h (+73/-0)
qtiplot/src/analysis/fit_gsl.cpp (+32/-0)
qtiplot/src/analysis/fit_gsl.h (+32/-0)
qtiplot/src/analysis/nrutil.cpp (+0/-14)
qtiplot/src/analysis/nrutil.h (+0/-2)
qtiplot/src/core/ApplicationWindow.cpp (+0/-17557)
qtiplot/src/core/ApplicationWindow.h (+0/-1411)
qtiplot/src/core/ConfigDialog.cpp (+0/-2736)
qtiplot/src/core/ConfigDialog.h (+0/-232)
qtiplot/src/core/CustomActionDialog.cpp (+0/-787)
qtiplot/src/core/CustomActionDialog.h (+0/-135)
qtiplot/src/core/FindDialog.cpp (+0/-144)
qtiplot/src/core/FindDialog.h (+0/-75)
qtiplot/src/core/Folder.cpp (+0/-495)
qtiplot/src/core/Folder.h (+0/-226)
qtiplot/src/core/ImportASCIIDialog.cpp (+0/-811)
qtiplot/src/core/ImportASCIIDialog.h (+0/-189)
qtiplot/src/core/MdiSubWindow.cpp (+0/-344)
qtiplot/src/core/MdiSubWindow.h (+0/-205)
qtiplot/src/core/MultiPeakFitTool.cpp (+0/-150)
qtiplot/src/core/MultiPeakFitTool.h (+0/-74)
qtiplot/src/core/OdsFileHandler.cpp (+165/-0)
qtiplot/src/core/OdsFileHandler.h (+82/-0)
qtiplot/src/core/OpenProjectDialog.cpp (+0/-98)
qtiplot/src/core/OpenProjectDialog.h (+0/-53)
qtiplot/src/core/PlotWizard.cpp (+0/-400)
qtiplot/src/core/PlotWizard.h (+0/-126)
qtiplot/src/core/QtiPlotApplication.cpp (+124/-0)
qtiplot/src/core/QtiPlotApplication.h (+57/-0)
qtiplot/src/core/RenameWindowDialog.cpp (+0/-154)
qtiplot/src/core/RenameWindowDialog.h (+0/-75)
qtiplot/src/core/core.pri (+0/-31)
qtiplot/src/core/globals.h (+0/-41)
qtiplot/src/core/main.cpp (+0/-151)
qtiplot/src/lib/3rdparty/qtcolorpicker/LGPL_EXCEPTION.txt (+0/-10)
qtiplot/src/lib/3rdparty/qtcolorpicker/LICENSE.GPL3 (+0/-674)
qtiplot/src/lib/3rdparty/qtcolorpicker/LICENSE.LGPL (+0/-504)
qtiplot/src/lib/3rdparty/qtcolorpicker/README.TXT (+0/-7)
qtiplot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp (+0/-1144)
qtiplot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h (+0/-121)
qtiplot/src/lib/CHANGES.txt (+0/-14)
qtiplot/src/lib/INSTALL (+0/-37)
qtiplot/src/lib/README (+0/-25)
qtiplot/src/lib/doc/Doxyfile (+0/-236)
qtiplot/src/lib/doc/qti.dox (+0/-60)
qtiplot/src/lib/gpl-3.0.txt (+0/-674)
qtiplot/src/lib/include/ColorBox.h (+0/-73)
qtiplot/src/lib/include/ColorButton.h (+0/-58)
qtiplot/src/lib/include/ColorMapEditor.h (+0/-96)
qtiplot/src/lib/include/DoubleSpinBox.h (+0/-105)
qtiplot/src/lib/include/ExtensibleFileDialog.h (+0/-78)
qtiplot/src/lib/include/LineNumberDisplay.h (+0/-61)
qtiplot/src/lib/include/PatternBox.h (+0/-61)
qtiplot/src/lib/include/PenStyleBox.h (+0/-58)
qtiplot/src/lib/include/SymbolBox.h (+0/-63)
qtiplot/src/lib/include/SymbolDialog.h (+0/-106)
qtiplot/src/lib/include/TextFormatButtons.h (+0/-90)
qtiplot/src/lib/libqti.pri (+0/-37)
qtiplot/src/lib/qti.pro (+0/-50)
qtiplot/src/lib/src/ColorBox.cpp (+0/-160)
qtiplot/src/lib/src/ColorButton.cpp (+0/-43)
qtiplot/src/lib/src/ColorMapEditor.cpp (+0/-308)
qtiplot/src/lib/src/DoubleSpinBox.cpp (+0/-207)
qtiplot/src/lib/src/ExtensibleFileDialog.cpp (+0/-85)
qtiplot/src/lib/src/LineNumberDisplay.cpp (+0/-118)
qtiplot/src/lib/src/PatternBox.cpp (+0/-187)
qtiplot/src/lib/src/PenStyleBox.cpp (+0/-84)
qtiplot/src/lib/src/SymbolBox.cpp (+0/-182)
qtiplot/src/lib/src/SymbolDialog.cpp (+0/-678)
qtiplot/src/lib/src/TextFormatButtons.cpp (+0/-639)
qtiplot/src/matrix/ColorMapDialog.cpp (+0/-89)
qtiplot/src/matrix/ColorMapDialog.h (+0/-54)
qtiplot/src/matrix/Matrix.cpp (+24/-3)
qtiplot/src/matrix/Matrix.h (+2/-0)
qtiplot/src/matrix/MatrixValuesDialog.cpp (+25/-1)
qtiplot/src/matrix/MatrixValuesDialog.h (+3/-0)
qtiplot/src/matrix/matrix.pri (+0/-21)
qtiplot/src/origin/importOPJ.cpp (+0/-1873)
qtiplot/src/origin/importOPJ.h (+0/-69)
qtiplot/src/origin/origin.pri (+0/-17)
qtiplot/src/plot2D/BoxCurve.cpp (+3/-3)
qtiplot/src/plot2D/BoxCurve.h (+1/-1)
qtiplot/src/plot2D/CanvasPicker.cpp (+14/-15)
qtiplot/src/plot2D/DataPickerTool.cpp (+58/-42)
qtiplot/src/plot2D/DataPickerTool.h (+6/-0)
qtiplot/src/plot2D/EllipseWidget.cpp (+0/-140)
qtiplot/src/plot2D/EllipseWidget.h (+0/-50)
qtiplot/src/plot2D/FunctionCurve.cpp (+85/-37)
qtiplot/src/plot2D/FunctionCurve.h (+1/-1)
qtiplot/src/plot2D/Graph.cpp (+637/-429)
qtiplot/src/plot2D/Graph.h (+52/-30)
qtiplot/src/plot2D/Grid.cpp (+2/-2)
qtiplot/src/plot2D/ImageWidget.cpp (+39/-5)
qtiplot/src/plot2D/ImageWidget.h (+11/-1)
qtiplot/src/plot2D/LegendWidget.cpp (+41/-25)
qtiplot/src/plot2D/LineProfileTool.cpp (+41/-28)
qtiplot/src/plot2D/LineProfileTool.h (+1/-1)
qtiplot/src/plot2D/LnScaleEngine.cpp (+1/-1)
qtiplot/src/plot2D/LogitScaleEngine.cpp (+1/-1)
qtiplot/src/plot2D/MultiLayer.cpp (+416/-178)
qtiplot/src/plot2D/MultiLayer.h (+29/-3)
qtiplot/src/plot2D/MultiPeakFitTool.cpp (+29/-14)
qtiplot/src/plot2D/PlotCurve.cpp (+29/-3)
qtiplot/src/plot2D/PlotToolInterface.h (+5/-2)
qtiplot/src/plot2D/ProbabilityScaleEngine.cpp (+1/-1)
qtiplot/src/plot2D/QwtBarCurve.cpp (+1/-1)
qtiplot/src/plot2D/QwtErrorPlotCurve.cpp (+15/-9)
qtiplot/src/plot2D/QwtHistogram.cpp (+4/-1)
qtiplot/src/plot2D/RangeSelectorTool.cpp (+3/-4)
qtiplot/src/plot2D/RangeSelectorTool.h (+2/-0)
qtiplot/src/plot2D/ScaleDraw.cpp (+81/-54)
qtiplot/src/plot2D/ScaleDraw.h (+11/-4)
qtiplot/src/plot2D/ScaleEngine.cpp (+15/-7)
qtiplot/src/plot2D/ScalePicker.cpp (+13/-13)
qtiplot/src/plot2D/ScreenPickerTool.cpp (+216/-5)
qtiplot/src/plot2D/ScreenPickerTool.h (+42/-1)
qtiplot/src/plot2D/SelectionMoveResizer.cpp (+5/-4)
qtiplot/src/plot2D/Spectrogram.cpp (+21/-10)
qtiplot/src/plot2D/SubtractLineTool.cpp (+122/-0)
qtiplot/src/plot2D/SubtractLineTool.h (+69/-0)
qtiplot/src/plot2D/TranslateCurveTool.cpp (+0/-1)
qtiplot/src/plot2D/VectorCurve.cpp (+1/-1)
qtiplot/src/plot2D/cursors.h (+0/-142)
qtiplot/src/plot2D/dialogs/AxesDialog.cpp (+152/-86)
qtiplot/src/plot2D/dialogs/AxesDialog.h (+9/-6)
qtiplot/src/plot2D/dialogs/ContourLinesEditor.cpp (+0/-412)
qtiplot/src/plot2D/dialogs/ContourLinesEditor.h (+0/-102)
qtiplot/src/plot2D/dialogs/CurvesDialog.cpp (+55/-47)
qtiplot/src/plot2D/dialogs/EnrichmentDialog.cpp (+17/-41)
qtiplot/src/plot2D/dialogs/ErrDialog.cpp (+1/-2)
qtiplot/src/plot2D/dialogs/FunctionDialog.cpp (+494/-271)
qtiplot/src/plot2D/dialogs/FunctionDialog.h (+33/-21)
qtiplot/src/plot2D/dialogs/ImageExportDialog.cpp (+34/-1)
qtiplot/src/plot2D/dialogs/ImageExportDialog.h (+3/-0)
qtiplot/src/plot2D/dialogs/LayerDialog.cpp (+374/-108)
qtiplot/src/plot2D/dialogs/LayerDialog.h (+27/-3)
qtiplot/src/plot2D/dialogs/PlotDialog.cpp (+466/-115)
qtiplot/src/plot2D/dialogs/PlotDialog.h (+28/-118)
qtiplot/src/plot2D/plot2D.pri (+0/-114)
qtiplot/src/plot3D/Bar.cpp (+52/-46)
qtiplot/src/plot3D/ColorMapPreviewDialog.cpp (+0/-95)
qtiplot/src/plot3D/ColorMapPreviewDialog.h (+0/-49)
qtiplot/src/plot3D/Cone3D.cpp (+1/-0)
qtiplot/src/plot3D/Graph3D.cpp (+539/-324)
qtiplot/src/plot3D/Graph3D.h (+27/-9)
qtiplot/src/plot3D/Plot3DDialog.cpp (+87/-60)
qtiplot/src/plot3D/Plot3DDialog.h (+5/-4)
qtiplot/src/plot3D/SurfaceDialog.cpp (+174/-96)
qtiplot/src/plot3D/SurfaceDialog.h (+15/-9)
qtiplot/src/plot3D/plot3D.pri (+0/-19)
qtiplot/src/scripting/FindReplaceDialog.cpp (+0/-215)
qtiplot/src/scripting/FindReplaceDialog.h (+0/-73)
qtiplot/src/scripting/MyParser.cpp (+0/-143)
qtiplot/src/scripting/MyParser.h (+0/-61)
qtiplot/src/scripting/Note.cpp (+0/-415)
qtiplot/src/scripting/Note.h (+0/-105)
qtiplot/src/scripting/PythonScript.cpp (+0/-300)
qtiplot/src/scripting/PythonScript.h (+0/-70)
qtiplot/src/scripting/PythonScripting.cpp (+0/-409)
qtiplot/src/scripting/PythonScripting.h (+0/-103)
qtiplot/src/scripting/PythonSyntaxHighlighter.cpp (+0/-189)
qtiplot/src/scripting/PythonSyntaxHighlighter.h (+0/-89)
qtiplot/src/scripting/Script.cpp (+0/-113)
qtiplot/src/scripting/Script.h (+0/-163)
qtiplot/src/scripting/ScriptEdit.cpp (+0/-819)
qtiplot/src/scripting/ScriptEdit.h (+0/-171)
qtiplot/src/scripting/ScriptWindow.cpp (+0/-482)
qtiplot/src/scripting/ScriptWindow.h (+0/-107)
qtiplot/src/scripting/ScriptingEnv.cpp (+0/-70)
qtiplot/src/scripting/ScriptingEnv.h (+0/-115)
qtiplot/src/scripting/ScriptingLangDialog.cpp (+0/-81)
qtiplot/src/scripting/ScriptingLangDialog.h (+0/-59)
qtiplot/src/scripting/customevents.h (+0/-40)
qtiplot/src/scripting/muParserScript.cpp (+0/-478)
qtiplot/src/scripting/muParserScript.h (+0/-85)
qtiplot/src/scripting/muParserScripting.cpp (+0/-108)
qtiplot/src/scripting/muParserScripting.h (+0/-134)
qtiplot/src/scripting/qti.sip (+0/-2824)
qtiplot/src/scripting/scripting.pri (+0/-117)
qtiplot/src/table/ExportDialog.cpp (+0/-296)
qtiplot/src/table/ExportDialog.h (+0/-100)
qtiplot/src/table/ExtractDataDialog.cpp (+229/-0)
qtiplot/src/table/ExtractDataDialog.h (+88/-0)
qtiplot/src/table/SetColValuesDialog.cpp (+0/-292)
qtiplot/src/table/SetColValuesDialog.h (+0/-96)
qtiplot/src/table/SortDialog.cpp (+0/-102)
qtiplot/src/table/SortDialog.h (+0/-62)
qtiplot/src/table/Table.cpp (+0/-3412)
qtiplot/src/table/Table.h (+0/-365)
qtiplot/src/table/TableDialog.cpp (+0/-576)
qtiplot/src/table/TableDialog.h (+0/-96)
qtiplot/src/table/TableStatistics.cpp (+0/-344)
qtiplot/src/table/TableStatistics.h (+0/-74)
qtiplot/src/table/table.pri (+0/-19)
qtiplot/translations/qtiplot_cn.ts (+0/-18144)
qtiplot/translations/qtiplot_cz.ts (+10940/-15639)
qtiplot/translations/qtiplot_de.ts (+4175/-5305)
qtiplot/translations/qtiplot_es.ts (+4031/-6180)
qtiplot/translations/qtiplot_fr.ts (+1992/-14588)
qtiplot/translations/qtiplot_ja.ts (+3100/-6775)
qtiplot/translations/qtiplot_ro.ts (+0/-18434)
qtiplot/translations/qtiplot_ru.ts (+1023/-4728)
qtiplot/translations/qtiplot_sv.ts (+4292/-5470)
qtiplot_0.9.7.14-1_amd64.build (+156/-0)
To merge this branch: bzr merge lp:~valavanisalex/ubuntu/maverick/qtiplot/qtiplot-fix-605025
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Pending
Review via email: mp+30599@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Scott Howard (showard314) wrote :

This is an impressive amount of work! Have you discussed this with upstream yet? Ion is quite responsive and would appreciate the help with this. He's responsive on his forum, check out this post about this bug:
http://developer.berlios.de/forum/message.php?msg_id=51418

The best thing would be to get this implimented upstream and we grab upstream's patch.

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

> This is an impressive amount of work! Have you discussed this with upstream
> yet? Ion is quite responsive and would appreciate the help with this. He's
> responsive on his forum, check out this post about this bug:
> http://developer.berlios.de/forum/message.php?msg_id=51418
>
> The best thing would be to get this implimented upstream and we grab
> upstream's patch.

Hi Scott, most of these changes are from upstream already. The diff against Ubuntu just looks large because there was a new upstream release!

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

I have uploaded debdiffs to bug #605027 so you can see the (minimal) changes against the Debian package.

Revision history for this message
Scott Howard (showard314) wrote :

ok, I thought the diff was huge because you updated to the new qt assistant. That's why I though Ion should know.

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

Ah OK,

Unfortunately, I think that moving to the new Qt Assistant needs to be an upstream task because their online documentation will also need to migrate to the new format. i.e. we could make a patch for Ubuntu but it wouldn't be able to read the old documentation!

Unmerged revisions

17. By Alex Valavanis

* debian/control: Fix Qt 4.7 compatibility (LP: #598826)
  + Build-Depends: libqtassistantclient-dev
  + Recommends: qt-assistant-compat

16. By Alex Valavanis

* Merge with Debian unstable (LP: #605027, LP: #608360)
  + debian/control: Ubuntu maintainers
* debian/patches/01_build_system.diff: Rm explicit python version
  (Closes: #560852)
* debian/control: Build-Depends: libqtassistantclient-dev (LP: #598826)
* New upstream release
* Build QTeXEngine into program
* Bump liborigin2 dependency to >=1:06042009+svn1724
* Bump muparser dependency to 1.32
* New upstream release
* Switch to dpkg-source 3.0 (quilt) format
* Minor fix to patch 01_build_system.diff
* Add qwtplot3d to build.conf
* Bump standards version to 3.8.4
* Fix spelling errors in description
* Add misc depends in qtiplot-doc
* Remove patch 02_docbook_stylesheet and
  04_add_includes.diff
* Rename 03_fix_qti_wordlist.txt_path to
  02_fix_paths.diff

15. By Alex Valavanis

Merging shared upstream rev into target branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc'
2=== added file '.pc/.version'
3--- .pc/.version 1970-01-01 00:00:00 +0000
4+++ .pc/.version 2010-07-22 00:49:43 +0000
5@@ -0,0 +1,1 @@
6+2
7
8=== added directory '.pc/01_build_system.diff'
9=== added directory '.pc/01_build_system.diff/qtiplot'
10=== added file '.pc/01_build_system.diff/qtiplot.pro'
11--- .pc/01_build_system.diff/qtiplot.pro 1970-01-01 00:00:00 +0000
12+++ .pc/01_build_system.diff/qtiplot.pro 2010-07-22 00:49:43 +0000
13@@ -0,0 +1,7 @@
14+TEMPLATE = subdirs
15+
16+SUBDIRS = fitPlugins \
17+ manual \
18+ 3rdparty/qwt \
19+ 3rdparty/qwtplot3d \
20+ qtiplot
21
22=== added file '.pc/01_build_system.diff/qtiplot/qtiplot.pro'
23--- .pc/01_build_system.diff/qtiplot/qtiplot.pro 1970-01-01 00:00:00 +0000
24+++ .pc/01_build_system.diff/qtiplot/qtiplot.pro 2010-07-22 00:49:43 +0000
25@@ -0,0 +1,241 @@
26+TARGET = qtiplot
27+QTI_ROOT = ..
28+!include( $$QTI_ROOT/build.conf ) {
29+ message( "You need a build.conf file with local settings!" )
30+}
31+
32+##################### 3rd PARTY HEADER FILES SECTION ########################
33+#!!! Warning: You must set this up in $$QTIROOT/build.conf
34+#############################################################################
35+
36+# local copy included
37+INCLUDEPATH += ../3rdparty/zlib
38+INCLUDEPATH += ../3rdparty/QTeXEngine/src
39+
40+# configurable
41+INCLUDEPATH += $$MUPARSER_INCLUDEPATH
42+INCLUDEPATH += $$QWT_INCLUDEPATH
43+INCLUDEPATH += $$QWT3D_INCLUDEPATH
44+INCLUDEPATH += $$GSL_INCLUDEPATH
45+
46+# configurable libs
47+LIBS += $$MUPARSER_LIBS
48+LIBS += $$QWT_LIBS
49+LIBS += $$QWT3D_LIBS
50+LIBS += $$GSL_LIBS
51+
52+#############################################################################
53+###################### BASIC PROJECT PROPERTIES #############################
54+#############################################################################
55+
56+QMAKE_PROJECT_DEPTH = 0
57+
58+!contains(CONFIG, BrowserPlugin){
59+ TEMPLATE = app
60+}
61+
62+CONFIG += qt warn_on exceptions opengl thread
63+CONFIG += assistant
64+
65+DEFINES += QT_PLUGIN
66+contains(CONFIG, CustomInstall){
67+ INSTALLS += target
68+ INSTALLS += translations
69+ INSTALLS += manual
70+ INSTALLS += documentation
71+ unix:INSTALLS += man
72+
73+ unix: INSTALLBASE = /usr
74+ win32: INSTALLBASE = C:/QtiPlot
75+
76+ unix: target.path = $$INSTALLBASE/bin
77+ unix: translations.path = $$INSTALLBASE/share/qtiplot/translations
78+ unix: manual.path = $$INSTALLBASE/share/doc/qtiplot/manual
79+ unix: documentation.path = $$INSTALLBASE/share/doc/qtiplot
80+ unix: man.path = $$INSTALLBASE/share/man/man1/
81+
82+ win32: target.path = $$INSTALLBASE
83+ win32: translations.path = $$INSTALLBASE/translations
84+ win32: manual.path = $$INSTALLBASE/manual
85+ win32: documentation.path = $$INSTALLBASE/doc
86+
87+ DEFINES += TRANSLATIONS_PATH="\\\"$$replace(translations.path," ","\ ")\\\"
88+ DEFINES += MANUAL_PATH="\\\"$$replace(manual.path," ","\ ")\\\"
89+ }
90+
91+win32:DEFINES += QT_DLL QT_THREAD_SUPPORT
92+QT += opengl qt3support network svg xml
93+
94+MOC_DIR = ../tmp/qtiplot
95+OBJECTS_DIR = ../tmp/qtiplot
96+SIP_DIR = ../tmp/qtiplot
97+DESTDIR = ./
98+
99+#############################################################################
100+###################### PROJECT FILES SECTION ################################
101+#############################################################################
102+
103+###################### ICONS ################################################
104+INCLUDEPATH += icons/
105+win32:RC_FILE = icons/qtiplot.rc
106+mac:RC_FILE = icons/qtiplot.icns
107+RESOURCES = ../manual/html/icons/icons.qrc
108+
109+###################### TRANSLATIONS #########################################
110+
111+TRANSLATIONS = translations/qtiplot_cn.ts \
112+ translations/qtiplot_cz.ts \
113+ translations/qtiplot_de.ts \
114+ translations/qtiplot_es.ts \
115+ translations/qtiplot_fr.ts \
116+ #translations/qtiplot_pt.ts \
117+ translations/qtiplot_ro.ts \
118+ translations/qtiplot_ru.ts \
119+ translations/qtiplot_ja.ts \
120+ translations/qtiplot_sv.ts
121+
122+translations.files += translations/qtiplot_cn.qm \
123+ translations/qtiplot_cz.qm \
124+ translations/qtiplot_de.qm \
125+ translations/qtiplot_es.qm \
126+ translations/qtiplot_fr.qm \
127+ #translations/qtiplot_pt.qm \
128+ translations/qtiplot_ro.qm \
129+ translations/qtiplot_ru.qm \
130+ translations/qtiplot_ja.qm \
131+ translations/qtiplot_sv.qm
132+
133+isEmpty(LUPDATE): LUPDATE = lupdate
134+#system($$LUPDATE -verbose qtiplot.pro)
135+isEmpty(LRELEASE): LRELEASE = lrelease
136+#system($$LRELEASE -verbose qtiplot.pro)
137+
138+###################### DOCUMENTATION ########################################
139+
140+manual.files += ../manual/html \
141+ ../manual/qtiplot-manual-en.pdf
142+
143+documentation.files += ../README.html \
144+ ../gpl_licence.txt
145+
146+unix: man.files += ../qtiplot.1
147+
148+###############################################################
149+##################### Compression (zlib-1.2.3) ################
150+###############################################################
151+
152+SOURCES += ../3rdparty/zlib/minigzip.c
153+
154+###############################################################
155+################# Default Modules #############################
156+###############################################################
157+
158+include(src/analysis/analysis.pri)
159+include(src/core/core.pri)
160+include(src/lib/libqti.pri)
161+include(src/plot2D/plot2D.pri)
162+include(src/plot3D/plot3D.pri)
163+include(src/matrix/matrix.pri)
164+include(src/table/table.pri)
165+include(src/scripting/scripting.pri)
166+
167+###############################################################
168+##################### TeX export: QTeXEngine ##################
169+###############################################################
170+
171+INCLUDEPATH += ../3rdparty/QTeXEngine/src
172+HEADERS += ../3rdparty/QTeXEngine/src/QTeXEngine.h
173+SOURCES += ../3rdparty/QTeXEngine/src/QTeXPaintEngine.cpp
174+SOURCES += ../3rdparty/QTeXEngine/src/QTeXPaintDevice.cpp
175+
176+###############################################################
177+##################### Scripting: PYTHON + SIP + PyQT ##########
178+###############################################################
179+
180+contains(SCRIPTING_LANGS, Python) {
181+ contains(CONFIG, CustomInstall){
182+ INSTALLS += pythonconfig
183+ pythonconfig.files += qtiplotrc.py \
184+ qtiUtil.py \
185+ qti_wordlist.txt \
186+
187+ unix: pythonconfig.path = /usr/local/qtiplot
188+ win32: pythonconfig.path = $$INSTALLBASE
189+ DEFINES += PYTHON_CONFIG_PATH="\\\"$$replace(pythonconfig.path," ","\ ")\\\"
190+ }
191+
192+ unix {
193+ isEmpty(PYTHON): PYTHON = python
194+ INCLUDEPATH += $$system($$PYTHON python-includepath.py)
195+ LIBS += $$system($$PYTHON -c "\"from distutils import sysconfig; print '-lpython'+sysconfig.get_config_var('VERSION')\"")
196+ LIBS += -lm
197+ system(mkdir -p $${SIP_DIR})
198+ system($$system($$PYTHON python-sipcmd.py) -c $${SIP_DIR} src/scripting/qti.sip)
199+ }
200+
201+ win32 {
202+ INCLUDEPATH += $$system(call python-includepath.py)
203+ LIBS += $$system(call python-libs-win.py)
204+ system($$system(call python-sipcmd.py) -c $${SIP_DIR} src/scripting/qti.sip)
205+ }
206+}
207+
208+###############################################################
209+
210+# check if we have libpng
211+!isEmpty(LIBPNG_LIBS) {
212+ DEFINES += GL2PS_HAVE_LIBPNG
213+ INCLUDEPATH += $$LIBPNG_INCLUDEPATH
214+ LIBS += $$LIBPNG_LIBS
215+}
216+
217+###############################################################
218+
219+# check if we have EmfEnginge
220+!isEmpty(EMF_ENGINE_LIBS) {
221+ DEFINES += EMF_OUTPUT
222+ INCLUDEPATH += $$EMF_ENGINE_INCLUDEPATH
223+ LIBS += $$EMF_ENGINE_LIBS
224+ win32:LIBS += -lgdiplus
225+ unix:LIBS += -lEMF
226+}
227+
228+# check if we have libxls
229+!isEmpty(XLS_LIBS) {
230+ DEFINES += XLS_IMPORT
231+ INCLUDEPATH += $$XLS_INCLUDEPATH
232+ LIBS += $$XLS_LIBS
233+}
234+
235+# check if we have QuaZIP
236+!isEmpty(QUAZIP_LIBS) {
237+ DEFINES += ODS_IMPORT
238+ INCLUDEPATH += $$QUAZIP_INCLUDEPATH
239+ LIBS += $$QUAZIP_LIBS
240+}
241+
242+# check if we have liborigin2
243+!isEmpty(BOOST_LIBS) {
244+ DEFINES += OPJ_IMPORT
245+ INCLUDEPATH += $$BOOST_INCLUDEPATH
246+ INCLUDEPATH += ../3rdparty/liborigin
247+ LIBS += $$BOOST_LIBS
248+ include(src/origin/origin.pri)
249+}
250+
251+###############################################################
252+
253+# At the very end: add global include- and lib path
254+unix:INCLUDEPATH += $$SYS_INCLUDEPATH
255+unix:LIBS += $$SYS_LIBS
256+
257+###############################################################
258+############### Building QtiPlot as a browser plugin ##########
259+###############################################################
260+
261+contains(CONFIG, BrowserPlugin){
262+ DEFINES += BROWSER_PLUGIN
263+ win32: CONFIG += qaxserver
264+ RC_FILE = qtiplot.rc
265+ include(../3rdparty/QtSolutions/qtbrowserplugin/src/qtbrowserplugin.pri)
266+}
267
268=== added directory '.pc/01_build_system.diff/qtiplot/src'
269=== added directory '.pc/01_build_system.diff/qtiplot/src/origin'
270=== added file '.pc/01_build_system.diff/qtiplot/src/origin/origin.pri'
271--- .pc/01_build_system.diff/qtiplot/src/origin/origin.pri 1970-01-01 00:00:00 +0000
272+++ .pc/01_build_system.diff/qtiplot/src/origin/origin.pri 2010-07-22 00:49:43 +0000
273@@ -0,0 +1,27 @@
274+###############################################################
275+################# Origin Import (liborigin) ###################
276+###############################################################
277+INCLUDEPATH += src/origin/
278+
279+HEADERS += src/origin/importOPJ.h
280+HEADERS += ../3rdparty/liborigin/OriginObj.h
281+HEADERS += ../3rdparty/liborigin/OriginFile.h
282+HEADERS += ../3rdparty/liborigin/OriginParser.h
283+HEADERS += ../3rdparty/liborigin/OriginDefaultParser.h
284+HEADERS += ../3rdparty/liborigin/Origin600Parser.h
285+HEADERS += ../3rdparty/liborigin/Origin610Parser.h
286+HEADERS += ../3rdparty/liborigin/Origin700Parser.h
287+HEADERS += ../3rdparty/liborigin/Origin750Parser.h
288+HEADERS += ../3rdparty/liborigin/Origin800Parser.h
289+HEADERS += ../3rdparty/liborigin/Origin810Parser.h
290+
291+SOURCES += src/origin/importOPJ.cpp
292+SOURCES += ../3rdparty/liborigin/OriginFile.cpp
293+SOURCES += ../3rdparty/liborigin/OriginParser.cpp
294+SOURCES += ../3rdparty/liborigin/OriginDefaultParser.cpp
295+SOURCES += ../3rdparty/liborigin/Origin600Parser.cpp
296+SOURCES += ../3rdparty/liborigin/Origin610Parser.cpp
297+SOURCES += ../3rdparty/liborigin/Origin700Parser.cpp
298+SOURCES += ../3rdparty/liborigin/Origin750Parser.cpp
299+SOURCES += ../3rdparty/liborigin/Origin800Parser.cpp
300+SOURCES += ../3rdparty/liborigin/Origin810Parser.cpp
301
302=== added directory '.pc/02_fix_paths.diff'
303=== added directory '.pc/02_fix_paths.diff/qtiplot'
304=== added directory '.pc/02_fix_paths.diff/qtiplot/src'
305=== added directory '.pc/02_fix_paths.diff/qtiplot/src/core'
306=== added file '.pc/02_fix_paths.diff/qtiplot/src/core/ApplicationWindow.cpp'
307--- .pc/02_fix_paths.diff/qtiplot/src/core/ApplicationWindow.cpp 1970-01-01 00:00:00 +0000
308+++ .pc/02_fix_paths.diff/qtiplot/src/core/ApplicationWindow.cpp 2010-07-22 00:49:43 +0000
309@@ -0,0 +1,18381 @@
310+/***************************************************************************
311+ File : ApplicationWindow.cpp
312+ Project : QtiPlot
313+--------------------------------------------------------------------
314+ Copyright : (C) 2004 - 2010 by Ion Vasilief,
315+ (C) 2006 - June 2007 Tilman Hoener zu Siederdissen, Knut Franke
316+ Email (use @ for *) : ion_vasilief*yahoo.fr
317+ Description : QtiPlot's main window
318+
319+ ***************************************************************************/
320+
321+/***************************************************************************
322+ * *
323+ * This program is free software; you can redistribute it and/or modify *
324+ * it under the terms of the GNU General Public License as published by *
325+ * the Free Software Foundation; either version 2 of the License, or *
326+ * (at your option) any later version. *
327+ * *
328+ * This program is distributed in the hope that it will be useful, *
329+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
330+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
331+ * GNU General Public License for more details. *
332+ * *
333+ * You should have received a copy of the GNU General Public License *
334+ * along with this program; if not, write to the Free Software *
335+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
336+ * Boston, MA 02110-1301 USA *
337+ * *
338+ ***************************************************************************/
339+#include "globals.h"
340+#include "ApplicationWindow.h"
341+#include <QtiPlotApplication.h>
342+
343+#include "PlotWizard.h"
344+#include "ConfigDialog.h"
345+#include "RenameWindowDialog.h"
346+#include "ImportASCIIDialog.h"
347+#include "Folder.h"
348+#include "FindDialog.h"
349+#include "OpenProjectDialog.h"
350+#include "CustomActionDialog.h"
351+#include "MdiSubWindow.h"
352+
353+#include <SymbolBox.h>
354+#include <ColorBox.h>
355+#include <PenStyleBox.h>
356+#include <PatternBox.h>
357+#include <SymbolDialog.h>
358+#include <ExportDialog.h>
359+#include <SetColValuesDialog.h>
360+#include <ExtractDataDialog.h>
361+#include <TableDialog.h>
362+#include <TableStatistics.h>
363+#include <Fit.h>
364+#include <MultiPeakFit.h>
365+#include <PolynomialFit.h>
366+#include <SigmoidalFit.h>
367+#include <LogisticFit.h>
368+#include <NonLinearFit.h>
369+#include <Integration.h>
370+#include <Differentiation.h>
371+#include <SmoothFilter.h>
372+#include <FFTFilter.h>
373+#include <Convolution.h>
374+#include <Correlation.h>
375+#include <ExpDecayDialog.h>
376+#include <PolynomFitDialog.h>
377+#include <FitDialog.h>
378+#include <IntDialog.h>
379+#include <InterpolationDialog.h>
380+#include <SmoothCurveDialog.h>
381+#include <FilterDialog.h>
382+#include <FFTDialog.h>
383+#include <FrequencyCountDialog.h>
384+#include <SubtractDataDialog.h>
385+#include <QwtErrorPlotCurve.h>
386+#include <LegendWidget.h>
387+#include <TexWidget.h>
388+#include <ArrowMarker.h>
389+#include <ImageWidget.h>
390+#include <Grid.h>
391+#include <ScaleDraw.h>
392+#include <ScaleEngine.h>
393+#include <QwtHistogram.h>
394+#include <FunctionCurve.h>
395+#include <QwtPieCurve.h>
396+#include <EllipseWidget.h>
397+#include <RectangleWidget.h>
398+#include <Spectrogram.h>
399+#include <EnrichmentDialog.h>
400+#include <TextEditor.h>
401+#include <CurvesDialog.h>
402+#include <PlotDialog.h>
403+#include <AxesDialog.h>
404+#include <LineDialog.h>
405+#include <ErrDialog.h>
406+#include <FunctionDialog.h>
407+#include <AssociationsDialog.h>
408+#include <ImageExportDialog.h>
409+#include <CurveRangeDialog.h>
410+#include <LayerDialog.h>
411+#include <TextDialog.h>
412+// TODO: move tool-specific code to an extension manager
413+#include <ScreenPickerTool.h>
414+#include <DataPickerTool.h>
415+#include <MultiPeakFitTool.h>
416+#include <LineProfileTool.h>
417+#include <RangeSelectorTool.h>
418+#include <PlotToolInterface.h>
419+#include <SubtractLineTool.h>
420+#include <AddWidgetTool.h>
421+#include <SurfaceDialog.h>
422+#include <Graph3D.h>
423+#include <Plot3DDialog.h>
424+#include <ColorMapDialog.h>
425+#include <MatrixDialog.h>
426+#include <MatrixSizeDialog.h>
427+#include <MatrixValuesDialog.h>
428+#include <MatrixModel.h>
429+#include <MatrixCommand.h>
430+#include <Note.h>
431+#include <ScriptingLangDialog.h>
432+#include <ScriptWindow.h>
433+#include <PythonSyntaxHighlighter.h>
434+#include <CreateBinMatrixDialog.h>
435+#include <QTextDocumentWriter>
436+#include <QToolButton>
437+
438+#include <stdio.h>
439+#include <stdlib.h>
440+#include <math.h>
441+
442+#include <fstream>
443+#include <iostream>
444+#include <string>
445+using namespace std;
446+
447+#include <qwt_scale_engine.h>
448+#include <qwt_scale_widget.h>
449+#include <qwt_plot_magnifier.h>
450+#include <qwt_symbol.h>
451+
452+#include <QFileDialog>
453+#include <QInputDialog>
454+#include <QProgressDialog>
455+#include <QPrintDialog>
456+#include <QPrintPreviewDialog>
457+#include <QPixmapCache>
458+#include <QMenuBar>
459+#include <QClipboard>
460+#include <QTranslator>
461+#include <QSplitter>
462+#include <QSettings>
463+#include <QApplication>
464+#include <QMessageBox>
465+#include <QPrinter>
466+#include <QActionGroup>
467+#include <QAction>
468+#include <QToolBar>
469+#include <QKeySequence>
470+#include <QImageReader>
471+#include <QImageWriter>
472+#include <QDateTime>
473+#include <QShortcut>
474+#include <QDockWidget>
475+#include <QTextStream>
476+#include <QVarLengthArray>
477+#include <QList>
478+#include <QUrl>
479+#include <QAssistantClient>
480+#include <QFontComboBox>
481+#include <QSpinBox>
482+#include <QMdiArea>
483+#include <QMdiSubWindow>
484+#include <QUndoStack>
485+#include <QUndoView>
486+#include <QCompleter>
487+#include <QStringListModel>
488+#include <QNetworkProxy>
489+
490+#include <zlib.h>
491+#include <iostream>
492+
493+#include <gsl/gsl_statistics.h>
494+#include <gsl/gsl_sort.h>
495+
496+#ifdef XLS_IMPORT
497+extern "C" {
498+ #include <libxls/xls.h>
499+}
500+#endif
501+
502+#ifdef ODS_IMPORT
503+ #include <QTemporaryFile>
504+ #include <OdsFileHandler.h>
505+ #include <quazip.h>
506+ #include <quazipfile.h>
507+#endif
508+
509+#ifdef OPJ_IMPORT
510+ #include "importOPJ.h"
511+#endif
512+
513+using namespace Qwt3D;
514+
515+extern "C"
516+{
517+void file_compress(char *file, char *mode);
518+void file_uncompress(char *file);
519+}
520+
521+ApplicationWindow::ApplicationWindow(bool factorySettings)
522+: QMainWindow(), scripted(ScriptingLangManager::newEnv(this))
523+{
524+ setAttribute(Qt::WA_DeleteOnClose);
525+ init(factorySettings);
526+ ((QtiPlotApplication *)QCoreApplication::instance ())->append(this);
527+}
528+
529+void ApplicationWindow::init(bool factorySettings)
530+{
531+ setWindowTitle(tr("QtiPlot - untitled"));
532+ setObjectName(tr("QtiPlot"));
533+ initGlobalConstants();
534+ QPixmapCache::setCacheLimit(20*QPixmapCache::cacheLimit ());
535+
536+ tablesDepend = new QMenu(this);
537+
538+ explorerWindow = new QDockWidget( this );
539+ explorerWindow->setWindowTitle(tr("Project Explorer"));
540+ explorerWindow->setObjectName("explorerWindow"); // this is needed for QMainWindow::restoreState()
541+ explorerWindow->setMinimumHeight(150);
542+ addDockWidget( Qt::BottomDockWidgetArea, explorerWindow );
543+
544+ actionSaveProject = NULL;
545+ folders = new FolderListView(this);
546+ folders->header()->setClickEnabled( false );
547+ folders->addColumn( tr("Folder") );
548+ folders->setRootIsDecorated( true );
549+ folders->setResizeMode(Q3ListView::LastColumn);
550+ folders->header()->hide();
551+ folders->setSelectionMode(Q3ListView::Single);
552+
553+ connect(folders, SIGNAL(currentChanged(Q3ListViewItem *)),
554+ this, SLOT(folderItemChanged(Q3ListViewItem *)));
555+ connect(folders, SIGNAL(itemRenamed(Q3ListViewItem *, int, const QString &)),
556+ this, SLOT(renameFolder(Q3ListViewItem *, int, const QString &)));
557+ connect(folders, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)),
558+ this, SLOT(showFolderPopupMenu(Q3ListViewItem *, const QPoint &, int)));
559+ connect(folders, SIGNAL(dragItems(QList<Q3ListViewItem *>)),
560+ this, SLOT(dragFolderItems(QList<Q3ListViewItem *>)));
561+ connect(folders, SIGNAL(dropItems(Q3ListViewItem *)),
562+ this, SLOT(dropFolderItems(Q3ListViewItem *)));
563+ connect(folders, SIGNAL(renameItem(Q3ListViewItem *)),
564+ this, SLOT(startRenameFolder(Q3ListViewItem *)));
565+ connect(folders, SIGNAL(addFolderItem()), this, SLOT(addFolder()));
566+ connect(folders, SIGNAL(deleteSelection()), this, SLOT(deleteSelectedItems()));
567+
568+ current_folder = new Folder( 0, tr("UNTITLED"));
569+ FolderListItem *fli = new FolderListItem(folders, current_folder);
570+ current_folder->setFolderListItem(fli);
571+ fli->setOpen( true );
572+
573+ lv = new FolderListView();
574+ lv->addColumn (tr("Name"),-1 );
575+ lv->addColumn (tr("Type"),-1 );
576+ lv->addColumn (tr("View"),-1 );
577+ lv->addColumn (tr("Size"),-1 );
578+ lv->addColumn (tr("Created"),-1);
579+ lv->addColumn (tr("Label"),-1);
580+ lv->setResizeMode(Q3ListView::LastColumn);
581+ lv->setMinimumHeight(80);
582+ lv->setSelectionMode(Q3ListView::Extended);
583+ lv->setDefaultRenameAction (Q3ListView::Accept);
584+
585+ explorerSplitter = new QSplitter(Qt::Horizontal, explorerWindow);
586+ explorerSplitter->addWidget(folders);
587+ explorerSplitter->addWidget(lv);
588+ explorerWindow->setWidget(explorerSplitter);
589+
590+ QList<int> splitterSizes;
591+ explorerSplitter->setSizes( splitterSizes << 45 << 45);
592+ explorerWindow->hide();
593+
594+ logWindow = new QDockWidget(this);
595+ logWindow->setObjectName("logWindow"); // this is needed for QMainWindow::restoreState()
596+ logWindow->setWindowTitle(tr("Results Log"));
597+ addDockWidget( Qt::TopDockWidgetArea, logWindow );
598+
599+ results=new QTextEdit(logWindow);
600+ results->setReadOnly (true);
601+
602+ logWindow->setWidget(results);
603+ logWindow->hide();
604+
605+#ifdef SCRIPTING_CONSOLE
606+ consoleWindow = new QDockWidget(this);
607+ consoleWindow->setObjectName("consoleWindow"); // this is needed for QMainWindow::restoreState()
608+ consoleWindow->setWindowTitle(tr("Scripting Console"));
609+ addDockWidget( Qt::TopDockWidgetArea, consoleWindow );
610+ console = new QTextEdit(consoleWindow);
611+ console->setReadOnly(true);
612+ consoleWindow->setWidget(console);
613+ consoleWindow->hide();
614+#endif
615+
616+ undoStackWindow = new QDockWidget(this);
617+ undoStackWindow->setObjectName("undoStackWindow"); // this is needed for QMainWindow::restoreState()
618+ undoStackWindow->setWindowTitle(tr("Undo Stack"));
619+ addDockWidget(Qt::RightDockWidgetArea, undoStackWindow);
620+
621+ d_undo_view = new QUndoView(undoStackWindow);
622+ d_undo_view->setCleanIcon(QIcon(":/filesave.png"));
623+ undoStackWindow->setWidget(d_undo_view);
624+ undoStackWindow->hide();
625+
626+ // Needs to be done after initialization of dock windows,
627+ // because we now use QDockWidget::toggleViewAction()
628+ createActions();
629+ initToolBars();
630+ initMainMenu();
631+
632+ d_workspace = new QMdiArea();
633+ d_workspace->setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
634+ d_workspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
635+ d_workspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
636+ d_workspace->setActivationOrder(QMdiArea::ActivationHistoryOrder);
637+ setCentralWidget(d_workspace);
638+
639+ setAcceptDrops(true);
640+
641+ hiddenWindows = new QList<QWidget*>();
642+
643+ scriptWindow = 0;
644+ d_text_editor = NULL;
645+
646+ renamedTables = QStringList();
647+ if (!factorySettings)
648+ readSettings();
649+ createLanguagesList();
650+ insertTranslatedStrings();
651+ disableToolbars();
652+
653+ assistant = new QAssistantClient( QString(), this );
654+
655+ actionNextWindow = new QAction(QIcon(":/next.png"), tr("&Next","next window"), this);
656+ actionNextWindow->setShortcut( tr("F5","next window shortcut") );
657+ connect(actionNextWindow, SIGNAL(activated()), d_workspace, SLOT(activateNextSubWindow()));
658+
659+ actionPrevWindow = new QAction(QIcon(":/prev.png"), tr("&Previous","previous window"), this);
660+ actionPrevWindow->setShortcut( tr("F6","previous window shortcut") );
661+ connect(actionPrevWindow, SIGNAL(activated()), d_workspace, SLOT(activatePreviousSubWindow()));
662+
663+ connect(tablesDepend, SIGNAL(activated(int)), this, SLOT(showTable(int)));
664+
665+ connect(this, SIGNAL(modified()),this, SLOT(modifiedProject()));
666+ connect(d_workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)),
667+ this, SLOT(windowActivated(QMdiSubWindow*)));
668+ connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
669+ this, SLOT(maximizeWindow(Q3ListViewItem *)));
670+ connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
671+ this, SLOT(folderItemDoubleClicked(Q3ListViewItem *)));
672+ connect(lv, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)),
673+ this, SLOT(showWindowPopupMenu(Q3ListViewItem *, const QPoint &, int)));
674+ connect(lv, SIGNAL(dragItems(QList<Q3ListViewItem *>)),
675+ this, SLOT(dragFolderItems(QList<Q3ListViewItem *>)));
676+ connect(lv, SIGNAL(dropItems(Q3ListViewItem *)),
677+ this, SLOT(dropFolderItems(Q3ListViewItem *)));
678+ connect(lv, SIGNAL(renameItem(Q3ListViewItem *)),
679+ this, SLOT(startRenameFolder(Q3ListViewItem *)));
680+ connect(lv, SIGNAL(addFolderItem()), this, SLOT(addFolder()));
681+ connect(lv, SIGNAL(deleteSelection()), this, SLOT(deleteSelectedItems()));
682+ connect(lv, SIGNAL(itemRenamed(Q3ListViewItem *, int, const QString &)),
683+ this, SLOT(renameWindow(Q3ListViewItem *, int, const QString &)));
684+
685+ connect(scriptEnv, SIGNAL(error(const QString&,const QString&,int)),
686+ this, SLOT(scriptError(const QString&,const QString&,int)));
687+ connect(scriptEnv, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&)));
688+
689+ connect(recent, SIGNAL(activated(int)), this, SLOT(openRecentProject(int)));
690+ connect(explorerWindow, SIGNAL(dockLocationChanged (Qt::DockWidgetArea)), this, SLOT(updateExplorerWindowLayout(Qt::DockWidgetArea)));
691+
692+ // this has to be done after connecting scriptEnv
693+ scriptEnv->initialize();
694+
695+ //apply user settings
696+ updateAppFonts();
697+ setScriptingLanguage(defaultScriptingLang);
698+ setAppColors(workspaceColor, panelsColor, panelsTextColor, true);
699+
700+ loadCustomActions();
701+ initCompleter();
702+}
703+
704+void ApplicationWindow::updateExplorerWindowLayout(Qt::DockWidgetArea area)
705+{
706+ switch(area){
707+ case Qt::LeftDockWidgetArea:
708+ case Qt::RightDockWidgetArea:
709+ explorerSplitter->setOrientation(Qt::Vertical);
710+ break;
711+
712+ case Qt::TopDockWidgetArea:
713+ case Qt::BottomDockWidgetArea:
714+ case Qt::NoDockWidgetArea:
715+ explorerSplitter->setOrientation(Qt::Horizontal);
716+ break;
717+
718+ default:
719+ break;
720+ }
721+}
722+
723+void ApplicationWindow::initWindow()
724+{
725+ switch(d_init_window_type){
726+ case TableWindow:
727+ newTable();
728+ break;
729+ case MatrixWindow:
730+ newMatrix();
731+ break;
732+ case MultiLayerWindow:
733+ newGraph();
734+ break;
735+ case NoteWindow:
736+ newNote();
737+ break;
738+ default:
739+ break;
740+ }
741+ savedProject();
742+}
743+
744+void ApplicationWindow::initGlobalConstants()
745+{
746+ d_indexed_colors = ColorBox::defaultColors();
747+ d_indexed_color_names = ColorBox::defaultColorNames();
748+
749+ d_symbols_list = SymbolBox::defaultSymbols();
750+
751+ d_latex_compiler = MathTran;
752+ d_latex_compiler_path = QString::null;
753+ d_mdi_windows_area = true;
754+ d_open_project_filter = QString::null;//tr("QtiPlot project") + " (*.qti)";
755+
756+ d_comment_highlight_color = Qt::red;
757+ d_class_highlight_color = Qt::darkMagenta;
758+ d_numeric_highlight_color = Qt::darkGreen;
759+ d_keyword_highlight_color = Qt::darkBlue;
760+ d_function_highlight_color = Qt::blue;
761+ d_quotation_highlight_color = Qt::darkYellow;
762+
763+ d_notes_tab_length = 20;
764+ d_completer = NULL;
765+ d_completion = true;
766+ d_note_line_numbers = true;
767+
768+ d_auto_update_table_values = true;
769+ d_active_window = NULL;
770+ d_matrix_undo_stack_size = 10;
771+
772+ d_opening_file = false;
773+ d_is_appending_file = false;
774+ d_in_place_editing = true;
775+
776+ d_matrix_tool_bar = true;
777+ d_file_tool_bar = true;
778+ d_table_tool_bar = true;
779+ d_column_tool_bar = true;
780+ d_edit_tool_bar = true;
781+ d_notes_tool_bar = true;
782+ d_plot_tool_bar = true;
783+ d_plot3D_tool_bar = true;
784+ d_display_tool_bar = false;
785+ d_format_tool_bar = true;
786+
787+ appStyle = qApp->style()->objectName();
788+ d_app_rect = QRect();
789+ projectname = "untitled";
790+ lastCopiedLayer = 0;
791+ d_enrichement_copy = NULL;
792+ d_arrow_copy = NULL;
793+
794+ savingTimerId = 0;
795+
796+ autoSearchUpdatesRequest = false;
797+
798+ show_windows_policy = ActiveFolder;
799+ d_script_win_on_top = false;
800+ d_script_win_rect = QRect(0, 0, 500, 300);
801+ d_init_window_type = TableWindow;
802+
803+ QString aux = qApp->applicationDirPath();
804+ workingDir = aux;
805+
806+#ifdef TRANSLATIONS_PATH
807+ d_translations_folder = TRANSLATIONS_PATH;
808+#else
809+ d_translations_folder = aux + "/translations";
810+#endif
811+
812+#ifdef MANUAL_PATH
813+ helpFilePath = MANUAL_PATH;
814+ helpFilePath += "/index.html";
815+#else
816+ helpFilePath = aux + "/manual/index.html";
817+#endif
818+
819+#ifdef PYTHON_CONFIG_PATH
820+ d_python_config_folder = PYTHON_CONFIG_PATH;
821+#else
822+ d_python_config_folder = aux;
823+#endif
824+
825+ fitPluginsPath = aux + "fitPlugins";
826+ fitModelsPath = QString::null;
827+ templatesDir = aux;
828+ asciiDirPath = aux;
829+ imagesDirPath = aux;
830+ scriptsDirPath = aux;
831+ customActionsDirPath = QString::null;
832+
833+ appFont = QFont();
834+ d_notes_font = appFont;
835+
836+ QString family = appFont.family();
837+ int pointSize = appFont.pointSize();
838+ tableTextFont = appFont;
839+ tableHeaderFont = appFont;
840+ plotAxesFont = QFont(family, pointSize, QFont::Bold, false);
841+ plotNumbersFont = QFont(family, pointSize );
842+ plotLegendFont = appFont;
843+ plotTitleFont = QFont(family, pointSize + 2, QFont::Bold,false);
844+
845+ autoSearchUpdates = false;
846+ appLanguage = QLocale::system().name().section('_',0,0);
847+ show_windows_policy = ApplicationWindow::ActiveFolder;
848+
849+ workspaceColor = QColor("darkGray");
850+ panelsColor = QColor("#ffffff");
851+ panelsTextColor = QColor("#000000");
852+ tableBkgdColor = QColor("#ffffff");
853+ tableTextColor = QColor("#000000");
854+ tableHeaderColor = QColor("#000000");
855+
856+ d_graph_background_color = Qt::white;
857+ d_graph_canvas_color = Qt::white;
858+ d_graph_border_color = Qt::black;
859+ d_graph_background_opacity = 255;
860+ d_graph_canvas_opacity = 255;
861+ d_graph_border_width = 0;
862+ d_graph_tick_labels_dist = 4;
863+ d_graph_axes_labels_dist = 2;
864+
865+ autoSave = true;
866+ autoSaveTime = 15;
867+ d_backup_files = true;
868+
869+ defaultScriptingLang = "muParser";
870+/*#ifdef SCRIPTING_PYTHON
871+ defaultScriptingLang = "Python";
872+#endif*/
873+
874+ d_decimal_digits = 13;
875+ d_muparser_c_locale = true;
876+
877+ d_extended_open_dialog = true;
878+ d_extended_export_dialog = true;
879+ d_extended_import_ASCII_dialog = true;
880+ d_extended_plot_dialog = true;
881+
882+ d_add_curves_dialog_size = QSize(700, 400);
883+ d_show_current_folder = false;
884+
885+ d_confirm_overwrite = true;
886+ confirmCloseFolder = true;
887+ confirmCloseTable = true;
888+ confirmCloseMatrix = true;
889+ confirmClosePlot2D = true;
890+ confirmClosePlot3D = true;
891+ confirmCloseNotes = true;
892+ d_inform_rename_table = true;
893+
894+ d_show_table_comments = false;
895+
896+ titleOn = true;
897+ d_show_axes = QVector<bool> (QwtPlot::axisCnt, true);
898+ d_show_axes_labels = QVector<bool> (QwtPlot::axisCnt, true);
899+ canvasFrameWidth = 0;
900+ d_canvas_frame_color = Qt::black;
901+ defaultPlotMargin = 0;
902+ drawBackbones = true;
903+ axesLineWidth = 1;
904+ autoscale2DPlots = true;
905+ autoScaleFonts = true;
906+ autoResizeLayers = true;
907+ antialiasing2DPlots = false;
908+ d_scale_plots_on_print = false;
909+ d_print_cropmarks = false;
910+ d_graph_legend_display = Graph::ColumnName;
911+ d_graph_axis_labeling = Graph::Default;
912+ d_synchronize_graph_scales = true;
913+ d_print_paper_size = QPrinter::A4;
914+ d_printer_orientation = QPrinter::Landscape;
915+ defaultCurveStyle = int(Graph::LineSymbols);
916+ defaultCurveLineWidth = 1;
917+ d_curve_line_style = 0;//Qt::SolidLine;
918+ defaultCurveBrush = 0;
919+ defaultCurveAlpha = 255;
920+ defaultSymbolSize = 7;
921+ defaultSymbolEdge = 1.0;
922+ d_fill_symbols = true;
923+ d_symbol_style = 0;
924+ d_indexed_symbols = true;
925+ d_keep_aspect_ration = true;
926+
927+ majTicksStyle = int(ScaleDraw::Out);
928+ minTicksStyle = int(ScaleDraw::Out);
929+ minTicksLength = 5;
930+ majTicksLength = 9;
931+
932+ legendFrameStyle = int(LegendWidget::Line);
933+ d_frame_widget_pen = QPen(Qt::black, 1, Qt::SolidLine);
934+ legendTextColor = Qt::black;
935+ legendBackground = Qt::white;
936+ legendBackground.setAlpha(0); // transparent by default;
937+ d_legend_default_angle = 0;
938+ d_frame_geometry_unit = (int)FrameWidget::Scale;
939+ d_layer_geometry_unit = (int)FrameWidget::Pixel;
940+ d_layer_canvas_width = 400;
941+ d_layer_canvas_height = 300;
942+
943+ d_rect_default_background = Qt::white;
944+ d_rect_default_brush = QBrush(Qt::white);
945+
946+ defaultArrowLineWidth = 1;
947+ defaultArrowColor = Qt::black;
948+ defaultArrowHeadLength = 4;
949+ defaultArrowHeadAngle = 45;
950+ defaultArrowHeadFill = true;
951+ defaultArrowLineStyle = Graph::getPenStyle("SolidLine");
952+
953+ d_3D_legend = true;
954+ d_3D_projection = NOFLOOR;
955+ d_3D_smooth_mesh = true;
956+ d_3D_resolution = 1;
957+ d_3D_orthogonal = false;
958+ d_3D_autoscale = true;
959+ d_3D_axes_font = QFont(family, pointSize, QFont::Normal, false);
960+ d_3D_numbers_font = QFont(family, pointSize);
961+ d_3D_title_font = QFont(family, pointSize + 2, QFont::Normal, false);
962+ d_3D_color_map = QwtLinearColorMap(Qt::blue, Qt::red);
963+ d_3D_mesh_color = Qt::black;
964+ d_3D_axes_color = Qt::black;
965+ d_3D_numbers_color = Qt::black;
966+ d_3D_labels_color = Qt::black;
967+ d_3D_background_color = Qt::white;
968+ d_3D_grid_color = Qt::blue;
969+ d_3D_minor_grid_color = Qt::lightGray;
970+ d_3D_minor_grids = true;
971+ d_3D_major_grids = true;
972+ d_3D_major_style = Qwt3D::SOLID;
973+ d_3D_minor_style = Qwt3D::DASH;
974+ d_3D_major_width = 1.0;
975+ d_3D_minor_width = 0.8;
976+
977+ fit_output_precision = 13;
978+ pasteFitResultsToPlot = false;
979+ writeFitResultsToLog = true;
980+ generateUniformFitPoints = true;
981+ fitPoints = 100;
982+ generatePeakCurves = true;
983+ peakCurvesColor = Qt::green;
984+ fit_scale_errors = true;
985+ d_2_linear_fit_points = true;
986+ d_multi_peak_messages = true;
987+
988+ columnSeparator = "\t";
989+ ignoredLines = 0;
990+ renameColumns = true;
991+ strip_spaces = false;
992+ simplify_spaces = false;
993+ d_ASCII_file_filter = "*";
994+ d_ASCII_import_locale = QLocale::system().name();
995+ d_ASCII_import_mode = int(ImportASCIIDialog::NewTables);
996+ d_ASCII_import_first_row_role = 0;//column names
997+ d_ASCII_comment_string = "#";
998+ d_ASCII_import_comments = false;
999+ d_ASCII_import_read_only = false;
1000+ d_ASCII_import_preview = true;
1001+ d_preview_lines = 100;
1002+ d_import_ASCII_dialog_size = QSize();
1003+ d_ASCII_end_line = LF;
1004+ d_eol = LF;
1005+#ifdef Q_OS_MAC
1006+ d_ASCII_end_line = CR;
1007+ d_eol = CR;
1008+#endif
1009+
1010+ d_export_col_separator = "\t";
1011+ d_export_col_names = false;
1012+ d_export_col_comment = false;
1013+ d_export_table_selection = false;
1014+ d_export_ASCII_file_filter = ".dat";
1015+
1016+ d_scale_fonts_factor = 0.0;
1017+ d_image_export_filter = ".png";
1018+ d_export_transparency = false;
1019+ d_export_quality = 100;
1020+ d_export_raster_size = QSizeF();
1021+ d_export_size_unit = FrameWidget::Pixel;
1022+ d_export_vector_resolution = QWidget().logicalDpiX();
1023+ d_export_bitmap_resolution = d_export_vector_resolution;
1024+ d_export_color = true;
1025+ d_export_escape_tex_strings = true;
1026+ d_export_tex_font_sizes = true;
1027+ d_3D_export_text_mode = 0; //VectorWriter::PIXEL
1028+ d_3D_export_sort = 1; //VectorWriter::SIMPLESORT
1029+}
1030+
1031+void ApplicationWindow::initToolBars()
1032+{
1033+ initPlot3DToolBar();
1034+
1035+ setWindowIcon(QIcon(":/logo.png"));
1036+ QPixmap openIcon, saveIcon;
1037+
1038+ fileTools = new QToolBar(tr( "File" ), this);
1039+ fileTools->setObjectName("fileTools"); // this is needed for QMainWindow::restoreState()
1040+ fileTools->setIconSize( QSize(18,20) );
1041+ addToolBar( Qt::TopToolBarArea, fileTools );
1042+
1043+ fileTools->addAction(actionNewProject);
1044+ fileTools->addAction(actionNewFolder);
1045+ fileTools->addAction(actionNewTable);
1046+ fileTools->addAction(actionNewMatrix);
1047+ fileTools->addAction(actionNewNote);
1048+ fileTools->addAction(actionNewGraph);
1049+ fileTools->addAction(actionNewFunctionPlot);
1050+ fileTools->addAction(actionNewSurfacePlot);
1051+ fileTools->addSeparator ();
1052+ fileTools->addAction(actionOpen);
1053+ fileTools->addAction(actionOpenTemplate);
1054+#ifdef XLS_IMPORT
1055+ fileTools->addAction(actionOpenExcel);
1056+#endif
1057+#ifdef ODS_IMPORT
1058+ fileTools->addAction(actionOpenOds);
1059+#endif
1060+ fileTools->addAction(actionAppendProject);
1061+ fileTools->addAction(actionSaveProject);
1062+ fileTools->addAction(actionSaveTemplate);
1063+ fileTools->addSeparator ();
1064+ fileTools->addAction(actionLoad);
1065+ fileTools->addSeparator ();
1066+ fileTools->addAction(actionCopyWindow);
1067+ fileTools->addAction(actionPrint);
1068+ fileTools->addAction(actionPrintPreview);
1069+ fileTools->addAction(actionExportPDF);
1070+ fileTools->addSeparator();
1071+ fileTools->addAction(actionShowExplorer);
1072+ fileTools->addAction(actionShowLog);
1073+#ifdef SCRIPTING_PYTHON
1074+ fileTools->addAction(actionShowScriptWindow);
1075+#endif
1076+
1077+ editTools = new QToolBar(tr("Edit"), this);
1078+ editTools->setObjectName("editTools"); // this is needed for QMainWindow::restoreState()
1079+ editTools->setIconSize( QSize(18,20) );
1080+ addToolBar( editTools );
1081+
1082+ editTools->addAction(actionUndo);
1083+ editTools->addAction(actionRedo);
1084+ editTools->addAction(actionCutSelection);
1085+ editTools->addAction(actionCopySelection);
1086+ editTools->addAction(actionPasteSelection);
1087+ editTools->addAction(actionClearSelection);
1088+
1089+ noteTools = new QToolBar(tr("Notes"), this);
1090+ noteTools->setObjectName("noteTools"); // this is needed for QMainWindow::restoreState()
1091+ noteTools->setIconSize( QSize(18,20) );
1092+#ifdef SCRIPTING_PYTHON
1093+ noteTools->addAction(actionNoteExecuteAll);
1094+ noteTools->addAction(actionNoteExecute);
1095+ noteTools->addAction(actionCommentSelection);
1096+ noteTools->addAction(actionUncommentSelection);
1097+#endif
1098+ noteTools->addAction(actionDecreaseIndent);
1099+ noteTools->addAction(actionIncreaseIndent);
1100+ noteTools->addAction(actionFind);
1101+ noteTools->addAction(actionFindPrev);
1102+ noteTools->addAction(actionFindNext);
1103+ noteTools->addAction(actionReplace);
1104+ addToolBar( noteTools );
1105+
1106+ plotTools = new QToolBar(tr("Plot"), this);
1107+ plotTools->setObjectName("plotTools"); // this is needed for QMainWindow::restoreState()
1108+ plotTools->setIconSize( QSize(16,20) );
1109+ addToolBar( plotTools );
1110+
1111+ plotTools->addAction(actionAddLayer);
1112+ plotTools->addAction(actionAddInsetLayer);
1113+ plotTools->addAction(actionAddInsetCurveLayer);
1114+ plotTools->addSeparator();
1115+ plotTools->addAction(actionShowLayerDialog);
1116+ plotTools->addAction(actionAutomaticLayout);
1117+ plotTools->addSeparator();
1118+ plotTools->addAction(actionExtractLayers);
1119+ plotTools->addAction(actionExtractGraphs);
1120+ plotTools->addSeparator();
1121+ plotTools->addAction(actionAddErrorBars);
1122+ plotTools->addAction(actionShowCurvesDialog);
1123+ plotTools->addAction(actionAddFunctionCurve);
1124+ plotTools->addAction(actionNewLegend);
1125+ plotTools->addSeparator ();
1126+ plotTools->addAction(actionUnzoom);
1127+
1128+ dataTools = new QActionGroup( this );
1129+ dataTools->setExclusive( true );
1130+
1131+ btnPointer = new QAction(tr("Disable &Tools"), this);
1132+ btnPointer->setActionGroup(dataTools);
1133+ btnPointer->setCheckable( true );
1134+ btnPointer->setIcon(QIcon(":/pointer.png"));
1135+ btnPointer->setChecked(true);
1136+ plotTools->addAction(btnPointer);
1137+
1138+ actionMagnify->setActionGroup(dataTools);
1139+ actionMagnify->setCheckable( true );
1140+
1141+ actionMagnifyHor->setActionGroup(dataTools);
1142+ actionMagnifyHor->setCheckable( true );
1143+
1144+ actionMagnifyVert->setActionGroup(dataTools);
1145+ actionMagnifyVert->setCheckable( true );
1146+
1147+ btnZoomIn = new QAction(tr("&Zoom In"), this);
1148+ btnZoomIn->setShortcut( tr("Ctrl++") );
1149+ btnZoomIn->setActionGroup(dataTools);
1150+ btnZoomIn->setCheckable( true );
1151+ btnZoomIn->setIcon(QIcon(":/zoom.png"));
1152+
1153+ btnZoomOut = new QAction(tr("&Zoom Out"), this);
1154+ btnZoomOut->setShortcut( tr("Ctrl+-") );
1155+ btnZoomOut->setActionGroup(dataTools);
1156+ btnZoomOut->setCheckable( true );
1157+ btnZoomOut->setIcon(QIcon(":/zoomOut.png"));
1158+
1159+ QMenu *menu_zoom = new QMenu(this);
1160+ menu_zoom->addAction(actionMagnify);
1161+ menu_zoom->addAction(actionMagnifyHor);
1162+ menu_zoom->addAction(actionMagnifyVert);
1163+ menu_zoom->addAction(btnZoomIn);
1164+ menu_zoom->addAction(btnZoomOut);
1165+
1166+ QToolButton *btn_zoom = new QToolButton(this);
1167+ btn_zoom->setMenu(menu_zoom);
1168+ btn_zoom->setPopupMode(QToolButton::MenuButtonPopup);
1169+ btn_zoom->setDefaultAction(actionMagnify);
1170+ connect(menu_zoom, SIGNAL(triggered(QAction *)), btn_zoom, SLOT(setDefaultAction(QAction *)));
1171+
1172+ plotTools->addWidget(btn_zoom);
1173+
1174+ btnCursor = new QAction(tr("&Data Reader"), this);
1175+ btnCursor->setShortcut( tr("CTRL+D") );
1176+ btnCursor->setActionGroup(dataTools);
1177+ btnCursor->setCheckable( true );
1178+ btnCursor->setIcon(QIcon(":/select.png"));
1179+ plotTools->addAction(btnCursor);
1180+
1181+ btnSelect = new QAction(tr("&Select Data Range"), this);
1182+ btnSelect->setShortcut( tr("ALT+S") );
1183+ btnSelect->setActionGroup(dataTools);
1184+ btnSelect->setCheckable( true );
1185+ btnSelect->setIcon(QIcon(":/cursors.png"));
1186+ plotTools->addAction(btnSelect);
1187+
1188+ btnPicker = new QAction(tr("S&creen Reader"), this);
1189+ btnPicker->setActionGroup(dataTools);
1190+ btnPicker->setCheckable( true );
1191+ btnPicker->setIcon(QIcon(":/cursor_16.png"));
1192+ plotTools->addAction(btnPicker);
1193+
1194+ actionDrawPoints = new QAction(tr("&Draw Data Points"), this);
1195+ actionDrawPoints->setActionGroup(dataTools);
1196+ actionDrawPoints->setCheckable( true );
1197+ actionDrawPoints->setIcon(QIcon(":/draw_points.png"));
1198+ plotTools->addAction(actionDrawPoints);
1199+
1200+ btnMovePoints = new QAction(tr("&Move Data Points..."), this);
1201+ btnMovePoints->setShortcut( tr("Ctrl+ALT+M") );
1202+ btnMovePoints->setActionGroup(dataTools);
1203+ btnMovePoints->setCheckable( true );
1204+ btnMovePoints->setIcon(QIcon(":/hand.png"));
1205+ plotTools->addAction(btnMovePoints);
1206+
1207+ btnRemovePoints = new QAction(tr("Remove &Bad Data Points..."), this);
1208+ btnRemovePoints->setShortcut( tr("Alt+B") );
1209+ btnRemovePoints->setActionGroup(dataTools);
1210+ btnRemovePoints->setCheckable( true );
1211+ btnRemovePoints->setIcon(QIcon(":/delete.png"));
1212+ plotTools->addAction(btnRemovePoints);
1213+
1214+ actionDragCurve = new QAction(tr("Dra&g Curve"), this);
1215+ actionDragCurve->setActionGroup(dataTools);
1216+ actionDragCurve->setCheckable( true );
1217+ actionDragCurve->setIcon(QIcon(":/drag_curve.png"));
1218+ plotTools->addAction(actionDragCurve);
1219+
1220+ connect( dataTools, SIGNAL( triggered( QAction* ) ), this, SLOT( pickDataTool( QAction* ) ) );
1221+ plotTools->addSeparator ();
1222+
1223+ actionAddFormula = new QAction(tr("Add E&quation"), this);
1224+ actionAddFormula->setShortcut( tr("ALT+Q") );
1225+ actionAddFormula->setCheckable(true);
1226+ actionAddFormula->setIcon(QIcon(":/equation.png"));
1227+ connect(actionAddFormula, SIGNAL(triggered()), this, SLOT(addTexFormula()));
1228+ plotTools->addAction(actionAddFormula);
1229+
1230+ actionAddText = new QAction(tr("Add &Text"), this);
1231+ actionAddText->setShortcut( tr("ALT+T") );
1232+ actionAddText->setIcon(QIcon(":/text.png"));
1233+ actionAddText->setCheckable(true);
1234+ connect(actionAddText, SIGNAL(triggered()), this, SLOT(addText()));
1235+ plotTools->addAction(actionAddText);
1236+
1237+ btnArrow = new QAction(tr("Draw &Arrow"), this);
1238+ btnArrow->setShortcut( tr("CTRL+ALT+A") );
1239+ btnArrow->setActionGroup(dataTools);
1240+ btnArrow->setCheckable( true );
1241+ btnArrow->setIcon(QIcon(":/arrow.png"));
1242+ plotTools->addAction(btnArrow);
1243+
1244+ btnLine = new QAction(tr("Draw &Line"), this);
1245+ btnLine->setShortcut( tr("CTRL+ALT+L") );
1246+ btnLine->setActionGroup(dataTools);
1247+ btnLine->setCheckable( true );
1248+ btnLine->setIcon(QIcon(":/lPlot.png"));
1249+ plotTools->addAction(btnLine);
1250+
1251+ QPixmap pix = QPixmap(16, 16);
1252+ pix.fill(Qt::transparent);
1253+ QPainter p;
1254+ p.begin(&pix);
1255+ p.setBrush(Qt::lightGray);
1256+ p.drawRect(QRect(1, 2, 12, 10));
1257+
1258+ actionAddRectangle = new QAction(tr("Add &Rectangle"), this);
1259+ actionAddRectangle->setShortcut( tr("CTRL+ALT+R") );
1260+ actionAddRectangle->setCheckable(true);
1261+ actionAddRectangle->setIcon(QIcon(pix));
1262+ connect(actionAddRectangle, SIGNAL(triggered()), this, SLOT(addRectangle()));
1263+ plotTools->addAction(actionAddRectangle);
1264+
1265+ pix.fill(Qt::transparent);
1266+ p.drawEllipse(QRect(0, 2, 15, 12));
1267+ p.end();
1268+
1269+ actionAddEllipse = new QAction(tr("Add &Ellipse"), this);
1270+ actionAddEllipse->setShortcut( tr("CTRL+ALT+E") );
1271+ actionAddEllipse->setCheckable(true);
1272+ actionAddEllipse->setIcon(QIcon(pix));
1273+ connect(actionAddEllipse, SIGNAL(triggered()), this, SLOT(addEllipse()));
1274+ plotTools->addAction(actionAddEllipse);
1275+
1276+ plotTools->addAction(actionTimeStamp);
1277+ plotTools->addAction(actionAddImage);
1278+ plotTools->hide();
1279+
1280+ tableTools = new QToolBar(tr("Table"), this);
1281+ tableTools->setObjectName("tableTools"); // this is needed for QMainWindow::restoreState()
1282+ tableTools->setIconSize( QSize(16, 20));
1283+ addToolBar(Qt::TopToolBarArea, tableTools);
1284+
1285+ QMenu *menuPlotLine = new QMenu(this);
1286+ menuPlotLine->addAction(actionPlotL);
1287+ menuPlotLine->addAction(actionPlotHorSteps);
1288+ menuPlotLine->addAction(actionPlotVertSteps);
1289+
1290+ QToolButton *btnPlotLine = new QToolButton(this);
1291+ btnPlotLine->setMenu(menuPlotLine);
1292+ btnPlotLine->setPopupMode(QToolButton::MenuButtonPopup);
1293+ btnPlotLine->setDefaultAction(actionPlotL);
1294+ connect(menuPlotLine, SIGNAL(triggered(QAction *)), btnPlotLine, SLOT(setDefaultAction(QAction *)));
1295+ tableTools->addWidget(btnPlotLine);
1296+
1297+ QMenu *menuPlotScatter = new QMenu(this);
1298+ menuPlotScatter->addAction(actionPlotP);
1299+ menuPlotScatter->addAction(actionPlotVerticalDropLines);
1300+
1301+ QToolButton *btnPlotScatter = new QToolButton(this);
1302+ btnPlotScatter->setMenu(menuPlotScatter);
1303+ btnPlotScatter->setPopupMode(QToolButton::MenuButtonPopup);
1304+ btnPlotScatter->setDefaultAction(actionPlotP);
1305+ connect(menuPlotScatter, SIGNAL(triggered(QAction *)), btnPlotScatter, SLOT(setDefaultAction(QAction *)));
1306+ tableTools->addWidget(btnPlotScatter);
1307+
1308+ QMenu *menuPlotLineSymbol = new QMenu(this);
1309+ menuPlotLineSymbol->addAction(actionPlotLP);
1310+ menuPlotLineSymbol->addAction(actionPlotSpline);
1311+
1312+ QToolButton *btnPlotLineSymbol = new QToolButton(this);
1313+ btnPlotLineSymbol->setMenu(menuPlotLineSymbol);
1314+ btnPlotLineSymbol->setPopupMode(QToolButton::MenuButtonPopup);
1315+ btnPlotLineSymbol->setDefaultAction(actionPlotLP);
1316+ connect(menuPlotLineSymbol, SIGNAL(triggered(QAction *)), btnPlotLineSymbol, SLOT(setDefaultAction(QAction *)));
1317+ tableTools->addWidget(btnPlotLineSymbol);
1318+
1319+ QMenu *menuPlotBars = new QMenu(this);
1320+ menuPlotBars->addAction(actionPlotVerticalBars);
1321+ menuPlotBars->addAction(actionPlotHorizontalBars);
1322+ menuPlotBars->addAction(actionStackColumns);
1323+ menuPlotBars->addAction(actionStackBars);
1324+
1325+ QToolButton *btnPlotBars = new QToolButton(this);
1326+ btnPlotBars->setMenu(menuPlotBars);
1327+ btnPlotBars->setPopupMode(QToolButton::MenuButtonPopup);
1328+ btnPlotBars->setDefaultAction(actionPlotVerticalBars);
1329+ connect(menuPlotBars, SIGNAL(triggered(QAction *)), btnPlotBars, SLOT(setDefaultAction(QAction *)));
1330+ tableTools->addWidget(btnPlotBars);
1331+
1332+ tableTools->addAction(actionPlotArea);
1333+ tableTools->addAction(actionPlotPie);
1334+
1335+ QMenu *menuStatisticPlots = new QMenu(this);
1336+ menuStatisticPlots->addAction(actionBoxPlot);
1337+ menuStatisticPlots->addAction(actionPlotHistogram);
1338+ menuStatisticPlots->addAction(actionPlotStackedHistograms);
1339+ menuStatisticPlots->addAction(actionStemPlot);
1340+
1341+ QToolButton *btnStatisticPlots = new QToolButton(this);
1342+ btnStatisticPlots->setMenu(menuStatisticPlots);
1343+ btnStatisticPlots->setPopupMode(QToolButton::MenuButtonPopup);
1344+ btnStatisticPlots->setDefaultAction(actionBoxPlot);
1345+ connect(menuStatisticPlots, SIGNAL(triggered(QAction *)), btnStatisticPlots, SLOT(setDefaultAction(QAction *)));
1346+ tableTools->addWidget(btnStatisticPlots);
1347+
1348+ QMenu *menuVectorPlots = new QMenu(this);
1349+ menuVectorPlots->addAction(actionPlotVectXYXY);
1350+ menuVectorPlots->addAction(actionPlotVectXYAM);
1351+
1352+ QToolButton *btnVectorPlots = new QToolButton(this);
1353+ btnVectorPlots->setMenu(menuVectorPlots);
1354+ btnVectorPlots->setPopupMode(QToolButton::MenuButtonPopup);
1355+ btnVectorPlots->setDefaultAction(actionPlotVectXYXY);
1356+ connect(menuVectorPlots, SIGNAL(triggered(QAction *)), btnVectorPlots, SLOT(setDefaultAction(QAction *)));
1357+ tableTools->addWidget(btnVectorPlots);
1358+
1359+ QMenu *menuPlotSpecial = new QMenu(this);
1360+ menuPlotSpecial->addAction(actionPlotDoubleYAxis);
1361+ menuPlotSpecial->addAction(actionWaterfallPlot);
1362+ menuPlotSpecial->addAction(actionAddZoomPlot);
1363+ menuPlotSpecial->addAction(actionPlot2VerticalLayers);
1364+ menuPlotSpecial->addAction(actionPlot2HorizontalLayers);
1365+ menuPlotSpecial->addAction(actionPlot4Layers);
1366+ menuPlotSpecial->addAction(actionPlotStackedLayers);
1367+ menuPlotSpecial->addAction(actionCustomSharedAxisLayers);
1368+
1369+ QToolButton *btnPlotSpecial = new QToolButton(this);
1370+ btnPlotSpecial->setMenu(menuPlotSpecial);
1371+ btnPlotSpecial->setPopupMode(QToolButton::MenuButtonPopup);
1372+ btnPlotSpecial->setDefaultAction(actionPlotDoubleYAxis);
1373+ connect(menuPlotSpecial, SIGNAL(triggered(QAction *)), btnPlotSpecial, SLOT(setDefaultAction(QAction *)));
1374+ tableTools->addWidget(btnPlotSpecial);
1375+
1376+ tableTools->addSeparator ();
1377+
1378+ QMenu *menu3DPlots = new QMenu(this);
1379+ menu3DPlots->addAction(actionPlot3DBars);
1380+ menu3DPlots->addAction(actionPlot3DRibbon);
1381+ menu3DPlots->addAction(actionPlot3DScatter);
1382+ menu3DPlots->addAction(actionPlot3DTrajectory);
1383+
1384+ QToolButton *btn3DPlots = new QToolButton(this);
1385+ btn3DPlots->setMenu(menu3DPlots);
1386+ btn3DPlots->setPopupMode(QToolButton::MenuButtonPopup);
1387+ btn3DPlots->setDefaultAction(actionPlot3DBars);
1388+ connect(menu3DPlots, SIGNAL(triggered(QAction *)), btn3DPlots, SLOT(setDefaultAction(QAction *)));
1389+ tableTools->addWidget(btn3DPlots);
1390+
1391+ tableTools->setEnabled(false);
1392+ tableTools->hide();
1393+
1394+ columnTools = new QToolBar(tr( "Column"), this);
1395+ columnTools->setObjectName("columnTools"); // this is needed for QMainWindow::restoreState()
1396+ columnTools->setIconSize(QSize(16, 20));
1397+ addToolBar(Qt::TopToolBarArea, columnTools);
1398+
1399+ columnTools->addAction(actionShowColumnValuesDialog);
1400+ columnTools->addAction(actionSetAscValues);
1401+ columnTools->addAction(actionSetRandomValues);
1402+ columnTools->addSeparator();
1403+ columnTools->addAction(actionSortTable);
1404+ columnTools->addAction(actionShowColStatistics);
1405+ columnTools->addAction(actionShowRowStatistics);
1406+ columnTools->addSeparator();
1407+ columnTools->addAction(actionSetXCol);
1408+ columnTools->addAction(actionSetYCol);
1409+ columnTools->addAction(actionSetZCol);
1410+ columnTools->addAction(actionSetYErrCol);
1411+ columnTools->addAction(actionSetLabelCol);
1412+ columnTools->addAction(actionDisregardCol);
1413+ columnTools->addSeparator();
1414+ columnTools->addAction(actionMoveColFirst);
1415+ columnTools->addAction(actionMoveColLeft);
1416+ columnTools->addAction(actionMoveColRight);
1417+ columnTools->addAction(actionMoveColLast);
1418+ columnTools->addAction(actionSwapColumns);
1419+ columnTools->addSeparator();
1420+ columnTools->addAction(actionAdjustColumnWidth);
1421+ columnTools->addAction(actionMoveRowUp);
1422+ columnTools->addAction(actionMoveRowDown);
1423+ columnTools->addSeparator();
1424+ columnTools->addAction(actionAddColToTable);
1425+ columnTools->setEnabled(false);
1426+ columnTools->hide();
1427+
1428+ displayBar = new QToolBar( tr( "Data Display" ), this );
1429+ displayBar->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
1430+ displayBar->setObjectName("displayBar"); // this is needed for QMainWindow::restoreState()
1431+ info = new QLineEdit( this );
1432+ displayBar->addWidget( info );
1433+ info->setReadOnly(true);
1434+ QPalette palette;
1435+ palette.setColor(QPalette::Text, QColor(Qt::green));
1436+ palette.setColor(QPalette::HighlightedText, QColor(Qt::darkGreen));
1437+ palette.setColor(QPalette::Base, QColor(Qt::black));
1438+ info->setPalette(palette);
1439+
1440+ addToolBar( Qt::TopToolBarArea, displayBar );
1441+ displayBar->hide();
1442+
1443+ insertToolBarBreak (displayBar);
1444+
1445+ plotMatrixBar = new QToolBar( tr( "Matrix Plot" ), this);
1446+ plotMatrixBar->setObjectName("plotMatrixBar");
1447+ addToolBar(Qt::BottomToolBarArea, plotMatrixBar);
1448+
1449+ QMenu *menu3DMatrix = new QMenu(this);
1450+ menu3DMatrix->addAction(actionPlot3DWireFrame);
1451+ menu3DMatrix->addAction(actionPlot3DHiddenLine);
1452+ menu3DMatrix->addAction(actionPlot3DWireSurface);
1453+ menu3DMatrix->addAction(actionPlot3DPolygons);
1454+
1455+ QToolButton *btn3DMatrix = new QToolButton(this);
1456+ btn3DMatrix->setMenu(menu3DMatrix);
1457+ btn3DMatrix->setPopupMode(QToolButton::MenuButtonPopup);
1458+ btn3DMatrix->setDefaultAction(actionPlot3DWireSurface);
1459+ connect(menu3DMatrix, SIGNAL(triggered(QAction *)), btn3DMatrix, SLOT(setDefaultAction(QAction *)));
1460+ plotMatrixBar->addWidget(btn3DMatrix);
1461+
1462+ actionPlot3DBars->addTo(plotMatrixBar);
1463+ actionPlot3DScatter->addTo(plotMatrixBar);
1464+
1465+ plotMatrixBar->addSeparator();
1466+
1467+ QMenu *menuContourPlot = new QMenu(this);
1468+ menuContourPlot->addAction(actionColorMap);
1469+ menuContourPlot->addAction(actionContourMap);
1470+ menuContourPlot->addAction(actionGrayMap);
1471+
1472+ QToolButton *btnContourPlot = new QToolButton(this);
1473+ btnContourPlot->setMenu(menuContourPlot);
1474+ btnContourPlot->setPopupMode(QToolButton::MenuButtonPopup);
1475+ btnContourPlot->setDefaultAction(actionColorMap);
1476+ connect(menuContourPlot, SIGNAL(triggered(QAction *)), btnContourPlot, SLOT(setDefaultAction(QAction *)));
1477+ plotMatrixBar->addWidget(btnContourPlot);
1478+
1479+ actionImagePlot->addTo(plotMatrixBar);
1480+ actionImageProfilesPlot->addTo(plotMatrixBar);
1481+ actionPlotHistogram->addTo(plotMatrixBar);
1482+ plotMatrixBar->addSeparator();
1483+ actionSetMatrixValues->addTo(plotMatrixBar);
1484+ actionFlipMatrixHorizontally->addTo(plotMatrixBar);
1485+ actionFlipMatrixVertically->addTo(plotMatrixBar);
1486+ actionRotateMatrix->addTo(plotMatrixBar);
1487+ actionRotateMatrixMinus->addTo(plotMatrixBar);
1488+ plotMatrixBar->addSeparator();
1489+ plotMatrixBar->addAction(actionIncreasePrecision);
1490+ plotMatrixBar->addAction(actionDecreasePrecision);
1491+ plotMatrixBar->hide();
1492+
1493+ formatToolBar = new QToolBar(tr( "Format" ), this);
1494+ formatToolBar->setObjectName("formatToolBar");
1495+ addToolBar(Qt::TopToolBarArea, formatToolBar);
1496+
1497+ QFontComboBox *fb = new QFontComboBox();
1498+ connect(fb, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(setFontFamily(const QFont &)));
1499+ actionFontBox = formatToolBar->addWidget(fb);
1500+
1501+ QSpinBox *sb = new QSpinBox();
1502+ connect(sb, SIGNAL(valueChanged(int)), this, SLOT(setFontSize(int)));
1503+ actionFontSize = formatToolBar->addWidget(sb);
1504+
1505+ actionFontBold->addTo(formatToolBar);
1506+ actionFontItalic->addTo(formatToolBar);
1507+
1508+ actionUnderline->addTo(formatToolBar);
1509+ actionSuperscript->addTo(formatToolBar);
1510+ actionSubscript->addTo(formatToolBar);
1511+ actionGreekSymbol->addTo(formatToolBar);
1512+ actionGreekMajSymbol->addTo(formatToolBar);
1513+ actionMathSymbol->addTo(formatToolBar);
1514+
1515+ formatToolBar->setEnabled(false);
1516+ formatToolBar->hide();
1517+
1518+ QList<QToolBar *> toolBars = toolBarsList();
1519+ foreach (QToolBar *t, toolBars)
1520+ connect(t, SIGNAL(actionTriggered(QAction *)), this, SLOT(performCustomAction(QAction *)));
1521+}
1522+
1523+void ApplicationWindow::insertTranslatedStrings()
1524+{
1525+ if (projectname == "untitled")
1526+ setWindowTitle(tr("QtiPlot - untitled"));
1527+
1528+ lv->setColumnText (0, tr("Name"));
1529+ lv->setColumnText (1, tr("Type"));
1530+ lv->setColumnText (2, tr("View"));
1531+ lv->setColumnText (3, tr("Size"));
1532+ lv->setColumnText (4, tr("Created"));
1533+ lv->setColumnText (5, tr("Label"));
1534+
1535+ if (scriptWindow)
1536+ scriptWindow->setWindowTitle(tr("QtiPlot - Script Window"));
1537+ explorerWindow->setWindowTitle(tr("Project Explorer"));
1538+ logWindow->setWindowTitle(tr("Results Log"));
1539+ undoStackWindow->setWindowTitle(tr("Undo Stack"));
1540+#ifdef SCRIPTING_CONSOLE
1541+ consoleWindow->setWindowTitle(tr("Scripting Console"));
1542+#endif
1543+ displayBar->setWindowTitle(tr("Data Display"));
1544+ tableTools->setWindowTitle(tr("Table"));
1545+ columnTools->setWindowTitle(tr("Column"));
1546+ plotTools->setWindowTitle(tr("Plot"));
1547+ fileTools->setWindowTitle(tr("File"));
1548+ editTools->setWindowTitle(tr("Edit"));
1549+ noteTools->setWindowTitle(tr("Notes"));
1550+ plotMatrixBar->setWindowTitle(tr("Matrix Plot"));
1551+ plot3DTools->setWindowTitle(tr("3D Surface"));
1552+ formatToolBar->setWindowTitle(tr("Format"));
1553+
1554+ fileMenu->changeItem(recentMenuID, tr("&Recent Projects"));
1555+ fileMenu->setTitle(tr("&File"));
1556+ newMenu->setTitle(tr("&New"));
1557+ exportPlotMenu->setTitle(tr("&Export Graph"));
1558+ importMenu->setTitle(tr("&Import"));
1559+ edit->setTitle(tr("&Edit"));
1560+ view->setTitle(tr("&View"));
1561+ graphMenu->setTitle(tr("&Graph"));
1562+ plot3DMenu->setTitle(tr("3D &Plot"));
1563+ matrixMenu->setTitle(tr("&Matrix"));
1564+ plot2DMenu->setTitle(tr("&Plot"));
1565+ plotDataMenu->setTitle(tr("&Data"));
1566+ normMenu->setTitle(tr("&Normalize"));
1567+ fillMenu->setTitle(tr("&Fill Columns With"));
1568+ tableMenu->setTitle(tr("&Table"));
1569+ smoothMenu->setTitle(tr("&Smooth"));
1570+ filterMenu->setTitle(tr("&FFT filter"));
1571+ decayMenu->setTitle(tr("Fit E&xponential Decay"));
1572+ multiPeakMenu->setTitle(tr("Fit &Multi-peak"));
1573+ analysisMenu->setTitle(tr("&Analysis"));
1574+ format->setTitle(tr("F&ormat"));
1575+ scriptingMenu->setTitle(tr("&Scripting"));
1576+ windowsMenu->setTitle(tr("&Windows"));
1577+ help->setTitle(tr("&Help"));
1578+
1579+ translateActionsStrings();
1580+ customMenu(activeWindow());
1581+}
1582+
1583+void ApplicationWindow::initMainMenu()
1584+{
1585+ menuBar()->setObjectName("menuBar");
1586+
1587+ fileMenu = new QMenu(this);
1588+ fileMenu->setObjectName("fileMenu");
1589+ connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(fileMenuAboutToShow()));
1590+ menuBar()->addMenu(fileMenu);
1591+
1592+ recent = new QMenu(this);
1593+ newMenu = new QMenu(this);
1594+ newMenu->setObjectName("newMenu");
1595+ exportPlotMenu = new QMenu(this);
1596+ exportPlotMenu->setObjectName("exportPlotMenu");
1597+ importMenu = new QMenu(this);
1598+ importMenu->setObjectName("importMenu");
1599+
1600+ edit = new QMenu(this);
1601+ edit->setObjectName("editMenu");
1602+ menuBar()->addMenu(edit);
1603+
1604+ edit->addAction(actionUndo);
1605+ edit->addAction(actionRedo);
1606+ edit->insertSeparator();
1607+ edit->addAction(actionCopySelection);
1608+ edit->addAction(actionPasteSelection);
1609+ edit->addAction(actionClearSelection);
1610+ edit->insertSeparator();
1611+ edit->addAction(actionDeleteFitTables);
1612+ edit->addAction(actionClearLogInfo);
1613+ edit->insertSeparator();
1614+ edit->addAction(actionShowConfigureDialog);
1615+
1616+ connect(edit, SIGNAL(aboutToShow()), this, SLOT(editMenuAboutToShow()));
1617+
1618+ view = new QMenu(this);
1619+ view->setObjectName("viewMenu");
1620+ menuBar()->addMenu(view);
1621+
1622+ view->setCheckable(true);
1623+ view->addAction(actionToolBars);
1624+ view->addAction(actionShowPlotWizard);
1625+ view->addAction(actionShowExplorer);
1626+ view->addAction(actionShowLog);
1627+ view->addAction(actionShowUndoStack);
1628+#ifdef SCRIPTING_CONSOLE
1629+ view->addAction(actionShowConsole);
1630+#endif
1631+
1632+ scriptingMenu = new QMenu(this);
1633+ scriptingMenu->setObjectName("scriptingMenu");
1634+ connect(scriptingMenu, SIGNAL(aboutToShow()), this, SLOT(scriptingMenuAboutToShow()));
1635+ menuBar()->addMenu(scriptingMenu);
1636+
1637+ graphMenu = new QMenu(this);
1638+ graphMenu->setObjectName("graphMenu");
1639+ graphMenu->setCheckable(true);
1640+ menuBar()->addMenu(graphMenu);
1641+
1642+ graphMenu->addAction(actionShowCurvesDialog);
1643+ graphMenu->addAction(actionAddFunctionCurve);
1644+ graphMenu->addAction(actionAddErrorBars);
1645+ graphMenu->addAction(actionNewLegend);
1646+ graphMenu->addSeparator();
1647+ graphMenu->addAction(actionAddFormula);
1648+ graphMenu->addAction(actionAddText);
1649+ graphMenu->addAction(btnArrow);
1650+ graphMenu->addAction(btnLine);
1651+ graphMenu->addAction(actionAddRectangle);
1652+ graphMenu->addAction(actionAddEllipse);
1653+ graphMenu->addAction(actionTimeStamp);
1654+ graphMenu->addAction(actionAddImage);
1655+ graphMenu->addSeparator();//layers section
1656+ graphMenu->addAction(actionAddLayer);
1657+ graphMenu->addAction(actionAddInsetLayer);
1658+ graphMenu->addAction(actionAddInsetCurveLayer);
1659+ graphMenu->addAction(actionShowLayerDialog);
1660+ graphMenu->addAction(actionAutomaticLayout);
1661+ graphMenu->addSeparator();
1662+ graphMenu->addAction(actionExtractLayers);
1663+ graphMenu->addAction(actionExtractGraphs);
1664+ graphMenu->addSeparator();
1665+ graphMenu->addAction(actionDeleteLayer);
1666+
1667+ plot3DMenu = new QMenu(this);
1668+ plot3DMenu->setObjectName("plot3DMenu");
1669+ plot3DMenu->addAction(actionPlot3DWireFrame);
1670+ plot3DMenu->addAction(actionPlot3DHiddenLine);
1671+ plot3DMenu->addAction(actionPlot3DPolygons);
1672+ plot3DMenu->addAction(actionPlot3DWireSurface);
1673+ plot3DMenu->insertSeparator();
1674+ plot3DMenu->addAction(actionPlot3DBars);
1675+ plot3DMenu->addAction(actionPlot3DScatter);
1676+ plot3DMenu->insertSeparator();
1677+ plot3DMenu->addAction(actionColorMap);
1678+ plot3DMenu->addAction(actionContourMap);
1679+ plot3DMenu->addAction(actionGrayMap);
1680+ plot3DMenu->insertSeparator();
1681+ plot3DMenu->addAction(actionImagePlot);
1682+ plot3DMenu->addAction(actionImageProfilesPlot);
1683+ plot3DMenu->insertSeparator();
1684+ plot3DMenu->addAction(actionPlotHistogram);
1685+ menuBar()->addMenu(plot3DMenu);
1686+
1687+ matrixMenu = new QMenu(this);
1688+ matrixMenu->setObjectName("matrixMenu");
1689+ connect(matrixMenu, SIGNAL(aboutToShow()), this, SLOT(matrixMenuAboutToShow()));
1690+ menuBar()->addMenu(matrixMenu);
1691+
1692+ plot2DMenu = new QMenu(this);
1693+ plot2DMenu->setObjectName("plot2DMenu");
1694+ connect(plot2DMenu, SIGNAL(aboutToShow()), this, SLOT(plotMenuAboutToShow()));
1695+ menuBar()->addMenu(plot2DMenu);
1696+
1697+ plotDataMenu = new QMenu(this);
1698+ plotDataMenu->setObjectName("plotDataMenu");
1699+ plotDataMenu->setCheckable(true);
1700+ connect(plotDataMenu, SIGNAL(aboutToShow()), this, SLOT(plotDataMenuAboutToShow()));
1701+ menuBar()->addMenu(plotDataMenu);
1702+
1703+ normMenu = new QMenu(this);
1704+ normMenu->setObjectName("normMenu");
1705+
1706+ fillMenu = new QMenu();
1707+ fillMenu->setObjectName("fillMenu");
1708+
1709+ analysisMenu = new QMenu(this);
1710+ analysisMenu->setObjectName("analysisMenu");
1711+ connect(analysisMenu, SIGNAL(aboutToShow()), this, SLOT(analysisMenuAboutToShow()));
1712+ menuBar()->addMenu(analysisMenu);
1713+
1714+ tableMenu = new QMenu(this);
1715+ tableMenu->setObjectName("tableMenu");
1716+ connect(tableMenu, SIGNAL(aboutToShow()), this, SLOT(tableMenuAboutToShow()));
1717+ menuBar()->addMenu(tableMenu);
1718+
1719+ smoothMenu = new QMenu(this);
1720+ smoothMenu->setObjectName("smoothMenu");
1721+
1722+ filterMenu = new QMenu(this);
1723+ filterMenu->setObjectName("filterMenu");
1724+
1725+ decayMenu = new QMenu(this);
1726+ decayMenu->setObjectName("decayMenu");
1727+
1728+ multiPeakMenu = new QMenu(this);
1729+ multiPeakMenu->setObjectName("multiPeakMenu");
1730+
1731+ format = new QMenu(this);
1732+ format->setObjectName("formatMenu");
1733+ menuBar()->addMenu(format);
1734+
1735+ windowsMenu = new QMenu(this);
1736+ windowsMenu->setObjectName("windowsMenu");
1737+ windowsMenu->setCheckable(true);
1738+ connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
1739+ menuBar()->addMenu(windowsMenu);
1740+
1741+ foldersMenu = new QMenu(this);
1742+ foldersMenu->setCheckable(true);
1743+
1744+ help = new QMenu(this);
1745+ help->setObjectName("helpMenu");
1746+ menuBar()->addMenu(help);
1747+
1748+ help->addAction(actionShowHelp);
1749+ help->addAction(actionChooseHelpFolder);
1750+ help->insertSeparator();
1751+ help->addAction(actionHomePage);
1752+ help->addAction(actionCheckUpdates);
1753+ help->addAction(actionDownloadManual);
1754+ help->addAction(actionTranslations);
1755+ help->insertSeparator();
1756+ help->addAction(actionTechnicalSupport);
1757+ help->addAction(actionDonate);
1758+ help->addAction(actionHelpForums);
1759+ help->addAction(actionHelpBugReports);
1760+ help->insertSeparator();
1761+ help->addAction(actionAbout);
1762+
1763+ QList<QMenu *> menus;
1764+ menus << windowsMenu << view << graphMenu << fileMenu << format << edit;
1765+ menus << help << plot2DMenu << analysisMenu;
1766+ menus << matrixMenu << plot3DMenu << plotDataMenu << scriptingMenu;
1767+ menus << tableMenu << newMenu << exportPlotMenu << importMenu;
1768+
1769+ foreach (QMenu *m, menus)
1770+ connect(m, SIGNAL(triggered(QAction *)), this, SLOT(performCustomAction(QAction *)));
1771+
1772+ disableActions();
1773+}
1774+
1775+void ApplicationWindow::tableMenuAboutToShow()
1776+{
1777+ tableMenu->clear();
1778+ fillMenu->clear();
1779+
1780+ QMenu *setAsMenu = tableMenu->addMenu(tr("Set Columns &As"));
1781+ setAsMenu->addAction(actionSetXCol);
1782+ setAsMenu->addAction(actionSetYCol);
1783+ setAsMenu->addAction(actionSetZCol);
1784+ setAsMenu->insertSeparator();
1785+ setAsMenu->addAction(actionSetLabelCol);
1786+ setAsMenu->addAction(actionDisregardCol);
1787+ setAsMenu->insertSeparator();
1788+ setAsMenu->addAction(actionSetXErrCol);
1789+ setAsMenu->addAction(actionSetYErrCol);
1790+ setAsMenu->insertSeparator();
1791+ setAsMenu->addAction(tr("&Read-only"), this, SLOT(setReadOnlyColumns()));
1792+ setAsMenu->addAction(tr("Read/&Write"), this, SLOT(setReadWriteColumns()));
1793+
1794+ tableMenu->addAction(actionShowColumnOptionsDialog);
1795+ tableMenu->insertSeparator();
1796+
1797+ tableMenu->addAction(actionShowColumnValuesDialog);
1798+ tableMenu->addAction(actionTableRecalculate);
1799+
1800+ fillMenu->addAction(actionSetAscValues);
1801+ fillMenu->addAction(actionSetRandomValues);
1802+ tableMenu->addMenu (fillMenu);
1803+
1804+ tableMenu->addAction(actionClearTable);
1805+ tableMenu->insertSeparator();
1806+ tableMenu->addAction(actionAddColToTable);
1807+ tableMenu->addAction(actionShowColsDialog);
1808+ tableMenu->insertSeparator();
1809+ tableMenu->addAction(actionHideSelectedColumns);
1810+ tableMenu->addAction(actionShowAllColumns);
1811+ tableMenu->addAction(actionAdjustColumnWidth);
1812+ tableMenu->insertSeparator();
1813+ tableMenu->addAction(actionMoveColFirst);
1814+ tableMenu->addAction(actionMoveColLeft);
1815+ tableMenu->addAction(actionMoveColRight);
1816+ tableMenu->addAction(actionMoveColLast);
1817+ tableMenu->addAction(actionSwapColumns);
1818+ tableMenu->insertSeparator();
1819+ tableMenu->addAction(actionShowRowsDialog);
1820+ tableMenu->addAction(actionDeleteRows);
1821+
1822+ QMenu *moveRowMenu = tableMenu->addMenu(tr("Move Row"));
1823+ moveRowMenu->addAction(actionMoveRowUp);
1824+ moveRowMenu->addAction(actionMoveRowDown);
1825+
1826+ tableMenu->insertSeparator();
1827+ tableMenu->addAction(actionGoToRow);
1828+ tableMenu->addAction(actionGoToColumn);
1829+ tableMenu->addAction(actionExtractTableData);
1830+ tableMenu->insertSeparator();
1831+
1832+ QMenu *convertToMatrixMenu = tableMenu->addMenu(tr("Convert to &Matrix"));
1833+ convertToMatrixMenu->addAction(actionConvertTableDirect);
1834+ convertToMatrixMenu->addAction(actionConvertTableBinning);
1835+ convertToMatrixMenu->addAction(actionConvertTableRegularXYZ);
1836+
1837+ reloadCustomActions();
1838+}
1839+
1840+void ApplicationWindow::plotDataMenuAboutToShow()
1841+{
1842+ plotDataMenu->clear();
1843+ plotDataMenu->addAction(btnPointer);
1844+ plotDataMenu->insertSeparator();
1845+ plotDataMenu->addAction(actionMagnify);
1846+ plotDataMenu->addAction(actionMagnifyHor);
1847+ plotDataMenu->addAction(actionMagnifyVert);
1848+ plotDataMenu->addAction(btnZoomIn);
1849+ plotDataMenu->addAction(btnZoomOut);
1850+ plotDataMenu->addAction(actionUnzoom);
1851+ plotDataMenu->insertSeparator();
1852+ plotDataMenu->addAction(btnCursor);
1853+ plotDataMenu->addAction(btnSelect);
1854+ plotDataMenu->addAction(btnPicker);
1855+ plotDataMenu->insertSeparator();
1856+ plotDataMenu->addAction(actionDrawPoints);
1857+ plotDataMenu->addAction(btnMovePoints);
1858+ plotDataMenu->addAction(btnRemovePoints);
1859+ plotDataMenu->addAction(actionDragCurve);
1860+
1861+ reloadCustomActions();
1862+}
1863+
1864+void ApplicationWindow::plotMenuAboutToShow()
1865+{
1866+ plot2DMenu->clear();
1867+
1868+ plot2DMenu->addAction(actionPlotL);
1869+ plot2DMenu->addAction(actionPlotP);
1870+ plot2DMenu->addAction(actionPlotLP);
1871+
1872+ QMenu *specialPlotMenu = plot2DMenu->addMenu (tr("Special Line/Symb&ol"));
1873+ specialPlotMenu->addAction(actionPlotVerticalDropLines);
1874+ specialPlotMenu->addAction(actionPlotSpline);
1875+ specialPlotMenu->addAction(actionPlotVertSteps);
1876+ specialPlotMenu->addAction(actionPlotHorSteps);
1877+ specialPlotMenu->insertSeparator();
1878+ specialPlotMenu->addAction(actionPlotDoubleYAxis);
1879+ specialPlotMenu->addAction(actionWaterfallPlot);
1880+ specialPlotMenu->addAction(actionAddZoomPlot);
1881+
1882+ plot2DMenu->insertSeparator();
1883+ plot2DMenu->addAction(actionPlotVerticalBars);
1884+ plot2DMenu->addAction(actionPlotHorizontalBars);
1885+ QMenu *specialBarMenu = plot2DMenu->addMenu (tr("Spec&ial Bar/Column"));
1886+ specialBarMenu->addAction(actionStackBars);
1887+ specialBarMenu->addAction(actionStackColumns);
1888+
1889+ plot2DMenu->addAction(actionPlotArea);
1890+ plot2DMenu->addAction(actionPlotPie);
1891+ plot2DMenu->addAction(actionPlotVectXYXY);
1892+ plot2DMenu->addAction(actionPlotVectXYAM);
1893+ plot2DMenu->insertSeparator();
1894+
1895+ QMenu *statMenu = plot2DMenu->addMenu (tr("Statistical &Graphs"));
1896+ statMenu->addAction(actionBoxPlot);
1897+ statMenu->addAction(actionPlotHistogram);
1898+ statMenu->addAction(actionPlotStackedHistograms);
1899+ statMenu->insertSeparator();
1900+ statMenu->addAction(actionStemPlot);
1901+
1902+ QMenu *panelsMenu = plot2DMenu->addMenu (tr("Pa&nel"));
1903+ panelsMenu->addAction(actionPlot2VerticalLayers);
1904+ panelsMenu->addAction(actionPlot2HorizontalLayers);
1905+ panelsMenu->addAction(actionPlot4Layers);
1906+ panelsMenu->addAction(actionPlotStackedLayers);
1907+ panelsMenu->addAction(actionCustomLayout);
1908+
1909+ QMenu *gridMenu = plot2DMenu->addMenu (tr("Shared A&xes Panel"));
1910+ gridMenu->addAction(actionVertSharedAxisLayers);
1911+ gridMenu->addAction(actionHorSharedAxisLayers);
1912+ gridMenu->addAction(actionSharedAxesLayers);
1913+ gridMenu->addAction(actionStackSharedAxisLayers);
1914+ gridMenu->addAction(actionCustomSharedAxisLayers);
1915+
1916+ QMenu *plot3D = plot2DMenu->addMenu (tr("3&D Plot"));
1917+ plot3D->addAction(actionPlot3DRibbon);
1918+ plot3D->addAction(actionPlot3DBars);
1919+ plot3D->addAction(actionPlot3DScatter);
1920+ plot3D->addAction(actionPlot3DTrajectory);
1921+
1922+ reloadCustomActions();
1923+}
1924+
1925+void ApplicationWindow::customMenu(QMdiSubWindow* w)
1926+{
1927+ analysisMenu->menuAction()->setVisible(false);
1928+ tableMenu->menuAction()->setVisible(false);
1929+ plotDataMenu->menuAction()->setVisible(false);
1930+ graphMenu->menuAction()->setVisible(false);
1931+ matrixMenu->menuAction()->setVisible(false);
1932+ format->menuAction()->setVisible(false);
1933+ plot2DMenu->menuAction()->setVisible(false);
1934+ plot3DMenu->menuAction()->setVisible(false);
1935+#ifndef SCRIPTING_PYTHON
1936+ scriptingMenu->menuAction()->setVisible(false);
1937+#endif
1938+
1939+ // these use the same keyboard shortcut (Ctrl+Return) and should not be enabled at the same time
1940+ actionNoteEvaluate->setEnabled(false);
1941+ actionTableRecalculate->setEnabled(false);
1942+ // these use the same keyboard shortcut (Alt+C) and should not be enabled at the same time
1943+ actionShowCurvesDialog->setEnabled(false);
1944+ actionAddColToTable->setEnabled(false);
1945+ // these use the same keyboard shortcut (Alt+Q) and should not be enabled at the same time
1946+ actionAddFormula->setEnabled(false);
1947+ actionShowColumnValuesDialog->setEnabled(false);
1948+ actionSetMatrixValues->setEnabled(false);
1949+ // these use the same keyboard shortcut (Ctrl+Alt+F) and should not be enabled at the same time
1950+ actionAddFunctionCurve->setEnabled(false);
1951+ actionFind->setEnabled(false);
1952+
1953+ // clear undo stack view (in case window is not a matrix)
1954+ d_undo_view->setStack(0);
1955+ actionUndo->setEnabled(false);
1956+ actionRedo->setEnabled(false);
1957+
1958+ actionCopyWindow->setEnabled(w);
1959+ actionPrint->setEnabled(w);
1960+ actionPrintPreview->setEnabled(w);
1961+ actionExportPDF->setEnabled(w);
1962+
1963+ if(w){
1964+ actionPrintAllPlots->setEnabled(projectHas2DPlots());
1965+ actionPrint->setEnabled(true);
1966+ actionCutSelection->setEnabled(true);
1967+ actionCopySelection->setEnabled(true);
1968+ actionPasteSelection->setEnabled(true);
1969+ actionClearSelection->setEnabled(true);
1970+ actionSaveTemplate->setEnabled(true);
1971+ QStringList tables = tableNames() + matrixNames();
1972+ if (!tables.isEmpty())
1973+ actionShowExportASCIIDialog->setEnabled(true);
1974+ else
1975+ actionShowExportASCIIDialog->setEnabled(false);
1976+
1977+ if (w->isA("MultiLayer")) {
1978+ actionAddFunctionCurve->setEnabled(true);
1979+ actionShowCurvesDialog->setEnabled(true);
1980+ actionAddFormula->setEnabled(true);
1981+
1982+ graphMenu->menuAction()->setVisible(true);
1983+ plotDataMenu->menuAction()->setVisible(true);
1984+ analysisMenu->menuAction()->setVisible(true);
1985+ format->menuAction()->setVisible(true);
1986+ format->clear();
1987+ format->addAction(actionShowPlotDialog);
1988+ format->insertSeparator();
1989+ format->addAction(actionShowScaleDialog);
1990+ format->addAction(actionShowAxisDialog);
1991+ actionShowAxisDialog->setEnabled(true);
1992+ format->insertSeparator();
1993+ format->addAction(actionShowGridDialog);
1994+ format->addAction(actionShowTitleDialog);
1995+ } else if (w->isA("Graph3D")) {
1996+ disableActions();
1997+
1998+ actionPrint->setEnabled(true);
1999+ actionSaveTemplate->setEnabled(true);
2000+
2001+ format->menuAction()->setVisible(true);
2002+ format->clear();
2003+ format->addAction(actionShowPlotDialog);
2004+ format->addAction(actionShowScaleDialog);
2005+ format->addAction(actionShowAxisDialog);
2006+ format->addAction(actionShowTitleDialog);
2007+ if (((Graph3D*)w)->coordStyle() == Qwt3D::NOCOORD)
2008+ actionShowAxisDialog->setEnabled(false);
2009+ } else if (w->inherits("Table")) {
2010+ plot2DMenu->menuAction()->setVisible(true);
2011+ analysisMenu->menuAction()->setVisible(true);
2012+ tableMenu->menuAction()->setVisible(true);
2013+
2014+ actionTableRecalculate->setEnabled(true);
2015+ actionAddColToTable->setEnabled(true);
2016+ actionShowColumnValuesDialog->setEnabled(true);
2017+ } else if (w->isA("Matrix")){
2018+ actionTableRecalculate->setEnabled(true);
2019+ actionSetMatrixValues->setEnabled(true);
2020+
2021+ plot3DMenu->menuAction()->setVisible(true);
2022+ analysisMenu->menuAction()->setVisible(true);
2023+ matrixMenu->menuAction()->setVisible(true);
2024+
2025+ d_undo_view->setEmptyLabel(w->objectName() + ": " + tr("Empty Stack"));
2026+ QUndoStack *stack = ((Matrix *)w)->undoStack();
2027+ d_undo_view->setStack(stack);
2028+ } else if (qobject_cast<Note*>(w)){
2029+ #ifndef SCRIPTING_PYTHON
2030+ scriptingMenu->menuAction()->setVisible(true);
2031+ #endif
2032+ actionSaveTemplate->setEnabled(false);
2033+ actionNoteEvaluate->setEnabled(true);
2034+ actionFind->setEnabled(true);
2035+ } else
2036+ disableActions();
2037+ } else
2038+ disableActions();
2039+
2040+ reloadCustomActions();
2041+}
2042+
2043+void ApplicationWindow::disableActions()
2044+{
2045+ actionSaveTemplate->setEnabled(false);
2046+ actionPrintAllPlots->setEnabled(false);
2047+ actionPrint->setEnabled(false);
2048+
2049+ actionCutSelection->setEnabled(false);
2050+ actionCopySelection->setEnabled(false);
2051+ actionPasteSelection->setEnabled(false);
2052+ actionClearSelection->setEnabled(false);
2053+}
2054+
2055+void ApplicationWindow::customColumnActions()
2056+{
2057+ actionAdjustColumnWidth->setEnabled(false);
2058+ actionMoveColFirst->setEnabled(false);
2059+ actionMoveColLeft->setEnabled(false);
2060+ actionMoveColRight->setEnabled(false);
2061+ actionMoveColLast->setEnabled(false);
2062+ actionSetXCol->setEnabled(false);
2063+ actionSetYCol->setEnabled(false);
2064+ actionSetZCol->setEnabled(false);
2065+ actionSetLabelCol->setEnabled(false);
2066+ actionSetYErrCol->setEnabled(false);
2067+ actionDisregardCol->setEnabled(false);
2068+ actionSwapColumns->setEnabled(false);
2069+ actionSetAscValues->setEnabled(false);
2070+ actionSetRandomValues->setEnabled(false);
2071+
2072+ Table *t = (Table*)activeWindow(TableWindow);
2073+ if (!t)
2074+ return;
2075+
2076+ int selectedCols = t->selectedColsNumber();
2077+ if (selectedCols == 1){
2078+ int col = t->selectedColumn();
2079+ if (col > 0){
2080+ actionMoveColFirst->setEnabled(true);
2081+ actionMoveColLeft->setEnabled(true);
2082+ }
2083+
2084+ if (col < t->numCols() - 1){
2085+ actionMoveColRight->setEnabled(true);
2086+ actionMoveColLast->setEnabled(true);
2087+ }
2088+ }
2089+
2090+ if (selectedCols >= 1){
2091+ actionSetAscValues->setEnabled(true);
2092+ actionSetRandomValues->setEnabled(true);
2093+ actionSetXCol->setEnabled(true);
2094+ actionSetYCol->setEnabled(true);
2095+ actionSetZCol->setEnabled(true);
2096+ actionSetYErrCol->setEnabled(true);
2097+ actionSetLabelCol->setEnabled(true);
2098+ actionDisregardCol->setEnabled(true);
2099+ actionAdjustColumnWidth->setEnabled(true);
2100+ }
2101+
2102+ if (selectedCols == 2)
2103+ actionSwapColumns->setEnabled(true);
2104+}
2105+
2106+void ApplicationWindow::customToolBars(QMdiSubWindow* w)
2107+{
2108+ disableToolbars();
2109+ if (!w)
2110+ return;
2111+
2112+ if (w->isA("MultiLayer") && d_plot_tool_bar){
2113+ if(!plotTools->isVisible())
2114+ plotTools->show();
2115+ plotTools->setEnabled (true);
2116+ custom2DPlotTools((MultiLayer *)w);
2117+ if(d_format_tool_bar && !formatToolBar->isVisible()){
2118+ formatToolBar->setEnabled (true);
2119+ formatToolBar->show();
2120+ }
2121+ } else if (w->inherits("Table")){
2122+ if(d_table_tool_bar){
2123+ if(!tableTools->isVisible())
2124+ tableTools->show();
2125+ tableTools->setEnabled (true);
2126+ }
2127+ if (d_column_tool_bar){
2128+ if(!columnTools->isVisible())
2129+ columnTools->show();
2130+ columnTools->setEnabled (true);
2131+ customColumnActions();
2132+ }
2133+ } else if (w->isA("Matrix") && d_matrix_tool_bar){
2134+ if(!plotMatrixBar->isVisible())
2135+ plotMatrixBar->show();
2136+ plotMatrixBar->setEnabled (true);
2137+ } else if (w->isA("Graph3D") && d_plot3D_tool_bar){
2138+ if(!plot3DTools->isVisible())
2139+ plot3DTools->show();
2140+
2141+ plot3DTools->setEnabled(((Graph3D*)w)->plotStyle() != Qwt3D::NOPLOT);
2142+ custom3DActions(w);
2143+ } else if (w->isA("Note")){
2144+ if(d_format_tool_bar && !formatToolBar->isVisible())
2145+ formatToolBar->show();
2146+ if(d_notes_tool_bar && !noteTools->isVisible())
2147+ noteTools->show();
2148+
2149+ formatToolBar->setEnabled (true);
2150+ noteTools->setEnabled (true);
2151+ setFormatBarFont(((Note*)w)->currentEditor()->currentFont());
2152+ }
2153+}
2154+
2155+void ApplicationWindow::disableToolbars()
2156+{
2157+ plotTools->setEnabled(false);
2158+ tableTools->setEnabled(false);
2159+ columnTools->setEnabled(false);
2160+ plot3DTools->setEnabled(false);
2161+ plotMatrixBar->setEnabled(false);
2162+ noteTools->setEnabled(false);
2163+}
2164+
2165+void ApplicationWindow::plot3DRibbon()
2166+{
2167+ MdiSubWindow *w = activeWindow(TableWindow);
2168+ if (!w)
2169+ return;
2170+
2171+ Table *table = static_cast<Table*>(w);
2172+ if(table->selectedColumns().count() == 1){
2173+ if (!validFor3DPlot(table))
2174+ return;
2175+ plotXYZ(table, table->colName(table->selectedColumn()), Graph3D::Ribbon);
2176+ } else
2177+ QMessageBox::warning(this, tr("QtiPlot - Plot error"), tr("You must select exactly one column for plotting!"));
2178+}
2179+
2180+void ApplicationWindow::plot3DWireframe()
2181+{
2182+ plot3DMatrix (0, Qwt3D::WIREFRAME);
2183+}
2184+
2185+void ApplicationWindow::plot3DHiddenLine()
2186+{
2187+ plot3DMatrix (0, Qwt3D::HIDDENLINE);
2188+}
2189+
2190+void ApplicationWindow::plot3DPolygons()
2191+{
2192+ plot3DMatrix (0, Qwt3D::FILLED);
2193+}
2194+
2195+void ApplicationWindow::plot3DWireSurface()
2196+{
2197+ plot3DMatrix (0, Qwt3D::FILLEDMESH);
2198+}
2199+
2200+void ApplicationWindow::plot3DBars()
2201+{
2202+ MdiSubWindow *w = activeWindow();
2203+ if (!w)
2204+ return;
2205+
2206+ if (w->inherits("Table")){
2207+ Table *table = static_cast<Table *>(w);
2208+ if (!validFor3DPlot(table))
2209+ return;
2210+
2211+ if(table->selectedColumns().count() == 1)
2212+ plotXYZ(table, table->colName(table->selectedColumn()), Graph3D::Bars);
2213+ else
2214+ QMessageBox::warning(this, tr("QtiPlot - Plot error"),tr("You must select exactly one column for plotting!"));
2215+ }
2216+ else if(w->inherits("Matrix"))
2217+ plot3DMatrix(0, Qwt3D::USER);
2218+}
2219+
2220+void ApplicationWindow::plot3DScatter()
2221+{
2222+ MdiSubWindow *w = activeWindow();
2223+ if (!w)
2224+ return;
2225+
2226+ if (w->inherits("Table"))
2227+ {
2228+ Table *table = static_cast<Table *>(w);
2229+ if (!validFor3DPlot(table))
2230+ return;
2231+
2232+ if(table->selectedColumns().count() == 1)
2233+ plotXYZ(table, table->colName(table->selectedColumn()), Graph3D::Scatter);
2234+ else
2235+ QMessageBox::warning(this, tr("QtiPlot - Plot error"),tr("You must select exactly one column for plotting!"));
2236+ }
2237+ else if(w->inherits("Matrix"))
2238+ plot3DMatrix (0, Qwt3D::POINTS);
2239+}
2240+
2241+void ApplicationWindow::plot3DTrajectory()
2242+{
2243+ Table *table = (Table *)activeWindow(TableWindow);
2244+ if (!table)
2245+ return;
2246+ if (!validFor3DPlot(table))
2247+ return;
2248+
2249+ if(table->selectedColumns().count() == 1)
2250+ plotXYZ(table, table->colName(table->selectedColumn()), Graph3D::Trajectory);
2251+ else
2252+ QMessageBox::warning(this, tr("QtiPlot - Plot error"), tr("You must select exactly one column for plotting!"));
2253+}
2254+
2255+void ApplicationWindow::plotBoxDiagram()
2256+{
2257+ generate2DGraph(Graph::Box);
2258+}
2259+
2260+void ApplicationWindow::plotVerticalBars()
2261+{
2262+ generate2DGraph(Graph::VerticalBars);
2263+}
2264+
2265+void ApplicationWindow::plotHorizontalBars()
2266+{
2267+ generate2DGraph(Graph::HorizontalBars);
2268+}
2269+
2270+void ApplicationWindow::plotStackBar()
2271+{
2272+ generate2DGraph(Graph::StackBar);
2273+}
2274+
2275+void ApplicationWindow::plotStackColumn()
2276+{
2277+ generate2DGraph(Graph::StackColumn);
2278+}
2279+
2280+MultiLayer* ApplicationWindow::plotHistogram()
2281+{
2282+ return generate2DGraph(Graph::Histogram);
2283+}
2284+
2285+MultiLayer* ApplicationWindow::plotHistogram(Matrix *m)
2286+{
2287+ if (!m){
2288+ m = (Matrix*)activeWindow(MatrixWindow);
2289+ if (!m)
2290+ return 0;
2291+ }
2292+
2293+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2294+ MultiLayer* g = newGraph();
2295+ if (g)
2296+ g->activeLayer()->addHistogram(m);
2297+ QApplication::restoreOverrideCursor();
2298+ return g;
2299+}
2300+
2301+void ApplicationWindow::plotArea()
2302+{
2303+ generate2DGraph(Graph::Area);
2304+}
2305+
2306+void ApplicationWindow::plotPie()
2307+{
2308+ Table *table = (Table *)activeWindow(TableWindow);
2309+ if (!table)
2310+ return;
2311+
2312+ if(table->selectedColumns().count() != 1){
2313+ QMessageBox::warning(this, tr("QtiPlot - Plot error"),
2314+ tr("You must select exactly one column for plotting!"));
2315+ return;
2316+ }
2317+
2318+ QStringList s = table->selectedColumns();
2319+ if (s.count()>0){
2320+ Q3TableSelection sel = table->getSelection();
2321+ multilayerPlot(table, s, Graph::Pie, sel.topRow(), sel.bottomRow());
2322+ } else
2323+ QMessageBox::warning(this, tr("QtiPlot - Error"), tr("Please select a column to plot!"));
2324+}
2325+
2326+void ApplicationWindow::plotL()
2327+{
2328+ generate2DGraph(Graph::Line);
2329+}
2330+
2331+void ApplicationWindow::plotP()
2332+{
2333+ generate2DGraph(Graph::Scatter);
2334+}
2335+
2336+void ApplicationWindow::plotLP()
2337+{
2338+ generate2DGraph(Graph::LineSymbols);
2339+}
2340+
2341+void ApplicationWindow::plotVerticalDropLines()
2342+{
2343+ generate2DGraph(Graph::VerticalDropLines);
2344+}
2345+
2346+void ApplicationWindow::plotSpline()
2347+{
2348+ generate2DGraph(Graph::Spline);
2349+}
2350+
2351+void ApplicationWindow::plotVertSteps()
2352+{
2353+ generate2DGraph(Graph::VerticalSteps);
2354+}
2355+
2356+void ApplicationWindow::plotHorSteps()
2357+{
2358+ generate2DGraph(Graph::HorizontalSteps);
2359+}
2360+
2361+void ApplicationWindow::plotVectXYXY()
2362+{
2363+ Table *table = (Table *)activeWindow(TableWindow);
2364+ if (!table)
2365+ return;
2366+ if (!validFor2DPlot(table, Graph::VectXYXY))
2367+ return;
2368+
2369+ QStringList s = table->selectedColumns();
2370+ if (s.count() == 4) {
2371+ Q3TableSelection sel = table->getSelection();
2372+ multilayerPlot(table, s, Graph::VectXYXY, sel.topRow(), sel.bottomRow());
2373+ } else
2374+ QMessageBox::warning(this, tr("QtiPlot - Error"), tr("Please select four columns for this operation!"));
2375+}
2376+
2377+void ApplicationWindow::plotVectXYAM()
2378+{
2379+ Table *table = (Table *)activeWindow(TableWindow);
2380+ if (!table)
2381+ return;
2382+ if (!validFor2DPlot(table, Graph::VectXYAM))
2383+ return;
2384+
2385+ QStringList s = table->selectedColumns();
2386+ if (s.count() == 4){
2387+ Q3TableSelection sel = table->getSelection();
2388+ multilayerPlot(table, s, Graph::VectXYAM, sel.topRow(), sel.bottomRow());
2389+ } else
2390+ QMessageBox::warning(this, tr("QtiPlot - Error"), tr("Please select four columns for this operation!"));
2391+}
2392+
2393+void ApplicationWindow::renameListViewItem(const QString& oldName,const QString& newName)
2394+{
2395+ Q3ListViewItem *it=lv->findItem (oldName,0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2396+ if (it)
2397+ it->setText(0,newName);
2398+}
2399+
2400+void ApplicationWindow::setListViewLabel(const QString& caption,const QString& label)
2401+{
2402+ Q3ListViewItem *it = lv->findItem ( caption, 0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2403+ if (it){
2404+ QString s = label;
2405+ it->setText(5, s.replace("\n", " "));
2406+ }
2407+}
2408+
2409+void ApplicationWindow::setListViewDate(const QString& caption,const QString& date)
2410+{
2411+ Q3ListViewItem *it=lv->findItem ( caption, 0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2412+ if (it)
2413+ it->setText(4,date);
2414+}
2415+
2416+void ApplicationWindow::setListView(const QString& caption,const QString& view)
2417+{
2418+ Q3ListViewItem *it=lv->findItem ( caption,0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2419+ if (it)
2420+ it->setText(2,view);
2421+}
2422+
2423+void ApplicationWindow::setListViewSize(const QString& caption,const QString& size)
2424+{
2425+ Q3ListViewItem *it=lv->findItem ( caption,0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2426+ if (it)
2427+ it->setText(3,size);
2428+}
2429+
2430+QString ApplicationWindow::listViewDate(const QString& caption)
2431+{
2432+ Q3ListViewItem *it=lv->findItem (caption,0, Q3ListView::ExactMatch | Qt::CaseSensitive );
2433+ if (it)
2434+ return it->text(4);
2435+ else
2436+ return "";
2437+}
2438+
2439+void ApplicationWindow::updateTableNames(const QString& oldName, const QString& newName)
2440+{
2441+ QList<MdiSubWindow *> windows = windowsList();
2442+ foreach (MdiSubWindow *w, windows) {
2443+ if (w->isA("MultiLayer")) {
2444+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
2445+ foreach(Graph *g, layers)
2446+ g->updateCurveNames(oldName, newName);
2447+ } else if (w->isA("Graph3D")) {
2448+ QString name = ((Graph3D*)w)->formula();
2449+ if (name.contains(oldName, true)) {
2450+ name.replace(oldName,newName);
2451+ ((Graph3D*)w)->setPlotAssociation(name);
2452+ }
2453+ }
2454+ }
2455+}
2456+
2457+void ApplicationWindow::updateColNames(const QString& oldName, const QString& newName)
2458+{
2459+ QList<MdiSubWindow *> windows = windowsList();
2460+ foreach (MdiSubWindow *w, windows){
2461+ if (w->isA("MultiLayer")){
2462+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
2463+ foreach(Graph *g, layers)
2464+ g->updateCurveNames(oldName, newName, false);
2465+ }
2466+ else if (w->isA("Graph3D")){
2467+ QString name = ((Graph3D*)w)->formula();
2468+ if (name.contains(oldName)){
2469+ name.replace(oldName,newName);
2470+ ((Graph3D*)w)->setPlotAssociation(name);
2471+ }
2472+ }
2473+ }
2474+}
2475+
2476+void ApplicationWindow::changeMatrixName(const QString& oldName, const QString& newName)
2477+{
2478+ QList<MdiSubWindow *> windows = windowsList();
2479+ foreach(MdiSubWindow *w, windows){
2480+ if (w->isA("Graph3D"))
2481+ {
2482+ QString s = ((Graph3D*)w)->formula();
2483+ if (s.contains(oldName))
2484+ {
2485+ s.replace(oldName, newName);
2486+ ((Graph3D*)w)->setPlotAssociation(s);
2487+ }
2488+ }
2489+ else if (w->isA("MultiLayer"))
2490+ {
2491+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
2492+ foreach(Graph *g, layers){
2493+ for (int i=0; i<g->curveCount(); i++){
2494+ QwtPlotItem *sp = (QwtPlotItem *)g->plotItem(i);
2495+ if (sp && sp->rtti() == QwtPlotItem::Rtti_PlotSpectrogram && sp->title().text() == oldName)
2496+ sp->setTitle(newName);
2497+ }
2498+ }
2499+ }
2500+ }
2501+}
2502+
2503+void ApplicationWindow::remove3DMatrixPlots(Matrix *m)
2504+{
2505+ if (!m)
2506+ return;
2507+
2508+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2509+
2510+ QList<MdiSubWindow *> windows = windowsList();
2511+ foreach(MdiSubWindow *w, windows){
2512+ if (w->isA("Graph3D") && ((Graph3D*)w)->matrix() == m)
2513+ ((Graph3D*)w)->clearData();
2514+ else if (w->isA("MultiLayer")){
2515+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
2516+ foreach(Graph *g, layers){
2517+ QList<QwtPlotItem *> curvesList = g->curvesList();
2518+ foreach (QwtPlotItem *it, curvesList){
2519+ if (it->rtti() == QwtPlotItem::Rtti_PlotSpectrogram){
2520+ if (((Spectrogram *)it)->matrix() == m)
2521+ g->removeCurve(it);
2522+ } else if (((PlotCurve *)it)->type() == Graph::Histogram){
2523+ if (((QwtHistogram *)it)->matrix() == m)
2524+ g->removeCurve(it);
2525+ }
2526+ }
2527+ g->updatePlot();
2528+ }
2529+ }
2530+ }
2531+ QApplication::restoreOverrideCursor();
2532+}
2533+
2534+void ApplicationWindow::updateMatrixPlots(Matrix *m)
2535+{
2536+ if (!m)
2537+ return;
2538+
2539+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2540+
2541+ QList<MdiSubWindow *> windows = windowsList();
2542+ foreach(MdiSubWindow *w, windows){
2543+ if (w->isA("Graph3D") && ((Graph3D*)w)->matrix() == m)
2544+ ((Graph3D*)w)->updateMatrixData(m);
2545+ else if (w->isA("MultiLayer")){
2546+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
2547+ foreach(Graph *g, layers){
2548+ QList<QwtPlotItem *> curvesList = g->curvesList();
2549+ foreach (QwtPlotItem *it, curvesList){
2550+ if (it->rtti() == QwtPlotItem::Rtti_PlotSpectrogram){
2551+ Spectrogram *sp = (Spectrogram *)it;
2552+ if (sp->matrix() == m){
2553+ sp->updateData();
2554+ g->updatePlot();
2555+ }
2556+ } else if (((PlotCurve *)it)->type() == Graph::Histogram){
2557+ QwtHistogram *h = (QwtHistogram *)it;
2558+ if (h->matrix() == m){
2559+ h->loadData();
2560+ g->updatePlot();
2561+ }
2562+ }
2563+ }
2564+ }
2565+ }
2566+ }
2567+ QApplication::restoreOverrideCursor();
2568+}
2569+
2570+void ApplicationWindow::add3DData()
2571+{
2572+ if (!hasTable()){
2573+ QMessageBox::warning(this,tr("QtiPlot - Warning"),
2574+ tr("<h4>There are no tables available in this project.</h4>"
2575+ "<p><h4>Please create a table and try again!</h4>"));
2576+ return;
2577+ }
2578+
2579+ QStringList zColumns = columnsList(Table::Z);
2580+ if ((int)zColumns.count() <= 0){
2581+ QMessageBox::critical(this,tr("QtiPlot - Warning"),
2582+ tr("There are no available columns with plot designation set to Z!"));
2583+ return;
2584+ }
2585+
2586+ bool ok;
2587+ QString column = QInputDialog::getItem(this, tr("QtiPlot - Choose data set"),
2588+ tr("Column") + ": ", zColumns, 0, false, &ok);
2589+ if (ok && !column.isEmpty())
2590+ insertNew3DData(column);
2591+}
2592+
2593+void ApplicationWindow::change3DData()
2594+{
2595+ bool ok;
2596+ QString column = QInputDialog::getItem(this, tr("QtiPlot - Choose data set"),
2597+ tr("Column") + ": ", columnsList(Table::Z), 0, false, &ok);
2598+ if (ok && !column.isEmpty())
2599+ change3DData(column);
2600+}
2601+
2602+void ApplicationWindow::change3DMatrix()
2603+{
2604+ QStringList matrices = matrixNames();
2605+ int currentIndex = 0;
2606+ Graph3D* g = (Graph3D*)activeWindow(Plot3DWindow);
2607+ if (g && g->matrix())
2608+ currentIndex = matrices.indexOf(g->matrix()->objectName());
2609+
2610+ bool ok;
2611+ QString matrixName = QInputDialog::getItem(this, tr("QtiPlot - Choose matrix to plot"),
2612+ tr("Matrix") + ": ", matrices, currentIndex, false, &ok);
2613+ if (ok && !matrixName.isEmpty())
2614+ change3DMatrix(matrixName);
2615+}
2616+
2617+void ApplicationWindow::change3DMatrix(const QString& matrix_name)
2618+{
2619+ Graph3D *g = (Graph3D*)activeWindow(Plot3DWindow);
2620+ if (!g)
2621+ return;
2622+
2623+ Matrix *m = matrix(matrix_name);
2624+ if (!m)
2625+ return;
2626+
2627+ if (d_3D_autoscale)
2628+ g->addMatrixData(m);
2629+ else
2630+ g->addMatrixData(m, g->xStart(), g->xStop(), g->yStart(), g->yStop(), g->zStart(), g->zStop());
2631+
2632+ emit modified();
2633+}
2634+
2635+void ApplicationWindow::add3DMatrixPlot()
2636+{
2637+ QStringList matrices = matrixNames();
2638+ if ((int)matrices.count() <= 0){
2639+ QMessageBox::warning(this, tr("QtiPlot - Warning"),
2640+ tr("<h4>There are no matrices available in this project.</h4>"
2641+ "<p><h4>Please create a matrix and try again!</h4>"));
2642+ return;
2643+ }
2644+
2645+ bool ok;
2646+ QString matrixName = QInputDialog::getItem(this, tr("QtiPlot - Choose matrix to plot"),
2647+ tr("Matrix") + ": ", matrices, 0, false, &ok);
2648+ if (ok && !matrixName.isEmpty())
2649+ insert3DMatrixPlot(matrixName);
2650+}
2651+
2652+void ApplicationWindow::insert3DMatrixPlot(const QString& matrix_name)
2653+{
2654+ Graph3D *g = (Graph3D*)activeWindow(Plot3DWindow);
2655+ if (!g)
2656+ return;
2657+
2658+ g->addMatrixData(matrix(matrix_name));
2659+ emit modified();
2660+}
2661+
2662+void ApplicationWindow::insertNew3DData(const QString& colName)
2663+{
2664+ Graph3D *g = (Graph3D*)activeWindow(Plot3DWindow);
2665+ if (!g)
2666+ return;
2667+
2668+ g->insertNewData(table(colName),colName);
2669+ emit modified();
2670+}
2671+
2672+void ApplicationWindow::change3DData(const QString& colName)
2673+{
2674+ Graph3D *g = (Graph3D*)activeWindow(Plot3DWindow);
2675+ if (!g)
2676+ return;
2677+
2678+ g->changeDataColumn(table(colName), colName, g->tablePlotType());
2679+ emit modified();
2680+}
2681+
2682+void ApplicationWindow::editSurfacePlot()
2683+{
2684+ Graph3D *g = (Graph3D*)activeWindow(Plot3DWindow);
2685+ if (!g)
2686+ return;
2687+
2688+ SurfaceDialog* sd = new SurfaceDialog(this);
2689+ sd->setAttribute(Qt::WA_DeleteOnClose);
2690+
2691+ if (g->hasData() && g->userFunction())
2692+ sd->setFunction(g);
2693+ else if (g->hasData() && g->parametricSurface())
2694+ sd->setParametricSurface(g);
2695+ else
2696+ sd->setGraph(g);
2697+ sd->exec();
2698+}
2699+
2700+void ApplicationWindow::newSurfacePlot()
2701+{
2702+ SurfaceDialog* sd = new SurfaceDialog(this);
2703+ sd->setAttribute(Qt::WA_DeleteOnClose);
2704+ sd->exec();
2705+}
2706+
2707+Graph3D* ApplicationWindow::plotSurface(const QString& formula, double xl, double xr,
2708+ double yl, double yr, double zl, double zr, int columns, int rows)
2709+{
2710+ Graph3D *plot = newPlot3D();
2711+ if(!plot)
2712+ return 0;
2713+
2714+ plot->addFunction(formula, xl, xr, yl, yr, zl, zr, columns, rows);
2715+ plot->setDataColorMap(d_3D_color_map);
2716+ plot->update();
2717+
2718+ emit modified();
2719+ return plot;
2720+}
2721+
2722+Graph3D* ApplicationWindow::plotParametricSurface(const QString& xFormula, const QString& yFormula,
2723+ const QString& zFormula, double ul, double ur, double vl, double vr,
2724+ int columns, int rows, bool uPeriodic, bool vPeriodic)
2725+{
2726+ Graph3D *plot = newPlot3D();
2727+ if(!plot)
2728+ return 0;
2729+ plot->addParametricSurface(xFormula, yFormula, zFormula, ul, ur, vl, vr,
2730+ columns, rows, uPeriodic, vPeriodic);
2731+ plot->setDataColorMap(d_3D_color_map);
2732+ plot->update();
2733+
2734+ emit modified();
2735+ return plot;
2736+}
2737+
2738+void ApplicationWindow::updateSurfaceFuncList(const QString& s)
2739+{
2740+ surfaceFunc.remove(s);
2741+ surfaceFunc.push_front(s);
2742+ while ((int)surfaceFunc.size() > 10)
2743+ surfaceFunc.pop_back();
2744+}
2745+
2746+Graph3D* ApplicationWindow::addRibbon(const QString& caption, const QString& formula,
2747+ double xl, double xr, double yl, double yr, double zl, double zr)
2748+{
2749+ Table* t = table(formula.left(formula.find("_", 0)));
2750+ if (!t)
2751+ return 0;
2752+
2753+ QString s = formula;
2754+ s.remove("(X)").remove("(Y)");
2755+ QStringList l = s.split(",");
2756+ if (l.size() != 2)
2757+ return 0;
2758+
2759+ Graph3D *plot = newPlot3D(caption);
2760+ if(!plot)
2761+ return 0;
2762+
2763+ plot->addRibbon(t, l[0], l[1], xl, xr, yl, yr, zl, zr);
2764+ plot->setDataColorMap(d_3D_color_map);
2765+ plot->update();
2766+
2767+ return plot;
2768+}
2769+
2770+Graph3D* ApplicationWindow::newPlot3D(const QString& title)
2771+{
2772+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2773+
2774+ QString label = title;
2775+ if (label.isEmpty() || alreadyUsedName(label))
2776+ label = generateUniqueName(tr("Graph"));
2777+
2778+ Graph3D *plot = new Graph3D("", this, 0);
2779+ plot->setWindowTitle(label);
2780+ plot->setName(label);
2781+
2782+ initPlot3D(plot);
2783+
2784+ emit modified();
2785+ QApplication::restoreOverrideCursor();
2786+ return plot;
2787+}
2788+
2789+Graph3D* ApplicationWindow::plotXYZ(Table* table, const QString& zColName, int type)
2790+{
2791+ int zCol = table->colIndex(zColName);
2792+ if (zCol < 0)
2793+ return 0;
2794+
2795+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2796+
2797+ Graph3D *plot = newPlot3D();
2798+ if(!plot)
2799+ return 0;
2800+
2801+ if (type == Graph3D::Ribbon) {
2802+ int ycol = table->colIndex(zColName);
2803+ plot->addRibbon(table, table->colName(table->colX(ycol)), zColName);
2804+ } else
2805+ plot->addData(table, table->colX(zCol), table->colY(zCol), zCol, type);
2806+
2807+ plot->setDataColorMap(d_3D_color_map);
2808+ plot->update();
2809+
2810+ emit modified();
2811+ QApplication::restoreOverrideCursor();
2812+ return plot;
2813+}
2814+
2815+void ApplicationWindow::initPlot3D(Graph3D *plot)
2816+{
2817+ if (d_mdi_windows_area)
2818+ d_workspace->addSubWindow(plot);
2819+ else
2820+ plot->setParent(0);
2821+
2822+ connectSurfacePlot(plot);
2823+
2824+ plot->setIcon(QPixmap(":/trajectory.png"));
2825+ plot->show();
2826+ plot->setFocus();
2827+
2828+ addListViewItem(plot);
2829+
2830+ if (!plot3DTools->isVisible())
2831+ plot3DTools->show();
2832+
2833+ if (!plot3DTools->isEnabled())
2834+ plot3DTools->setEnabled(true);
2835+
2836+ customMenu(plot);
2837+ customToolBars(plot);
2838+}
2839+
2840+void ApplicationWindow::exportMatrix(const QString& exportFilter)
2841+{
2842+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
2843+ if (!m)
2844+ return;
2845+
2846+ ImageExportDialog *ied = new ImageExportDialog(m, this, d_extended_export_dialog);
2847+ ied->setDir(imagesDirPath);
2848+ ied->selectFile(m->objectName());
2849+ if (exportFilter.isEmpty())
2850+ ied->selectFilter(d_image_export_filter);
2851+ else
2852+ ied->selectFilter(exportFilter);
2853+
2854+ if ( ied->exec() != QDialog::Accepted )
2855+ return;
2856+ imagesDirPath = ied->directory().path();
2857+
2858+ QString selected_filter = ied->selectedFilter().remove("*");
2859+ QString file_name = ied->selectedFiles()[0];
2860+ if(!file_name.endsWith(selected_filter, Qt::CaseInsensitive))
2861+ file_name.append(selected_filter);
2862+
2863+ if (selected_filter.contains(".eps") || selected_filter.contains(".pdf") || selected_filter.contains(".ps"))
2864+ m->exportVector(file_name, ied->vectorResolution(), ied->color());
2865+ else if (selected_filter.contains(".svg"))
2866+ m->exportSVG(file_name);
2867+#ifdef EMF_OUTPUT
2868+ else if (selected_filter.contains(".emf"))
2869+ m->exportEMF(file_name);
2870+#endif
2871+ else if (selected_filter.contains(".odf"))
2872+ m->exportRasterImage(file_name, ied->quality(), ied->bitmapResolution());
2873+ else {
2874+ QList<QByteArray> list = QImageWriter::supportedImageFormats();
2875+ for (int i=0; i<(int)list.count(); i++){
2876+ if (selected_filter.contains("." + (list[i]).lower()))
2877+ m->exportRasterImage(file_name, ied->quality(), ied->bitmapResolution());
2878+ }
2879+ }
2880+}
2881+
2882+Matrix* ApplicationWindow::importImage(const QString& fileName, bool newWindow)
2883+{
2884+ QString fn = fileName;
2885+ if (fn.isEmpty()){
2886+ fn = getFileName(this, tr("QtiPlot - Import image from file"), imagesDirPath, imageFilter(), 0, false);
2887+ if ( !fn.isEmpty() ){
2888+ QFileInfo fi(fn);
2889+ imagesDirPath = fi.dirPath(true);
2890+ }
2891+ }
2892+
2893+ QImage image(fn);
2894+ if (image.isNull())
2895+ return 0;
2896+
2897+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2898+
2899+ MdiSubWindow *w = activeWindow(MatrixWindow);
2900+ Matrix* m = NULL;
2901+ if (w && !newWindow){
2902+ m = (Matrix *)w;
2903+ m->importImage(fn);
2904+ } else {
2905+ m = new Matrix(scriptEnv, image, "", this);
2906+ initMatrix(m, generateUniqueName(tr("Matrix")));
2907+ m->show();
2908+ m->setWindowLabel(fn);
2909+ m->setCaptionPolicy(MdiSubWindow::Both);
2910+ }
2911+
2912+ QApplication::restoreOverrideCursor();
2913+ return m;
2914+}
2915+
2916+QString ApplicationWindow::imageFilter()
2917+{
2918+ QList<QByteArray> list = QImageReader::supportedImageFormats();
2919+ QString filter = tr("Images") + " (", aux1, aux2;
2920+ for (int i = 0; i < (int)list.count(); i++){
2921+ aux1 = " *." + list[i] + " ";
2922+ aux2 += " *." + list[i] + ";;";
2923+ filter += aux1;
2924+ }
2925+ filter += ");;" + aux2;
2926+ return filter;
2927+}
2928+
2929+void ApplicationWindow::loadImage()
2930+{
2931+ QString fn = getFileName(this, tr("QtiPlot - Load image from file"), imagesDirPath, imageFilter(), 0, false);
2932+ if ( !fn.isEmpty() ){
2933+ loadImage(fn);
2934+ QFileInfo fi(fn);
2935+ imagesDirPath = fi.dirPath(true);
2936+ }
2937+}
2938+
2939+void ApplicationWindow::loadImage(const QString& fn)
2940+{
2941+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2942+
2943+ MultiLayer *plot = multilayerPlot(generateUniqueName(tr("Graph")));
2944+ plot->setWindowLabel(fn);
2945+ plot->setCaptionPolicy(MdiSubWindow::Both);
2946+
2947+ Graph *g = plot->activeLayer();
2948+ g->setTitle("");
2949+ for (int i=0; i<4; i++)
2950+ g->enableAxis(i, false);
2951+ g->addImage(fn);
2952+ QApplication::restoreOverrideCursor();
2953+}
2954+
2955+MultiLayer* ApplicationWindow::multilayerPlot(const QString& caption, int layers, int rows, int cols)
2956+{
2957+ MultiLayer* ml = new MultiLayer(this, layers, rows, cols);
2958+ initMultilayerPlot(ml, caption);
2959+ return ml;
2960+}
2961+
2962+MultiLayer* ApplicationWindow::newGraph(const QString& caption)
2963+{
2964+ MultiLayer *ml = multilayerPlot(generateUniqueName(caption));
2965+ if (ml){
2966+ Graph *g = ml->activeLayer();
2967+ if (g){
2968+ setPreferences(g);
2969+ g->newLegend();
2970+ }
2971+ ml->arrangeLayers(false, true);
2972+ }
2973+
2974+ return ml;
2975+}
2976+
2977+MultiLayer* ApplicationWindow::multilayerPlot(Table* w, const QStringList& colList, int style, int startRow, int endRow)
2978+{//used when plotting selected columns
2979+ if (!w)
2980+ return 0;
2981+
2982+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2983+
2984+ MultiLayer* g = multilayerPlot(generateUniqueName(tr("Graph")));
2985+ Graph *ag = g->activeLayer();
2986+ if (!ag)
2987+ return 0;
2988+
2989+ setPreferences(ag);
2990+ ag->addCurves(w, colList, style, defaultCurveLineWidth, defaultSymbolSize, startRow, endRow);
2991+ ag->newLegend();
2992+
2993+ g->arrangeLayers(false, true);
2994+ QApplication::restoreOverrideCursor();
2995+ return g;
2996+}
2997+
2998+MultiLayer* ApplicationWindow::multilayerPlot(int c, int r, int style, const MultiLayer::AlignPolicy& align)
2999+{//used when plotting from the panel menu
3000+ Table *t = (Table *)activeWindow(TableWindow);
3001+ if (!t)
3002+ return 0;
3003+
3004+ if (!validFor2DPlot(t, (Graph::CurveType)style))
3005+ return 0;
3006+
3007+ QStringList list = t->drawableColumnSelection();
3008+ if((int)list.count() < 1) {
3009+ QMessageBox::warning(this, tr("QtiPlot - Plot error"), tr("Please select a Y column to plot!"));
3010+ return 0;
3011+ }
3012+
3013+ int curves = list.count();
3014+ if (r < 0)
3015+ r = curves;
3016+
3017+ int layers = c*r;
3018+ MultiLayer* g = multilayerPlot(generateUniqueName(tr("Graph")), layers, r, c);
3019+ QList<Graph *> layersList = g->layersList();
3020+ int i = 0;
3021+ foreach(Graph *ag, layersList){
3022+ setPreferences(ag);
3023+ if (i < curves){
3024+ QStringList lst = QStringList() << list[i];
3025+ for (int j = 0; j < curves; j++){
3026+ int col = t->colIndex(list[j]);
3027+ if (t->colPlotDesignation(col) == Table::xErr ||
3028+ t->colPlotDesignation(col) == Table::yErr ||
3029+ t->colPlotDesignation(col) == Table::Label){
3030+ lst << list[j];
3031+ }
3032+ }
3033+ ag->addCurves(t, lst, style, defaultCurveLineWidth, defaultSymbolSize);
3034+ }
3035+ i++;
3036+ }
3037+
3038+ if (align == MultiLayer::AlignCanvases){
3039+ g->setAlignPolicy(align);
3040+ g->setSpacing(0, 0);
3041+ g->setCommonLayerAxes();
3042+ connect(layersList.last(), SIGNAL(updatedLayout(Graph *)), g, SLOT(updateLayersLayout(Graph *)));
3043+ } else {
3044+ g->arrangeLayers(false, true);
3045+ foreach(Graph *ag, layersList){
3046+ if (ag->curveCount())
3047+ ag->newLegend();
3048+ }
3049+ }
3050+ return g;
3051+}
3052+
3053+MultiLayer* ApplicationWindow::waterfallPlot()
3054+{
3055+ Table *t = (Table *)activeWindow(TableWindow);
3056+ if (!t)
3057+ return 0;
3058+
3059+ return waterfallPlot(t, t->selectedYColumns());
3060+}
3061+
3062+MultiLayer* ApplicationWindow::waterfallPlot(Table *t, const QStringList& list)
3063+{
3064+ if (!t)
3065+ return 0;
3066+
3067+ int curves = list.count();
3068+ if(curves < 1){
3069+ QMessageBox::warning(this, tr("QtiPlot - Plot error"),
3070+ tr("Please select a Y column to plot!"));
3071+ return 0;
3072+ }
3073+
3074+ MultiLayer* ml = new MultiLayer(this, curves, 1, 1);
3075+ QList<Graph *> layersList = ml->layersList();
3076+ int i = 0;
3077+ foreach(Graph *g, layersList){
3078+ DataCurve *cv = g->insertCurve(t, list[i], Graph::Line);
3079+ if (cv)
3080+ cv->setPen(QPen(d_indexed_colors[i], defaultCurveLineWidth));
3081+ i++;
3082+ }
3083+ QString legend = QString();
3084+ initMultilayerPlot(ml, QString());
3085+ foreach(Graph *g, layersList){
3086+ g->hide();
3087+ legend += g->legendText(true) + "\n";
3088+ setPreferences(g);
3089+ g->setCanvasFrame(0);
3090+ g->setTitle(QString::null);
3091+ g->setMargin(0);
3092+ g->setFrame(0);
3093+ g->raise();
3094+ }
3095+
3096+ ml->setWaterfallLayout();
3097+ Graph *g = layersList.last();
3098+ if (g)
3099+ g->newLegend(legend.trimmed())->move(QPoint(5, 5));
3100+ return ml;
3101+}
3102+
3103+void ApplicationWindow::initMultilayerPlot(MultiLayer* g, const QString& name)
3104+{
3105+ QString label = name;
3106+ while(alreadyUsedName(label))
3107+ label = generateUniqueName(tr("Graph"));
3108+
3109+ g->setWindowTitle(label);
3110+ g->setName(label);
3111+ g->setIcon(QPixmap(":/graph.png"));
3112+ g->setScaleLayersOnPrint(d_scale_plots_on_print);
3113+ g->printCropmarks(d_print_cropmarks);
3114+
3115+ if (d_mdi_windows_area)
3116+ d_workspace->addSubWindow(g);
3117+ else
3118+ g->setParent(0);
3119+
3120+ connectMultilayerPlot(g);
3121+ g->showNormal();
3122+
3123+ addListViewItem(g);
3124+}
3125+
3126+void ApplicationWindow::setAutoUpdateTableValues(bool on)
3127+{
3128+ if (d_auto_update_table_values == on)
3129+ return;
3130+
3131+ d_auto_update_table_values = on;
3132+
3133+ Folder *f = projectFolder();
3134+ while (f){
3135+ QList<MdiSubWindow *> folderWindows = f->windowsList();
3136+ foreach(MdiSubWindow *w, folderWindows){
3137+ if (w->inherits("Table"))
3138+ ((Table *)w)->setAutoUpdateValues(d_auto_update_table_values);
3139+ }
3140+ f = f->folderBelow();
3141+ }
3142+}
3143+
3144+void ApplicationWindow::customTable(Table* w)
3145+{
3146+ QColorGroup cg;
3147+ cg.setColor(QColorGroup::Base, tableBkgdColor);
3148+ cg.setColor(QColorGroup::Text, tableTextColor);
3149+ w->setPalette(QPalette(cg, cg, cg));
3150+
3151+ w->setHeaderColor(tableHeaderColor);
3152+ w->setTextFont(tableTextFont);
3153+ w->setHeaderFont(tableHeaderFont);
3154+ w->showComments(d_show_table_comments);
3155+ w->setNumericPrecision(d_decimal_digits);
3156+}
3157+
3158+void ApplicationWindow::setPreferences(Graph* g)
3159+{
3160+ if (!g)
3161+ return;
3162+
3163+ if (!g->isPiePlot()){
3164+ for (int i = 0; i < QwtPlot::axisCnt; i++){
3165+ bool show = d_show_axes[i];
3166+ g->enableAxis(i, show);
3167+ if(show){
3168+ ScaleDraw *sd = (ScaleDraw *)g->axisScaleDraw (i);
3169+ sd->enableComponent(QwtAbstractScaleDraw::Labels, d_show_axes_labels[i]);
3170+ sd->setSpacing(d_graph_tick_labels_dist);
3171+ if (i == QwtPlot::yRight && !d_show_axes_labels[i])
3172+ g->setAxisTitle(i, tr(" "));
3173+ }
3174+ }
3175+
3176+ g->updateSecondaryAxis(QwtPlot::xTop);
3177+ g->updateSecondaryAxis(QwtPlot::yRight);
3178+
3179+ QList<int> ticksList;
3180+ ticksList<<majTicksStyle<<majTicksStyle<<majTicksStyle<<majTicksStyle;
3181+ g->setMajorTicksType(ticksList);
3182+ ticksList.clear();
3183+ ticksList<<minTicksStyle<<minTicksStyle<<minTicksStyle<<minTicksStyle;
3184+ g->setMinorTicksType(ticksList);
3185+
3186+ g->setTicksLength (minTicksLength, majTicksLength);
3187+ g->setAxesLinewidth(axesLineWidth);
3188+ g->drawAxesBackbones(drawBackbones);
3189+ g->setCanvasFrame(canvasFrameWidth, d_canvas_frame_color);
3190+ for (int i = 0; i < QwtPlot::axisCnt; i++)
3191+ g->setAxisTitleDistance(i, d_graph_axes_labels_dist);
3192+ }
3193+
3194+ g->setAxisTitlePolicy(d_graph_axis_labeling);
3195+ g->setSynchronizedScaleDivisions(d_synchronize_graph_scales);
3196+ g->initFonts(plotAxesFont, plotNumbersFont);
3197+ g->initTitle(titleOn, plotTitleFont);
3198+
3199+ g->setMargin(defaultPlotMargin);
3200+ g->enableAutoscaling(autoscale2DPlots);
3201+ g->setAutoscaleFonts(autoScaleFonts);
3202+ g->setAntialiasing(antialiasing2DPlots);
3203+ g->setFrame(d_graph_border_width, d_graph_border_color);
3204+
3205+ QColor c = d_graph_background_color;
3206+ c.setAlpha(d_graph_background_opacity);
3207+ g->setBackgroundColor(c);
3208+
3209+ c = d_graph_canvas_color;
3210+ c.setAlpha(d_graph_canvas_opacity);
3211+ g->setCanvasBackground(c);
3212+}
3213+
3214+/*
3215+ * return the current Plot (used for the Python interface)
3216+ */
3217+MultiLayer* ApplicationWindow::currentPlot()
3218+{
3219+ MultiLayer* p = (MultiLayer*)activeWindow(MultiLayerWindow);
3220+ return p;
3221+}
3222+
3223+/*
3224+ * return the current Table (used for the Python interface)
3225+ */
3226+Table* ApplicationWindow::currentTable()
3227+{
3228+ Table* w = (Table*)activeWindow(TableWindow);
3229+ return w;
3230+}
3231+
3232+/*
3233+ *creates a new empty table
3234+ */
3235+Table* ApplicationWindow::newTable()
3236+{
3237+ Table* w = new Table(scriptEnv, 30, 2, "", this, 0);
3238+ initTable(w, generateUniqueName(tr("Table")));
3239+ w->showNormal();
3240+ return w;
3241+}
3242+
3243+/*
3244+ *used when opening a project file
3245+ */
3246+Table* ApplicationWindow::newTable(const QString& caption, int r, int c)
3247+{
3248+ Table* w = new Table(scriptEnv, r, c, "", this, 0);
3249+ initTable(w, caption);
3250+ if (d_is_appending_file && w->objectName() != caption){//the table was renamed
3251+ renamedTables << caption << w->objectName();
3252+ if (d_inform_rename_table){
3253+ QApplication::restoreOverrideCursor();
3254+ QMessageBox:: warning(this, tr("QtiPlot - Renamed Window"),
3255+ tr("The table '%1' already exists. It has been renamed '%2'.").arg(caption).arg(w->objectName()));
3256+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3257+ }
3258+ }
3259+ w->showNormal();
3260+ return w;
3261+}
3262+
3263+Table* ApplicationWindow::newTable(int r, int c, const QString& name, const QString& legend)
3264+{
3265+ Table* w = new Table(scriptEnv, r, c, legend, this, 0);
3266+ initTable(w, name);
3267+ return w;
3268+}
3269+
3270+Table* ApplicationWindow::newHiddenTable(const QString& name, const QString& label, int r, int c, const QString& text)
3271+{
3272+ Table* w = new Table(scriptEnv, r, c, label, this, 0);
3273+
3274+ if (!text.isEmpty()) {
3275+ QStringList rows = text.split("\n", QString::SkipEmptyParts);
3276+ QStringList list = rows[0].split("\t");
3277+ w->setHeader(list);
3278+
3279+ QString rlist;
3280+ for (int i=0; i<r; i++){
3281+ rlist=rows[i+1];
3282+ list = rlist.split("\t");
3283+ for (int j=0; j<c; j++)
3284+ w->setText(i, j, list[j]);
3285+ }
3286+ }
3287+
3288+ initTable(w, name);
3289+ hideWindow(w);
3290+ return w;
3291+}
3292+
3293+void ApplicationWindow::initTable(Table* w, const QString& caption)
3294+{
3295+ QString name = caption;
3296+ name = name.replace ("_","-");
3297+
3298+ while(name.isEmpty() || alreadyUsedName(name))
3299+ name = generateUniqueName(tr("Table"));
3300+
3301+ if (d_mdi_windows_area)
3302+ d_workspace->addSubWindow(w);
3303+ else
3304+ w->setParent(0);
3305+
3306+ connectTable(w);
3307+ customTable(w);
3308+
3309+ w->setName(name);
3310+ w->setIcon(QPixmap(":/worksheet.png") );
3311+ addListViewItem(w);
3312+}
3313+
3314+/*
3315+ * !creates a new table with type statistics on target columns/rows of table base
3316+ */
3317+TableStatistics *ApplicationWindow::newTableStatistics(Table *base, int type, QList<int> target, const QString &caption)
3318+{
3319+ TableStatistics* s = new TableStatistics(scriptEnv, this, base, (TableStatistics::Type) type, target);
3320+ if (caption.isEmpty())
3321+ initTable(s, s->objectName());
3322+ else
3323+ initTable(s, caption);
3324+ s->showNormal();
3325+ return s;
3326+}
3327+
3328+/*
3329+ * return the current note (used for the Python interface)
3330+ */
3331+Note* ApplicationWindow::currentNote()
3332+{
3333+ Note* m = (Note*)activeWindow(NoteWindow);
3334+ return m;
3335+}
3336+
3337+/*
3338+ *creates a new empty note window
3339+ */
3340+Note* ApplicationWindow::newNote(const QString& caption)
3341+{
3342+ Note* m = new Note(scriptEnv, "", this);
3343+
3344+ QString name = caption;
3345+ while(name.isEmpty() || alreadyUsedName(name))
3346+ name = generateUniqueName(tr("Notes"));
3347+
3348+ m->setName(name);
3349+ m->setIcon(QPixmap(":/note.png"));
3350+ m->askOnCloseEvent(confirmCloseNotes);
3351+
3352+ if (d_mdi_windows_area)
3353+ d_workspace->addSubWindow(m);
3354+ else
3355+ m->setParent(0);
3356+
3357+ addListViewItem(m);
3358+
3359+ connect(m, SIGNAL(modifiedWindow(MdiSubWindow*)), this, SLOT(modifiedProject(MdiSubWindow*)));
3360+ connect(m, SIGNAL(resizedWindow(MdiSubWindow*)),this,SLOT(modifiedProject(MdiSubWindow*)));
3361+ connect(m, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(closeWindow(MdiSubWindow*)));
3362+ connect(m, SIGNAL(hiddenWindow(MdiSubWindow*)), this, SLOT(hideWindow(MdiSubWindow*)));
3363+ connect(m, SIGNAL(statusChanged(MdiSubWindow*)), this, SLOT(updateWindowStatus(MdiSubWindow*)));
3364+ connect(m, SIGNAL(dirPathChanged(const QString&)), this, SLOT(scriptsDirPathChanged(const QString&)));
3365+ connect(m, SIGNAL(currentEditorChanged()), this, SLOT(scriptingMenuAboutToShow()));
3366+
3367+ m->showNormal();
3368+ return m;
3369+}
3370+
3371+void ApplicationWindow::connectScriptEditor(ScriptEdit *editor)
3372+{
3373+ if (!editor)
3374+ return;
3375+
3376+ QTextDocument *doc = editor->document();
3377+ actionUndo->setEnabled(doc->isUndoAvailable());
3378+ actionRedo->setEnabled(doc->isRedoAvailable());
3379+
3380+ connect(editor, SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)));
3381+ connect(editor, SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)));
3382+}
3383+
3384+/*
3385+ * return the current Matrix (used for the Python interface)
3386+ */
3387+Matrix* ApplicationWindow::currentMatrix()
3388+{
3389+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3390+ return m;
3391+}
3392+
3393+Matrix* ApplicationWindow::newMatrix(int rows, int columns)
3394+{
3395+ Matrix* m = new Matrix(scriptEnv, rows, columns, "", this, 0);
3396+ initMatrix(m, generateUniqueName(tr("Matrix")));
3397+ m->showNormal();
3398+ return m;
3399+}
3400+
3401+Matrix* ApplicationWindow::newMatrix(const QString& caption, int r, int c)
3402+{
3403+ Matrix* w = new Matrix(scriptEnv, r, c, "", this, 0);
3404+ initMatrix(w, caption);
3405+ if (d_is_appending_file && w->objectName() != caption){//the matrix was renamed
3406+ renamedTables << caption << w->objectName();
3407+ if (d_inform_rename_table){
3408+ QApplication::restoreOverrideCursor();
3409+ QMessageBox:: warning(this, tr("QtiPlot - Renamed Window"),
3410+ tr("The table '%1' already exists. It has been renamed '%2'.").arg(caption).arg(w->objectName()));
3411+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3412+ }
3413+ }
3414+
3415+ w->showNormal();
3416+ return w;
3417+}
3418+
3419+void ApplicationWindow::viewMatrixImage()
3420+{
3421+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3422+ if (!m)
3423+ return;
3424+
3425+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3426+ m->undoStack()->push(new MatrixSetViewCommand(m, m->viewType(), Matrix::ImageView, tr("Set Image Mode")));
3427+ m->setViewType(Matrix::ImageView);
3428+ QApplication::restoreOverrideCursor();
3429+}
3430+
3431+void ApplicationWindow::viewMatrixTable()
3432+{
3433+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3434+ if (!m)
3435+ return;
3436+
3437+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3438+ m->undoStack()->push(new MatrixSetViewCommand(m, m->viewType(), Matrix::TableView, tr("Set Data Mode")));
3439+ m->setViewType(Matrix::TableView);
3440+ QApplication::restoreOverrideCursor();
3441+}
3442+
3443+void ApplicationWindow::viewMatrixXY()
3444+{
3445+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3446+ if (!m)
3447+ return;
3448+
3449+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3450+ m->undoStack()->push(new MatrixSetHeaderViewCommand(m, m->headerViewType(), Matrix::XY, tr("Show X/Y")));
3451+ m->setHeaderViewType(Matrix::XY);
3452+ QApplication::restoreOverrideCursor();
3453+}
3454+
3455+void ApplicationWindow::viewMatrixColumnRow()
3456+{
3457+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3458+ if (!m)
3459+ return;
3460+
3461+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3462+ m->undoStack()->push(new MatrixSetHeaderViewCommand(m, m->headerViewType(), Matrix::ColumnRow, tr("Show Column/Row")));
3463+ m->setHeaderViewType(Matrix::ColumnRow);
3464+ QApplication::restoreOverrideCursor();
3465+}
3466+
3467+void ApplicationWindow::setMatrixDefaultScale()
3468+{
3469+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3470+ if (!m)
3471+ return;
3472+
3473+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3474+ m->undoStack()->push(new MatrixSetColorMapCommand(m, m->colorMapType(), m->colorMap(),
3475+ Matrix::Default, QwtLinearColorMap(), tr("Set Default Palette")));
3476+ m->setDefaultColorMap();
3477+ QApplication::restoreOverrideCursor();
3478+}
3479+
3480+void ApplicationWindow::setMatrixGrayScale()
3481+{
3482+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3483+ if (!m)
3484+ return;
3485+
3486+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3487+ m->undoStack()->push(new MatrixSetColorMapCommand(m, m->colorMapType(), m->colorMap(),
3488+ Matrix::GrayScale, QwtLinearColorMap(), tr("Set Gray Scale Palette")));
3489+ m->setGrayScale();
3490+ QApplication::restoreOverrideCursor();
3491+}
3492+
3493+void ApplicationWindow::setMatrixRainbowScale()
3494+{
3495+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3496+ if (!m)
3497+ return;
3498+
3499+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3500+ m->undoStack()->push(new MatrixSetColorMapCommand(m, m->colorMapType(), m->colorMap(),
3501+ Matrix::Rainbow, QwtLinearColorMap(), tr("Set Rainbow Palette")));
3502+ m->setRainbowColorMap();
3503+ QApplication::restoreOverrideCursor();
3504+}
3505+
3506+void ApplicationWindow::showColorMapDialog()
3507+{
3508+ Matrix* m = static_cast<Matrix*>(activeWindow(MatrixWindow));
3509+ if (!m)
3510+ return;
3511+
3512+ ColorMapDialog *cmd = new ColorMapDialog(this);
3513+ cmd->setAttribute(Qt::WA_DeleteOnClose);
3514+ cmd->setMatrix(m);
3515+ cmd->exec();
3516+}
3517+
3518+void ApplicationWindow::transposeMatrix()
3519+{
3520+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3521+ if (!m)
3522+ return;
3523+
3524+ m->transpose();
3525+}
3526+
3527+void ApplicationWindow::flipMatrixVertically()
3528+{
3529+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3530+ if (!m)
3531+ return;
3532+
3533+ m->flipVertically();
3534+}
3535+
3536+void ApplicationWindow::flipMatrixHorizontally()
3537+{
3538+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3539+ if (!m)
3540+ return;
3541+
3542+ m->flipHorizontally();
3543+}
3544+
3545+void ApplicationWindow::rotateMatrix90()
3546+{
3547+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3548+ if (!m)
3549+ return;
3550+
3551+ m->rotate90();
3552+}
3553+
3554+void ApplicationWindow::rotateMatrixMinus90()
3555+{
3556+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3557+ if (!m)
3558+ return;
3559+
3560+ m->rotate90(false);
3561+}
3562+
3563+void ApplicationWindow::matrixDeterminant()
3564+{
3565+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3566+ if (!m)
3567+ return;
3568+
3569+ QDateTime dt = QDateTime::currentDateTime ();
3570+ QString info=dt.toString(Qt::LocalDate);
3571+ info+= "\n" + tr("Determinant of ") + QString(m->objectName()) + ":\t";
3572+ info+= "det = " + QString::number(m->determinant()) + "\n";
3573+ info+="-------------------------------------------------------------\n";
3574+
3575+ current_folder->appendLogInfo(info);
3576+
3577+ showResults(true);
3578+}
3579+
3580+void ApplicationWindow::invertMatrix()
3581+{
3582+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3583+ if (!m)
3584+ return;
3585+
3586+ m->invert();
3587+}
3588+
3589+Table* ApplicationWindow::convertMatrixToTableDirect()
3590+{
3591+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3592+ if (!m)
3593+ return 0;
3594+
3595+ return matrixToTable(m, Direct);
3596+}
3597+
3598+Table* ApplicationWindow::convertMatrixToTableXYZ()
3599+{
3600+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3601+ if (!m)
3602+ return 0;
3603+
3604+ return matrixToTable(m, XYZ);
3605+}
3606+
3607+Table* ApplicationWindow::convertMatrixToTableYXZ()
3608+{
3609+ Matrix* m = (Matrix*)activeWindow(MatrixWindow);
3610+ if (!m)
3611+ return 0;
3612+
3613+ return matrixToTable(m, YXZ);
3614+}
3615+
3616+Table* ApplicationWindow::matrixToTable(Matrix* m, MatrixToTableConversion conversionType)
3617+{
3618+ if (!m)
3619+ return 0;
3620+
3621+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3622+
3623+ int rows = m->numRows();
3624+ int cols = m->numCols();
3625+ MatrixModel *mModel = m->matrixModel();
3626+
3627+ Table* w = NULL;
3628+ if (conversionType == Direct){
3629+ w = new Table(scriptEnv, rows, cols, "", this, 0);
3630+ for (int i = 0; i<rows; i++){
3631+ for (int j = 0; j<cols; j++)
3632+ w->setCell(i, j, m->cell(i,j));
3633+ }
3634+ } else if (conversionType == XYZ){
3635+ int tableRows = rows*cols;
3636+ w = new Table(scriptEnv, tableRows, 3, "", this, 0);
3637+ for (int i = 0; i<rows; i++){
3638+ for (int j = 0; j<cols; j++){
3639+ int cell = i*cols + j;
3640+ w->setCell(cell, 0, mModel->x(j));
3641+ w->setCell(cell, 1, mModel->y(i));
3642+ w->setCell(cell, 2, mModel->cell(i, j));
3643+ }
3644+ }
3645+ } else if (conversionType == YXZ){
3646+ int tableRows = rows*cols;
3647+ w = new Table(scriptEnv, tableRows, 3, "", this, 0);
3648+ for (int i = 0; i<cols; i++){
3649+ for (int j = 0; j<rows; j++){
3650+ int cell = i*rows + j;
3651+ w->setCell(cell, 0, mModel->x(i));
3652+ w->setCell(cell, 1, mModel->y(j));
3653+ w->setCell(cell, 2, mModel->cell(i, j));
3654+ }
3655+ }
3656+ }
3657+
3658+
3659+ initTable(w, generateUniqueName(tr("Table")));
3660+ w->setWindowLabel(m->windowLabel());
3661+ w->setCaptionPolicy(m->captionPolicy());
3662+ w->resize(m->size());
3663+ w->showNormal();
3664+
3665+ QApplication::restoreOverrideCursor();
3666+ return w;
3667+}
3668+
3669+void ApplicationWindow::initMatrix(Matrix* m, const QString& caption)
3670+{
3671+ QString name = caption;
3672+ while(alreadyUsedName(name)){name = generateUniqueName(tr("Matrix"));}
3673+
3674+ m->setWindowTitle(name);
3675+ m->setName(name);
3676+ m->setIcon( QPixmap(":/matrix.png") );
3677+ m->askOnCloseEvent(confirmCloseMatrix);
3678+ m->setNumericPrecision(d_decimal_digits);
3679+
3680+ if (d_mdi_windows_area)
3681+ d_workspace->addSubWindow(m);
3682+ else
3683+ m->setParent(0);
3684+
3685+ addListViewItem(m);
3686+
3687+ QUndoStack *stack = m->undoStack();
3688+ connect(stack, SIGNAL(canUndoChanged(bool)), actionUndo, SLOT(setEnabled(bool)));
3689+ connect(stack, SIGNAL(canRedoChanged(bool)), actionRedo, SLOT(setEnabled(bool)));
3690+ connect(m, SIGNAL(modifiedWindow(MdiSubWindow*)), this, SLOT(modifiedProject(MdiSubWindow*)));
3691+ connect(m, SIGNAL(modifiedData(Matrix*)), this, SLOT(updateMatrixPlots(Matrix *)));
3692+ connect(m, SIGNAL(resizedWindow(MdiSubWindow*)),this,SLOT(modifiedProject(MdiSubWindow*)));
3693+ connect(m, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(closeWindow(MdiSubWindow*)));
3694+ connect(m, SIGNAL(hiddenWindow(MdiSubWindow*)), this, SLOT(hideWindow(MdiSubWindow*)));
3695+ connect(m, SIGNAL(statusChanged(MdiSubWindow*)),this, SLOT(updateWindowStatus(MdiSubWindow*)));
3696+ connect(m, SIGNAL(showContextMenu()), this, SLOT(showWindowContextMenu()));
3697+
3698+ emit modified();
3699+}
3700+
3701+void ApplicationWindow::showBinMatrixDialog()
3702+{
3703+ Table* t = (Table*)activeWindow(TableWindow);
3704+ if (!t)
3705+ return;
3706+
3707+ Q3TableSelection sel = t->getSelection();
3708+ if (t->selectedYColumns().size() != 1 || fabs(sel.topRow() - sel.bottomRow()) < 2){
3709+ QMessageBox::warning(this, tr("QtiPlot - Column selection error"),
3710+ tr("You must select a single Y column that has an associated X column!"));
3711+ return;
3712+ }
3713+
3714+ CreateBinMatrixDialog *cbmd = new CreateBinMatrixDialog(t, sel.topRow(), sel.bottomRow(), this);
3715+ cbmd->exec();
3716+}
3717+
3718+Matrix* ApplicationWindow::convertTableToMatrixRegularXYZ()
3719+{
3720+ Table* t = (Table*)activeWindow(TableWindow);
3721+ if (!t)
3722+ return 0;
3723+
3724+ Q3TableSelection sel = t->getSelection();
3725+ if (t->selectedColumns().size() != 1 ||
3726+ t->colPlotDesignation(t->colIndex(t->selectedColumns()[0])) != Table::Z ||
3727+ fabs(sel.topRow() - sel.bottomRow()) < 2){
3728+ QMessageBox::warning(this, tr("QtiPlot - Column selection error"),
3729+ tr("You must select exactly one Z column!"));
3730+ return 0;
3731+ }
3732+
3733+ int zcol = t->colIndex(t->selectedColumns()[0]);
3734+ int ycol = t->colY(zcol);
3735+ int xcol = t->colX(ycol);
3736+
3737+ int cells = 0;
3738+ int startRow = sel.topRow();
3739+ int endRow = sel.bottomRow();
3740+ for (int i = startRow; i <= endRow; i++){
3741+ QString xs = t->text(i, xcol);
3742+ QString ys = t->text(i, ycol);
3743+ QString zs = t->text(i, zcol);
3744+ if (!xs.isEmpty() && !ys.isEmpty() && !zs.isEmpty())
3745+ cells++;
3746+ }
3747+
3748+ if (!cells)
3749+ return 0;
3750+
3751+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3752+
3753+ QLocale locale = this->locale();
3754+ bool xVariesFirst = false;
3755+ int firstValidRow = sel.topRow();
3756+ double x0 = 0.0, y0 = 0.0, xstart = 0.0, ystart = 0.0;
3757+ double tolerance = 0.15;
3758+ for (int i = startRow; i <= endRow; i++){
3759+ QString xs = t->text(i, xcol);
3760+ QString ys = t->text(i, ycol);
3761+ QString zs = t->text(i, zcol);
3762+ if (!xs.isEmpty() && !ys.isEmpty() && !zs.isEmpty()){
3763+ x0 = locale.toDouble(xs);
3764+ y0 = locale.toDouble(ys);
3765+ xstart = x0;
3766+ ystart = y0;
3767+ firstValidRow = i;
3768+
3769+ for (int j = i + 1; j <= endRow; j++){
3770+ xs = t->text(j, xcol);
3771+ ys = t->text(j, ycol);
3772+ zs = t->text(j, zcol);
3773+ if (!xs.isEmpty() && !ys.isEmpty() && !zs.isEmpty()){
3774+ double x = locale.toDouble(xs);
3775+ double y = locale.toDouble(ys);
3776+ if (fabs(x - x0) > tolerance*x0 && fabs(y - y0) <= tolerance*y0)
3777+ xVariesFirst = true;
3778+ break;
3779+ }
3780+ }
3781+ break;
3782+ }
3783+ }
3784+
3785+ int rows = 0;
3786+ int cols = 0;
3787+ for (int i = firstValidRow; i <= endRow; i++){
3788+ QString xs = t->text(i, xcol);
3789+ QString ys = t->text(i, ycol);
3790+ QString zs = t->text(i, zcol);
3791+ if (!xs.isEmpty() && !ys.isEmpty() && !zs.isEmpty()){
3792+ double x = locale.toDouble(xs);
3793+ double y = locale.toDouble(ys);
3794+ if (xVariesFirst){
3795+ if (fabs(y - y0) <= tolerance*y0){
3796+ cols++;
3797+ y0 = y;
3798+ } else
3799+ break;
3800+ } else {
3801+ if (fabs(x - x0) <= tolerance*x0){
3802+ rows++;
3803+ x0 = x;
3804+ } else
3805+ break;
3806+ }
3807+ }
3808+ }
3809+
3810+ if (rows)
3811+ cols = cells/rows;
3812+ else
3813+ rows = cells/cols;
3814+
3815+ double xend = xstart, yend = ystart;
3816+ Matrix* m = newMatrix(rows, cols);
3817+ for (int i = startRow; i <= endRow; i++){
3818+ QString xs = t->text(i, xcol);
3819+ QString ys = t->text(i, ycol);
3820+ QString zs = t->text(i, zcol);
3821+ if (!xs.isEmpty() && !ys.isEmpty() && !zs.isEmpty()){
3822+ int row = 0, col = 0;
3823+ if (xVariesFirst){
3824+ col = i%cols;
3825+ row = i/cols;
3826+ } else {
3827+ row = i%rows;
3828+ col = i/rows;
3829+ }
3830+
3831+ double x = locale.toDouble(xs);
3832+ double y = locale.toDouble(ys);
3833+ if (x > xend)
3834+ xend = x;
3835+ if (y > yend)
3836+ yend = y;
3837+
3838+ m->setCell(row, col, locale.toDouble(zs));
3839+ }
3840+ }
3841+
3842+ m->setCoordinates(QMIN(xstart, xend), QMAX(xstart, xend), QMIN(ystart, yend), QMAX(ystart, yend));
3843+
3844+ QApplication::restoreOverrideCursor();
3845+ return m;
3846+}
3847+
3848+Matrix* ApplicationWindow::convertTableToMatrix()
3849+{
3850+ Table* t = (Table*)activeWindow(TableWindow);
3851+ if (!t)
3852+ return 0;
3853+
3854+ return tableToMatrix (t);
3855+}
3856+
3857+Matrix* ApplicationWindow::tableToMatrix(Table* t)
3858+{
3859+ if (!t)
3860+ return 0;
3861+
3862+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3863+
3864+ int rows = t->numRows();
3865+ int cols = t->numCols();
3866+
3867+ Matrix* m = newMatrix(rows, cols);
3868+ for (int i = 0; i<rows; i++){
3869+ for (int j = 0; j<cols; j++)
3870+ m->setCell(i, j, t->cell(i, j));
3871+ }
3872+
3873+ m->showNormal();
3874+
3875+ QApplication::restoreOverrideCursor();
3876+ return m;
3877+}
3878+
3879+MdiSubWindow* ApplicationWindow::window(const QString& name)
3880+{
3881+ QList<MdiSubWindow *> windows = windowsList();
3882+ foreach(MdiSubWindow *w, windows){
3883+ if (w->objectName() == name)
3884+ return w;
3885+ }
3886+ return NULL;
3887+}
3888+
3889+Table* ApplicationWindow::table(const QString& name)
3890+{
3891+ int pos = name.find("_", 0);
3892+ QString caption = name.left(pos);
3893+
3894+ Folder *f = projectFolder();
3895+ while (f){
3896+ QList<MdiSubWindow *> folderWindows = f->windowsList();
3897+ foreach(MdiSubWindow *w, folderWindows){
3898+ if (w->inherits("Table") && w->objectName() == caption)
3899+ return (Table*)w;
3900+ }
3901+ f = f->folderBelow();
3902+ }
3903+
3904+ return 0;
3905+}
3906+
3907+Matrix* ApplicationWindow::matrix(const QString& name)
3908+{
3909+ QString caption = name;
3910+ if (d_is_appending_file && !renamedTables.isEmpty() && renamedTables.contains(caption)){
3911+ int index = renamedTables.findIndex(caption);
3912+ caption = renamedTables[index + 1];
3913+ }
3914+
3915+ Folder *f = projectFolder();
3916+ while (f){
3917+ QList<MdiSubWindow *> folderWindows = f->windowsList();
3918+ foreach(MdiSubWindow *w, folderWindows){
3919+ if (w->isA("Matrix") && w->objectName() == caption)
3920+ return (Matrix*)w;
3921+ }
3922+ f = f->folderBelow();
3923+ }
3924+ return 0;
3925+}
3926+
3927+MdiSubWindow *ApplicationWindow::activeWindow(WindowType type)
3928+{
3929+ if (!d_active_window){
3930+ QList<MdiSubWindow *> windows = current_folder->windowsList();
3931+ if (!current_folder->activeWindow() && windows.size() > 0){
3932+ d_active_window = windows[0];
3933+ } else
3934+ return NULL;
3935+ }
3936+
3937+ switch(type){
3938+ case NoWindow:
3939+ break;
3940+
3941+ case TableWindow:
3942+ if (d_active_window->inherits("Table"))
3943+ return d_active_window;
3944+ else
3945+ return NULL;
3946+ break;
3947+
3948+ case MatrixWindow:
3949+ return qobject_cast<Matrix *>(d_active_window);
3950+ break;
3951+
3952+ case MultiLayerWindow:
3953+ return qobject_cast<MultiLayer *>(d_active_window);
3954+ break;
3955+
3956+ case NoteWindow:
3957+ return qobject_cast<Note *>(d_active_window);
3958+ break;
3959+
3960+ case Plot3DWindow:
3961+ return qobject_cast<Graph3D *>(d_active_window);
3962+ break;
3963+ }
3964+ return d_active_window;
3965+}
3966+
3967+void ApplicationWindow::windowActivated(QMdiSubWindow *w)
3968+{
3969+ MdiSubWindow *window = qobject_cast<MdiSubWindow *>(w);
3970+ if (!window)
3971+ return;
3972+
3973+ if (d_active_window && d_active_window == window)
3974+ return;
3975+
3976+ d_active_window = window;
3977+
3978+ customToolBars(window);
3979+ customMenu(window);
3980+
3981+ if (d_opening_file)
3982+ return;
3983+
3984+ QList<MdiSubWindow *> windows = current_folder->windowsList();
3985+ foreach(MdiSubWindow *ow, windows){
3986+ if (ow != window && ow->status() == MdiSubWindow::Maximized){
3987+ ow->setNormal();
3988+ break;
3989+ }
3990+ }
3991+
3992+ Folder *f = window->folder();
3993+ if (f)
3994+ f->setActiveWindow(window);
3995+
3996+ emit modified();
3997+}
3998+
3999+void ApplicationWindow::addErrorBars()
4000+{
4001+ MdiSubWindow *w = activeWindow(MultiLayerWindow);
4002+ if (!w)
4003+ return;
4004+
4005+ MultiLayer* plot = (MultiLayer*)w;
4006+ if (plot->isEmpty()){
4007+ QMessageBox::warning(this,tr("QtiPlot - Warning"),
4008+ tr("<h4>There are no plot layers available in this window.</h4>"
4009+ "<p><h4>Please add a layer and try again!</h4>"));
4010+ return;
4011+ }
4012+
4013+ Graph* g = (Graph*)plot->activeLayer();
4014+ if (!g)
4015+ return;
4016+
4017+ if (!g->curveCount()){
4018+ QMessageBox::warning(this, tr("QtiPlot - Warning"), tr("There are no curves available on this plot!"));
4019+ return;
4020+ }
4021+
4022+ if (g->isPiePlot()){
4023+ QMessageBox::warning(this, tr("QtiPlot - Warning"), tr("This functionality is not available for pie plots!"));
4024+ return;
4025+ }
4026+
4027+ ErrDialog* ed = new ErrDialog(this);
4028+ connect (ed, SIGNAL(options(const QString&, int, double, int)), this, SLOT(defineErrorBars(const QString&, int, double, int)));
4029+ connect (ed, SIGNAL(options(const QString&, const QString&, int)), this, SLOT(defineErrorBars(const QString&, const QString&, int)));
4030+
4031+ ed->setCurveNames(g->analysableCurvesList());
4032+ ed->setSrcTables(tableList());
4033+ ed->exec();
4034+}
4035+
4036+void ApplicationWindow::defineErrorBars(const QString& name, int type, double percent, int direction)
4037+{
4038+ MdiSubWindow *w = activeWindow(MultiLayerWindow);
4039+ if (!w)
4040+ return;
4041+
4042+ Graph* g = ((MultiLayer*)w)->activeLayer();
4043+ if (!g)
4044+ return;
4045+
4046+ Table *t = table(name);
4047+ if (!t){//user defined function
4048+ QMessageBox::critical(this, tr("QtiPlot - Error bars error"),
4049+ tr("This feature is not available for user defined function curves!"));
4050+ return;
4051+ }
4052+
4053+ DataCurve *master_curve = (DataCurve *)g->curve(name);
4054+ QString xColName = master_curve->xColumnName();
4055+ if (xColName.isEmpty())
4056+ return;
4057+
4058+ if (direction == QwtErrorPlotCurve::Horizontal)
4059+ t->addCol(Table::xErr);
4060+ else
4061+ t->addCol(Table::yErr);
4062+
4063+ int r = master_curve->dataSize();
4064+ int rows = t->numRows();
4065+ int c = t->numCols() - 1;
4066+ int ycol = t->colIndex(name);
4067+ if (!direction)
4068+ ycol = t->colIndex(xColName);
4069+
4070+ QVarLengthArray<double> Y(r);
4071+ if (direction == QwtErrorPlotCurve::Horizontal){
4072+ for (int i = 0; i < r; i++)
4073+ Y[i] = master_curve->x(i);
4074+ } else {
4075+ for (int i = 0; i < r; i++)
4076+ Y[i] = master_curve->y(i);
4077+ }
4078+
4079+ QString errColName = t->colName(c);
4080+
4081+ if (type == 0){
4082+ double prc = 0.01*percent;
4083+ int aux = 0;
4084+ for (int i = 0; i < rows; i++){
4085+ if (!t->text(i, ycol).isEmpty() && aux < r){
4086+ t->setCell(i, c, Y[aux]*prc);
4087+ aux++;
4088+ }
4089+ }
4090+ } else if (type == 1) {
4091+ double sd = gsl_stats_sd(Y.data(), 1, r);
4092+ for (int i = 0; i < rows; i++){
4093+ if (!t->text(i, ycol).isEmpty())
4094+ t->setCell(i, c, sd);
4095+ }
4096+ }
4097+ QwtErrorPlotCurve *er = g->addErrorBars(xColName, name, t, errColName, direction);
4098+ if (er){
4099+ er->setColor(master_curve->pen().color());
4100+ g->replot();
4101+ emit modified();
4102+ }
4103+}
4104+
4105+void ApplicationWindow::defineErrorBars(const QString& curveName, const QString& errColumnName, int direction)
4106+{
4107+ Table *w = table(curveName);
4108+ if (!w){//user defined function --> no worksheet available
4109+ QMessageBox::critical(this,tr("QtiPlot - Error"),
4110+ tr("This feature is not available for user defined function curves!"));
4111+ return;
4112+ }
4113+
4114+ Table *errTable = table(errColumnName);
4115+ if (w->numRows() != errTable->numRows()){
4116+ QMessageBox::critical(this,tr("QtiPlot - Error"), tr("The selected columns have different numbers of rows!"));
4117+ addErrorBars();
4118+ return;
4119+ }
4120+
4121+ int errCol = errTable->colIndex(errColumnName);
4122+ if (errTable->isEmptyColumn(errCol)){
4123+ QMessageBox::critical(this, tr("QtiPlot - Error"), tr("The selected error column is empty!"));
4124+ addErrorBars();
4125+ return;
4126+ }
4127+
4128+ MultiLayer *plot = (MultiLayer *)activeWindow(MultiLayerWindow);
4129+ if (!plot)
4130+ return;
4131+
4132+ Graph* g = plot->activeLayer();
4133+ if (!g)
4134+ return;
4135+
4136+ QwtErrorPlotCurve *er = g->addErrorBars(curveName, errTable, errColumnName, direction);
4137+ if (er){
4138+ DataCurve *mc = er->masterCurve();
4139+ if (mc){
4140+ er->setColor(mc->pen().color());
4141+ g->replot();
4142+ }
4143+ emit modified();
4144+ }
4145+}
4146+
4147+void ApplicationWindow::removeCurves(const QString& name)
4148+{
4149+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
4150+
4151+ QList<MdiSubWindow *> windows = windowsList();
4152+ foreach(MdiSubWindow *w, windows){
4153+ if (w->isA("MultiLayer")){
4154+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
4155+ foreach(Graph *g, layers)
4156+ g->removeCurves(name);
4157+ } else if (w->isA("Graph3D")){
4158+ if ( (((Graph3D*)w)->formula()).contains(name) )
4159+ ((Graph3D*)w)->clearData();
4160+ }
4161+ }
4162+ QApplication::restoreOverrideCursor();
4163+}
4164+
4165+void ApplicationWindow::updateCurves(Table *t, const QString& name)
4166+{
4167+ QList<MdiSubWindow *> windows = windowsList();
4168+ foreach(MdiSubWindow *w, windows){
4169+ if (w->isA("MultiLayer")){
4170+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
4171+ foreach(Graph *g, layers)
4172+ g->updateCurvesData(t, name);
4173+ } else if (w->isA("Graph3D")){
4174+ Graph3D* g = (Graph3D*)w;
4175+ if ((g->formula()).contains(name))
4176+ g->updateData(t);
4177+ }
4178+ }
4179+}
4180+
4181+void ApplicationWindow::showPreferencesDialog()
4182+{
4183+ ConfigDialog* cd = new ConfigDialog(this);
4184+ cd->setColumnSeparator(columnSeparator);
4185+ cd->exec();
4186+}
4187+
4188+void ApplicationWindow::setSaveSettings(bool autoSaving, int min)
4189+{
4190+ if (autoSave==autoSaving && autoSaveTime==min)
4191+ return;
4192+
4193+ autoSave=autoSaving;
4194+ autoSaveTime=min;
4195+
4196+ killTimer(savingTimerId);
4197+
4198+ if (autoSave)
4199+ savingTimerId=startTimer(autoSaveTime*60000);
4200+ else
4201+ savingTimerId=0;
4202+}
4203+
4204+void ApplicationWindow::changeAppStyle(const QString& s)
4205+{
4206+ // style keys are case insensitive
4207+ if (appStyle.toLower() == s.toLower())
4208+ return;
4209+
4210+ qApp->setStyle(s);
4211+ appStyle = qApp->style()->objectName();
4212+
4213+ QPalette pal = qApp->palette();
4214+ pal.setColor (QPalette::Active, QPalette::Base, QColor(panelsColor));
4215+ qApp->setPalette(pal);
4216+
4217+}
4218+
4219+void ApplicationWindow::changeAppFont(const QFont& f)
4220+{
4221+ if (appFont == f)
4222+ return;
4223+
4224+ appFont = f;
4225+ updateAppFonts();
4226+}
4227+
4228+void ApplicationWindow::updateAppFonts()
4229+{
4230+ qApp->setFont(appFont);
4231+ this->setFont(appFont);
4232+ info->setFont(QFont(appFont.family(), 2 + appFont.pointSize(), QFont::Bold,false));
4233+}
4234+
4235+void ApplicationWindow::updateConfirmOptions(bool askTables, bool askMatrices, bool askPlots2D,
4236+ bool askPlots3D, bool askNotes)
4237+{
4238+ QList<MdiSubWindow *> windows = windowsList();
4239+
4240+
4241+ if (confirmCloseTable != askTables){
4242+ confirmCloseTable=askTables;
4243+ foreach(MdiSubWindow *w, windows){
4244+ if (w->inherits("Table"))
4245+ w->askOnCloseEvent(confirmCloseTable);
4246+ }
4247+ }
4248+
4249+ if (confirmCloseMatrix != askMatrices){
4250+ confirmCloseMatrix = askMatrices;
4251+ foreach(MdiSubWindow *w, windows){
4252+ if (w->isA("Matrix"))
4253+ w->askOnCloseEvent(confirmCloseMatrix);
4254+ }
4255+ }
4256+
4257+ if (confirmClosePlot2D != askPlots2D){
4258+ confirmClosePlot2D=askPlots2D;
4259+ foreach(MdiSubWindow *w, windows){
4260+ if (w->isA("MultiLayer"))
4261+ w->askOnCloseEvent(confirmClosePlot2D);
4262+ }
4263+ }
4264+
4265+ if (confirmClosePlot3D != askPlots3D){
4266+ confirmClosePlot3D=askPlots3D;
4267+ foreach(MdiSubWindow *w, windows){
4268+ if (w->isA("Graph3D"))
4269+ w->askOnCloseEvent(confirmClosePlot3D);
4270+ }
4271+ }
4272+
4273+ if (confirmCloseNotes != askNotes){
4274+ confirmCloseNotes = askNotes;
4275+ foreach(MdiSubWindow *w, windows){
4276+ if (w->isA("Note"))
4277+ w->askOnCloseEvent(confirmCloseNotes);
4278+ }
4279+ }
4280+}
4281+
4282+void ApplicationWindow::setGraphDefaultSettings(bool autoscale, bool scaleFonts,
4283+ bool resizeLayers, bool antialiasing)
4284+{
4285+ if (autoscale2DPlots == autoscale &&
4286+ autoScaleFonts == scaleFonts &&
4287+ autoResizeLayers != resizeLayers &&
4288+ antialiasing2DPlots == antialiasing)
4289+ return;
4290+
4291+ autoscale2DPlots = autoscale;
4292+ autoScaleFonts = scaleFonts;
4293+ autoResizeLayers = !resizeLayers;
4294+ antialiasing2DPlots = antialiasing;
4295+
4296+ QList<MdiSubWindow *> windows = windowsList();
4297+ foreach(MdiSubWindow *w, windows){
4298+ if (w->isA("MultiLayer")){
4299+ ((MultiLayer*)w)->setScaleLayersOnResize(autoResizeLayers);
4300+ QList<Graph *> layers = ((MultiLayer*)w)->layersList();
4301+ foreach(Graph *g, layers){
4302+ g->enableAutoscaling(autoscale2DPlots);
4303+ g->updateScale();
4304+ g->setAutoscaleFonts(autoScaleFonts);
4305+ g->setAntialiasing(antialiasing2DPlots);
4306+ }
4307+ }
4308+ }
4309+}
4310+
4311+void ApplicationWindow::setArrowDefaultSettings(double lineWidth, const QColor& c, Qt::PenStyle style,
4312+ int headLength, int headAngle, bool fillHead)
4313+{
4314+ if (defaultArrowLineWidth == lineWidth &&
4315+ defaultArrowColor == c &&
4316+ defaultArrowLineStyle == style &&
4317+ defaultArrowHeadLength == headLength &&
4318+ defaultArrowHeadAngle == headAngle &&
4319+ defaultArrowHeadFill == fillHead)
4320+ return;
4321+
4322+ defaultArrowLineWidth = lineWidth;
4323+ defaultArrowColor = c;
4324+ defaultArrowLineStyle = style;
4325+ defaultArrowHeadLength = headLength;
4326+ defaultArrowHeadAngle = headAngle;
4327+ defaultArrowHeadFill = fillHead;
4328+ saveSettings();
4329+}
4330+
4331+ApplicationWindow * ApplicationWindow::plotFile(const QString& fn)
4332+{
4333+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
4334+ ApplicationWindow *app = new ApplicationWindow();
4335+ app->restoreApplicationGeometry();
4336+
4337+ QList<QByteArray> lst = QImageReader::supportedImageFormats() << "JPG";
4338+ QStringList tempList;
4339+ foreach(QByteArray temp,lst)// convert QList<QByteArray> to QStringList to be able to 'filter'
4340+ tempList.append(QString(temp));
4341+
4342+ QFileInfo fi(fn);
4343+ QStringList l = tempList.filter(fi.suffix(), Qt::CaseInsensitive);
4344+ if (l.count() > 0)
4345+ app->importImage(fn);
4346+ else {
4347+ Table* t = app->newTable();
4348+ if (!t) {
4349+ QApplication::restoreOverrideCursor();
4350+ return NULL;
4351+ }
4352+ t->importASCII(fn, app->columnSeparator, 0, app->renameColumns, app->strip_spaces, app->simplify_spaces,
4353+ app->d_ASCII_import_comments, app->d_ASCII_comment_string,
4354+ app->d_ASCII_import_read_only, Table::Overwrite, app->d_ASCII_import_locale, app->d_ASCII_end_line);
4355+ t->setCaptionPolicy(MdiSubWindow::Both);
4356+ app->multilayerPlot(t, t->YColumns(), defaultCurveStyle);
4357+ }
4358+
4359+ QApplication::restoreOverrideCursor();
4360+ savedProject();//force saved state
4361+ close();
4362+ return app;
4363+}
4364+
4365+Table * ApplicationWindow::importOdfSpreadsheet(const QString& fileName, int sheet)
4366+{
4367+#ifdef ODS_IMPORT
4368+ QString fn = fileName;
4369+ if (fn.isEmpty()){
4370+ fn = getFileName(this, tr("Open ODF Spreadsheet File"), QString::null, "*.ods", 0, false);
4371+ if (fn.isEmpty())
4372+ return NULL;
4373+ }
4374+
4375+ QuaZipFile file(fn, "content.xml");
4376+ if(!file.open(QIODevice::ReadOnly)){
4377+ QMessageBox::critical(this, tr("QtiPlot"), tr("Couldn't open file %1").arg(fn));
4378+ return NULL;
4379+ }
4380+ QTemporaryFile out;
4381+ if (out.open()){
4382+ char c;
4383+ while(file.getChar(&c))
4384+ out.putChar(c);
4385+ out.close();
4386+ }
4387+ file.close();
4388+
4389+ OdsFileHandler handler(this, fn);
4390+ QXmlSimpleReader reader;
4391+ reader.setContentHandler(&handler);
4392+ reader.setErrorHandler(&handler);
4393+
4394+ QXmlInputSource xmlInputSource(&out);
4395+ if (reader.parse(xmlInputSource)){
4396+ int sheets = handler.sheetsCount();
4397+ if (sheet > sheets){
4398+ QMessageBox::critical(this, tr("QtiPlot"), tr("File %1 contains only %2 sheets!").arg(fn).arg(sheets));
4399+ } else if (sheet > 0){
4400+ Table *aux = NULL;
4401+ for (int i = 0; i < sheets; i++){
4402+ Table *t = handler.sheet(i);
4403+ if (i == sheet - 1)
4404+ aux = t;
4405+ else {
4406+ t->askOnCloseEvent(false);
4407+ t->close();
4408+ }
4409+ }
4410+ return aux;
4411+ }
4412+ return handler.sheet(sheets - 1);
4413+ }
4414+ return NULL;
4415+#else
4416+ QMessageBox::critical(this, tr("QtiPlot"), tr("QtiPlot was built without ODF spreadsheet support!"));
4417+ return NULL;
4418+#endif
4419+}
4420+
4421+Table * ApplicationWindow::importExcel(const QString& fileName, int sheet)
4422+{
4423+#ifdef XLS_IMPORT
4424+ QString fn = fileName;
4425+ if (fn.isEmpty()){
4426+ fn = getFileName(this, tr("Open Excel File"), QString::null, "*.xls", 0, false);
4427+ if (fn.isEmpty())
4428+ return NULL;
4429+ }
4430+
4431+ // open workbook, choose standard conversion
4432+ xlsWorkBook* pWB = xls_open(fn.toAscii().data(), "iso-8859-15//TRANSLIT");
4433+ if (!pWB)
4434+ return NULL;
4435+
4436+ if (sheet > 0 && sheet > pWB->sheets.count){
4437+ QMessageBox::critical(this, tr("QtiPlot"), tr("File %1 contains only %2 sheets, operation aborted!").arg(fn).arg(pWB->sheets.count));
4438+ return NULL;
4439+ }
4440+
4441+ Table *table = NULL;
4442+ for (int i = 0; i < pWB->sheets.count; i++){// process all sheets
4443+ int currentSheet = i + 1;
4444+ if (sheet > 0 && sheet != currentSheet)
4445+ continue;
4446+
4447+ xlsWorkSheet* pWS = xls_getWorkSheet(pWB, i);// open and parse the sheet
4448+ xls_parseWorkSheet(pWS);
4449+
4450+ int rows = pWS->rows.lastrow + 1;
4451+ int cols = pWS->rows.lastcol;
4452+ if (rows == 1 && !cols){
4453+ if (sheet > 0 && sheet == currentSheet){
4454+ QMessageBox::critical(this, tr("QtiPlot"), tr("Sheet %1 is empty, operation aborted!").arg(sheet));
4455+ return NULL;
4456+ } else
4457+ continue;
4458+ }
4459+
4460+ table = newTable(rows, cols, QString::null, fn + ", " + tr("sheet") + ": " + QString(pWB->sheets.sheet[i].name));
4461+ QDate d1(1899, 12, 30);//start date in Excel files see(http://sc.openoffice.org/excelfileformat.pdf)
4462+ QTime t1(0, 0);
4463+ double daySeconds = 24*60*60;
4464+ for (int t = 0; t <= pWS->rows.lastrow; t++){// process all rows of the sheet
4465+ struct st_row::st_row_data* row = &pWS->rows.row[t];
4466+ for (int tt = 0; tt <= pWS->rows.lastcol; tt++){
4467+ st_cell::st_cell_data cell = row->cells.cell[tt];
4468+ if (!cell.ishiden){
4469+ // display the colspan as only one cell, but reject rowspans (they can't be converted to CSV)
4470+ if (cell.rowspan > 1){
4471+ printf("%d,%d: rowspan=%i", tt, t, cell.rowspan);
4472+ continue;
4473+ }
4474+ // display the value of the cell (either numeric or string)
4475+ if (cell.id == 0x0BD){ // number
4476+ if (table->columnType(tt) == Table::Date){
4477+ QDate d2 = d1.addDays(cell.d);
4478+ table->setText(t, tt, d2.toString("dd.MM.yyyy"));
4479+ } else if (table->columnType(tt) == Table::Time){
4480+ QTime t2 = t1.addSecs(qRound(cell.d*daySeconds));
4481+ table->setText(t, tt, t2.toString("hh:mm:ss"));
4482+ } else
4483+ table->setCell(t, tt, cell.d);
4484+ } else if (cell.id == 0x27e){//date
4485+ QDate d2 = d1.addDays(cell.d);
4486+ table->setDateFormat("dd.MM.yyyy", tt, false);
4487+ table->setText(t, tt, d2.toString("dd.MM.yyyy"));
4488+ } else if (cell.id == 0x203){//time
4489+ table->setTimeFormat("hh:mm:ss", tt, false);
4490+ QTime t2 = t1.addSecs(qRound(cell.d*daySeconds));
4491+ table->setText(t, tt, t2.toString("hh:mm:ss"));
4492+ } else if (cell.id == 0x06 && cell.l == 0)//formula
4493+ table->setCell(t, tt, cell.d);
4494+ else if (cell.str != NULL)
4495+ table->setText(t, tt, QString(cell.str));
4496+ }
4497+ }
4498+ }
4499+ table->showNormal();
4500+
4501+ if (sheet > 0 && sheet == currentSheet)
4502+ break;
4503+ }
4504+ xls_close(pWB);
4505+
4506+ updateRecentProjectsList(fn);
4507+ return table;
4508+#else
4509+ QMessageBox::critical(this, tr("QtiPlot"), tr("QtiPlot was built without libxls support!"));
4510+ return NULL;
4511+#endif
4512+}
4513+
4514+Table * ApplicationWindow::importWaveFile()
4515+{
4516+ QString fn = getFileName(this, tr("Open File"), QString::null, "*.wav", 0, false);
4517+ if (fn.isEmpty())
4518+ return NULL;
4519+
4520+ QString log = QDateTime::currentDateTime ().toString(Qt::LocalDate) + " - ";
4521+ log += tr("Imported sound file") + ": " + fn + "\n";
4522+ ifstream file(fn, ios::in | ios::binary);
4523+
4524+ file.seekg(4, ios::beg);
4525+ int chunkSize;
4526+ file.read( (char*) &chunkSize, 4 ); // read the ChunkSize
4527+
4528+ file.seekg(16, ios::beg);
4529+ int subChunk1Size;
4530+ file.read( (char*) &subChunk1Size, 4 ); // read the SubChunk1Size
4531+
4532+ short format;
4533+ file.read( (char*) &format, sizeof(short) ); // read the file format. This should be 1 for PCM
4534+ log += tr("Format") + ": ";
4535+ if (format != 1){
4536+ QMessageBox::information(this, tr("QtiPlot"),
4537+ tr("This is not a PCM type WAV file, operation aborted!"));
4538+ log += QString::number(format) + "\n";
4539+ showResults(log, true);
4540+ return NULL;
4541+ } else
4542+ log += tr("PCM") + "\n";
4543+
4544+ short channels;
4545+ file.read( (char*) &channels, sizeof(short) ); // read the # of channels (1 or 2)
4546+ QStringList header;
4547+ if (channels == 2)
4548+ header << tr("Time") << tr("Left") << tr("Right");
4549+ else if (channels == 1)
4550+ header << tr("Time") << tr("Data");
4551+ log += tr("Channels") + ": " + QString::number(channels) + "\n";
4552+
4553+ int sampleRate;
4554+ file.read( (char*) &sampleRate, sizeof(int) );
4555+ log += tr("Sample Rate") + ": " + QString::number(sampleRate) + "\n";
4556+
4557+ int byteRate;
4558+ file.read( (char*) &byteRate, sizeof(int) );
4559+ log += tr("Byte Rate") + ": " + QString::number(byteRate) + "\n";
4560+
4561+ short blockAlign;
4562+ file.read( (char*) &blockAlign, sizeof(short) );
4563+ log += tr("Block Align") + ": " + QString::number(blockAlign) + "\n";
4564+
4565+ short bitsPerSample;
4566+ file.read( (char*) &bitsPerSample, sizeof(short) );
4567+ log += tr("Bits Per Sample") + ": " + QString::number(bitsPerSample) + "\n";
4568+ log += "__________________________________\n";
4569+ showResults(log, true);
4570+
4571+ int rows = (chunkSize - 36)/blockAlign;
4572+ Table *t = newTable(rows, int(channels + 1), QFileInfo(fn).baseName(), fn);
4573+ if (!t)
4574+ return NULL;
4575+
4576+ t->setHeader(header);
4577+
4578+ file.seekg(44, ios::beg);
4579+
4580+ double dt = 1.0/(double)sampleRate;
4581+ int aux = 1;
4582+ if (bitsPerSample == 8){
4583+ if (channels == 2)
4584+ file.seekg(46, ios::beg);//???Why???
4585+ int size = 1;
4586+ uchar ch;
4587+ while(!file.eof()){
4588+ int i = aux - 1;
4589+ t->setCell(i, 0, dt*aux);
4590+ for (int j = 1; j <= channels; j++){
4591+ file.read((char*) &ch, size);
4592+ t->setText(i, j, QString::number(ch));
4593+ }
4594+ aux++;
4595+ }
4596+ } else if (bitsPerSample == 16){
4597+ int size = sizeof(short);
4598+ short ch;
4599+ while(!file.eof()){
4600+ int i = aux - 1;
4601+ t->setCell(i, 0, dt*aux);
4602+ for (int j = 1; j <= channels; j++){
4603+ file.read((char*) &ch, size);
4604+ t->setText(i, j, QString::number(ch));
4605+ }
4606+ aux++;
4607+ }
4608+ }
4609+
4610+ file.close();
4611+ t->show();
4612+ return t;
4613+}
4614+
4615+void ApplicationWindow::importASCII()
4616+{
4617+ ImportASCIIDialog *import_dialog = new ImportASCIIDialog(!activeWindow(TableWindow) && !activeWindow(MatrixWindow), this, d_extended_import_ASCII_dialog);
4618+ import_dialog->setDirectory(asciiDirPath);
4619+ import_dialog->selectFilter(d_ASCII_file_filter);
4620+ if (d_import_ASCII_dialog_size.isValid())
4621+ import_dialog->resize(d_import_ASCII_dialog_size);
4622+ if (import_dialog->exec() != QDialog::Accepted)
4623+ return;
4624+
4625+ asciiDirPath = import_dialog->directory().path();
4626+ d_ASCII_import_mode = import_dialog->importMode();
4627+ columnSeparator = import_dialog->columnSeparator();
4628+ ignoredLines = import_dialog->ignoredLines();
4629+ renameColumns = import_dialog->useFirstRow();
4630+ strip_spaces = import_dialog->stripSpaces();
4631+ simplify_spaces = import_dialog->simplifySpaces();
4632+ d_ASCII_import_locale = import_dialog->decimalSeparators();
4633+ d_ASCII_comment_string = import_dialog->commentString();
4634+ d_ASCII_import_comments = import_dialog->useSecondRow();
4635+ d_ASCII_import_read_only = import_dialog->readOnly();
4636+ d_ASCII_end_line = (EndLineChar)import_dialog->endLineChar();
4637+ saveSettings();
4638+
4639+ importASCII(import_dialog->selectedFiles(),
4640+ import_dialog->importMode(),
4641+ import_dialog->columnSeparator(),
4642+ import_dialog->ignoredLines(),
4643+ import_dialog->renameColumns(),
4644+ import_dialog->stripSpaces(),
4645+ import_dialog->simplifySpaces(),
4646+ import_dialog->importComments(),
4647+ import_dialog->decimalSeparators(),
4648+ import_dialog->commentString(),
4649+ import_dialog->readOnly(),
4650+ import_dialog->endLineChar(),
4651+ import_dialog->columnTypes());
4652+}
4653+
4654+void ApplicationWindow::importASCII(const QStringList& files, int import_mode, const QString& local_column_separator,
4655+ int local_ignored_lines, bool local_rename_columns, bool local_strip_spaces, bool local_simplify_spaces,
4656+ bool local_import_comments, QLocale local_separators, const QString& local_comment_string,
4657+ bool import_read_only, int endLineChar, const QList<int>& colTypes)
4658+{
4659+ if (files.isEmpty())
4660+ return;
4661+
4662+ switch(import_mode) {
4663+ case ImportASCIIDialog::NewTables:
4664+ {
4665+ int dx = 0, dy = 0;
4666+ QStringList sorted_files = files;
4667+ sorted_files.sort();
4668+ int filesCount = sorted_files.size();
4669+ for (int i=0; i<filesCount; i++){
4670+ Table *w = newTable();
4671+ if (!w)
4672+ continue;
4673+
4674+ w->importASCII(sorted_files[i], local_column_separator, local_ignored_lines,
4675+ local_rename_columns, local_strip_spaces, local_simplify_spaces,
4676+ local_import_comments, local_comment_string, import_read_only,
4677+ Table::Overwrite, local_separators, endLineChar, -1, colTypes);
4678+ if (!w) continue;
4679+ w->setWindowLabel(sorted_files[i]);
4680+ w->setCaptionPolicy(MdiSubWindow::Both);
4681+
4682+ QString name = QFileInfo(sorted_files[i]).baseName();
4683+ if (!alreadyUsedName(name) && !name.contains(QRegExp("\\W")))
4684+ setWindowName(w, name);
4685+
4686+ if (i == 0){
4687+ dx = w->verticalHeaderWidth();
4688+ dy = w->frameGeometry().height() - w->widget()->height();
4689+ }
4690+ if (filesCount > 1)
4691+ w->move(QPoint(i*dx, i*dy));
4692+ }
4693+ modifiedProject();
4694+ break;
4695+ }
4696+ case ImportASCIIDialog::NewMatrices:
4697+ {
4698+ int dx = 0, dy = 0;
4699+ QStringList sorted_files = files;
4700+ sorted_files.sort();
4701+ int filesCount = sorted_files.size();
4702+ for (int i=0; i<filesCount; i++){
4703+ Matrix *w = newMatrix();
4704+ if (!w)
4705+ continue;
4706+ w->importASCII(sorted_files[i], local_column_separator, local_ignored_lines,
4707+ local_strip_spaces, local_simplify_spaces, local_comment_string,
4708+ Matrix::Overwrite, local_separators, endLineChar);
4709+ w->setWindowLabel(sorted_files[i]);
4710+ w->setCaptionPolicy(MdiSubWindow::Both);
4711+
4712+ QString name = QFileInfo(sorted_files[i]).baseName();
4713+ if (!alreadyUsedName(name) && !name.contains(QRegExp("\\W")))
4714+ setWindowName(w, name);
4715+
4716+ if (i == 0){
4717+ dx = w->verticalHeaderWidth();
4718+ dy = w->frameGeometry().height() - w->widget()->height();
4719+ }
4720+ if (filesCount > 1)
4721+ w->move(QPoint(i*dx,i*dy));
4722+ }
4723+ modifiedProject();
4724+ break;
4725+ }
4726+
4727+ case ImportASCIIDialog::NewColumns:
4728+ case ImportASCIIDialog::NewRows:
4729+ {
4730+ MdiSubWindow *w = activeWindow();
4731+ if (!w)
4732+ return;
4733+
4734+ if (w->inherits("Table")){
4735+ Table *t = (Table*)w;
4736+ for (int i = 0; i < files.size(); i++){
4737+ t->importASCII(files[i], local_column_separator, local_ignored_lines, local_rename_columns,
4738+ local_strip_spaces, local_simplify_spaces, local_import_comments,
4739+ local_comment_string, import_read_only, (Table::ImportMode)(import_mode - 2),
4740+ local_separators, endLineChar, -1, colTypes);
4741+ }
4742+ t->notifyChanges();
4743+ emit modifiedProject(t);
4744+ } else if (w->isA("Matrix")){
4745+ Matrix *m = (Matrix *)w;
4746+ for (int i=0; i<files.size(); i++){
4747+ m->importASCII(files[i], local_column_separator, local_ignored_lines,
4748+ local_strip_spaces, local_simplify_spaces, local_comment_string,
4749+ (Matrix::ImportMode)(import_mode - 2), local_separators, endLineChar);
4750+ }
4751+ }
4752+ w->setWindowLabel(files.join("; "));
4753+ w->setCaptionPolicy(MdiSubWindow::Name);
4754+ break;
4755+ }
4756+ case ImportASCIIDialog::Overwrite:
4757+ {
4758+ MdiSubWindow *w = activeWindow();
4759+ if (!w)
4760+ return;
4761+
4762+ if (w->inherits("Table")){
4763+ Table *t = (Table *)w;
4764+ t->importASCII(files[0], local_column_separator, local_ignored_lines, local_rename_columns,
4765+ local_strip_spaces, local_simplify_spaces, local_import_comments,
4766+ local_comment_string, import_read_only, Table::Overwrite, local_separators, endLineChar, -1, colTypes);
4767+ t->notifyChanges();
4768+ } else if (w->isA("Matrix")){
4769+ Matrix *m = (Matrix *)w;
4770+ m->importASCII(files[0], local_column_separator, local_ignored_lines,
4771+ local_strip_spaces, local_simplify_spaces, local_comment_string,
4772+ Matrix::Overwrite, local_separators, endLineChar);
4773+ }
4774+
4775+ w->setWindowLabel(files[0]);
4776+ w->setCaptionPolicy(MdiSubWindow::Both);
4777+
4778+ QString name = QFileInfo(files[0]).baseName();
4779+ if (!alreadyUsedName(name) && !name.contains(QRegExp("\\W")))
4780+ setWindowName(w, name);
4781+
4782+ modifiedProject();
4783+ break;
4784+ }
4785+ }
4786+}
4787+
4788+void ApplicationWindow::open()
4789+{
4790+ if (showSaveProjectMessage() == QMessageBox::Cancel)
4791+ return;
4792+
4793+ OpenProjectDialog *open_dialog = new OpenProjectDialog(this, d_extended_open_dialog);
4794+ open_dialog->setDirectory(workingDir);
4795+
4796+ if (open_dialog->exec() != QDialog::Accepted || open_dialog->selectedFiles().isEmpty())
4797+ return;
4798+ workingDir = open_dialog->directory().path();
4799+
4800+ switch(open_dialog->openMode()) {
4801+ case OpenProjectDialog::NewProject:
4802+ {
4803+ QString fn = open_dialog->selectedFiles()[0];
4804+ QFileInfo fi(fn);
4805+
4806+ if (projectname != "untitled"){
4807+ QFileInfo fi(projectname);
4808+ QString pn = fi.absFilePath();
4809+ if (fn == pn){
4810+ QMessageBox::warning(this, tr("QtiPlot - File openning error"),
4811+ tr("The file: <b>%1</b> is the current file!").arg(fn));
4812+ return;
4813+ }
4814+ }
4815+
4816+ if (!fi.exists ()){
4817+ QMessageBox::critical(this, tr("QtiPlot - File openning error"),
4818+ tr("The file: <b>%1</b> doesn't exist!").arg(fn));
4819+ return;
4820+ }
4821+
4822+ saveSettings();//the recent projects must be saved
4823+
4824+ #ifdef BROWSER_PLUGIN
4825+ if (isProjectFile(fn))
4826+ closeProject();
4827+ open(fn, false, false);
4828+ #else
4829+ ApplicationWindow *a = open (fn);
4830+ if (a){
4831+ a->workingDir = workingDir;
4832+ if (isProjectFile(fn))
4833+ this->close();
4834+ }
4835+ #endif
4836+
4837+ break;
4838+ }
4839+ case OpenProjectDialog::NewFolder:
4840+ appendProject(open_dialog->selectedFiles()[0]);
4841+ break;
4842+ }
4843+}
4844+
4845+bool ApplicationWindow::isProjectFile(const QString& fn)
4846+{
4847+ if (fn.endsWith(".qti", Qt::CaseInsensitive) || fn.endsWith(".qti.gz", Qt::CaseInsensitive) ||
4848+ fn.endsWith(".qti~", Qt::CaseInsensitive) ||
4849+ fn.endsWith(".opj",Qt::CaseInsensitive) || fn.endsWith(".ogg",Qt::CaseInsensitive))
4850+ return true;
4851+ return false;
4852+}
4853+
4854+ApplicationWindow* ApplicationWindow::open(const QString& fn, bool factorySettings, bool newProject)
4855+{
4856+ QFileInfo fi(fn);
4857+ if (!fi.isReadable()){
4858+ QMessageBox::critical(this, tr("QtiPlot - File openning error"),
4859+ tr("You don't have the permission to open this file: <b>%1</b>").arg(fn));
4860+ return NULL;
4861+ }
4862+
4863+#ifdef OPJ_IMPORT
4864+ if (fn.endsWith(".opj", Qt::CaseInsensitive) || fn.endsWith(".ogm", Qt::CaseInsensitive) ||
4865+ fn.endsWith(".ogw", Qt::CaseInsensitive) || fn.endsWith(".ogg", Qt::CaseInsensitive))
4866+ return importOPJ(fn, factorySettings, newProject);
4867+ else
4868+#endif
4869+ if (fn.endsWith(".py", Qt::CaseInsensitive))
4870+ return loadScript(fn);
4871+ else if (fn.endsWith(".xls", Qt::CaseInsensitive)){
4872+ importExcel(fn);
4873+ return this;
4874+ } else if (fn.endsWith(".ods", Qt::CaseInsensitive)){
4875+ importOdfSpreadsheet(fn);
4876+ return this;
4877+ }
4878+
4879+ QString fname = fn;
4880+ if (fn.endsWith(".qti.gz", Qt::CaseInsensitive)){//decompress using zlib
4881+ file_uncompress((char *)fname.ascii());
4882+ fname = fname.left(fname.size() - 3);
4883+ }
4884+
4885+ QFile f(fname);
4886+ QTextStream t( &f );
4887+ f.open(QIODevice::ReadOnly);
4888+ QString s = t.readLine();
4889+ f.close();
4890+
4891+ QStringList lst = s.split(QRegExp("\\s"), QString::SkipEmptyParts);
4892+ bool qtiProject = (lst.count() < 2 || lst[0] != "QtiPlot") ? false : true;
4893+ if (!qtiProject){
4894+ if (QFile::exists(fname + "~")){
4895+ int choice = QMessageBox::question(this, tr("QtiPlot - File opening error"),
4896+ tr("The file <b>%1</b> is corrupted, but there exists a backup copy.<br>Do you want to open the backup instead?").arg(fn),
4897+ QMessageBox::Yes|QMessageBox::Default, QMessageBox::No|QMessageBox::Escape);
4898+ if (choice == QMessageBox::Yes)
4899+ return open(fname + "~");
4900+ else
4901+ QMessageBox::critical(this, tr("QtiPlot - File opening error"), tr("The file: <b> %1 </b> was not created using QtiPlot!").arg(fn));
4902+ return 0;
4903+ }
4904+
4905+ return plotFile(fn);
4906+ }
4907+
4908+ QStringList vl = lst[1].split(".", QString::SkipEmptyParts);
4909+ d_file_version = 100*(vl[0]).toInt()+10*(vl[1]).toInt()+(vl[2]).toInt();
4910+
4911+ ApplicationWindow* app = openProject(fname, factorySettings, newProject);
4912+
4913+ f.close();
4914+ return app;
4915+}
4916+
4917+void ApplicationWindow::openRecentProject(int index)
4918+{
4919+ QString fn = recent->text(index);
4920+ int pos = fn.find(" ", 0);
4921+ fn = fn.right(fn.length() - pos - 1);
4922+
4923+ if (projectname != "untitled"){
4924+ QFileInfo fi(projectname);
4925+ QString pn = fi.absFilePath();
4926+
4927+ if (QDir::toNativeSeparators(fn) == QDir::toNativeSeparators(pn)){
4928+ QMessageBox::warning(this, tr("QtiPlot - File openning error"),
4929+ tr("The file: <p><b> %1 </b><p> is the current file!").arg(QDir::toNativeSeparators(fn)));
4930+ return;
4931+ }
4932+ }
4933+
4934+ if (isProjectFile(fn)){
4935+ if (showSaveProjectMessage() == QMessageBox::Cancel)
4936+ return;
4937+ }
4938+
4939+ QFile f(fn);
4940+ if (!f.exists()){
4941+ QMessageBox::critical(this, tr("QtiPlot - File Open Error"),
4942+ tr("The file: <b> %1 </b> <p>does not exist anymore!"
4943+ "<p>It will be removed from the list.").arg(fn));
4944+
4945+ for (int i = 0; i < recentProjects.size(); i++){
4946+ if (QDir::toNativeSeparators(recentProjects[i]) == fn){
4947+ recentProjects.removeAt(i);
4948+ break;
4949+ }
4950+ }
4951+ updateRecentProjectsList();
4952+ return;
4953+ }
4954+
4955+ if (!fn.isEmpty()){
4956+ saveSettings();//the recent projects must be saved
4957+ #ifdef BROWSER_PLUGIN
4958+ if (isProjectFile(fn))
4959+ closeProject();
4960+ open (fn, false, false);
4961+ #else
4962+ bool isSaved = saved;
4963+ ApplicationWindow * a = open (fn);
4964+ if (a){
4965+ if (isSaved)
4966+ savedProject();//force saved state
4967+ if (isProjectFile(fn))
4968+ close();
4969+ else
4970+ modifiedProject();
4971+ }
4972+ #endif
4973+ }
4974+}
4975+
4976+ApplicationWindow* ApplicationWindow::openProject(const QString& fn, bool factorySettings, bool newProject)
4977+{
4978+ ApplicationWindow *app = this;
4979+ if (newProject)
4980+ app = new ApplicationWindow(factorySettings);
4981+
4982+ app->projectname = fn;
4983+ app->d_file_version = d_file_version;
4984+ app->setWindowTitle(tr("QtiPlot") + " - " + fn);
4985+ app->d_opening_file = true;
4986+ app->d_workspace->blockSignals(true);
4987+
4988+ QFile f(fn);
4989+ QTextStream t( &f );
4990+ t.setEncoding(QTextStream::UnicodeUTF8);
4991+ f.open(QIODevice::ReadOnly);
4992+
4993+ QFileInfo fi(fn);
4994+ QString baseName = fi.fileName();
4995+
4996+ t.readLine();
4997+ if (d_file_version < 73)
4998+ t.readLine();
4999+
5000+ QString s = t.readLine();
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: