Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl Class Reference
Collaboration diagram for geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl:
Collaboration graph
[legend]

Public Member Functions

 ImageTaskExportWidgetImpl (ImageTaskExportWidget *pQ)
 
 ~ImageTaskExportWidgetImpl ()=default
 
ImageTaskExportWidgetImpl operator= (const ImageTaskExportWidgetImpl &)=delete
 
 ImageTaskExportWidgetImpl (const ImageTaskExportWidgetImpl &)=delete
 
void setImageTask (const task::ImageTask *task, const std::vector< geometrize::ShapeResult > *shapes)
 
void saveSVG () const
 
void saveRasterizedSVG () const
 
void saveRasterizedSVGs () const
 
void saveGeometryData () const
 
void saveGIF () const
 
void saveHTML5WebpageButton () const
 
void saveWebGLWebpageButton () const
 
void onLanguageChange ()
 

Private Member Functions

void populateUi ()
 
void showExportMisconfiguredMessage () const
 

Private Attributes

const geometrize::task::ImageTaskm_task
 
const std::vector
< geometrize::ShapeResult > * 
m_shapes
 
ImageTaskExportWidgetq
 
std::unique_ptr
< Ui::ImageTaskExportWidget > 
ui
 

Constructor & Destructor Documentation

geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::ImageTaskExportWidgetImpl ( ImageTaskExportWidget pQ)
inline
30  : m_task{nullptr}, m_shapes{nullptr}, q{pQ}, ui{std::make_unique<Ui::ImageTaskExportWidget>()}
31  {
32  ui->setupUi(q);
33  populateUi();
34  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
std::unique_ptr< Ui::ImageTaskExportWidget > ui
Definition: imagetaskexportwidget.cpp:223
void populateUi()
Definition: imagetaskexportwidget.cpp:209
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::~ImageTaskExportWidgetImpl ( )
default
geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::ImageTaskExportWidgetImpl ( const ImageTaskExportWidgetImpl )
delete

Member Function Documentation

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::onLanguageChange ( )
inline
203  {
204  ui->retranslateUi(q);
205  populateUi();
206  }
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
std::unique_ptr< Ui::ImageTaskExportWidget > ui
Definition: imagetaskexportwidget.cpp:223
void populateUi()
Definition: imagetaskexportwidget.cpp:209

Here is the call graph for this function:

ImageTaskExportWidgetImpl geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::operator= ( const ImageTaskExportWidgetImpl )
delete
void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::populateUi ( )
inlineprivate
210  {
211  }

Here is the caller graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveGeometryData ( ) const
inline
114  {
115  if(!m_shapes) {
117  return;
118  }
119 
121  if(path.isEmpty()) {
122  return;
123  }
124 
126  if(path.endsWith("json")) {
128  } else if(path.endsWith("txt")) {
130  }
131 
132  const std::string data{geometrize::exporter::exportShapeData(*m_shapes, format)};
133  util::writeStringToFile(data, path.toStdString());
134  }
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
std::string exportShapeData(const std::vector< geometrize::ShapeResult > &data, const ShapeDataFormat format)
exportShapeData Exports shape data to a specified format (JSON or a custom textual array format)...
Definition: shapedataexporter.cpp:17
QString openSaveGeometryDataPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:141
ShapeDataFormat
Definition: shapedataexporter.h:17
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
bool writeStringToFile(const std::string &str, const std::string &path)
writeStringToFile Writes the string to the file path, attempting to overwrite any existing file at th...
Definition: util.cpp:271

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveGIF ( ) const
inline
137  {
138  if(!m_task || !m_shapes) {
140  return;
141  }
142 
143  const QString path{common::ui::openSaveGIFPathPickerDialog(q)};
144  if(path.isEmpty()) {
145  return;
146  }
147 
148  // Rasterize as x3 normal size and downscale for less jaggy result
149  const std::uint32_t scaleFactor{3};
150  const std::uint32_t width{m_task->getCurrent().getWidth()};
151  const std::uint32_t height{m_task->getCurrent().getHeight()};
152 
153  auto frameSkipPredicate = [](const std::size_t frameIdx) {
154  if(frameIdx % 2 == 0) {
155  return true;
156  }
157  return false;
158  };
159 
161  *m_shapes,
162  width,
163  height,
164  width * scaleFactor,
165  height * scaleFactor,
166  frameSkipPredicate,
167  path.toStdString());
168  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
QString openSaveGIFPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:149
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
bool exportGIF(const std::vector< geometrize::ShapeResult > &data, std::uint32_t inputWidth, std::uint32_t inputHeight, std::uint32_t outputWidth, std::uint32_t outputHeight, const std::function< bool(std::size_t)> &frameSkipPredicate, const std::string &filePath)
exportGIF Exports shape data to a GIF image.
Definition: gifexporter.cpp:80
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveHTML5WebpageButton ( ) const
inline
171  {
172  if(!m_shapes) {
174  return;
175  }
176 
177  const QString path{common::ui::openSaveCanvasPathPickerDialog(q)};
178  if(path.isEmpty()) {
179  return;
180  }
181 
182  const std::string pageSource{geometrize::exporter::exportCanvasWebpage(*m_shapes)};
183  util::writeStringToFile(pageSource, path.toStdString());
184  }
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
QString openSaveCanvasPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:157
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
std::string exportCanvasWebpage(const std::vector< geometrize::ShapeResult > &data)
exportCanvasWebpage Exports shape data to a HTML5 canvas-based webpage.
Definition: webpageexporter.cpp:55
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
bool writeStringToFile(const std::string &str, const std::string &path)
writeStringToFile Writes the string to the file path, attempting to overwrite any existing file at th...
Definition: util.cpp:271

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveRasterizedSVG ( ) const
inline
62  {
63  if(!m_task || !m_shapes) {
65  return;
66  }
67 
69  if(path.isEmpty()) {
70  return;
71  }
72 
73  // Rasterize as x3 normal size and downscale for less jaggy result
74  const std::uint32_t scaleFactor{3};
75  const std::uint32_t width{m_task->getCurrent().getWidth()};
76  const std::uint32_t height{m_task->getCurrent().getHeight()};
78  *m_shapes,
79  width,
80  height,
81  width * scaleFactor,
82  height * scaleFactor,
83  path.toStdString());
84  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
bool exportRasterizedSvg(const std::vector< geometrize::ShapeResult > &shapes, const std::uint32_t inputWidth, const std::uint32_t inputHeight, const std::uint32_t outputWidth, const std::uint32_t outputHeight, const std::string &filePath)
exportRasterizedSvg Exports the shape data as an image by rasterizing an SVG rendered from the shape ...
Definition: imageexporter.cpp:74
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
QString openSaveRasterizedSVGPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:127
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveRasterizedSVGs ( ) const
inline
87  {
88  if(!m_task || !m_shapes) {
90  return;
91  }
92 
94  if(path.isEmpty()) {
95  return;
96  }
97 
98  // Rasterize as x3 normal size and downscale for less jaggy result
99  const std::uint32_t scaleFactor{3};
100  const std::uint32_t width{m_task->getCurrent().getWidth()};
101  const std::uint32_t height{m_task->getCurrent().getHeight()};
103  *m_shapes,
104  width,
105  height,
106  width * scaleFactor,
107  height * scaleFactor,
108  path.toStdString(),
109  "exported_image",
110  ".png");
111  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
QString openSaveRasterizedSVGsPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:135
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
bool exportRasterizedSvgs(const std::vector< geometrize::ShapeResult > &shapes, std::uint32_t inputWidth, std::uint32_t inputHeight, std::uint32_t outputWidth, std::uint32_t outputHeight, const std::string &targetDir, const std::string &baseFilename, const std::string &fileExtension)
exportRasterizedSvgs Exports the shape data to images by rasterizing SVGs rendered from the shape dat...
Definition: imageexporter.cpp:86
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveSVG ( ) const
inline
46  {
47  if(!m_task || !m_shapes) {
49  return;
50  }
51 
52  const QString path{common::ui::openSaveSVGPathPickerDialog(q)};
53  if(path.isEmpty()) {
54  return;
55  }
56 
57  const std::string data{geometrize::exporter::exportSVG(*m_shapes, m_task->getCurrent().getWidth(), m_task->getCurrent().getHeight())};
58  util::writeStringToFile(data, path.toStdString());
59  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
QString openSaveSVGPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:119
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
bool writeStringToFile(const std::string &str, const std::string &path)
writeStringToFile Writes the string to the file path, attempting to overwrite any existing file at th...
Definition: util.cpp:271

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::saveWebGLWebpageButton ( ) const
inline
187  {
188  if(!m_shapes) {
190  return;
191  }
192 
193  const QString path{common::ui::openSaveWebGLPathPickerDialog(q)};
194  if(path.isEmpty()) {
195  return;
196  }
197 
198  const std::string pageSource{geometrize::exporter::exportWebGLWebpage(*m_shapes)};
199  util::writeStringToFile(pageSource, path.toStdString());
200  }
void showExportMisconfiguredMessage() const
Definition: imagetaskexportwidget.cpp:213
QString openSaveWebGLPathPickerDialog(QWidget *parent)
Definition: uiactions.cpp:165
std::string exportWebGLWebpage(const std::vector< geometrize::ShapeResult > &data)
exportWebGLWebpage Exports shape data to a WebGL-based webpage.
Definition: webpageexporter.cpp:60
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
bool writeStringToFile(const std::string &str, const std::string &path)
writeStringToFile Writes the string to the file path, attempting to overwrite any existing file at th...
Definition: util.cpp:271

Here is the call graph for this function:

void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::setImageTask ( const task::ImageTask task,
const std::vector< geometrize::ShapeResult > *  shapes 
)
inline
40  {
41  m_task = task;
42  m_shapes = shapes;
43  }
const geometrize::task::ImageTask * m_task
Definition: imagetaskexportwidget.cpp:219
const std::vector< geometrize::ShapeResult > * m_shapes
Definition: imagetaskexportwidget.cpp:220
void geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::showExportMisconfiguredMessage ( ) const
inlineprivate
214  {
215  QMessageBox::warning(q, tr("Failed to run exporter", "Title of error message shown when an attempt to save/export a file failed"),
216  tr("Failed to run exporter. Exporter was misconfigured.", "Error message text shown when an attempt to save/export a file failed"));
217  }
ImageTaskExportWidget * q
Definition: imagetaskexportwidget.cpp:222

Here is the caller graph for this function:

Member Data Documentation

const std::vector<geometrize::ShapeResult>* geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::m_shapes
private
const geometrize::task::ImageTask* geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::m_task
private
ImageTaskExportWidget* geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::q
private
std::unique_ptr<Ui::ImageTaskExportWidget> geometrize::dialog::ImageTaskExportWidget::ImageTaskExportWidgetImpl::ui
private

The documentation for this class was generated from the following file: