Geometrize  1.0
An application for geometrizing images into geometric primitives
Functions
geometrize::util Namespace Reference

Functions

void debugBreak ()
 debugBreak Forces the debugger to break/halt the application when this is called. More...
 
void printToConsole (const std::string &str)
 printToConsole A convenience function for printing a string to the command-line console. More...
 
void printToAllScriptConsoleWidgets (const std::string &str)
 printToAllScriptConsoleWidgets A convenience function for printing a string to all the GUI console widgets in the application More...
 
void messageBox (const std::string &str)
 messageBox A convenience function for displaying a message box containing a message. More...
 
void processApplicationEvents ()
 processApplicationEvents Processes all pending application events for the calling thread. More...
 
bool fileExists (const std::string &filePath)
 fileExists Checks if a file exists, returns true if it does. More...
 
bool directoryExists (const std::string &dirPath)
 directoryExists Checks if a directory exists, returns true if it does. More...
 
bool directoriesExist (const std::vector< std::string > &dirPaths)
 directoriesExist Checks if the given directories exist, returns true if all do. More...
 
bool directoryContainsFile (const std::string &dirPath, const std::string &fileName)
 directoryContainsFile Checks if the directory contains the given file, returns true if it does. More...
 
bool createDirectory (const std::string &dirPath)
 createDirectory Creates the directory at the given path, recursively creating subdirectories if needed More...
 
std::string readFileAsString (const std::string &filePath)
 readFileAsString Reads a file, returning a string containing the contents. More...
 
std::vector< std::string > getFilePathsForDirectory (const std::string &dirPath)
 getFilePathsForDirectory Gets the absolute file paths to the files in the given directory. More...
 
std::vector< std::string > getSubdirectoriesForDirectory (const std::string &dirPath)
 getSubdirectoriesForDirectory Gets the absolute paths for direct subdirectories of the given directory. More...
 
bool endsWith (const std::string &value, const std::string &ending)
 
std::vector< std::string > getFilesWithExtension (const std::string &dirPath, const std::string &extension)
 getFilesWithExtension Gets the absolute file paths to the files with the given extension in the given directory. More...
 
std::string getFirstFileWithExtension (const std::string &dirPath, const std::string &extension)
 getFirstFileWithExtension Gets the absolute file path to the first file with the given extension in the given directory. More...
 
std::string getFirstFileWithExtensions (const std::string &dirPath, const std::vector< std::string > &extensions)
 getFirstFileWithExtensions Gets the absolute file path to the first file with one of the given extensions in the given directory. More...
 
std::vector< std::string > getScriptsForPath (const std::string &path)
 getScriptsForPath Gets the absolute file paths to the script files (*.chai) for the given directory, using recursive search. More...
 
std::vector< std::string > getScriptsForPaths (const std::vector< std::string > &dirPaths)
 getScriptsForPaths Gets the absolute file paths to the script files (*.chai) for the given directories, using recursive search. More...
 
std::string getDirectoryForFilePath (const std::string &filePath)
 getDirectoryForFilePath Gets the directory path from the given local file path. More...
 
std::string getFileNameForFilePath (const std::string &filePath)
 getFileNameForFilePath Gets the filename from the given local file path. More...
 
bool openInDefaultApplication (const std::string &path)
 openInDefaultApplication Opens the given path in the default application. More...
 
bool revealInDefaultApplication (const std::string &path)
 revealInDefaultApplication Reveals the given path in the parent folder (or path with the filename trimmed). More...
 
void clearGlobalClipboard ()
 clearGlobalClipboard Clears the global system clipboard contents. More...
 
std::string getGlobalClipboardText ()
 getGlobalClipboardText Gets the global system clipboard text. More...
 
void setGlobalClipboardText (const std::string &text)
 setClipboardText Sets the global system clipboard text. More...
 
bool stringBeginsWith (const std::string &str, const std::string &prefix)
 stringBeginsWith Checks if a string begins with the given prefix. More...
 
bool stringEndsWith (const std::string &str, const std::string &suffix)
 stringEndsWith Checks if a string ends with the given suffix. More...
 
std::string getApplicationDirectoryLocation ()
 getApplicationDirectory Get directory that the application is in. More...
 
std::string getAppDataLocation ()
 getAppDataLocation Returns a directory location where persistent application data can be stored. More...
 
std::string getHomeDirectoryLocation ()
 getHomeDirectoryLocation Returns a path to where the user's home directory is. More...
 
std::string getDesktopDirectoryLocation ()
 getDesktopDirectoryLocation Returns a path to where the user's desktop is. More...
 
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 the path. More...
 
std::string percentEncode (const std::string &str)
 percentEncode Returns a percent-encoded copy of the input string. More...
 
int randomInRange (int lower, int upper)
 randomInRange Returns a random integer in the range [lower, upper], inclusive. Note that this uses thread-local RNGs under the hood. This must not be called on the same thread as the Geometrize shape mutation code - otherwise the shape generation may not be deterministic. More...
 
std::vector< std::string > split (const std::string &s, char delimiter)
 split Splits a given string into a vector of tokens using the given delimiter. More...
 
int getCursorX ()
 getCursorX Gets the x-coordinate of the cursor in global screen coordinates. More...
 
int getCursorY ()
 getCursorY Gets the y-coordinate of the cursor in global screen coordinates. More...
 
void setCursorPos (int x, int y)
 setCursorPos Sets the cursor position in global screen coordinates. More...
 
std::string getOperatingSystemProductType ()
 getOperatingSystemProductType Returns the product name of the operating system this application is running in. More...
 
bool saveWidgetScreenshot (const std::string &path, QWidget *widget)
 saveWidgetScreenshot Takes a screenshot of the given widget and saves it as a .png image to the given path. More...
 
std::vector< std::string > getAllNamedWidgets ()
 getAllWidgetNames Returns a vector containing the names of all the existing widgets in the application More...
 
std::vector< std::string > getAllNamedGeometrizeWidgets ()
 getAllWidgetNames Returns a vector containing the names of all the widgets in the application with "geometrize" in their name More...
 
QWidget * getWidgetByName (const std::string &widgetName)
 getWidgetByName Returns the first found instance of the existing widget with the given name More...
 
std::vector< std::string > getAllNamedCommandHandlers ()
 getAllNamedCommandHandlers Gets all of the existing objects in the application that implement the CommandHandler interface and can be addressed by name More...
 
geometrize::script::CommandHandlergetCommandHandlerByName (const std::string &name)
 getCommandHandlerByName Returns the first found instance of the existing command handler with the given name More...
 
void sendCommand (const std::string &target, const std::string &command)
 sendCommand Sends a command to the given command handler More...
 
void sendCommand (const std::string &target, geometrize::script::Command &command)
 sendCommand Sends a command to the given command handler More...
 
void broadcastCommand (const std::string &command)
 broadcastCommand Sends a command to all command handlers More...
 
