@@ -37,14 +37,13 @@ import { TrackableBoolean } from "#src/trackable_boolean.js";
3737import type { WatchableValueInterface } from "#src/trackable_value.js" ;
3838import { TrackableValue , WatchableValue } from "#src/trackable_value.js" ;
3939import type { UserLayerWithAnnotations } from "#src/ui/annotations.js" ;
40+ import { randomUint64 } from "#src/util/bigint.js" ;
4041import { RefCounted } from "#src/util/disposable.js" ;
41- import { verifyFiniteFloat , verifyInt } from "#src/util/json.js" ;
42- import { NullarySignal } from "#src/util/signal.js" ;
42+ import { parseUint64 , verifyFiniteFloat , verifyInt } from "#src/util/json.js" ;
4343import { TrackableEnum } from "#src/util/trackable_enum.js" ;
4444import { VoxelPreviewMultiscaleSource } from "#src/voxel_annotation/PreviewMultiscaleChunkSource.js" ;
4545import type { VoxelEditControllerHost } from "#src/voxel_annotation/edit_controller.js" ;
4646import { VoxelEditController } from "#src/voxel_annotation/edit_controller.js" ;
47- import { LabelsManager } from "#src/voxel_annotation/labels.js" ;
4847
4948export enum BrushShape {
5049 DISK = 0 ,
@@ -73,16 +72,9 @@ export class VoxelEditingContext
7372 //this.registerDisposer(optimisticRenderLayer);
7473 }
7574
76- // VoxelEditControllerHost implementation
77- get labelsManager ( ) : LabelsManager {
78- return this . hostLayer . voxLabelsManager ! ;
79- }
8075 get rpc ( ) {
8176 return this . hostLayer . manager . chunkManager . rpc ! ;
8277 }
83- setDrawErrorMessage ( message : string | undefined ) : void {
84- this . hostLayer . setDrawErrorMessage ( message ) ;
85- }
8678
8779 disposed ( ) {
8880 this . controller . dispose ( ) ;
@@ -141,23 +133,22 @@ export class VoxelEditingContext
141133}
142134
143135export declare abstract class UserLayerWithVoxelEditing extends UserLayer {
144- voxLabelsManager ?: LabelsManager ;
145- labelsChanged : NullarySignal ;
146136 isEditable : WatchableValue < boolean > ;
147- onDrawMessageChanged ?: ( ) => void ;
148- voxDrawErrorMessage : string | undefined ;
149137
150138 voxBrushRadius : TrackableValue < number > ;
151139 voxEraseMode : TrackableBoolean ;
152140 voxBrushShape : TrackableEnum < BrushShape > ;
153141 voxFloodMaxVoxels : TrackableValue < number > ;
142+ paintValue : TrackableValue < bigint > ;
154143
155144 editingContexts : Map < LoadedDataSubsource , VoxelEditingContext > ;
156145
157146 abstract _createVoxelRenderLayer (
158147 source : MultiscaleVolumeChunkSource ,
159148 transform : WatchableValueInterface < RenderLayerTransformOrError > ,
160149 ) : ImageRenderLayer | SegmentationRenderLayer ;
150+ abstract getVoxelPaintValue ( erase : boolean ) : bigint ;
151+ abstract setVoxelPaintValue ( value : bigint ) : void ;
161152
162153 initializeVoxelEditingForSubsource (
163154 loadedSubsource : LoadedDataSubsource ,
@@ -168,7 +159,6 @@ export declare abstract class UserLayerWithVoxelEditing extends UserLayer {
168159 ) : void ;
169160
170161 getIdentitySliceViewSourceOptions ( ) : SliceViewSourceOptions ;
171- setDrawErrorMessage ( message : string | undefined ) : void ;
172162 handleVoxAction ( action : string , context : LayerActionContext ) : void ;
173163}
174164
@@ -177,23 +167,15 @@ export function UserLayerWithVoxelEditingMixin<
177167> ( Base : TBase ) {
178168 abstract class C extends Base implements UserLayerWithVoxelEditing {
179169 editingContexts = new Map < LoadedDataSubsource , VoxelEditingContext > ( ) ;
180- voxLabelsManager ?: LabelsManager ;
181- labelsChanged = new NullarySignal ( ) ;
182170 isEditable = new WatchableValue < boolean > ( false ) ;
171+ paintValue = new TrackableValue < bigint > ( 1n , ( x ) => parseUint64 ( x ) ) ;
183172
184173 // Brush properties
185174 voxBrushRadius = new TrackableValue < number > ( 3 , verifyInt ) ;
186175 voxEraseMode = new TrackableBoolean ( false ) ;
187176 voxBrushShape = new TrackableEnum ( BrushShape , BrushShape . DISK ) ;
188177 voxFloodMaxVoxels = new TrackableValue < number > ( 10000 , verifyFiniteFloat ) ;
189178
190- voxDrawErrorMessage : string | undefined = undefined ;
191- onDrawMessageChanged ?: ( ) => void ;
192- setDrawErrorMessage ( message : string | undefined ) : void {
193- this . voxDrawErrorMessage = message ;
194- this . onDrawMessageChanged ?.( ) ;
195- }
196-
197179 constructor ( ...args : any [ ] ) {
198180 super ( ...args ) ;
199181 this . registerDisposer ( ( ) => {
@@ -206,13 +188,23 @@ export function UserLayerWithVoxelEditingMixin<
206188 this . voxEraseMode . changed . add ( this . specificationChanged . dispatch ) ;
207189 this . voxBrushShape . changed . add ( this . specificationChanged . dispatch ) ;
208190 this . voxFloodMaxVoxels . changed . add ( this . specificationChanged . dispatch ) ;
191+ this . paintValue . changed . add ( this . specificationChanged . dispatch ) ;
209192 this . tabs . add ( "Draw" , {
210193 label : "Draw" ,
211194 order : 20 ,
212195 getter : ( ) => new VoxToolTab ( this ) ,
213196 } ) ;
214197 }
215198
199+ getVoxelPaintValue ( erase : boolean ) : bigint {
200+ if ( erase ) return 0n ;
201+ return this . paintValue . value ;
202+ }
203+ setVoxelPaintValue ( value : bigint ) {
204+ this . paintValue . value = value ;
205+ }
206+
207+
216208 abstract _createVoxelRenderLayer (
217209 source : MultiscaleVolumeChunkSource ,
218210 transform : WatchableValueInterface < RenderLayerTransformOrError > ,
@@ -226,16 +218,6 @@ export function UserLayerWithVoxelEditingMixin<
226218
227219 const primarySource = loadedSubsource . subsourceEntry . subsource
228220 . volume as MultiscaleVolumeChunkSource ;
229- const baseSpec = primarySource . getSources (
230- this . getIdentitySliceViewSourceOptions ( ) ,
231- ) [ 0 ] [ 0 ] ! . chunkSource . spec ;
232-
233- if ( this . voxLabelsManager === undefined ) {
234- this . voxLabelsManager = new LabelsManager (
235- baseSpec . dataType ,
236- this . labelsChanged . dispatch ,
237- ) ;
238- }
239221
240222 const previewSource = new VoxelPreviewMultiscaleSource (
241223 this . manager . chunkManager ,
@@ -289,8 +271,7 @@ export function UserLayerWithVoxelEditingMixin<
289271 } ;
290272 }
291273
292- handleVoxAction ( action : string , context : LayerActionContext ) : void {
293- super . handleAction ( action , context ) ;
274+ handleVoxAction ( action : string , _context : LayerActionContext ) : void {
294275 const firstContext = this . editingContexts . values ( ) . next ( ) . value ;
295276 if ( ! firstContext ) return ;
296277 const controller = firstContext . controller ;
@@ -301,8 +282,8 @@ export function UserLayerWithVoxelEditingMixin<
301282 case "redo" :
302283 controller . redo ( ) ;
303284 break ;
304- case "new-label " :
305- this . voxLabelsManager ?. createNewLabel ( ) ;
285+ case "randomize-paint-value " :
286+ this . paintValue . value = randomUint64 ( ) ;
306287 break ;
307288 }
308289 }
0 commit comments