Spaces:
Running
Running
import { defineStore } from 'pinia' | |
export const useCalibrationStore = defineStore('calibration', { | |
state: () => ({ | |
// Flux principal | |
mode: null, // 'auto' ou 'manual' | |
currentStep: 'mode-selection', // 'mode-selection', 'upload', 'video-type', 'processing', 'results' | |
// Traitement | |
processing: false, | |
processingProgress: 0, | |
processingTask: '', | |
// Résultats | |
results: null, | |
error: null, | |
// Configuration manuelle | |
manualLines: {}, | |
// Configuration vidéo dynamique | |
videoProcessingParams: { | |
kpThreshold: 0.15, | |
lineThreshold: 0.15, | |
frameStep: 10 | |
} | |
}), | |
getters: { | |
isAutoMode: (state) => state.mode === 'auto', | |
isManualMode: (state) => state.mode === 'manual', | |
hasResults: (state) => state.results !== null, | |
isProcessing: (state) => state.processing, | |
// Étapes actives | |
isModeSelection: (state) => state.currentStep === 'mode-selection', | |
isUploadStep: (state) => state.currentStep === 'upload', | |
isVideoTypeStep: (state) => state.currentStep === 'video-type', | |
isProcessingStep: (state) => state.currentStep === 'processing', | |
isResultsStep: (state) => state.currentStep === 'results' | |
}, | |
actions: { | |
// Navigation entre étapes | |
setMode(mode) { | |
this.mode = mode | |
this.currentStep = 'upload' | |
}, | |
setCurrentStep(step) { | |
this.currentStep = step | |
}, | |
// Traitement | |
setProcessing(processing, task = '') { | |
this.processing = processing | |
this.processingTask = task | |
if (processing) { | |
this.currentStep = 'processing' | |
} | |
}, | |
updateProgress(progress, task = '') { | |
this.processingProgress = progress | |
if (task) this.processingTask = task | |
}, | |
setResults(results) { | |
this.results = results | |
this.processing = false | |
this.error = null | |
this.currentStep = 'results' | |
}, | |
setError(error) { | |
this.error = error | |
this.processing = false | |
}, | |
// Configuration | |
setVideoParams(params) { | |
this.videoProcessingParams = { ...this.videoProcessingParams, ...params } | |
}, | |
setManualLines(lines) { | |
this.manualLines = lines | |
}, | |
// Réinitialisation | |
reset() { | |
this.mode = null | |
this.currentStep = 'mode-selection' | |
this.processing = false | |
this.processingProgress = 0 | |
this.processingTask = '' | |
this.results = null | |
this.error = null | |
this.manualLines = {} | |
}, | |
// Passer en mode manuel depuis les résultats | |
switchToManual() { | |
this.mode = 'manual' | |
// On garde les autres données pour permettre le retour | |
} | |
} | |
}) |