qt环境下Mapx组建的编程---------regoin

#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>
#include <QToolBar>
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    map(nullptr),
    pCMapXPoint(nullptr),pCMapXPoint1(nullptr),pCMapXPoint2(nullptr),
    pCMapFeaFactory(nullptr),
    pCMapXFeature(nullptr),
    pCMapStyle(nullptr),
    pCMapLayers(nullptr),
    pCMapLayer(nullptr),

    pCMapLine(nullptr),
    pCMapPoints(nullptr),
    pCMapParts(nullptr),

    pCMapArc(nullptr),

    pCMapXFeatureRegoin(nullptr),
    //坐标的变化
    pCMapXCoordSys(nullptr),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->resize(1000,800);

    QPushButton *pButton = new QPushButton("tool",this);
    pButton->resize(70,23);

    //建立一个地图
    map = new MapSpace::Map("",this);
    //设置大小属性
    map->move(QPoint(10,25));
    map->resize(QSize(size().width()-20,size().height()-20));

    map->SetCurrentTool(MapSpace::ToolConstants::miPanTool);//鼠标工具
    map->setProperty("MousewheelSupport",2);//支持滚轮
 /* 显示一个小图标(旗子模样)*/
    pCMapLayers = map->Layers();
    pCMapLayers->AddGeoSetLayers("C:/mapx/MapX4/Maps/Captial.gst");
    pCMapLayer = pCMapLayers->CreateLayer("test");


    pCMapFeaFactory = map->FeatureFactory();



    //划一个区域。regoin
    pCMapXFeatureRegoin = pCMapFeaFactory->CreateRegion();//创建一个区域feature
    pCMapPoints = new MapSpace::CMapXPoints;
    pCMapPoints->setControl("MapX.Points.4");
    pCMapParts = pCMapXFeatureRegoin->Parts();
    pCMapXPoint = pCMapPoints->AddXY(120.07372, 29.35792);
    pCMapXPoint1 = pCMapPoints->AddXY(120.07270, 29.35780);
    pCMapXPoint2 = pCMapPoints->AddXY(120.07000, 29.35000);

    pCMapStyle = pCMapXFeatureRegoin->Style();
    //pCMapStyle->setControl("Mapx.Style.4");
    //pCMapStyle->SetRegionBackColor(200);
    //pCMapStyle->SetLineColor(117);
    pCMapStyle->SetRegionBorderWidthUnit(MapSpace::StyleUnitConstants::miStyleUnitTenthsOfPoint);
    pCMapStyle->SetRegionBorderWidth(35);//边界线条宽度,与上方函数一起使用
    pCMapStyle->SetRegionBorderColor(243);//边界颜色
    pCMapStyle->SetRegionColor(123);//背景颜色
   // pCMapStyle->SetRegionStyle(MapSpace::miPenSolid);
    pCMapStyle->SetRegionPattern(MapSpace::miPatternCross);
    //pCMapStyle->SetRegionTransparent(true);//用于至少两个图元之间

    pCMapParts->Add(pCMapPoints->asVariant().value<IDispatch*>());
    pCMapLayer->AddFeature(pCMapXFeatureRegoin->asVariant().value<IDispatch*>());
    map->ZoomTo(200,120.06272, 29.35522);
}
在加上圆形的图元
 1 void MainWindow::CMapxInit(){
 2     widget = new QAxWidget(this);
 3     widget->setControl(QString::fromUtf8("{9D6ED188-5910-11D2-98A6-00A0C9742CCA}"));
 4     widget->resize(size().width(),size().height());
 5 
 6     pCMapX = new CMapX(widget->asVariant().value<IDispatch*>());
 7     pCMapXLayer = pCMapX->Layers()->CreateLayer("aaa");
 8 
 9     pCMapXFeatureFactory = pCMapX->FeatureFactory();
10     pCMapXFeaturePoint = pCMapXFeatureFactory->CreateSymbol();
11 
12     pCMapXPoint = pCMapXFeaturePoint->Point();
13     pCMapXPoint->Set(120.06872,29.35692);
14     //算出外接矩形的两个角坐标,一个在X轴上,一个在Y轴上
15 
16     pCMapXFeatureCircularRegion = pCMapXFeatureFactory->CreateCircularRegion(miCircleTypeMap,pCMapXPoint->asVariant().value<IDispatch*>(),1,0,1000);
17     pStyle =  pCMapXFeatureCircularRegion->Style();
18     pStyle->SetRegionColor(QColor(255,0,0));
19 
20     pCMapXLayer->AddFeature(pCMapXFeatureCircularRegion->asVariant().value<IDispatch*>());
21 
22     pCMapX->ZoomTo(10,120.06872,29.35692);
23 }
 
  

 

 

转载于:https://www.cnblogs.com/first-semon/p/5894039.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值