import { observer } from "mobx-react"; import React from "react"; import classNames from "classnames"; import { theme } from "eez-studio-ui/theme"; import { SvgLabel } from "eez-studio-ui/svg-label"; import { TreeObjectAdapter } from "project-editor/core/objectAdapter"; import type { IFlowContext } from "project-editor/flow/flow-interfaces"; import { ConnectionLine } from "project-editor/flow/connection-line"; import { getValueLabel } from "project-editor/features/variable/value-type"; import type { ComponentInput } from "project-editor/flow/component"; import { getConnectionLineShape } from "project-editor/flow/connection-line/connection-line-shape"; import { registerPath, unregisterPath } from "project-editor/flow/connection-line/real-time-traffic-visualizer"; import { ProjectEditor } from "project-editor/project-editor-interface"; //////////////////////////////////////////////////////////////////////////////// const lineColor = () => theme().connectionLineColor; const seqLineColor = () => theme().seqConnectionLineColor; const selectedLineColor = () => theme().selectedConnectionLineColor; const selectedLineColorInViewer = () => theme().selectionBackgroundColor; const disabledLineColor = () => theme().disabledLineColor; export const strokeWidth = 1.2; const seqStrokeWidth = 1.2; const strokeOutlineWidth = 1.5; const strokeBackgroundWidth = 8; //////////////////////////////////////////////////////////////////////////////// export const ConnectionLines = observer( ({ connectionLines, context, selected = false }: { connectionLines: TreeObjectAdapter[]; context: IFlowContext; selected?: boolean; }) => { return ( <> {connectionLines .filter( connectionLineAdapter => context.flowState || context.projectStore.project.settings.general .hiddenWidgetLines != "hidden" || (connectionLineAdapter.object as ConnectionLine) .isVisible ) .map(connectionLineAdapter => ( ))} ); } ); export const ConnectionLineDebugValues = observer( ({ connectionLines, context, selected = false }: { connectionLines: TreeObjectAdapter[]; context: IFlowContext; selected?: boolean; }) => { return ( <> {connectionLines.map(connectionLineAdapter => ( ))} ); } ); export const ConnectionLineShape = observer( ({ connectionLineAdapter, context, selected, shadow }: { connectionLineAdapter: TreeObjectAdapter; context: IFlowContext; selected: boolean; shadow?: { color: string }; }) => { const connectionLine = connectionLineAdapter.object as ConnectionLine; const { lineShape, center } = getConnectionLineShape( context, connectionLine ); if (!lineShape) { return null; } const targetInput = connectionLine.targetComponent?.inputs.find( input => input.name == connectionLine.input ); const scale = context.viewState.transform.scale; return ( {context.projectStore.uiStateStore.showComponentDescriptions && connectionLine.description && ( )} ); } ); const ConnectionLineDebugValue = observer( ({ connectionLineAdapter, context, selected }: { connectionLineAdapter: TreeObjectAdapter; context: IFlowContext; selected: boolean; }) => { const connectionLine = connectionLineAdapter.object as ConnectionLine; const targetInput = connectionLine.targetComponent?.inputs.find( input => input.name == connectionLine.input ); return ( ); } ); const VisiblePath = observer( class VisiblePath extends React.Component<{ lineShape: string; selected: boolean; connectionLine: ConnectionLine; context: IFlowContext; targetInput: ComponentInput | undefined; shadow: { color: string } | undefined; }> { ref = React.createRef(); componentDidMount() { if (this.ref.current) { registerPath(this.props.connectionLine, this.ref.current); } } componentWillUnmount() { if (this.ref.current) { unregisterPath(this.props.connectionLine, this.ref.current); } } render() { const { lineShape, selected, connectionLine, targetInput } = this.props; const seq = targetInput?.isSequenceInput && !( connectionLine.targetComponent instanceof ProjectEditor.OutputActionComponentClass ); return ( ); } } ); const DebugValue = observer( ({ connectionLine, context, selected, id, targetInput }: { connectionLine: ConnectionLine; context: IFlowContext; selected: boolean; id: string; targetInput: ComponentInput | undefined; }) => { let valueStr: string | undefined; if ( context.flowState && context.document.projectStore.runtime && context.document.projectStore.runtime.isDebuggerActive && connectionLine.targetComponent && targetInput ) { const inputValue = context.flowState.getInputValue( connectionLine.targetComponent, connectionLine.input ); if ( inputValue !== undefined && (!targetInput.isSequenceInput || inputValue != null) ) { valueStr = getValueLabel( context.projectStore.project, inputValue, targetInput.type ); } } if (!valueStr) { return null; } if (valueStr.length > 50) { valueStr = valueStr.substring(0, 50) + "..."; } return ( ); } ); export const LineMarkers = () => ( ); function LineEndMarker({ id, color }: { id: string; color: string }) { return ( ); } function AnimationCurveEndMarker() { return ( ); }