File indexing completed on 2024-12-22 04:16:10
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Lukas Tvrdy <lukast.dev@gmail.com> 0003 * SPDX-FileCopyrightText: 2010 José Luis Vergara <pentalis@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #include "KisHatchingOptionsWidget.h" 0008 0009 #include <QButtonGroup> 0010 0011 #include <lager/constant.hpp> 0012 #include "ui_wdghatchingoptions.h" 0013 0014 #include "KisHatchingOptionsModel.h" 0015 #include <kis_paintop_lod_limitations.h> 0016 0017 namespace { 0018 0019 0020 class KisHatchingOptions: public QWidget, public Ui::WdgHatchingOptions 0021 { 0022 public: 0023 KisHatchingOptions(QWidget *parent = 0) 0024 : QWidget(parent) { 0025 setupUi(this); 0026 0027 QString px = i18n(" px"); 0028 0029 angleKisAngleSelector ->setIncreasingDirection(KisAngleGauge::IncreasingDirection_Clockwise); 0030 0031 //setRange(minimum, maximum, decimals) 0032 angleKisAngleSelector -> setRange(-90.0, 90.0); 0033 angleKisAngleSelector -> setDecimals(1); 0034 separationKisDoubleSliderSpinBox-> setRange(1.0, 30.0, 1); 0035 thicknessKisDoubleSliderSpinBox -> setRange(1.0, 30.0, 1); 0036 originXKisDoubleSliderSpinBox -> setRange(-300, 300, 0); 0037 originYKisDoubleSliderSpinBox -> setRange(-300, 300, 0); 0038 0039 separationKisDoubleSliderSpinBox-> setSingleStep(0.1); 0040 thicknessKisDoubleSliderSpinBox -> setSingleStep(0.1); 0041 0042 separationKisDoubleSliderSpinBox-> setSuffix(px); 0043 thicknessKisDoubleSliderSpinBox -> setSuffix(px); 0044 originXKisDoubleSliderSpinBox -> setSuffix(px); 0045 originYKisDoubleSliderSpinBox -> setSuffix(px); 0046 } 0047 }; 0048 0049 0050 } 0051 0052 0053 struct KisHatchingOptionsWidget::Private 0054 { 0055 Private(lager::cursor<KisHatchingOptionsData> optionData) 0056 : model(optionData) 0057 { 0058 } 0059 0060 KisHatchingOptionsModel model; 0061 }; 0062 0063 0064 KisHatchingOptionsWidget::KisHatchingOptionsWidget(lager::cursor<KisHatchingOptionsData> optionData) 0065 : KisPaintOpOption(i18n("Hatching options"), KisPaintOpOption::GENERAL, true) 0066 , m_d(new Private(optionData)) 0067 { 0068 0069 KisHatchingOptions *widget = new KisHatchingOptions(); 0070 setObjectName("KisHatchingOptions"); 0071 0072 m_checkable = false; 0073 0074 using namespace KisWidgetConnectionUtils; 0075 0076 connectControl(widget->angleKisAngleSelector, &m_d->model, "angle"); 0077 connectControl(widget->separationKisDoubleSliderSpinBox, &m_d->model, "separation"); 0078 connectControl(widget->thicknessKisDoubleSliderSpinBox, &m_d->model, "thickness"); 0079 connectControl(widget->originXKisDoubleSliderSpinBox, &m_d->model, "originX"); 0080 connectControl(widget->originYKisDoubleSliderSpinBox, &m_d->model, "originY"); 0081 0082 QButtonGroup *group = new QButtonGroup(widget); 0083 group->addButton(widget->noCrosshatchingRadioButton, static_cast<int>(CrosshatchingType::NoCrosshatching)); 0084 group->addButton(widget->perpendicularRadioButton, static_cast<int>(CrosshatchingType::Perpendicular)); 0085 group->addButton(widget->minusThenPlusRadioButton, static_cast<int>(CrosshatchingType::MinusThenPlus)); 0086 group->addButton(widget->plusThenMinusRadioButton, static_cast<int>(CrosshatchingType::PlusThenMinus)); 0087 group->addButton(widget->moirePatternRadioButton, static_cast<int>(CrosshatchingType::MoirePattern)); 0088 group->setExclusive(true); 0089 connectControl(group, &m_d->model, "crosshatchingStyle"); 0090 0091 connectControl(widget->separationIntervalSpinBox, &m_d->model, "separationIntervals"); 0092 0093 m_d->model.optionData.bind(std::bind(&KisHatchingOptionsWidget::emitSettingChanged, this)); 0094 0095 setConfigurationPage(widget); 0096 } 0097 0098 KisHatchingOptionsWidget::~KisHatchingOptionsWidget() 0099 { 0100 } 0101 0102 void KisHatchingOptionsWidget::writeOptionSetting(KisPropertiesConfigurationSP setting) const 0103 { 0104 KisHatchingOptionsData data = *m_d->model.optionData; 0105 data.write(setting.data()); 0106 } 0107 0108 void KisHatchingOptionsWidget::readOptionSetting(const KisPropertiesConfigurationSP setting) 0109 { 0110 KisHatchingOptionsData data = *m_d->model.optionData; 0111 data.read(setting.data()); 0112 m_d->model.optionData.set(data); 0113 }