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 Attributes | List of all members
geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl Class Reference
Collaboration diagram for geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl:
Collaboration graph
[legend]

Public Member Functions

 ImageTaskPreferencesImpl ()
 
 ImageTaskPreferencesImpl (const std::string &filePath)
 
 ~ImageTaskPreferencesImpl ()=default
 
ImageTaskPreferencesImploperator= (const ImageTaskPreferencesImpl &)=default
 
 ImageTaskPreferencesImpl (const ImageTaskPreferencesImpl &)=default
 
bool load (const std::string &filePath)
 
bool save (const std::string &filePath)
 
geometrize::ImageRunnerOptions getImageRunnerOptions () const
 
void enableShapeTypes (const geometrize::ShapeTypes shapes)
 
void disableShapeTypes (const geometrize::ShapeTypes shapes)
 
void setShapeTypes (const geometrize::ShapeTypes shapes)
 
void setShapeAlpha (const std::uint8_t alpha)
 
void setCandidateShapeCount (const std::uint32_t shapeCount)
 
void setMaxShapeMutations (const std::uint32_t maxMutations)
 
void setSeed (const std::uint32_t seed)
 
void setMaxThreads (const std::uint32_t maxThreads)
 
void setScriptModeEnabled (const bool enabled)
 
bool isScriptModeEnabled () const
 
void setScript (const std::string &scriptName, const std::string &code)
 
void setScripts (const std::map< std::string, std::string > &scripts)
 
std::map< std::string,
std::string > 
getScripts () const
 

Private Attributes

serialization::ImageTaskPreferencesData m_data
 
geometrize::ImageRunnerOptions m_options
 

The data that will be serialized/deserialized

More...
 
bool m_scriptsEnabled {false}
 

The Geometrize library-level image runner options

More...
 
std::map< std::string,
std::string > 
m_scripts
 

Whether the custom Chaiscript scripts are enabled or not

More...
 

Constructor & Destructor Documentation

geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::ImageTaskPreferencesImpl ( )
inline
39  {
40  }
geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::ImageTaskPreferencesImpl ( const std::string &  filePath)
inline
43  {
44  load(filePath);
45  }
bool load(const std::string &filePath)
Definition: imagetaskpreferences.cpp:51

Here is the call graph for this function:

geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::~ImageTaskPreferencesImpl ( )
default
geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::ImageTaskPreferencesImpl ( const ImageTaskPreferencesImpl )
default

Member Function Documentation

