diff --git a/CHANGELOG.md b/CHANGELOG.md
index e18bccb..37fd2f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ New export/import features:
Other new features:
* New command for measuring total length of selected entities,
"Analyze → Measure Perimeter".
+ * New link to match the on-screen size of the sketch with its actual size,
+ "view → set to full scale".
2.2
---
diff --git a/res/win32/manifest.xml b/res/win32/manifest.xml
index f27a236..22a78cc 100644
--- a/res/win32/manifest.xml
+++ b/res/win32/manifest.xml
@@ -6,6 +6,11 @@
name="JonathanWesthues.3dCAD.SolveSpace"
type="win32"
/>
+
+
+ true
+
+
Parametric 3d CAD tool.
diff --git a/src/platform/cocoamain.mm b/src/platform/cocoamain.mm
index f448441..94be0c6 100644
--- a/src/platform/cocoamain.mm
+++ b/src/platform/cocoamain.mm
@@ -1045,6 +1045,15 @@ void GetTextWindowSize(int *w, int *h) {
*h = (int)size.height;
}
+double GetScreenDpi() {
+ NSScreen *screen = [NSScreen mainScreen];
+ NSDictionary *description = [screen deviceDescription];
+ NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
+ CGSize displayPhysicalSize = CGDisplayScreenSize(
+ [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+ return (displayPixelSize.width / displayPhysicalSize.width) * 25.4f;
+}
+
void InvalidateText(void) {
NSSize size = [TWView convertSizeToBacking:[TWView frame].size];
size.height = (SS.TW.top[SS.TW.rows - 1] + 1) * TextWindow::LINE_HEIGHT / 2;
diff --git a/src/platform/gtkmain.cpp b/src/platform/gtkmain.cpp
index 4f20f50..1b7aa60 100644
--- a/src/platform/gtkmain.cpp
+++ b/src/platform/gtkmain.cpp
@@ -1420,6 +1420,10 @@ void GetTextWindowSize(int *w, int *h) {
*h = allocation.get_height();
}
+double GetScreenDpi() {
+ return Gdk::Screen::get_default()->get_resolution();
+}
+
void InvalidateText(void) {
TW->get_widget().queue_draw();
}
diff --git a/src/platform/headless.cpp b/src/platform/headless.cpp
index 9580e0f..8b949d6 100644
--- a/src/platform/headless.cpp
+++ b/src/platform/headless.cpp
@@ -96,6 +96,9 @@ void ScheduleLater() {
void GetGraphicsWindowSize(int *w, int *h) {
*w = *h = 600;
}
+double GetScreenDpi() {
+ return 72;
+}
void InvalidateGraphics() {
}
diff --git a/src/platform/w32main.cpp b/src/platform/w32main.cpp
index a74a05a..c4b7e91 100644
--- a/src/platform/w32main.cpp
+++ b/src/platform/w32main.cpp
@@ -266,6 +266,13 @@ void SolveSpace::GetTextWindowSize(int *w, int *h)
GetWindowSize(TextWnd, w, h);
}
+double SolveSpace::GetScreenDpi() {
+ HDC hdc = GetDC(NULL);
+ double dpi = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
+ return dpi;
+}
+
void SolveSpace::OpenWebsite(const char *url) {
ShellExecuteW(GraphicsWnd, L"open", Widen(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
}
diff --git a/src/solvespace.h b/src/solvespace.h
index 03c8a6e..9fbe77e 100644
--- a/src/solvespace.h
+++ b/src/solvespace.h
@@ -264,6 +264,7 @@ void ToggleFullScreen();
bool FullScreenIsActive();
void GetGraphicsWindowSize(int *w, int *h);
void GetTextWindowSize(int *w, int *h);
+double GetScreenDpi();
int64_t GetMilliseconds();
void dbp(const char *str, ...);
diff --git a/src/ui.h b/src/ui.h
index f1be194..a216674 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -457,6 +457,7 @@ public:
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);
static void ScreenChangeViewOrigin(int link, uint32_t v);
static void ScreenChangeViewProjection(int link, uint32_t v);
diff --git a/src/view.cpp b/src/view.cpp
index c1a2bfa..6f91eb6 100644
--- a/src/view.cpp
+++ b/src/view.cpp
@@ -14,6 +14,8 @@ void TextWindow::ShowEditView() {
SS.GW.scale * SS.MmPerUnit(),
SS.UnitName(),
&ScreenChangeViewScale);
+ Printf(false, "%Bd %Fl%Ll%fset to full scale%E",
+ &ScreenChangeViewToFullScale);
Printf(false, "");
Printf(false, "%Bd %Ftorigin (maps to center of screen)%E");
@@ -42,6 +44,10 @@ void TextWindow::ScreenChangeViewScale(int link, uint32_t v) {
SS.TW.ShowEditControl(3, ssprintf("%.3f", SS.GW.scale * SS.MmPerUnit()));
}
+void TextWindow::ScreenChangeViewToFullScale(int link, uint32_t v) {
+ SS.GW.scale = GetScreenDpi() / 25.4;
+}
+
void TextWindow::ScreenChangeViewOrigin(int link, uint32_t v) {
std::string edit_value =
ssprintf("%s, %s, %s",