Remove the "style → background image" feature.

This commit is contained in:
whitequark 2017-03-13 01:12:58 +00:00
parent 5744d1d599
commit ca2aad7fea
5 changed files with 1 additions and 89 deletions

View File

@ -13,6 +13,7 @@ New sketch features:
* TTF text request has two additional points on the right side, which allow * TTF text request has two additional points on the right side, which allow
constraining the width of text. constraining the width of text.
* Image requests can now be created, similar to TTF text requests. * Image requests can now be created, similar to TTF text requests.
This replaces the "style → background image" feature.
* Irrelevant points (e.g. arc center point) are not counted when estimating * Irrelevant points (e.g. arc center point) are not counted when estimating
the bounding box used to compute chord tolerance. the bounding box used to compute chord tolerance.
* When adding a constraint which has a label and is redundant with another * When adding a constraint which has a label and is redundant with another

View File

@ -657,30 +657,6 @@ void GraphicsWindow::DrawPersistent(Canvas *canvas) {
void GraphicsWindow::Draw(Canvas *canvas) { void GraphicsWindow::Draw(Canvas *canvas) {
const Camera &camera = canvas->GetCamera(); const Camera &camera = canvas->GetCamera();
if(SS.bgImage.pixmap) {
double mmw = SS.bgImage.pixmap->width / SS.bgImage.scale,
mmh = SS.bgImage.pixmap->height / SS.bgImage.scale;
Vector n = camera.projUp.Cross(camera.projRight);
Vector origin = SS.bgImage.origin;
origin = origin.DotInToCsys(camera.projRight, camera.projUp, n);
// Place the depth of our origin at the point that corresponds to
// w = 1, so that it's unaffected by perspective.
origin.z = (offset.ScaledBy(-1)).Dot(n);
origin = origin.ScaleOutOfCsys(camera.projRight, camera.projUp, n);
// Place the background at the very back of the Z order.
Canvas::Fill fillBackground = {};
fillBackground.color = RgbaColor::From(255, 255, 255, 255);
fillBackground.layer = Canvas::Layer::BACK;
Canvas::hFill hcfBackground = canvas->GetFill(fillBackground);
canvas->DrawPixmap(SS.bgImage.pixmap,
origin, projRight.ScaledBy(mmw), projUp.ScaledBy(mmh),
{ 0.0, 1.0 }, { 1.0, 0.0 },
hcfBackground);
}
// Nasty case when we're reloading the linked files; could be that // Nasty case when we're reloading the linked files; could be that
// we get an error, so a dialog pops up, and a message loop starts, and // we get an error, so a dialog pops up, and a message loop starts, and
// we have to get called to paint ourselves. If the sketch is screwed // we have to get called to paint ourselves. If the sketch is screwed

View File

@ -779,11 +779,6 @@ public:
Vector ptA; Vector ptA;
Vector ptB; Vector ptB;
} extraLine; } extraLine;
struct {
std::shared_ptr<Pixmap> pixmap;
double scale; // pixels per mm
Vector origin;
} bgImage;
struct { struct {
bool draw, showOrigin; bool draw, showOrigin;
Vector pt, u, v; Vector pt, u, v;

View File

@ -107,7 +107,6 @@ void Style::LoadFactoryDefaults() {
FillDefaultStyle(s, d, /*factory=*/true); FillDefaultStyle(s, d, /*factory=*/true);
} }
SS.backgroundColor = RGBi(0, 0, 0); SS.backgroundColor = RGBi(0, 0, 0);
SS.bgImage.pixmap = nullptr;
} }
void Style::FreezeDefaultStyles() { void Style::FreezeDefaultStyles() {
@ -389,31 +388,6 @@ void TextWindow::ScreenChangeBackgroundColor(int link, uint32_t v) {
SS.TW.edit.meaning = Edit::BACKGROUND_COLOR; SS.TW.edit.meaning = Edit::BACKGROUND_COLOR;
} }
void TextWindow::ScreenBackgroundImage(int link, uint32_t v) {
SS.bgImage.pixmap = nullptr;
if(link == 'l') {
Platform::Path bgImageFile;
if(GetOpenFile(&bgImageFile, "", RasterFileFilter)) {
FILE *f = OpenFile(bgImageFile, "rb");
if(f) {
SS.bgImage.pixmap = Pixmap::ReadPng(f);
SS.bgImage.scale = SS.GW.scale;
SS.bgImage.origin = SS.GW.offset.ScaledBy(-1);
fclose(f);
} else {
Error("Error reading PNG file '%s'", bgImageFile.raw.c_str());
}
}
}
SS.ScheduleShowTW();
}
void TextWindow::ScreenChangeBackgroundImageScale(int link, uint32_t v) {
SS.TW.edit.meaning = Edit::BACKGROUND_IMG_SCALE;
SS.TW.ShowEditControl(10, ssprintf("%.3f", SS.bgImage.scale * SS.MmPerUnit()));
}
void TextWindow::ShowListOfStyles() { void TextWindow::ShowListOfStyles() {
Printf(true, "%Ft color style-name"); Printf(true, "%Ft color style-name");
@ -441,25 +415,6 @@ void TextWindow::ShowListOfStyles() {
rgb.redF(), rgb.greenF(), rgb.blueF(), rgb.redF(), rgb.greenF(), rgb.blueF(),
top[rows-1] + 2, &ScreenChangeBackgroundColor); top[rows-1] + 2, &ScreenChangeBackgroundColor);
Printf(false, "");
Printf(false, "%Ft background bitmap image%E");
if(SS.bgImage.pixmap) {
Printf(false, "%Ba %Ftwidth:%E %dpx %Ftheight:%E %dpx",
SS.bgImage.pixmap->width, SS.bgImage.pixmap->height);
Printf(false, " %Ftscale:%E %# px/%s %Fl%Ll%f%D[change]%E",
SS.bgImage.scale*SS.MmPerUnit(),
SS.UnitName(),
&ScreenChangeBackgroundImageScale, top[rows-1] + 2);
Printf(false, "%Ba %Fl%Lc%fclear background image%E",
&ScreenBackgroundImage);
} else {
Printf(false, "%Ba none - %Fl%Ll%fload background image%E",
&ScreenBackgroundImage);
Printf(false, " (bottom left will be center of view)");
}
Printf(false, ""); Printf(false, "");
Printf(false, " %Fl%Ll%fload factory defaults%E", Printf(false, " %Fl%Ll%fload factory defaults%E",
&ScreenLoadFactoryDefaultStyles); &ScreenLoadFactoryDefaultStyles);
@ -709,18 +664,6 @@ bool TextWindow::EditControlDoneForStyles(const char *str) {
} }
break; break;
case Edit::BACKGROUND_IMG_SCALE: {
Expr *e = Expr::From(str, true);
if(e) {
double ev = e->Eval();
if(ev < 0.001 || isnan(ev)) {
Error(_("Scale must not be zero or negative!"));
} else {
SS.bgImage.scale = ev / SS.MmPerUnit();
}
}
break;
}
default: return false; default: return false;
} }
SS.GW.persistentDirty = true; SS.GW.persistentDirty = true;

