64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
|
|
#include "ManualLabelToolWidget.h"
|
|||
|
|
#include <qdockwidget.h>
|
|||
|
|
#include <qgslayertreeview.h>
|
|||
|
|
#include <qgslayertreemodel.h>
|
|||
|
|
#include <qgslayertreemapcanvasbridge.h>
|
|||
|
|
|
|||
|
|
ManualLabelToolWidget::ManualLabelToolWidget(QWidget *parent)
|
|||
|
|
: QMainWindow(parent)
|
|||
|
|
{
|
|||
|
|
this->init_UI();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ManualLabelToolWidget::~ManualLabelToolWidget()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ManualLabelToolWidget::init_UI()
|
|||
|
|
{
|
|||
|
|
// 1. inti map canvas
|
|||
|
|
this->map_canvas = new QgsMapCanvas();
|
|||
|
|
this->setCentralWidget((this->map_canvas));
|
|||
|
|
|
|||
|
|
// 2. map tool pan
|
|||
|
|
this->map_tool_pan = new QgsMapToolPan(this->map_canvas);
|
|||
|
|
this->map_canvas->setMapTool(this->map_tool_pan);
|
|||
|
|
|
|||
|
|
// 3. map layer manager
|
|||
|
|
this->map_layerTreeView =new QgsLayerTreeView(this);
|
|||
|
|
// 4. create map model
|
|||
|
|
this->map_layerModel = new QgsLayerTreeModel(QgsProject::instance()->layerTreeRoot(), this);
|
|||
|
|
this->map_layerModel->setFlag(QgsLayerTreeModel::AllowNodeRename); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
this->map_layerModel->setFlag(QgsLayerTreeModel::AllowNodeReorder); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
this->map_layerModel->setFlag(QgsLayerTreeModel::AllowNodeChangeVisibility); // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ɼ<EFBFBD><C9BC><EFBFBD>
|
|||
|
|
this->map_layerModel->setFlag(QgsLayerTreeModel::ShowLegendAsTree); // <20><><EFBFBD><EFBFBD>״ͼ<D7B4><CDBC>ʾͼ<CABE><CDBC>
|
|||
|
|
this->map_layerModel->setAutoCollapseLegendNodes(10); // <20>Զ<EFBFBD><D4B6>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
this->map_layerTreeView->setModel(this->map_layerModel);
|
|||
|
|
// create bridge between mapcontrol and layer
|
|||
|
|
this->map_layer_Bridge = new QgsLayerTreeMapCanvasBridge(QgsProject::instance()->layerTreeRoot(), this->map_canvas, this);
|
|||
|
|
|
|||
|
|
|
|||
|
|
// layer <20><><EFBFBD><EFBFBD>
|
|||
|
|
// 1. <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>QDockWidget<65><74>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ
|
|||
|
|
this->layerTreeDock =new QDockWidget(tr(u8"ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), this);
|
|||
|
|
this->layerTreeDock->setWidget(this->map_layerTreeView);
|
|||
|
|
|
|||
|
|
// 2. <20><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ(m_layerTreeView)<29><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|||
|
|
layerTreeDock->setWidget(this->map_layerTreeView);
|
|||
|
|
|
|||
|
|
// 3. (<28><>ѡ<EFBFBD><D1A1><EFBFBD>Ƽ<EFBFBD>)<29><><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
layerTreeDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 5. <20><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
this->addDockWidget(Qt::LeftDockWidgetArea, this->layerTreeDock);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|