@@ -5,9 +5,18 @@ import { isOk, withResultAsync } from 'common/util/result';
55import  {  useCanvasManager  }  from  'features/controlLayers/contexts/CanvasManagerProviderGate' ; 
66import  {  selectDefaultControlAdapter ,  selectDefaultIPAdapter  }  from  'features/controlLayers/hooks/addLayerHooks' ; 
77import  {  getPrefixedId  }  from  'features/controlLayers/konva/util' ; 
8- import  {  controlLayerAdded ,  ipaAdded ,  rasterLayerAdded ,  rgAdded  }  from  'features/controlLayers/store/canvasSlice' ; 
8+ import  { 
9+   controlLayerAdded , 
10+   entityRasterized , 
11+   ipaAdded , 
12+   ipaImageChanged , 
13+   rasterLayerAdded , 
14+   rgAdded , 
15+   rgIPAdapterImageChanged , 
16+ }  from  'features/controlLayers/store/canvasSlice' ; 
917import  type  { 
1018  CanvasControlLayerState , 
19+   CanvasEntityIdentifier , 
1120  CanvasIPAdapterState , 
1221  CanvasRasterLayerState , 
1322  CanvasRegionalGuidanceState , 
@@ -102,7 +111,7 @@ export const useSaveBboxAsRegionalGuidanceIPAdapter = () => {
102111      dispatch ( rgAdded ( {  overrides,  isSelected : true  } ) ) ; 
103112    } ; 
104113
105-     return  {  region : 'bbox' ,  saveToGallery : true ,  onSave } ; 
114+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
106115  } ,  [ defaultIPAdapter ,  dispatch ] ) ; 
107116  const  saveBboxAsRegionalGuidanceIPAdapter  =  useSaveCanvas ( saveBboxAsRegionalGuidanceIPAdapterArg ) ; 
108117  return  saveBboxAsRegionalGuidanceIPAdapter ; 
@@ -123,7 +132,7 @@ export const useSaveBboxAsGlobalIPAdapter = () => {
123132      dispatch ( ipaAdded ( {  overrides,  isSelected : true  } ) ) ; 
124133    } ; 
125134
126-     return  {  region : 'bbox' ,  saveToGallery : true ,  onSave } ; 
135+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
127136  } ,  [ defaultIPAdapter ,  dispatch ] ) ; 
128137  const  saveBboxAsIPAdapter  =  useSaveCanvas ( saveBboxAsIPAdapterArg ) ; 
129138  return  saveBboxAsIPAdapter ; 
@@ -140,7 +149,7 @@ export const useSaveBboxAsRasterLayer = () => {
140149      dispatch ( rasterLayerAdded ( {  overrides,  isSelected : true  } ) ) ; 
141150    } ; 
142151
143-     return  {  region : 'bbox' ,  saveToGallery : true ,  onSave } ; 
152+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
144153  } ,  [ dispatch ] ) ; 
145154  const  saveBboxAsRasterLayer  =  useSaveCanvas ( saveBboxAsRasterLayerArg ) ; 
146155  return  saveBboxAsRasterLayer ; 
@@ -160,8 +169,63 @@ export const useSaveBboxAsControlLayer = () => {
160169      dispatch ( controlLayerAdded ( {  overrides,  isSelected : true  } ) ) ; 
161170    } ; 
162171
163-     return  {  region : 'bbox' ,  saveToGallery : true ,  onSave } ; 
172+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
164173  } ,  [ defaultControlAdapter ,  dispatch ] ) ; 
165174  const  saveBboxAsControlLayer  =  useSaveCanvas ( saveBboxAsControlLayerArg ) ; 
166175  return  saveBboxAsControlLayer ; 
167176} ; 
177+ 
178+ export  const  usePullBboxIntoLayer  =  ( entityIdentifier : CanvasEntityIdentifier < 'control_layer'  |  'raster_layer' > )  =>  { 
179+   const  dispatch  =  useAppDispatch ( ) ; 
180+ 
181+   const  pullBboxIntoLayerArg  =  useMemo < UseSaveCanvasArg > ( ( )  =>  { 
182+     const  onSave  =  ( imageDTO : ImageDTO ,  rect : Rect )  =>  { 
183+       dispatch ( 
184+         entityRasterized ( { 
185+           entityIdentifier, 
186+           position : {  x : rect . x ,  y : rect . y  } , 
187+           imageObject : imageDTOToImageObject ( imageDTO ) , 
188+           replaceObjects : true , 
189+         } ) 
190+       ) ; 
191+     } ; 
192+ 
193+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
194+   } ,  [ dispatch ,  entityIdentifier ] ) ; 
195+ 
196+   const  pullBboxIntoLayer  =  useSaveCanvas ( pullBboxIntoLayerArg ) ; 
197+   return  pullBboxIntoLayer ; 
198+ } ; 
199+ 
200+ export  const  usePullBboxIntoIPAdapter  =  ( entityIdentifier : CanvasEntityIdentifier < 'ip_adapter' > )  =>  { 
201+   const  dispatch  =  useAppDispatch ( ) ; 
202+ 
203+   const  pullBboxIntoIPAdapterArg  =  useMemo < UseSaveCanvasArg > ( ( )  =>  { 
204+     const  onSave  =  ( imageDTO : ImageDTO ,  _ : Rect )  =>  { 
205+       dispatch ( ipaImageChanged ( {  entityIdentifier,  imageDTO } ) ) ; 
206+     } ; 
207+ 
208+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
209+   } ,  [ dispatch ,  entityIdentifier ] ) ; 
210+ 
211+   const  pullBboxIntoIPAdapter  =  useSaveCanvas ( pullBboxIntoIPAdapterArg ) ; 
212+   return  pullBboxIntoIPAdapter ; 
213+ } ; 
214+ 
215+ export  const  usePullBboxIntoRegionalGuidanceIPAdapter  =  ( 
216+   entityIdentifier : CanvasEntityIdentifier < 'regional_guidance' > , 
217+   ipAdapterId : string 
218+ )  =>  { 
219+   const  dispatch  =  useAppDispatch ( ) ; 
220+ 
221+   const  pullBboxIntoRegionalGuidanceIPAdapterArg  =  useMemo < UseSaveCanvasArg > ( ( )  =>  { 
222+     const  onSave  =  ( imageDTO : ImageDTO ,  _ : Rect )  =>  { 
223+       dispatch ( rgIPAdapterImageChanged ( {  entityIdentifier,  ipAdapterId,  imageDTO } ) ) ; 
224+     } ; 
225+ 
226+     return  {  region : 'bbox' ,  saveToGallery : false ,  onSave } ; 
227+   } ,  [ dispatch ,  entityIdentifier ,  ipAdapterId ] ) ; 
228+ 
229+   const  pullBboxIntoRegionalGuidanceIPAdapter  =  useSaveCanvas ( pullBboxIntoRegionalGuidanceIPAdapterArg ) ; 
230+   return  pullBboxIntoRegionalGuidanceIPAdapter ; 
231+ } ; 
0 commit comments