Skip to content

Commit

Permalink
Merge branch 'dev' into dhruv/1798/refactoring-gizmos
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed Sep 22, 2024
2 parents 2f8c826 + e008481 commit 8f6c6d8
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ExporterOptions:
exportAsPart: bool = field(default=False)

exportLocation: ExportLocation = field(default=ExportLocation.UPLOAD)
openSynthesisUponExport: bool = field(default=False)

hierarchy: ModelHierarchy = field(default=ModelHierarchy.FusionAssembly)
visualQuality: TriangleMeshQualityOptions = field(default=TriangleMeshQualityOptions.LowQualityTriangleMesh)
Expand Down
9 changes: 8 additions & 1 deletion exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import os
import pathlib
import webbrowser
from enum import Enum
from typing import Any

import adsk.core
import adsk.fusion

from src import gm
from src import APP_WEBSITE_URL, gm
from src.APS.APS import getAuth, getUserInfo
from src.Logging import getLogger, logFailure
from src.Parser.ExporterOptions import ExporterOptions
Expand Down Expand Up @@ -348,6 +349,7 @@ def notify(self, args: adsk.core.CommandEventArgs) -> None:
exportAsPart=generalConfigTab.exportAsPart,
frictionOverride=generalConfigTab.overrideFriction,
frictionOverrideCoeff=generalConfigTab.frictionOverrideCoeff,
openSynthesisUponExport=generalConfigTab.openSynthesisUponExport,
)

Parser(exporterOptions).export()
Expand All @@ -359,6 +361,11 @@ def notify(self, args: adsk.core.CommandEventArgs) -> None:
jointConfigTab.reset()
gamepieceConfigTab.reset()

if generalConfigTab.openSynthesisUponExport:
res = webbrowser.open(APP_WEBSITE_URL)
if not res:
gm.ui.messageBox("Failed to open Synthesis in your default browser.")


