Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYGeographicData.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #include "TYGeographicData.h"
17 
18 TYGeographicData::TYGeographicData(QObject* parent) : QObject(parent) {}
19 
21 {
22  if (text != m_landtake_coordinates)
23  {
26  }
27 }
28 
29 QString TYGeographicData::crs() const
30 {
31  return m_crs;
32 }
33 
34 void TYGeographicData::setCrs(const QString& text)
35 {
36  if (text != m_crs)
37  {
38  m_crs = text;
39  emit crsChanged();
40  }
41 }
42 
44 {
46 }
47 
48 void TYGeographicData::setBackgroundImg(const QString& base64Image)
49 {
50  if (base64Image != m_base64Image)
51  {
52  m_base64Image = base64Image;
53  m_image = QImage();
54  emit backgroundImgChanged();
55  }
56 }
57 
59 {
60  return m_base64Image;
61 }
62 
64 {
65  return m_level_curves;
66 }
67 
68 void TYGeographicData::setLevelCurves(const QString& text)
69 {
70  if (text != m_level_curves)
71  {
72  m_level_curves = text;
73  emit levelCurvesChanged();
74  }
75 }
76 
78 {
79  return m_scale_factor;
80 }
81 
82 void TYGeographicData::setScaleFactor(const QString& text)
83 {
84  if (text != m_scale_factor)
85  {
86  m_scale_factor = text;
87  emit scaleFactorChanged();
88  }
89 }
90 
92 {
93  return m_image_width;
94 }
95 
96 void TYGeographicData::setImageWidth(const QString& text)
97 {
98  if (text != m_image_width)
99  {
100  m_image_width = text;
101  emit imageWidthChanged();
102  }
103 }
104 
106 {
107  if (m_image.isNull() && !m_base64Image.isEmpty())
108  {
110  }
111  return m_image;
112 }
113 
114 bool TYGeographicData::saveImageToFile(const QString& filePath)
115 {
116  QImage image = getImage();
117  if (image.isNull())
118  {
119  qWarning() << "Image is null, cannot save.";
120  return false;
121  }
122 
123  // Save the image to a PNG file
124  return image.save(filePath, "PNG");
125 }
126 
127 QImage TYGeographicData::buildImageFromBase64(const QString& base64Image) const
128 {
129  // Decode base64 image string to byte array
130  QByteArray imageData = QByteArray::fromBase64(base64Image.toUtf8());
131 
132  // Load byte array into a QImage
133  QImage image;
134  image.loadFromData(imageData);
135 
136  return image;
137 }
void imageWidthChanged()
void setScaleFactor(const QString &text)
QImage getImage() const
void backgroundImgChanged()
void scaleFactorChanged()
void setLandtakeCoordinates(const QString &text)
QString m_landtake_coordinates
void landtakeCoordinatesChanged()
QString landtakeCoordinates() const
QString backgroundImg() const
void levelCurvesChanged()
TYGeographicData(QObject *parent=nullptr)
QString scaleFactor() const
QImage buildImageFromBase64(const QString &base64Image) const
void setLevelCurves(const QString &text)
void setBackgroundImg(const QString &base64Image)
void setCrs(const QString &text)
Q_INVOKABLE bool saveImageToFile(const QString &filePath)
QString levelCurves() const
QString imageWidth() const
void setImageWidth(const QString &text)