1 /*
2 Scan Tailor - Interactive post-processing tool for scanned pages.
3 Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "OutputParams.h"
20 #include <QDomDocument>
21 #include "FillZonePropFactory.h"
22 #include "PictureZonePropFactory.h"
23
24 namespace output {
OutputParams(const OutputImageParams & output_image_params,const OutputFileParams & output_file_params,const OutputFileParams & foreground_file_params,const OutputFileParams & background_file_params,const OutputFileParams & original_background_file_params,const OutputFileParams & automask_file_params,const OutputFileParams & speckles_file_params,const ZoneSet & picture_zones,const ZoneSet & fill_zones)25 OutputParams::OutputParams(const OutputImageParams& output_image_params,
26 const OutputFileParams& output_file_params,
27 const OutputFileParams& foreground_file_params,
28 const OutputFileParams& background_file_params,
29 const OutputFileParams& original_background_file_params,
30 const OutputFileParams& automask_file_params,
31 const OutputFileParams& speckles_file_params,
32 const ZoneSet& picture_zones,
33 const ZoneSet& fill_zones)
34 : m_outputImageParams(output_image_params),
35 m_outputFileParams(output_file_params),
36 m_foregroundFileParams(foreground_file_params),
37 m_backgroundFileParams(background_file_params),
38 m_originalBackgroundFileParams(original_background_file_params),
39 m_automaskFileParams(automask_file_params),
40 m_specklesFileParams(speckles_file_params),
41 m_pictureZones(picture_zones),
42 m_fillZones(fill_zones) {}
43
OutputParams(const QDomElement & el)44 OutputParams::OutputParams(const QDomElement& el)
45 : m_outputImageParams(el.namedItem("image").toElement()),
46 m_outputFileParams(el.namedItem("file").toElement()),
47 m_foregroundFileParams(el.namedItem("foreground_file").toElement()),
48 m_backgroundFileParams(el.namedItem("background_file").toElement()),
49 m_originalBackgroundFileParams(el.namedItem("original_background_file").toElement()),
50 m_automaskFileParams(el.namedItem("automask").toElement()),
51 m_specklesFileParams(el.namedItem("speckles").toElement()),
52 m_pictureZones(el.namedItem("zones").toElement(), PictureZonePropFactory()),
53 m_fillZones(el.namedItem("fill-zones").toElement(), FillZonePropFactory()) {}
54
toXml(QDomDocument & doc,const QString & name) const55 QDomElement OutputParams::toXml(QDomDocument& doc, const QString& name) const {
56 QDomElement el(doc.createElement(name));
57 el.appendChild(m_outputImageParams.toXml(doc, "image"));
58 el.appendChild(m_outputFileParams.toXml(doc, "file"));
59 el.appendChild(m_foregroundFileParams.toXml(doc, "foreground_file"));
60 el.appendChild(m_backgroundFileParams.toXml(doc, "background_file"));
61 el.appendChild(m_originalBackgroundFileParams.toXml(doc, "original_background_file"));
62 el.appendChild(m_automaskFileParams.toXml(doc, "automask"));
63 el.appendChild(m_specklesFileParams.toXml(doc, "speckles"));
64 el.appendChild(m_pictureZones.toXml(doc, "zones"));
65 el.appendChild(m_fillZones.toXml(doc, "fill-zones"));
66
67 return el;
68 }
69
outputImageParams() const70 const OutputImageParams& OutputParams::outputImageParams() const {
71 return m_outputImageParams;
72 }
73
outputFileParams() const74 const OutputFileParams& OutputParams::outputFileParams() const {
75 return m_outputFileParams;
76 }
77
foregroundFileParams() const78 const OutputFileParams& OutputParams::foregroundFileParams() const {
79 return m_foregroundFileParams;
80 }
81
backgroundFileParams() const82 const OutputFileParams& OutputParams::backgroundFileParams() const {
83 return m_backgroundFileParams;
84 }
85
originalBackgroundFileParams() const86 const OutputFileParams& OutputParams::originalBackgroundFileParams() const {
87 return m_originalBackgroundFileParams;
88 }
89
automaskFileParams() const90 const OutputFileParams& OutputParams::automaskFileParams() const {
91 return m_automaskFileParams;
92 }
93
specklesFileParams() const94 const OutputFileParams& OutputParams::specklesFileParams() const {
95 return m_specklesFileParams;
96 }
97
pictureZones() const98 const ZoneSet& OutputParams::pictureZones() const {
99 return m_pictureZones;
100 }
101
fillZones() const102 const ZoneSet& OutputParams::fillZones() const {
103 return m_fillZones;
104 }
105 } // namespace output