OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{SketchInlineEditor.cpp} Namespace Reference

Functions

std::string fmt_value (double v, int digits=3)
bool parse_value (const char *text, double &out)
void ux_trace (const char *event, const std::string &title, const std::string &detail)

Variables

const char *const kWindowName = "##sketchvalue"

Function Documentation

◆ fmt_value()

std::string Slic3r::GUI::anonymous_namespace{SketchInlineEditor.cpp}::fmt_value ( double v,
int digits = 3 )
30{
31 char fmt[16];
32 std::snprintf(fmt, sizeof(fmt), "%%.%df", digits);
33 char buf[64];
34 std::snprintf(buf, sizeof(buf), fmt, v);
35 for (char* c = buf; *c; ++c)
36 if (*c == ',') *c = '.';
37 std::string s(buf);
38 if (s.find('.') != std::string::npos) {
39 while (!s.empty() && s.back() == '0') s.pop_back();
40 if (!s.empty() && s.back() == '.') s.pop_back();
41 }
42 if (s == "-0") s = "0";
43 return s;
44}

References fmt_value().

Referenced by fmt_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_value()

bool Slic3r::GUI::anonymous_namespace{SketchInlineEditor.cpp}::parse_value ( const char * text,
double & out )
47{
48 if (text == nullptr) return false;
49 std::string t(text);
50 for (char& c : t)
51 if (c == ',') c = '.';
52 // strtod, not std::stod: no exceptions, and `end` tells us whether the WHOLE field was a
53 // number. "12mm" must be refused, not silently read as 12.
54 const char* b = t.c_str();
55 char* end = nullptr;
56 const double v = std::strtod(b, &end);
57 if (end == b) return false;
58 while (*end == ' ' || *end == '\t') ++end;
59 if (*end != '\0') return false;
60 out = v;
61 return true;
62}

References parse_value().

Referenced by parse_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ux_trace()

void Slic3r::GUI::anonymous_namespace{SketchInlineEditor.cpp}::ux_trace ( const char * event,
const std::string & title,
const std::string & detail )
74{
75 if (!std::getenv("ORCA_CAD_UXTRACE")) return;
76 std::fprintf(stderr, "[UX] %s title=%s %s\n", event, title.c_str(), detail.c_str());
77 std::fflush(stderr);
78}
Definition PluginsDialog.hpp:60

References ux_trace().

Referenced by ux_trace().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ kWindowName

const char* const Slic3r::GUI::anonymous_namespace{SketchInlineEditor.cpp}::kWindowName = "##sketchvalue"