Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Namespaces | Functions
util.cpp File Reference
#include "util.h"
#include <cassert>
#include <csignal>
#include <fstream>
#include <random>
#include <QApplication>
#include <QClipboard>
#include <QCoreApplication>
#include <QCursor>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDir>
#include <QDirIterator>
#include <QFileInfo>
#include <QGuiApplication>
#include <QMessageBox>
#include <QObject>
#include <QPixmap>
#include <QPoint>
#include <QScreen>
#include <QStandardPaths>
#include <QTextStream>
#include <QUrl>
#include <QWindow>
#include "dialog/scriptconsole.h"
#include "geometrize/commonutil.h"

Namespaces

 geometrize
 < Energy function passed to the image task worker thread.
 
 geometrize::util
 

Functions

void geometrize::util::debugBreak ()
 debugBreak Forces the debugger to break/halt the application when this is called. More...
 
void geometrize::util::printToConsole (const std::string &str)
 printToConsole A convenience function for printing a string to the command-line console. More...
 
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 More...
 
void geometrize::util::messageBox (const std::string &str)
 messageBox A convenience function for displaying a message box containing a message. More...
 
void geometrize::util::processApplicationEvents ()
 processApplicationEvents Processes all pending application events for the calling thread. More...
 
bool geometrize::util::fileExists (const std::string &filePath)
 fileExists Checks if a file exists, returns true if it does. More...
 
bool geometrize::util::directoryExists (const std::string &dirPath)
 directoryExists Checks if a directory exists, returns true if it does. More...
 
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. More...
 
std::string geometrize::util::readFileAsString (const std::string &filePath)
 readFileAsString Reads a file, returning a string containing the contents. More...
 
std::vector< std::string > geometrize::util::getFilePathsForDirectory (const std::string &dirPath)
 getFilePathsForDirectory Gets the absolute file paths to the files in the given directory. More...
 
std::vector< std::string > geometrize::util::getSubdirectoriesForDirectory (const std::string &dirPath)
 getSubdirectoriesForDirectory Gets the absolute paths for direct subdirectories of the given directory. More...
 
bool geometrize::util::endsWith (const std::string &value, const std::string &ending)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
std::string geometrize::util::getDirectoryForFilePath (const std::string &filePath)
 getDirectoryForFilePath Gets the directory path from the given local file path. More...
 
bool geometrize::util::openInDefaultApplication (const std::string &path)
 openInDefaultApplication Opens the given path in the default application. More...
 
bool geometrize::util::revealInDefaultApplication (const std::string &path)
 revealInDefaultApplication Reveals the given path in the parent folder (or path with the filename trimmed). More...
 
void geometrize::util::clearGlobalClipboard ()
 clearGlobalClipboard Clears the global system clipboard contents. More...
 
std::string geometrize::util::getGlobalClipboardText ()
 getGlobalClipboardText Gets the global system clipboard text. More...
 
void geometrize::util::setGlobalClipboardText (const std::string &text)
 setClipboardText Sets the global system clipboard text. More...
 
bool geometrize::util::stringBeginsWith (const std::string &str, const std::string &prefix)
 stringBeginsWith Checks if a string begins with the given prefix. More...
 
bool geometrize::util::stringEndsWith (const std::string &str, const std::string &suffix)
 stringEndsWith Checks if a string ends with the given suffix. More...
 
std::string geometrize::util::getApplicationDirectoryLocation ()
 getApplicationDirectory Get directory that the application is in. More...
 
std::string geometrize::util::getAppDataLocation ()
 getAppDataLocation Returns a directory location where persistent application data can be stored. More...
 
std::string geometrize::util::getHomeDirectoryLocation ()
 getHomeDirectoryLocation Returns a path to where the user's home directory is. More...
 
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. More...
 
std::string geometrize::util::percentEncode (const std::string &str)
 percentEncode Returns a percent-encoded copy of the input string. More...
 
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. More...
 
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. More...
 
int geometrize::util::getCursorX ()
 getCursorX Gets the x-coordinate of the cursor in global screen coordinates. More...
 
int geometrize::util::getCursorY ()
 getCursorY Gets the y-coordinate of the cursor in global screen coordinates. More...
 
void geometrize::util::setCursorPos (int x, int y)
 setCursorPos Sets the cursor position in global screen coordinates. More...
 
std::string geometrize::util::getOperatingSystemProductType ()
 getOperatingSystemProductType Returns the product name of the operating system this application is running in. More...
 
bool geometrize::util::saveDesktopScreenshot (const std::string &path)
 saveDesktopScreenshot Takes a screenshot of the desktop and saves it as a .png image to the given path. More...
 
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. More...