File indexing completed on 2024-05-05 08:41:14
0001 /* 0002 * Copyright (C) 2010-2015 by Stephen Allewell 0003 * steve.allewell@gmail.com 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 */ 0010 0011 #ifndef ImportImageDlg_H 0012 #define ImportImageDlg_H 0013 0014 #include <QAction> 0015 #include <QDialog> 0016 #include <QPixmap> 0017 #include <QSize> 0018 #include <QTimer> 0019 #include <QWidget> 0020 0021 // wrap include to silence unused-parameter warning from Magick++ include file 0022 #pragma GCC diagnostic push 0023 #pragma GCC diagnostic ignored "-Wunused-parameter" 0024 #pragma GCC diagnostic ignored "-Wsuggest-override" 0025 #include <Magick++.h> 0026 #pragma GCC diagnostic pop 0027 0028 #include "AlphaSelect.h" 0029 #include "ui_ImportImage.h" 0030 0031 class SchemeManager; 0032 class QHideEvent; 0033 class QShowEvent; 0034 0035 class ImportImageDlg : public QDialog 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 ImportImageDlg(QWidget *, const Magick::Image &); 0041 virtual ~ImportImageDlg() = default; 0042 0043 Magick::Image convertedImage() const; 0044 bool ignoreColor() const; 0045 Magick::Color ignoreColorValue() const; 0046 QString flossScheme() const; 0047 double horizontalClothCount() const; 0048 double verticalClothCount() const; 0049 bool useFractionals() const; 0050 QRect croppedArea() const; 0051 0052 protected: 0053 virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; 0054 virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; 0055 virtual void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; 0056 0057 private slots: 0058 void on_FlossScheme_currentIndexChanged(const QString &); 0059 void on_UseMaximumColors_toggled(bool); 0060 void on_MaximumColors_valueChanged(int); 0061 void on_IgnoreColor_toggled(bool); 0062 void on_ColorButton_clicked(bool); 0063 void on_HorizontalClothCount_valueChanged(double); 0064 void on_VerticalClothCount_valueChanged(double); 0065 void on_ClothCountLink_clicked(bool); 0066 void on_PatternScale_valueChanged(int); 0067 void on_CropEnabled_toggled(bool); 0068 void on_CropReset_clicked(bool); 0069 void imageCropped(const QRectF &rectF); 0070 void on_UseFractionals_toggled(bool); 0071 void selectColor(const QPoint &); 0072 void on_DialogButtonBox_accepted(); 0073 void on_DialogButtonBox_rejected(); 0074 void on_DialogButtonBox_helpRequested(); 0075 void on_DialogButtonBox_clicked(QAbstractButton *); 0076 0077 private: 0078 void updateWindowTitle(); 0079 void resetImportParameters(); 0080 void clothCountChanged(double, double); 0081 void calculateSizes(); 0082 void createImageMap(); 0083 void renderPixmap(); 0084 void pickColor(); 0085 0086 Ui::ImportImage ui; 0087 0088 QPixmap m_pixmap; 0089 QSize m_originalSize; 0090 QSize m_preferredSize; 0091 int m_timer; 0092 AlphaSelect *m_alphaSelect; 0093 Magick::ColorRGB m_ignoreColorValue; 0094 Magick::Image m_originalImage; 0095 Magick::Image m_convertedImage; 0096 Magick::Image m_colorMap; 0097 QRect m_crop; 0098 }; 0099 0100 #endif // ImportImageDlg_H