Add ExportBackgroundColor config to GUI and CLI
parent
d3da2c8b22
commit
028b613f10
|
@ -94,6 +94,10 @@ void TextWindow::ScreenChangeFixExportColors(int link, uint32_t v) {
|
|||
SS.fixExportColors = !SS.fixExportColors;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeExportBackgroundColor(int link, uint32_t v) {
|
||||
SS.exportBackgroundColor = !SS.exportBackgroundColor;
|
||||
}
|
||||
|
||||
void TextWindow::ScreenChangeBackFaces(int link, uint32_t v) {
|
||||
SS.drawBackFaces = !SS.drawBackFaces;
|
||||
SS.GW.Invalidate(/*clearPersistent=*/true);
|
||||
|
@ -299,6 +303,9 @@ void TextWindow::ShowConfiguration() {
|
|||
Printf(false, " %Fd%f%Ll%s fix white exported lines%E",
|
||||
&ScreenChangeFixExportColors,
|
||||
SS.fixExportColors ? CHECK_TRUE : CHECK_FALSE);
|
||||
Printf(false, " %Fd%f%Ll%s export background color%E",
|
||||
&ScreenChangeExportBackgroundColor,
|
||||
SS.exportBackgroundColor ? CHECK_TRUE : CHECK_FALSE);
|
||||
|
||||
Printf(false, "");
|
||||
Printf(false, "%Ft export canvas size: "
|
||||
|
|
|
@ -25,6 +25,8 @@ Common options:
|
|||
piecewise linear, and exact surfaces into triangle meshes.
|
||||
For export commands, the unit is mm, and the default is 1.0 mm.
|
||||
For non-export commands, the unit is %%, and the default is 1.0 %%.
|
||||
-b, --bg-color <on|off>
|
||||
Whether to export the background colour in vector formats. Defaults to off.
|
||||
|
||||
Commands:
|
||||
thumbnail --output <pattern> --size <size> --view <direction>
|
||||
|
@ -33,6 +35,7 @@ Commands:
|
|||
<size> is <width>x<height>, in pixels. Graphics acceleration is
|
||||
not used, and the output may look slightly different from the GUI.
|
||||
export-view --output <pattern> --view <direction> [--chord-tol <tolerance>]
|
||||
[--bg-color <on|off>]
|
||||
Exports a view of the sketch, in a 2d vector format.
|
||||
export-wireframe --output <pattern> [--chord-tol <tolerance>]
|
||||
Exports a wireframe of the sketch, in a 3d vector format.
|
||||
|
@ -155,6 +158,21 @@ static bool RunCommand(const std::vector<std::string> args) {
|
|||
} else return false;
|
||||
};
|
||||
|
||||
bool bg_color = false;
|
||||
auto ParseBgColor = [&](size_t &argn) {
|
||||
if(argn + 1 < args.size() && (args[argn] == "--bg-color" ||
|
||||
args[argn] == "-b")) {
|
||||
argn++;
|
||||
if(args[argn] == "on") {
|
||||
bg_color = true;
|
||||
return true;
|
||||
} else if(args[argn] == "off") {
|
||||
bg_color = false;
|
||||
return true;
|
||||
} else return false;
|
||||
} else return false;
|
||||
};
|
||||
|
||||
unsigned width = 0, height = 0;
|
||||
if(args[1] == "thumbnail") {
|
||||
auto ParseSize = [&](size_t &argn) {
|
||||
|
@ -221,7 +239,8 @@ static bool RunCommand(const std::vector<std::string> args) {
|
|||
if(!(ParseInputFile(argn) ||
|
||||
ParseOutputPattern(argn) ||
|
||||
ParseViewDirection(argn) ||
|
||||
ParseChordTolerance(argn))) {
|
||||
ParseChordTolerance(argn) ||
|
||||
ParseBgColor(argn))) {
|
||||
fprintf(stderr, "Unrecognized option '%s'.\n", args[argn].c_str());
|
||||
return false;
|
||||
}
|
||||
|
@ -233,9 +252,10 @@ static bool RunCommand(const std::vector<std::string> args) {
|
|||
}
|
||||
|
||||
runner = [&](const Platform::Path &output) {
|
||||
SS.GW.projRight = projRight;
|
||||
SS.GW.projUp = projUp;
|
||||
SS.exportChordTol = chordTol;
|
||||
SS.GW.projRight = projRight;
|
||||
SS.GW.projUp = projUp;
|
||||
SS.exportChordTol = chordTol;
|
||||
SS.exportBackgroundColor = bg_color;
|
||||
|
||||
SS.ExportViewOrWireframeTo(output, /*exportWireframe=*/false);
|
||||
};
|
||||
|
|
|
@ -68,6 +68,8 @@ void SolveSpaceUI::Init() {
|
|||
exportOffset = settings->ThawFloat("ExportOffset", 0.0);
|
||||
// Rewrite exported colors close to white into black (assuming white bg)
|
||||
fixExportColors = settings->ThawBool("FixExportColors", true);
|
||||
// Export background color
|
||||
exportBackgroundColor = settings->ThawBool("ExportBackgroundColor", false);
|
||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||
drawBackFaces = settings->ThawBool("DrawBackFaces", true);
|
||||
// Use turntable mouse navigation
|
||||
|
@ -246,6 +248,8 @@ void SolveSpaceUI::Exit() {
|
|||
settings->FreezeFloat("ExportOffset", exportOffset);
|
||||
// Rewrite exported colors close to white into black (assuming white bg)
|
||||
settings->FreezeBool("FixExportColors", fixExportColors);
|
||||
// Export background color
|
||||
settings->FreezeBool("ExportBackgroundColor", exportBackgroundColor);
|
||||
// Draw back faces of triangles (when mesh is leaky/self-intersecting)
|
||||
settings->FreezeBool("DrawBackFaces", drawBackFaces);
|
||||
// Draw closed polygons areas
|
||||
|
|
|
@ -559,6 +559,7 @@ public:
|
|||
double exportScale;
|
||||
double exportOffset;
|
||||
bool fixExportColors;
|
||||
bool exportBackgroundColor;
|
||||
bool drawBackFaces;
|
||||
bool showContourAreas;
|
||||
bool checkClosedContour;
|
||||
|
|
1
src/ui.h
1
src/ui.h
|
@ -434,6 +434,7 @@ public:
|
|||
static void ScreenGoToWebsite(int link, uint32_t v);
|
||||
|
||||
static void ScreenChangeFixExportColors(int link, uint32_t v);
|
||||
static void ScreenChangeExportBackgroundColor(int link, uint32_t v);
|
||||
static void ScreenChangeBackFaces(int link, uint32_t v);
|
||||
static void ScreenChangeShowContourAreas(int link, uint32_t v);
|
||||
static void ScreenChangeCheckClosedContour(int link, uint32_t v);
|
||||
|
|
Loading…
Reference in New Issue