dwv 0.31.0-beta.21 → 0.31.0-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dwv.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dwv 0.31.0-beta.21 2023-01-09 17:12:44 */
1
+ /*! dwv 0.31.0-beta.22 2023-01-18 18:57:53 */
2
2
  // Inspired from umdjs
3
3
  // See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
4
4
  (function (root, factory) {
@@ -311,6 +311,17 @@ dwv.App = function () {
311
311
  return stage.getViewLayersByDataIndex(index);
312
312
  };
313
313
 
314
+ /**
315
+ * Get the draw layers associated to a data index.
316
+ * The layer are available after the first loaded item.
317
+ *
318
+ * @param {number} index The data index.
319
+ * @returns {Array} The layers.
320
+ */
321
+ this.getDrawLayersByDataIndex = function (index) {
322
+ return stage.getDrawLayersByDataIndex(index);
323
+ };
324
+
314
325
  /**
315
326
  * Get a layer group by div id.
316
327
  * The layer is available after the first loaded item.
@@ -850,6 +861,16 @@ dwv.App = function () {
850
861
  stage.getActiveLayerGroup().getActiveDrawLayer().getDrawController();
851
862
  drawController.updateDraw(drawDetails);
852
863
  };
864
+ /**
865
+ * Delete a draw.
866
+ *
867
+ * @param {object} drawDetails Details of the drawing to check.
868
+ */
869
+ this.deleteDraw = function (drawDetails) {
870
+ var drawController =
871
+ stage.getActiveLayerGroup().getActiveDrawLayer().getDrawController();
872
+ drawController.deleteDraw(drawDetails, fireEvent, this.addToUndoStack);
873
+ };
853
874
  /**
854
875
  * Delete all Draws from all layers.
855
876
  */
@@ -1068,6 +1089,23 @@ dwv.App = function () {
1068
1089
  undoStack.redo();
1069
1090
  };
1070
1091
 
1092
+ /**
1093
+ * Get the undo stack size.
1094
+ *
1095
+ * @returns {number} The size of the stack.
1096
+ */
1097
+ this.getStackSize = function () {
1098
+ return undoStack.getStackSize();
1099
+ };
1100
+
1101
+ /**
1102
+ * Get the current undo stack index.
1103
+ *
1104
+ * @returns {number} The stack index.
1105
+ */
1106
+ this.getCurrentStackIndex = function () {
1107
+ return undoStack.getCurrentStackIndex();
1108
+ };
1071
1109
 
1072
1110
  // Private Methods -----------------------------------------------------------
1073
1111
 
@@ -2115,6 +2153,30 @@ dwv.ctrl.DrawController = function (konvaLayer) {
2115
2153
  exeCallback(delcmd);
2116
2154
  };
2117
2155
 
2156
+ /**
2157
+ * Delete a Draw from the stage.
2158
+ *
2159
+ * @param {object} drawDetails Details of the group to update.
2160
+ * @param {object} cmdCallback The DeleteCommand callback.
2161
+ * @param {object} exeCallback The callback to call once the
2162
+ * DeleteCommand has been executed.
2163
+ * @returns {boolean} False if the group cannot be found.
2164
+ */
2165
+ this.deleteDraw = function (drawDetails, cmdCallback, exeCallback) {
2166
+ // get the group
2167
+ var group = konvaLayer.findOne('#' + drawDetails.id);
2168
+ if (typeof group === 'undefined') {
2169
+ dwv.logger.warn(
2170
+ '[deleteDraw] Cannot find node with id: ' + drawDetails.id
2171
+ );
2172
+ return false;
2173
+ }
2174
+ // delete
2175
+ this.deleteDrawGroup(group, cmdCallback, exeCallback);
2176
+
2177
+ return true;
2178
+ };
2179
+
2118
2180
  /**
2119
2181
  * Delete all Draws from the stage.
2120
2182
  *
@@ -4694,7 +4756,7 @@ dwv.dicom = dwv.dicom || {};
4694
4756
  * @returns {string} The version of the library.
4695
4757
  */
4696
4758
  dwv.getVersion = function () {
4697
- return '0.31.0-beta.21';
4759
+ return '0.31.0-beta.22';
4698
4760
  };
4699
4761
 
4700
4762
  /**
@@ -14547,6 +14609,20 @@ dwv.gui.Stage = function () {
14547
14609
  return res;
14548
14610
  };
14549
14611
 
14612
+ /**
14613
+ * Get the draw layers associated to a data index.
14614
+ *
14615
+ * @param {number} index The data index.
14616
+ * @returns {Array} The layers.
14617
+ */
14618
+ this.getDrawLayersByDataIndex = function (index) {
14619
+ var res = [];
14620
+ for (var i = 0; i < layerGroups.length; ++i) {
14621
+ res = res.concat(layerGroups[i].getDrawLayersByDataIndex(index));
14622
+ }
14623
+ return res;
14624
+ };
14625
+
14550
14626
  /**
14551
14627
  * Add a layer group to the list.
14552
14628
  *
@@ -35644,15 +35720,6 @@ dwv.tool.UndoStack = function () {
35644
35720
  */
35645
35721
  var stack = [];
35646
35722
 
35647
- /**
35648
- * Get the stack.
35649
- *
35650
- * @returns {Array} The list of stored commands.
35651
- */
35652
- this.getStack = function () {
35653
- return stack;
35654
- };
35655
-
35656
35723
  /**
35657
35724
  * Current command index.
35658
35725
  *
@@ -35669,6 +35736,24 @@ dwv.tool.UndoStack = function () {
35669
35736
  */
35670
35737
  var listenerHandler = new dwv.utils.ListenerHandler();
35671
35738
 
35739
+ /**
35740
+ * Get the stack size.
35741
+ *
35742
+ * @returns {number} The size of the stack.
35743
+ */
35744
+ this.getStackSize = function () {
35745
+ return stack.length;
35746
+ };
35747
+
35748
+ /**
35749
+ * Get the current stack index.
35750
+ *
35751
+ * @returns {number} The stack index.
35752
+ */
35753
+ this.getCurrentStackIndex = function () {
35754
+ return curCmdIndex;
35755
+ };
35756
+
35672
35757
  /**
35673
35758
  * Add a command to the stack.
35674
35759
  *