|
114 | 114 | currentObject.fillColor = 'black';
|
115 | 115 | currentObject.strokeWidth = 2;
|
116 | 116 | break;
|
| 117 | + case 'underline': |
| 118 | + var start = new ps.Point(event.point); |
| 119 | + $rootScope.startRow = getStartRow($rootScope.docInfo,start,attrs); |
| 120 | + $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(start.x)); |
| 121 | + if($rootScope.startText.length>1){ |
| 122 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight), new ps.Point($rootScope.startText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight)); |
| 123 | + currentObject.strokeColor = 'black'; |
| 124 | + currentObject.strokeWidth = 2; |
| 125 | + } |
| 126 | + else if($rootScope.startText.length>1){ |
| 127 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight), new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight)); |
| 128 | + currentObject.strokeColor = 'black'; |
| 129 | + currentObject.strokeWidth = 2; |
| 130 | + } |
| 131 | + break; |
| 132 | + case 'strikeout': |
| 133 | + var start = new ps.Point(event.point); |
| 134 | + $rootScope.startRow = getStartRow($rootScope.docInfo,start,attrs); |
| 135 | + $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(start.x)); |
| 136 | + if($rootScope.startText.length>1){ |
| 137 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2), new ps.Point($rootScope.startText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 138 | + currentObject.strokeColor = 'black'; |
| 139 | + currentObject.strokeWidth = 2; |
| 140 | + } |
| 141 | + else if($rootScope.startText.length>1){ |
| 142 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2), new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 143 | + currentObject.strokeColor = 'black'; |
| 144 | + currentObject.strokeWidth = 2; |
| 145 | + } |
| 146 | + break; |
117 | 147 | }
|
118 | 148 | };
|
119 | 149 |
|
|
141 | 171 | currentObject.position.x += event.delta.x;
|
142 | 172 | currentObject.position.y += event.delta.y;
|
143 | 173 | break;
|
| 174 | + case 'underline': |
| 175 | + if(currentObject){ |
| 176 | + var end = new ps.Point(event.point); |
| 177 | + var endText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(end.x)); |
| 178 | + if(endText.length>1){ |
| 179 | + currentObject.add(new ps.Point(endText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight)); |
| 180 | + } |
| 181 | + else if(endText.length>0){ |
| 182 | + currentObject.add(new ps.Point(endText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight)); |
| 183 | + } |
| 184 | + } |
| 185 | + break; |
| 186 | + case 'strikeout': |
| 187 | + if(currentObject){ |
| 188 | + var end = new ps.Point(event.point); |
| 189 | + var endText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(end.x)); |
| 190 | + if(endText.length>1){ |
| 191 | + currentObject.add(new ps.Point(endText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 192 | + } |
| 193 | + else if(endText.length>0){ |
| 194 | + currentObject.add(new ps.Point(endText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 195 | + } |
| 196 | + |
| 197 | + } |
| 198 | + break; |
144 | 199 | case 'arrow':
|
145 | 200 | if (currentObject) {
|
146 | 201 | currentObject.remove();
|
|
163 | 218 | currentObject.strokeColor = 'black';
|
164 | 219 | currentObject.strokeWidth = 2;
|
165 | 220 | break;
|
| 221 | + case 'distance': |
| 222 | + if(currentObject){ |
| 223 | + currentObject.remove(); |
| 224 | + } |
| 225 | + var start = new ps.Point(event.downPoint); |
| 226 | + var end = new ps.Point(event.point); |
| 227 | + var textX = (start.x + end.x)/2; |
| 228 | + var textY = (start.y + end.y)/2; |
| 229 | + var textPoint = new ps.Point(textX, textY); |
| 230 | + var tailLine = new ps.Path.Line(start, end); |
| 231 | + var textPosition = end.add(start); |
| 232 | + var tailVector = end.subtract(start); |
| 233 | + var headLine = tailVector.normalize(10); |
| 234 | + var tailArrow = tailVector.normalize(-10); |
| 235 | + currentObject = new ps.Group([ |
| 236 | + new ps.Path([start, end]), |
| 237 | + new ps.Path([ |
| 238 | + end.add(headLine.rotate(150)), |
| 239 | + end, |
| 240 | + end.add(headLine.rotate(-150)) |
| 241 | + ]), |
| 242 | + new ps.Path([ |
| 243 | + start.add(tailArrow.rotate(-150)), |
| 244 | + start, |
| 245 | + start.add(tailArrow.rotate(150)) |
| 246 | + ]), |
| 247 | + new ps.PointText(textPoint) |
| 248 | + ]); |
| 249 | + |
| 250 | + currentObject.strokeColor = 'black'; |
| 251 | + currentObject.strokeWidth = 2; |
| 252 | + currentObject._children[3].content = Math.floor(currentObject._children[0].length) + " px"; |
| 253 | + currentObject._children[3].strokeWidth = 0.5; |
| 254 | + break; |
166 | 255 | }
|
167 | 256 | };
|
168 | 257 |
|
|
214 | 303 | ant.svgPath = currentObject.exportSVG().firstChild.getAttribute('d');
|
215 | 304 | ant.svgPath += " " + currentObject.exportSVG().lastChild.getAttribute('d');
|
216 | 305 | break;
|
| 306 | + case 'distance': |
| 307 | + ant = { |
| 308 | + type : 12, |
| 309 | + svgPath : currentObject.exportSVG().children[0].getAttribute('d')+ " " + currentObject.exportSVG().children[1].getAttribute('d') + " " + currentObject.exportSVG().children[2].getAttribute('d'), |
| 310 | + text : currentObject.children[3].content, |
| 311 | + box : { |
| 312 | + x: currentObject.children[3].position.x, |
| 313 | + y: currentObject.children[3].position.y, |
| 314 | + width: 0, |
| 315 | + height: 0 |
| 316 | + } |
| 317 | + }; |
| 318 | + break; |
| 319 | + case 'underline': |
| 320 | + ant = { |
| 321 | + type : 11, |
| 322 | + svgPath : currentObject.exportSVG().getAttribute('d'), |
| 323 | + box: { |
| 324 | + x: currentObject.bounds.x, |
| 325 | + y: currentObject.bounds.y, |
| 326 | + width: 0, |
| 327 | + height: 0 |
| 328 | + }, |
| 329 | + }; |
| 330 | + break; |
| 331 | + case 'strikeout': |
| 332 | + ant = { |
| 333 | + type : 11, |
| 334 | + svgPath : currentObject.exportSVG().getAttribute('d'), |
| 335 | + box: { |
| 336 | + x: currentObject.bounds.x, |
| 337 | + y: currentObject.bounds.y, |
| 338 | + width: 0, |
| 339 | + height: 0 |
| 340 | + }, |
| 341 | + }; |
| 342 | + break; |
217 | 343 | }
|
218 | 344 |
|
219 | 345 | if (ant.type) {
|
|
309 | 435 | arrow.strokeWidth = 2;
|
310 | 436 | arrow.name = item.annotation.guid;
|
311 | 437 | break;
|
| 438 | + case 11: |
| 439 | + var line = new ps.Path(); |
| 440 | + line.pathData = item.annotation.svgPath; |
| 441 | + line.strokeColor = 'black'; |
| 442 | + line.strokeWidth = 2; |
| 443 | + line.name = item.annotation.guid; |
| 444 | + break; |
| 445 | + case 3: |
| 446 | + var line = new ps.Path(); |
| 447 | + line.pathData = item.annotation.svgPath; |
| 448 | + line.strokeColor = 'black'; |
| 449 | + line.strokeWidth = 2; |
| 450 | + line.name = item.annotation.guid; |
| 451 | + break; |
| 452 | + case 12: |
| 453 | + var distance = new ps.Group([ |
| 454 | + new ps.Path(item.annotation.svgPath.split(" ")[0]), |
| 455 | + new ps.Path(item.annotation.svgPath.split(" ")[1]), |
| 456 | + new ps.Path(item.annotation.svgPath.split(" ")[2]), |
| 457 | + new ps.PointText(new ps.Point(item.annotation.box.x, item.annotation.box.y)) |
| 458 | + ]); |
| 459 | + distance.strokeColor = 'black'; |
| 460 | + distance.strokeWidth = 2; |
| 461 | + distance.children[3].content = Math.floor(distance.children[0].length) + " px"; |
| 462 | + distance.children[3].strokeWidth = 0.5; |
| 463 | + distance.name = item.annotation.guid; |
| 464 | + break; |
312 | 465 | }
|
313 | 466 | })
|
314 | 467 | }
|
| 468 | + function getStartRow(docInfo,start,attrs){ |
| 469 | + var startRow = []; |
| 470 | + for(var i = 0; i<30; i++){ |
| 471 | + startRow = docInfo.pages[attrs.number-1].rows.filter(x => Math.floor(x.lineTop) == (Math.floor(start.y)-i )); |
| 472 | + if(startRow.length>0) |
| 473 | + return startRow; |
| 474 | + } |
| 475 | + if(startRow.length == 0) |
| 476 | + for(var i = 0; i<30; i++){ |
| 477 | + startRow = docInfo.pages[attrs.number-1].rows.filter(x => Math.floor(x.lineTop) == (Math.floor(start.y)+i )); |
| 478 | + if(startRow.length>0) |
| 479 | + return startRow; |
| 480 | + } |
| 481 | + |
| 482 | + } |
315 | 483 |
|
316 | 484 | function setupAnnotationDeletion($rootScope, AnnotationFactory, scope, element, attrs) {
|
317 | 485 | var ps = paper.PaperScope.get(scope.paperScopeId);
|
|
0 commit comments