File indexing completed on 2024-12-22 04:16:09

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Agata Cacko <cacko.azh@gmail.com>
0003  *  SPDX-FileCopyrightText: 2009, 2010 Lukáš Tvrdý (lukast.dev@gmail.com)
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #include "KisGridOpOptionData.h"
0008 
0009 #include "kis_properties_configuration.h"
0010 
0011 
0012 bool KisGridOpOptionData::read(const KisPropertiesConfiguration *setting)
0013 {
0014     grid_width = qMax(1, setting->getInt(GRID_WIDTH));
0015     grid_height = qMax(1, setting->getInt(GRID_HEIGHT));
0016     diameter = setting->getInt(DIAMETER);
0017     // If loading an old brush without a diameter set, set to grid_width as was the old logic
0018     if (!diameter) {
0019         diameter = grid_width;
0020     }
0021     else {
0022         diameter = qMax(1, diameter);
0023     }
0024     horizontal_offset = setting->getDouble(HORIZONTAL_OFFSET);
0025     vertical_offset = setting->getDouble(VERTICAL_OFFSET);
0026     grid_division_level = setting->getInt(GRID_DIVISION_LEVEL);
0027     grid_pressure_division = setting->getBool(GRID_PRESSURE_DIVISION);
0028     grid_scale = setting->getDouble(GRID_SCALE);
0029     grid_vertical_border = setting->getDouble(GRID_VERTICAL_BORDER);
0030     grid_horizontal_border = setting->getDouble(GRID_HORIZONTAL_BORDER);
0031     grid_random_border = setting->getBool(GRID_RANDOM_BORDER);
0032     return true;
0033 }
0034 
0035 void KisGridOpOptionData::write(KisPropertiesConfiguration *setting) const
0036 {
0037     setting->setProperty(DIAMETER, qMax(1,diameter));
0038     setting->setProperty(GRID_WIDTH, qMax(1, grid_width));
0039     setting->setProperty(GRID_HEIGHT, qMax(1, grid_height));
0040     setting->setProperty(HORIZONTAL_OFFSET, horizontal_offset);
0041     setting->setProperty(VERTICAL_OFFSET, vertical_offset);
0042     setting->setProperty(GRID_DIVISION_LEVEL, grid_division_level);
0043     setting->setProperty(GRID_PRESSURE_DIVISION, grid_pressure_division);
0044     setting->setProperty(GRID_SCALE, grid_scale);
0045     setting->setProperty(GRID_VERTICAL_BORDER, grid_vertical_border);
0046     setting->setProperty(GRID_HORIZONTAL_BORDER, grid_horizontal_border);
0047     setting->setProperty(GRID_RANDOM_BORDER, grid_random_border);
0048 }