Add exportable option to default styles
Primarily, this enables the user to export of construction entities in 2D views such as SVG. Previously constuction entities were always skipped. The "export these objects" is now available for all default styles. One may turn off export of constraints or the inactive groups for example. This also adds the exportable flag to the factory settings and support for saving the exportable option for default styles in the configuration. Construction entities with custom styles respect this option as well. NOTE: Running this version will add new entries to the configuration (Registry, .config etc.) on exit when testing this code.pull/964/head
parent
83dfcf44e2
commit
10ca307d98
|
@ -462,7 +462,7 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) const {
|
||||||
|
|
||||||
// Record our style for all of the Beziers that we just created.
|
// Record our style for all of the Beziers that we just created.
|
||||||
for(; i < sbl->l.n; i++) {
|
for(; i < sbl->l.n; i++) {
|
||||||
sbl->l[i].auxA = style.v;
|
sbl->l[i].auxA = Style::ForEntity(h).v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,6 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const Platform::Path &filename, bool
|
||||||
for(auto &entity : SK.entity) {
|
for(auto &entity : SK.entity) {
|
||||||
Entity *e = &entity;
|
Entity *e = &entity;
|
||||||
if(!e->IsVisible()) continue;
|
if(!e->IsVisible()) continue;
|
||||||
if(e->construction) continue;
|
|
||||||
|
|
||||||
if(SS.exportPwlCurves || sm || fabs(SS.exportOffset) > LENGTH_EPS)
|
if(SS.exportPwlCurves || sm || fabs(SS.exportOffset) > LENGTH_EPS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1085,7 +1085,9 @@ void SvgFileWriter::StartFile() {
|
||||||
fprintf(f, "}\r\n");
|
fprintf(f, "}\r\n");
|
||||||
|
|
||||||
auto export_style = [&](hStyle hs) {
|
auto export_style = [&](hStyle hs) {
|
||||||
|
Style *s = Style::Get(hs);
|
||||||
RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true);
|
RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true);
|
||||||
|
RgbaColor fillRgb = Style::FillColor(hs, /*forExport=*/true);
|
||||||
StipplePattern pattern = Style::PatternType(hs);
|
StipplePattern pattern = Style::PatternType(hs);
|
||||||
double stippleScale = Style::StippleScaleMm(hs);
|
double stippleScale = Style::StippleScaleMm(hs);
|
||||||
|
|
||||||
|
@ -1100,7 +1102,12 @@ void SvgFileWriter::StartFile() {
|
||||||
if(!patternStr.empty()) {
|
if(!patternStr.empty()) {
|
||||||
fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str());
|
fprintf(f, "stroke-dasharray:%s;\r\n", patternStr.c_str());
|
||||||
}
|
}
|
||||||
fprintf(f, "fill:none;\r\n");
|
if(s->filled) {
|
||||||
|
fprintf(f, "fill:#%02x%02x%02x;\r\n", fillRgb.red, fillRgb.green, fillRgb.blue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(f, "fill:none;\r\n");
|
||||||
|
}
|
||||||
fprintf(f, "}\r\n");
|
fprintf(f, "}\r\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -883,6 +883,7 @@ public:
|
||||||
RgbaColor color;
|
RgbaColor color;
|
||||||
double width;
|
double width;
|
||||||
int zIndex;
|
int zIndex;
|
||||||
|
bool exportable;
|
||||||
} Default;
|
} Default;
|
||||||
static const Default Defaults[];
|
static const Default Defaults[];
|
||||||
|
|
||||||
|
@ -890,6 +891,7 @@ public:
|
||||||
static std::string CnfWidth(const std::string &prefix);
|
static std::string CnfWidth(const std::string &prefix);
|
||||||
static std::string CnfTextHeight(const std::string &prefix);
|
static std::string CnfTextHeight(const std::string &prefix);
|
||||||
static std::string CnfPrefixToName(const std::string &prefix);
|
static std::string CnfPrefixToName(const std::string &prefix);
|
||||||
|
static std::string CnfExportable(const std::string &prefix);
|
||||||
|
|
||||||
static void CreateAllDefaultStyles();
|
static void CreateAllDefaultStyles();
|
||||||
static void CreateDefaultStyle(hStyle h);
|
static void CreateDefaultStyle(hStyle h);
|
||||||
|
|
|
@ -8,22 +8,22 @@
|
||||||
#include "solvespace.h"
|
#include "solvespace.h"
|
||||||
|
|
||||||
const Style::Default Style::Defaults[] = {
|
const Style::Default Style::Defaults[] = {
|
||||||
{ { ACTIVE_GRP }, "ActiveGrp", RGBf(1.0, 1.0, 1.0), 1.5, 4 },
|
{ { ACTIVE_GRP }, "ActiveGrp", RGBf(1.0, 1.0, 1.0), 1.5, 4, true },
|
||||||
{ { CONSTRUCTION }, "Construction", RGBf(0.1, 0.7, 0.1), 1.5, 0 },
|
{ { CONSTRUCTION }, "Construction", RGBf(0.1, 0.7, 0.1), 1.5, 0, false },
|
||||||
{ { INACTIVE_GRP }, "InactiveGrp", RGBf(0.5, 0.3, 0.0), 1.5, 3 },
|
{ { INACTIVE_GRP }, "InactiveGrp", RGBf(0.5, 0.3, 0.0), 1.5, 3, true },
|
||||||
{ { DATUM }, "Datum", RGBf(0.0, 0.8, 0.0), 1.5, 0 },
|
{ { DATUM }, "Datum", RGBf(0.0, 0.8, 0.0), 1.5, 0, true },
|
||||||
{ { SOLID_EDGE }, "SolidEdge", RGBf(0.8, 0.8, 0.8), 1.0, 2 },
|
{ { SOLID_EDGE }, "SolidEdge", RGBf(0.8, 0.8, 0.8), 1.0, 2, true },
|
||||||
{ { CONSTRAINT }, "Constraint", RGBf(1.0, 0.1, 1.0), 1.0, 0 },
|
{ { CONSTRAINT }, "Constraint", RGBf(1.0, 0.1, 1.0), 1.0, 0, true },
|
||||||
{ { SELECTED }, "Selected", RGBf(1.0, 0.0, 0.0), 1.5, 0 },
|
{ { SELECTED }, "Selected", RGBf(1.0, 0.0, 0.0), 1.5, 0, true },
|
||||||
{ { HOVERED }, "Hovered", RGBf(1.0, 1.0, 0.0), 1.5, 0 },
|
{ { HOVERED }, "Hovered", RGBf(1.0, 1.0, 0.0), 1.5, 0, true },
|
||||||
{ { CONTOUR_FILL }, "ContourFill", RGBf(0.0, 0.1, 0.1), 1.0, 0 },
|
{ { CONTOUR_FILL }, "ContourFill", RGBf(0.0, 0.1, 0.1), 1.0, 0, true },
|
||||||
{ { NORMALS }, "Normals", RGBf(0.0, 0.4, 0.4), 1.0, 0 },
|
{ { NORMALS }, "Normals", RGBf(0.0, 0.4, 0.4), 1.0, 0, true },
|
||||||
{ { ANALYZE }, "Analyze", RGBf(0.0, 1.0, 1.0), 3.0, 0 },
|
{ { ANALYZE }, "Analyze", RGBf(0.0, 1.0, 1.0), 3.0, 0, true },
|
||||||
{ { DRAW_ERROR }, "DrawError", RGBf(1.0, 0.0, 0.0), 8.0, 0 },
|
{ { DRAW_ERROR }, "DrawError", RGBf(1.0, 0.0, 0.0), 8.0, 0, true },
|
||||||
{ { DIM_SOLID }, "DimSolid", RGBf(0.1, 0.1, 0.1), 1.0, 0 },
|
{ { DIM_SOLID }, "DimSolid", RGBf(0.1, 0.1, 0.1), 1.0, 0, true },
|
||||||
{ { HIDDEN_EDGE }, "HiddenEdge", RGBf(0.8, 0.8, 0.8), 1.0, 1 },
|
{ { HIDDEN_EDGE }, "HiddenEdge", RGBf(0.8, 0.8, 0.8), 1.0, 1, true },
|
||||||
{ { OUTLINE }, "Outline", RGBf(0.8, 0.8, 0.8), 3.0, 5 },
|
{ { OUTLINE }, "Outline", RGBf(0.8, 0.8, 0.8), 3.0, 5, true },
|
||||||
{ { 0 }, NULL, RGBf(0.0, 0.0, 0.0), 0.0, 0 }
|
{ { 0 }, NULL, RGBf(0.0, 0.0, 0.0), 0.0, 0, true }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string Style::CnfColor(const std::string &prefix) {
|
std::string Style::CnfColor(const std::string &prefix) {
|
||||||
|
@ -35,6 +35,9 @@ std::string Style::CnfWidth(const std::string &prefix) {
|
||||||
std::string Style::CnfTextHeight(const std::string &prefix) {
|
std::string Style::CnfTextHeight(const std::string &prefix) {
|
||||||
return "Style_" + prefix + "_TextHeight";
|
return "Style_" + prefix + "_TextHeight";
|
||||||
}
|
}
|
||||||
|
std::string Style::CnfExportable(const std::string &prefix) {
|
||||||
|
return "Style_" + prefix + "_Exportable";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Style::CnfPrefixToName(const std::string &prefix) {
|
std::string Style::CnfPrefixToName(const std::string &prefix) {
|
||||||
std::string name = "#def-";
|
std::string name = "#def-";
|
||||||
|
@ -97,7 +100,9 @@ void Style::FillDefaultStyle(Style *s, const Default *d, bool factory) {
|
||||||
s->textOrigin = TextOrigin::NONE;
|
s->textOrigin = TextOrigin::NONE;
|
||||||
s->textAngle = 0;
|
s->textAngle = 0;
|
||||||
s->visible = true;
|
s->visible = true;
|
||||||
s->exportable = true;
|
s->exportable = (factory)
|
||||||
|
? d->exportable
|
||||||
|
: settings->ThawBool(CnfExportable(d->cnfPrefix), d->exportable);
|
||||||
s->filled = false;
|
s->filled = false;
|
||||||
s->fillColor = RGBf(0.3, 0.3, 0.3);
|
s->fillColor = RGBf(0.3, 0.3, 0.3);
|
||||||
s->stippleType = (d->h.v == Style::HIDDEN_EDGE) ? StipplePattern::DASH
|
s->stippleType = (d->h.v == Style::HIDDEN_EDGE) ? StipplePattern::DASH
|
||||||
|
@ -121,6 +126,7 @@ void Style::FreezeDefaultStyles(Platform::SettingsRef settings) {
|
||||||
settings->FreezeColor(CnfColor(d->cnfPrefix), Color(d->h));
|
settings->FreezeColor(CnfColor(d->cnfPrefix), Color(d->h));
|
||||||
settings->FreezeFloat(CnfWidth(d->cnfPrefix), (float)Width(d->h));
|
settings->FreezeFloat(CnfWidth(d->cnfPrefix), (float)Width(d->h));
|
||||||
settings->FreezeFloat(CnfTextHeight(d->cnfPrefix), (float)TextHeight(d->h));
|
settings->FreezeFloat(CnfTextHeight(d->cnfPrefix), (float)TextHeight(d->h));
|
||||||
|
settings->FreezeBool(CnfExportable(d->cnfPrefix), Exportable(d->h.v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,17 +856,19 @@ void TextWindow::ShowStyleInfo() {
|
||||||
((uint32_t)s->textOrigin & (uint32_t)Style::TextOrigin::TOP) ? RADIO_TRUE : RADIO_FALSE);
|
((uint32_t)s->textOrigin & (uint32_t)Style::TextOrigin::TOP) ? RADIO_TRUE : RADIO_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->h.v >= Style::FIRST_CUSTOM) {
|
Printf(false, "");
|
||||||
Printf(false, "");
|
|
||||||
|
|
||||||
|
if(s->h.v >= Style::FIRST_CUSTOM) {
|
||||||
Printf(false, " %Fd%D%f%Lv%s show these objects on screen%E",
|
Printf(false, " %Fd%D%f%Lv%s show these objects on screen%E",
|
||||||
s->h.v, &ScreenChangeStyleYesNo,
|
s->h.v, &ScreenChangeStyleYesNo,
|
||||||
s->visible ? CHECK_TRUE : CHECK_FALSE);
|
s->visible ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
Printf(false, " %Fd%D%f%Le%s export these objects%E",
|
Printf(false, " %Fd%D%f%Le%s export these objects%E",
|
||||||
s->h.v, &ScreenChangeStyleYesNo,
|
s->h.v, &ScreenChangeStyleYesNo,
|
||||||
s->exportable ? CHECK_TRUE : CHECK_FALSE);
|
s->exportable ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
|
||||||
|
if(s->h.v >= Style::FIRST_CUSTOM) {
|
||||||
Printf(false, "");
|
Printf(false, "");
|
||||||
Printf(false, "To assign lines or curves to this style,");
|
Printf(false, "To assign lines or curves to this style,");
|
||||||
Printf(false, "right-click them on the drawing.");
|
Printf(false, "right-click them on the drawing.");
|
||||||
|
|
Loading…
Reference in New Issue