diff --git a/src/App.vue b/src/App.vue index 7a73fe4..b06f53d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -33,10 +33,10 @@ import { useROSStore } from './stores/ros' import { useMessasgeStore } from './stores/message' import { usePackageStore } from './stores/package' import { useNodesStore } from './stores/nodes' -import { computed, onMounted, ref, watch } from 'vue' +import { onMounted, ref, watch } from 'vue' import PackageLoader from './components/PackageLoader.vue' -import type { Messages, NodeMsg, Packages, SubtreeInfo, TreeMsg } from './types/types' -import { EditorSkin, useEditorStore } from './stores/editor' +import type { MessageTypes, NodeMsg, Packages, SubtreeInfo, TreeMsg } from './types/types' +import { useEditorStore } from './stores/editor' import { useEditNodeStore } from './stores/edit_node' import NodeList from './components/NodeList.vue' import SelectSubtree from './components/SelectSubtree.vue' @@ -80,11 +80,11 @@ function updatePackagesSubscription() { ros_store.packages_sub.subscribe(onNewPackagesMsg) } -function onNewMessagesMsg(msg: Messages) { +function onNewMessagesMsg(msg: MessageTypes) { if (!messages_store.messages_available) { messages_store.areMessagesAvailable(true) } - messages_store.updateAvailableMessages(msg.messages) + messages_store.updateAvailableMessages(msg) } function updateMessagesSubscription() { @@ -107,6 +107,10 @@ function updateSubtreeInfoSubscription() { ros_store.subtree_info_sub.subscribe(onNewSubtreeInfoMsg) } +function updateChannelssubscription() { + ros_store.channels_sub.subscribe(messages_store.updateMessageChannels) +} + function handleNodeSearch(event: Event) { const target = event.target as HTMLInputElement node_search.value = target.value @@ -154,6 +158,7 @@ ros_store.$onAction(({ name, after }) => { updateTreeSubscription() updateSubtreeInfoSubscription() updateMessagesSubscription() + updateChannelssubscription() updatePackagesSubscription() }) }) @@ -163,6 +168,7 @@ onMounted(() => { updateTreeSubscription() updateSubtreeInfoSubscription() updateMessagesSubscription() + updateChannelssubscription() updatePackagesSubscription() }) diff --git a/src/assets/utils.scss b/src/assets/utils.scss index 5570fc7..218ad79 100644 --- a/src/assets/utils.scss +++ b/src/assets/utils.scss @@ -60,3 +60,15 @@ --bs-btn-disabled-border-color: var(--bs-body-color); --bs-gradient: none; } + +.search-results { + padding-left: 5px; + padding-right: 5px; + + max-height: 11em; + overflow-y: auto; +} + +.search-result:hover { + background-color: #007bff; +} diff --git a/src/components/D3BehaviorTreeEditor.vue b/src/components/D3BehaviorTreeEditor.vue index b2c77b3..6414407 100644 --- a/src/components/D3BehaviorTreeEditor.vue +++ b/src/components/D3BehaviorTreeEditor.vue @@ -42,27 +42,19 @@ import type { NodeDataLocation, NodeMsg, ParamData, - PyEnum, - PyLogger, - PyOperand, - PyOperator, - TreeMsg, TrimmedNode, TrimmedNodeData, NodeDataWiring } from '@/types/types' import { Position, IOKind } from '@/types/types' -import { getDefaultValue, prettyprint_type, python_builtin_types, typesCompatible } from '@/utils' -import { faArrowDown19 } from '@fortawesome/free-solid-svg-icons' +import { getDefaultValue, prettyprint_type, serializeNodeOptions, typesCompatible } from '@/utils' import { notify } from '@kyvg/vue3-notification' import * as d3 from 'd3' -import type { ZoomBehavior } from 'd3' import { onMounted, ref, watch, watchEffect } from 'vue' import type { HierarchyNode, HierarchyLink } from 'd3-hierarchy' import { flextree, type FlextreeNode } from 'd3-flextree' import type { MoveNodeRequest, MoveNodeResponse } from '@/types/services/MoveNode' import type { RemoveNodeRequest, RemoveNodeResponse } from '@/types/services/RemoveNode' -import type { ReplaceNodeRequest, ReplaceNodeResponse } from '@/types/services/ReplaceNode' import type { WireNodeDataRequest, WireNodeDataResponse } from '@/types/services/WireNodeData' const editor_store = useEditorStore() @@ -152,34 +144,10 @@ function resetView() { } function buildNodeMessage(node: DocumentedNode): NodeMsg { - function getDefaultValues(paramList: NodeData[], options?: NodeData[] | null) { - options = options || [] - - return paramList.map((x) => { - return { - key: x.key, - value: getDefaultValue(prettyprint_type(x.serialized_value), options) - } - }) - } - const default_options = getDefaultValues(node.options) - const options = default_options.map((x) => { - if (x.value.type === 'unset_optionref') { - const optionref: string = x.value.value as string - const optionTypeName = optionref.substring('Ref to "'.length, optionref.length - 1) - const optionType = default_options.find((x) => { - return x.key === optionTypeName - }) - if (optionType && optionType.value) { - return { - key: x.key, - value: getDefaultValue(optionType.value.value as string) - } - } - } + const options = node.options.map((opt: NodeData) => { return { - key: x.key, - value: x.value + key: opt.key, + value: getDefaultValue(prettyprint_type(opt.serialized_value), node.options) } as ParamData }) @@ -187,32 +155,7 @@ function buildNodeMessage(node: DocumentedNode): NodeMsg { module: node.module, node_class: node.node_class, name: node.name, - options: options.map((x) => { - const option: NodeData = { - key: x.key, - serialized_value: '', - serialized_type: '' - } - if (x.value.type === 'type') { - if (python_builtin_types.indexOf(x.value.value as string) >= 0) { - x.value.value = '__builtin__.' + x.value.value - } - option.serialized_value = JSON.stringify({ - 'py/type': x.value.value - }) - } else if (x.value.type.startsWith('__')) { - const py_value: PyLogger | PyOperator | PyOperand | PyEnum = x.value.value as - | PyLogger - | PyOperator - | PyOperand - | PyEnum - py_value['py/object' as keyof typeof py_value] = x.value.type.substring('__'.length) - option.serialized_value = JSON.stringify(x.value.value) - } else { - option.serialized_value = JSON.stringify(x.value.value) - } - return option - }), + options: serializeNodeOptions(options), child_names: [], inputs: [], outputs: [], diff --git a/src/components/EditableNode.vue b/src/components/EditableNode.vue index 55b8783..32775ac 100644 --- a/src/components/EditableNode.vue +++ b/src/components/EditableNode.vue @@ -28,16 +28,12 @@ * POSSIBILITY OF SUCH DAMAGE. --> diff --git a/src/components/JSONInput.vue b/src/components/JSONInput.vue index f718dd5..c5110a4 100644 --- a/src/components/JSONInput.vue +++ b/src/components/JSONInput.vue @@ -29,23 +29,13 @@ --> diff --git a/src/components/ParamInputs.vue b/src/components/ParamInputs.vue index 16052e7..f0662f4 100644 --- a/src/components/ParamInputs.vue +++ b/src/components/ParamInputs.vue @@ -36,6 +36,23 @@ import MathOperandParam from './param_inputs/MathOperandParam.vue' import { computed } from 'vue' import { useEditNodeStore } from '@/stores/edit_node' import { useEditorStore } from '@/stores/editor' +import FilePathParam from './param_inputs/FilePathParam.vue' +import { + FilePath_Name, + MathBinaryOperator_Name, + MathOperandType_Name, + MathUnaryOperandType_Name, + MathUnaryOperator_Name, + OrderedDict_Name, + RosTopicType_Name, + RosTopicName_Name, + RosServiceType_Name, + RosServiceName_Name, + RosActionType_Name, + RosActionName_Name +} from '@/types/python_types' +import RosTypeParam from './param_inputs/RosTypeParam.vue' +import RosNameParam from './param_inputs/RosNameParam.vue' const props = defineProps<{ category: 'options' @@ -104,7 +121,7 @@ const json_attrs = computed(() => { case 'list': break case 'dict': - case 'collections.OrderedDict': + case OrderedDict_Name: break default: break @@ -187,6 +204,51 @@ function onFocus() { :op_type="'unary'" /> + + + + + + + + + + +