Results 1 to 4 of 4

Thread: ActiveQt using free open source MapWindow activeX control

  1. #1
    Join Date
    Feb 2006
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default ActiveQt using free open source MapWindow activeX control

    Hi,

    I'm developing a basic GIS application using ActiveQt module and free open source activeX called MapWindow. I'm using Visual Studio .NET 2003 and Qt 4.2.
    This activeX control supports basic GIS drawing and shapefile manipulation. The ActiveX control's API is here.
    I've used dumpcpp tool to generate the Qt's wrapper to this control. I enclose this two generated files called mapwindow.h and mapwindow.cpp in the zip file.
    I've created a simple widget with the designer and created "manually" the QAxWidget. This is the code:

    #ifndef MPWTEST_H
    #define MPWTEST_H

    #include <QtGui/QMainWindow>
    #include <QAxObject>
    #include <QDebug>
    #include <QFile>
    #include <QUuid>
    #include <QTextStream>
    #include "mapwindow.h"
    #include "ui_mpwtest.h"

    using namespace MapWinGIS;

    class MPWTEST : public QMainWindow
    {
    Q_OBJECT

    public:
    MPWTEST(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~MPWTEST();

    private:
    Ui::MPWTESTClass ui;
    Map mapObject2;
    };

    #endif // MPWTEST_H

    *************************
    ***** End of file ***********
    *************************


    #include "mpwtest.h"
    #include <qaxobject.h>
    #include <qaxwidget.h>

    MPWTEST::MPWTEST(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
    {
    ui.setupUi(this);
    //mapObject = new Map(this);

    if (!mapObject2.isNull())
    {
    ui.vboxLayout->addWidget(&mapObject2);
    mapObject2.NewDrawing(dlScreenReferencedList);
    mapObject2.DrawCircle(3,4,12,QColor("red"),true);
    }
    }


    *************************
    ***** End of file ***********
    *************************

    This example works ok, as you see, it draws a red circle on the 3,4 coordiantes.
    The problem comes when i try to load a Shapefile using Shapefile Object from the ActiveX.
    I'm trying to create a Shapefile object and call "Open" function. As stated in the MapWindow doc, the signature for Open in VisualBasic is:
    Function Open(ShapefileName As String, Optional cBack As MapWinGIS.ICallback) As Boolean.

    So, in the Qt's wrapper mapwindow.h it shows:
    inline bool Open(const QString& ShapefileName, MapWinGIS::ICallback* cBack);

    Being ICallback a parameter not supported in ActiveQt, I cannot use dynamicCall in order to use "Open" function. So I try to use the wrapper:

    1 Shapefile *shp = new Shapefile;
    2 if (shp)
    3 {
    4 bool result = shp->Open("country.shp",NULL);
    5 if (result)
    6 {
    7 mapObject2.AddLayer((IDispatch *)shp,true);
    8 }
    9 }

    This code doesn't work!. It stops in line 4 showing
    "ASSERT: "id < 0" in file .\qaxbase.cpp, line 3598
    It seems the object is not being properly initalized. If i use, IShapefile instead of Shapefile changing line 1

    1 IShapefile *shp = new IShapefile;

    it shows a runtime Qt warning after executing line 4:
    QAxBase::qt_metacall: Object is not initialized, or initialization failed
    and the boolean variable result is always false.
    Having {c0eac9eb-1d02-4bd9-8dab-4bf922c8cd13} as the Uid for the Shapefile control, I try the "queryInterface" way with:

    1 IShapefile *shp = 0;
    2 mapObject2.queryInterface(QUuid("{c0eac9eb-1d02-4bd9-8dab-4bf922c8cd13}"),(void**)&shp);
    3 if (shp)
    4 {
    5 bool result = shp->Open("country.shp",NULL);
    6 if (result)
    7 {
    8 mapObject2.AddLayer((IDispatch *)shp,true);
    9 }
    10 }
    11 else
    12 {
    13 qDebug() << "Object creation failed.";
    14 }

    Executing this code, shp remains 0 after line 3...mmmm, I don't know if I am misunderstanding something or the Uid for the Shapefile is incorrect or....
    Do you know what's happening? I've compiled and run the example C++ Simple Map Project (Visual Studio 2003) from the sample code on the web and it works perfectly.

    Thanks for your time,

    Carlos.
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: ActiveQt using free open source MapWindow activeX control

    Open Function exits in class ITable,not IShapefile ,see mapwindow.h

  3. #3
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveQt using free open source MapWindow activeX control

    Hello,

    I exactly have the same problem about using a shapefile. Actually, I don't manage to call the CreateNew() or Open() methods of my Shapefile object without getting a crash of my application during runtime.
    I am using Visual C++ 2008 but I have the same problems with QtCreator.
    Please let me know if you know anything about how to load a Shape file stored on disk and how to associate it with a Map object.

    Thanks in advance,
    Romain.

  4. #4
    Join Date
    Oct 2015
    Posts
    1
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: ActiveQt using free open source MapWindow activeX control

    I'm trying to use MapWinGIS.ocx in my QT application. I got the header and lib files of MapWindow. Is there anyway I could get the source code for simply loading shape files?
    Thanks.


    Quote Originally Posted by crey View Post
    Hi,

    I'm developing a basic GIS application using ActiveQt module and free open source activeX called MapWindow. I'm using Visual Studio .NET 2003 and Qt 4.2.
    This activeX control supports basic GIS drawing and shapefile manipulation. The ActiveX control's API is here.
    I've used dumpcpp tool to generate the Qt's wrapper to this control. I enclose this two generated files called mapwindow.h and mapwindow.cpp in the zip file.
    I've created a simple widget with the designer and created "manually" the QAxWidget. This is the code:

    #ifndef MPWTEST_H
    #define MPWTEST_H

    #include <QtGui/QMainWindow>
    #include <QAxObject>
    #include <QDebug>
    #include <QFile>
    #include <QUuid>
    #include <QTextStream>
    #include "mapwindow.h"
    #include "ui_mpwtest.h"

    using namespace MapWinGIS;

    class MPWTEST : public QMainWindow
    {
    Q_OBJECT

    public:
    MPWTEST(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~MPWTEST();

    private:
    Ui::MPWTESTClass ui;
    Map mapObject2;
    };

    #endif // MPWTEST_H

    *************************
    ***** End of file ***********
    *************************


    #include "mpwtest.h"
    #include <qaxobject.h>
    #include <qaxwidget.h>

    MPWTEST::MPWTEST(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
    {
    ui.setupUi(this);
    //mapObject = new Map(this);

    if (!mapObject2.isNull())
    {
    ui.vboxLayout->addWidget(&mapObject2);
    mapObject2.NewDrawing(dlScreenReferencedList);
    mapObject2.DrawCircle(3,4,12,QColor("red"),true);
    }
    }


    *************************
    ***** End of file ***********
    *************************

    This example works ok, as you see, it draws a red circle on the 3,4 coordiantes.
    The problem comes when i try to load a Shapefile using Shapefile Object from the ActiveX.
    I'm trying to create a Shapefile object and call "Open" function. As stated in the MapWindow doc, the signature for Open in VisualBasic is:
    Function Open(ShapefileName As String, Optional cBack As MapWinGIS.ICallback) As Boolean.

    So, in the Qt's wrapper mapwindow.h it shows:
    inline bool Open(const QString& ShapefileName, MapWinGIS::ICallback* cBack);

    Being ICallback a parameter not supported in ActiveQt, I cannot use dynamicCall in order to use "Open" function. So I try to use the wrapper:

    1 Shapefile *shp = new Shapefile;
    2 if (shp)
    3 {
    4 bool result = shp->Open("country.shp",NULL);
    5 if (result)
    6 {
    7 mapObject2.AddLayer((IDispatch *)shp,true);
    8 }
    9 }

    This code doesn't work!. It stops in line 4 showing
    "ASSERT: "id < 0" in file .\qaxbase.cpp, line 3598
    It seems the object is not being properly initalized. If i use, IShapefile instead of Shapefile changing line 1

    1 IShapefile *shp = new IShapefile;

    it shows a runtime Qt warning after executing line 4:
    QAxBase::qt_metacall: Object is not initialized, or initialization failed
    and the boolean variable result is always false.
    Having {c0eac9eb-1d02-4bd9-8dab-4bf922c8cd13} as the Uid for the Shapefile control, I try the "queryInterface" way with:

    1 IShapefile *shp = 0;
    2 mapObject2.queryInterface(QUuid("{c0eac9eb-1d02-4bd9-8dab-4bf922c8cd13}"),(void**)&shp);
    3 if (shp)
    4 {
    5 bool result = shp->Open("country.shp",NULL);
    6 if (result)
    7 {
    8 mapObject2.AddLayer((IDispatch *)shp,true);
    9 }
    10 }
    11 else
    12 {
    13 qDebug() << "Object creation failed.";
    14 }

    Executing this code, shp remains 0 after line 3...mmmm, I don't know if I am misunderstanding something or the Uid for the Shapefile is incorrect or....
    Do you know what's happening? I've compiled and run the example C++ Simple Map Project (Visual Studio 2003) from the sample code on the web and it works perfectly.

    Thanks for your time,

    Carlos.

Similar Threads

  1. Replies: 6
    Last Post: 3rd February 2006, 10:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.