other.ts 849 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {EXPCAD as CAD} from './index'
  2. export interface Other{
  3. showLabel: () => void,
  4. hideLabel: () => void
  5. }
  6. // 附加走过路径的label
  7. export const other = (cad: CAD) => {
  8. let show = false
  9. let addProcessing = cad.addProcessing
  10. cad.addProcessing = (...args) => {
  11. let processing = addProcessing.call(cad, ...args)
  12. let addTagging = processing.addTagging
  13. processing.addTagging = (args) => {
  14. (args as any).show = show
  15. return addTagging.call(processing, args)
  16. }
  17. return processing
  18. }
  19. cad.hideLabel = () => {
  20. show = false
  21. cad.processings.forEach(processing => {
  22. processing.taggings.forEach(t => t.ele.show = show)
  23. })
  24. }
  25. cad.showLabel = () => {
  26. show = true
  27. cad.processings.forEach(processing => {
  28. processing.taggings.forEach(t => t.ele.show = show)
  29. })
  30. }
  31. }