From 2f5dfb8e6507992a25eb03bb167a23387fe5d3c3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 20 May 2019 16:34:06 +0200 Subject: [PATCH 1/5] Remove hardcoded set perspective function CURA-5395 --- cura/CuraApplication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 1155c67423..81a5d4fcc8 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -838,7 +838,6 @@ class CuraApplication(QtApplication): if diagonal < 1: #No printer added yet. Set a default camera distance for normal-sized printers. diagonal = 375 camera.setPosition(Vector(-80, 250, 700) * diagonal / 375) - camera.setPerspective(True) camera.lookAt(Vector(0, 0, 0)) controller.getScene().setActiveCamera("3d") From 65a8582a1ebca50dffc5022eb2c91ee20cd06ada Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 May 2019 09:54:32 +0200 Subject: [PATCH 2/5] Add preference to set the camera rendering type CURA-5395 --- resources/qml/Preferences/GeneralPage.qml | 54 ++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 47cc11632c..dd6004eae0 100644 --- a/resources/qml/Preferences/GeneralPage.qml +++ b/resources/qml/Preferences/GeneralPage.qml @@ -95,6 +95,10 @@ UM.PreferencesPage UM.Preferences.resetPreference("view/top_layer_count"); topLayerCountCheckbox.checked = boolCheck(UM.Preferences.getValue("view/top_layer_count")) + UM.Preferences.resetPreference("general/camera_perspective_mode") + var defaultCameraMode = UM.Preferences.getValue("general/camera_perspective_mode") + setDefaultCameraMode(defaultCameraMode) + UM.Preferences.resetPreference("cura/choice_on_profile_override") setDefaultDiscardOrKeepProfile(UM.Preferences.getValue("cura/choice_on_profile_override")) @@ -330,7 +334,8 @@ UM.PreferencesPage } } - UM.TooltipArea { + UM.TooltipArea + { width: childrenRect.width; height: childrenRect.height; text: catalog.i18nc("@info:tooltip", "Moves the camera so the model is in the center of the view when a model is selected") @@ -344,7 +349,8 @@ UM.PreferencesPage } } - UM.TooltipArea { + UM.TooltipArea + { width: childrenRect.width; height: childrenRect.height; text: catalog.i18nc("@info:tooltip", "Should the default zoom behavior of cura be inverted?") @@ -436,6 +442,50 @@ UM.PreferencesPage } } + UM.TooltipArea + { + width: childrenRect.width + height: childrenRect.height + text: catalog.i18nc("@info:tooltip", "What type of camera rendering should be used?") + Column + { + spacing: 4 * screenScaleFactor + + Label + { + text: catalog.i18nc("@window:text", "Camera rendering: ") + } + ComboBox + { + id: cameraComboBox + + model: ListModel + { + id: comboBoxList + + Component.onCompleted: { + append({ text: catalog.i18n("Perspective"), code: "perspective" }) + append({ text: catalog.i18n("Orthogonal"), code: "orthogonal" }) + } + } + + currentIndex: + { + var code = UM.Preferences.getValue("general/camera_perspective_mode"); + for(var i = 0; i < comboBoxList.count; ++i) + { + if(model.get(i).code == code) + { + return i + } + } + return 0 + } + onActivated: UM.Preferences.setValue("general/camera_perspective_mode", model.get(index).code) + } + } + } + Item { //: Spacer From 9e6263b1f19960404051b2f2c00c7d5cf62c4cdc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 May 2019 14:56:00 +0200 Subject: [PATCH 3/5] Change instances of assert_called_once to assert_called_once_with Grumbles something about python 3.5 and 3.6... --- tests/API/TestAccount.py | 8 ++++---- tests/TestOAuth2.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/API/TestAccount.py b/tests/API/TestAccount.py index 7a9997c771..725028b32c 100644 --- a/tests/API/TestAccount.py +++ b/tests/API/TestAccount.py @@ -21,14 +21,14 @@ def test_login(): account._authorization_service = mocked_auth_service account.login() - mocked_auth_service.startAuthorizationFlow.assert_called_once() + mocked_auth_service.startAuthorizationFlow.assert_called_once_with() # Fake a sucesfull login account._onLoginStateChanged(True) # Attempting to log in again shouldn't change anything. account.login() - mocked_auth_service.startAuthorizationFlow.assert_called_once() + mocked_auth_service.startAuthorizationFlow.assert_called_once_with() def test_initialize(): @@ -37,7 +37,7 @@ def test_initialize(): account._authorization_service = mocked_auth_service account.initialize() - mocked_auth_service.loadAuthDataFromPreferences.assert_called_once() + mocked_auth_service.loadAuthDataFromPreferences.assert_called_once_with() def test_logout(): @@ -54,7 +54,7 @@ def test_logout(): assert account.isLoggedIn account.logout() - mocked_auth_service.deleteAuthData.assert_called_once() + mocked_auth_service.deleteAuthData.assert_called_once_with() def test_errorLoginState(): diff --git a/tests/TestOAuth2.py b/tests/TestOAuth2.py index d4af485130..358ed5afbb 100644 --- a/tests/TestOAuth2.py +++ b/tests/TestOAuth2.py @@ -101,7 +101,7 @@ def test_initialize(): initialize_preferences = MagicMock() authorization_service = AuthorizationService(OAUTH_SETTINGS, original_preference) authorization_service.initialize(initialize_preferences) - initialize_preferences.addPreference.assert_called_once() + initialize_preferences.addPreference.assert_called_once_with("test/auth_data", "{}") original_preference.addPreference.assert_not_called() From 8b7c95da35463a2bfc7973493ebb62540cda8dc4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 May 2019 11:23:44 +0200 Subject: [PATCH 4/5] ViewOrientationControls now use actions This prevents code duplication CURA-5395 --- resources/qml/Actions.qml | 56 +++++++++++------------ resources/qml/ViewOrientationControls.qml | 12 ++--- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index ce9618a560..8487ec8ee4 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -101,7 +101,7 @@ Item Action { id: redoAction; - text: catalog.i18nc("@action:inmenu menubar:edit","&Redo"); + text: catalog.i18nc("@action:inmenu menubar:edit", "&Redo"); iconName: "edit-redo"; shortcut: StandardKey.Redo; onTriggered: UM.OperationStack.redo(); @@ -110,65 +110,65 @@ Item Action { - id: quitAction; - text: catalog.i18nc("@action:inmenu menubar:file","&Quit"); - iconName: "application-exit"; - shortcut: StandardKey.Quit; + id: quitAction + text: catalog.i18nc("@action:inmenu menubar:file","&Quit") + iconName: "application-exit" + shortcut: StandardKey.Quit } Action { - id: view3DCameraAction; - text: catalog.i18nc("@action:inmenu menubar:view","3D View"); - onTriggered: UM.Controller.rotateView("3d", 0); + id: view3DCameraAction + text: catalog.i18nc("@action:inmenu menubar:view", "3D View") + onTriggered: UM.Controller.rotateView("3d", 0) } Action { - id: viewFrontCameraAction; - text: catalog.i18nc("@action:inmenu menubar:view","Front View"); - onTriggered: UM.Controller.rotateView("home", 0); + id: viewFrontCameraAction + text: catalog.i18nc("@action:inmenu menubar:view", "Front View") + onTriggered: UM.Controller.rotateView("home", 0) } Action { - id: viewTopCameraAction; - text: catalog.i18nc("@action:inmenu menubar:view","Top View"); - onTriggered: UM.Controller.rotateView("y", 90); + id: viewTopCameraAction + text: catalog.i18nc("@action:inmenu menubar:view", "Top View") + onTriggered: UM.Controller.rotateView("y", 90) } Action { - id: viewLeftSideCameraAction; - text: catalog.i18nc("@action:inmenu menubar:view","Left Side View"); - onTriggered: UM.Controller.rotateView("x", 90); + id: viewLeftSideCameraAction + text: catalog.i18nc("@action:inmenu menubar:view", "Left Side View") + onTriggered: UM.Controller.rotateView("x", 90) } Action { - id: viewRightSideCameraAction; - text: catalog.i18nc("@action:inmenu menubar:view","Right Side View"); - onTriggered: UM.Controller.rotateView("x", -90); + id: viewRightSideCameraAction + text: catalog.i18nc("@action:inmenu menubar:view", "Right Side View") + onTriggered: UM.Controller.rotateView("x", -90) } Action { - id: preferencesAction; - text: catalog.i18nc("@action:inmenu","Configure Cura..."); - iconName: "configure"; + id: preferencesAction + text: catalog.i18nc("@action:inmenu", "Configure Cura...") + iconName: "configure" } Action { - id: addMachineAction; - text: catalog.i18nc("@action:inmenu menubar:printer","&Add Printer..."); + id: addMachineAction + text: catalog.i18nc("@action:inmenu menubar:printer", "&Add Printer...") } Action { - id: settingsAction; - text: catalog.i18nc("@action:inmenu menubar:printer","Manage Pr&inters..."); - iconName: "configure"; + id: settingsAction + text: catalog.i18nc("@action:inmenu menubar:printer", "Manage Pr&inters...") + iconName: "configure" } Action diff --git a/resources/qml/ViewOrientationControls.qml b/resources/qml/ViewOrientationControls.qml index 51ed6e3dcb..5750e935f4 100644 --- a/resources/qml/ViewOrientationControls.qml +++ b/resources/qml/ViewOrientationControls.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import UM 1.4 as UM - +import Cura 1.1 as Cura // A row of buttons that control the view direction Row { @@ -19,30 +19,30 @@ Row ViewOrientationButton { iconSource: UM.Theme.getIcon("view_3d") - onClicked: UM.Controller.rotateView("3d", 0) + onClicked: Cura.Actions.view3DCamera.trigger() } ViewOrientationButton { iconSource: UM.Theme.getIcon("view_front") - onClicked: UM.Controller.rotateView("home", 0) + onClicked: Cura.Actions.viewFrontCamera.trigger() } ViewOrientationButton { iconSource: UM.Theme.getIcon("view_top") - onClicked: UM.Controller.rotateView("y", 90) + onClicked: Cura.Actions.viewTopCamera.trigger() } ViewOrientationButton { iconSource: UM.Theme.getIcon("view_left") - onClicked: UM.Controller.rotateView("x", 90) + onClicked: Cura.Actions.viewLeftSideCamera.trigger() } ViewOrientationButton { iconSource: UM.Theme.getIcon("view_right") - onClicked: UM.Controller.rotateView("x", -90) + onClicked: Cura.Actions.viewRightSideCamera.trigger() } } From c9f07c898c3b7ffbce12c3a8afa2d8afd6c6cad6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 31 May 2019 11:32:16 +0200 Subject: [PATCH 5/5] Refactoring the rotateView to setCameraRotation The new name actualy reflects what it was doing (it sets the rotation, it doesn't apply a new one to it!) CURA-5395 --- resources/qml/Actions.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 8487ec8ee4..71a655c664 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -120,35 +120,35 @@ Item { id: view3DCameraAction text: catalog.i18nc("@action:inmenu menubar:view", "3D View") - onTriggered: UM.Controller.rotateView("3d", 0) + onTriggered: UM.Controller.setCameraRotation("3d", 0) } Action { id: viewFrontCameraAction text: catalog.i18nc("@action:inmenu menubar:view", "Front View") - onTriggered: UM.Controller.rotateView("home", 0) + onTriggered: UM.Controller.setCameraRotation("home", 0) } Action { id: viewTopCameraAction text: catalog.i18nc("@action:inmenu menubar:view", "Top View") - onTriggered: UM.Controller.rotateView("y", 90) + onTriggered: UM.Controller.setCameraRotation("y", 90) } Action { id: viewLeftSideCameraAction text: catalog.i18nc("@action:inmenu menubar:view", "Left Side View") - onTriggered: UM.Controller.rotateView("x", 90) + onTriggered: UM.Controller.setCameraRotation("x", 90) } Action { id: viewRightSideCameraAction text: catalog.i18nc("@action:inmenu menubar:view", "Right Side View") - onTriggered: UM.Controller.rotateView("x", -90) + onTriggered: UM.Controller.setCameraRotation("x", -90) } Action