Update selection of extrusion/lathe solid model color to use new
color picker. And apply same rule to rewrite nearly-white colors (when exporting with a file format typically viewed on a white background) for fill color as for stroke color. [git-p4: depot-paths = "//depot/solvespace/": change = 2176]
This commit is contained in:
parent
439e4d3124
commit
307965d53f
@ -160,7 +160,7 @@ void TextWindow::ScreenChangeGCodeParameter(int link, DWORD v) {
|
||||
|
||||
void TextWindow::ShowConfiguration(void) {
|
||||
int i;
|
||||
Printf(true, "%Ft material color-(r, g, b)");
|
||||
Printf(true, "%Ft user color (r, g, b)");
|
||||
|
||||
for(i = 0; i < SS.MODEL_COLORS; i++) {
|
||||
Printf(false, "%Bp #%d: %Bp %Bp (%@, %@, %@) %f%D%Ll%Fl[change]%E",
|
||||
@ -305,9 +305,10 @@ bool TextWindow::EditControlDoneForConfiguration(char *s) {
|
||||
break;
|
||||
}
|
||||
case EDIT_COLOR: {
|
||||
double r, g, b;
|
||||
if(sscanf(s, "%lf, %lf, %lf", &r, &g, &b)==3) {
|
||||
SS.modelColor[edit.i] = RGB(r*255, g*255, b*255);
|
||||
Vector rgb;
|
||||
if(sscanf(s, "%lf, %lf, %lf", &rgb.x, &rgb.y, &rgb.z)==3) {
|
||||
rgb = rgb.ClampWithin(0, 1);
|
||||
SS.modelColor[edit.i] = RGBf(rgb.x, rgb.y, rgb.z);
|
||||
} else {
|
||||
Error("Bad format: specify color as r, g, b");
|
||||
}
|
||||
|
@ -544,15 +544,16 @@ void VectorFileWriter::Output(SBezierLoopSetSet *sblss, SMesh *sm) {
|
||||
hStyle hs = { b->auxA };
|
||||
Style *stl = Style::Get(hs);
|
||||
double lineWidth = Style::WidthMm(b->auxA)*s;
|
||||
DWORD strokeRgb = Style::Color(b->auxA, true);
|
||||
DWORD strokeRgb = Style::Color(hs, true);
|
||||
DWORD fillRgb = Style::FillColor(hs, true);
|
||||
|
||||
StartPath(strokeRgb, lineWidth, stl->filled, stl->fillColor);
|
||||
StartPath(strokeRgb, lineWidth, stl->filled, fillRgb);
|
||||
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
||||
for(b = sbl->l.First(); b; b = sbl->l.NextAfter(b)) {
|
||||
Bezier(b);
|
||||
}
|
||||
}
|
||||
FinishPath(strokeRgb, lineWidth, stl->filled, stl->fillColor);
|
||||
FinishPath(strokeRgb, lineWidth, stl->filled, fillRgb);
|
||||
}
|
||||
}
|
||||
FinishAndCloseFile();
|
||||
|
3
sketch.h
3
sketch.h
@ -717,8 +717,11 @@ public:
|
||||
static void AssignSelectionToStyle(DWORD v);
|
||||
static DWORD CreateCustomStyle(void);
|
||||
|
||||
static DWORD RewriteColor(DWORD rgb);
|
||||
|
||||
static Style *Get(hStyle hs);
|
||||
static DWORD Color(hStyle hs, bool forExport=false);
|
||||
static DWORD FillColor(hStyle hs, bool forExport=false);
|
||||
static float Width(hStyle hs);
|
||||
static DWORD Color(int hs, bool forExport=false);
|
||||
static float Width(int hs);
|
||||
|
63
style.cpp
63
style.cpp
@ -1,8 +1,6 @@
|
||||
#include "solvespace.h"
|
||||
#include <png.h>
|
||||
|
||||
#define clamp01(x) (max(0, min(1, (x))))
|
||||
|
||||
const Style::Default Style::Defaults[] = {
|
||||
{ ACTIVE_GRP, "ActiveGrp", RGBf(1.0, 1.0, 1.0), 1.5, },
|
||||
{ CONSTRUCTION, "Construction", RGBf(0.1, 0.7, 0.1), 1.5, },
|
||||
@ -202,24 +200,45 @@ float Style::Width(int s) {
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Return the color associated with our style as 8-bit RGB.
|
||||
// If a color is almost white, then we can rewrite it to black, just so that
|
||||
// it won't disappear on file formats with a light background.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD Style::RewriteColor(DWORD rgbin) {
|
||||
Vector rgb = Vector::From(REDf(rgbin), GREENf(rgbin), BLUEf(rgbin));
|
||||
rgb = rgb.Minus(Vector::From(1, 1, 1));
|
||||
if(rgb.Magnitude() < 0.4 && SS.fixExportColors) {
|
||||
// This is an almost-white color in a default style, which is
|
||||
// good for the default on-screen view (black bg) but probably
|
||||
// not desired in the exported files, which typically are shown
|
||||
// against white backgrounds.
|
||||
return RGB(0, 0, 0);
|
||||
} else {
|
||||
return rgbin;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Return the stroke color associated with our style as 8-bit RGB.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD Style::Color(hStyle h, bool forExport) {
|
||||
Style *s = Get(h);
|
||||
if(forExport) {
|
||||
Vector rgb = Vector::From(REDf(s->color),
|
||||
GREENf(s->color),
|
||||
BLUEf(s->color));
|
||||
rgb = rgb.Minus(Vector::From(1, 1, 1));
|
||||
if(rgb.Magnitude() < 0.4 && SS.fixExportColors) {
|
||||
// This is an almost-white color in a default style, which is
|
||||
// good for the default on-screen view (black bg) but probably
|
||||
// not desired in the exported files, which typically are shown
|
||||
// against white backgrounds.
|
||||
return RGB(0, 0, 0);
|
||||
}
|
||||
return RewriteColor(s->color);
|
||||
} else {
|
||||
return s->color;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Return the fill color associated with our style as 8-bit RGB.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD Style::FillColor(hStyle h, bool forExport) {
|
||||
Style *s = Get(h);
|
||||
if(forExport) {
|
||||
return RewriteColor(s->fillColor);
|
||||
} else {
|
||||
return s->fillColor;
|
||||
}
|
||||
return s->color;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -649,21 +668,19 @@ bool TextWindow::EditControlDoneForStyles(char *str) {
|
||||
case EDIT_BACKGROUND_COLOR:
|
||||
case EDIT_STYLE_FILL_COLOR:
|
||||
case EDIT_STYLE_COLOR: {
|
||||
double r, g, b;
|
||||
if(sscanf(str, "%lf, %lf, %lf", &r, &g, &b)==3) {
|
||||
r = clamp01(r);
|
||||
g = clamp01(g);
|
||||
b = clamp01(b);
|
||||
Vector rgb;
|
||||
if(sscanf(str, "%lf, %lf, %lf", &rgb.x, &rgb.y, &rgb.z)==3) {
|
||||
rgb = rgb.ClampWithin(0, 1);
|
||||
if(edit.meaning == EDIT_STYLE_COLOR) {
|
||||
SS.UndoRemember();
|
||||
s = Style::Get(edit.style);
|
||||
s->color = RGBf(r, g, b);
|
||||
s->color = RGBf(rgb.x, rgb.y, rgb.z);
|
||||
} else if(edit.meaning == EDIT_STYLE_FILL_COLOR) {
|
||||
SS.UndoRemember();
|
||||
s = Style::Get(edit.style);
|
||||
s->fillColor = RGBf(r, g, b);
|
||||
s->fillColor = RGBf(rgb.x, rgb.y, rgb.z);
|
||||
} else {
|
||||
SS.backgroundColor = RGBf(r, g, b);
|
||||
SS.backgroundColor = RGBf(rgb.x, rgb.y, rgb.z);
|
||||
}
|
||||
} else {
|
||||
Error("Bad format: specify color as r, g, b");
|
||||
|
@ -238,11 +238,8 @@ void TextWindow::ScreenColor(int link, DWORD v) {
|
||||
SS.UndoRemember();
|
||||
|
||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||
if(v < 0 || v >= SS.MODEL_COLORS) return;
|
||||
g->color = SS.modelColor[v];
|
||||
SS.MarkGroupDirty(g->h);
|
||||
SS.GenerateAll();
|
||||
SS.GW.ClearSuper();
|
||||
SS.TW.ShowEditControlWithColorPicker(v, 3, g->color);
|
||||
SS.TW.edit.meaning = EDIT_GROUP_COLOR;
|
||||
}
|
||||
void TextWindow::ScreenChangeExprA(int link, DWORD v) {
|
||||
Group *g = SK.GetGroup(SS.TW.shown.group);
|
||||
@ -383,17 +380,11 @@ void TextWindow::ShowGroupInfo(void) {
|
||||
if(g->type == Group::EXTRUDE ||
|
||||
g->type == Group::LATHE)
|
||||
{
|
||||
#define TWOX(v) v v
|
||||
Printf(false, "%Bd %Ftcolor%E "
|
||||
TWOX(TWOX(TWOX("%Bp%D%f%Ln %Bd%E "))),
|
||||
0x80000000 | SS.modelColor[0], 0, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[1], 1, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[2], 2, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[3], 3, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[4], 4, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[5], 5, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[6], 6, &TextWindow::ScreenColor,
|
||||
0x80000000 | SS.modelColor[7], 7, &TextWindow::ScreenColor);
|
||||
Printf(false,
|
||||
"%Bd %Ftcolor %E%Bp %Bd (%@, %@, %@) %f%D%Lf%Fl[change]%E",
|
||||
0x80000000 | g->color,
|
||||
REDf(g->color), GREENf(g->color), BLUEf(g->color),
|
||||
ScreenColor, top[rows-1] + 2);
|
||||
} else if(g->type == Group::IMPORTED) {
|
||||
bool sup = g->suppress;
|
||||
Printf(false, " %Fd%f%LP%c suppress this group's solid model",
|
||||
@ -701,6 +692,23 @@ void TextWindow::EditControlDone(char *s) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EDIT_GROUP_COLOR: {
|
||||
Vector rgb;
|
||||
if(sscanf(s, "%lf, %lf, %lf", &rgb.x, &rgb.y, &rgb.z)==3) {
|
||||
rgb = rgb.ClampWithin(0, 1);
|
||||
|
||||
Group *g = SK.group.FindByIdNoOops(SS.TW.shown.group);
|
||||
if(!g) break;
|
||||
g->color = RGBf(rgb.x, rgb.y, rgb.z);
|
||||
|
||||
SS.MarkGroupDirty(g->h);
|
||||
SS.later.generateAll = true;
|
||||
SS.GW.ClearSuper();
|
||||
} else {
|
||||
Error("Bad format: specify color as r, g, b");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EDIT_TTF_TEXT: {
|
||||
SS.UndoRemember();
|
||||
Request *r = SK.request.FindByIdNoOops(edit.request);
|
||||
|
1
ui.h
1
ui.h
@ -132,6 +132,7 @@ public:
|
||||
static const int EDIT_TIMES_REPEATED = 1;
|
||||
static const int EDIT_GROUP_NAME = 2;
|
||||
static const int EDIT_GROUP_SCALE = 3;
|
||||
static const int EDIT_GROUP_COLOR = 4;
|
||||
// For the configuraiton screen
|
||||
static const int EDIT_LIGHT_DIRECTION = 100;
|
||||
static const int EDIT_LIGHT_INTENSITY = 101;
|
||||
|
@ -1,10 +1,9 @@
|
||||
O(n*log(n)) assembly of edges into contours
|
||||
make group model color use new color picker
|
||||
fix anti-aliased edge bug with filled contours
|
||||
crude DXF, HPGL import
|
||||
a request to import a plane thing
|
||||
make export assemble only contours in same group
|
||||
make export rewrite fill color same as stroke color
|
||||
rotation works about first point under cursor
|
||||
|
||||
-----
|
||||
rounding, as a special group
|
||||
|
Loading…
Reference in New Issue
Block a user