Search in sources :

Example 11 with Leg

use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.

the class TableActivity method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem menuItem) {
    final TableCol col = fieldToTableCol.get(cellBeingClicked);
    final GraphToListTranslator.SurveyListEntry surveyEntry = fieldToSurveyEntry.get(cellBeingClicked);
    Context context = this;
    int itemId = menuItem.getItemId();
    if (itemId == R.id.setActiveStation) {
        Station newActive = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
        getSurvey().setActiveStation(newActive);
        syncTableWithSurvey();
        return true;
    } else if (itemId == R.id.graph_station_jump_to_plan) {
        Station planStation = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
        jumpToStation(planStation, PlanActivity.class);
        return true;
    } else if (itemId == R.id.graph_station_jump_to_ee) {
        Station eeStation = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
        jumpToStation(eeStation, ExtendedElevationActivity.class);
        return true;
    } else if (itemId == R.id.renameStation) {
        Station toRename = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
        if (toRename == Survey.NULL_STATION) {
            showSimpleToast("Can't rename a splay end");
        } else {
            ManualEntry.renameStation(this, getSurvey(), toRename);
        }
        return true;
    } else if (itemId == R.id.editLeg) {
        Leg toEdit = surveyEntry.getLeg();
        ManualEntry.editLeg(this, getSurvey(), toEdit);
        return true;
    } else if (itemId == R.id.moveRow) {
        final Leg toMove = surveyEntry.getLeg();
        requestMoveLeg(toMove);
        return true;
    } else if (itemId == R.id.upgradeRow) {
        Leg toUpgrade = surveyEntry.getLeg();
        SurveyUpdater.upgradeSplayToConnectedLeg(getSurvey(), toUpgrade, getInputMode());
        syncTableWithSurvey();
        return true;
    } else if (itemId == R.id.deleteStation) {
        Station toDelete = (Station) (GraphToListTranslator.createMap(surveyEntry).get(col));
        askAboutDeleting(context, toDelete, null);
        return true;
    } else if (itemId == R.id.deleteLeg) {
        askAboutDeleting(context, surveyEntry.getFrom(), surveyEntry.getLeg());
        return true;
    } else if (itemId == R.id.deleteSplay) {
        askAboutDeleting(context, surveyEntry.getFrom(), surveyEntry.getLeg());
        return true;
    } else {
        return false;
    }
}
Also used : Context(android.content.Context) Station(org.hwyl.sexytopo.model.survey.Station) GraphToListTranslator(org.hwyl.sexytopo.control.util.GraphToListTranslator) TableCol(org.hwyl.sexytopo.model.table.TableCol) SuppressLint(android.annotation.SuppressLint) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 12 with Leg

use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.

the class TableActivity method onLongClick.

@Override
public boolean onLongClick(View view) {
    TextView textView = (TextView) view;
    cellBeingClicked = textView;
    TableCol col = fieldToTableCol.get(textView);
    if (col == TableCol.FROM || col == TableCol.TO) {
        showPopup(view, R.menu.table_station_selected, this);
    } else {
        final GraphToListTranslator.SurveyListEntry surveyEntry = fieldToSurveyEntry.get(cellBeingClicked);
        Leg leg = surveyEntry.getLeg();
        if (leg.hasDestination()) {
            showPopup(view, R.menu.table_full_leg_selected, this);
        } else {
            showPopup(view, R.menu.table_splay_selected, this);
        }
    }
    return true;
}
Also used : GraphToListTranslator(org.hwyl.sexytopo.control.util.GraphToListTranslator) TableCol(org.hwyl.sexytopo.model.table.TableCol) TextView(android.widget.TextView) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 13 with Leg

use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.

the class OldStyleLoader method addLegToSurvey.

private static void addLegToSurvey(Survey survey, Map<String, Station> nameToStation, String[] fields, String comment) throws Exception {
    Station from = retrieveOrCreateStation(nameToStation, fields[0], comment);
    Station to = retrieveOrCreateStation(nameToStation, fields[1], comment);
    float distance = Float.parseFloat(fields[2]);
    float azimuth = Float.parseFloat(fields[3]);
    float inclination = Float.parseFloat(fields[4]);
    List<Station> stationsSoFar = survey.getAllStations();
    if (!stationsSoFar.contains(from) && !stationsSoFar.contains(to)) {
        throw new Exception("Stations are out of order in file");
    } else if (stationsSoFar.contains(from) && stationsSoFar.contains(to)) {
        throw new Exception("Duplicate leg encountered");
    } else if (stationsSoFar.contains(from)) {
        // forward leg
        Leg leg = (to == Survey.NULL_STATION) ? new Leg(distance, azimuth, inclination) : new Leg(distance, azimuth, inclination, to, new Leg[] {});
        from.addOnwardLeg(leg);
    } else if (stationsSoFar.contains(to)) {
        // backwards leg
        Leg leg = (from == Survey.NULL_STATION) ? new Leg(distance, azimuth, inclination) : new Leg(distance, azimuth, inclination, from, new Leg[] {});
        to.addOnwardLeg(leg.reverse());
    }
    // Bit of a hack; hopefully the last station processed will be the active one
    // (should probably record the active station in the file somewhere)
    survey.setActiveStation(from);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 14 with Leg

use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.

the class ConnectedSurveysTest method getBasicSurvey.

private static Survey getBasicSurvey(String name) {
    Survey basicSurvey = new Survey(name);
    Leg l0 = new Leg(1.0f, 0.0f, 0.0f);
    SurveyUpdater.update(basicSurvey, l0);
    SurveyUpdater.upgradeSplayToConnectedLeg(basicSurvey, l0, InputMode.FORWARD);
    return basicSurvey;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 15 with Leg

use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.

the class SurvexImporterTest method testBasicImportRecordsPromotions.

@Test
public void testBasicImportRecordsPromotions() throws Exception {
    final String testContent = "1\t2\t5.0\t0.0\t0.0\t; {from: 5.0 0.0 0.0, 5.0 0.0 0.0, 5.0 0.0 0.0}";
    Survey survey = new Survey("Test");
    SurvexImporter.parse(testContent, survey);
    Leg leg = survey.getOrigin().getConnectedOnwardLegs().get(0);
    Assert.assertEquals(3, leg.getPromotedFrom().length);
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Leg(org.hwyl.sexytopo.model.survey.Leg) Test(org.junit.Test)

Aggregations

Leg (org.hwyl.sexytopo.model.survey.Leg)94 Station (org.hwyl.sexytopo.model.survey.Station)30 Test (org.junit.Test)30 Survey (org.hwyl.sexytopo.model.survey.Survey)23 Coord3D (org.hwyl.sexytopo.model.graph.Coord3D)17 Line (org.hwyl.sexytopo.model.graph.Line)8 ArrayList (java.util.ArrayList)7 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 JSONArray (org.json.JSONArray)6 JSONObject (org.json.JSONObject)6 Space (org.hwyl.sexytopo.model.graph.Space)4 TextView (android.widget.TextView)3 GraphToListTranslator (org.hwyl.sexytopo.control.util.GraphToListTranslator)3 TableCol (org.hwyl.sexytopo.model.table.TableCol)3 JSONException (org.json.JSONException)3 AlertDialog (android.app.AlertDialog)2 ParseException (java.text.ParseException)2 HashMap (java.util.HashMap)2 LRUD (org.hwyl.sexytopo.model.table.LRUD)2 SuppressLint (android.annotation.SuppressLint)1