Edit mode prep (#2370)
* remove edit mode * small rename * update with compat with old edit mode * exit edit mode still needed * add log to export
This commit is contained in:
		@ -273,6 +273,8 @@ const part001 = startSketchOn('-XZ')
 | 
			
		||||
  for (let { modelPath, imagePath, outputType } of exportLocations) {
 | 
			
		||||
    // May change depending on the file being dealt with
 | 
			
		||||
    let cliCommand = `export ZOO_TOKEN=${secrets.snapshottoken} && zoo file snapshot --output-format=png --src-format=${outputType} ${modelPath} ${imagePath}`
 | 
			
		||||
    const fileSize = (await fsp.stat(modelPath)).size
 | 
			
		||||
    console.log(`Size of the file at ${modelPath}: ${fileSize} bytes`)
 | 
			
		||||
 | 
			
		||||
    const parentPath = path.dirname(modelPath)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -56,7 +56,7 @@ function CommandBarSelectionInput({
 | 
			
		||||
  // In future the engine's edit mode will go away and this will be handled differently.
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    kclManager.exitEditMode()
 | 
			
		||||
    return () => kclManager.enterEditMode()
 | 
			
		||||
    return () => kclManager.defaultSelectionFilter()
 | 
			
		||||
  }, [])
 | 
			
		||||
 | 
			
		||||
  // Fast-forward through this arg if it's marked as skippable
 | 
			
		||||
 | 
			
		||||
@ -188,7 +188,7 @@ export class KclManager {
 | 
			
		||||
      engineCommandManager: this.engineCommandManager,
 | 
			
		||||
    })
 | 
			
		||||
    sceneInfra.modelingSend({ type: 'code edit during sketch' })
 | 
			
		||||
    enterEditMode(programMemory, this.engineCommandManager)
 | 
			
		||||
    defaultSelectionFilter(programMemory, this.engineCommandManager)
 | 
			
		||||
    this.isExecuting = false
 | 
			
		||||
    // Check the cancellation token for this execution before applying side effects
 | 
			
		||||
    if (this._cancelTokens.get(currentExecutionId)) {
 | 
			
		||||
@ -348,9 +348,6 @@ export class KclManager {
 | 
			
		||||
    void this.engineCommandManager.setPlaneHidden(this.defaultPlanes.yz, true)
 | 
			
		||||
    void this.engineCommandManager.setPlaneHidden(this.defaultPlanes.xz, true)
 | 
			
		||||
  }
 | 
			
		||||
  enterEditMode() {
 | 
			
		||||
    enterEditMode(this.programMemory, this.engineCommandManager)
 | 
			
		||||
  }
 | 
			
		||||
  exitEditMode() {
 | 
			
		||||
    this.engineCommandManager.sendSceneCommand({
 | 
			
		||||
      type: 'modeling_cmd_req',
 | 
			
		||||
@ -358,9 +355,12 @@ export class KclManager {
 | 
			
		||||
      cmd: { type: 'edit_mode_exit' },
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
  defaultSelectionFilter() {
 | 
			
		||||
    defaultSelectionFilter(this.programMemory, this.engineCommandManager)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function enterEditMode(
 | 
			
		||||
function defaultSelectionFilter(
 | 
			
		||||
  programMemory: ProgramMemory,
 | 
			
		||||
  engineCommandManager: EngineCommandManager
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
@ -77,7 +77,29 @@ export async function getEventForSelectWithPoint(
 | 
			
		||||
      },
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  const _artifact = engineCommandManager.artifactMap[data.entity_id]
 | 
			
		||||
  let _artifact = engineCommandManager.artifactMap[data.entity_id]
 | 
			
		||||
  if (!_artifact) {
 | 
			
		||||
    // This logic for getting the parent id is for solid2ds as in edit mode it return the face id
 | 
			
		||||
    // but we don't recognise that in the artifact map because we store the path id when the path is
 | 
			
		||||
    // created, the solid2d is implicitly created with the close stdlib function
 | 
			
		||||
    // there's plans to get the faceId back from the solid2d creation
 | 
			
		||||
    // https://github.com/KittyCAD/engine/issues/2094
 | 
			
		||||
    // at which point we can add it to the artifact map and remove this logic
 | 
			
		||||
    const parentId = (
 | 
			
		||||
      await engineCommandManager.sendSceneCommand({
 | 
			
		||||
        type: 'modeling_cmd_req',
 | 
			
		||||
        cmd: {
 | 
			
		||||
          type: 'entity_get_parent_id',
 | 
			
		||||
          entity_id: data.entity_id,
 | 
			
		||||
        },
 | 
			
		||||
        cmd_id: uuidv4(),
 | 
			
		||||
      })
 | 
			
		||||
    )?.data?.data?.entity_id
 | 
			
		||||
    const parentArtifact = engineCommandManager.artifactMap[parentId]
 | 
			
		||||
    if (parentArtifact) {
 | 
			
		||||
      _artifact = parentArtifact
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  const sourceRange = _artifact?.range
 | 
			
		||||
  if (_artifact) {
 | 
			
		||||
    if (_artifact.commandType === 'solid3d_get_extrusion_face_info') {
 | 
			
		||||
 | 
			
		||||
@ -1027,7 +1027,8 @@ export const modelingMachine = createMachine(
 | 
			
		||||
            filter: ['face', 'plane'],
 | 
			
		||||
          },
 | 
			
		||||
        }),
 | 
			
		||||
      'set selection filter to defaults': () => kclManager.enterEditMode(),
 | 
			
		||||
      'set selection filter to defaults': () =>
 | 
			
		||||
        kclManager.defaultSelectionFilter(),
 | 
			
		||||
    },
 | 
			
		||||
    // end actions
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user