TIFFView.cpp
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:19k
- // TIFFView.cpp : implementation of the TIFFView class
- //
- #include "stdafx.h"
- #include "TIFFSample.h"
- #include "TIFFFrame.h"
- #include "TIFFDoc.h"
- #include "TIFFView.h"
- #include "RegPtDLG.h"
- #include "FlightDLG.h"
- #include <string>
- #include <geo.h>
- #include <dibijg.h>
- using namespace std;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- TIFFView * g_view = 0;
- extern CStatusBar * g_statusBar;
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView
- IMPLEMENT_DYNCREATE(TIFFView, CScrollView)
- BEGIN_MESSAGE_MAP(TIFFView, CScrollView)
- //{{AFX_MSG_MAP(TIFFView)
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- ON_UPDATE_COMMAND_UI(ID_VIEW_IMGBAR, OnUpdateImageList)
- ON_COMMAND(ID_VIEW_IMGBAR, OnImageList)
- ON_UPDATE_COMMAND_UI(ID_VIEW_2D, OnUpdateView2D)
- ON_COMMAND(ID_VIEW_2D, OnView2D)
- ON_UPDATE_COMMAND_UI(ID_VIEW_3D, OnUpdateView3D)
- ON_COMMAND(ID_VIEW_3D, OnView3D)
- ON_UPDATE_COMMAND_UI(ID_VIEW_REG, OnUpdateRegistration)
- ON_COMMAND(ID_VIEW_REG, OnRegistration)
- ON_WM_SIZE()
- ON_UPDATE_COMMAND_UI(ID_TOOLS_FLY, OnUpdateToolsFly)
- ON_COMMAND(ID_TOOLS_FLY, OnToolsFly)
- ON_WM_TIMER()
- ON_UPDATE_COMMAND_UI(ID_VIEW_STOPFLIGHT, OnUpdateViewStopflight)
- ON_COMMAND(ID_VIEW_STOPFLIGHT, OnViewStopflight)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView construction/destruction
- TIFFView::TIFFView() : m_cs(0,0)
- {
- m_shownImage = 0;
- g_view = this;
- m_leftDown = false;
- m_isGeo = false;
- m_scaleFactor = 1.0;
- m_view2D = true;
- m_registrationMode = false;
- }
- TIFFView::~TIFFView()
- {
- }
- BOOL TIFFView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CScrollView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView drawing
- void TIFFView::OnDraw(CDC* pDC)
- {
- TIFFDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (pDC->IsPrinting())
- {
- DIBSection * dib = GetDocument()->GetDIB(m_shownImage);
- if (dib && dib->IsCreated())
- {
- int wpix = pDC->GetDeviceCaps(HORZRES);
- int hpix = pDC->GetDeviceCaps(VERTRES);
- int imgWidth = dib->Width();
- int imgHeight = dib->Height();
- double horzScale = (double)wpix / (double)imgWidth;
- double vertScale = (double)hpix / (double)imgHeight;
- DIBSection tmpDIB;
- if (horzScale < vertScale)
- {
- hpix = (int)(imgHeight*horzScale);
- }
- else
- {
- wpix = (int)(imgWidth*vertScale);
- }
- BeginWaitCursor();
- {
- dib->ResizeImage(tmpDIB, wpix, hpix);
- }
- EndWaitCursor();
- pDC->BitBlt( 0, 0, wpix, hpix, tmpDIB.GetDC(), 0, 0, SRCCOPY);
- }
- }
- else
- {
- ShowImage();
- }
- }
- void TIFFView::StretchImage(double scale_factor)
- {
- if (m_view2D)
- {
- double delta = fabs(scale_factor - m_scaleFactor);
- if (delta > 0.01)
- {
- DIBSection * dib = GetDocument()->GetDIB(m_shownImage);
- if (dib && dib->IsCreated())
- {
- int w = (int)(0.50 + scale_factor * dib->Width());
- int h = (int)(0.50 + scale_factor * dib->Height());
- BeginWaitCursor();
- {
- dib->ResizeImage(m_viewDIB, w, h);
- }
- EndWaitCursor();
- m_cs.cx = w;
- m_cs.cy = h;
- SetScrollSizes(MM_TEXT, m_cs);
- ShowImage();
- }
- m_scaleFactor = scale_factor;
- }
- }
- else
- {
- m_view_matrix = m_earth3D.GetModelState();
- m_view_matrix.SetScale(scale_factor,scale_factor,scale_factor);
- m_earth3D.SetModelState(m_view_matrix);
- ShowImage();
- }
- }
- void TIFFView::Stretched2Unstretched(int xin, int yin, int& xout, int& yout)
- {
- xout = (int)(0.50 + (double)xin / m_scaleFactor);
- yout = (int)(0.50 + (double)yin / m_scaleFactor);
- }
- void TIFFView::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
- CSize sizeTotal;
- sizeTotal.cx = sizeTotal.cy = 100;
- SetScrollSizes(MM_TEXT, sizeTotal);
- if (m_dlg.m_hWnd == NULL)
- {
- m_dlg.Create(IDD_TIFFDIR_DLG, this);
- }
- if (!m_earth3D.IsInitialized())
- {
- CRect r;
- GetClientRect(&r);
- m_earth3D.CreateImage(r.Width(),r.Height());
- //m_earth3D.RebuildEarth();
- //m_earth3D.RebuildTexture();
- }
- //DIBSection tmpDIB;
- //OpenIJG2DIB("land1024x512.jpg",tmpDIB);
- //m_earth3D.SetTexture(tmpDIB);
- TIFFFrame * frm = (TIFFFrame *)GetParentFrame();
- if (frm)
- {
- frm->HideList();
- }
- }
- void TIFFView::ShowImage(void)
- {
- if (m_view2D)
- {
- if (m_viewDIB.IsCreated())
- {
- CClientDC dc(this);
- CPoint sp = GetScrollPosition();
- CRect r;
- GetClientRect(&r);
- UINT32 w = m_viewDIB.Width();
- UINT32 h = m_viewDIB.Height();
- if (w < r.Width())
- {
- dc.PatBlt(w,0,r.Width(),r.Height(), WHITENESS);
- }
- if (h < r.Height())
- {
- dc.PatBlt(0,h,r.Width(),r.Height(), WHITENESS);
- }
- m_viewDIB.Draw(&dc, sp.x, sp.y);
- PlotClickPoints(dc);
- }
- }
- else
- {
- if (m_earth3D.IsInitialized())
- {
- m_earth3D.RenderImage();
- m_earth3D.DrawImage(this);
- }
- }
- }
- void TIFFView::PlotClickPoints(CClientDC& dc)
- {
- if (m_isGeo)
- {
- double x, y;
- COLORREF cr = RGB(255,64,64);
- COLORREF cr2 = RGB(255,255,255);
- CPoint sp = GetScrollPosition();
-
- int size = m_pts.size();
- for (int i = 0; i < size; i++){
- m_utmProj.forward(m_pts[i].m_lat,m_pts[i].m_lon,x,y);
- x -= m_gr.m_tieX;
- y = m_gr.m_tieY - y;
- x /= m_gr.m_resX;
- y /= m_gr.m_resY;
- x *= m_scaleFactor;
- y *= m_scaleFactor;
- x -= sp.x;
- y -= sp.y;
-
- dc.FillSolidRect((int)x-2,(int)y-2,6,6,cr2);
- dc.FillSolidRect((int)x-3,(int)y-3,6,6,cr);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView printing
- BOOL TIFFView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void TIFFView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void TIFFView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView diagnostics
- #ifdef _DEBUG
- void TIFFView::AssertValid() const
- {
- CScrollView::AssertValid();
- }
- void TIFFView::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
- TIFFDoc* TIFFView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(TIFFDoc)));
- return (TIFFDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // TIFFView message handlers
- void TIFFView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
- {
- bool showList = false;
- m_pts.clear();
- TIFFDoc * doc = GetDocument();
- if (doc)
- {
- TIFFFrame * frm = (TIFFFrame *)GetParentFrame();
- if (frm)
- {
- frm->HideList();
- }
- ArrayContainer<DIBSection *> * dibs = doc->GetDIBs();
- if (dibs)
- {
- int size = dibs->GetSize();
- m_dlg.SetImageCount(size);
- m_shownImage = 0;
- if (size > 1)
- {
- showList = true;
- }
- DIBSection * dib = doc->GetDIB(m_shownImage);
- m_isGeo = false;
- if (dib && dib->IsCreated())
- {
- m_isGeo = dib->IsGeoImage();
- int w = (int)(0.50 + m_scaleFactor * dib->Width());
- int h = (int)(0.50 + m_scaleFactor * dib->Height());
- BeginWaitCursor();
- {
- dib->ResizeImage(m_viewDIB, w, h);
- }
- EndWaitCursor();
- m_cs.cx = w;
- m_cs.cy = h;
- if (m_isGeo)
- {
- m_gr = dib->GetGeoReference();
- m_isGeo = true;
- string ellps;
- switch (m_gr.m_ellipse){
- case GEORef::Clarke1866:
- {
- ellps = "clrk66";
- }
- break;
- case GEORef::WGS84:
- {
- ellps = "WGS84";
- }
- break;
- case GEORef::WGS72:
- {
- ellps = "WGS72";
- }
- break;
- case GEORef::UnknownEllipsoid:
- {
- ellps = "WGS84";
- }
- break;
- }
- m_utmProj.setup(m_gr.m_zone,ellps.c_str());
- m_earth3D.SetGeoImage(dib, &m_utmProj);
- m_earth3D.RebuildImage();
- }
- }
- else
- {
- CRect r;
- GetClientRect(&r);
- m_cs.cx = r.Width();
- m_cs.cy = r.Height();
- }
- SetScrollSizes(MM_TEXT, m_cs);
- InvalidateRect(NULL, true);
- }
- }
- if (m_dlg.m_hWnd)
- {
- m_dlg.ShowWindow( showList ? SW_SHOW : SW_HIDE );
- m_dlg.UpdateList();
- }
- }
- void TIFFView::SetImage(UINT32 ndx)
- {
- DIBSection * dib = GetDocument()->GetDIB(ndx);
- if (dib && dib->IsCreated())
- {
- int w = (int)(0.50 + m_scaleFactor * dib->Width());
- int h = (int)(0.50 + m_scaleFactor * dib->Height());
- BeginWaitCursor();
- {
- dib->ResizeImage(m_viewDIB, w, h);
- }
- EndWaitCursor();
- m_cs.cx = w;
- m_cs.cy = h;
- SetScrollSizes(MM_TEXT, m_cs);
- m_shownImage = ndx;
- ShowImage();
- }
- }
- void TIFFView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- if (m_registrationMode)
- {
- CPoint sp = GetScrollPosition();
- point.x += sp.x;
- point.y += sp.y;
- int xout, yout;
- Stretched2Unstretched(point.x,point.y,xout,yout);
- if (m_isGeo)
- {
- double lat, lon;
- if (m_view2D)
- {
- double x = m_gr.m_tieX+m_gr.m_resX*(double)xout;
- double y = m_gr.m_tieY-m_gr.m_resY*(double)yout;
- m_utmProj.inverse(x,y,lat,lon);
- RegPtDLG dlg;
- dlg.SetPosition(lat,lon);
- if (dlg.DoModal() == IDOK)
- {
- ClickPoint pt(dlg.GetLat(),dlg.GetLon(),dlg.GetName(),dlg.GetAltitude());
- m_pts.push_back(pt);
- TIFFFrame * frm = (TIFFFrame *)GetParentFrame();
- if (frm)
- {
- frm->UpdateList();
- frm->ShowList();
- }
- ShowImage();
- }
- }
- else
- {
- int id;
- m_earth3D.PickObject(point.x,point.y,id);
- if (m_earth3D.PickedPoint())
- {
- lat = m_earth3D.GetPickedLat();
- lon = m_earth3D.GetPickedLon();
- RegPtDLG dlg;
- dlg.SetPosition(lat,lon);
- if (dlg.DoModal() == IDOK)
- {
- ClickPoint pt(dlg.GetLat(),dlg.GetLon(),dlg.GetName(),dlg.GetAltitude());
- m_pts.push_back(pt);
- TIFFFrame * frm = (TIFFFrame *)GetParentFrame();
- if (frm)
- {
- frm->UpdateList();
- frm->ShowList();
- }
- ShowImage();
- }
- }
- }
- }
- m_registrationMode = false;
- }
- else
- {
- m_leftDown = true;
- m_clickPoint = point;
- if (m_view2D)
- {
- }
- else
- {
- m_view_matrix = m_earth3D.GetModelState();
- }
- }
-
- CScrollView::OnLButtonDown(nFlags, point);
- }
- void TIFFView::OnLButtonUp(UINT nFlags, CPoint point)
- {
- m_leftDown = false;
-
- //CScrollView::OnLButtonUp(nFlags, point);
- }
- void TIFFView::OnMouseMove(UINT nFlags, CPoint point)
- {
- CPoint sp = GetScrollPosition();
- memset(m_status, 0, (size_t)80);
- memset(m_status1, 0, (size_t)80);
- memset(m_status2, 0, (size_t)80);
- memset(m_status3, 0, (size_t)80);
- if (m_view2D)
- {
- if (m_leftDown)
- {
- int xDelta = point.x - m_clickPoint.x;
- int yDelta = point.y - m_clickPoint.y;
- m_clickPoint = point;
- sp.x -= xDelta;
- sp.y -= yDelta;
- sp.x = (sp.x < 0) ? 0 : sp.x;
- sp.y = (sp.y < 0) ? 0 : sp.y;
-
- sp.x = (sp.x > m_cs.cx) ? m_cs.cx : sp.x;
- sp.y = (sp.y > m_cs.cy) ? m_cs.cy : sp.y;
- CRect r;
- GetClientRect(&r);
- int spxMax = m_viewDIB.Width() - r.Width();
- int spyMax = m_viewDIB.Height() - r.Height();
- if (spxMax < 0) spxMax = 0;
- if (spyMax < 0) spyMax = 0;
- sp.x = (sp.x < spxMax) ? sp.x : spxMax;
- sp.y = (sp.y < spyMax) ? sp.y : spyMax;
- ScrollToPosition(sp);
- ShowImage();
- }
- int xin = sp.x + point.x;
- int yin = sp.y + point.y;
- int xout, yout;
- Stretched2Unstretched( xin, yin, xout, yout );
-
- sprintf(m_status1,"%dx%d", xin, yin);
-
- if (g_statusBar)
- {
- g_statusBar->SetPaneText(1, m_status1);
- }
- if (m_isGeo)
- {
- double lat, lon;
- double x = m_gr.m_tieX+m_gr.m_resX*(double)xout;
- double y = m_gr.m_tieY-m_gr.m_resY*(double)yout;
- sprintf(m_status2,"( %.1f, %.1f )",x,y);
- m_utmProj.inverse(x,y,lat,lon);
- INT32 latDeg, latMin, lonDeg, lonMin;
- double latSec, lonSec;
- m_utmProj.DD2DMS(lat,latDeg,latMin,latSec);
- m_utmProj.DD2DMS(lon,lonDeg,lonMin,lonSec);
- sprintf(m_status3,"( %d-%.2d-%2.1f %c, %d-%.2d-%2.1f %c )",
- latDeg,latMin,latSec,(lat<0.0)?'S':'N', lonDeg, lonMin, lonSec,
- (lon<0.0)?'W':'E');
- }
- }
- else
- {
- if (m_leftDown)
- {
- int xdiff = point.x - m_clickPoint.x;
- int ydiff = point.y - m_clickPoint.y;
- double yrot = (double)xdiff/9.0;
- double xrot = (double)ydiff/9.0;
- double zrot = 0.0;
- while (xrot < 0.0) xrot += 360.0;
- while (xrot > 360.0) xrot -= 360.00000001;
- while (yrot < 0.0) yrot += 360.0;
- while (yrot > 360.0) yrot -= 360.00000001;
- Matrix3D mat = m_view_matrix;
- mat.AddRotation(xrot,yrot,zrot);
- m_earth3D.SetModelState(mat);
- ShowImage();
- }
- }
-
- if (g_statusBar)
- {
- g_statusBar->SetPaneText(2, m_status2);
- g_statusBar->SetPaneText(3, m_status3);
- }
- CScrollView::OnMouseMove(nFlags, point);
- }
- void TIFFView::OnUpdateImageList(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- pCmdUI->SetCheck(m_dlg.IsWindowVisible());
- }
- void TIFFView::OnImageList()
- {
- m_dlg.ShowWindow(m_dlg.IsWindowVisible() ? SW_HIDE : SW_SHOW);
- }
- void TIFFView::OnUpdateView2D(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- pCmdUI->SetCheck(m_view2D);
- }
- void TIFFView::OnView2D()
- {
- m_view2D = true;
- m_registrationMode = false;
- CSize cs;
- cs.cx = m_viewDIB.Width();
- cs.cy = m_viewDIB.Height();
- SetScrollSizes(MM_TEXT, cs);
- ShowImage();
- }
- void TIFFView::OnUpdateView3D(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- pCmdUI->SetCheck(!m_view2D);
- }
- void TIFFView::OnView3D()
- {
- m_view2D = false;
- m_registrationMode = false;
- CRect r;
- GetClientRect(&r);
- m_earth3D.SizeImage(r.Width(),r.Height());
- m_earth3D.RebuildImage();
- //
- // we don't want any scroll bars
- //
- CSize cs;
- cs.cx = 5;
- cs.cy = 5;
- SetScrollSizes(MM_TEXT, cs);
- ShowImage();
- }
- void TIFFView::OnUpdateRegistration(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable();
- }
- void TIFFView::OnRegistration(void)
- {
- m_registrationMode = m_registrationMode ? false : true;
- }
- void TIFFView::OnSize(UINT nType, int cx, int cy)
- {
- CScrollView::OnSize(nType, cx, cy);
-
- if ((cx > 0) && (cy > 0))
- {
- if (m_view2D)
- {
- CSize cs;
- cs.cx = m_viewDIB.Width();
- cs.cy = m_viewDIB.Height();
- SetScrollSizes(MM_TEXT, cs);
- }
- else
- {
- CRect r;
- GetClientRect(&r);
- //
- // we don't want any scroll bars
- //
- CSize cs;
- cs.cx = 5;
- cs.cy = 5;
- SetScrollSizes(MM_TEXT, cs);
- bool skip = false;
- DIBSection * dib = m_earth3D.GetDIB();
- if (dib)
- {
- if ((dib->Width() == r.Width()) && (dib->Height() == r.Height()))
- skip = true;
- }
- if (!skip)
- {
- m_earth3D.SizeImage(r.Width(),r.Height());
- m_earth3D.RebuildImage();
- m_earth3D.RebuildEarth();
- }
- ShowImage();
- }
- }
- }
- void TIFFView::OnUpdateToolsFly(CCmdUI* pCmdUI)
- {
- //
- // we only want to enable user to fly if they are in 3D mode,
- // and if the image they are looking at is a geo image, and if
- // they have defined some points to fly...
- //
- bool showFlyMenu = m_view2D ? false : (m_pts.size()>1) ? m_isGeo : false;
- pCmdUI->Enable(showFlyMenu);
- }
- void TIFFView::OnToolsFly()
- {
- FlightDLG dlg;
- if (dlg.DoModal() == IDOK)
- {
- m_flyFirstPerson = dlg.GetFirstPerson();
- m_flyDuration = dlg.GetDuration();
- // basically going to setup 100 equally spaced points along the
- // route (i.e. from the first point to the last)
- m_totalFrames = 100;
- double dx, u[3], v[3], lat1, lon1, lat2, lon2, alt1, alt2;
- double D = 0.0;
- int i, j;
- int size = m_pts.size();
- for (i = 0; i < (size-1); i++){
- lat1 = m_pts[i].m_lat;
- lon1 = m_pts[i].m_lon;
- lat2 = m_pts[i+1].m_lat;
- lon2 = m_pts[i+1].m_lon;
- D += GeoCalc::GCDistance(lat1,lon1,lat2,lon2);
- }
- // dividing the total distance by the number of divisions
- dx = D / (m_totalFrames-1);
- // following loop sets up the individual way points to fly through
- // ultimately we will be interpolating between these points.
- V3D v3d;
- m_flyWayPoints.clear();
- for (i = 0; i < (size-1); i++){
- lat1 = m_pts[i].m_lat;
- lon1 = m_pts[i].m_lon;
- lat2 = m_pts[i+1].m_lat;
- lon2 = m_pts[i+1].m_lon;
- alt1 = m_pts[i].m_alt;
- alt2 = m_pts[i+1].m_alt;
- int total = (int)GeoCalc::GCDistance(lat1,lon1,lat2,lon2)/dx;
- m_earth3D.GeoToXYZ(lat1, lon1, u[0], u[1], u[2],1.0 + alt1/GEO::ERADM);
- m_earth3D.GeoToXYZ(lat2, lon2, v[0], v[1], v[2],1.0 + alt2/GEO::ERADM);
- for (j = 0; j < total; j++){
- double p = (double)j/(double)total;
- v3d.m_x = u[0] + p * (v[0] - u[0]);
- v3d.m_y = u[1] + p * (v[1] - u[1]);
- v3d.m_z = u[2] + p * (v[2] - u[2]);
- m_flyWayPoints.push_back(v3d);
- }
- }
- // get the start time (in ticks)
- m_flyStart = GetTickCount();
- m_earth3D.SetFlyMode(true);
- SetTimer(m_flyTimer, 3, NULL);
- }
- }
- void TIFFView::OnTimer(UINT nIDEvent)
- {
- if (nIDEvent == m_flyTimer)
- {
- UINT32 ticks = GetTickCount();
- double comp = (double)m_flyWayPoints.size() * (double)(ticks - m_flyStart)/((double)m_flyDuration*1000.0);
- if (comp < (double)(m_flyWayPoints.size() - 1))
- {
- double u[3], v[3];
- UINT32 last = (UINT32)comp;
- UINT32 next = last + 1;
- // interpolate the current position
- u[0] = m_flyWayPoints[last].m_x + (comp - (double)last) * (m_flyWayPoints[next].m_x - m_flyWayPoints[last].m_x);
- u[1] = m_flyWayPoints[last].m_y + (comp - (double)last) * (m_flyWayPoints[next].m_y - m_flyWayPoints[last].m_y);
- u[2] = m_flyWayPoints[last].m_z + (comp - (double)last) * (m_flyWayPoints[next].m_z - m_flyWayPoints[last].m_z);
- // this is an attempt to make the turns a little smoother
- if (last < 98)
- next++;
- // v is the where the nose of the airplane is pointing to
- v[0] = m_flyWayPoints[next].m_x;
- v[1] = m_flyWayPoints[next].m_y;
- v[2] = m_flyWayPoints[next].m_z;
- // setting the position, the look-at point, and the flight mode
- m_earth3D.SetFlyPosition(u,v,m_flyFirstPerson);
- m_earth3D.RenderImage();
- m_earth3D.DrawImage(this);
- }
- else
- {
- KillTimer(m_flyTimer);
- m_earth3D.SetFlyMode(false);
- m_earth3D.RebuildImage();
- m_flyWayPoints.clear();
- ShowImage();
- }
- }
-
- CScrollView::OnTimer(nIDEvent);
- }
- void TIFFView::OnUpdateViewStopflight(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_earth3D.GetFlyMode());
- }
- void TIFFView::OnViewStopflight()
- {
- KillTimer(m_flyTimer);
- m_flyWayPoints.clear();
- m_earth3D.SetFlyMode(false);
- m_earth3D.RebuildImage();
- ShowImage();
- }