diff --git a/CHANGELOG.md b/CHANGELOG.md index c85bda3..caa1d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ New sketch features: * TTF text request has two additional points on the right side, which allow constraining the width of text. * 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 the bounding box used to compute chord tolerance. * When adding a constraint which has a label and is redundant with another diff --git a/src/draw.cpp b/src/draw.cpp index 1a638a7..bbe0b2c 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -657,30 +657,6 @@ void GraphicsWindow::DrawPersistent(Canvas *canvas) { void GraphicsWindow::Draw(Canvas *canvas) { 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 // 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 diff --git a/src/solvespace.h b/src/solvespace.h index 82c37d4..3330095 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -779,11 +779,6 @@ public: Vector ptA; Vector ptB; } extraLine; - struct { - std::shared_ptr pixmap; - double scale; // pixels per mm - Vector origin; - } bgImage; struct { bool draw, showOrigin; Vector pt, u, v; diff --git a/src/style.cpp b/src/style.cpp index c08f7ed..9729b3e 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -107,7 +107,6 @@ void Style::LoadFactoryDefaults() { FillDefaultStyle(s, d, /*factory=*/true); } SS.backgroundColor = RGBi(0, 0, 0); - SS.bgImage.pixmap = nullptr; } void Style::FreezeDefaultStyles() { @@ -389,31 +388,6 @@ void TextWindow::ScreenChangeBackgroundColor(int link, uint32_t v) { 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() { Printf(true, "%Ft color style-name"); @@ -441,25 +415,6 @@ void TextWindow::ShowListOfStyles() { rgb.redF(), rgb.greenF(), rgb.blueF(), 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, " %Fl%Ll%fload factory defaults%E", &ScreenLoadFactoryDefaultStyles); @@ -709,18 +664,6 @@ bool TextWindow::EditControlDoneForStyles(const char *str) { } 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; } SS.GW.persistentDirty = true; diff --git a/src/ui.h b/src/ui.h index bdef6ce..dcc9db4 100644 --- a/src/ui.h +++ b/src/ui.h @@ -415,7 +415,6 @@ public: STYLE_FILL_COLOR = 504, STYLE_NAME = 505, BACKGROUND_COLOR = 506, - BACKGROUND_IMG_SCALE = 507, STYLE_STIPPLE_PERIOD = 508, // For paste transforming PASTE_TIMES_REPEATED = 600, @@ -511,7 +510,6 @@ public: static void ScreenCreateCustomStyle(int link, uint32_t v); static void ScreenLoadFactoryDefaultStyles(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 ScreenShowEditView(int link, uint32_t v); @@ -560,7 +558,6 @@ public: static void ScreenChangeStyleTextAngle(int link, uint32_t v); static void ScreenChangeStyleColor(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 ScreenChangeViewScale(int link, uint32_t v); static void ScreenChangeViewToFullScale(int link, uint32_t v);