protected static boolean isServiceVisible(DrawContext dc, PlaceNameService placeNameService) {
    //noinspection SimplifiableIfStatement
    if (!placeNameService.isEnabled()) return false;

    return (dc.getVisibleSector() != null)
        && placeNameService.getMaskingSector().intersects(dc.getVisibleSector());
    //
    //        return
    // placeNameService.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates());
  }
  protected static boolean isTileVisible(
      DrawContext dc, Tile tile, double minDistanceSquared, double maxDistanceSquared) {
    if (!tile.getSector().intersects(dc.getVisibleSector())) return false;

    View view = dc.getView();
    Position eyePos = view.getEyePosition();
    if (eyePos == null) return false;

    Angle lat =
        clampAngle(
            eyePos.getLatitude(),
            tile.getSector().getMinLatitude(),
            tile.getSector().getMaxLatitude());
    Angle lon =
        clampAngle(
            eyePos.getLongitude(),
            tile.getSector().getMinLongitude(),
            tile.getSector().getMaxLongitude());
    Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
    double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
    //noinspection RedundantIfStatement
    if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

    return true;
  }
  /**
   * Select the visible grid elements
   *
   * @param dc the current <code>DrawContext</code>.
   */
  protected void selectRenderables(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    Sector vs = dc.getVisibleSector();
    OrbitView view = (OrbitView) dc.getView();
    // Compute labels offset from view center
    Position centerPos = view.getCenterPosition();
    Double pixelSizeDegrees =
        Angle.fromRadians(
                view.computePixelSizeAtDistance(view.getZoom())
                    / dc.getGlobe().getEquatorialRadius())
            .degrees;
    Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4;
    Position labelPos =
        Position.fromDegrees(
            centerPos.getLatitude().degrees - labelOffsetDegrees,
            centerPos.getLongitude().degrees - labelOffsetDegrees,
            0);
    Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees;
    labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78);
    labelPos =
        new Position(
            Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0);

    if (vs != null) {
      for (GridElement ge : this.gridElements) {
        if (ge.isInView(dc)) {
          if (ge.renderable instanceof GeographicText) {
            GeographicText gt = (GeographicText) ge.renderable;
            if (labelPos.getLatitude().degrees < 72
                || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) {
              // Adjust label position according to eye position
              Position pos = gt.getPosition();
              if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        pos.getLatitude().degrees,
                        labelPos.getLongitude().degrees,
                        pos.getElevation());
              else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        labelPos.getLatitude().degrees,
                        pos.getLongitude().degrees,
                        pos.getElevation());

              gt.setPosition(pos);
            }
          }

          this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM);
        }
      }
      // System.out.println("Total elements: " + count + " visible sector: " + vs);
    }
  }
示例#4
0
  protected Vec4 draw(DrawContext dc, Iterator<TrackPoint> trackPositions) {
    if (dc.getVisibleSector() == null) return null;

    SectorGeometryList geos = dc.getSurfaceGeometry();
    if (geos == null) return null;

    if (!this.pipeShape.isInitialized) {
      this.pipeShape.initialize(dc);
    }

    if (!this.junctionShape.isInitialized) this.junctionShape.initialize(dc);

    int index = 0;
    List<Vec4> points = new ArrayList<Vec4>();
    while (trackPositions.hasNext()) {
      TrackPoint tp = trackPositions.next();
      if (index >= this.lowerLimit && index <= this.upperLimit) {
        Vec4 point = this.computeSurfacePoint(dc, tp);
        if (point != null) {
          points.add(point);
        }
      }
      if (++index >= this.upperLimit) break;
    }

    if (points.size() < 1) return null;

    this.begin(dc);
    {
      this.pipeMaterial.apply(dc.getGL(), GL.GL_FRONT);
      Vec4 p1 = points.get(0);
      for (int i = 1; i < points.size(); i++) {
        Vec4 p2 = points.get(i);
        this.pipeShape.render(dc, p1, p2, this.pipeRadius);
        p1 = p2;
      }

      this.junctionMaterial.apply(dc.getGL(), GL.GL_FRONT);
      for (Vec4 point : points) {
        this.junctionShape.render(dc, point, this.junctionShapeRadius);
      }
    }
    this.end(dc);

    return null; // TODO: return the last-drawn location
  }
    protected boolean isNavSectorVisible(
        DrawContext dc, double minDistanceSquared, double maxDistanceSquared) {
      if (!navSector.intersects(dc.getVisibleSector())) return false;

      View view = dc.getView();
      Position eyePos = view.getEyePosition();
      if (eyePos == null) return false;

      // check for eyePos over globe
      if (Double.isNaN(eyePos.getLatitude().getDegrees())
          || Double.isNaN(eyePos.getLongitude().getDegrees())) return false;

      Angle lat =
          clampAngle(eyePos.getLatitude(), navSector.getMinLatitude(), navSector.getMaxLatitude());
      Angle lon =
          clampAngle(
              eyePos.getLongitude(), navSector.getMinLongitude(), navSector.getMaxLongitude());
      Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
      double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
      //noinspection RedundantIfStatement
      if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

      return true;
    }
示例#6
0
  protected void drawMany(DrawContext dc, Iterable<? extends WWIcon> icons, Layer layer) {
    if (dc == null) {
      String msg = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    if (dc.getVisibleSector() == null) return;

    SectorGeometryList geos = dc.getSurfaceGeometry();
    //noinspection RedundantIfStatement
    if (geos == null) return;

    if (icons == null) {
      String msg = Logging.getMessage("nullValue.IconIterator");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    Iterator<? extends WWIcon> iterator = icons.iterator();

    if (!iterator.hasNext()) return;

    double horizon = dc.getView().getHorizonDistance();

    while (iterator.hasNext()) {
      WWIcon icon = iterator.next();
      if (!isIconValid(icon, true)) {
        // Record feedback data for this WWIcon if feedback is enabled.
        if (icon != null) this.recordFeedback(dc, icon, null, null);

        continue;
      }

      if (!icon.isVisible()) {
        // Record feedback data for this WWIcon if feedback is enabled.
        this.recordFeedback(dc, icon, null, null);

        continue;
      }

      // Determine Cartesian position from the surface geometry if the icon is near the surface,
      // otherwise draw it from the globe.
      Position pos = icon.getPosition();
      Vec4 iconPoint = null;
      if (pos.getElevation() < dc.getGlobe().getMaxElevation()
          && !this.isAlwaysUseAbsoluteElevation()) {
        iconPoint = dc.getSurfaceGeometry().getSurfacePoint(icon.getPosition());
      }

      if (iconPoint == null) {
        Angle lat = pos.getLatitude();
        Angle lon = pos.getLongitude();
        double elevation = pos.getElevation();
        if (!this.isAlwaysUseAbsoluteElevation()) elevation += dc.getGlobe().getElevation(lat, lon);
        iconPoint = dc.getGlobe().computePointFromPosition(lat, lon, elevation);
      }

      double eyeDistance =
          icon.isAlwaysOnTop() ? 0 : dc.getView().getEyePoint().distanceTo3(iconPoint);

      // X-PATCH Marjan
      // extracted skip conditions into an overrideable method
      if (!meetsRenderCriteria(dc, icon, iconPoint, eyeDistance)) {
        this.recordFeedback(dc, icon, iconPoint, null);
        continue;
      }
      // X-END

      // The icons aren't drawn here, but added to the ordered queue to be drawn back-to-front.
      dc.addOrderedRenderable(new OrderedIcon(icon, iconPoint, layer, eyeDistance, horizon));

      if (icon.isShowToolTip()) this.addToolTip(dc, icon, iconPoint);
    }
  }