Utility functions to pass wxWidgets pointers from Perl to C++ code.

C++ var_dir / set_var_dir() interface to access the UI resources
from the C++ code.
This commit is contained in:
bubnikv 2017-10-17 20:00:15 +02:00
parent af51220f34
commit d9d6d996e9
9 changed files with 157 additions and 3 deletions

View file

@ -666,7 +666,7 @@ void ModelObject::cut(coordf_t z, Model* model) const
// we rather split the mesh into multiple non-intersecting pieces.
TriangleMeshPtrs meshptrs = volume->mesh.split();
for (TriangleMeshPtrs::iterator mesh = meshptrs.begin(); mesh != meshptrs.end(); ++mesh) {
printf("Cutting mesh patch %d of %d\n", size_t(mesh - meshptrs.begin()));
printf("Cutting mesh patch %d of %d\n", int(mesh - meshptrs.begin()), int(meshptrs.size()));
(*mesh)->repair();
TriangleMeshSlicer tms(*mesh);
if (mesh == meshptrs.begin()) {

View file

@ -223,6 +223,7 @@ public:
bool operator==(const Pointf &rhs) const { return this->x == rhs.x && this->y == rhs.y; }
bool operator!=(const Pointf &rhs) const { return ! (*this == rhs); }
bool operator< (const Pointf& rhs) const { return this->x < rhs.x || (this->x == rhs.x && this->y < rhs.y); }
};
inline Pointf operator+(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x + point2.x, point1.y + point2.y); }

View file

@ -6,6 +6,13 @@ namespace Slic3r {
extern void set_logging_level(unsigned int level);
extern void trace(unsigned int level, const char *message);
// Set a path with GUI resource files.
void set_var_dir(const std::string &path);
// Return a path to the GUI resource files.
const std::string& var_dir();
// Return a resource path for a file_name.
std::string var(const std::string &file_name);
extern std::string encode_path(const char *src);
extern std::string decode_path(const char *src);
extern std::string normalize_utf8_nfc(const char *src);

View file

@ -6,6 +6,8 @@
#include <boost/locale.hpp>
#include <boost/filesystem.hpp>
#include <boost/nowide/integration/filesystem.hpp>
#include <boost/nowide/convert.hpp>
@ -67,6 +69,24 @@ void trace(unsigned int level, const char *message)
(::boost::log::keywords::severity = severity)) << message;
}
static std::string g_var_dir;
void set_var_dir(const std::string &dir)
{
g_var_dir = dir;
}
const std::string& var_dir()
{
return g_var_dir;
}
std::string var(const std::string &file_name)
{
auto file = boost::filesystem::canonical(boost::filesystem::path(g_var_dir) / file_name).make_preferred();
return file.string();
}
} // namespace Slic3r
#ifdef SLIC3R_HAS_BROKEN_CROAK