当前位置:网站首页>vtk. JS left mouse button sliding to change window level and window width

vtk. JS left mouse button sliding to change window level and window width

2022-06-23 07:53:00 Xiaojiangjiang 12

var that = this;
function DragObj(selector) {
  // Save node 
  this.ele = $(selector).get(0);

  // call startDrag
  this.startDrag();
}

/* encapsulation startDrag Method */
DragObj.prototype.startDrag = function () {
  var self = this;
  // Add... To the node of the current object mousedown event , Execute sliding event after mouse down event 
  $(self.ele).on({
    mousedown: function () {
      self.drag();
    }
  })

}
/* Encapsulate sliding events */
DragObj.prototype.drag = function () {
  var self = this;
  /* initialization self.newDisance*/
  self.newDisance = {
    X:that.vtkObj['imageActorI'].getProperty().getColorLevel(),
    Y:that.vtkObj['imageActorI'].getProperty().getColorWindow()
  }

  // to X Add move and end events to window objects 
  $('#contentX').on({
    /* According to the moving distance, judge whether to increase or decrease the grayscale , To the left and right wl, Up and down for ww*/
    mousemove: function (oEvent) {
      if(self.disance && self.disance.X){
        self.newDisance.X = that.vtkObj['imageActorI'].getProperty().getColorLevel() + (oEvent.pageX - self.disance.X);
        self.newDisance.Y = that.vtkObj['imageActorI'].getProperty().getColorWindow() + (oEvent.pageY - self.disance.Y);
      }
      self.disance = {
        X: oEvent.pageX,
        Y: oEvent.pageY
      };
// Sagittal plane , Coronal plane , The axial plane changes the window level and window width at the same time 
      ['X','Y','Z'].forEach((type) => {
        that.vtkObj['imageActor' + that.typeMap[type]].getProperty().setColorLevel(self.newDisance.X);
        that.vtkObj['imageActor' + that.typeMap[type]].getProperty().setColorWindow(self.newDisance.Y);
      })
      $(".colorLevel").val(self.newDisance.X);
      $(".colorWindow").val(self.newDisance.Y);
    },
    mouseup: function () {
      /* Reset the distance after releasing the mouse , Let it recalculate */
      self.disance = {};
      self.newDisance = {
        X:that.vtkObj['imageActorI'].getProperty().getColorLevel(),
        Y:that.vtkObj['imageActorI'].getProperty().getColorWindow()
      };
      $("#contentX").off('mousemove mouseup');
    }
  })
}
new DragObj('#contentX');

 

原网站

版权声明
本文为[Xiaojiangjiang 12]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230726577767.html