onMouseDown()

in src/engine/tools23d/mprrenderer.js [490:527]


  onMouseDown(xScr, yScr) {
    if (this.m_objGraphics2d.m_volumeData === null || this.m_objGraphics2d.m_volumeHeader === null) {
      return;
    }
    const TWICE = 2.0;
    const xt = xScr * TWICE - 1.0;
    const yt = (1.0 - yScr) * TWICE - 1.0;

    for (let i = 0; i < NUM_PROJECTIONS; ++i) {
      if (this.m_projectionRect[i].xMin <= xt && xt <= this.m_projectionRect[i].xMax) {
        // is in i-th projection
        if (this.m_projectionRect[i].yMin <= yt && yt <= this.m_projectionRect[i].yMax) {
          // is in i-th projection rect
          if (this.m_controlPoint[i].y - this.m_yControlShift <= yt && yt <= this.m_controlPoint[i].y + this.m_yControlShift) {
            // is near control point for vertical lines
            if (i === PROJECTION_Z) {
              // for z projection (has horizontal line)
              if (this.m_controlPoint[i].x - this.m_xControlShift <= xt && xt <= this.m_controlPoint[i].x + this.m_xControlShift) {
                // is near control point for horizontal line
                this.m_runningState = true;
                this.m_activePlane = i;
              } else {
                return;
              }
            } else {
              // for x and y projections
              this.m_runningState = true;
              this.m_activePlane = i;
            }
          } else {
            return;
          }
        } else {
          return;
        }
      }
    }
  }