@@ -14,14 +14,14 @@ import {ANGLE_UNIT, OutlineType, getWorldOrImage, findClosestIndex, makeFootprin
14
14
lengthSizeUnit , updateFootprintDrawobjAngle ,
15
15
updateFootprintTranslate , updateFootprintOutline } from '../visualize/draw/MarkerFootprintObj.js' ;
16
16
import { markerInterval , getCC , cancelTimeoutProcess , initMarkerPos ,
17
- updateVertexInfo , updateMarkerText } from './MarkerTool.js' ;
17
+ updateVertexInfo , updateMarkerText , translateForRelocate , getMovement } from './MarkerTool.js' ;
18
18
import { getFootprintToolUIComponent } from './FootprintToolUI.jsx' ;
19
19
import ShapeDataObj from '../visualize/draw/ShapeDataObj.js' ;
20
20
import { clone } from '../util/WebUtil.js' ;
21
21
import { getDS9Region } from '../rpc/PlotServicesJson.js' ;
22
22
import { FootprintFactory } from '../visualize/draw/FootprintFactory.js' ;
23
23
import { makeImagePt } from '../visualize/Point.js' ;
24
- import { get , set , isArray , has , isNil } from 'lodash' ;
24
+ import { get , set , isArray , has , isNil , isEmpty } from 'lodash' ;
25
25
import Enum from 'enum' ;
26
26
27
27
@@ -67,7 +67,7 @@ export function footprintCreateLayerActionCreator(rawAction) {
67
67
get ( visRoot ( ) , 'activePlotId' ) : isArray ( plotId ) ? plotId [ 0 ] : plotId ;
68
68
69
69
if ( pId ) {
70
- dispatchAttachLayerToPlot ( drawLayerId , pId , attachPlotGroup ) ;
70
+ dispatchAttachLayerToPlot ( drawLayerId , pId , attachPlotGroup , attachPlotGroup ) ;
71
71
72
72
var plot = primePlot ( visRoot ( ) , pId ) ;
73
73
if ( plot ) {
@@ -102,6 +102,7 @@ export function footprintStartActionCreator(rawAction) {
102
102
const { footprintStatus, currentPt, timeoutProcess} = get ( footprintObj , 'actionInfo' , { } ) ;
103
103
var wpt , idx , refPt ;
104
104
var nextStatus = null ;
105
+ let move = { } ;
105
106
106
107
cancelTimeoutProcess ( timeoutProcess ) ;
107
108
// marker can move to anywhere the mouse click at while in 'attached' state
@@ -112,7 +113,8 @@ export function footprintStartActionCreator(rawAction) {
112
113
wpt = getWorldOrImage ( currentPt , cc ) ;
113
114
nextStatus = FootprintStatus . rotate ;
114
115
} else {
115
- wpt = getWorldOrImage ( imagePt , cc ) ; // relocate the footprint right after the layer is attached
116
+ wpt = getWorldOrImage ( currentPt , cc ) ; // relocate the footprint right after the layer is attached
117
+ move = getMovement ( currentPt , imagePt , cc ) ;
116
118
nextStatus = FootprintStatus . attached_relocate ;
117
119
}
118
120
}
@@ -132,7 +134,7 @@ export function footprintStartActionCreator(rawAction) {
132
134
}
133
135
if ( nextStatus ) {
134
136
showFootprintByTimer ( dispatcher , DrawLayerCntlr . FOOTPRINT_START , regions , plotId ,
135
- nextStatus , footprintInterval , drawLayerId , { isOutline : true , isRotate :true } , fpInfo , wpt , refPt ) ;
137
+ nextStatus , footprintInterval , drawLayerId , { isOutline : true , isRotate :true } , fpInfo , wpt , refPt , move ) ;
136
138
}
137
139
} ;
138
140
}
@@ -278,13 +280,13 @@ function getLayerChanges(drawLayer, action) {
278
280
if ( ! drawLayerId || drawLayerId !== drawLayer . drawLayerId ) return null ;
279
281
280
282
const dd = Object . assign ( { } , drawLayer . drawData ) ;
281
- var plotIdAry ;
283
+ const { plotIdAry= [ ] } = drawLayer ;
282
284
var retV = null ;
283
285
284
286
switch ( action . type ) {
285
287
286
288
case DrawLayerCntlr . FOOTPRINT_CREATE :
287
- plotIdAry = getPlotViewIdListInGroup ( visRoot ( ) , plotId ) ;
289
+ // plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
288
290
plotIdAry . forEach ( ( pId ) => {
289
291
const plot = primePlot ( visRoot ( ) , pId ) ;
290
292
const cc = CsysConverter . make ( plot ) ;
@@ -300,17 +302,17 @@ function getLayerChanges(drawLayer, action) {
300
302
var wptObj ;
301
303
const { wpt} = action . payload ;
302
304
303
- plotIdAry = getPlotViewIdListInGroup ( visRoot ( ) , plotId ) ;
305
+ // plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
304
306
plotIdAry . forEach ( ( pId ) => {
305
307
wptObj = ( pId === plotId ) ? wpt : get ( dd , [ 'data' , pId , 'pts' , '0' ] ) ;
306
308
retV = createFootprintObjs ( action , drawLayer , pId , wptObj , retV ) ;
307
309
} ) ;
308
310
return retV ;
309
311
310
312
case DrawLayerCntlr . MODIFY_CUSTOM_FIELD :
311
- const { fpText, fpTextLoc, angleDeg, activePlotId } = action . payload . changes ;
313
+ const { fpText, fpTextLoc, angleDeg} = action . payload . changes ;
312
314
313
- plotIdAry = getPlotViewIdListInGroup ( visRoot ( ) , activePlotId ) ;
315
+ // plotIdAry = getPlotViewIdListInGroup(visRoot(), activePlotId);
314
316
if ( plotIdAry ) {
315
317
if ( ! isNil ( angleDeg ) ) {
316
318
return updateFootprintAngle ( angleDeg , dd [ DataTypes . DATA ] , plotIdAry ) ;
@@ -319,6 +321,11 @@ function getLayerChanges(drawLayer, action) {
319
321
}
320
322
}
321
323
break ;
324
+ case DrawLayerCntlr . ATTACH_LAYER_TO_PLOT :
325
+ if ( get ( action . payload , 'isExistingDrawLayer' , false ) ) {
326
+ return attachToNewPlot ( drawLayer , get ( action . payload , [ 'plotIdAry' , '0' ] ) ) ;
327
+ }
328
+ break ;
322
329
default :
323
330
return null ;
324
331
}
@@ -437,8 +444,10 @@ function createFootprintObjs(action, dl, plotId, wpt, prevRet) {
437
444
438
445
if ( footprintStatus === FootprintStatus . attached ||
439
446
footprintStatus === FootprintStatus . attached_relocate ) { // position is relocated after the layer is attached
440
-
441
447
footprintObj = makeFootprint ( regions , wpt , isHandle , cc , text , textLoc ) ;
448
+ if ( footprintStatus === FootprintStatus . attached_relocate ) {
449
+ footprintObj = translateForRelocate ( footprintObj , move , cc ) ;
450
+ }
442
451
} else if ( crtFpObj ) {
443
452
if ( ( footprintStatus === FootprintStatus . rotate || footprintStatus === FootprintStatus . relocate ) && move ) {
444
453
var { apt} = move ; // move to relocate or rotate
@@ -518,4 +527,55 @@ function resetRotateSide(footprintObj) {
518
527
outlineBox [ rSide ] = 1 ;
519
528
}
520
529
}
521
- }
530
+ }
531
+
532
+ /**
533
+ * add the footprint drawing objects into the new plot reated after the drawing layer is created
534
+ * @param drawLayer
535
+ * @param newPlotId new plot
536
+ * @returns {* }
537
+ */
538
+ function attachToNewPlot ( drawLayer , newPlotId ) {
539
+ const data = get ( drawLayer , [ 'drawData' , 'data' ] , { } ) ;
540
+ const existPlotId = ! isEmpty ( data ) && Object . keys ( data ) . find ( ( pId ) => {
541
+ return ! isEmpty ( drawLayer . drawData . data [ pId ] ) ;
542
+ } ) ;
543
+
544
+ if ( ! existPlotId ) return null ;
545
+
546
+ const { text, textLoc, renderOptions, actionInfo, translation, angle, angleUnit,
547
+ drawData, regions} = get ( drawLayer , [ 'drawData' , 'data' , existPlotId ] ) ;
548
+ const plot = primePlot ( visRoot ( ) , newPlotId ) ;
549
+ const cc = CsysConverter . make ( plot ) ;
550
+ let wpt = initMarkerPos ( plot , cc ) ;
551
+ let footprintObj = makeFootprint ( regions , wpt ,
552
+ { isOutline : drawData ? drawData . isOutline : false ,
553
+ isRotate : drawData ? drawData . isRorate : false } ,
554
+ cc , text , textLoc ) ;
555
+
556
+ if ( ! isEmpty ( translation ) ) {
557
+ footprintObj = updateFootprintTranslate ( footprintObj , cc , translation ) ;
558
+ footprintObj = updateFootprintOutline ( footprintObj , cc ) ;
559
+ resetRotateSide ( footprintObj ) ;
560
+ wpt = get ( footprintObj , [ 'pts' , '0' ] ) ;
561
+ }
562
+
563
+ if ( angle ) {
564
+ footprintObj = updateFootprintDrawobjAngle ( footprintObj , cc , wpt , angle , angleUnit ) ;
565
+ footprintObj . angleFromUI = false ;
566
+ }
567
+
568
+ const aInfo = Object . assign ( { } , actionInfo , { currentPt : wpt } ) ;
569
+ set ( drawLayer . drawData , [ DataTypes . DATA , newPlotId ] , Object . assign ( footprintObj , { actionInfo : aInfo ,
570
+ renderOptions, translation} ) ) ;
571
+ const dlObj = { drawData : drawLayer . drawData , helpLine : editHelpText } ;
572
+
573
+ if ( aInfo . footprintStatus ) {
574
+ const { exclusiveDef, vertexDef} = updateVertexInfo ( footprintObj , newPlotId , drawLayer , drawLayer ) ;
575
+
576
+ if ( exclusiveDef && vertexDef ) {
577
+ return clone ( dlObj , { footprintStatus : aInfo . footprintStatus , vertexDef, exclusiveDef} ) ;
578
+ }
579
+ }
580
+ return dlObj ;
581
+ }
0 commit comments