void broadcastCommand (geometrize::script::Command &command)
 broadcastCommand Sends a command to all command handlers More...
 
std::string getFormattedTimestamp (const std::string &formatString)
 getFormattedTimestamp Gets a formatted timestamp for the current local time More...
 
std::string getFilenameTimestamp ()
 getFilenameTimestamp Gets a filename timestamp string for the current local time More...
 
std::string getUuidString ()
 getUuidString Gets a Universally Unique Identifier (UUID) as a string More...
 
void setWidgetSize (QWidget *widget, int width, int height)
 setWidgetSize Sets the size of the given widget in pixels. More...
 
void setWidgetPosition (QWidget *widget, int x, int y)
 setWidgetPosition Sets the widget to the given position. More...
 
void arrangeWidgetsInGrid (const std::vector< QWidget * > &widgets, int centerX, int centerY, int xDim, int yDim, int resizeX, int resizeY)
 arrangeWidgetsInGrid Arranges the given widgets into a grid shape More...
 
void arrangeImageTaskWidgetsInGrid (int centerX, int centerY, int xDim, int yDim, int resizeX, int resizeY)
 arrangeImageTaskWidgetsInGrid Arranges all the open image task widgets into a grid shape More...
 
void arrangeWidgetsInGridOnMonitor (const std::vector< QWidget * > &widgets, int screenIdx, int resizeX, int resizeY)
 arrangeWidgetsInGridOnMonitor Arranges the given widgets into a grid on the given monitor More...
 
void arrangeImageTaskWidgetsInGridOnMonitor (int screenIdx, int resizeX, int resizeY)
 arrangeImageTaskWidgetsInGridOnMonitor Arranges all the open image task widgets into a grid on the given monitor More...
 
void arrangeWidgetsInGridOnPrimaryMonitor (const std::vector< QWidget * > &widgets, int resizeX, int resizeY)
 arrangeWidgetsInGridOnPrimaryMonitor Arranges the given widgets into a grid on the primary monitor More...
 
void arrangeImageTaskWidgetsInGridOnPrimaryMonitor (int resizeX, int resizeY)
 arrangeImageTaskWidgetsInGridOnPrimaryMonitor Arranges all the open image task widgets into a grid on the given monitor More...
 
void fitWidgetsInGridOnMonitor (const std::vector< QWidget * > &widgets, int screenIdx)
 fitWidgetsInGridOnMonitor Fits the given widgets into a grid on the given monitor More...
 
void fitImageTaskWidgetsInGridOnMonitor (int screenIdx)
 fitImageTaskWidgetsInGridOnMonitor Fits all of the open image task widgets into a grid on the given monitor More...
 
void fitWidgetsInGridOnPrimaryMonitor (const std::vector< QWidget * > &widgets)
 fitWidgetsInGridOnPrimaryMonitor Fits the given widgets into a grid on the primary monitor More...
 
void fitImageTaskWidgetsInGridOnPrimaryMonitor ()
 fitImageTaskWidgetsInGridOnPrimaryMonitor Fits all of the open image task widgets into a grid on the primary monitor More...
 
template<typename T >
clamp (T value, T lower, T upper)
 clamp Clamps a value within a range. More...
 
template<typename T >
void split (const std::string &s, const char delimiter, T result)
 
std::vector< std::string > readStringVector (const std::string &filePath)
 readStringVector Reads the JSON file containing the vector of strings at the given filepath. Will attempt to overwrite any existing file when it does this. More...
 
void writeStringVector (const std::vector< std::string > &vec, const std::string &filePath)
 writeStringVector Writes the string vector to the given filepath as JSON. Will attempt to overwrite any existing file. More...
 
void openTask (const QString &urlStr, bool addToRecents)
 
void openTasks (const QStringList &urls, const bool addToRecents)
 
bool openTemplate (chaiscript::ChaiScript &engine, const std::string &templateFolder)
 
TemplateManifest getTemplateManifest (const std::string &templateFolder)
 

Function Documentation

◆ arrangeImageTaskWidgetsInGrid()

void geometrize::util::arrangeImageTaskWidgetsInGrid ( int  centerX,
int  centerY,
int  xDim,
int  yDim,
int  resizeX,
int  resizeY 
)

arrangeImageTaskWidgetsInGrid Arranges all the open image task widgets into a grid shape

