Merge pull request #5768 from Ultimaker/CURA-5395-orthographic-view

Support for orthographic view
This commit is contained in:
Lipu Fei 2019-06-06 11:49:25 +02:00 committed by GitHub
commit 0e55b25e0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 38 deletions

View file

@ -839,7 +839,6 @@ class CuraApplication(QtApplication):
if diagonal < 1: #No printer added yet. Set a default camera distance for normal-sized printers. if diagonal < 1: #No printer added yet. Set a default camera distance for normal-sized printers.
diagonal = 375 diagonal = 375
camera.setPosition(Vector(-80, 250, 700) * diagonal / 375) camera.setPosition(Vector(-80, 250, 700) * diagonal / 375)
camera.setPerspective(True)
camera.lookAt(Vector(0, 0, 0)) camera.lookAt(Vector(0, 0, 0))
controller.getScene().setActiveCamera("3d") controller.getScene().setActiveCamera("3d")

View file

@ -110,65 +110,65 @@ Item
Action Action
{ {
id: quitAction; id: quitAction
text: catalog.i18nc("@action:inmenu menubar:file","&Quit"); text: catalog.i18nc("@action:inmenu menubar:file","&Quit")
iconName: "application-exit"; iconName: "application-exit"
shortcut: StandardKey.Quit; shortcut: StandardKey.Quit
} }
Action Action
{ {
id: view3DCameraAction; id: view3DCameraAction
text: catalog.i18nc("@action:inmenu menubar:view","3D View"); text: catalog.i18nc("@action:inmenu menubar:view", "3D View")
onTriggered: UM.Controller.rotateView("3d", 0); onTriggered: UM.Controller.setCameraRotation("3d", 0)
} }
Action Action
{ {
id: viewFrontCameraAction; id: viewFrontCameraAction
text: catalog.i18nc("@action:inmenu menubar:view","Front View"); text: catalog.i18nc("@action:inmenu menubar:view", "Front View")
onTriggered: UM.Controller.rotateView("home", 0); onTriggered: UM.Controller.setCameraRotation("home", 0)
} }
Action Action
{ {
id: viewTopCameraAction; id: viewTopCameraAction
text: catalog.i18nc("@action:inmenu menubar:view","Top View"); text: catalog.i18nc("@action:inmenu menubar:view", "Top View")
onTriggered: UM.Controller.rotateView("y", 90); onTriggered: UM.Controller.setCameraRotation("y", 90)
} }
Action Action
{ {
id: viewLeftSideCameraAction; id: viewLeftSideCameraAction
text: catalog.i18nc("@action:inmenu menubar:view","Left Side View"); text: catalog.i18nc("@action:inmenu menubar:view", "Left Side View")
onTriggered: UM.Controller.rotateView("x", 90); onTriggered: UM.Controller.setCameraRotation("x", 90)
} }
Action Action
{ {
id: viewRightSideCameraAction; id: viewRightSideCameraAction
text: catalog.i18nc("@action:inmenu menubar:view","Right Side View"); text: catalog.i18nc("@action:inmenu menubar:view", "Right Side View")
onTriggered: UM.Controller.rotateView("x", -90); onTriggered: UM.Controller.setCameraRotation("x", -90)
} }
Action Action
{ {
id: preferencesAction; id: preferencesAction
text: catalog.i18nc("@action:inmenu","Configure Cura..."); text: catalog.i18nc("@action:inmenu", "Configure Cura...")
iconName: "configure"; iconName: "configure"
} }
Action Action
{ {
id: addMachineAction; id: addMachineAction
text: catalog.i18nc("@action:inmenu menubar:printer","&Add Printer..."); text: catalog.i18nc("@action:inmenu menubar:printer", "&Add Printer...")
} }
Action Action
{ {
id: settingsAction; id: settingsAction
text: catalog.i18nc("@action:inmenu menubar:printer","Manage Pr&inters..."); text: catalog.i18nc("@action:inmenu menubar:printer", "Manage Pr&inters...")
iconName: "configure"; iconName: "configure"
} }
Action Action

View file

@ -95,6 +95,10 @@ UM.PreferencesPage
UM.Preferences.resetPreference("view/top_layer_count"); UM.Preferences.resetPreference("view/top_layer_count");
topLayerCountCheckbox.checked = boolCheck(UM.Preferences.getValue("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") UM.Preferences.resetPreference("cura/choice_on_profile_override")
setDefaultDiscardOrKeepProfile(UM.Preferences.getValue("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; width: childrenRect.width;
height: childrenRect.height; 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") 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; width: childrenRect.width;
height: childrenRect.height; height: childrenRect.height;
text: catalog.i18nc("@info:tooltip", "Should the default zoom behavior of cura be inverted?") 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 Item
{ {
//: Spacer //: Spacer

View file

@ -6,7 +6,7 @@ import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import UM 1.4 as UM import UM 1.4 as UM
import Cura 1.1 as Cura
// A row of buttons that control the view direction // A row of buttons that control the view direction
Row Row
{ {
@ -19,30 +19,30 @@ Row
ViewOrientationButton ViewOrientationButton
{ {
iconSource: UM.Theme.getIcon("view_3d") iconSource: UM.Theme.getIcon("view_3d")
onClicked: UM.Controller.rotateView("3d", 0) onClicked: Cura.Actions.view3DCamera.trigger()
} }
ViewOrientationButton ViewOrientationButton
{ {
iconSource: UM.Theme.getIcon("view_front") iconSource: UM.Theme.getIcon("view_front")
onClicked: UM.Controller.rotateView("home", 0) onClicked: Cura.Actions.viewFrontCamera.trigger()
} }
ViewOrientationButton ViewOrientationButton
{ {
iconSource: UM.Theme.getIcon("view_top") iconSource: UM.Theme.getIcon("view_top")
onClicked: UM.Controller.rotateView("y", 90) onClicked: Cura.Actions.viewTopCamera.trigger()
} }
ViewOrientationButton ViewOrientationButton
{ {
iconSource: UM.Theme.getIcon("view_left") iconSource: UM.Theme.getIcon("view_left")
onClicked: UM.Controller.rotateView("x", 90) onClicked: Cura.Actions.viewLeftSideCamera.trigger()
} }
ViewOrientationButton ViewOrientationButton
{ {
iconSource: UM.Theme.getIcon("view_right") iconSource: UM.Theme.getIcon("view_right")
onClicked: UM.Controller.rotateView("x", -90) onClicked: Cura.Actions.viewRightSideCamera.trigger()
} }
} }

View file

@ -101,7 +101,7 @@ def test_initialize():
initialize_preferences = MagicMock() initialize_preferences = MagicMock()
authorization_service = AuthorizationService(OAUTH_SETTINGS, original_preference) authorization_service = AuthorizationService(OAUTH_SETTINGS, original_preference)
authorization_service.initialize(initialize_preferences) authorization_service.initialize(initialize_preferences)
assert initialize_preferences.addPreference.called initialize_preferences.addPreference.assert_called_once_with("test/auth_data", "{}")
original_preference.addPreference.assert_not_called() original_preference.addPreference.assert_not_called()