File indexing completed on 2024-05-19 03:48:34

0001 /*
0002     File                 : AbstractAspect.h
0003     Project              : LabPlot
0004     Description          : Base class for all objects in a Project.
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2007-2009 Tilman Benkert <thzs@gmx.net>
0007     SPDX-FileCopyrightText: 2007-2010 Knut Franke <knut.franke@gmx.de>
0008     SPDX-FileCopyrightText: 2011-2023 Alexander Semke <alexander.semke@web.de>
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #ifndef ASPECTFACTORY_H
0013 
0014 #include "backend/core/Project.h"
0015 #include "backend/spreadsheet/Spreadsheet.h"
0016 #include "backend/worksheet/Image.h"
0017 #include "backend/worksheet/InfoElement.h"
0018 #include "backend/worksheet/Worksheet.h"
0019 #include "backend/worksheet/plots/cartesian/Axis.h"
0020 #include "backend/worksheet/plots/cartesian/BarPlot.h"
0021 #include "backend/worksheet/plots/cartesian/BoxPlot.h"
0022 #include "backend/worksheet/plots/cartesian/CartesianPlot.h"
0023 #include "backend/worksheet/plots/cartesian/CartesianPlotLegend.h"
0024 #include "backend/worksheet/plots/cartesian/CustomPoint.h"
0025 #include "backend/worksheet/plots/cartesian/Histogram.h"
0026 #include "backend/worksheet/plots/cartesian/KDEPlot.h"
0027 #include "backend/worksheet/plots/cartesian/LollipopPlot.h"
0028 #include "backend/worksheet/plots/cartesian/QQPlot.h"
0029 #include "backend/worksheet/plots/cartesian/ReferenceLine.h"
0030 #include "backend/worksheet/plots/cartesian/XYConvolutionCurve.h"
0031 #include "backend/worksheet/plots/cartesian/XYCorrelationCurve.h"
0032 #include "backend/worksheet/plots/cartesian/XYDataReductionCurve.h"
0033 #include "backend/worksheet/plots/cartesian/XYDifferentiationCurve.h"
0034 #include "backend/worksheet/plots/cartesian/XYEquationCurve.h"
0035 #include "backend/worksheet/plots/cartesian/XYFitCurve.h"
0036 #include "backend/worksheet/plots/cartesian/XYFourierFilterCurve.h"
0037 #include "backend/worksheet/plots/cartesian/XYFourierTransformCurve.h"
0038 #include "backend/worksheet/plots/cartesian/XYIntegrationCurve.h"
0039 #include "backend/worksheet/plots/cartesian/XYInterpolationCurve.h"
0040 #include "backend/worksheet/plots/cartesian/XYSmoothCurve.h"
0041 
0042 #ifndef SDK
0043 #include "backend/core/Workbook.h"
0044 #include "backend/datapicker/Datapicker.h"
0045 #include "backend/datapicker/DatapickerCurve.h"
0046 #include "backend/matrix/Matrix.h"
0047 // #include "backend/datasources/LiveDataSource.h"
0048 #include "backend/note/Note.h"
0049 #endif
0050 
0051 class AspectFactory {
0052 public:
0053     static AbstractAspect* createAspect(AspectType type, AbstractAspect* parent) {
0054         if (type == AspectType::Folder)
0055             return new Folder(QString());
0056 
0057         /* worksheet and all its children */
0058         else if (type == AspectType::Worksheet)
0059             return new Worksheet(QString());
0060         else if (type == AspectType::CartesianPlot)
0061             return new CartesianPlot(QString());
0062         else if (type == AspectType::TextLabel)
0063             return new TextLabel(QString());
0064         else if (type == AspectType::Image)
0065             return new Image(QString());
0066         else if (type == AspectType::CustomPoint) {
0067             auto* plot = static_cast<CartesianPlot*>(parent);
0068             return new CustomPoint(plot, QString());
0069         } else if (type == AspectType::ReferenceLine) {
0070             auto* plot = static_cast<CartesianPlot*>(parent);
0071             return new ReferenceLine(plot, QString());
0072         } else if (type == AspectType::InfoElement) {
0073             auto* plot = static_cast<CartesianPlot*>(parent);
0074             return new InfoElement(QString(), plot);
0075         }
0076 
0077         /* CartesianPlot's children */
0078         else if (type == AspectType::Axis)
0079             return new Axis(QString());
0080         else if (type == AspectType::XYCurve)
0081             return new XYCurve(QString());
0082         else if (type == AspectType::XYEquationCurve)
0083             return new XYEquationCurve(QString());
0084         else if (type == AspectType::XYConvolutionCurve)
0085             return new XYConvolutionCurve(QString());
0086         else if (type == AspectType::XYCorrelationCurve)
0087             return new XYCorrelationCurve(QString());
0088         else if (type == AspectType::XYDataReductionCurve)
0089             return new XYDataReductionCurve(QString());
0090         else if (type == AspectType::XYDifferentiationCurve)
0091             return new XYDifferentiationCurve(QString());
0092         else if (type == AspectType::XYFitCurve)
0093             return new XYFitCurve(QString());
0094         else if (type == AspectType::XYFourierFilterCurve)
0095             return new XYFourierFilterCurve(QString());
0096         else if (type == AspectType::XYFourierTransformCurve)
0097             return new XYFourierTransformCurve(QString());
0098         else if (type == AspectType::XYIntegrationCurve)
0099             return new XYIntegrationCurve(QString());
0100         else if (type == AspectType::XYInterpolationCurve)
0101             return new XYInterpolationCurve(QString());
0102         else if (type == AspectType::XYSmoothCurve)
0103             return new XYSmoothCurve(QString());
0104         else if (type == AspectType::CartesianPlotLegend)
0105             return new CartesianPlotLegend(QString());
0106 
0107         /* statistical plots */
0108         else if (type == AspectType::BoxPlot)
0109             return new BoxPlot(QString());
0110         else if (type == AspectType::Histogram)
0111             return new Histogram(QString());
0112         else if (type == AspectType::KDEPlot)
0113             return new KDEPlot(QString());
0114         else if (type == AspectType::QQPlot)
0115             return new QQPlot(QString());
0116 
0117         /* bar plots */
0118         else if (type == AspectType::BarPlot)
0119             return new BarPlot(QString());
0120         else if (type == AspectType::LollipopPlot)
0121             return new LollipopPlot(QString());
0122 
0123         /* data containers */
0124         else if (type == AspectType::Spreadsheet)
0125             return new Spreadsheet(QString(), true /*loading*/);
0126         else if (type == AspectType::Column)
0127             return new Column(QString());
0128 
0129 #ifndef SDK
0130         else if (type == AspectType::Matrix)
0131             return new Matrix(QString());
0132         else if (type == AspectType::Datapicker)
0133             return new Datapicker(QString());
0134         else if (type == AspectType::Note)
0135             return new Note(QString());
0136         else if (type == AspectType::Workbook)
0137             return new Workbook(QString());
0138 #endif
0139         return nullptr;
0140     }
0141 };
0142 
0143 #endif