Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
bindingswrapper.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <QImage>
7 
8 #include "geometrize/shaperesult.h"
9 
10 #include "common/util.h"
11 
12 class QObject;
13 
14 namespace geometrize
15 {
16 class Bitmap;
17 }
18 
19 namespace geometrize
20 {
21 
22 namespace dialog
23 {
24 class ImageTaskWindow;
25 class LaunchWindow;
26 }
27 
28 }
29 
30 namespace geometrize
31 {
32 
33 namespace scene
34 {
35 class TabletEventData;
36 }
37 
38 namespace task
39 {
40 class ImageTask;
41 }
42 
43 }
44 
45 namespace geometrize
46 {
47 
48 namespace script
49 {
50 
51 namespace bindings
52 {
53 
55 
57 
58 geometrize::task::ImageTask* createImageTask(geometrize::Bitmap& bitmap);
59 
60 std::string getApplicationDirectoryPath();
61 
62 void printToConsole(const std::string& str);
63 
64 void messageBox(const std::string& str);
65 
66 void printToAllScriptConsoleWidgets(const std::string& str);
67 
68 void debugBreak();
69 
71 
72 bool fileExists(const std::string& filePath);
73 
74 bool directoryExists(const std::string& dirPath);
75 
76 bool directoryContainsFile(const std::string& dirPath, const std::string& fileName);
77 
78 std::string readFileAsString(const std::string& filePath);
79 
80 std::vector<std::string> getFilePathsForDirectory(const std::string& dirPath);
81 
82 std::vector<std::string> getScriptSearchPaths();
83 
84 std::vector<std::string> getTemplateSearchPaths();
85 
86 std::string getFirstFileWithExtension(const std::string& dirPath, const std::string& extension);
87 
88 std::string getFirstFileWithExtensions(const std::string& dirPath, const std::vector<std::string>& extensions);
89 
90 std::vector<std::string> getFilesWithExtension(const std::string& dirPath, const std::string& extension);
91 
92 std::vector<std::string> getFilesWithExtensions(const std::string& dirPath, const std::vector<std::string>& extensions);
93 
94 std::vector<std::string> getSupportedImageFileExtensions();
95 
96 std::vector<std::string> getScriptsForPath(const std::string& dirPath);
97 
98 void openTask(const std::string& url, bool addToRecents);
99 
100 bool openInDefaultApplication(const std::string& path);
101 
102 bool revealInDefaultApplication(const std::string& path);
103 
104 void clearGlobalClipboard();
105 
106 std::string getGlobalClipboardText();
107 
108 void setGlobalClipboardText(const std::string& text);
109 
110 bool stringBeginsWith(const std::string& str, const std::string& prefix);
111 
112 bool stringEndsWith(const std::string& str, const std::string& suffix);
113 
114 std::string getApplicationDirectoryLocation();
115 
116 std::string getAppDataLocation();
117 
118 std::string getHomeDirectoryLocation();
119 
120 bool writeStringToFile(const std::string& str, const std::string& path);
121 
122 std::string percentEncode(const std::string& str);
123 
124 template<typename T, typename U, typename V>
125 T randomInRange(U lower, V upper)
126 {
127  return static_cast<T>(geometrize::util::randomInRange(static_cast<int>(lower), static_cast<int>(upper)));
128 }
129 
130 int randomIntInRange(int lower, int upper);
131 
132 float randomFloatInRange(float lower, float upper);
133 
134 template<typename T> T randomInVector(const std::vector<T>& v)
135 {
136  assert(!v.empty());
137  return v[randomInRange<int, std::size_t, std::size_t>(0, v.size() - 1)];
138 }
139 
140 template<typename T, typename U, typename V>
141 T clamp(T value, U lower, V upper)
142 {
143  assert(lower <= upper);
144  if (value < lower) {
145  value = lower;
146  }
147  if (value > upper) {
148  value = upper;
149  }
150  return value;
151 }
152 
153 int clampInt(int value, int lower, int upper);
154 
155 float clampFloat(float value, float lower, float upper);
156 
157 template<typename T>
158 bool vectorContains(const std::vector<T>& v, const T& t)
159 {
160  return (std::find(v.begin(), v.end(), t) != v.end());
161 }
162 
163 std::vector<std::string> split(const std::string& s, const char delimiter);
164 
165 std::string getOperatingSystemProductType();
166 
167 int getCursorX();
168 
169 int getCursorY();
170 
171 void setCursorPos(int x, int y);
172 
173 void setTranslatorsForLocale(const std::string& locale);
174 
175 bool exportGIF(const std::vector<geometrize::ShapeResult>& data,
176  std::uint32_t inputWidth,
177  std::uint32_t inputHeight,
178  std::uint32_t outputWidth,
179  std::uint32_t outputHeight,
180  std::size_t frameSkip,
181  const std::string& filePath);
182 
183 bool saveDesktopScreenshot(const std::string& path);
184 
185 bool saveWidgetScreenshot(const std::string& path, QWidget* widget);
186 
188 
189 }
190 
191 }
192 
193 }
void setCursorPos(const int x, const int y)
Definition: bindingswrapper.cpp:259
int getCursorX()
Definition: bindingswrapper.cpp:249
void clearGlobalClipboard()
Definition: bindingswrapper.cpp:169
void processApplicationEvents()
Definition: bindingswrapper.cpp:69
float randomFloatInRange(const float lower, const float upper)
Definition: bindingswrapper.cpp:224
std::string getOperatingSystemProductType()
Definition: bindingswrapper.cpp:244
std::vector< std::string > getFilePathsForDirectory(const std::string &dirPath)
Definition: bindingswrapper.cpp:94
The ImageTaskWindow class encapsulates the UI for manipiulating, running and viewing an image task th...
Definition: imagetaskwindow.h:28
std::string getGlobalClipboardText()
Definition: bindingswrapper.cpp:174
std::string getApplicationDirectoryLocation()
Definition: bindingswrapper.cpp:194
int getCursorY()
Definition: bindingswrapper.cpp:254
bool vectorContains(const std::vector< T > &v, const T &t)
Definition: bindingswrapper.h:158
void debugBreak()
Definition: bindingswrapper.cpp:64
int clampInt(const int value, const int lower, const int upper)
Definition: bindingswrapper.cpp:229
int randomIntInRange(const int lower, const int upper)
Definition: bindingswrapper.cpp:219
float clampFloat(const float value, const float lower, const float upper)
Definition: bindingswrapper.cpp:234
std::vector< std::string > split(const std::string &s, const char delimiter)
Definition: bindingswrapper.cpp:239
bool directoryContainsFile(const std::string &dirPath, const std::string &fileName)
Definition: bindingswrapper.cpp:84
std::vector< std::string > getSupportedImageFileExtensions()
Definition: bindingswrapper.cpp:135
T randomInVector(const std::vector< T > &v)
Definition: bindingswrapper.h:134
std::string getHomeDirectoryLocation()
Definition: bindingswrapper.cpp:204
bool exportGIF(const std::vector< geometrize::ShapeResult > &data, const std::uint32_t inputWidth, const std::uint32_t inputHeight, const std::uint32_t outputWidth, const std::uint32_t outputHeight, const std::size_t frameSkip, const std::string &filePath)
Definition: bindingswrapper.cpp:269
T clamp(T value, U lower, V upper)
Definition: bindingswrapper.h:141
std::vector< std::string > getTemplateSearchPaths()
Definition: bindingswrapper.cpp:104
bool saveDesktopScreenshot(const std::string &path)
Definition: bindingswrapper.cpp:282
void openTask(const std::string &url, const bool addToRecents)
Definition: bindingswrapper.cpp:145
bool writeStringToFile(const std::string &str, const std::string &path)
Definition: bindingswrapper.cpp:209
bool revealInDefaultApplication(const std::string &path)
Definition: bindingswrapper.cpp:164
void printToConsole(const std::string &str)
Definition: bindingswrapper.cpp:49
bool openInDefaultApplication(const std::string &path)
Definition: bindingswrapper.cpp:159
std::string getFirstFileWithExtensions(const std::string &dirPath, const std::vector< std::string > &extensions)
Definition: bindingswrapper.cpp:114
bool stringEndsWith(const std::string &str, const std::string &suffix)
Definition: bindingswrapper.cpp:189
geometrize::dialog::ImageTaskWindow * createImageTaskWindow()
Definition: bindingswrapper.cpp:29
std::string getFirstFileWithExtension(const std::string &dirPath, const std::string &extension)
Definition: bindingswrapper.cpp:109
geometrize::dialog::LaunchWindow * createLaunchWindow()
Definition: bindingswrapper.cpp:34
bool directoryExists(const std::string &dirPath)
Definition: bindingswrapper.cpp:79
std::vector< std::string > getFilesWithExtensions(const std::string &, const std::vector< std::string > &)
Definition: bindingswrapper.cpp:119
bool saveWidgetScreenshot(const std::string &path, QWidget *widget)
Definition: bindingswrapper.cpp:287
The TabletEventData class represents data produced from a Wacom pen/tablet event (in the context of a...
Definition: customtabletevent.h:55
std::vector< std::string > getScriptsForPath(const std::string &dirPath)
Definition: bindingswrapper.cpp:140
std::vector< std::string > getScriptSearchPaths()
Definition: bindingswrapper.cpp:99
std::string getAppDataLocation()
Definition: bindingswrapper.cpp:199
void setTranslatorsForLocale(const std::string &locale)
Definition: bindingswrapper.cpp:264
T randomInRange(U lower, V upper)
Definition: bindingswrapper.h:125
bool fileExists(const std::string &filePath)
Definition: bindingswrapper.cpp:74
std::vector< std::string > getFilesWithExtension(const std::string &dirPath, const std::string &extension)
Definition: bindingswrapper.cpp:130
std::string readFileAsString(const std::string &filePath)
Definition: bindingswrapper.cpp:89
bool stringBeginsWith(const std::string &str, const std::string &prefix)
Definition: bindingswrapper.cpp:184
geometrize::task::ImageTask * createImageTask(geometrize::Bitmap &bitmap)
Definition: bindingswrapper.cpp:39
void setGlobalClipboardText(const std::string &text)
Definition: bindingswrapper.cpp:179
The ImageTask class transforms a source image into a collection of shapes approximating the source im...
Definition: imagetask.h:50
std::string customTabletEventDataToString(const geometrize::scene::TabletEventData &data)
Definition: bindingswrapper.cpp:292
std::string percentEncode(const std::string &str)
Definition: bindingswrapper.cpp:214
void printToAllScriptConsoleWidgets(const std::string &str)
Definition: bindingswrapper.cpp:54
void messageBox(const std::string &str)
Definition: bindingswrapper.cpp:59
std::string getApplicationDirectoryPath()
Definition: bindingswrapper.cpp:44
The LaunchWindow class models the UI for a launchpad for opening new task templates and recent tasks...
Definition: launchwindow.h:19
int randomInRange(const int lower, const int upper)
randomInRange Returns a random integer in the range [lower, upper], inclusive. Note that this uses th...
Definition: util.cpp:298