Esempio n. 1
0
  @Override
  protected void recordTrace() {
    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();
    switch (quadric.getType()) {
      case GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES:
      case GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES:
        initDrawPlanes(quadric);
        drawPlanes[0].recordTrace();
        drawPlanes[1].recordTrace();
        break;

      case GeoQuadricNDConstants.QUADRIC_PLANE:
        initDrawPlanes(quadric);
        drawPlanes[0].recordTrace();
        break;

      case GeoQuadricNDConstants.QUADRIC_LINE:
        initDrawLine(quadric);
        drawLine.recordTrace();
        break;

      default:
        super.recordTrace();
        break;
    }
  }
Esempio n. 2
0
  @Override
  public void setWaitForUpdateVisualStyle() {

    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();
    switch (quadric.getType()) {
      case GeoQuadricNDConstants.QUADRIC_SINGLE_POINT:
        super.setWaitForUpdate();
        break;
      case GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES:
      case GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES:
        initDrawPlanes(quadric);
        drawPlanes[0].setWaitForUpdateVisualStyle();
        drawPlanes[1].setWaitForUpdateVisualStyle();
        super.setWaitForUpdate();
        break;

      case GeoQuadricNDConstants.QUADRIC_PLANE:
        initDrawPlanes(quadric);
        drawPlanes[0].setWaitForUpdateVisualStyle();
        super.setWaitForUpdate();
        break;

      case GeoQuadricNDConstants.QUADRIC_LINE:
        initDrawLine(quadric);
        drawLine.setWaitForUpdateVisualStyle();
        super.setWaitForUpdate();
        break;
    }

    super.setWaitForUpdateVisualStyle();
  }
Esempio n. 3
0
  /**
   * common constructor
   *
   * @param view3D
   * @param axis3D
   */
  public DrawAxis3D(EuclidianView3D view3D, GeoAxis3D axis3D) {

    super(view3D, axis3D);

    super.setDrawMinMax(-2, 2);

    labels = new TreeMap<String, DrawLabel3D>();
  }
Esempio n. 4
0
  /** drawLabel is used here for ticks */
  public void drawLabel(Renderer renderer) {

    // if (!getView3D().isStarted()) return;

    if (!getGeoElement().isEuclidianVisible()) return;

    if (!getGeoElement().isLabelVisible()) return;

    // Application.debug("ici");

    for (DrawLabel3D label : labels.values()) label.draw(renderer);

    super.drawLabel(renderer);
  }
Esempio n. 5
0
  @Override
  protected void clearTraceForViewChanged() {

    if (drawPlanes != null) {
      drawPlanes[0].clearTraceForViewChanged();
      if (drawPlanes[1] != null) {
        drawPlanes[1].clearTraceForViewChanged();
      }
    }

    if (drawLine != null) {
      drawLine.clearTraceForViewChanged();
    }

    super.clearTraceForViewChanged();
  }
Esempio n. 6
0
  public double[] getDrawMinMax() {
    long deltaT = getDeltaT();

    if (deltaT > 0) {
      if (deltaT > TIME_DURATION) {
        super.setDrawMinMax(drawMinFinal, drawMaxFinal);
      } else {
        double[] minmaxIni = super.getDrawMinMax();
        double[] minmax = new double[2];
        double dt = (double) deltaT * TIME_FACTOR;
        minmax[0] = drawMinFinal * dt + minmaxIni[0] * (1 - dt);
        minmax[1] = drawMaxFinal * dt + minmaxIni[1] * (1 - dt);
        return minmax;
      }
    }

    return super.getDrawMinMax();
  }
Esempio n. 7
0
  protected boolean updateForItSelf() {

    setColors();

    setLabelWaitForUpdate();

    double[] minmax = getDrawMinMax();

    PlotterBrush brush = getView3D().getRenderer().getGeometryManager().getBrush();
    brush.setArrowType(PlotterBrush.ARROW_TYPE_SIMPLE);
    brush.setTicks(PlotterBrush.TICKS_ON);
    brush.setTicksDistance((float) ((GeoAxis3D) getGeoElement()).getNumbersDistance());
    brush.setTicksOffset((float) (-minmax[0] / (minmax[1] - minmax[0])));
    super.updateForItSelf(false);
    brush.setArrowType(PlotterBrush.ARROW_TYPE_NONE);
    brush.setTicks(PlotterBrush.TICKS_OFF);

    return timesUpForUpdate();
  }
