2026-01-14 20:00:35 -05:00
|
|
|
import { memo } from 'react';
|
|
|
|
|
import { NodeProps } from 'reactflow';
|
2026-01-24 15:17:34 -05:00
|
|
|
import { Cpu, Terminal } from 'lucide-react';
|
2026-01-14 20:00:35 -05:00
|
|
|
import { BaseNode } from './BaseNode';
|
2026-01-24 15:17:34 -05:00
|
|
|
import { SolverNodeData, SolverEngine } from '../../../lib/canvas/schema';
|
|
|
|
|
|
|
|
|
|
// Human-readable engine names
|
|
|
|
|
const ENGINE_LABELS: Record<SolverEngine, string> = {
|
|
|
|
|
nxnastran: 'NX Nastran',
|
|
|
|
|
mscnastran: 'MSC Nastran',
|
|
|
|
|
python: 'Python Script',
|
|
|
|
|
abaqus: 'Abaqus',
|
|
|
|
|
ansys: 'ANSYS',
|
|
|
|
|
};
|
2026-01-14 20:00:35 -05:00
|
|
|
|
|
|
|
|
function SolverNodeComponent(props: NodeProps<SolverNodeData>) {
|
|
|
|
|
const { data } = props;
|
2026-01-24 15:17:34 -05:00
|
|
|
|
|
|
|
|
// Build display string: "Engine - SolutionType" or just one
|
|
|
|
|
const engineLabel = data.engine ? ENGINE_LABELS[data.engine] : null;
|
|
|
|
|
const solverTypeLabel = data.solverType || null;
|
|
|
|
|
|
|
|
|
|
let displayText: string;
|
|
|
|
|
if (engineLabel && solverTypeLabel) {
|
|
|
|
|
displayText = `${engineLabel} (${solverTypeLabel})`;
|
|
|
|
|
} else if (engineLabel) {
|
|
|
|
|
displayText = engineLabel;
|
|
|
|
|
} else if (solverTypeLabel) {
|
|
|
|
|
displayText = solverTypeLabel;
|
|
|
|
|
} else {
|
|
|
|
|
displayText = 'Configure solver';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use Terminal icon for Python, Cpu for others
|
|
|
|
|
const icon = data.engine === 'python'
|
|
|
|
|
? <Terminal size={16} />
|
|
|
|
|
: <Cpu size={16} />;
|
|
|
|
|
|
2026-01-14 20:00:35 -05:00
|
|
|
return (
|
2026-01-24 15:17:34 -05:00
|
|
|
<BaseNode {...props} icon={icon} iconColor="text-violet-400">
|
|
|
|
|
{displayText}
|
2026-01-14 20:00:35 -05:00
|
|
|
</BaseNode>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
export const SolverNode = memo(SolverNodeComponent);
|