View File

@ -415,7 +415,6 @@ public:
STYLE_FILL_COLOR = 504, STYLE_FILL_COLOR = 504,
STYLE_NAME = 505, STYLE_NAME = 505,
BACKGROUND_COLOR = 506, BACKGROUND_COLOR = 506,
BACKGROUND_IMG_SCALE = 507,
STYLE_STIPPLE_PERIOD = 508, STYLE_STIPPLE_PERIOD = 508,
// For paste transforming // For paste transforming
PASTE_TIMES_REPEATED = 600, PASTE_TIMES_REPEATED = 600,
@ -511,7 +510,6 @@ public:
static void ScreenCreateCustomStyle(int link, uint32_t v); static void ScreenCreateCustomStyle(int link, uint32_t v);
static void ScreenLoadFactoryDefaultStyles(int link, uint32_t v); static void ScreenLoadFactoryDefaultStyles(int link, uint32_t v);
static void ScreenAssignSelectionToStyle(int link, uint32_t v); static void ScreenAssignSelectionToStyle(int link, uint32_t v);
static void ScreenBackgroundImage(int link, uint32_t v);
static void ScreenShowConfiguration(int link, uint32_t v); static void ScreenShowConfiguration(int link, uint32_t v);
static void ScreenShowEditView(int link, uint32_t v); static void ScreenShowEditView(int link, uint32_t v);
@ -560,7 +558,6 @@ public:
static void ScreenChangeStyleTextAngle(int link, uint32_t v); static void ScreenChangeStyleTextAngle(int link, uint32_t v);
static void ScreenChangeStyleColor(int link, uint32_t v); static void ScreenChangeStyleColor(int link, uint32_t v);
static void ScreenChangeBackgroundColor(int link, uint32_t v); static void ScreenChangeBackgroundColor(int link, uint32_t v);
static void ScreenChangeBackgroundImageScale(int link, uint32_t v);
static void ScreenChangePasteTransformed(int link, uint32_t v); static void ScreenChangePasteTransformed(int link, uint32_t v);
static void ScreenChangeViewScale(int link, uint32_t v); static void ScreenChangeViewScale(int link, uint32_t v);
static void ScreenChangeViewToFullScale(int link, uint32_t v); static void ScreenChangeViewToFullScale(int link, uint32_t v);