Esempio n. 8
0
  @Override
  public void setWaitForUpdate() {

    super.setWaitForUpdate();
    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();
    int type = quadric.getType();

    switch (type) {
      case GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES:
      case GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES:
        initDrawPlanes(quadric);
        drawPlanes[0].setWaitForUpdate();
        drawPlanes[1].setWaitForUpdate();
        break;
      case GeoQuadricNDConstants.QUADRIC_PLANE:
        initDrawPlanes(quadric);
        drawPlanes[0].setWaitForUpdate();
        break;
      case GeoQuadricNDConstants.QUADRIC_LINE:
        initDrawLine(quadric);
        drawLine.setWaitForUpdate();
        break;
    }
  }
Esempio n. 9
0
 public void setWaitForReset() {
   super.setWaitForReset();
   for (DrawLabel3D label : labels.values()) label.setWaitForReset();
 }
Esempio n. 10
0
  @Override
  protected void updateForView() {

    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();
    int type = quadric.getType();

    switch (type) {
      case GeoQuadricNDConstants.QUADRIC_SPHERE:
        if (getView3D().viewChangedByZoom()) {
          Renderer renderer = getView3D().getRenderer();
          PlotterSurface surface = renderer.getGeometryManager().getSurface();

          double s = scale;
          scale = getView3D().getScale();
          // check if longitude length changes
          double radius = quadric.getHalfAxis(0);
          int l = surface.calcSphereLongitudesNeeded(radius, scale);
          // redraw if sphere was not visible, or if new longitude length,
          // or if negative zoom occured
          if (visible == Visible.TOTALLY_OUTSIDE || l != longitude || scale < s) {
            Coords center = quadric.getMidpoint3D();
            checkSphereVisible(center, radius);
            if (visible != Visible.TOTALLY_OUTSIDE) {
              // App.debug(l+","+longitude);
              longitude = l;
              surface.start(getReusableSurfaceIndex());
              drawSphere(surface, center, radius);
              setSurfaceIndex(surface.end());
              recordTrace();
            } else {
              setSurfaceIndex(-1);
            }
          }
        } else if (visible != Visible.TOTALLY_INSIDE && getView3D().viewChangedByTranslate()) {
          Renderer renderer = getView3D().getRenderer();
          PlotterSurface surface = renderer.getGeometryManager().getSurface();

          Coords center = quadric.getMidpoint3D();
          double radius = quadric.getHalfAxis(0);
          checkSphereVisible(center, radius);
          if (visible != Visible.TOTALLY_OUTSIDE) {
            surface.start(getReusableSurfaceIndex());
            drawSphere(surface, center, radius);
            setSurfaceIndex(surface.end());
            recordTrace();
          } else {
            setSurfaceIndex(-1);
          }
        }
        break;
      case GeoQuadricNDConstants.QUADRIC_ELLIPSOID:
      case GeoQuadricNDConstants.QUADRIC_CONE:
      case GeoQuadricNDConstants.QUADRIC_CYLINDER:
      case GeoQuadricNDConstants.QUADRIC_HYPERBOLOID_ONE_SHEET:
      case GeoQuadricNDConstants.QUADRIC_HYPERBOLOID_TWO_SHEETS:
      case GeoQuadricNDConstants.QUADRIC_PARABOLOID:
      case GeoQuadricNDConstants.QUADRIC_HYPERBOLIC_PARABOLOID:
      case GeoQuadricNDConstants.QUADRIC_PARABOLIC_CYLINDER:
      case GeoQuadricNDConstants.QUADRIC_HYPERBOLIC_CYLINDER:
      case GeoQuadricNDConstants.QUADRIC_SINGLE_POINT:
        if (getView3D().viewChangedByZoom() || getView3D().viewChangedByTranslate()) {
          updateForItSelf();
        }
        break;
      case GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES:
      case GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES:
        if (getView3D().viewChanged()) {
          initDrawPlanes(quadric);
          drawPlanes[0].updateForView();
          drawPlanes[1].updateForView();
          super.setWaitForUpdate();
        }
        break;

      case GeoQuadricNDConstants.QUADRIC_PLANE:
        if (getView3D().viewChanged()) {
          initDrawPlanes(quadric);
          drawPlanes[0].updateForView();
          super.setWaitForUpdate();
        }
        break;

      case GeoQuadricNDConstants.QUADRIC_LINE:
        if (getView3D().viewChanged()) {
          initDrawLine(quadric);
          drawLine.updateForView();
          super.setWaitForUpdate();
        }
        break;
    }
  }
