//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include "kln89_symbols.hxx"
#include <iostream>
-#include <ATC/ATCProjection.hxx>
+#include <ATCDCL/ATCProjection.hxx>
#include <Main/fg_props.hxx>
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
+#include "Airports/simple.hxx"
-SG_USING_STD(cout);
+using std::cout;
KLN89::KLN89(RenderArea2D* instrument)
: DCLGPS(instrument) {
void KLN89::CrsrPressed() {
_dispMsg = false;
- if(_activePage == _nrst_page) return; // CRSR cannot be switched off on nrst page.
+ // CRSR cannot be switched off on nrst page.
+ if(_activePage == _nrst_page) { return; }
+ // CRSR is always off when inner-knob is out on nav4 page.
+ if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull")) { return; }
if(_cleanUpPage >= 0) {
_pages[(unsigned int)_cleanUpPage]->CleanUp();
_cleanUpPage = -1;
} else {
_dir_page->SetId(_activeWaypoint.id);
}
- // } else if(_curPage == 6 && _nav_page->GetSubPage() == 3 && 0) {
+ } else if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull") && _activeFP->waypoints.size()) {
// NAV 4
- // TODO
- // The && 0 should be && outer knob is out.
+ _dir_page->SetId(((KLN89NavPage*)_activePage)->GetNav4WpId());
} else if(_curPage == 7 && _activePage->GetSubPage() == 0 && _mode == KLN89_MODE_CRSR) {
//cout << "Checking the fpl page!\n";
// FPL 0
} else {
_dir_page->SetId(_activeWaypoint.id);
}
- // This need to come after the bit before otherwise the FPL page clears it's current ID when it looses focus.
+ // This need to come after the bit before otherwise the FPL or NAV4 page clears their current ID when it looses focus.
_activePage->LooseFocus();
_activePage = _dir_page;
_mode = KLN89_MODE_CRSR;
double mapScaleMeters = _mapScale * (_mapScaleUnits == 0 ? SG_NM_TO_METER : 1000);
// TODO - use an aligned projection when either DTK or TK up!
- FGATCAlignedProjection mapProj(Point3D(_gpsLon * SG_RADIANS_TO_DEGREES, _gpsLat * SG_RADIANS_TO_DEGREES, 0.0), _mapHeading);
+ FGATCAlignedProjection mapProj(SGGeod::fromRad(_gpsLon, _gpsLat), _mapHeading);
double meter_per_pix = (_mapOrientation == 0 ? mapScaleMeters / 20.0f : mapScaleMeters / 29.0f);
- Point3D bottomLeft = mapProj.ConvertFromLocal(Point3D(gps_max(-57.0 * meter_per_pix, -50000), gps_max((_mapOrientation == 0 ? -20.0 * meter_per_pix : -11.0 * meter_per_pix), -25000), 0.0));
- Point3D topRight = mapProj.ConvertFromLocal(Point3D(gps_min(54.0 * meter_per_pix, 50000), gps_min((_mapOrientation == 0 ? 20.0 * meter_per_pix : 29.0 * meter_per_pix), 25000), 0.0));
+ SGGeod bottomLeft = mapProj.ConvertFromLocal(SGVec3d(gps_max(-57.0 * meter_per_pix, -50000), gps_max((_mapOrientation == 0 ? -20.0 * meter_per_pix : -11.0 * meter_per_pix), -25000), 0.0));
+ SGGeod topRight = mapProj.ConvertFromLocal(SGVec3d(gps_min(54.0 * meter_per_pix, 50000), gps_min((_mapOrientation == 0 ? 20.0 * meter_per_pix : 29.0 * meter_per_pix), 25000), 0.0));
// Draw Airport labels first (but not one's that are waypoints)
// Draw Airports first (but not one's that are waypoints)
// Annotation then gets drawn by Nav page, NOT this function.
if(_drawApt && draw_avs) {
- airport_list apt;
/*
bool have_apt = _overlays->FindArpByRegion(&apt, bottomLeft.lat(), bottomLeft.lon(), topRight.lat(), topRight.lon());
//cout << "Vors enclosed are: ";
for(unsigned int i=1; i<_activeFP->waypoints.size(); ++i) {
GPSWaypoint* wp0 = _activeFP->waypoints[i-1];
GPSWaypoint* wp1 = _activeFP->waypoints[i];
- Point3D p0 = mapProj.ConvertToLocal(Point3D(wp0->lon * SG_RADIANS_TO_DEGREES, wp0->lat * SG_RADIANS_TO_DEGREES, 0.0));
- Point3D p1 = mapProj.ConvertToLocal(Point3D(wp1->lon * SG_RADIANS_TO_DEGREES, wp1->lat * SG_RADIANS_TO_DEGREES, 0.0));
+ SGVec3d p0 = mapProj.ConvertToLocal(SGGeod::fromRad(wp0->lon, wp0->lat));
+ SGVec3d p1 = mapProj.ConvertToLocal(SGGeod::fromRad(wp1->lon, wp1->lat));
int mx0 = int(p0.x() / meter_per_pix) + 56;
int my0 = int(p0.y() / meter_per_pix) + (_mapOrientation == 0 ? 19 : 10);
int mx1 = int(p1.x() / meter_per_pix) + 56;