class CommandExecutePreviewHandler(adsk.core.CommandEventHandler):
"""### Gets an event that is fired when the command has completed gathering the required input and now needs to perform a preview.
Expand Down
15 changes: 15 additions & 0 deletions exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs, exporterOptions: Exp
frictionCoefficient.tooltip = "<i>Friction coefficients range from 0 (ice) to 1 (rubber).</i>"
frictionCoefficient.isVisible = exporterOptions.frictionOverride

createBooleanInput(
"openSynthesisOnExportButton",
"Open Synthesis on Export",
generalTabInputs,
checked=exporterOptions.openSynthesisUponExport,
tooltip="Launch the Synthesis website upon export.",
)

if exporterOptions.exportMode == ExportMode.FIELD:
autoCalcWeightButton.isVisible = False
exportAsPartButton.isVisible = False
Expand Down Expand Up @@ -182,6 +190,13 @@ def frictionOverrideCoeff(self) -> float:
)
return frictionSlider.valueOne or -1.0

@property
def openSynthesisUponExport(self) -> bool:
openSynthesisButton: adsk.core.BoolValueCommandInput = self.generalOptionsTab.children.itemById(
"openSynthesisOnExportButton"
)
return openSynthesisButton.value or False

@logFailure
def handleInputChanged(self, args: adsk.core.InputChangedEventArgs) -> None:
autoCalcWeightButton: adsk.core.BoolValueCommandInput = args.inputs.itemById("autoCalcWeightButton")
Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

APP_NAME = "Synthesis"
APP_TITLE = "Synthesis Robot Exporter"
APP_WEBSITE_URL = "https://synthesis.autodesk.com/fission/"
DESCRIPTION = "Exports files from Fusion into the Synthesis Format"
INTERNAL_ID = "Synthesis"
ADDIN_PATH = os.path.dirname(os.path.realpath(__file__))
Expand Down
4 changes: 2 additions & 2 deletions fission/src/ui/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Modal: React.FC<ModalProps> = ({
<div
id={modalId}
key={modalId}
className={`${className} flex flex-col absolute max-w-[98vw] max-h-[90vh] w-fit h-fit left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-background text-main-text m-auto border-5 rounded-2xl shadow-sm shadow-slate-800`}
className={`${className} flex flex-col absolute max-w-[50vw] max-h-[95vh] w-fit h-fit left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-background text-main-text m-auto border-5 rounded-2xl shadow-sm shadow-slate-800`}
>
{name && (
<div id="header" className="flex items-center gap-8 h-16">
Expand All @@ -78,7 +78,7 @@ const Modal: React.FC<ModalProps> = ({
id="content"
className={`${contentClassName || ""} ${
!contentClassName?.includes("mx") ? "mx-[2rem]" : ""
} flex flex-col gap-4 max-h-75vh p-4`}
} flex flex-col gap-4 max-h-[75vh]`}
>
{children}
</div>
Expand Down
4 changes: 2 additions & 2 deletions fission/src/ui/components/StyledComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Label, { LabelSize } from "./Label"
import Button, { ButtonProps, ButtonSize } from "./Button"
import { IoCheckmark, IoPencil, IoPeople, IoTrashBin } from "react-icons/io5"
import { HiDownload } from "react-icons/hi"
import { AiOutlinePlus } from "react-icons/ai"
import { BiRefresh } from "react-icons/bi"
import { AiFillWarning } from "react-icons/ai"
import { BsCodeSquare } from "react-icons/bs"
Expand Down Expand Up @@ -58,7 +57,8 @@ export class SynthesisIcons {
/** Large icons: used for icon buttons */
public static DeleteLarge = (<IoTrashBin size={"1.25rem"} />)
public static DownloadLarge = (<HiDownload size={"1.25rem"} />)
public static AddLarge = (<AiOutlinePlus size={"1.25rem"} />)
public static AddLarge = (<FaPlus size={"1.25rem"} />)
public static GearLarge = (<FaGear size={"1.25rem"} />)
public static RefreshLarge = (<BiRefresh size={"1.25rem"} />)
public static SelectLarge = (<IoCheckmark size={"1.25rem"} />)
public static EditLarge = (<IoPencil size={"1.25rem"} />)
Expand Down
43 changes: 27 additions & 16 deletions fission/src/ui/modals/configuring/SettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import React, { useState } from "react"
import Modal, { ModalPropsImpl } from "@/components/Modal"
import { FaGear } from "react-icons/fa6"
import Label, { LabelSize } from "@/components/Label"
import Dropdown from "@/components/Dropdown"
import Slider from "@/components/Slider"
import Checkbox from "@/components/Checkbox"
import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
import { SceneOverlayEvent, SceneOverlayEventKey } from "@/ui/components/SceneOverlayEvents"
import { QualitySetting } from "@/systems/preferences/PreferenceTypes"
import { Box } from "@mui/material"
import { Spacer } from "@/ui/components/StyledComponents"
import { Spacer, SynthesisIcons } from "@/ui/components/StyledComponents"
import World from "@/systems/World"

const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const [qualitySettings, setQualitySettings] = useState<string>(
PreferencesSystem.getGlobalPreference<string>("QualitySettings")
)
const [zoomSensitivity, setZoomSensitivity] = useState<number>(

// Disabled until camera settings are implemented
/* const [zoomSensitivity, setZoomSensitivity] = useState<number>(
PreferencesSystem.getGlobalPreference<number>("ZoomSensitivity")
)
const [pitchSensitivity, setPitchSensitivity] = useState<number>(
PreferencesSystem.getGlobalPreference<number>("PitchSensitivity")
)
const [yawSensitivity, setYawSensitivity] = useState<number>(
PreferencesSystem.getGlobalPreference<number>("YawSensitivity")
)
) */

const [reportAnalytics, setReportAnalytics] = useState<boolean>(
PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics")
)
const [useMetric, setUseMetric] = useState<boolean>(PreferencesSystem.getGlobalPreference<boolean>("UseMetric"))

// Disabled until use metric is implemented
// const [useMetric, setUseMetric] = useState<boolean>(PreferencesSystem.getGlobalPreference<boolean>("UseMetric"))

const [renderScoringZones, setRenderScoringZones] = useState<boolean>(
PreferencesSystem.getGlobalPreference<boolean>("RenderScoringZones")
)
Expand All @@ -44,29 +48,32 @@ const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {

const saveSettings = () => {
PreferencesSystem.setGlobalPreference<string>("QualitySettings", qualitySettings)
PreferencesSystem.setGlobalPreference<number>("ZoomSensitivity", zoomSensitivity)
PreferencesSystem.setGlobalPreference<number>("PitchSensitivity", pitchSensitivity)
PreferencesSystem.setGlobalPreference<number>("YawSensitivity", yawSensitivity)

PreferencesSystem.setGlobalPreference<boolean>("ReportAnalytics", reportAnalytics)
PreferencesSystem.setGlobalPreference<boolean>("UseMetric", useMetric)
PreferencesSystem.setGlobalPreference<boolean>("RenderScoringZones", renderScoringZones)
PreferencesSystem.setGlobalPreference<boolean>("RenderSceneTags", renderSceneTags)
PreferencesSystem.setGlobalPreference<boolean>("RenderScoreboard", renderScoreboard)
PreferencesSystem.setGlobalPreference<boolean>("SubsystemGravity", subsystemGravity)

// Disabled until these settings are implemented
/* PreferencesSystem.setGlobalPreference<number>("ZoomSensitivity", zoomSensitivity)
PreferencesSystem.setGlobalPreference<number>("PitchSensitivity", pitchSensitivity)
PreferencesSystem.setGlobalPreference<number>("YawSensitivity", yawSensitivity)
PreferencesSystem.setGlobalPreference<boolean>("UseMetric", useMetric) */

PreferencesSystem.savePreferences()
}

return (
<Modal
name="Settings"
icon={<FaGear />}
icon={SynthesisIcons.GearLarge}
modalId={modalId}
onAccept={() => {
saveSettings()
}}
>
<div className="flex overflow-y-auto flex-col gap-2 bg-background-secondary rounded-md p-2 max-h-[60vh]">
<div className="flex overflow-y-auto flex-col gap-2 bg-background-secondary rounded-md p-2 max-h-[60vh] min-w-[20vw]">
<Label size={LabelSize.Medium}>Screen Settings</Label>
<Dropdown
label="Quality Settings"
Expand All @@ -77,7 +84,9 @@ const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
World.SceneRenderer.ChangeLighting(selected)
}}
/>
{Spacer(5)}

{/* Disabled until these settings are implemented */}
{/* {Spacer(5)}
<Label size={LabelSize.Medium}>Camera Settings</Label>
<Slider
min={1}
Expand Down Expand Up @@ -106,7 +115,7 @@ const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
format={{ maximumFractionDigits: 2 }}
onChange={(_, value) => setYawSensitivity(value as number)}
tooltipText="Moving the camera left and right."
/>
/>*/}
{Spacer(20)}
<Label size={LabelSize.Medium}>Preferences</Label>
<Box display="flex" flexDirection={"column"}>
Expand All @@ -118,13 +127,15 @@ const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
}}
tooltipText="Record user data such as what robots are spawned and how they are configured. No personal data will be collected."
/>
<Checkbox
{/* Disabled until this settings is implemented */}
{/* <Checkbox
label="Use Metric"
defaultState={PreferencesSystem.getGlobalPreference<boolean>("UseMetric")}
onClick={checked => {
setUseMetric(checked)
}}
/>
tooltipText="Metric measurements. (ex: meters instead of feet)"
/> */}
<Checkbox
label="Realistic Subsystem Gravity"
defaultState={PreferencesSystem.getGlobalPreference<boolean>("SubsystemGravity")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import InputSystem from "@/systems/input/InputSystem"
import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain"
import { SynthesisIcons } from "@/ui/components/StyledComponents"
import { usePanelControlContext } from "@/ui/PanelContext"
import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel"
import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface"
import {
setSelectedConfigurationType,
ConfigurationType,
} from "@/ui/panels/configuring/assembly-config/ConfigurationType"

const AssignNewSchemeModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const { openPanel } = usePanelControlContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import InputSchemeManager from "@/systems/input/InputSchemeManager"
import DefaultInputs from "@/systems/input/DefaultInputs"
import { SynthesisIcons } from "@/ui/components/StyledComponents"
import { usePanelControlContext } from "@/ui/PanelContext"
import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel"
import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface"
import {
ConfigurationType,
setSelectedConfigurationType,
} from "@/ui/panels/configuring/assembly-config/ConfigurationType"

const NewInputSchemeModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const { openPanel } = usePanelControlContext()
Expand All @@ -16,7 +19,7 @@ const NewInputSchemeModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
return (
<Modal
name="New Input Scheme"
icon={SynthesisIcons.Add}
icon={SynthesisIcons.AddLarge}
modalId={modalId}
onAccept={() => {
const scheme = DefaultInputs.newBlankScheme
Expand Down
3 changes: 1 addition & 2 deletions fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { useModalControlContext } from "@/ui/ModalContext"
import { usePanelControlContext } from "@/ui/PanelContext"
import { Box } from "@mui/material"
import { useEffect, useReducer } from "react"
import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurePanel"
import { setSelectedScheme } from "./assembly-config/interfaces/inputs/ConfigureInputsInterface"
import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurationType"

/** We store the selected brain index globally to specify which robot the input scheme should be bound to. */
let selectedBrainIndexGlobal: number | undefined = undefined
Expand Down Expand Up @@ -73,7 +73,6 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
sidePadding={8}
acceptEnabled={false}
icon={SynthesisIcons.Gamepad}
cancelEnabled={selectedBrainIndexGlobal != undefined}
cancelName="Close"
>
{/** A scroll view with buttons to select default and custom input schemes */}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** An event to save whatever configuration interface is open when it is closed */
export class ConfigurationSavedEvent extends Event {
public constructor() {
super("ConfigurationSaved")

window.dispatchEvent(this)
}

public static Listen(func: (e: Event) => void) {
window.addEventListener("ConfigurationSaved", func)
}

public static RemoveListener(func: (e: Event) => void) {
window.removeEventListener("ConfigurationSaved", func)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export enum ConfigurationType {
ROBOT,
FIELD,
INPUTS,
}

let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT

export function setSelectedConfigurationType(type: ConfigurationType) {
selectedConfigurationType = type
}

export function getConfigurationType() {
return selectedConfigurationType
}
Loading

0 comments on commit 8f6c6d8

Please sign in to comment.