File indexing completed on 2024-05-12 15:28:16

0001 /***************************************************************************
0002     File                 : DatapickerImageWidget.h
0003     Project              : LabPlot
0004     Description          : widget for datapicker properties
0005     --------------------------------------------------------------------
0006     Copyright            : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com)
0007     Copyright            : (C) 2015 by Alexander Semke (alexander.semke@web.de)
0008 
0009  ***************************************************************************/
0010 /***************************************************************************
0011  *                                                                         *
0012  *  This program is free software; you can redistribute it and/or modify   *
0013  *  it under the terms of the GNU General Public License as published by   *
0014  *  the Free Software Foundation; either version 2 of the License, or      *
0015  *  (at your option) any later version.                                    *
0016  *                                                                         *
0017  *  This program is distributed in the hope that it will be useful,        *
0018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0020  *  GNU General Public License for more details.                           *
0021  *                                                                         *
0022  *   You should have received a copy of the GNU General Public License     *
0023  *   along with this program; if not, write to the Free Software           *
0024  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0025  *   Boston, MA  02110-1301  USA                                           *
0026  *                                                                         *
0027  ***************************************************************************/
0028 
0029 #ifndef DATAPICKERIMAGEWIDGET_H
0030 #define DATAPICKERIMAGEWIDGET_H
0031 
0032 #include <QGraphicsView>
0033 
0034 #include "ui_datapickerimagewidget.h"
0035 #include "backend/datapicker/DatapickerImage.h"
0036 #include "kdefrontend/dockwidgets/BaseDock.h"
0037 
0038 class QxtSpanSlider;
0039 
0040 class HistogramView : public QGraphicsView {
0041     Q_OBJECT
0042 
0043 public:
0044     explicit HistogramView(QWidget*, int);
0045     void setScalePixmap(const QString&);
0046     int *bins{nullptr};
0047 
0048 public slots:
0049     void setSpan(int, int);
0050 
0051 private:
0052     void resizeEvent(QResizeEvent *event) override;
0053     void drawBackground(QPainter*, const QRectF&) override;
0054     QGraphicsRectItem* m_lowerSlider;
0055     QGraphicsRectItem* m_upperSlider;
0056     QGraphicsScene* m_scene;
0057     int m_range;
0058 };
0059 
0060 class DatapickerImageWidget : public BaseDock {
0061     Q_OBJECT
0062 
0063 public:
0064     explicit DatapickerImageWidget(QWidget*);
0065 
0066     void setImages(QList<DatapickerImage*>);
0067     void load();
0068     void updateLocale() override;
0069 
0070 private:
0071     Ui::DatapickerImageWidget ui;
0072     void init();
0073     void initConnections();
0074 
0075     DatapickerImage* m_image;
0076     QList<DatapickerImage*> m_imagesList;
0077 
0078     QxtSpanSlider* ssIntensity;
0079     QxtSpanSlider* ssForeground;
0080     QxtSpanSlider* ssHue;
0081     QxtSpanSlider* ssSaturation;
0082     QxtSpanSlider* ssValue;
0083 
0084     HistogramView* gvIntensity;
0085     HistogramView* gvForeground;
0086     HistogramView* gvHue;
0087     HistogramView* gvSaturation;
0088     HistogramView* gvValue;
0089 
0090 private slots:
0091     //SLOTs for changes triggered in DatapickerImageWidget
0092     //"General"-tab
0093     void fileNameChanged();
0094     void selectFile();
0095     void plotImageTypeChanged(int);
0096 
0097     //"Edit image"-tab
0098     void rotationChanged(double);
0099     void intensitySpanChanged(int, int);
0100     void foregroundSpanChanged(int, int);
0101     void hueSpanChanged(int, int);
0102     void saturationSpanChanged(int, int);
0103     void valueSpanChanged(int, int);
0104 
0105     void minSegmentLengthChanged(int);
0106     void pointSeparationChanged(int);
0107     void graphTypeChanged();
0108     void ternaryScaleChanged(double);
0109     void logicalPositionChanged();
0110 
0111     //symbol properties
0112     void pointsStyleChanged(int);
0113     void pointsSizeChanged(double);
0114     void pointsRotationChanged(int);
0115     void pointsOpacityChanged(int);
0116     void pointsFillingStyleChanged(int);
0117     void pointsFillingColorChanged(const QColor&);
0118     void pointsBorderStyleChanged(int);
0119     void pointsBorderColorChanged(const QColor&);
0120     void pointsBorderWidthChanged(double);
0121     void pointsVisibilityChanged(bool);
0122 
0123 
0124     //SLOTs for changes triggered in DatapickerImageWidget
0125     void imageDescriptionChanged(const AbstractAspect*);
0126     void imageFileNameChanged(const QString&);
0127     void imageRotationAngleChanged(float);
0128     void imageAxisPointsChanged(const DatapickerImage::ReferencePoints&);
0129     void imageEditorSettingsChanged(const DatapickerImage::EditorSettings&);
0130     void imageMinSegmentLengthChanged(const int);
0131     void updateSymbolWidgets();
0132     void handleWidgetActions();
0133     //symbol
0134     void symbolStyleChanged(Symbol::Style);
0135     void symbolSizeChanged(qreal);
0136     void symbolRotationAngleChanged(qreal);
0137     void symbolOpacityChanged(qreal);
0138     void symbolBrushChanged(const QBrush&);
0139     void symbolPenChanged(const QPen&);
0140     void symbolVisibleChanged(bool);
0141 };
0142 
0143 #endif //DATAPICKERIMAGEWIDGET_H