Search in sources :

Example 1 with CrossSection

use of org.hwyl.sexytopo.model.sketch.CrossSection in project sexytopo by richsmith.

the class GraphView method drawCrossSectionIndicator.

private void drawCrossSectionIndicator(Canvas canvas, CrossSectionDetail crossSectionDetail, float x, float y, int alpha) {
    crossSectionIndicatorPaint.setAlpha(alpha / 2);
    CrossSection crossSection = crossSectionDetail.getCrossSection();
    float angle = (float) Math.toRadians(crossSection.getAngle());
    float indicatorWidth = (float) (1 * surveyToViewScale);
    float startX = x - ((indicatorWidth / 2) * (float) Math.cos(angle));
    float startY = y - ((indicatorWidth / 2) * (float) Math.sin(angle));
    float endX = x + ((indicatorWidth / 2) * (float) Math.cos(angle));
    float endY = y + ((indicatorWidth / 2) * (float) Math.sin(angle));
    canvas.drawLine(startX, startY, endX, endY, crossSectionIndicatorPaint);
    float lineLength = Space2DUtils.getDistance(new Coord2D(startX, startY), new Coord2D(endX, endY));
    float arrowLength = lineLength * 0.4f;
    float arrowOuterCornerX = startX;
    float arrowOuterCornerY = startY;
    float arrowInnerCornerX = startX + ((lineLength * 0.05f) * (float) Math.cos(angle));
    float arrowInnerCornerY = startY + ((lineLength * 0.05f) * (float) Math.sin(angle));
    float arrowAngle = (float) Math.toRadians(Space2DUtils.adjustAngle(crossSection.getAngle(), -90));
    float arrowTipX = startX + (arrowLength * (float) Math.cos(arrowAngle));
    float arrowTipY = startY + (arrowLength * (float) Math.sin(arrowAngle));
    Path path = new Path();
    path.moveTo(arrowInnerCornerX, arrowInnerCornerY);
    path.lineTo(arrowOuterCornerX, arrowOuterCornerY);
    path.lineTo(arrowTipX, arrowTipY);
    path.lineTo(arrowInnerCornerX, arrowInnerCornerY);
    canvas.drawPath(path, crossSectionIndicatorPaint);
}
Also used : Path(android.graphics.Path) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

Example 2 with CrossSection

use of org.hwyl.sexytopo.model.sketch.CrossSection in project sexytopo by richsmith.

the class GraphView method drawCrossSections.

private void drawCrossSections(Canvas canvas, List<CrossSectionDetail> crossSectionDetails, int alpha) {
    boolean showStationLabels = getDisplayPreference(GraphActivity.DisplayPreference.SHOW_STATION_LABELS);
    crossSectionConnectorPaint.setAlpha(alpha);
    List<CrossSectionDetail> badXSections = new ArrayList<>();
    for (CrossSectionDetail sectionDetail : crossSectionDetails) {
        if (!couldBeOnScreen(sectionDetail)) {
            continue;
        }
        CrossSection crossSection = sectionDetail.getCrossSection();
        if (crossSection == null) {
            badXSections.add(sectionDetail);
            continue;
        }
        Station station = crossSection.getStation();
        if (station == null) {
            badXSections.add(sectionDetail);
            continue;
        }
        Coord2D surveyStationLocation = this.projection.getStationMap().get(station);
        if (surveyStationLocation == null) {
            badXSections.add(sectionDetail);
            continue;
        }
        Coord2D centreOnSurvey = sectionDetail.getPosition();
        Coord2D centreOnView = surveyCoordsToViewCoords(centreOnSurvey);
        drawStationCross(canvas, stationPaint, centreOnView.x, centreOnView.y, STATION_DIAMETER, alpha);
        String description = sectionDetail.getCrossSection().getStation().getName() + " X";
        if (showStationLabels) {
            stationPaint.setAlpha(alpha);
            canvas.drawText(description, centreOnView.x, centreOnView.y, stationPaint);
        }
        Space<Coord2D> projection = sectionDetail.getProjection();
        drawLegs(canvas, projection, alpha);
        Coord2D viewStationLocation = surveyCoordsToViewCoords(surveyStationLocation);
        drawDashedLine(canvas, viewStationLocation, centreOnView, DASHED_LINE_INTERVAL, crossSectionConnectorPaint);
    }
    for (CrossSectionDetail crossSectionDetail : badXSections) {
        Station station = crossSectionDetail.getCrossSection().getStation();
        String name = station == null ? "Unknown" : station.getName();
        Log.e("Missing station details for cross section on station " + name + "; removing");
        crossSectionDetails.remove(crossSectionDetail);
    }
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) ArrayList(java.util.ArrayList) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

Example 3 with CrossSection

use of org.hwyl.sexytopo.model.sketch.CrossSection in project sexytopo by richsmith.

the class GraphView method handlePositionCrossSection.

private boolean handlePositionCrossSection(MotionEvent event) {
    Coord2D touchPointOnView = new Coord2D(event.getX(), event.getY());
    Coord2D touchPointOnSurvey = viewCoordsToSurveyCoords(touchPointOnView);
    final Station station = survey.getActiveStation();
    CrossSection crossSection = CrossSectioner.section(survey, station);
    sketch.addCrossSection(crossSection, touchPointOnSurvey);
    setSketchTool(previousSketchTool);
    invalidate();
    return true;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

Example 4 with CrossSection

use of org.hwyl.sexytopo.model.sketch.CrossSection in project sexytopo by richsmith.

the class SketchJsonTranslater method toCrossSectionDetail.

public static CrossSectionDetail toCrossSectionDetail(Survey survey, JSONObject json) throws JSONException {
    Coord2D position = toCoord2D(json.getJSONObject(POSITION_TAG));
    float angle = (float) json.getDouble(ANGLE_TAG);
    String stationdId = json.getString(STATION_ID_TAG);
    Station station = survey.getStationByName(stationdId);
    CrossSectionDetail crossSectionDetail = new CrossSectionDetail(new CrossSection(station, angle), position);
    return crossSectionDetail;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

Example 5 with CrossSection

use of org.hwyl.sexytopo.model.sketch.CrossSection in project sexytopo by richsmith.

the class CrossSectioner method section.

public static CrossSection section(Survey survey, final Station station) {
    float angle = getAngleOfSection(survey, station);
    CrossSection crossSection = new CrossSection(station, angle);
    return crossSection;
}
Also used : CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

Aggregations

CrossSection (org.hwyl.sexytopo.model.sketch.CrossSection)5 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)4 Station (org.hwyl.sexytopo.model.survey.Station)3 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)2 Path (android.graphics.Path)1 ArrayList (java.util.ArrayList)1