void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::disableShapeTypes ( const geometrize::ShapeTypes  shapes)
inline
98  {
99  m_options.shapeTypes = static_cast<geometrize::ShapeTypes>(static_cast<std::uint32_t>(m_options.shapeTypes) &~ static_cast<std::uint32_t>(shapes));
100  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::enableShapeTypes ( const geometrize::ShapeTypes  shapes)
inline
93  {
94  m_options.shapeTypes = static_cast<geometrize::ShapeTypes>(static_cast<std::uint32_t>(m_options.shapeTypes) | static_cast<std::uint32_t>(shapes));
95  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
geometrize::ImageRunnerOptions geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::getImageRunnerOptions ( ) const
inline
88  {
89  return m_options;
90  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
std::map<std::string, std::string> geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::getScripts ( ) const
inline
153  {
154  return m_scripts;
155  }
std::map< std::string, std::string > m_scripts
Whether the custom Chaiscript scripts are enabled or not
Definition: imagetaskpreferences.cpp:162
bool geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::isScriptModeEnabled ( ) const
inline
138  {
139  return m_scriptsEnabled;
140  }
bool m_scriptsEnabled
The Geometrize library-level image runner options
Definition: imagetaskpreferences.cpp:161
bool geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::load ( const std::string &  filePath)
inline
52  {
53  // Preferences can be bundled into Qt resources, so we use a streamview that loads the file contents into a byte array first
54  serialization::StreamView streamView(filePath);
55  std::istream input(&streamView);
56  try {
57  cereal::JSONInputArchive archive{input};
59  } catch(...) {
60  return false;
61  }
62  return true;
63  }
void archive(Archive &ar, geometrize::ImageRunnerOptions &options, bool &scriptsEnabled, std::map< std::string, std::string > &scripts)
Definition: imagetaskpreferencesdata.h:25
bool m_scriptsEnabled
The Geometrize library-level image runner options
Definition: imagetaskpreferences.cpp:161
serialization::ImageTaskPreferencesData m_data
Definition: imagetaskpreferences.cpp:158
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
std::map< std::string, std::string > m_scripts
Whether the custom Chaiscript scripts are enabled or not
Definition: imagetaskpreferences.cpp:162

Here is the call graph for this function:

Here is the caller graph for this function:

ImageTaskPreferencesImpl& geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::operator= ( const ImageTaskPreferencesImpl )
default
bool geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::save ( const std::string &  filePath)
inline
66  {
67  // Create the directory at the filepath if it does not already exist
68  // This is necessary because the output archive will not create any missing directories
69  const QFileInfo info(QString::fromStdString(filePath));
70  const QDir dir(info.absoluteDir());
71  if(!dir.exists() && !dir.mkpath(dir.absolutePath())) {
72  assert(0 && "Failed to create directory in which to save image task preferences");
73  return false;
74  }
75 
76  std::ofstream output(filePath);
77  try {
78  cereal::JSONOutputArchive archive{output};
80  } catch(...) {
81  assert(0 && "Failed to write image task preferences");
82  return false;
83  }
84  return true;
85  }
void archive(Archive &ar, geometrize::ImageRunnerOptions &options, bool &scriptsEnabled, std::map< std::string, std::string > &scripts)
Definition: imagetaskpreferencesdata.h:25
bool m_scriptsEnabled
The Geometrize library-level image runner options
Definition: imagetaskpreferences.cpp:161
serialization::ImageTaskPreferencesData m_data
Definition: imagetaskpreferences.cpp:158
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
std::map< std::string, std::string > m_scripts
Whether the custom Chaiscript scripts are enabled or not
Definition: imagetaskpreferences.cpp:162

Here is the call graph for this function:

void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setCandidateShapeCount ( const std::uint32_t  shapeCount)
inline
113  {
114  m_options.shapeCount = shapeCount;
115  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setMaxShapeMutations ( const std::uint32_t  maxMutations)
inline
118  {
119  m_options.maxShapeMutations = maxMutations;
120  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setMaxThreads ( const std::uint32_t  maxThreads)
inline
128  {
129  m_options.maxThreads = maxThreads;
130  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setScript ( const std::string &  scriptName,
const std::string &  code 
)
inline
143  {
144  m_scripts[scriptName] = code;
145  }
std::map< std::string, std::string > m_scripts
Whether the custom Chaiscript scripts are enabled or not
Definition: imagetaskpreferences.cpp:162
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setScriptModeEnabled ( const bool  enabled)
inline
133  {
134  m_scriptsEnabled = enabled;
135  }
bool m_scriptsEnabled
The Geometrize library-level image runner options
Definition: imagetaskpreferences.cpp:161
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setScripts ( const std::map< std::string, std::string > &  scripts)
inline
148  {
149  m_scripts = scripts;
150  }
std::map< std::string, std::string > m_scripts
Whether the custom Chaiscript scripts are enabled or not
Definition: imagetaskpreferences.cpp:162
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setSeed ( const std::uint32_t  seed)
inline
123  {
124  m_options.seed = seed;
125  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setShapeAlpha ( const std::uint8_t  alpha)
inline
108  {
109  m_options.alpha = alpha;
110  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159
void geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::setShapeTypes ( const geometrize::ShapeTypes  shapes)
inline
103  {
104  m_options.shapeTypes = shapes;
105  }
geometrize::ImageRunnerOptions m_options
The data that will be serialized/deserialized
Definition: imagetaskpreferences.cpp:159

Member Data Documentation

serialization::ImageTaskPreferencesData geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::m_data
private
geometrize::ImageRunnerOptions geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::m_options
private

The data that will be serialized/deserialized

std::map<std::string, std::string> geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::m_scripts
private

Whether the custom Chaiscript scripts are enabled or not

bool geometrize::preferences::ImageTaskPreferences::ImageTaskPreferencesImpl::m_scriptsEnabled {false}
private

The Geometrize library-level image runner options


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