Browse Source

Adding full google maps support to windows

QGC4.4
pixhawk 14 years ago
parent
commit
0268fb5ee0
  1. 13
      src/ui/MapWidget.cc
  2. 21
      src/ui/map3D/QGCGoogleEarthView.cc
  3. 1
      src/ui/map3D/QGCGoogleEarthView.h

13
src/ui/MapWidget.cc

@ -34,6 +34,7 @@ MapWidget::MapWidget(QWidget *parent) :
mav(NULL), mav(NULL),
lastUpdate(0), lastUpdate(0),
initialized(false), initialized(false),
mc(NULL),
m_ui(new Ui::MapWidget) m_ui(new Ui::MapWidget)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -952,7 +953,7 @@ void MapWidget::updatePosition(float time, double lat, double lon)
//gpsposition->setText(QString::number(time) + " / " + QString::number(lat) + " / " + QString::number(lon)); //gpsposition->setText(QString::number(time) + " / " + QString::number(lat) + " / " + QString::number(lon));
if (followgps->isChecked() && isVisible()) if (followgps->isChecked() && isVisible())
{ {
mc->setView(QPointF(lat, lon)); if (mc) mc->setView(QPointF(lat, lon));
} }
} }
@ -975,6 +976,8 @@ void MapWidget::wheelEvent(QWheelEvent *event)
void MapWidget::keyPressEvent(QKeyEvent *event) void MapWidget::keyPressEvent(QKeyEvent *event)
{ {
if (mc)
{
switch (event->key()) { switch (event->key()) {
case Qt::Key_Plus: case Qt::Key_Plus:
mc->zoomIn(); mc->zoomIn();
@ -997,17 +1000,23 @@ void MapWidget::keyPressEvent(QKeyEvent *event)
default: default:
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
}
} }
void MapWidget::resizeEvent(QResizeEvent* event ) void MapWidget::resizeEvent(QResizeEvent* event )
{ {
Q_UNUSED(event); Q_UNUSED(event);
mc->resize(this->size()); if (mc) mc->resize(this->size());
} }
void MapWidget::showEvent(QShowEvent* event) void MapWidget::showEvent(QShowEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
if (!initialized)
{
initialized = true;
init();
}
} }
void MapWidget::hideEvent(QHideEvent* event) void MapWidget::hideEvent(QHideEvent* event)

21
src/ui/map3D/QGCGoogleEarthView.cc

@ -44,17 +44,13 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
webViewWin(new QGCWebAxWidget(this)), webViewWin(new QGCWebAxWidget(this)),
documentWin(NULL),
#endif #endif
#if (defined _MSC_VER)
ui(new Ui::QGCGoogleEarthView) ui(new Ui::QGCGoogleEarthView)
#else
ui(new Ui::QGCGoogleEarthView)
#endif
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
// Create layout and attach webViewWin // Create layout and attach webViewWin
QFile file("doc.html"); QFile file("doc.html");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug() << __FILE__ << __LINE__ << "Could not open log file"; qDebug() << __FILE__ << __LINE__ << "Could not open log file";
@ -406,6 +402,16 @@ QVariant QGCGoogleEarthView::documentElement(QString name)
} }
else else
{ {
if (documentWin)
{
// Get HTMLElement object
QVariantList params;
params.append(name);
//QAxObject* elementWin = documentWin->dynamicCall("getElementById(QString)", params);
QVariant result =documentWin->dynamicCall("toString()");
qDebug() << "GOT RESULT" << result;
return QVariant(0);//QVariant(result);
}
//QVariantList params; //QVariantList params;
//params.append(javaScript); //params.append(javaScript);
//params.append("JScript"); //params.append("JScript");
@ -425,6 +431,7 @@ void QGCGoogleEarthView::initializeGoogleEarth()
QAxObject* doc = webViewWin->querySubObject("Document()"); QAxObject* doc = webViewWin->querySubObject("Document()");
//IDispatch* Disp; //IDispatch* Disp;
IDispatch* winDoc = NULL; IDispatch* winDoc = NULL;
IHTMLDocument2* document = NULL;
//332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2 //332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2
//25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument //25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument
@ -435,11 +442,11 @@ void QGCGoogleEarthView::initializeGoogleEarth()
// CoInternetSetFeatureEnabled // CoInternetSetFeatureEnabled
// (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE); // (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE);
// //
IHTMLDocument2* document = NULL; document = NULL;
winDoc->QueryInterface( IID_IHTMLDocument2, (void**)&document ); winDoc->QueryInterface( IID_IHTMLDocument2, (void**)&document );
IHTMLWindow2 *window = NULL; IHTMLWindow2 *window = NULL;
document->get_parentWindow( &window ); document->get_parentWindow( &window );
documentWin = new QAxObject(document, webViewWin);
jScriptWin = new QAxObject(window, webViewWin); jScriptWin = new QAxObject(window, webViewWin);
connect(jScriptWin, SIGNAL(exception(int,QString,QString,QString)), this, SLOT(printWinException(int,QString,QString,QString))); connect(jScriptWin, SIGNAL(exception(int,QString,QString,QString)), this, SLOT(printWinException(int,QString,QString,QString)));
jScriptInitialized = true; jScriptInitialized = true;

1
src/ui/map3D/QGCGoogleEarthView.h

@ -143,6 +143,7 @@ protected:
#ifdef _MSC_VER #ifdef _MSC_VER
QGCWebAxWidget* webViewWin; QGCWebAxWidget* webViewWin;
QAxObject* jScriptWin; QAxObject* jScriptWin;
QAxObject* documentWin;
#endif #endif
#if (defined Q_OS_MAC) #if (defined Q_OS_MAC)
QWebView* webViewMac; QWebView* webViewMac;

Loading…
Cancel
Save