Esempio n. 11
0
  @Override
  public boolean hit(Hitting hitting) {

    if (waitForReset) { // prevent NPE
      return false;
    }

    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();

    quadric.resetLastHitParameters();

    if (quadric.getType() == GeoQuadricNDConstants.QUADRIC_NOT_CLASSIFIED) {
      return false;
    }

    if (quadric.getType() == GeoQuadricNDConstants.QUADRIC_SINGLE_POINT) {
      if (DrawPoint3D.hit(
          hitting,
          quadric.getMidpoint3D(),
          this,
          quadric.getLineThickness(),
          project,
          parameters,
          false)) {
        setPickingType(PickingType.POINT_OR_CURVE);
        return true;
      }
      return false;
    }

    if (quadric.getType() == GeoQuadricNDConstants.QUADRIC_LINE) {
      if (drawLine.hit(hitting)) {
        setZPick(drawLine.getZPickNear(), drawLine.getZPickFar());
        setPickingType(PickingType.POINT_OR_CURVE);
        return true;
      }
      return false;
    }

    if (getGeoElement().getAlphaValue() < EuclidianController.MIN_VISIBLE_ALPHA_VALUE) {
      return false;
    }

    if (quadric.getType() == GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES
        || quadric.getType() == GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES) {
      double z1 = Double.NEGATIVE_INFINITY, z2 = Double.NEGATIVE_INFINITY;
      if (drawPlanes[0].hit(hitting, p1, project)) {
        z1 = drawPlanes[0].getZPickNear();
      }
      if (drawPlanes[1].hit(hitting, p2, project)) {
        z2 = drawPlanes[1].getZPickNear();
      }

      int planeIndex = 0;

      // keep highest value (closest to eye)
      if (z1 < z2) {
        z1 = z2;
        planeIndex = 1;
      }

      // if both negative infinity : not hitted
      if (Double.isInfinite(z1)) {
        quadric.resetLastHitParameters();
        return false;
      }

      // project with ortho matrix to get correct parameters
      hitting.origin.projectPlaneThruVIfPossible(
          quadric.getPlanes()[planeIndex].getCoordSys().getMatrixOrthonormal(),
          hitting.direction,
          p1,
          project);

      parameters1[0] = PathNormalizer.inverseInfFunction(project.getX()) + 2 * planeIndex;
      parameters1[1] = project.getY();
      quadric.setLastHitParameters(parameters1);

      // hitted
      setZPick(z1, z1);
      setPickingType(PickingType.SURFACE);
      return true;
    }

    if (quadric.getType() == GeoQuadricNDConstants.QUADRIC_PLANE) {
      if (drawPlanes[0].hit(hitting)) {
        setZPick(drawPlanes[0].getZPickNear(), drawPlanes[0].getZPickFar());
        setPickingType(PickingType.SURFACE);
        return true;
      }
      return false;
    }

    quadric.getProjections(
        null, hitting.origin, hitting.direction, p1, parameters1, p2, parameters2);

    double z1 = Double.NEGATIVE_INFINITY, z2 = Double.NEGATIVE_INFINITY;

    // check first point
    if (hitting.isInsideClipping(p1) && arePossibleParameters(parameters1[0], parameters1[1])) {
      // check distance to hitting line
      p1.projectLine(hitting.origin, hitting.direction, project, parameters);

      double d = p1.distance(project);
      if (d * getView3D().getScale() <= hitting.getThreshold()) {
        z1 = -parameters[0];
      }
    }

    // check second point (if defined)
    if (p2.isDefined()
        && hitting.isInsideClipping(p2)
        && arePossibleParameters(parameters2[0], parameters2[1])) {
      // check distance to hitting line
      p2.projectLine(hitting.origin, hitting.direction, project, parameters);

      double d = p2.distance(project);
      if (d * getView3D().getScale() <= hitting.getThreshold()) {
        z2 = -parameters[0];
      }
    }

    // keep highest value (closest to eye)
    if (z1 < z2) {
      z1 = z2;
      quadric.setLastHitParameters(parameters2);
    } else {
      quadric.setLastHitParameters(parameters1);
    }

    // if both negative infinity : not hitted
    if (Double.isInfinite(z1)) {
      quadric.resetLastHitParameters();
      return false;
    }

    // hitted
    setZPick(z1, z1);
    setPickingType(PickingType.SURFACE);
    return true;
  }