Parameters
centerXThe x coordinate of where to center the grid
centerYThe y coordinate of where to center the grid
xDimThe number of widgets to lay out horizontally
yDimThe number of widgets to lay out vertically
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
541 {
542  arrangeWidgetsInGrid(getImageTaskWidgets(), centerX, centerY, xDim, yDim, resizeX, resizeY);
543 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arrangeImageTaskWidgetsInGridOnMonitor()

void geometrize::util::arrangeImageTaskWidgetsInGridOnMonitor ( int  screenIdx,
int  resizeX,
int  resizeY 
)

arrangeImageTaskWidgetsInGridOnMonitor Arranges all the open image task widgets into a grid on the given monitor

Parameters
screenIdxThe index of the screen to center the grid on
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
558 {
559  arrangeWidgetsInGridOnMonitor(getImageTaskWidgets(), screenIdx, resizeX, resizeY);
560 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arrangeImageTaskWidgetsInGridOnPrimaryMonitor()

void geometrize::util::arrangeImageTaskWidgetsInGridOnPrimaryMonitor ( int  resizeX,
int  resizeY 
)

arrangeImageTaskWidgetsInGridOnPrimaryMonitor Arranges all the open image task widgets into a grid on the given monitor

Parameters
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
568 {
569  arrangeWidgetsInGridOnPrimaryMonitor(getImageTaskWidgets(), resizeX, resizeY);
570 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arrangeWidgetsInGrid()

void geometrize::util::arrangeWidgetsInGrid ( const std::vector< QWidget * > &  widgets,
int  centerX,
int  centerY,
int  xDim,
int  yDim,
int  resizeX,
int  resizeY 
)

arrangeWidgetsInGrid Arranges the given widgets into a grid shape

Parameters
widgetsThe widgets to arrange
centerXThe x coordinate of where to center the grid
centerYThe y coordinate of where to center the grid
xDimThe number of widgets to lay out horizontally
yDimThe number of widgets to lay out vertically
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
522 {
523  int idx = 0;
524  const int width = xDim * resizeX;
525  const int height = yDim * resizeY;
526  for(int y = 0; y < yDim; y++) {
527  for(int x = 0; x < xDim; x++) {
528  if(idx >= widgets.size()) {
529  continue;
530  }
531  if(QWidget* widget = widgets[idx]) {
532  setWidgetSize(widget, resizeX, resizeY);
533  setWidgetPosition(widget, (centerX - width / 2) + x * resizeX, (centerY - height / 2) + y * resizeY);
534  }
535  idx++;
536  }
537  }
538 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arrangeWidgetsInGridOnMonitor()

void geometrize::util::arrangeWidgetsInGridOnMonitor ( const std::vector< QWidget * > &  widgets,
int  screenIdx,
int  resizeX,
int  resizeY 
)

arrangeWidgetsInGridOnMonitor Arranges the given widgets into a grid on the given monitor

Parameters
widgetsThe widgets to arrange
screenIdxThe index of the screen to center the grid on
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
546 {
547  QList<QScreen*> screens = QGuiApplication::screens();
548  if(screenIdx >= screens.size()) {
549  return;
550  }
551  QRect screenGeometry = screens.at(screenIdx)->geometry();
552  int height = screenGeometry.height();
553  int width = screenGeometry.width();
554  arrangeWidgetsInGrid(widgets, screenGeometry.x() + width / 2, screenGeometry.y() + height / 2, (width / resizeX), (height / resizeY), resizeX, resizeY);
555 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arrangeWidgetsInGridOnPrimaryMonitor()

void geometrize::util::arrangeWidgetsInGridOnPrimaryMonitor ( const std::vector< QWidget * > &  widgets,
int  resizeX,
int  resizeY 
)

arrangeWidgetsInGridOnPrimaryMonitor Arranges the given widgets into a grid on the primary monitor

Parameters
widgetsThe widgets to arrange
resizeXThe width to resize the widgets to
resizeYThe height to resize the widgets to
563 {
564  arrangeWidgetsInGridOnMonitor(widgets, getPrimaryScreenIdx(), resizeX, resizeY);
565 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ broadcastCommand() [1/2]

void geometrize::util::broadcastCommand ( const std::string &  command)

broadcastCommand Sends a command to all command handlers

Parameters
commandA string representation of the command
481 {
483  for(const auto& h : handlers) {
484  h->handleCommand(geometrize::script::Command(command));
485  }
486 }
Here is the caller graph for this function:

◆ broadcastCommand() [2/2]

void geometrize::util::broadcastCommand ( geometrize::script::Command command)

broadcastCommand Sends a command to all command handlers

Parameters
commandA command object representing the command
489 {
491  for(const auto& h : handlers) {
492  h->handleCommand(command);
493  }
494 }

◆ clamp()

template<typename T >
T geometrize::util::clamp ( value,
lower,
upper 
)

clamp Clamps a value within a range.

Parameters
valueThe value to clamp.
lowerThe lower bound of the range.
upperThe upper bound of the range.
Returns
The clamped value.
267 {
268  assert(lower <= upper);
269  if (value < lower) {
270  value = lower;
271  }
272  if (value > upper) {
273  value = upper;
274  }
275  return value;
276 }
Here is the caller graph for this function:

◆ clearGlobalClipboard()

void geometrize::util::clearGlobalClipboard ( )

clearGlobalClipboard Clears the global system clipboard contents.

290 {
291  QApplication::clipboard()->clear();
292 }
Here is the caller graph for this function:

◆ createDirectory()

bool geometrize::util::createDirectory ( const std::string &  dirPath)

createDirectory Creates the directory at the given path, recursively creating subdirectories if needed

Returns
True if the directory was created (or already existed), else false
151 {
152  return QDir().mkpath(QString::fromStdString(dirPath));
153 }
Here is the caller graph for this function:

◆ debugBreak()

void geometrize::util::debugBreak ( )

debugBreak Forces the debugger to break/halt the application when this is called.

76 {
77 #ifdef _MSC_VER
78  __debugbreak();
79 #elif __MINGW32__
80  // Not sure how to break here...
81  assert(0 && "Mingw32 debug break");
82 #else
83  raise(SIGTRAP);
84 #endif
85 }
Here is the caller graph for this function:

◆ directoriesExist()

bool geometrize::util::directoriesExist ( const std::vector< std::string > &  dirPaths)

directoriesExist Checks if the given directories exist, returns true if all do.

Parameters
dirPathsThe directory paths.
Returns
True if all the directories exist, false if any do not.
131 {
132  return std::all_of(dirPaths.begin(), dirPaths.end(), directoryExists);
133 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ directoryContainsFile()

bool geometrize::util::directoryContainsFile ( const std::string &  dirPath,
const std::string &  fileName 
)

directoryContainsFile Checks if the directory contains the given file, returns true if it does.

Returns
True if the directory contains the given file, false otherwise.
136 {
137  const QString qFileName{QString::fromStdString(fileName)};
138  QDirIterator it(QString::fromStdString(dirPath));
139  while(it.hasNext()) {
140  it.next();
141  if(QFileInfo(it.filePath()).isFile()) {
142  if(it.fileName() == qFileName) {
143  return true;
144  }
145  }
146  }
147  return false;
148 }
Here is the caller graph for this function:

◆ directoryExists()

bool geometrize::util::directoryExists ( const std::string &  dirPath)

directoryExists Checks if a directory exists, returns true if it does.

Parameters
dirPathThe directory path.
Returns
True if the directory exists, false if it does not.
126 {
127  return QDir(QString::fromStdString(dirPath)).exists();
128 }
Here is the caller graph for this function:

◆ endsWith()

bool geometrize::util::endsWith ( const std::string &  value,
const std::string &  ending 
)
inline
195 {
196  if (value.length() >= ending.length()) {
197  return (0 == value.compare (value.length() - ending.length(), ending.length(), ending));
198  } else {
199  return false;
200  }
201 }

◆ fileExists()

bool geometrize::util::fileExists ( const std::string &  filePath)

fileExists Checks if a file exists, returns true if it does.

Parameters
filePathThe file path.
Returns
True if the file exists, false if it does not.
121 {
122  return QFile(QString::fromStdString(filePath)).exists();
123 }
Here is the caller graph for this function:

◆ fitImageTaskWidgetsInGridOnMonitor()

void geometrize::util::fitImageTaskWidgetsInGridOnMonitor ( int  screenIdx)

fitImageTaskWidgetsInGridOnMonitor Fits all of the open image task widgets into a grid on the given monitor

Parameters
screenIdxThe index of the screen to center the grid on
588 {
589  fitWidgetsInGridOnMonitor(getImageTaskWidgets(), screenIdx);
590 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fitImageTaskWidgetsInGridOnPrimaryMonitor()

void geometrize::util::fitImageTaskWidgetsInGridOnPrimaryMonitor ( )

fitImageTaskWidgetsInGridOnPrimaryMonitor Fits all of the open image task widgets into a grid on the primary monitor

598 {
599  fitWidgetsInGridOnPrimaryMonitor(getImageTaskWidgets());
600 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fitWidgetsInGridOnMonitor()

void geometrize::util::fitWidgetsInGridOnMonitor ( const std::vector< QWidget * > &  widgets,
int  screenIdx 
)

fitWidgetsInGridOnMonitor Fits the given widgets into a grid on the given monitor

Parameters
widgetsThe widgets to arrange
screenIdxThe index of the screen to center the grid on
573 {
574  QList<QScreen*> screens = QGuiApplication::screens();
575  if(screenIdx >= screens.size()) {
576  return;
577  }
578  QRect screenGeometry = screens.at(screenIdx)->geometry();
579  const int width = screenGeometry.width();
580  const int height = screenGeometry.height();
581  const double maxWidgetsAcross = 4.0;
582  const int widgetWidth = std::max(1.0, (static_cast<double>(width) / maxWidgetsAcross) - 5);
583  const int widgetHeight = std::max(1.0, std::min((static_cast<double>(height) / (static_cast<double>(widgets.size() / maxWidgetsAcross))) - 5, 800.0));
584  arrangeWidgetsInGridOnMonitor(widgets, screenIdx, widgetWidth, widgetHeight);
585 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fitWidgetsInGridOnPrimaryMonitor()

void geometrize::util::fitWidgetsInGridOnPrimaryMonitor ( const std::vector< QWidget * > &  widgets)

fitWidgetsInGridOnPrimaryMonitor Fits the given widgets into a grid on the primary monitor

Parameters
widgetsThe widgets to arrange
593 {
594  fitWidgetsInGridOnMonitor(widgets, getPrimaryScreenIdx());
595 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllNamedCommandHandlers()

std::vector< std::string > geometrize::util::getAllNamedCommandHandlers ( )

getAllNamedCommandHandlers Gets all of the existing objects in the application that implement the CommandHandler interface and can be addressed by name

Returns
A vector containing the names of all existing objects that implement the CommandHandler interface
435 {
437  std::vector<std::string> names;
438  for(const auto& h : handlers) {
439  names.emplace_back(h->getCommandHandlerName());
440  }
441  return names;
442 }
Here is the caller graph for this function:

◆ getAllNamedGeometrizeWidgets()

std::vector< std::string > geometrize::util::getAllNamedGeometrizeWidgets ( )

getAllWidgetNames Returns a vector containing the names of all the widgets in the application with "geometrize" in their name

Returns
A vector containing the names of all the existing widgets in the application with "geometrize" in their name
412 {
413  std::vector<std::string> names;
414  const QWidgetList allWidgets = QApplication::allWidgets();
415  for (QWidget* widget : allWidgets) {
416  if(widget && widget->objectName().contains("geometrize")) {
417  names.emplace_back(widget->objectName().toStdString());
418  }
419  }
420  return names;
421 }
Here is the caller graph for this function:

◆ getAllNamedWidgets()

std::vector< std::string > geometrize::util::getAllNamedWidgets ( )

getAllWidgetNames Returns a vector containing the names of all the existing widgets in the application

Returns
A vector containing the names of all the existing widgets in the application
400 {
401  std::vector<std::string> names;
402  const QWidgetList allWidgets = QApplication::allWidgets();
403  for (QWidget* widget : allWidgets) {
404  if(widget && !widget->objectName().isEmpty()) {
405  names.emplace_back(widget->objectName().toStdString());
406  }
407  }
408  return names;
409 }
Here is the caller graph for this function:

◆ getAppDataLocation()

std::string geometrize::util::getAppDataLocation ( )

getAppDataLocation Returns a directory location where persistent application data can be stored.

Returns
Directory location where persistent application data can be stored.
320 {
321  return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).toStdString();
322 }
Here is the caller graph for this function:

◆ getApplicationDirectoryLocation()

std::string geometrize::util::getApplicationDirectoryLocation ( )

getApplicationDirectory Get directory that the application is in.

Returns
Get application directory.
315 {
316  return QCoreApplication::applicationDirPath().toStdString();
317 }
Here is the caller graph for this function:

◆ getCommandHandlerByName()

geometrize::script::CommandHandler * geometrize::util::getCommandHandlerByName ( const std::string &  name)

getCommandHandlerByName Returns the first found instance of the existing command handler with the given name

Parameters
nameThe name of the command handler to find
Returns
A pointer to the first command handler with the given name, nullptr if no match
445 {
447  for(const auto& h : handlers) {
448  if(h->getCommandHandlerName() == name)
449  {
450  return h;
451  }
452  }
453  return nullptr;
454 }
Here is the caller graph for this function:

◆ getCursorX()

int geometrize::util::getCursorX ( )

getCursorX Gets the x-coordinate of the cursor in global screen coordinates.

Returns
The x-coordinate of the cursor.
375 {
376  return QCursor::pos().x();
377 }
Here is the caller graph for this function:

◆ getCursorY()

int geometrize::util::getCursorY ( )

getCursorY Gets the y-coordinate of the cursor in global screen coordinates.

Returns
The y-coordinate of the cursor.
380 {
381  return QCursor::pos().y();
382 }
Here is the caller graph for this function:

◆ getDesktopDirectoryLocation()

std::string geometrize::util::getDesktopDirectoryLocation ( )

getDesktopDirectoryLocation Returns a path to where the user's desktop is.

Returns
Location of the user's desktop directory.
330 {
331  return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString();
332 }
Here is the caller graph for this function:

◆ getDirectoryForFilePath()

std::string geometrize::util::getDirectoryForFilePath ( const std::string &  filePath)

getDirectoryForFilePath Gets the directory path from the given local file path.

Parameters
filePathThe filepath to chop.
Returns
The directory path i.e. the file path with the file name and any trailing slashes removed.
263 {
264  const QFileInfo fileInfo{QString::fromStdString(filePath)};
265 
266  if(!fileInfo.exists()) {
267  assert(0 && "File does not exist");
268  }
269 
270  return fileInfo.absoluteDir().absolutePath().toStdString();
271 }
Here is the caller graph for this function:

◆ getFileNameForFilePath()

std::string geometrize::util::getFileNameForFilePath ( const std::string &  filePath)

getFileNameForFilePath Gets the filename from the given local file path.

Parameters
filePathThe filepath to chop.
Returns
The filename i.e. the file name from the end of the filepath
274 {
275  return QFileInfo(QString::fromStdString(filePath)).fileName().toStdString();
276 }
Here is the caller graph for this function:

◆ getFilenameTimestamp()

std::string geometrize::util::getFilenameTimestamp ( )

getFilenameTimestamp Gets a filename timestamp string for the current local time

Returns
A timestamp string in the format "yyyy_MM_dd_hh_mm_ss_zzz"
502 {
503  return getFormattedTimestamp("yyyy_MM_dd_hh_mm_ss_zzz");
504 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFilePathsForDirectory()

std::vector< std::string > geometrize::util::getFilePathsForDirectory ( const std::string &  dirPath)

getFilePathsForDirectory Gets the absolute file paths to the files in the given directory.

Parameters
dirPathThe directory to search.
Returns
A vector of files.
167 {
168  std::vector<std::string> files;
169 
170  QDirIterator it(QString::fromStdString(dirPath));
171  while(it.hasNext()) {
172  it.next();
173  if(QFileInfo(it.filePath()).isFile()) {
174  files.push_back(it.filePath().toStdString());
175  }
176  }
177  return files;
178 }
Here is the caller graph for this function:

◆ getFilesWithExtension()

std::vector< std::string > geometrize::util::getFilesWithExtension ( const std::string &  dirPath,
const std::string &  extension 
)

getFilesWithExtension Gets the absolute file paths to the files with the given extension in the given directory.

Parameters
dirPathThe directory to search.
extensionThe file extension to match.
Returns
The file paths to the files encountered, empty vector if there are no matching files. The order of the file paths is implementation-dependent.
204 {
205  std::vector<std::string> files{getFilePathsForDirectory(dirPath)};
206 
207  files.erase(std::remove_if(files.begin(), files.end(), [&extension](const std::string& s) {
208  return !endsWith(s, extension);
209  }), files.end());
210 
211  return files;
212 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFirstFileWithExtension()

std::string geometrize::util::getFirstFileWithExtension ( const std::string &  dirPath,
const std::string &  extension 
)

getFirstFileWithExtension Gets the absolute file path to the first file with the given extension in the given directory.

Parameters
dirPathThe directory to search.
extensionThe file extension to match.
Returns
The file path to the first matching file encountered, empty string if there are no matching files. The 'first' file is implementation-dependent.
215 {
216  const std::vector<std::string> files{getFilesWithExtension(dirPath, extension)};
217 
218  if(files.empty()) {
219  return "";
220  }
221  return files.front();
222 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFirstFileWithExtensions()

std::string geometrize::util::getFirstFileWithExtensions ( const std::string &  dirPath,
const std::vector< std::string > &  extensions 
)

getFirstFileWithExtensions Gets the absolute file path to the first file with one of the given extensions in the given directory.

Parameters
dirPathThe directory to search.
extensionsThe file extension to match.
Returns
The file path to the first matching file encountered, empty string if there are no matching files. The 'first' file is implementation-dependent.
225 {
226  for(const std::string& ext : extensions) {
227  const std::string s{getFirstFileWithExtension(dirPath, ext)};
228  if(!s.empty()) {
229  return s;
230  }
231  }
232 
233  return "";
234 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFormattedTimestamp()

std::string geometrize::util::getFormattedTimestamp ( const std::string &  formatString)

getFormattedTimestamp Gets a formatted timestamp for the current local time

Parameters
formatStringThe format of the timestamp e.g. "ddMMyyyy-hhmmss"
Returns
A string representing a timestamp for the current local time
497 {
498  return QDateTime::currentDateTime().toString(QString::fromStdString(formatString)).toStdString();
499 }
Here is the caller graph for this function:

◆ getGlobalClipboardText()

std::string geometrize::util::getGlobalClipboardText ( )

getGlobalClipboardText Gets the global system clipboard text.

Returns
The global system clipboard text, or an empty string if the clipboard does not contain any text.
295 {
296  return QApplication::clipboard()->text().toStdString();
297 }
Here is the caller graph for this function:

◆ getHomeDirectoryLocation()

std::string geometrize::util::getHomeDirectoryLocation ( )

getHomeDirectoryLocation Returns a path to where the user's home directory is.

Returns
Location of the user's home directory.
325 {
326  return QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString();
327 }
Here is the caller graph for this function:

◆ getOperatingSystemProductType()

std::string geometrize::util::getOperatingSystemProductType ( )

getOperatingSystemProductType Returns the product name of the operating system this application is running in.

Returns
The name of the operating system: "windows", "osx", "linux", "android", "ios", "tvos" etc
390 {
391  return QSysInfo::productType().toStdString();
392 }
Here is the caller graph for this function:

◆ getScriptsForPath()

std::vector< std::string > geometrize::util::getScriptsForPath ( const std::string &  path)

getScriptsForPath Gets the absolute file paths to the script files (*.chai) for the given directory, using recursive search.

Parameters
dirPathThe directory to search.
Returns
The absolute file paths to the script files for the given directory.
237 {
238  std::vector<std::string> scripts;
239  if(!util::directoryExists(dirPath)) {
240  assert(0 && "Script directory does not exist");
241  return scripts;
242  }
243 
244  QDirIterator it(QString::fromStdString(dirPath), { "*.chai" }, QDir::Files, QDirIterator::Subdirectories);
245  while (it.hasNext()) {
246  scripts.push_back(it.next().toStdString());
247  }
248 
249  return scripts;
250 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getScriptsForPaths()

std::vector< std::string > geometrize::util::getScriptsForPaths ( const std::vector< std::string > &  dirPaths)

getScriptsForPaths Gets the absolute file paths to the script files (*.chai) for the given directories, using recursive search.

Parameters
dirPathsThe directories to search.
Returns
The absolute file paths to the script files for the given directories.
253 {
254  std::vector<std::string> scripts;
255  for(const auto& dirPath : dirPaths) {
256  const auto newScripts = getScriptsForPath(dirPath);
257  scripts.insert(scripts.end(), newScripts.begin(), newScripts.end());
258  }
259  return scripts;
260 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSubdirectoriesForDirectory()

std::vector< std::string > geometrize::util::getSubdirectoriesForDirectory ( const std::string &  dirPath)

getSubdirectoriesForDirectory Gets the absolute paths for direct subdirectories of the given directory.

Parameters
dirPathThe directory to search.
Returns
A vector of directory paths.
181 {
182  std::vector<std::string> files;
183 
184  QDirIterator it(QString::fromStdString(dirPath));
185  while(it.hasNext()) {
186  it.next();
187  if(QFileInfo(it.filePath()).isDir()) {
188  files.push_back(it.filePath().toStdString());
189  }
190  }
191  return files;
192 }
Here is the caller graph for this function:

◆ getTemplateManifest()

TemplateManifest geometrize::util::getTemplateManifest ( const std::string &  templateFolder)
99 {
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUuidString()

std::string geometrize::util::getUuidString ( )

getUuidString Gets a Universally Unique Identifier (UUID) as a string

Returns
The UUID string
507 {
508  return QUuid::createUuid().toString().toStdString();
509 }
Here is the caller graph for this function:

◆ getWidgetByName()

QWidget * geometrize::util::getWidgetByName ( const std::string &  widgetName)

getWidgetByName Returns the first found instance of the existing widget with the given name

Parameters
widgetNameThe name of the widget to find
Returns
A pointer to the first widget instance with the given name, nullptr if no match
424 {
425  const QWidgetList allWidgets = QApplication::allWidgets();
426  for (QWidget* widget : allWidgets) {
427  if(widget && widget->objectName().toStdString() == widgetName) {
428  return widget;
429  }
430  }
431  return nullptr;
432 }
Here is the caller graph for this function:

◆ messageBox()

void geometrize::util::messageBox ( const std::string &  str)

messageBox A convenience function for displaying a message box containing a message.

Parameters
strThe string to display in the message box.
104 {
105  QMessageBox msgBox;
106  msgBox.setText(QString::fromStdString(str));
107  msgBox.exec();
108 }
Here is the caller graph for this function:

◆ openInDefaultApplication()

bool geometrize::util::openInDefaultApplication ( const std::string &  path)

openInDefaultApplication Opens the given path in the default application.

Parameters
pathThe path to the resource to open.
Returns
True if the directory, file, URL (or whatever) should open, else false.
279 {
280  return QDesktopServices::openUrl(QUrl::fromUserInput(QString::fromStdString(path)));
281 }
Here is the caller graph for this function:

◆ openTask()

void geometrize::util::openTask ( const QString &  urlStr,
bool  addToRecents 
)
32 {
33  if(urlStr.length() == 0) {
34  return;
35  }
36 
37  if(addToRecents) {
38  geometrize::getRecentItems().add(urlStr, urlStr);
39  }
40 
41  const QUrl url{QUrl::fromUserInput(urlStr)};
42  if(url.isLocalFile()) {
43  geometrize::task::createImageTaskAndWindow(url.toLocalFile().toStdString(), url.toLocalFile().toStdString(), std::nullopt);
44  return;
45  }
46 
47  std::vector<std::string> imageExtensions{format::getReadableImageFileExtensions(true)};
48  for(const std::string& ext : imageExtensions) {
49  if(url.toString().endsWith(QString::fromStdString(ext), Qt::CaseInsensitive)) {
51  return;
52  }
53  }
54 
56 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openTasks()

void geometrize::util::openTasks ( const QStringList &  urls,
const bool  addToRecents 
)
59 {
60  for(const QString& url : urls) {
61  openTask(url, addToRecents);
62  }
63 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openTemplate()

bool geometrize::util::openTemplate ( chaiscript::ChaiScript &  engine,
const std::string &  templateFolder 
)
66 {
67  const std::vector<std::string> scripts{util::getScriptsForPath(templateFolder)};
68  if(scripts.empty()) {
69  // Could not find script for template, so assume it's an image task
70  const std::string imageFile{util::getFirstFileWithExtensions(templateFolder, format::getReadableImageFileExtensions(true))};
71  if(imageFile.empty()) {
72  return false;
73  }
74 
75  // Apply settings file if a default one is available
76  const auto prefs = [&templateFolder]() -> std::optional<preferences::ImageTaskPreferences> {
77  const std::string settingsFile{geometrize::searchpaths::getDefaultTaskSettingsFilename()};
78  if(util::directoryContainsFile(templateFolder, settingsFile)) {
79  const std::string settingsPath{QDir(QString::fromStdString(templateFolder)).filePath(QString::fromStdString(settingsFile)).toStdString()};
80  const preferences::ImageTaskPreferences prefs(settingsPath);
81  return prefs;
82  }
83  return std::nullopt;
84  }();
85 
86  task::createImageTaskAndWindow(imageFile, imageFile, prefs);
87 
88  return true;
89  }
90 
91  const std::string script{util::readFileAsString(scripts.front())};
92  engine.set_global(chaiscript::var(templateFolder), "templateDirectory");
93  geometrize::script::runScript(script, engine);
94 
95  return true;
96 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ percentEncode()

std::string geometrize::util::percentEncode ( const std::string &  str)

percentEncode Returns a percent-encoded copy of the input string.

Parameters
strThe input string, to be percent-encoded.
Returns
The percent-encoded input string.
355 {
356  const QString s{QString::fromStdString(str)};
357  const QString percentEncoded{QUrl::toPercentEncoding(s)};
358  return percentEncoded.toStdString();
359 }
Here is the caller graph for this function:

◆ printToAllScriptConsoleWidgets()

void geometrize::util::printToAllScriptConsoleWidgets ( const std::string &  str)

printToAllScriptConsoleWidgets A convenience function for printing a string to all the GUI console widgets in the application

Parameters
strThe string to print to the script console widgets.
93 {
94  const auto& allWidgets = QApplication::topLevelWidgets();
95  for (const auto& widget : allWidgets) {
96  const auto& consoles = widget->findChildren<geometrize::dialog::ScriptConsole*>();
97  for(auto& console : consoles) {
98  console->appendString(str);
99  }
100  }
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printToConsole()

void geometrize::util::printToConsole ( const std::string &  str)

printToConsole A convenience function for printing a string to the command-line console.

Parameters
strThe string to print to the console.
88 {
89  QTextStream(stdout) << QString::fromStdString(str);
90 }
Here is the caller graph for this function:

◆ processApplicationEvents()

void geometrize::util::processApplicationEvents ( )

processApplicationEvents Processes all pending application events for the calling thread.

111 {
112  QCoreApplication* app = QCoreApplication::instance();
113  if(app == nullptr) {
114  assert(0 && "Application instance pointer is null");
115  return;
116  }
117  app->processEvents();
118 }
Here is the caller graph for this function:

◆ randomInRange()

int geometrize::util::randomInRange ( int  lower,
int  upper 
)

randomInRange Returns a random integer in the range [lower, upper], inclusive. Note that this uses thread-local RNGs under the hood. This must not be called on the same thread as the Geometrize shape mutation code - otherwise the shape generation may not be deterministic.

Parameters
lowerThe minimum value.
upperThe maximum value.
Returns
An integer in the range [lower, upper] inclusive.
362 {
363  assert(lower <= upper);
364  return geometrize::commonutil::randomRange(lower, upper);
365 }
Here is the caller graph for this function:

◆ readFileAsString()

std::string geometrize::util::readFileAsString ( const std::string &  filePath)

readFileAsString Reads a file, returning a string containing the contents.

Parameters
filePathThe path to the file.
Returns
The contents of the file, as a string.
156 {
157  QFile file(QString::fromStdString(filePath));
158 
159  if(file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
160  return QString(file.readAll()).toStdString();
161  }
162 
163  return "";
164 }
Here is the caller graph for this function:

◆ readStringVector()

std::vector< std::string > geometrize::util::readStringVector ( const std::string &  filePath)

readStringVector Reads the JSON file containing the vector of strings at the given filepath. Will attempt to overwrite any existing file when it does this.

Parameters
filePathThe path to the file to read.
Returns
The vector of strings read from the file.
21 {
22  if(!geometrize::util::stringEndsWith(filePath, ".json")) {
23  assert(0 && "Failed to read string vector, check file extension");
24  }
25 
26  std::vector<std::string> result;
27  std::ifstream file(filePath);
28  if(!file) {
29  return result;
30  }
31 
32  cereal::JSONInputArchive archive(file);
33  archive(result);
34  return result;
35 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ revealInDefaultApplication()

bool geometrize::util::revealInDefaultApplication ( const std::string &  path)

revealInDefaultApplication Reveals the given path in the parent folder (or path with the filename trimmed).

Parameters
pathThe path to the resource to view.
Returns
True if the file, folder, URL (or whatever) should be revealed, else false.
284 {
285  const QUrl directoryPath{QUrl::fromUserInput(QString::fromStdString(path)).adjusted(QUrl::RemoveFilename)};
286  return QDesktopServices::openUrl(directoryPath);
287 }
Here is the caller graph for this function:

◆ saveWidgetScreenshot()

bool geometrize::util::saveWidgetScreenshot ( const std::string &  path,
QWidget *  widget 
)

saveWidgetScreenshot Takes a screenshot of the given widget and saves it as a .png image to the given path.

Parameters
pathThe file path to save the screenshot to.
widgetThe widget to take a screenshot of.
Returns
True if the screenshot was taken and save successfully, else false.
395 {
396  return widget->grab().save(QString::fromStdString(path), "png");
397 }
Here is the caller graph for this function:

◆ sendCommand() [1/2]

void geometrize::util::sendCommand ( const std::string &  target,
const std::string &  command 
)

sendCommand Sends a command to the given command handler

Parameters
targetThe name of the target command handler
commandA string representation of the command
457 {
459  for(const auto& h : handlers) {
460  if(h->getCommandHandlerName() == target)
461  {
462  h->handleCommand(geometrize::script::Command(command));
463  return;
464  }
465  }
466 }
Here is the caller graph for this function:

◆ sendCommand() [2/2]

void geometrize::util::sendCommand ( const std::string &  target,
geometrize::script::Command command 
)

sendCommand Sends a command to the given command handler

Parameters
targetThe name of the target command handler
commandA command object representing the command
469 {
471  for(const auto& h : handlers) {
472  if(h->getCommandHandlerName() == target)
473  {
474  h->handleCommand(geometrize::script::Command(command));
475  return;
476  }
477  }
478 }

◆ setCursorPos()

void geometrize::util::setCursorPos ( int  x,
int  y 
)

setCursorPos Sets the cursor position in global screen coordinates.

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
385 {
386  QCursor::setPos(x, y);
387 }
Here is the caller graph for this function:

◆ setGlobalClipboardText()

void geometrize::util::setGlobalClipboardText ( const std::string &  text)

setClipboardText Sets the global system clipboard text.

Parameters
textThe text to set as the clipboard text.
300 {
301  QApplication::clipboard()->setText(QString::fromStdString(text));
302 }
Here is the caller graph for this function:

◆ setWidgetPosition()

void geometrize::util::setWidgetPosition ( QWidget *  widget,
int  x,
int  y 
)

setWidgetPosition Sets the widget to the given position.

Parameters
widgetThe widget to move.
xThe x-coordinate to set on the widget.
yThe y-coordinate to set on the widget.
517 {
518  widget->move(x, y);
519 }
Here is the caller graph for this function:

◆ setWidgetSize()

void geometrize::util::setWidgetSize ( QWidget *  widget,
int  width,
int  height 
)

setWidgetSize Sets the size of the given widget in pixels.

Parameters
widgetThe widget to resize.
widthThe width to set on the widget.
heightThe height to set on the widget.
512 {
513  widget->resize(width, height);
514 }
Here is the caller graph for this function:

◆ split() [1/2]

std::vector< std::string > geometrize::util::split ( const std::string &  s,
char  delimiter 
)

split Splits a given string into a vector of tokens using the given delimiter.

Parameters
sThe string to split.
delimiterThe delimiter to split on.
Returns
A vector containing the split string.
368 {
369  std::vector<std::string> elements;
370  split(s, delimiter, std::back_inserter(elements));
371  return elements;
372 }
Here is the caller graph for this function:

◆ split() [2/2]

template<typename T >
void geometrize::util::split ( const std::string &  s,
const char  delimiter,
result 
)
280 {
281  std::stringstream ss;
282  ss.str(s);
283  std::string item;
284  while (std::getline(ss, item, delimiter)) {
285  *(result++) = item;
286  }
287 }

◆ stringBeginsWith()

bool geometrize::util::stringBeginsWith ( const std::string &  str,
const std::string &  prefix 
)

stringBeginsWith Checks if a string begins with the given prefix.

Parameters
strThe string to check.
prefixThe prefix to check for.
Returns
True if the string begins with the given prefix, false otherwise.
305 {
306  return str.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), str.begin());
307 }
Here is the caller graph for this function:

◆ stringEndsWith()

bool geometrize::util::stringEndsWith ( const std::string &  str,
const std::string &  suffix 
)

stringEndsWith Checks if a string ends with the given suffix.

Parameters
strThe string to check.
suffixThe suffix ending to check for.
Returns
True if the string ends with the given suffix, false otherwise.
310 {
311  return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
312 }
Here is the caller graph for this function:

◆ writeStringToFile()

bool geometrize::util::writeStringToFile ( const std::string &  str,
const std::string &  path 
)

writeStringToFile Writes the string to the file path, attempting to overwrite any existing file at the path.

Parameters
strThe string to write to file.
pathThe file path to write to.
Returns
True if the string was successfully written to the file, else false.
335 {
336  std::ofstream out(path, std::ios::trunc | std::ios::out);
337  if(!out.is_open()) {
338  return false;
339  }
340 
341  if(out) {
342  out << str;
343  }
344 
345  out.close();
346 
347  if(!out) {
348  return false;
349  }
350 
351  return true;
352 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeStringVector()

void geometrize::util::writeStringVector ( const std::vector< std::string > &  vec,
const std::string &  filePath 
)

writeStringVector Writes the string vector to the given filepath as JSON. Will attempt to overwrite any existing file.

Parameters
textThe vector of strings to write.
filePathThe path of the file to write to.
38 {
39  if(!geometrize::util::stringEndsWith(filePath, ".json")) {
40  assert(0 && "Failed to write string vector, check file extension");
41  }
42 
43  // Create folders up to the path if necessary
44  const QFileInfo fileInfo(QString::fromStdString(filePath));
45  if(!fileInfo.exists()) {
46  const bool createdDir{QDir().mkpath(fileInfo.absolutePath())};
47  if(!createdDir) {
48  assert(0 && "Failed to create directory for string vector");
49  return;
50  }
51  }
52 
53  std::ofstream file(filePath);
54  cereal::JSONOutputArchive archive(file);
55  archive(cereal::make_nvp("stringVector", vec));
56 }
Here is the call graph for this function:
Here is the caller graph for this function:
chaiscript::extras::math::trunc
ModulePtr trunc(ModulePtr m=std::make_shared< Module >())
Definition: chaiscriptmathextras.h:320
geometrize::util::fitWidgetsInGridOnPrimaryMonitor
void fitWidgetsInGridOnPrimaryMonitor(const std::vector< QWidget * > &widgets)
fitWidgetsInGridOnPrimaryMonitor Fits the given widgets into a grid on the primary monitor
Definition: util.cpp:592
geometrize::util::openTask
void openTask(const QString &urlStr, bool addToRecents)
Definition: taskutil.cpp:31
geometrize::util::getFirstFileWithExtensions
std::string getFirstFileWithExtensions(const std::string &dirPath, const std::vector< std::string > &extensions)
getFirstFileWithExtensions Gets the absolute file path to the first file with one of the given extens...
Definition: util.cpp:224
geometrize::util::directoryContainsFile
bool directoryContainsFile(const std::string &dirPath, const std::string &fileName)
directoryContainsFile Checks if the directory contains the given file, returns true if it does.
Definition: util.cpp:135
geometrize::util::getScriptsForPath
std::vector< std::string > getScriptsForPath(const std::string &dirPath)
getScriptsForPath Gets the absolute file paths to the script files (*.chai) for the given directory,...
Definition: util.cpp:236
geometrize::task::createImageTaskAndWindow
ImageTask * createImageTaskAndWindow(const std::string &displayName, const std::string &taskUrl, const std::optional< geometrize::preferences::ImageTaskPreferences > &prefs)
createImageTaskAndWindow Creates an image task, and immediately creates a graphical window for manipu...
Definition: imagetaskcreator.cpp:52
geometrize::util::getFormattedTimestamp
std::string getFormattedTimestamp(const std::string &formatString)
getFormattedTimestamp Gets a formatted timestamp for the current local time
Definition: util.cpp:496
geometrize::util::fitWidgetsInGridOnMonitor
void fitWidgetsInGridOnMonitor(const std::vector< QWidget * > &widgets, int screenIdx)
fitWidgetsInGridOnMonitor Fits the given widgets into a grid on the given monitor
Definition: util.cpp:572
geometrize::util::readFileAsString
std::string readFileAsString(const std::string &filePath)
readFileAsString Reads a file, returning a string containing the contents.
Definition: util.cpp:155
geometrize::script::Command
The Command class provides a convenient way for a script to tell an object about something For exampl...
Definition: command.h:17
geometrize::network::completionhandlers::onWebpageDownloadComplete
void onWebpageDownloadComplete(network::Downloader *self, const QNetworkReply::NetworkError error)
onWebpageDownloadComplete A callback when a webpage download completes.
Definition: completionhandlers.cpp:53
geometrize::network::downloadImage
void downloadImage(const QUrl &url, const std::function< void(network::Downloader *self, QNetworkReply::NetworkError error)> &onComplete)
downloadImage Downloads an image over the network.
Definition: networkactions.cpp:13
geometrize::format::getReadableImageFileExtensions
std::vector< std::string > getReadableImageFileExtensions(const bool includeDotPrefix)
getReadableImageFileExtensions Gets the lower-case image file extensions that have read support.
Definition: formatsupport.cpp:11
geometrize::util::getFilesWithExtension
std::vector< std::string > getFilesWithExtension(const std::string &dirPath, const std::string &extension)
getFilesWithExtension Gets the absolute file paths to the files with the given extension in the given...
Definition: util.cpp:203
geometrize::getRecentItems
RecentItems & getRecentItems()
getRecentItems Gets a reference to the recent files list.
Definition: recentitems.cpp:206
geometrize::script::runScript
void runScript(const std::string &code, chaiscript::ChaiScript &runner)
runScript Evaluates the provided script code.
Definition: scriptrunner.cpp:16
geometrize::util::getFirstFileWithExtension
std::string getFirstFileWithExtension(const std::string &dirPath, const std::string &extension)
getFirstFileWithExtension Gets the absolute file path to the first file with the given extension in t...
Definition: util.cpp:214
geometrize::util::arrangeWidgetsInGrid
void arrangeWidgetsInGrid(const std::vector< QWidget * > &widgets, int centerX, int centerY, int xDim, int yDim, int resizeX, int resizeY)
arrangeWidgetsInGrid Arranges the given widgets into a grid shape
Definition: util.cpp:521
geometrize::util::getFilePathsForDirectory
std::vector< std::string > getFilePathsForDirectory(const std::string &dirPath)
getFilePathsForDirectory Gets the absolute file paths to the files in the given directory.
Definition: util.cpp:166
geometrize::util::setWidgetPosition
void setWidgetPosition(QWidget *widget, int x, int y)
setWidgetPosition Sets the widget to the given position.
Definition: util.cpp:516
geometrize::util::directoryExists
bool directoryExists(const std::string &dirPath)
directoryExists Checks if a directory exists, returns true if it does.
Definition: util.cpp:125
geometrize::dialog::ScriptConsole::appendString
void appendString(const std::string &str)
appendString Appends a string to the console output window
Definition: scriptconsole.cpp:137
geometrize::RecentItems::add
void add(const QString &itemId, const QString &itemDisplayName)
add Adds an item to the recent items.
Definition: recentitems.cpp:177
geometrize::script::CommandHandler::allCommandHandlers
static std::set< CommandHandler * > allCommandHandlers
Definition: commandhandler.h:28
geometrize::util::arrangeWidgetsInGridOnMonitor
void arrangeWidgetsInGridOnMonitor(const std::vector< QWidget * > &widgets, int screenIdx, int resizeX, int resizeY)
arrangeWidgetsInGridOnMonitor Arranges the given widgets into a grid on the given monitor
Definition: util.cpp:545
geometrize::dialog::ScriptConsole
The ScriptConsole class models a command line and output window.
Definition: scriptconsole.h:26
geometrize::network::completionhandlers::onImageDownloadComplete
void onImageDownloadComplete(network::Downloader *self, const QNetworkReply::NetworkError error)
onImageDownloadComplete A callback when an image download completes.
Definition: completionhandlers.cpp:26
geometrize::util::arrangeWidgetsInGridOnPrimaryMonitor
void arrangeWidgetsInGridOnPrimaryMonitor(const std::vector< QWidget * > &widgets, int resizeX, int resizeY)
arrangeWidgetsInGridOnPrimaryMonitor Arranges the given widgets into a grid on the primary monitor
Definition: util.cpp:562
geometrize::searchpaths::getDefaultTaskSettingsFilename
std::string getDefaultTaskSettingsFilename()
getTaskSettingsFilename Gets the default name of a task settings file that is manually saved by the u...
Definition: searchpaths.cpp:31
geometrize::format::getSupportedTemplateManifestFileExtensions
std::vector< std::string > getSupportedTemplateManifestFileExtensions()
getSupportedTemplateManifestFileExtensions Gets the supported template manifest file extensions for s...
Definition: formatsupport.cpp:28
geometrize::util::setWidgetSize
void setWidgetSize(QWidget *widget, int width, int height)
setWidgetSize Sets the size of the given widget in pixels.
Definition: util.cpp:511
geometrize::util::split
std::vector< std::string > split(const std::string &s, const char delimiter)
split Splits a given string into a vector of tokens using the given delimiter.
Definition: util.cpp:367
geometrize::util::stringEndsWith
bool stringEndsWith(const std::string &str, const std::string &suffix)
stringEndsWith Checks if a string ends with the given suffix.
Definition: util.cpp:309
geometrize::network::downloadWebpage
void downloadWebpage(const QUrl &url, const std::function< void(network::Downloader *self, QNetworkReply::NetworkError error)> &onComplete)
downloadWebpage Downloads a whole webpage over the network.
Definition: networkactions.cpp:18