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;
}
}
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;
}
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);
}
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;
}
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);
}
Aggregations