Skip to content

Commit

Permalink
* rotation in stepping menu now uses radians and shows degrees in uni…
Browse files Browse the repository at this point in the history
…t selector

* action points and actions could be deleted
* rename dialog for AP is shown after AP is created
* Action objects now could not be renamed in project editor
* fixed: create package btn was not working
* fixed: plus / minus buttons was greyed out when robot sent to unreachable pose
  • Loading branch information
Kapim committed Mar 30, 2021
1 parent 323862c commit f8572fa
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 857 deletions.
2 changes: 1 addition & 1 deletion arcor2_AREditor/Assets/BASE/Scripts/ActionPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public bool Locked {

set {
Debug.Assert(Base.ProjectManager.Instance.ProjectMeta != null);
locked = value;
PlayerPrefsHelper.SaveBool("project/" + Base.ProjectManager.Instance.ProjectMeta.Id + "/AP/" + Data.Id + "/locked", value);
}
}
Expand Down Expand Up @@ -73,7 +74,6 @@ public virtual void InitAP(IO.Swagger.Model.ActionPoint apData, float size, IAct
ActionsCollapsed = PlayerPrefsHelper.LoadBool("/AP/" + Data.Id + "/actionsCollapsed", false);
transform.localPosition = GetScenePosition();
SetSize(size);
ActivateForGizmo((ControlBoxManager.Instance.UseGizmoMove && ProjectManager.Instance.AllowEdit && !MenuManager.Instance.IsAnyMenuOpened) ? "GizmoRuntime" : "Default");
if (Data.Actions == null)
Data.Actions = new List<IO.Swagger.Model.Action>();
if (Data.Orientations == null)
Expand Down
43 changes: 2 additions & 41 deletions arcor2_AREditor/Assets/BASE/Scripts/ControlBoxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class ControlBoxManager : Singleton<ControlBoxManager> {
private InputDialog InputDialog;
[SerializeField]

public Toggle MoveToggle;
public Toggle RotateToggle;
public Toggle TrackablesToggle;
public Toggle ConnectionsToggle;
public Toggle VRModeToggle;
Expand All @@ -24,37 +22,8 @@ public class ControlBoxManager : Singleton<ControlBoxManager> {
private ManualTooltip calibrationElementsTooltip;


private bool useGizmoMove = false;
public bool UseGizmoMove {
get => useGizmoMove;
set {
useGizmoMove = value;
if (useGizmoMove) {
TransformGizmo.Instance.transformType = TransformType.Move;
useGizmoRotate = false;
RotateToggle.isOn = false;
MoveToggle.isOn = true;
}
}
}

private bool useGizmoRotate = false;
public bool UseGizmoRotate {
get => useGizmoRotate;
set {
useGizmoRotate = value;
if (useGizmoRotate) {
TransformGizmo.Instance.transformType = TransformType.Rotate;
useGizmoMove = false;
RotateToggle.isOn = true;
MoveToggle.isOn = false;
}
}
}

private void Start() {
MoveToggle.isOn = PlayerPrefsHelper.LoadBool("control_box_gizmo_move", false);
RotateToggle.isOn = PlayerPrefsHelper.LoadBool("control_box_gizmo_rotate", false);
#if UNITY_ANDROID && AR_ON
TrackablesToggle.isOn = PlayerPrefsHelper.LoadBool("control_box_display_trackables", false);
CalibrationElementsToggle.interactable = false;
Expand Down Expand Up @@ -112,21 +81,15 @@ public void OnCalibrationElementsToggleClick() {
}

private void GameStateChanged(object sender, GameStateEventArgs args) {
MoveToggle.gameObject.SetActive(false);
RotateToggle.gameObject.SetActive(false);
ConnectionsToggle.gameObject.SetActive(false);
switch (args.Data) {

case GameManager.GameStateEnum.ProjectEditor:
MoveToggle.gameObject.SetActive(true);
// use move only if the gizmo was previously active (for tablet version)
if (UseGizmoMove || UseGizmoRotate)
UseGizmoMove = true;

ConnectionsToggle.gameObject.SetActive(true);
break;
case GameManager.GameStateEnum.SceneEditor:
RotateToggle.gameObject.SetActive(true);
MoveToggle.gameObject.SetActive(true);

break;
case GameManager.GameStateEnum.PackageRunning:
ConnectionsToggle.gameObject.SetActive(true);
Expand Down Expand Up @@ -166,8 +129,6 @@ public void DisplayConnections(bool active) {


private void OnDestroy() {
PlayerPrefsHelper.SaveBool("control_box_gizmo_move", MoveToggle.isOn);
PlayerPrefsHelper.SaveBool("control_box_gizmo_rotate", RotateToggle.isOn);
#if UNITY_ANDROID && AR_ON
PlayerPrefsHelper.SaveBool("control_box_display_trackables", TrackablesToggle.isOn);
#endif
Expand Down
2 changes: 0 additions & 2 deletions arcor2_AREditor/Assets/BASE/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,6 @@ public Button CreateButton(Transform parent, string label) {
/// <returns></returns>
public async Task<bool> AddActionPoint(string name, string parent) {
try {
ProjectManager.Instance.SelectAPNameWhenCreated = name;
if (string.IsNullOrEmpty(parent)) {
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0f));
Vector3 point = TransformConvertor.UnityToROS(Scene.transform.InverseTransformPoint(ray.GetPoint(0.5f)));
Expand All @@ -1780,7 +1779,6 @@ public async Task<bool> AddActionPoint(string name, string parent) {
return true;
} catch (RequestFailedException e) {
Notifications.Instance.ShowNotification("Failed to add action point", e.Message);
ProjectManager.Instance.SelectAPNameWhenCreated = "";
return false;
}
}
Expand Down
12 changes: 4 additions & 8 deletions arcor2_AREditor/Assets/BASE/Scripts/ProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,7 @@ private void OnActionPointAdded(object sender, ProjectActionPointEventArgs data)
}

}
if (ap != null && SelectAPNameWhenCreated.Equals(ap.GetName())) {
SelectorMenu.Instance.ForceUpdateMenus();
SelectorMenu.Instance.SetSelectedObject(ap, true);
SelectAPNameWhenCreated = "";
}

updateProject = true;
}

Expand Down Expand Up @@ -472,10 +468,10 @@ public Project GetProject() {


private void Update() {
if (GameManager.Instance.GetGameState() == GameManager.GameStateEnum.ProjectEditor &&
/*if (GameManager.Instance.GetGameState() == GameManager.GameStateEnum.ProjectEditor &&
GameManager.Instance.SceneInteractable &&
GameManager.Instance.GetEditorState() == GameManager.EditorStateEnum.Normal) {
if (!projectActive && (ControlBoxManager.Instance.UseGizmoMove)) {
/if (!projectActive && (ControlBoxManager.Instance.UseGizmoMove)) {
ActivateActionPointsForGizmo(true);
projectActive = true;
} else if (projectActive && !(ControlBoxManager.Instance.UseGizmoMove)) {
Expand All @@ -487,7 +483,7 @@ private void Update() {
ActivateActionPointsForGizmo(false);
projectActive = false;
}
}
}*/
if (updateProject) {
ProjectChanged = true;
updateProject = false;
Expand Down
4 changes: 2 additions & 2 deletions arcor2_AREditor/Assets/BASE/Scripts/SceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public IO.Swagger.Model.Scene GetScene() {
// Update is called once per frame
private void Update() {
// Activates scene if the AREditor is in SceneEditor mode and scene is interactable (no windows are openned).
if (GameManager.Instance.GetGameState() == GameManager.GameStateEnum.SceneEditor &&
/*if (GameManager.Instance.GetGameState() == GameManager.GameStateEnum.SceneEditor &&
GameManager.Instance.SceneInteractable &&
GameManager.Instance.GetEditorState() == GameManager.EditorStateEnum.Normal) {
if (!sceneActive && (ControlBoxManager.Instance.UseGizmoMove || ControlBoxManager.Instance.UseGizmoRotate)) {
Expand All @@ -245,7 +245,7 @@ private void Update() {
ActivateActionObjectsForGizmo(false);
sceneActive = false;
}
}
}*/
if (updateScene) {
SceneChanged = true;
updateScene = false;
Expand Down
Loading

0 comments on commit f8572fa

Please sign in to comment.