use of jmri.jmrix.rps.PositionFile in project JMRI by JMRI.
the class AlignmentPanel method store.
void store() {
try {
// request the filename from an open dialog
fci.rescanCurrentDirectory();
int retVal = fci.showSaveDialog(this);
// handle selection or cancel
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fci.getSelectedFile();
if (log.isInfoEnabled()) {
log.info("located file " + file + " for load");
}
// handle the file
PositionFile pf = new PositionFile();
pf.prepare();
pf.setReceiver(1, getPoint(x1l, y1l, z1l), true);
pf.setReceiver(2, getPoint(x2l, y1l, z2l), true);
pf.setReceiver(3, getPoint(x3l, y1l, z3l), true);
pf.setReceiver(4, getPoint(x4l, y1l, z4l), true);
// save the measurements too
for (int i = 0; i < NREADINGS; i++) {
Point3d p = lines[i].getPoint();
p.z = -p.z;
pf.setCalibrationPoint(p, lines[i].getReading());
}
pf.store(file);
} else {
log.info("load cancelled in open dialog");
}
} catch (Exception e) {
log.error("exception during load: " + e);
}
}
use of jmri.jmrix.rps.PositionFile in project JMRI by JMRI.
the class AlignmentPanel method load.
void load() {
try {
// request the filename from an open dialog
fci.rescanCurrentDirectory();
int retVal = fci.showOpenDialog(this);
// handle selection or cancel
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fci.getSelectedFile();
if (log.isInfoEnabled()) {
log.info("located file " + file + " for load");
}
// handle the file
PositionFile pf = new PositionFile();
pf.loadFile(file);
Point3d p;
Reading r;
for (int i = 0; i < NREADINGS; i++) {
p = pf.getCalibrationPosition(i);
if (p != null) {
lines[i].setPoint(p);
} else {
lines[i].setPoint(new Point3d(0.f, 0.f, 0.f));
}
}
for (int i = 0; i < NREADINGS; i++) {
r = pf.getCalibrationReading(i);
lines[i].reset();
if (r != null) {
lines[i].setReading(r);
}
}
} else {
log.info("load cancelled in open dialog");
}
} catch (Exception e) {
log.error("exception during load: " + e);
}
}
Aggregations