From 20b83c5b534c6767b04338578df2d2c6ff111bd1 Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Thu, 3 May 2018 09:21:01 +0200
Subject: [PATCH 1/2] Save the Canonical Language Name instead of the
 Enumerator to the Slic3r.ini

---
 xs/src/slic3r/GUI/GUI.cpp | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp
index e6c07b470..4789f4590 100644
--- a/xs/src/slic3r/GUI/GUI.cpp
+++ b/xs/src/slic3r/GUI/GUI.cpp
@@ -309,22 +309,18 @@ bool select_language(wxArrayString & names,
 
 bool load_language()
 {
-	long language;
-	if (!g_AppConfig->has("translation_language"))
-		language = wxLANGUAGE_UNKNOWN;
-	else {
-		auto str_language = g_AppConfig->get("translation_language");
-		language = str_language != "" ? stol(str_language) : wxLANGUAGE_UNKNOWN;
-	}
+	wxString language = wxEmptyString;
+	if (g_AppConfig->has("translation_language"))
+		language = g_AppConfig->get("translation_language");
 
-	if (language == wxLANGUAGE_UNKNOWN) 
+	if (language.IsEmpty()) 
 		return false;
 	wxArrayString	names;
 	wxArrayLong		identifiers;
 	get_installed_languages(names, identifiers);
 	for (size_t i = 0; i < identifiers.Count(); i++)
 	{
-		if (identifiers[i] == language)
+		if (wxLocale::GetLanguageCanonicalName(identifiers[i]) == language)
 		{
 			g_wxLocale = new wxLocale;
 			g_wxLocale->Init(identifiers[i]);
@@ -339,13 +335,11 @@ bool load_language()
 
 void save_language()
 {
-	//! TO DO !! use GetCanonicalName;
-	long language = wxLANGUAGE_UNKNOWN;
-	if (g_wxLocale)	{
-		language = g_wxLocale->GetLanguage();
-	}
-	std::string str_language = std::to_string(language);
-	g_AppConfig->set("translation_language", str_language);
+	wxString language = wxEmptyString; 
+	if (g_wxLocale)	
+		language = g_wxLocale->GetCanonicalName();
+
+	g_AppConfig->set("translation_language", language.ToStdString());
 	g_AppConfig->save();
 }
 

From d19b1162b3689de25af260bb958272df6bf77a3a Mon Sep 17 00:00:00 2001
From: Enrico Turri <enricoturri@seznam.cz>
Date: Thu, 3 May 2018 11:09:13 +0200
Subject: [PATCH 2/2] Fixed normals on wipe tower box

---
 xs/src/libslic3r/TriangleMesh.cpp | 10 +++++++---
 xs/src/slic3r/GUI/3DScene.cpp     | 11 +++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp
index aecb39662..45e4b6f5d 100644
--- a/xs/src/libslic3r/TriangleMesh.cpp
+++ b/xs/src/libslic3r/TriangleMesh.cpp
@@ -51,9 +51,6 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
 
     for (int i = 0; i < stl.stats.number_of_facets; i++) {
         stl_facet facet;
-        facet.normal.x = 0;
-        facet.normal.y = 0;
-        facet.normal.z = 0;
 
         const Pointf3& ref_f1 = points[facets[i].x];
         facet.vertex[0].x = ref_f1.x;
@@ -73,6 +70,13 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
         facet.extra[0] = 0;
         facet.extra[1] = 0;
 
+        float normal[3];
+        stl_calculate_normal(normal, &facet);
+        stl_normalize_vector(normal);
+        facet.normal.x = normal[0];
+        facet.normal.y = normal[1];
+        facet.normal.z = normal[2];
+
         stl.facet_start[i] = facet;
     }
     stl_get_size(&stl);
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp
index a016ab5aa..6b2f5c830 100644
--- a/xs/src/slic3r/GUI/3DScene.cpp
+++ b/xs/src/slic3r/GUI/3DScene.cpp
@@ -443,13 +443,16 @@ std::vector<int> GLVolumeCollection::load_object(
 int GLVolumeCollection::load_wipe_tower_preview(
     int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs)
 {
-    float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f };
+    float color[4] = { 0.5f, 0.5f, 0.0f, 0.5f };
     this->volumes.emplace_back(new GLVolume(color));
     GLVolume &v = *this->volumes.back();
 
-    auto mesh = make_cube(width, depth, height);    
-    mesh.translate(-width/2.f,-depth/2.f,0.f);    
-    Point origin_of_rotation(0.f,0.f);
+    if (height == 0.0f)
+        height = 0.1f;
+
+    auto mesh = make_cube(width, depth, height);
+    mesh.translate(-width / 2.f, -depth / 2.f, 0.f);
+    Point origin_of_rotation(0.f, 0.f);
     mesh.rotate(rotation_angle,&origin_of_rotation);
 
     if (use_VBOs)