增加了DEM->PointCloud 功能
parent
e90822a5fb
commit
d4123c36a8
|
@ -107,6 +107,7 @@ if (POLICY CMP0091)
|
|||
cmake_policy(SET CMP0091 NEW)
|
||||
endif (POLICY CMP0091)
|
||||
if(MSVC)
|
||||
add_definitions(-D_USE_MATH_DEFINES)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||
|
@ -256,7 +257,7 @@ find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
|||
|
||||
|
||||
# QGIS 库 作为遥感数据操作,这个是插件库,如果不编译插件库,可以不用考虑这个库,注意这个库是由源代码构建,建议不要动
|
||||
find_package(QGIS REQUIRED)
|
||||
#find_package(QGIS REQUIRED)
|
||||
|
||||
message("CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}")
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ set(SOVERSION ${PROJECT_VERSION} ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINO
|
|||
#-----------------------------------------------------------------------------
|
||||
list(APPEND _libraries BaseCppLibrary Common PythonModule SARibbonBar Settings DataProperty MeshData SelfDefObject Material Geometry BCBase ConfigOptions ParaClassFactory ModelData ModuleBase PostAlgorithm PostRenderData PostInterface PostCurveDataManager PostPlotWidget PostWidgets GeometryDataExchange ProjectTree ProjectTreeExtend GeometryCommand GeometryWidgets PluginManager GmshModule IO SolverControl MainWidgets UserGuidence)
|
||||
list(APPEND _libraries PointCloudOperator)
|
||||
list(APPEND _libraries json qcustomplot qhexedit qscintilla2 llqgisbaselib)
|
||||
list(APPEND _libraries json qcustomplot qhexedit qscintilla2 )
|
||||
|
||||
#[[if(_WIN_)
|
||||
list(APPEND _libraries XGenerateReport License)
|
||||
|
@ -33,7 +33,7 @@ list(APPEND LAMPCAE_Runtimes_Libraries Qt5::Qml Qt5::Network )
|
|||
list(APPEND LAMPCAE_Runtimes_Libraries
|
||||
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||
QGIS::App QGIS::Core QGIS::Gui QGIS::Analysis
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreateCone</class>
|
||||
<widget class="QDialog" name="CreateCone">
|
||||
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>307</height>
|
||||
<height>367</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -75,7 +75,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxR2">
|
||||
<property name="suffix">
|
||||
<string>mm</string>
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000000000000004384584304507619735463404765184.000000000000000</double>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxL">
|
||||
<property name="suffix">
|
||||
<string>mm</string>
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000000000.000000000000000</double>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxR">
|
||||
<property name="suffix">
|
||||
<string>mm</string>
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999999999999932209486743616279764617084419440640.000000000000000</double>
|
||||
|
|
|
@ -288,6 +288,11 @@ namespace MainWidget
|
|||
}
|
||||
void ControlPanel::setplotTab(bool flag) {
|
||||
_ui->projectTab->setTabVisible(4, flag);
|
||||
|
||||
}
|
||||
size_t ControlPanel::getTabCount()
|
||||
{
|
||||
return _ui->projectTab->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace MainWidget
|
|||
// 关闭绘图接口
|
||||
void setplotTab(bool flag);
|
||||
|
||||
size_t getTabCount();
|
||||
Post::PostTreeWidget *getPostTreeWidget();
|
||||
public slots:
|
||||
//鼠标点击事件,包括左键单击双击及右键菜单
|
||||
|
|
|
@ -166,8 +166,6 @@ namespace GUI {
|
|||
QApplication::applicationDirPath() + "/customization.xml";
|
||||
sa_apply_customize_from_xml_file(strCostomizePath, this, m_ribbonActionMgr);
|
||||
}
|
||||
|
||||
|
||||
// 控制菜单,这些功能后期开发仿真算法之后,再开放功能
|
||||
{
|
||||
qDebug()<< " V1.2";
|
||||
|
@ -178,8 +176,8 @@ namespace GUI {
|
|||
_controlPanel->setphysicsTab(false);
|
||||
_controlPanel->setpostTab(false);
|
||||
_controlPanel->setplotTab(false);
|
||||
qDebug()<<"_controlPaneld has tab : "+QString::number(_controlPanel->getTabCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -273,6 +271,7 @@ namespace GUI {
|
|||
connect(_ui->actionPCLGuassFilter,SIGNAL(triggered()),this,SLOT(on_pclGuassFilter()));
|
||||
connect(_ui->actionPCLBilateralFilter,SIGNAL(triggered()),this,SLOT(on_pclBilateralFilter()));
|
||||
connect(_ui->actionPCLGPMesh,SIGNAL(triggered()),this,SLOT(on_pclGPMesh()));
|
||||
|
||||
connect(_ui->actionPCLPoissonMesh,SIGNAL(triggered()),this,SLOT(on_pclPoissonMesh()));
|
||||
// feko 参数
|
||||
connect(_ui->actionImageSetting,SIGNAL(triggered()),this,SLOT(on_actionImageSetting()));
|
||||
|
|
|
@ -153,11 +153,6 @@ namespace GUI {
|
|||
// Ribbon Customize
|
||||
SARibbonActionsManager* getActionManager();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
/*更新注册接口*/
|
||||
void updateInterfaces();
|
||||
|
@ -508,6 +503,7 @@ namespace GUI {
|
|||
//
|
||||
void setPostAnimationToolBar(bool ribbon);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief ui
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QMdiArea>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
class QMdiSubWindow;
|
||||
class QMdiArea;
|
||||
//class QMdiArea;
|
||||
class QToolBar;
|
||||
class SARibbonCategory;
|
||||
|
||||
|
@ -89,8 +91,6 @@ namespace GUI {
|
|||
void clearSelectModelSig();
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/*打开前处理窗口 */
|
||||
|
@ -159,7 +159,7 @@ namespace GUI {
|
|||
QHash<QMdiSubWindow*, Post::RealTimeWindowBase*> _realTimeWindow{};
|
||||
QHash<QMdiSubWindow*, XReport::ReportWindow*> _reportWindow{};
|
||||
QPair<QMdiSubWindow*, GenerateGeometry::GenerateGeometryWidget*> _geometryWindow{};
|
||||
// QHash<QMdiSubWindow*, GenerateGeometry::GenerateGeometryWidget*> _geometryWindow{};
|
||||
// QHash<QMdiSubWindow*, GenerateGeometry::GenerateGeometryWidget*> _geometryWindow{};
|
||||
|
||||
QList<QToolBar*> _currentToolBars{};
|
||||
SARibbonCategory* _threeD_render_page{};
|
||||
|
|
|
@ -61,7 +61,8 @@ namespace ModuleBase
|
|||
: _ui(new Ui::Graph3DWindow), GraphWindowBase(mainwindow, id, type, connentToMainWindow)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
setMouseTracking(true); // 启用鼠标跟踪,以便能够捕获鼠标进入事件
|
||||
setAttribute(Qt::WA_Hover); // 启用悬停事件,以便能够在鼠标悬停时获取焦点
|
||||
init();
|
||||
_render->GlobalWarningDisplayOff();
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Settings/BusAPI.h"
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QDebug>
|
||||
namespace Plugins
|
||||
{
|
||||
PluginManageDialog::PluginManageDialog(GUI::MainWindow *mw, PluginManager *m)
|
||||
|
@ -146,8 +146,10 @@ namespace Plugins
|
|||
QStringList failins;
|
||||
for (QString name : selectedNames)
|
||||
{
|
||||
qDebug()<< QString("check loading plugin :")+name;
|
||||
if (!commonList.contains(name))
|
||||
{
|
||||
qDebug()<< QString("start loading plugin :")+name;
|
||||
bool ok = _manager->loadPlugin(name);
|
||||
if (!ok)
|
||||
{
|
||||
|
|
|
@ -85,55 +85,35 @@ namespace Plugins {
|
|||
typedef void (*Reg)(GUI::MainWindow*, QList<Plugins::PluginBase*>*);
|
||||
Reg fun = nullptr;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if(!pluginname.toLower().startsWith("plugin"))
|
||||
return false;
|
||||
if(!pluginname.toLower().endsWith(".dll"))
|
||||
return false;
|
||||
|
||||
qDebug() << "loading Plugin dll : " << plugpath;
|
||||
HMODULE hmodel = LoadLibrary(LPCWSTR(plugpath.utf16()));
|
||||
qDebug()<<"Error Code :"+QString::number(GetLastError());
|
||||
if(hmodel) {
|
||||
fun = (Reg)GetProcAddress(hmodel, "Register");
|
||||
if(fun) {
|
||||
fun(_mainWindow, &_pluginList);
|
||||
Plugins::PluginBase* pls = _pluginList.last();
|
||||
qDebug() << "Plugin: " << pls->getDescribe();
|
||||
qDebug() << "loading Plugin: " << pls->getDescribe();
|
||||
pls->install();
|
||||
pls->setFileName(pluginname);
|
||||
pls->setWinModule(hmodel);
|
||||
pls->reTranslate(lang);
|
||||
qDebug() << "loading Plugin finished : " << pls->getDescribe();
|
||||
} else {
|
||||
FreeLibrary(hmodel);
|
||||
qDebug() << "do not find Register function Plugin: " << plugpath;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else{
|
||||
qDebug() << "loading Plugin dll Failure: " << plugpath;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
if(!pluginname.toLower().startsWith("libplugin"))
|
||||
return false;
|
||||
if(!pluginname.toLower().endsWith(".so"))
|
||||
return false;
|
||||
void* pHandle = dlopen(plugpath.toLatin1().data(), RTLD_NOW);
|
||||
if(!pHandle) {
|
||||
qDebug() << "dlopen error: " << dlerror();
|
||||
return false;
|
||||
}
|
||||
fun = (Reg)dlsym(pHandle, "Register");
|
||||
if(fun) {
|
||||
fun(_mainWindow, &_pluginList);
|
||||
Plugins::PluginBase* pls = _pluginList.last();
|
||||
qDebug() << "Plugin: " << pls->getDescribe();
|
||||
pls->install();
|
||||
pls->setFileName(pluginname);
|
||||
pls->setLinuxModule(pHandle);
|
||||
pls->reTranslate(lang);
|
||||
} else {
|
||||
// plugins.removeOne(pluginname);
|
||||
dlclose(pHandle);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
emit updateActionStates();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace MeshData
|
|||
vtkSmartPointer<vtkUnstructuredGridWriter> writer = vtkSmartPointer<vtkUnstructuredGridWriter>::New();
|
||||
writer->SetInputData(ungird);
|
||||
writer->SetFileTypeToBinary();
|
||||
writer->SetFileName(ba);
|
||||
writer->SetFileName(_fileName.toLocal8Bit().constData());
|
||||
writer->Write();
|
||||
return true;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ namespace MeshData
|
|||
writer->SetInputConnection(cellToPointFilter->GetOutputPort());
|
||||
// writer->SetInputData(ungird);
|
||||
writer->SetFileTypeToBinary();
|
||||
writer->SetFileName(ba);
|
||||
writer->SetFileName(_fileName.toLocal8Bit().constData());
|
||||
writer->Write();
|
||||
qDebug()<<" VTKdataExchange::writeSTL finish !!!! "+ba;
|
||||
QFile outfile(_fileName);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/PluginRasterTool.iml" filepath="$PROJECT_DIR$/.idea/PluginRasterTool.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -21,6 +21,36 @@ include_directories(C:/PCL/include/pcl-1.14)
|
|||
# qt5
|
||||
include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml)
|
||||
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
# boost
|
||||
include_directories(D:/vcpkg/installed/x64-windows/include)
|
||||
|
||||
# pcl
|
||||
include_directories(C:/PCL/3rdParty/FLANN/include)
|
||||
include_directories(C:/PCL/3rdParty/VTK/include/vtk-9.3)
|
||||
include_directories(C:/PCL/include/pcl-1.14)
|
||||
|
||||
# qt5
|
||||
include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml)
|
||||
|
||||
# json
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../json)
|
||||
|
||||
# 内部结构
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SqliteDBProcess/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/modelProcess)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/EchoShowProcess)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/OCCViewer)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/PointCloudProcess)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SharedModuleLib)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/TableProcess)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/TaskXml)
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接库
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -35,7 +65,9 @@ link_directories("C:/PCL/lib")
|
|||
# 自动添加include目录
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +75,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
# 添加资源文件
|
||||
#-----------------------------------------------------------------------------
|
||||
set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/qianfan.qrc")
|
||||
#set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc")
|
||||
set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc")
|
||||
qt5_add_resources(_resource ${_qrc} ${_lang})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -62,6 +94,8 @@ add_library(PluginRasterTool
|
|||
${_interface}
|
||||
${_header}
|
||||
${_source}
|
||||
RasterDataClass.cpp
|
||||
RasterDataClass.h
|
||||
)
|
||||
|
||||
|
||||
|
@ -74,10 +108,16 @@ link_directories("C:/PCL/3rdParty/FLANN/lib")
|
|||
link_directories("C:/VTK/lib")
|
||||
link_directories("C:/PCL/lib")
|
||||
|
||||
# QGIS 库 作为遥感数据操作,这个是插件库,如果不编译插件库,可以不用考虑这个库,注意这个库是由源代码构建,建议不要动
|
||||
#find_package(QGIS REQUIRED)
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization)
|
||||
find_package(PCL )
|
||||
# QGIS 库 作为遥感数据操作,这个是插件库,如果不编译插件库,可以不用考虑这个库,注意这个库是由源代码构建,建议不要动
|
||||
find_package(QGIS REQUIRED)
|
||||
|
||||
#gdal
|
||||
find_package(GDAL REQUIRED)
|
||||
include_directories(${GDAL_INCLUDE_DIRS})
|
||||
link_directories(${GDAL_LIBRARIES})
|
||||
|
||||
# boost
|
||||
include_directories(D:/vcpkg/installed/x64-windows/include)
|
||||
|
@ -93,28 +133,34 @@ link_directories(${PCL_LIBRARY_DIRS})
|
|||
add_definitions(${PCL_DEFINITIONS})
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加接口声明宏
|
||||
#-----------------------------------------------------------------------------
|
||||
target_compile_definitions(PluginRasterTool PRIVATE "NOMINMAX") # 禁用vc++ 中的min max 定义,避免与 pcl 的中 std::min,pcl::max 函数冲突
|
||||
target_compile_definitions(PluginRasterTool PRIVATE "RASTERTOOLPLUGIN_API")
|
||||
target_compile_definitions(PluginRasterTool PRIVATE "LLQIGSBASELIB_API")
|
||||
|
||||
|
||||
list(APPEND _depend_library
|
||||
llqgisbaselib Common PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow)
|
||||
|
||||
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
LAMPCAE::CGNS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
|
||||
QGIS::App QGIS::Core QGIS::Gui QGIS::Analysis
|
||||
Common PointCloudOperator Settings PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow
|
||||
)
|
||||
|
||||
# 添加 点云 pcl
|
||||
list(APPEND _runtimes_libraries
|
||||
|
||||
GDAL::GDAL
|
||||
)
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
|
||||
# QGIS::App QGIS::Core QGIS::Gui QGIS::Analysis
|
||||
)
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
Qt5::Network Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Gui Qt5::Svg Qt5::Widgets Qt5::Qml Qt5::DataVisualization Qt5::Charts Qt5::PrintSupport Qt5::Test
|
||||
)
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::TKFillet OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||
)
|
||||
|
||||
# 添加 VTK
|
||||
list(APPEND _runtimes_libraries
|
||||
|
@ -127,7 +173,7 @@ list(APPEND _runtimes_libraries
|
|||
target_link_libraries(PluginRasterTool PRIVATE
|
||||
${_runtimes_libraries}
|
||||
${_depend_library}
|
||||
${PCL_LIBRARIES}
|
||||
# ${PCL_LIBRARIES}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -151,4 +197,6 @@ set_target_properties(PluginRasterTool
|
|||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* @file QGISRasterManaget.cpp
|
||||
* @brief None
|
||||
* @author 陈增辉 (3045316072@qq.com)
|
||||
* @version 2.5.0
|
||||
* @date 24-5-27
|
||||
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||
*/
|
||||
|
||||
#include "QGISRasterManager.h"
|
||||
|
||||
namespace RasterShowTool {
|
||||
|
||||
|
||||
void QGISRasterManager::initialize(){
|
||||
|
||||
}
|
||||
QGISRasterManager::~QGISRasterManager() {
|
||||
|
||||
}
|
||||
QGISRasterManager::QGISRasterManager(QObject* parent, GUI::MainWindow* m): {
|
||||
this->m=m;
|
||||
mApp = ll_qgis_base_lib::Instance();
|
||||
mApp->initialize(this->m);
|
||||
}
|
||||
|
||||
} // namespace RasterShowTool
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* @file QGISRasterManaget.h
|
||||
* @brief None
|
||||
* @author 陈增辉 (3045316072@qq.com)
|
||||
* @version 2.5.0
|
||||
* @date 24-5-27
|
||||
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef LAMPCAE_QGISRASTERMANAGER_H
|
||||
#define LAMPCAE_QGISRASTERMANAGER_H
|
||||
#include "RasterToolPluginAPI.h"
|
||||
#include <QObject>
|
||||
#include "MainWindow/MainWindow.h"
|
||||
#include "llqgisbaselib/ll_qgis_base_lib.h"
|
||||
|
||||
namespace RasterShowTool {
|
||||
|
||||
class RASTERTOOLPLUGINAPI QGISRasterManager :public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QGISRasterManager(QObject* parent,GUI::MainWindow* m) ;
|
||||
~QGISRasterManager() ;
|
||||
static inline QGISRasterManager *instance() { return sm_instance; };
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
static QGISRasterManager* sm_instance;
|
||||
GUI::MainWindow* m;
|
||||
ll_qgis_base_lib *mApp = nullptr; // 包含stack + mapviewer
|
||||
|
||||
};
|
||||
|
||||
} // namespace RasterShowTool
|
||||
|
||||
#endif // LAMPCAE_QGISRASTERMANAGER_H
|
|
@ -1,40 +1,26 @@
|
|||
#include "RasterToolPlugin.h"
|
||||
//#include "ll_qgis_base_lib.h"
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include "RasterToolBoxActions.h"
|
||||
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
GUI::MainWindow* RasterShowTool::RasterToolPlugin::_mainwindow = nullptr;
|
||||
|
||||
namespace RasterShowTool {
|
||||
GUI::MainWindow* RasterTool::RasterToolPlugin::_mainwindow = nullptr;
|
||||
namespace RasterTool {
|
||||
RasterToolPlugin::RasterToolPlugin(GUI::MainWindow* m)
|
||||
{
|
||||
_describe = "MeshDataExchangePlugin Installed Successfully";
|
||||
_describe = "RasterToolPlugin Installed Successfully";
|
||||
_mainwindow = m;
|
||||
|
||||
// 初始化控制
|
||||
|
||||
|
||||
|
||||
|
||||
// 添加界面
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 界面绑定
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(_mainwindow,SIGNAL(on_actionImageShowToolTriggleSIGNAL(GUI::MainWindow* )),this,SLOT(RasterToolLoading(GUI::MainWindow*)));
|
||||
}
|
||||
|
||||
bool RasterToolPlugin::install()
|
||||
{
|
||||
qDebug()<<"RasterToolPlugin install RasterToolPlugin::install ";
|
||||
BindingQGISMapAndCAE(_mainwindow);
|
||||
BindingToolBox(_mainwindow);
|
||||
qDebug()<<"Base on QGIS has binding ";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -49,11 +35,34 @@ namespace RasterShowTool {
|
|||
{
|
||||
return _mainwindow;
|
||||
}
|
||||
} // namespace MeshData
|
||||
void RasterToolPlugin::RasterToolLoading(GUI::MainWindow* m) {
|
||||
|
||||
qDebug()<<"RasterToolPlugin loading sucessfully";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
|
||||
{
|
||||
Plugins::PluginBase* p = new RasterShowTool::RasterToolPlugin(m);
|
||||
ps->append(p);
|
||||
}
|
||||
qDebug()<<"RasterToolPlugin install RasterToolPlugin::install start Register";
|
||||
Plugins::PluginBase* p_meshdataExchangeplugin = new RasterTool::RasterToolPlugin(m);
|
||||
ps->append(p_meshdataExchangeplugin);
|
||||
qDebug()<<"RasterToolPlugin install RasterToolPlugin::install finish Register";
|
||||
|
||||
}
|
||||
void RASTERTOOLPLUGINAPI BindingQGISMapAndCAE(GUI::MainWindow* m) {
|
||||
qDebug()<<"Banding QGIS and CAE init ";
|
||||
|
||||
|
||||
qDebug()<<"Banding QGIS and CAE finished !!";
|
||||
}
|
||||
void RASTERTOOLPLUGINAPI BindingToolBox(GUI::MainWindow* m) {
|
||||
if(nullptr==m||nullptr==m->menuBar()){
|
||||
qDebug()<<"BindingToolBox";
|
||||
return ; // 判定失败
|
||||
}else{
|
||||
LAMPToolBox::RasterToolBox* demtoolbox=new LAMPToolBox::RasterToolBox;
|
||||
demtoolbox->initMainWindows(m);
|
||||
}
|
||||
//
|
||||
}
|
||||
|
|
|
@ -3,34 +3,36 @@
|
|||
|
||||
#include "RasterToolPluginAPI.h"
|
||||
#include "PluginManager/pluginBase.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "MainWindow/MainWindow.h"
|
||||
|
||||
namespace RasterShowTool
|
||||
{
|
||||
namespace RasterTool {
|
||||
|
||||
|
||||
class RASTERTOOLPLUGINAPI RasterToolPlugin : public Plugins::PluginBase
|
||||
{
|
||||
public:
|
||||
RasterToolPlugin(GUI::MainWindow* m);
|
||||
~RasterToolPlugin() = default;
|
||||
class RASTERTOOLPLUGINAPI RasterToolPlugin : public Plugins::PluginBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RasterToolPlugin(GUI::MainWindow* m);
|
||||
~RasterToolPlugin() = default;
|
||||
|
||||
bool install();
|
||||
bool uninstall();
|
||||
void reTranslate(QString);
|
||||
static GUI::MainWindow* getMWpt();
|
||||
|
||||
private:
|
||||
static GUI::MainWindow* _mainwindow;
|
||||
bool install();
|
||||
bool uninstall();
|
||||
void reTranslate(QString);
|
||||
static GUI::MainWindow* getMWpt();
|
||||
public slots:
|
||||
void RasterToolLoading(GUI::MainWindow* m);
|
||||
private:
|
||||
static GUI::MainWindow* _mainwindow;
|
||||
};
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void RASTERTOOLPLUGINAPI Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* plugs);
|
||||
//函数返回值是无效的,不要通过返回值判断
|
||||
|
||||
void RASTERTOOLPLUGINAPI BindingQGISMapAndCAE(GUI::MainWindow* m);
|
||||
|
||||
// 绑定常用工具箱
|
||||
void RASTERTOOLPLUGINAPI BindingToolBox(GUI::MainWindow* m);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -115,6 +115,10 @@ link_directories("C:/PCL/lib")
|
|||
find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization)
|
||||
find_package(PCL )
|
||||
|
||||
#gdal
|
||||
find_package(GDAL REQUIRED)
|
||||
include_directories(${GDAL_INCLUDE_DIRS})
|
||||
link_directories(${GDAL_LIBRARIES})
|
||||
|
||||
# boost
|
||||
include_directories(D:/vcpkg/installed/x64-windows/include)
|
||||
|
@ -132,8 +136,8 @@ add_definitions(${PCL_DEFINITIONS})
|
|||
# qwt
|
||||
include_directories(${Qwt_INCLUDE_DIRS})
|
||||
link_directories(${Qwt_LIBRARY_DIRS})
|
||||
|
||||
|
||||
# gdal
|
||||
include_directories(${GDAL_INCLUDE_DIRS})
|
||||
message("qwt dir ${Qwt_INCLUDE_DIRS}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -158,6 +162,7 @@ list(APPEND _depend_library
|
|||
)
|
||||
|
||||
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
LAMPCAE::CGNS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml LAMPCAE::QWT LAMPCAE::QWTPOLAR
|
||||
)
|
||||
|
@ -168,7 +173,7 @@ list(APPEND _runtimes_libraries
|
|||
)
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::TKFillet OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::TKFillet OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||
)
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
|
|
|
@ -134,13 +134,13 @@ namespace MainWidget {
|
|||
if (dlg.exec() != QFileDialog::FileName)
|
||||
return;
|
||||
|
||||
QString aSuffix = dlg.selectedNameFilter();
|
||||
QString aFileName = dlg.selectedFiles().join(",");
|
||||
if (!(aFileName.isEmpty())) {
|
||||
filepath = aFileName;
|
||||
QString aSuffix = dlg.selectedNameFilter();
|
||||
QString aFileName = dlg.selectedFiles().join(",");
|
||||
if (!(aFileName.isEmpty())) {
|
||||
filepath = aFileName;
|
||||
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
AbFileName = filepath;
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ using namespace Eigen;
|
|||
std::shared_ptr<GDALDataset> OpenDataset(const QString& in_path,GDALAccess rwmode)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDataset* dataset_ptr = (GDALDataset*)(GDALOpen(in_path.toUtf8().constData(), rwmode));
|
||||
std::shared_ptr<GDALDataset> rasterDataset(dataset_ptr, CloseDataset);
|
||||
return rasterDataset;
|
||||
|
@ -66,6 +68,8 @@ int ENVI2TIFF(QString in_envi_path, QString out_tiff_path)
|
|||
int CreateDataset(QString new_file_path,int height, int width, int band_num,double* gt, QString projection, GDALDataType gdal_dtype ,bool need_gt)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
|
||||
std::shared_ptr< GDALDataset> poDstDS(poDriver->Create(new_file_path.toUtf8().constData(), width, height, band_num, gdal_dtype, NULL));
|
||||
if (need_gt)
|
||||
|
@ -81,6 +85,8 @@ int CreateDataset(QString new_file_path,int height, int width, int band_num,d
|
|||
int saveDataset(QString new_file_path, int start_line,int start_cols ,int band_ids, int datacols,int datarows,void* databuffer)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
std::shared_ptr<GDALDataset> poDstDS = OpenDataset(new_file_path,GA_Update);
|
||||
GDALDataType gdal_datatype = poDstDS->GetRasterBand(1)->GetRasterDataType();
|
||||
poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_cols, start_line, datacols, datarows, databuffer, datacols, datarows, gdal_datatype, 0, 0);
|
||||
|
@ -369,7 +375,8 @@ GDALDataType getGDALDataType(QString fileptah)
|
|||
omp_init_lock(&lock);
|
||||
omp_set_lock(&lock);
|
||||
GDALAllRegister();
|
||||
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(fileptah.toUtf8().constData(), GA_ReadOnly));//锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
|
||||
|
||||
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
|
||||
|
@ -402,7 +409,9 @@ gdalImage::gdalImage(const QString& raster_path)
|
|||
omp_set_lock(&lock); //锟斤拷没斤拷锟?1锟?7
|
||||
this->img_path = raster_path;
|
||||
|
||||
GDALAllRegister();// 注绞斤拷斤拷锟?1锟?7
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");// 注绞斤拷斤拷锟?1锟?7
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
// 锟斤拷DEM影锟斤拷
|
||||
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(raster_path.toUtf8().constData(), GA_ReadOnly));//锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
|
||||
this->width = rasterDataset->GetRasterXSize();
|
||||
|
@ -463,7 +472,7 @@ Eigen::MatrixXd gdalImage::getData(int start_row, int start_col, int rows_count,
|
|||
omp_init_lock(&lock);
|
||||
omp_set_lock(&lock);
|
||||
GDALAllRegister();
|
||||
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly));//锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
|
||||
|
||||
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
|
||||
|
@ -606,6 +615,8 @@ void gdalImage::saveImage(Eigen::MatrixXd data, int start_row = 0, int start_col
|
|||
throw exception(tip.toUtf8().constData());
|
||||
}
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
|
||||
GDALDataset* poDstDS = nullptr;
|
||||
if (exists_test(this->img_path)) {
|
||||
|
@ -655,7 +666,8 @@ void gdalImage::saveImage()
|
|||
|
||||
void gdalImage::setNoDataValue(double nodatavalue = -9999, int band_ids = 1)
|
||||
{
|
||||
GDALAllRegister();// 注绞斤拷斤拷锟?1锟?7
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");// 注绞斤拷斤拷锟?1锟?7
|
||||
//GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
|
||||
GDALDataset* poDstDS = (GDALDataset*)(GDALOpen(img_path.toUtf8().constData(), GA_Update));
|
||||
poDstDS->GetRasterBand(band_ids)->SetNoDataValue(nodatavalue);
|
||||
|
@ -772,7 +784,8 @@ GDALRPCInfo gdalImage::getRPC()
|
|||
{
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
|
||||
CPLSetConfigOption("GDAL_DATA", "./data");
|
||||
GDALAllRegister();//注斤拷锟斤拷
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");//注斤拷锟斤拷
|
||||
//斤拷锟斤拷
|
||||
GDALDataset* pDS = (GDALDataset*)GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly);
|
||||
//锟斤拷元斤拷锟叫伙拷取RPC锟斤拷息
|
||||
|
@ -807,7 +820,8 @@ Eigen::MatrixXd gdalImage::getLandPoint(Eigen::MatrixXd points)
|
|||
|
||||
Eigen::MatrixXd gdalImage::getHist(int bandids)
|
||||
{
|
||||
GDALAllRegister();// 注绞斤拷斤拷锟?1锟?7
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");// 注绞斤拷斤拷锟?1锟?7
|
||||
// 锟斤拷DEM影锟斤拷
|
||||
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly));//锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
|
||||
|
||||
|
@ -845,7 +859,8 @@ gdalImage CreategdalImage(const QString& img_path, int height, int width, int
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
GDALAllRegister();// 注锟斤拷锟绞斤拷锟斤拷锟斤拷锟?1锟?7
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");// 注锟斤拷锟绞斤拷锟斤拷锟斤拷锟?1锟?7
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
|
||||
GDALDataset* poDstDS = poDriver->Create(img_path.toUtf8().constData(), width, height, band_num, GDT_Float32, NULL); // 锟斤拷锟斤拷锟斤拷
|
||||
if (need_gt) {
|
||||
|
@ -883,6 +898,7 @@ gdalImageComplex CreategdalImageComplex(const QString& img_path, int height,
|
|||
}
|
||||
}
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
|
||||
GDALDataset* poDstDS = poDriver->Create(img_path.toUtf8().constData(), width, height, band_num, GDT_CFloat64, NULL);
|
||||
if (need_gt) {
|
||||
|
@ -911,6 +927,7 @@ gdalImageComplex CreategdalImageComplex(const QString& img_path, int height,
|
|||
int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int new_width, int new_height, GDALResampleAlg eResample)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
|
||||
GDALDataset* pDSrc = (GDALDataset*)GDALOpen(pszSrcFile, GA_ReadOnly);
|
||||
if (pDSrc == NULL)
|
||||
|
@ -1017,6 +1034,7 @@ int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt,
|
|||
int ResampleGDALs(const char* pszSrcFile, int band_ids, GDALRIOResampleAlg eResample)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
|
||||
GDALDataset* pDSrc = (GDALDataset*)GDALOpen(pszSrcFile, GA_Update);
|
||||
if (pDSrc == NULL)
|
||||
|
@ -1096,7 +1114,8 @@ gdalImageComplex::gdalImageComplex(const QString& raster_path)
|
|||
omp_set_lock(&lock);
|
||||
this->img_path = raster_path;
|
||||
|
||||
GDALAllRegister();
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(raster_path.toUtf8().constData(), GA_ReadOnly));//锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
|
||||
this->width = rasterDataset->GetRasterXSize();
|
||||
this->height = rasterDataset->GetRasterYSize();
|
||||
|
@ -1150,6 +1169,7 @@ void gdalImageComplex::saveImage(Eigen::MatrixXcd data, int start_row, int start
|
|||
throw exception(tip.toUtf8().constData());
|
||||
}
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
|
||||
GDALDataset* poDstDS = nullptr;
|
||||
if (exists_test(this->img_path)) {
|
||||
|
@ -1198,6 +1218,7 @@ Eigen::MatrixXcd gdalImageComplex::getDataComplex(int start_row, int start_col,
|
|||
|
||||
GDALDataset* poDataset;
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
|
||||
// 打开TIFF文件
|
||||
poDataset = (GDALDataset*)GDALOpen(this->img_path.toUtf8().constData(), GA_ReadOnly);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
int Complex2dB(QString in_tiff, QString out_dB_path)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_tiff);
|
||||
int width = rasterDataset->GetRasterXSize();
|
||||
int height = rasterDataset->GetRasterYSize();
|
||||
|
@ -174,6 +175,7 @@ int Amplitude2dB(QString in_tiff, QString out_dB_path)
|
|||
{
|
||||
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_tiff);
|
||||
int width = rasterDataset->GetRasterXSize();
|
||||
int height = rasterDataset->GetRasterYSize();
|
||||
|
|
|
@ -42,6 +42,8 @@ int CalibrationSiglePolarSAR(QString out_path, QString in_sar_path, double ca
|
|||
int CalibrationComplex(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_sar_path);
|
||||
int width = rasterDataset->GetRasterXSize();
|
||||
int height = rasterDataset->GetRasterYSize();
|
||||
|
@ -205,6 +207,8 @@ int CalibrationComplex(const QString& out_path, const QString& in_sar_path, d
|
|||
int CalibrationComplex2dB(const QString& out_path, const QString& in_sar_path, double calibrationValue)
|
||||
{
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
|
||||
std::shared_ptr<GDALDataset> rasterDataset = OpenDataset(in_sar_path);
|
||||
int width = rasterDataset->GetRasterXSize();
|
||||
int height = rasterDataset->GetRasterYSize();
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace WBFZ {
|
|||
if(_mainwindow == nullptr)
|
||||
return false;
|
||||
PluginBase::install();
|
||||
DebugInfo("WBFZExchangePlugin::WBFZExchangePlugin has install\n ");
|
||||
DebugInfo("WBFZExchangePlugin::WBFZExchangePlugin has install PluginBase::install\n ");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace WBFZ
|
|||
bool uninstall();
|
||||
void reTranslate(QString);
|
||||
static GUI::MainWindow* getMWpt();
|
||||
|
||||
private:
|
||||
static GUI::MainWindow* _mainwindow;
|
||||
public slots:
|
||||
void pclStatisticalRemoveFilter(GUI::MainWindow* m);
|
||||
// 半径滤波
|
||||
|
@ -53,8 +54,7 @@ namespace WBFZ
|
|||
void actionImageShowToolShow(GUI::MainWindow* m);
|
||||
|
||||
void actionactionRCShowTool(GUI::MainWindow* m);
|
||||
private:
|
||||
static GUI::MainWindow* _mainwindow;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
#-----------------------------------------------------------------------------
|
||||
# 头文件搜索路径
|
||||
#-----------------------------------------------------------------------------
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
# qt5
|
||||
include_directories(C:/Qt/5.15.2/msvc2019_64/include/QtQml)
|
||||
|
||||
## json
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../json)
|
||||
|
||||
## qscintilla2
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexers)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/include)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/lexlib)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/Qt4Qt5)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla2/src)
|
||||
#
|
||||
## lamptool
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../LAMPTool/include)
|
||||
#
|
||||
## qcustomplot
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qcustomplot)
|
||||
#
|
||||
## qhexedit
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../qhexedit)
|
||||
|
||||
# boost
|
||||
include_directories(D:/vcpkg/installed/x64-windows/include)
|
||||
|
||||
# pcl
|
||||
include_directories(SYSTEM C:/PCL/3rdParty/FLANN/include)
|
||||
include_directories(SYSTEM C:/PCL/3rdParty/VTK/include/vtk-9.3)
|
||||
include_directories(SYSTEM C:/PCL/include/pcl-1.14)
|
||||
|
||||
# QGIS 库 作为遥感数据操作,这个是插件库,如果不编译插件库,可以不用考虑这个库,注意这个库是由源代码构建,建议不要动
|
||||
find_package(QGIS REQUIRED)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接库
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# pcl
|
||||
link_directories("C:/PCL/3rdParty/FLANN/lib")
|
||||
link_directories("C:/VTK/lib")
|
||||
link_directories("C:/PCL/lib")
|
||||
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
# 自动添加include目录
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Quick Sql Core Xml Opengl Gui Svg Xmlpatterns Uitools Widgets Qml Printsupport Sensors Quickwidgets Quick Concurrent Openglextensions Charts Datavisualization)
|
||||
find_package(PCL )
|
||||
find_package(Boost )
|
||||
include_directories(${PCL_INCLUDE_DIRS})
|
||||
include_directories(${QGIS_INCLUDE_DIR}) # 导入 QGIS
|
||||
link_directories(${PCL_LIBRARY_DIRS})
|
||||
add_definitions(${PCL_DEFINITIONS})
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加资源文件
|
||||
#-----------------------------------------------------------------------------
|
||||
set(_qrc "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/qianfan.qrc")
|
||||
#set(_lang "${CMAKE_CURRENT_SOURCE_DIR}/../qrc/translations.qrc")
|
||||
qt5_add_resources(_resource ${_qrc} ${_lang})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 源码扫描
|
||||
#-----------------------------------------------------------------------------
|
||||
file(GLOB _ui "*.ui")
|
||||
file(GLOB _header "*.h" "./Frameless/*.h")
|
||||
file(GLOB _source "*.cpp" "./Frameless/*.cpp")
|
||||
qt5_wrap_ui(_interface ${_ui})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加动态库目标
|
||||
#-----------------------------------------------------------------------------
|
||||
add_library(llqgisbaselib
|
||||
${_resource}
|
||||
${_interface}
|
||||
${_header}
|
||||
${_source}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加接口声明宏
|
||||
#-----------------------------------------------------------------------------
|
||||
target_compile_definitions(llqgisbaselib PRIVATE "LLQIGSBASELIB_API")
|
||||
target_compile_definitions(llqgisbaselib PRIVATE "_USE_MATH_DEFINES")
|
||||
|
||||
list(APPEND _depend_library
|
||||
Common PythonModule DataProperty MeshData Material Geometry BCBase ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GeometryCommand GeometryWidgets IO MainWidgets MainWindow)
|
||||
|
||||
|
||||
|
||||
list(APPEND _runtimes_libraries
|
||||
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersSources VTK::FiltersStatistics VTK::GUISupportQt VTK::IOCore VTK::IOImage VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingColor VTK::ImagingCore VTK::ImagingFourier VTK::ImagingGeneral VTK::ImagingHybrid VTK::ImagingMath VTK::ImagingSources VTK::InteractionStyle VTK::InteractionWidgets VTK::ParallelCore VTK::ParallelDIY VTK::RenderingAnnotation VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::jpeg VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib
|
||||
QGIS::App QGIS::Core QGIS::Gui QGIS::Analysis
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 安装Qt的依赖文件
|
||||
#-----------------------------------------------------------------------------
|
||||
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
|
||||
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 链接依赖库
|
||||
#-----------------------------------------------------------------------------
|
||||
target_link_libraries(llqgisbaselib PRIVATE
|
||||
${_runtimes_libraries}
|
||||
${_depend_library}
|
||||
${PCL_LIBRARIES}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加依赖关系
|
||||
#-----------------------------------------------------------------------------
|
||||
add_dependencies(llqgisbaselib ${_depend_library})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 添加运行时依赖关系
|
||||
#-----------------------------------------------------------------------------
|
||||
set(LAMPCAE_llqgisbaselib_Runtimes_Libraries ${_runtimes_libraries} PARENT_SCOPE)
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef LDGEOMETRY_H
|
||||
#define LDGEOMETRY_H
|
||||
|
||||
typedef struct _SGeometryInfo{
|
||||
int deviceId;
|
||||
int deviceType;
|
||||
int deviceBattery;
|
||||
|
||||
double latitude;
|
||||
|
||||
double longitude;
|
||||
|
||||
|
||||
double altitude;
|
||||
}SGeometryInfo;
|
||||
|
||||
typedef struct _SGeometryPoint{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double m;
|
||||
}SGeometryPoint;
|
||||
|
||||
#endif
|
|
@ -1,643 +0,0 @@
|
|||
#ifndef LDCOMMON_H
|
||||
#define LDCOMMON_H
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaProperty>
|
||||
|
||||
|
||||
|
||||
class SMarkerSymbolBase {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString offset MEMBER offset);
|
||||
Q_PROPERTY(QString offset_unit MEMBER offset_unit);
|
||||
Q_PROPERTY(QString offset_map_unit_scale MEMBER offset_map_unit_scale);
|
||||
Q_PROPERTY(QString size MEMBER size);
|
||||
Q_PROPERTY(QString size_unit MEMBER size_unit);
|
||||
Q_PROPERTY(QString size_map_unit_scale MEMBER size_map_unit_scale);
|
||||
Q_PROPERTY(QString horizontal_anchor_point MEMBER horizontal_anchor_point);
|
||||
Q_PROPERTY(QString vertical_anchor_point MEMBER vertical_anchor_point);
|
||||
public:
|
||||
QString size = QStringLiteral("1.0");
|
||||
QString size_unit;
|
||||
QString size_map_unit_scale;
|
||||
QString offset = QStringLiteral("0");
|
||||
QString offset_unit;
|
||||
QString offset_map_unit_scale;
|
||||
QString horizontal_anchor_point = QStringLiteral("0");
|
||||
QString vertical_anchor_point = QStringLiteral("0");
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolSimple : public SMarkerSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString name MEMBER name);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString scale_method MEMBER scale_method);
|
||||
Q_PROPERTY(QString outline_style MEMBER outline_style);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString cap_style MEMBER cap_style);
|
||||
public:
|
||||
QString name = QStringLiteral("circle");
|
||||
QString color = QStringLiteral("red");
|
||||
QString outline_color;
|
||||
QString joinstyle;
|
||||
QString angle;
|
||||
QString scale_method;
|
||||
QString outline_style;
|
||||
QString outline_width;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
QString cap_style;
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolSvg : public SMarkerSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString name MEMBER name);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString scale_method MEMBER scale_method);
|
||||
Q_PROPERTY(QString fixedAspectRatio MEMBER fixedAspectRatio);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
public:
|
||||
QString name;
|
||||
QString angle;
|
||||
QString scale_method;
|
||||
QString fixedAspectRatio;
|
||||
QString color;
|
||||
QString outline_color;
|
||||
QString outline_width;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolRaster : public SMarkerSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString imageFile MEMBER imageFile);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString scale_method MEMBER scale_method);
|
||||
public:
|
||||
QString imageFile;
|
||||
QString angle;
|
||||
QString scale_method;
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolAnimated : public SMarkerSymbolRaster{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString frameRate MEMBER frameRate)
|
||||
public:
|
||||
QString frameRate = "10";
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolEllipse : public SMarkerSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString symbol_name MEMBER symbol_name);
|
||||
Q_PROPERTY(QString symbol_width MEMBER symbol_width);
|
||||
Q_PROPERTY(QString symbol_width_unit MEMBER symbol_width_unit);
|
||||
Q_PROPERTY(QString symbol_width_map_unit_scale MEMBER symbol_width_map_unit_scale);
|
||||
Q_PROPERTY(QString symbol_height MEMBER symbol_height);
|
||||
Q_PROPERTY(QString symbol_height_unit MEMBER symbol_height_unit);
|
||||
Q_PROPERTY(QString symbol_height_map_unit_scale MEMBER symbol_height_map_unit_scale);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString outline_style MEMBER outline_style);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
Q_PROPERTY(QString cap_style MEMBER cap_style);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
|
||||
public:
|
||||
QString symbol_name;
|
||||
|
||||
QString symbol_width;
|
||||
QString symbol_width_unit;
|
||||
QString symbol_width_map_unit_scale;
|
||||
QString symbol_height;
|
||||
QString symbol_height_unit;
|
||||
QString symbol_height_map_unit_scale;
|
||||
QString angle;
|
||||
QString outline_style;
|
||||
QString joinstyle;
|
||||
QString cap_style;
|
||||
QString outline_width;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
QString color;
|
||||
QString outline_color;
|
||||
};
|
||||
|
||||
|
||||
class SMarkerSymbolFont : public SMarkerSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString font MEMBER font);
|
||||
Q_PROPERTY(QString chr MEMBER chr);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString font_style MEMBER font_style);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
|
||||
public:
|
||||
QString font = QStringLiteral("Dingbats");
|
||||
QString chr = QStringLiteral("%1").arg(QChar('A'));
|
||||
QString color = QStringLiteral("red");
|
||||
QString angle;
|
||||
QString font_style;
|
||||
QString outline_color;
|
||||
QString outline_width;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
QString joinstyle;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolBase {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString offset MEMBER offset)
|
||||
Q_PROPERTY(QString offset_unit MEMBER offset_unit)
|
||||
Q_PROPERTY(QString offset_map_unit_scale MEMBER offset_map_unit_scale)
|
||||
public:
|
||||
QString offset;
|
||||
QString offset_unit;
|
||||
QString offset_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolSimple : public SLineSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_style MEMBER outline_style);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString width_map_unit_scale MEMBER width_map_unit_scale);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
Q_PROPERTY(QString capstyle MEMBER capstyle);
|
||||
Q_PROPERTY(QString use_custom_dash MEMBER use_custom_dash);
|
||||
Q_PROPERTY(QString customdash MEMBER customdash);
|
||||
Q_PROPERTY(QString customdash_unit MEMBER customdash_unit);
|
||||
Q_PROPERTY(QString customdash_map_unit_scale MEMBER customdash_map_unit_scale);
|
||||
Q_PROPERTY(QString draw_inside_polygon MEMBER draw_inside_polygon);
|
||||
Q_PROPERTY(QString ring_filter MEMBER ring_filter);
|
||||
Q_PROPERTY(QString dash_pattern_offset MEMBER dash_pattern_offset);
|
||||
Q_PROPERTY(QString dash_pattern_offset_unit MEMBER dash_pattern_offset_unit);
|
||||
Q_PROPERTY(QString dash_pattern_offset_map_unit_scale MEMBER dash_pattern_offset_map_unit_scale);
|
||||
Q_PROPERTY(QString trim_distance_start MEMBER trim_distance_start);
|
||||
Q_PROPERTY(QString trim_distance_start_unit MEMBER trim_distance_start_unit);
|
||||
Q_PROPERTY(QString trim_distance_start_map_unit_scale MEMBER trim_distance_start_map_unit_scale);
|
||||
Q_PROPERTY(QString trim_distance_end MEMBER trim_distance_end);
|
||||
Q_PROPERTY(QString trim_distance_end_unit MEMBER trim_distance_end_unit);
|
||||
Q_PROPERTY(QString trim_distance_end_map_unit_scale MEMBER trim_distance_end_map_unit_scale);
|
||||
Q_PROPERTY(QString align_dash_pattern MEMBER align_dash_pattern);
|
||||
Q_PROPERTY(QString tweak_dash_pattern_on_corners MEMBER tweak_dash_pattern_on_corners);
|
||||
public:
|
||||
QString outline_color = QStringLiteral("red");
|
||||
QString outline_width = QStringLiteral("0.26");
|
||||
QString outline_style = QStringLiteral("solid");
|
||||
QString outline_width_unit;
|
||||
QString width_map_unit_scale;
|
||||
QString joinstyle;
|
||||
QString capstyle;
|
||||
QString use_custom_dash;
|
||||
QString customdash;
|
||||
QString customdash_unit;
|
||||
QString customdash_map_unit_scale;
|
||||
QString draw_inside_polygon;
|
||||
QString ring_filter;
|
||||
QString dash_pattern_offset;
|
||||
QString dash_pattern_offset_unit;
|
||||
QString dash_pattern_offset_map_unit_scale;
|
||||
QString trim_distance_start;
|
||||
QString trim_distance_start_unit;
|
||||
QString trim_distance_start_map_unit_scale;
|
||||
QString trim_distance_end;
|
||||
QString trim_distance_end_unit;
|
||||
QString trim_distance_end_map_unit_scale;
|
||||
QString align_dash_pattern;
|
||||
QString tweak_dash_pattern_on_corners;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolRaster : public SLineSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString line_width MEMBER line_width);
|
||||
Q_PROPERTY(QString line_width_unit MEMBER line_width_unit);
|
||||
Q_PROPERTY(QString width_map_unit_scale MEMBER width_map_unit_scale);
|
||||
Q_PROPERTY(QString imageFile MEMBER imageFile);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
Q_PROPERTY(QString capstyle MEMBER capstyle);
|
||||
Q_PROPERTY(QString alpha MEMBER alpha);
|
||||
public:
|
||||
QString line_width = QStringLiteral("0.26");
|
||||
QString line_width_unit;
|
||||
QString width_map_unit_scale;
|
||||
QString imageFile;
|
||||
QString joinstyle;
|
||||
QString capstyle;
|
||||
QString alpha = QStringLiteral("1");;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolMarker : public SLineSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString interval MEMBER interval);
|
||||
Q_PROPERTY(QString rotate MEMBER rotate);
|
||||
Q_PROPERTY(QString interval_unit MEMBER rotate);
|
||||
Q_PROPERTY(QString offset_along_line MEMBER rotate);
|
||||
Q_PROPERTY(QString offset_along_line_unit MEMBER rotate);
|
||||
Q_PROPERTY(QString offset_along_line_map_unit_scale MEMBER rotate);
|
||||
Q_PROPERTY(QString interval_map_unit_scale MEMBER rotate);
|
||||
Q_PROPERTY(QString average_angle_length MEMBER rotate);
|
||||
Q_PROPERTY(QString average_angle_unit MEMBER rotate);
|
||||
Q_PROPERTY(QString average_angle_map_unit_scale MEMBER rotate);
|
||||
Q_PROPERTY(QString placement MEMBER rotate);
|
||||
Q_PROPERTY(QString placements MEMBER rotate);
|
||||
Q_PROPERTY(QString ring_filter MEMBER rotate);
|
||||
Q_PROPERTY(QString place_on_every_part MEMBER rotate);
|
||||
|
||||
public:
|
||||
QString interval = QStringLiteral("3");
|
||||
QString rotate = QStringLiteral("1");
|
||||
QString interval_unit;
|
||||
QString offset_along_line;
|
||||
QString offset_along_line_unit;
|
||||
QString offset_along_line_map_unit_scale;
|
||||
QString interval_map_unit_scale;
|
||||
QString average_angle_length;
|
||||
QString average_angle_unit;
|
||||
QString average_angle_map_unit_scale;
|
||||
QString placement;
|
||||
QString placements;
|
||||
QString ring_filter;
|
||||
QString place_on_every_part;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolHashed : public SLineSymbolMarker{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString hash_angle MEMBER hash_angle);
|
||||
Q_PROPERTY(QString hash_length MEMBER hash_length);
|
||||
Q_PROPERTY(QString hash_length_unit MEMBER hash_length_unit);
|
||||
Q_PROPERTY(QString hash_length_map_unit_scale MEMBER hash_length_map_unit_scale);
|
||||
public:
|
||||
QString hash_angle;
|
||||
QString hash_length;
|
||||
QString hash_length_unit;
|
||||
QString hash_length_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolBurst : public SLineSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString line_width MEMBER line_width);
|
||||
Q_PROPERTY(QString line_width_unit MEMBER line_width_unit);
|
||||
Q_PROPERTY(QString width_map_unit_scale MEMBER width_map_unit_scale);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
Q_PROPERTY(QString capstyle MEMBER capstyle);
|
||||
Q_PROPERTY(QString color_type MEMBER color_type);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString gradient_color2 MEMBER gradient_color2);
|
||||
Q_PROPERTY(QString rampType MEMBER rampType);
|
||||
public:
|
||||
QString line_width = QStringLiteral("0.26");
|
||||
QString line_width_unit;
|
||||
QString width_map_unit_scale;
|
||||
QString joinstyle;
|
||||
QString capstyle;
|
||||
QString color_type = QStringLiteral("0");
|
||||
QString color = QStringLiteral("black");
|
||||
QString gradient_color2 = QStringLiteral("white");
|
||||
QString rampType;
|
||||
};
|
||||
|
||||
|
||||
class SLineSymbolArrow : public SLineSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString arrow_width MEMBER arrow_width);
|
||||
Q_PROPERTY(QString arrow_width_unit MEMBER arrow_width_unit);
|
||||
Q_PROPERTY(QString arrow_width_unit_scale MEMBER arrow_width_unit_scale);
|
||||
Q_PROPERTY(QString arrow_start_width MEMBER arrow_start_width);
|
||||
Q_PROPERTY(QString arrow_start_width_unit MEMBER arrow_start_width_unit);
|
||||
Q_PROPERTY(QString arrow_arrow_start_width_unit_scalewidth MEMBER arrow_arrow_start_width_unit_scalewidth);
|
||||
Q_PROPERTY(QString is_curved MEMBER is_curved);
|
||||
Q_PROPERTY(QString is_repeated MEMBER is_repeated);
|
||||
Q_PROPERTY(QString head_length MEMBER head_length);
|
||||
Q_PROPERTY(QString head_length_unit MEMBER head_length_unit);
|
||||
Q_PROPERTY(QString head_length_unit_scale MEMBER head_length_unit_scale);
|
||||
Q_PROPERTY(QString head_thickness MEMBER head_thickness);
|
||||
Q_PROPERTY(QString head_thickness_unit MEMBER head_thickness_unit);
|
||||
Q_PROPERTY(QString head_thickness_unit_scale MEMBER head_thickness_unit_scale);
|
||||
Q_PROPERTY(QString head_type MEMBER head_type);
|
||||
Q_PROPERTY(QString arrow_type MEMBER arrow_type);
|
||||
Q_PROPERTY(QString ring_filter MEMBER ring_filter);
|
||||
|
||||
public:
|
||||
QString arrow_width = QStringLiteral("1.0");
|
||||
QString arrow_width_unit;
|
||||
QString arrow_width_unit_scale;
|
||||
QString arrow_start_width= QStringLiteral("1.0");
|
||||
QString arrow_start_width_unit;
|
||||
QString arrow_arrow_start_width_unit_scalewidth;
|
||||
QString is_curved = QStringLiteral("1");
|
||||
QString is_repeated = QStringLiteral("1");;
|
||||
QString head_length= QStringLiteral("1.5");
|
||||
QString head_length_unit;
|
||||
QString head_length_unit_scale;
|
||||
QString head_thickness= QStringLiteral("1.5");
|
||||
QString head_thickness_unit;
|
||||
QString head_thickness_unit_scale;
|
||||
QString head_type = QStringLiteral("0");
|
||||
QString arrow_type = QStringLiteral("0");
|
||||
QString ring_filter;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolBase {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString offset MEMBER offset);
|
||||
Q_PROPERTY(QString offset_unit MEMBER offset_unit);
|
||||
Q_PROPERTY(QString offset_map_unit_scale MEMBER offset_map_unit_scale);
|
||||
public:
|
||||
QString offset;
|
||||
QString offset_unit;
|
||||
QString offset_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolSimple : public SFillSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString style MEMBER style);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString outline_style MEMBER outline_style);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString border_width_map_unit_scale MEMBER border_width_map_unit_scale);
|
||||
Q_PROPERTY(QString joinstyle MEMBER joinstyle);
|
||||
|
||||
public:
|
||||
QString color = QStringLiteral("red");
|
||||
QString style = QStringLiteral("solid");
|
||||
QString outline_color = QStringLiteral("35, 35, 35");
|
||||
QString outline_style = QStringLiteral("solid");
|
||||
QString outline_width = QStringLiteral("0.26");
|
||||
QString outline_width_unit;
|
||||
QString border_width_map_unit_scale;
|
||||
QString joinstyle = QStringLiteral("bevel");;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolRaster : public SFillSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString imageFile MEMBER imageFile);
|
||||
Q_PROPERTY(QString coordinate_mode MEMBER coordinate_mode);
|
||||
Q_PROPERTY(QString alpha MEMBER alpha);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString width MEMBER width);
|
||||
Q_PROPERTY(QString width_unit MEMBER width_unit);
|
||||
Q_PROPERTY(QString width_map_unit_scale MEMBER width_map_unit_scale);
|
||||
public:
|
||||
QString imageFile;
|
||||
QString coordinate_mode = QStringLiteral("0");
|
||||
QString alpha = QStringLiteral("1.0");
|
||||
QString angle = QStringLiteral("0.0");
|
||||
QString width = QStringLiteral("0.0");
|
||||
QString width_unit;
|
||||
QString width_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolSvg : public SFillSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString svgFile MEMBER svgFile);
|
||||
Q_PROPERTY(QString data MEMBER data);
|
||||
Q_PROPERTY(QString width MEMBER width);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString pattern_width_unit MEMBER pattern_width_unit);
|
||||
Q_PROPERTY(QString pattern_width_map_unit_scale MEMBER pattern_width_map_unit_scale);
|
||||
Q_PROPERTY(QString svg_outline_width_unit MEMBER svg_outline_width_unit);
|
||||
Q_PROPERTY(QString svg_outline_width_map_unit_scale MEMBER svg_outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
public:
|
||||
QString svgFile;
|
||||
QString data;
|
||||
QString width = QStringLiteral("12");
|
||||
QString angle = QStringLiteral("0");
|
||||
QString color = QStringLiteral("red");
|
||||
QString outline_color;
|
||||
QString outline_width;
|
||||
QString pattern_width_unit;
|
||||
QString pattern_width_map_unit_scale;
|
||||
QString svg_outline_width_unit;
|
||||
QString svg_outline_width_map_unit_scale;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolCentroid{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString point_on_surface MEMBER point_on_surface);
|
||||
Q_PROPERTY(QString point_on_all_parts MEMBER point_on_all_parts);
|
||||
Q_PROPERTY(QString clip_points MEMBER clip_points);
|
||||
Q_PROPERTY(QString clip_on_current_part_only MEMBER clip_on_current_part_only);
|
||||
public:
|
||||
QString point_on_surface;
|
||||
QString point_on_all_parts = QStringLiteral("1");
|
||||
QString clip_points;
|
||||
QString clip_on_current_part_only;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolGradient : public SFillSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString type MEMBER type);
|
||||
Q_PROPERTY(QString coordinate_mode MEMBER coordinate_mode);
|
||||
Q_PROPERTY(QString spread MEMBER spread);
|
||||
Q_PROPERTY(QString color_type MEMBER color_type);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString gradient_color2 MEMBER gradient_color2);
|
||||
Q_PROPERTY(QString reference_point1 MEMBER reference_point1);
|
||||
Q_PROPERTY(QString reference_point1_iscentroid MEMBER reference_point1_iscentroid);
|
||||
Q_PROPERTY(QString reference_point2 MEMBER reference_point2);
|
||||
Q_PROPERTY(QString reference_point2_iscentroid MEMBER reference_point2_iscentroid);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString rampType MEMBER rampType);
|
||||
|
||||
public:
|
||||
QString type = QStringLiteral("0");
|
||||
QString coordinate_mode = QStringLiteral("0");
|
||||
QString spread = QStringLiteral("0");
|
||||
QString color_type = QStringLiteral("0");
|
||||
QString color = QStringLiteral("red");
|
||||
QString gradient_color2 = QStringLiteral("yellow");
|
||||
QString reference_point1 = QStringLiteral("0,0");
|
||||
QString reference_point1_iscentroid;
|
||||
QString reference_point2 = QStringLiteral("1,0");
|
||||
QString reference_point2_iscentroid;
|
||||
QString angle = QStringLiteral("0");
|
||||
QString rampType;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolLinePattern : public SFillSymbolBase{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
Q_PROPERTY(QString distance MEMBER distance);
|
||||
Q_PROPERTY(QString outline_width MEMBER outline_width);
|
||||
Q_PROPERTY(QString outline_color MEMBER outline_color);
|
||||
Q_PROPERTY(QString distance_unit MEMBER distance_unit);
|
||||
Q_PROPERTY(QString distance_map_unit_scale MEMBER distance_map_unit_scale);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString coordinate_reference MEMBER coordinate_reference);
|
||||
Q_PROPERTY(QString clip_mode MEMBER clip_mode);
|
||||
public:
|
||||
QString angle = QStringLiteral("45");
|
||||
QString distance = QStringLiteral("5");
|
||||
QString outline_width = QStringLiteral("0.5");
|
||||
QString outline_color = QStringLiteral("black");
|
||||
QString distance_unit;
|
||||
QString distance_map_unit_scale;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
QString coordinate_reference;
|
||||
QString clip_mode;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolPointPattern{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString distance_x MEMBER distance_x);
|
||||
Q_PROPERTY(QString distance_y MEMBER distance_y);
|
||||
Q_PROPERTY(QString displacement_x MEMBER displacement_x);
|
||||
Q_PROPERTY(QString displacement_y MEMBER displacement_y);
|
||||
Q_PROPERTY(QString offset_x MEMBER offset_x);
|
||||
Q_PROPERTY(QString offset_y MEMBER offset_y);
|
||||
Q_PROPERTY(QString distance_x_unit MEMBER distance_x_unit);
|
||||
Q_PROPERTY(QString distance_x_map_unit_scale MEMBER distance_x_map_unit_scale);
|
||||
Q_PROPERTY(QString distance_y_unit MEMBER distance_y_unit);
|
||||
Q_PROPERTY(QString distance_y_map_unit_scale MEMBER distance_y_map_unit_scale);
|
||||
Q_PROPERTY(QString displacement_x_unit MEMBER displacement_x_unit);
|
||||
Q_PROPERTY(QString displacement_x_map_unit_scale MEMBER displacement_x_map_unit_scale);
|
||||
Q_PROPERTY(QString displacement_y_unit MEMBER displacement_y_unit);
|
||||
Q_PROPERTY(QString displacement_y_map_unit_scale MEMBER displacement_y_map_unit_scale);
|
||||
Q_PROPERTY(QString offset_x_unit MEMBER offset_x_unit);
|
||||
Q_PROPERTY(QString offset_x_map_unit_scale MEMBER offset_x_map_unit_scale);
|
||||
Q_PROPERTY(QString offset_y_unit MEMBER offset_y_unit);
|
||||
Q_PROPERTY(QString offset_y_map_unit_scale MEMBER offset_y_map_unit_scale);
|
||||
Q_PROPERTY(QString random_deviation_x MEMBER random_deviation_x);
|
||||
Q_PROPERTY(QString random_deviation_y MEMBER random_deviation_y);
|
||||
Q_PROPERTY(QString random_deviation_x_unit MEMBER random_deviation_x_unit);
|
||||
Q_PROPERTY(QString random_deviation_x_map_unit_scale MEMBER random_deviation_x_map_unit_scale);
|
||||
Q_PROPERTY(QString random_deviation_y_unit MEMBER random_deviation_y_unit);
|
||||
Q_PROPERTY(QString random_deviation_y_map_unit_scale MEMBER random_deviation_y_map_unit_scale);
|
||||
Q_PROPERTY(QString seed MEMBER seed);
|
||||
Q_PROPERTY(QString outline_width_unit MEMBER outline_width_unit);
|
||||
Q_PROPERTY(QString outline_width_map_unit_scale MEMBER outline_width_map_unit_scale);
|
||||
Q_PROPERTY(QString clip_mode MEMBER clip_mode);
|
||||
Q_PROPERTY(QString coordinate_reference MEMBER coordinate_reference);
|
||||
Q_PROPERTY(QString angle MEMBER angle);
|
||||
public:
|
||||
QString distance_x = QStringLiteral("15");
|
||||
QString distance_y = QStringLiteral("15");
|
||||
QString displacement_x = QStringLiteral("0");
|
||||
QString displacement_y = QStringLiteral("0");
|
||||
QString offset_x = QStringLiteral("0");
|
||||
QString offset_y = QStringLiteral("0");
|
||||
QString distance_x_unit;
|
||||
QString distance_x_map_unit_scale;
|
||||
QString distance_y_unit;
|
||||
QString distance_y_map_unit_scale;
|
||||
QString displacement_x_unit;
|
||||
QString displacement_x_map_unit_scale;
|
||||
QString displacement_y_unit;
|
||||
QString displacement_y_map_unit_scale;
|
||||
QString offset_x_unit;
|
||||
QString offset_x_map_unit_scale;
|
||||
QString offset_y_unit;
|
||||
QString offset_y_map_unit_scale;
|
||||
QString random_deviation_x = QStringLiteral("0");
|
||||
QString random_deviation_y = QStringLiteral("0");
|
||||
QString random_deviation_x_unit;
|
||||
QString random_deviation_x_map_unit_scale;
|
||||
QString random_deviation_y_unit;
|
||||
QString random_deviation_y_map_unit_scale;
|
||||
QString seed;
|
||||
QString outline_width_unit;
|
||||
QString outline_width_map_unit_scale;
|
||||
QString clip_mode = QStringLiteral("shape");
|
||||
QString coordinate_reference = QStringLiteral("feature");
|
||||
QString angle;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolRandomMarker{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString count_method MEMBER count_method);
|
||||
Q_PROPERTY(QString point_count MEMBER point_count);
|
||||
Q_PROPERTY(QString density_area MEMBER density_area);
|
||||
Q_PROPERTY(QString seed MEMBER seed);
|
||||
Q_PROPERTY(QString density_area_unit MEMBER density_area_unit);
|
||||
Q_PROPERTY(QString density_area_unit_scale MEMBER density_area_unit_scale);
|
||||
Q_PROPERTY(QString clip_points MEMBER clip_points);
|
||||
public:
|
||||
QString count_method = QStringLiteral("0");
|
||||
QString point_count = QStringLiteral("10");
|
||||
QString density_area = QStringLiteral("250.0");
|
||||
QString seed;
|
||||
QString density_area_unit;
|
||||
QString density_area_unit_scale;
|
||||
QString clip_points;
|
||||
};
|
||||
|
||||
|
||||
class SFillSymbolShapeburst{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString color_type MEMBER color_type);
|
||||
Q_PROPERTY(QString color MEMBER color);
|
||||
Q_PROPERTY(QString gradient_color2 MEMBER gradient_color2);
|
||||
Q_PROPERTY(QString blur_radius MEMBER blur_radius);
|
||||
Q_PROPERTY(QString use_whole_shape MEMBER use_whole_shape);
|
||||
Q_PROPERTY(QString max_distance MEMBER max_distance);
|
||||
Q_PROPERTY(QString rampType MEMBER rampType);
|
||||
Q_PROPERTY(QString distance_unit MEMBER distance_unit);
|
||||
Q_PROPERTY(QString distance_map_unit_scale MEMBER distance_map_unit_scale);
|
||||
Q_PROPERTY(QString ignore_rings MEMBER ignore_rings);
|
||||
public:
|
||||
QString color_type = QStringLiteral("0");
|
||||
QString color = QStringLiteral("red");
|
||||
QString gradient_color2 = QStringLiteral("white");
|
||||
QString blur_radius = QStringLiteral("0");
|
||||
QString use_whole_shape = QStringLiteral("1");
|
||||
QString max_distance = QStringLiteral("5");
|
||||
QString rampType;
|
||||
QString distance_unit;
|
||||
QString distance_map_unit_scale;
|
||||
QString ignore_rings;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef LDCOMMON_H
|
||||
#define LDCOMMON_H
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
|
||||
typedef struct _SSimpleMarker{
|
||||
QString shape;
|
||||
QString color;
|
||||
QString size;
|
||||
QString angle;
|
||||
}SSimpleMarker;
|
||||
|
||||
typedef struct _SSvgMarker{
|
||||
QString filePath;
|
||||
QString color;
|
||||
QString size;
|
||||
QString angle;
|
||||
}SSvgMarker;
|
||||
|
||||
typedef struct _SSimpleLineStyle{
|
||||
int penStyle;
|
||||
double penWidth;
|
||||
QColor penColor;
|
||||
|
||||
}SSimpleLineStyle;
|
||||
|
||||
#endif
|
|
@ -1,590 +0,0 @@
|
|||
#include "ll_qgis_base_lib.h"
|
||||
#include "MainWidgets/ControlPanel.h"
|
||||
#include "MainWindow/SubWindowManager.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QAction>
|
||||
#include <QToolButton>
|
||||
#include <QToolBar>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QUrlQuery>
|
||||
#include <QStatusBar>
|
||||
#include <QLabel>
|
||||
#include <QValidator>
|
||||
#include <QPainter>
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsmaptoolpan.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgsdockwidget.h"
|
||||
#include "qgslayertree.h"
|
||||
#include "qgslayertreeview.h"
|
||||
#include "qgslayertreemapcanvasbridge.h"
|
||||
#include "qgslayertreeregistrybridge.h"
|
||||
#include "qgslayertreeviewdefaultactions.h"
|
||||
#include "qgslayertreemodel.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsmaplayerfactory.h"
|
||||
#include "qgsbrightnesscontrastfilter.h"
|
||||
#include "qgshuesaturationfilter.h"
|
||||
#include "qgsrasterresampler.h"
|
||||
#include "qgscubicrasterresampler.h"
|
||||
#include "qgsrasterresamplefilter.h"
|
||||
|
||||
#include "qgspallabeling.h"
|
||||
#include "qgsvectorlayerlabeling.h"
|
||||
#include "qgsdoublespinbox.h"
|
||||
|
||||
#include "qgsdiagramrenderer.h"
|
||||
#include "qgspiediagram.h"
|
||||
|
||||
#include "qgssinglesymbolrenderer.h"
|
||||
#include "qgspointdisplacementrenderer.h"
|
||||
#include "qgspointclusterrenderer.h"
|
||||
#include "qgsheatmaprenderer.h"
|
||||
#include "qgsinvertedpolygonrenderer.h"
|
||||
#include "qgsembeddedsymbolrenderer.h"
|
||||
#include "qgs25drenderer.h"
|
||||
#include "qgsgraduatedsymbolrenderer.h"
|
||||
#include "qgsclassificationmethod.h"
|
||||
#include "qgsclassificationmethodregistry.h"
|
||||
#include "qgscategorizedsymbolrenderer.h"
|
||||
#include "qgsexpressioncontextutils.h"
|
||||
#include "qgscolorrampimpl.h"
|
||||
#include "qgsrastershader.h"
|
||||
#include "qgssinglebandpseudocolorrenderer.h"
|
||||
#include "qgshillshaderenderer.h"
|
||||
#include "qgsmultibandcolorrenderer.h"
|
||||
#include "qgspalettedrasterrenderer.h"
|
||||
#include "qgsrastercontourrenderer.h"
|
||||
#include "qgssymbol.h"
|
||||
#include "qgsmarkersymbol.h"
|
||||
#include "qgsmarkersymbollayer.h"
|
||||
#include "qgsfillsymbol.h"
|
||||
#include "qgsfillsymbollayer.h"
|
||||
#include "qgslinesymbol.h"
|
||||
#include "qgslinesymbollayer.h"
|
||||
#include "qgsannotationlayer.h"
|
||||
#include "qgsannotationmarkeritem.h"
|
||||
|
||||
#include "qgsvirtuallayerdefinition.h"
|
||||
#include "qgsvectorfilewriter.h"
|
||||
#include "qgsfilewidget.h"
|
||||
#include "qgsproviderregistry.h"
|
||||
//Raster
|
||||
#include "qgssinglebandgrayrenderer.h"
|
||||
#include "qgscontrastenhancement.h"
|
||||
#include "qgsrastertransparency.h"
|
||||
|
||||
#include "ll_qgis_base_lib_layertreeview_menu.h"
|
||||
#include "ll_qgis_base_lib_layerhandling.h"
|
||||
|
||||
ll_qgis_base_lib::ll_qgis_base_lib()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString ll_qgis_base_lib::version()
|
||||
{
|
||||
QString ver = QString::fromLocal8Bit("1.0.0");
|
||||
return ver;
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initialize(GUI::MainWindow *mainWindow)
|
||||
{
|
||||
mMainWindow = mainWindow;
|
||||
|
||||
initMapCanvas();
|
||||
initSrs();
|
||||
initLayerTreeView();
|
||||
initMaptools();
|
||||
initStatusbarWidget();
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::cleanup()
|
||||
{
|
||||
delete mMapCanvas;
|
||||
mMapCanvas = nullptr;
|
||||
|
||||
delete mLayerTreeView;
|
||||
mLayerTreeView = nullptr;
|
||||
|
||||
delete mLayerTreeMapCanvasBridge;
|
||||
mLayerTreeMapCanvasBridge = nullptr;
|
||||
|
||||
if(nullptr!=mLayerTreeDock) {
|
||||
delete mLayerTreeDock;
|
||||
mLayerTreeDock = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initMapCanvas()
|
||||
{
|
||||
mMapCanvas = new QgsMapCanvas;
|
||||
mMapCanvas->enableAntiAliasing(true);
|
||||
mMapCanvas->setCachingEnabled(true);
|
||||
mMapCanvas->setCanvasColor(QColor(255,255,255));
|
||||
mMapCanvas->setVisible(true);
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initSrs()
|
||||
{
|
||||
QgsSettings settings;
|
||||
qDebug() << settings.fileName();
|
||||
QgsProject *prj = QgsProject::instance();
|
||||
// set project CRS
|
||||
const QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), geoEpsgCrsAuthId(), QgsSettings::App ).toString() );
|
||||
// write the projections _proj string_ to project settings
|
||||
const bool planimetric = settings.value( QStringLiteral( "measure/planimetric" ), true, QgsSettings::Core ).toBool();
|
||||
prj->setCrs( srs, !planimetric ); // If the default ellipsoid is not planimetric, set it from the default crs
|
||||
if ( planimetric )
|
||||
prj->setEllipsoid( geoNone() );
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initLayerTreeView()
|
||||
{
|
||||
//添加DockWidget作为图层树的容器
|
||||
// mLayerTreeDock = new QgsDockWidget(tr("Layer Tree"));
|
||||
// mLayerTreeDock->setObjectName( QStringLiteral( "Layers" ) );
|
||||
// mLayerTreeDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
|
||||
//创建Model
|
||||
QgsLayerTreeModel* model = new QgsLayerTreeModel(QgsProject::instance()->layerTreeRoot(),this);
|
||||
model->setFlag( QgsLayerTreeModel::AllowNodeReorder );
|
||||
model->setFlag( QgsLayerTreeModel::AllowNodeRename );
|
||||
model->setFlag( QgsLayerTreeModel::AllowNodeChangeVisibility );
|
||||
model->setFlag( QgsLayerTreeModel::ShowLegendAsTree );
|
||||
model->setFlag( QgsLayerTreeModel::UseEmbeddedWidgets );
|
||||
model->setFlag( QgsLayerTreeModel::UseTextFormatting );
|
||||
model->setAutoCollapseLegendNodes( 10 );
|
||||
|
||||
//创建View,mLayerTreeView会在库外使用,所以需要添加getter方法,
|
||||
mLayerTreeView = new QgsLayerTreeView();
|
||||
mLayerTreeView->setModel(model);
|
||||
|
||||
//Map Canvas和Layer Tree View建立联系,这样通过QgsProject::instance()->addMapLayer添加图层后,会自动添加在图层树以及会在canvas渲染图层
|
||||
mLayerTreeMapCanvasBridge = new QgsLayerTreeMapCanvasBridge(QgsProject::instance()->layerTreeRoot(),mMapCanvas,this);
|
||||
connect( mLayerTreeMapCanvasBridge, &QgsLayerTreeMapCanvasBridge::canvasLayersChanged, mMapCanvas, &QgsMapCanvas::setLayers );
|
||||
|
||||
//Layer Tree View右键菜单实现
|
||||
mLayerTreeView->setMenuProvider(new ll_qgis_base_layertreeview_menu(mMainWindow,mLayerTreeView,mMapCanvas));
|
||||
connect(QgsProject::instance()->layerTreeRegistryBridge(),SIGNAL(addedLayersToLayerTree(QList<QgsMapLayer*>)),
|
||||
this,SLOT(slot_autoSelectAddedLayer(QList<QgsMapLayer*>)));
|
||||
|
||||
// QgsLayerTreeViewDefaultActions包含了默认实现的函数如添加Group
|
||||
QAction *actionAddGroup = new QAction( tr( "Add Group" ), this );
|
||||
actionAddGroup->setIcon( QIcon(":/images/themes/default/mActionAddGroup.png"));
|
||||
actionAddGroup->setToolTip( tr( "Add Group" ) );
|
||||
connect( actionAddGroup, &QAction::triggered, mLayerTreeView->defaultActions(), &QgsLayerTreeViewDefaultActions::addGroup );
|
||||
|
||||
QAction *actionShowAllLayers = new QAction( tr( "Show All Layers" ), this );
|
||||
actionShowAllLayers->setIcon( QIcon(":/images/themes/default/mActionShowAllLayers.png"));
|
||||
actionShowAllLayers->setToolTip( tr( "Show All Layers" ) );
|
||||
connect(actionShowAllLayers,&QAction::triggered,this,&ll_qgis_base_lib::showAllLayers);
|
||||
|
||||
QAction *actionHideAllLayers = new QAction( tr( "Hide All Layers" ), this );
|
||||
actionHideAllLayers->setIcon( QIcon(":/images/themes/default/mActionHideAllLayers.png"));
|
||||
actionHideAllLayers->setToolTip( tr( "Hide All Layers" ) );
|
||||
connect(actionHideAllLayers,&QAction::triggered,this,&ll_qgis_base_lib::hideAllLayers);
|
||||
|
||||
QAction *actionShowSelectedLayers = new QAction( tr( "Show Selected Layers" ), this );
|
||||
actionShowSelectedLayers->setIcon( QIcon(":/images/themes/default/mActionShowSelectedLayers.png"));
|
||||
actionShowSelectedLayers->setToolTip( tr( "Show Selected Layers" ) );
|
||||
connect(actionShowSelectedLayers,&QAction::triggered,this,&ll_qgis_base_lib::showSelectedLayers);
|
||||
|
||||
QAction *actionHideSelectedLayers = new QAction( tr( "Hide Selected Layers" ), this );
|
||||
actionHideSelectedLayers->setIcon( QIcon(":/images/themes/default/mActionHideSelectedLayers.png"));
|
||||
actionHideSelectedLayers->setToolTip( tr( "Hide Selected Layers" ) );
|
||||
connect(actionHideSelectedLayers,&QAction::triggered,this,&ll_qgis_base_lib::hideSelectedLayers);
|
||||
|
||||
// expand / collapse tool buttons
|
||||
QAction *actionExpandAll = new QAction( tr( "Expand All" ), this );
|
||||
actionExpandAll->setIcon( QIcon(":/images/themes/default/mActionExpandTree.png") );
|
||||
actionExpandAll->setToolTip( tr( "Expand All" ) );
|
||||
connect( actionExpandAll, &QAction::triggered, mLayerTreeView, &QgsLayerTreeView::expandAllNodes );
|
||||
QAction *actionCollapseAll = new QAction( tr( "Collapse All" ), this );
|
||||
actionCollapseAll->setIcon( QIcon(":/images/themes/default/mActionCollapseTree.png") );
|
||||
actionCollapseAll->setToolTip( tr( "Collapse All" ) );
|
||||
connect( actionCollapseAll, &QAction::triggered, mLayerTreeView, &QgsLayerTreeView::collapseAllNodes );
|
||||
|
||||
QAction *actionRemoveLayer = new QAction( tr( "Remove Layer" ), this );
|
||||
actionRemoveLayer->setIcon( QIcon(":/images/themes/default/mActionRemoveLayer.png") );
|
||||
actionRemoveLayer->setToolTip(tr( "Remvoe Layer" ));
|
||||
connect(actionRemoveLayer,&QAction::triggered,this,&ll_qgis_base_lib::removeLayer);
|
||||
|
||||
//在DockWidget上部添加一个工具栏
|
||||
QToolBar *toolbar = new QToolBar();
|
||||
// toolbar->setIconSize( iconSize( true ) );
|
||||
// toolbar->addAction( mActionStyleDock );
|
||||
toolbar->addAction( actionAddGroup );
|
||||
toolbar->addAction( actionShowAllLayers );
|
||||
toolbar->addAction( actionHideAllLayers );
|
||||
toolbar->addAction( actionShowSelectedLayers );
|
||||
toolbar->addAction( actionHideSelectedLayers );
|
||||
toolbar->addAction( actionExpandAll );
|
||||
toolbar->addAction( actionCollapseAll );
|
||||
toolbar->addAction( actionRemoveLayer );
|
||||
|
||||
//将工具栏和Layer Tree View添加到界面
|
||||
QVBoxLayout *vboxLayout = new QVBoxLayout;
|
||||
vboxLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
vboxLayout->setSpacing( 0 );
|
||||
vboxLayout->addWidget( toolbar );
|
||||
vboxLayout->addWidget( mLayerTreeView );
|
||||
|
||||
QWidget *w = new QWidget;
|
||||
w->setLayout( vboxLayout );
|
||||
// mLayerTreeDock->setWidget( w );
|
||||
|
||||
// banding map and tree in control and prewindows
|
||||
|
||||
GUI::SubWindowManager* subWindows=mMainWindow->getSubWindowManager();
|
||||
MainWidget::ControlPanel* controlPanel= mMainWindow->getControlPanel();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initMaptools()
|
||||
{
|
||||
mMapToolPan = new QgsMapToolPan(mMapCanvas);
|
||||
mMapCanvas->setMapTool(mMapToolPan);
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::initStatusbarWidget()
|
||||
{
|
||||
mCoordsEdit = new QgsStatusBarCoordinatesWidget( mMainWindow->statusBar() );
|
||||
mCoordsEdit->setObjectName( QStringLiteral( "mCoordsEdit" ) );
|
||||
mCoordsEdit->setMapCanvas( mMapCanvas);
|
||||
|
||||
mScaleWidget = new QgsStatusBarScaleWidget( mMapCanvas, mMainWindow->statusBar() );
|
||||
mScaleWidget->setObjectName( QStringLiteral( "mScaleWidget" ) );
|
||||
mScaleWidget->updateScales();
|
||||
|
||||
}
|
||||
|
||||
QgsMapLayer *ll_qgis_base_lib::addVectorLayer(const QString &uri, const QString &baseName, const QString &provider)
|
||||
{
|
||||
QgsMapLayer *layer = ll_qgis_base_lib_layerhandling::addVectorLayer( uri, baseName, provider );
|
||||
if ( layer )
|
||||
{
|
||||
mLayersList << layer;
|
||||
return layer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> ll_qgis_base_lib::addOgrVectorLayers(const QString &uri, const QString &baseName, const QString &provider)
|
||||
{
|
||||
bool ok = false;
|
||||
mVectorPath = uri;
|
||||
computeDataSources();
|
||||
QList<QgsMapLayer *> layers = ll_qgis_base_lib_layerhandling::addOgrVectorLayers(mDataSources,"","file",ok);
|
||||
return layers;
|
||||
}
|
||||
|
||||
QgsMapLayer *ll_qgis_base_lib::addRasterLayer(const QString &uri, const QString &baseName, const QString &provider)
|
||||
{
|
||||
QgsMapLayer *layer = ll_qgis_base_lib_layerhandling::addRasterLayer( uri, baseName, provider );
|
||||
if ( layer )
|
||||
{
|
||||
mLayersList << layer;
|
||||
return layer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QgsMapLayer *ll_qgis_base_lib::addWmsLayer(const QString &uri, const QString &baseName)
|
||||
{
|
||||
QString urlWithParams;
|
||||
QString type = QStringLiteral("xyz");
|
||||
int zMin = 0;
|
||||
int zMax = 18;
|
||||
#if 1
|
||||
QgsDataSourceUri urik;
|
||||
urik.setParam( QStringLiteral( "url" ), uri );
|
||||
urik.setParam( QStringLiteral( "type" ), type );
|
||||
urik.setParam( QStringLiteral( "zmin" ), QString::number( zMin ) );
|
||||
urik.setParam( QStringLiteral( "zmax" ), QString::number( zMax ) );
|
||||
urlWithParams = urik.encodedUri();
|
||||
#else
|
||||
QString urlEncode = QUrl::toPercentEncoding(url);
|
||||
urlWithParams = QString("type=xyz&url=%1&zmax=18&zmin=0").arg(urlEncode);
|
||||
#endif
|
||||
QgsRasterLayer *rlayer = new QgsRasterLayer(urlWithParams,baseName,"wms");
|
||||
QgsProject::instance()->addMapLayer(rlayer);
|
||||
return rlayer;
|
||||
}
|
||||
|
||||
QList<QgsMapCanvas *> ll_qgis_base_lib::mapCanvases()
|
||||
{
|
||||
// filter out browser canvases -- they are children of app, but a different
|
||||
// kind of beast, and here we only want the main canvas or dock canvases
|
||||
auto canvases = findChildren< QgsMapCanvas * >();
|
||||
canvases.erase( std::remove_if( canvases.begin(), canvases.end(),
|
||||
[]( QgsMapCanvas * canvas )
|
||||
{
|
||||
return !canvas || canvas->property( "browser_canvas" ).toBool();
|
||||
} ), canvases.end() );
|
||||
return canvases;
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::refreshMapCanvas(bool redrawAllLayers)
|
||||
{
|
||||
const auto canvases = mapCanvases();
|
||||
for ( QgsMapCanvas *canvas : canvases )
|
||||
{
|
||||
//stop any current rendering
|
||||
canvas->stopRendering();
|
||||
if ( redrawAllLayers )
|
||||
canvas->refreshAllLayers();
|
||||
else
|
||||
canvas->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::legendLayerZoomNative()
|
||||
{
|
||||
if ( !mLayerTreeView )
|
||||
return;
|
||||
|
||||
//find current Layer
|
||||
QgsMapLayer *currentLayer = mLayerTreeView->currentLayer();
|
||||
if ( !currentLayer )
|
||||
return;
|
||||
|
||||
if ( QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( currentLayer ) )
|
||||
{
|
||||
QgsDebugMsgLevel( "Raster units per pixel : " + QString::number( layer->rasterUnitsPerPixelX() ), 2 );
|
||||
QgsDebugMsgLevel( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ), 2 );
|
||||
|
||||
QList< double >nativeResolutions;
|
||||
if ( layer->dataProvider() )
|
||||
{
|
||||
nativeResolutions = layer->dataProvider()->nativeResolutions();
|
||||
}
|
||||
|
||||
// get length of central canvas pixel width in source raster crs
|
||||
QgsRectangle e = mMapCanvas->extent();
|
||||
QSize s = mMapCanvas->mapSettings().outputSize();
|
||||
QgsPointXY p1( e.center().x(), e.center().y() );
|
||||
QgsPointXY p2( e.center().x() + e.width() / s.width(), e.center().y() + e.height() / s.height() );
|
||||
QgsCoordinateTransform ct( mMapCanvas->mapSettings().destinationCrs(), layer->crs(), QgsProject::instance() );
|
||||
p1 = ct.transform( p1 );
|
||||
p2 = ct.transform( p2 );
|
||||
const double diagonalSize = std::sqrt( p1.sqrDist( p2 ) ); // width (actually the diagonal) of reprojected pixel
|
||||
if ( !nativeResolutions.empty() )
|
||||
{
|
||||
// find closest native resolution
|
||||
QList< double > diagonalNativeResolutions;
|
||||
diagonalNativeResolutions.reserve( nativeResolutions.size() );
|
||||
for ( double d : std::as_const( nativeResolutions ) )
|
||||
diagonalNativeResolutions << std::sqrt( 2 * d * d );
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < diagonalNativeResolutions.size() && diagonalNativeResolutions.at( i ) < diagonalSize; i++ )
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "test resolution %1: %2" ).arg( i ).arg( diagonalNativeResolutions.at( i ) ), 2 );
|
||||
}
|
||||
if ( i == nativeResolutions.size() ||
|
||||
( i > 0 && ( ( diagonalNativeResolutions.at( i ) - diagonalSize ) > ( diagonalSize - diagonalNativeResolutions.at( i - 1 ) ) ) ) )
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "previous resolution" ), 2 );
|
||||
i--;
|
||||
}
|
||||
|
||||
mMapCanvas->zoomByFactor( nativeResolutions.at( i ) / mMapCanvas->mapUnitsPerPixel() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMapCanvas->zoomByFactor( std::sqrt( layer->rasterUnitsPerPixelX() * layer->rasterUnitsPerPixelX() + layer->rasterUnitsPerPixelY() * layer->rasterUnitsPerPixelY() ) / diagonalSize );
|
||||
}
|
||||
|
||||
mMapCanvas->refresh();
|
||||
QgsDebugMsgLevel( "MapUnitsPerPixel after : " + QString::number( mMapCanvas->mapUnitsPerPixel() ), 2 );
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::legendLayerStretchUsingCurrentExtent()
|
||||
{
|
||||
if ( !mLayerTreeView )
|
||||
return;
|
||||
|
||||
//find current Layer
|
||||
QgsMapLayer *currentLayer = mLayerTreeView->currentLayer();
|
||||
if ( !currentLayer )
|
||||
return;
|
||||
|
||||
QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( currentLayer );
|
||||
if ( layer )
|
||||
{
|
||||
QgsRectangle myRectangle;
|
||||
myRectangle = mMapCanvas->mapSettings().outputExtentToLayerExtent( layer, mMapCanvas->extent() );
|
||||
layer->refreshContrastEnhancement( myRectangle );
|
||||
|
||||
mLayerTreeView->refreshLayerSymbology( layer->id() );
|
||||
refreshMapCanvas();
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::showVectorLayerSaveAsDialog()
|
||||
{
|
||||
emit showVectorLayerSaveAsDialogSignal();
|
||||
}
|
||||
|
||||
bool ll_qgis_base_lib::saveProjects(const QString &filename)
|
||||
{
|
||||
return QgsProject::instance()->write(filename);
|
||||
}
|
||||
|
||||
bool ll_qgis_base_lib::readProjects(const QString &filename, Qgis::ProjectReadFlags flags)
|
||||
{
|
||||
return QgsProject::instance()->read(filename,flags);
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::setCrs(const QgsCoordinateReferenceSystem &crs, bool adjustEllipsoid)
|
||||
{
|
||||
QgsProject::instance()->setCrs(crs,adjustEllipsoid);
|
||||
}
|
||||
|
||||
|
||||
void ll_qgis_base_lib::slot_autoSelectAddedLayer(const QList<QgsMapLayer *> layers)
|
||||
{
|
||||
if ( !layers.isEmpty() )
|
||||
{
|
||||
QgsLayerTreeLayer *nodeLayer = QgsProject::instance()->layerTreeRoot()->findLayer( layers[0]->id() );
|
||||
|
||||
if ( !nodeLayer )
|
||||
return;
|
||||
|
||||
QModelIndex index = mLayerTreeView->layerTreeModel()->node2index( nodeLayer );
|
||||
mLayerTreeView->setCurrentIndex( index );
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::showAllLayers()
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "Showing all layers!" ), 3 );
|
||||
mLayerTreeView->layerTreeModel()->rootGroup()->setItemVisibilityCheckedRecursive( true );
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::hideAllLayers()
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "hiding all layers!" ), 3 );
|
||||
|
||||
const auto constChildren = mLayerTreeView->layerTreeModel()->rootGroup()->children();
|
||||
for ( QgsLayerTreeNode *node : constChildren )
|
||||
{
|
||||
node->setItemVisibilityCheckedRecursive( false );
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::showSelectedLayers()
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "show selected layers!" ), 3 );
|
||||
|
||||
const auto constSelectedNodes = mLayerTreeView->selectedNodes();
|
||||
for ( QgsLayerTreeNode *node : constSelectedNodes )
|
||||
{
|
||||
QgsLayerTreeNode *nodeIter = node;
|
||||
while ( nodeIter )
|
||||
{
|
||||
nodeIter->setItemVisibilityChecked( true );
|
||||
nodeIter = nodeIter->parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::hideSelectedLayers()
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "hiding selected layers!" ), 3 );
|
||||
|
||||
const auto constSelectedNodes = mLayerTreeView->selectedNodes();
|
||||
for ( QgsLayerTreeNode *node : constSelectedNodes )
|
||||
{
|
||||
node->setItemVisibilityChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::removeLayer()
|
||||
{
|
||||
if(!mLayerTreeView)
|
||||
return;
|
||||
// const QList<QgsMapLayer *> selectedLayers = mLayerTreeView->selectedLayersRecursive();
|
||||
|
||||
if ( QMessageBox::warning( mMainWindow, tr( "Remove layers and groups" ), tr("Are you sure?"), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QList<QgsLayerTreeNode *> selectedNodes = mLayerTreeView->selectedNodes( true );
|
||||
for ( QgsLayerTreeNode *node : selectedNodes )
|
||||
{
|
||||
if ( QgsLayerTreeGroup *group = qobject_cast< QgsLayerTreeGroup * >( node ) )
|
||||
{
|
||||
if ( QgsGroupLayer *groupLayer = group->groupLayer() )
|
||||
{
|
||||
QgsProject::instance()->removeMapLayer( groupLayer );
|
||||
}
|
||||
}
|
||||
QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( node->parent() );
|
||||
if ( parentGroup )
|
||||
parentGroup->removeChildNode( node );
|
||||
}
|
||||
refreshMapCanvas();
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::userRotation()
|
||||
{
|
||||
double degrees = 0.0;//mRotationEdit->value();
|
||||
mMapCanvas->setRotation( degrees );
|
||||
mMapCanvas->refresh();
|
||||
}
|
||||
|
||||
void ll_qgis_base_lib::computeDataSources()
|
||||
{
|
||||
QgsSettings settings;
|
||||
mDataSources.clear();
|
||||
|
||||
QStringList openOptions;
|
||||
for ( const auto &filePath : QgsFileWidget::splitFilePaths( mVectorPath ) )
|
||||
{
|
||||
QVariantMap parts;
|
||||
if ( !openOptions.isEmpty() )
|
||||
parts.insert( QStringLiteral( "openOptions" ), openOptions );
|
||||
parts.insert( QStringLiteral( "path" ), filePath );
|
||||
mDataSources << QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "ogr" ), parts );
|
||||
}
|
||||
}
|
||||
|
||||
QgsStatusBarCoordinatesWidget *ll_qgis_base_lib::coordsEdit() const
|
||||
{
|
||||
return mCoordsEdit;
|
||||
}
|
||||
|
||||
QgsStatusBarScaleWidget *ll_qgis_base_lib::scaleWidget() const
|
||||
{
|
||||
return mScaleWidget;
|
||||
}
|
||||
|
||||
QgsDockWidget *ll_qgis_base_lib::layerTreeDock() const
|
||||
{
|
||||
return mLayerTreeDock;
|
||||
}
|
||||
|
||||
QgsMapCanvas *ll_qgis_base_lib::mapCanvas() const
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
QgsLayerTreeView *ll_qgis_base_lib::layerTreeView() const
|
||||
{
|
||||
return mLayerTreeView;
|
||||
}
|
||||
|
||||
|
|
@ -1,218 +0,0 @@
|
|||
#ifndef LD_LIB_APP_H
|
||||
#define LD_LIB_APP_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
#include <QObject>
|
||||
|
||||
#include "ll_qgis_base_lib_global.h"
|
||||
#include "ll_qgis_base_lib_singleton.h"
|
||||
#include "ld_symbol_property.h"
|
||||
#include "ld_geometry.h"
|
||||
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgspallabeling.h"
|
||||
#include "qgsvectorlayerlabeling.h"
|
||||
#include "qgsraster.h"
|
||||
#include "qgssymbol.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgssinglesymbolrenderer.h"
|
||||
#include "qgsmarkersymbol.h"
|
||||
|
||||
// 这两个属于app库,所以这里直接将源码拷贝到这里
|
||||
#include "qgsstatusbarscalewidget.h"
|
||||
#include "qgsstatusbarcoordinateswidget.h"
|
||||
#include "MainWindow/MainWindow.h"
|
||||
|
||||
class QMainWindow;
|
||||
class QDockWidget;
|
||||
class QLabel;
|
||||
class QValidator;
|
||||
|
||||
class QgsMapCanvas;
|
||||
class QgsMapToolPan;
|
||||
class QgsMapLayer;
|
||||
class QgsDockWidget;
|
||||
class QgsLayerTreeView;
|
||||
class QgsLayerTreeMapCanvasBridge;
|
||||
class QgsDoubleSpinBox;
|
||||
class QgsVectorLayer;
|
||||
class QgsRasterLayer;
|
||||
class QgsAnnotationLayer;
|
||||
class QgsSymbolLayer;
|
||||
class QgsRasterDataProvider;
|
||||
|
||||
/**
|
||||
* @brief 一些常用的功能模块放到库里
|
||||
*/
|
||||
class LD_LIB_APP_EXPORT ll_qgis_base_lib : public QObject
|
||||
{
|
||||
DECLARE_SINGLETON(ll_qgis_base_lib);
|
||||
Q_OBJECT
|
||||
private:
|
||||
ll_qgis_base_lib();
|
||||
public:
|
||||
///
|
||||
/// \brief 返回库版本
|
||||
/// \return
|
||||
///
|
||||
QString version();
|
||||
|
||||
// getters
|
||||
QgsLayerTreeView *layerTreeView() const;
|
||||
QgsMapCanvas *mapCanvas() const;
|
||||
QgsDockWidget *layerTreeDock() const;
|
||||
QgsStatusBarScaleWidget *scaleWidget() const;
|
||||
QgsStatusBarCoordinatesWidget *coordsEdit() const;
|
||||
|
||||
///
|
||||
/// \brief
|
||||
/// 1. 创建QgsMapCanvas
|
||||
/// 2. 创建QgsLayerTreeView等相关类,实现图层管理
|
||||
/// 3. 创建QgsMapTool
|
||||
/// 4. 创建状态栏widget
|
||||
/// \param mainWindow - 传入MainWindow指针
|
||||
///
|
||||
void initialize(GUI::MainWindow *mainWindow);
|
||||
///
|
||||
/// \brief 程序退出时清理资源
|
||||
///
|
||||
void cleanup();
|
||||
|
||||
///
|
||||
/// \brief initMapCanvas
|
||||
///
|
||||
void initMapCanvas();
|
||||
|
||||
///
|
||||
/// \brief initSrs
|
||||
///
|
||||
void initSrs();
|
||||
|
||||
///
|
||||
/// \brief 图层管理初始化
|
||||
/// QgsLayerTreeView QgsLayerTreeModel
|
||||
/// QgsLayerTreeMapCanvasBridge
|
||||
/// QgsLayerTreeViewMenuProvider
|
||||
void initLayerTreeView();
|
||||
///
|
||||
/// \brief 初始化QgsMaptools
|
||||
///
|
||||
void initMaptools();
|
||||
|
||||
///
|
||||
/// \brief 初始化状态栏,目前有坐标栏和缩放栏
|
||||
void initStatusbarWidget();
|
||||
|
||||
///
|
||||
/// \brief 保存项目
|
||||
/// \param filename
|
||||
/// \return
|
||||
///
|
||||
bool saveProjects(const QString &filename);
|
||||
///
|
||||
/// \brief 读取项目
|
||||
/// \param filename
|
||||
/// \param flags
|
||||
/// \return
|
||||
///
|
||||
bool readProjects(const QString &filename,Qgis::ProjectReadFlags flags = Qgis::ProjectReadFlags());
|
||||
///
|
||||
/// \brief 设置整体项目的坐标系
|
||||
/// \param crs
|
||||
/// \param adjustEllipsoid
|
||||
///
|
||||
void setCrs(const QgsCoordinateReferenceSystem &crs, bool adjustEllipsoid);
|
||||
|
||||
/**
|
||||
* @brief addVectorLayer
|
||||
* @param uri
|
||||
* @param baseName
|
||||
* @param provider
|
||||
* @return
|
||||
*/
|
||||
QgsMapLayer *addVectorLayer(const QString &uri, const QString &baseName, const QString &provider="ogr");
|
||||
|
||||
/**
|
||||
* @brief addOgrVectorLayers
|
||||
* @param uris
|
||||
* @param encoding
|
||||
* @param dataSourceType
|
||||
* @param ok
|
||||
* @param showWarningOnInvalid
|
||||
* @return
|
||||
*/
|
||||
QList< QgsMapLayer * > addOgrVectorLayers(const QString &uri, const QString &baseName, const QString &provider="ogr");
|
||||
/**
|
||||
* @brief addRasterLayer
|
||||
* @param uri
|
||||
* @param baseName
|
||||
* @param provider
|
||||
* @return
|
||||
*/
|
||||
QgsMapLayer *addRasterLayer(const QString &uri, const QString &baseName, const QString &provider="gdal");
|
||||
|
||||
///
|
||||
/// \brief addWmsLayer
|
||||
/// \param uri
|
||||
/// \param baseName
|
||||
/// \return
|
||||
///
|
||||
QgsMapLayer *addWmsLayer(const QString &uri,const QString &baseName);
|
||||
|
||||
///
|
||||
/// \brief MapCanvas有可能有多个
|
||||
/// \return
|
||||
///
|
||||
QList< QgsMapCanvas * > mapCanvases();
|
||||
///
|
||||
/// \brief refreshMapCanvas
|
||||
/// \param redrawAllLayers
|
||||
///
|
||||
void refreshMapCanvas(bool redrawAllLayers = false);
|
||||
|
||||
///
|
||||
/// \brief legendLayerZoomNative
|
||||
/// 图层树右键菜单使用该函数
|
||||
void legendLayerZoomNative();
|
||||
/**
|
||||
* @brief legendLayerStretchUsingCurrentExtent
|
||||
* 图层树右键菜单使用该函数
|
||||
*/
|
||||
void legendLayerStretchUsingCurrentExtent();
|
||||
|
||||
void showVectorLayerSaveAsDialog();
|
||||
public slots:
|
||||
void slot_autoSelectAddedLayer(const QList<QgsMapLayer *> layers);
|
||||
|
||||
private slots:
|
||||
void showAllLayers();
|
||||
void hideAllLayers();
|
||||
void showSelectedLayers();
|
||||
void hideSelectedLayers();
|
||||
void removeLayer();
|
||||
void userRotation();
|
||||
|
||||
signals:
|
||||
void showVectorLayerSaveAsDialogSignal();
|
||||
|
||||
private:
|
||||
void computeDataSources();
|
||||
|
||||
private:
|
||||
GUI::MainWindow *mMainWindow = nullptr;
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
QgsDockWidget* mLayerTreeDock = nullptr;
|
||||
QgsLayerTreeView* mLayerTreeView = nullptr;
|
||||
QgsLayerTreeMapCanvasBridge* mLayerTreeMapCanvasBridge = nullptr;
|
||||
QgsMapToolPan *mMapToolPan = nullptr;
|
||||
QgsStatusBarScaleWidget *mScaleWidget = nullptr;
|
||||
QgsStatusBarCoordinatesWidget *mCoordsEdit = nullptr;
|
||||
|
||||
QList<QgsMapLayer *> mLayersList;
|
||||
|
||||
QStringList mDataSources;
|
||||
QString mVectorPath;
|
||||
};
|
||||
|
||||
#endif // LD_LIB_APP_H
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef LD_LIB_APP_GLOBAL_H
|
||||
#define LD_LIB_APP_GLOBAL_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(LD_LIB_APP_LIBRARY)
|
||||
# define LD_LIB_APP_EXPORT LLQGISBASELIBAPI
|
||||
#else
|
||||
# define LD_LIB_APP_EXPORT LLQGISBASELIBAPI
|
||||
#endif
|
||||
|
||||
#endif // LD_LIB_APP_GLOBAL_H
|
|
@ -1,610 +0,0 @@
|
|||
#include "ll_qgis_base_lib_layerhandling.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qgsproviderregistry.h"
|
||||
#include "qgsprovidermetadata.h"
|
||||
#include "qgsprovidersublayerdetails.h"
|
||||
#include "qgsproviderutils.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsmaplayerfactory.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgslayertree.h"
|
||||
#include "qgslayertreeview.h"
|
||||
#include "qgslayertreenode.h"
|
||||
#include "qgszipitem.h"
|
||||
#include "qgsguiutils.h"
|
||||
|
||||
#include "ll_qgis_base_lib.h"
|
||||
|
||||
QgsVectorLayer *ll_qgis_base_lib_layerhandling::addVectorLayer(const QString &uri, const QString &baseName, const QString &provider)
|
||||
{
|
||||
return addLayerPrivate< QgsVectorLayer >( QgsMapLayerType::VectorLayer, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "ogr" ), true );
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> ll_qgis_base_lib_layerhandling::addOgrVectorLayers( const QStringList &layers, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid )
|
||||
{
|
||||
//note: this method ONLY supports vector layers from the OGR provider!
|
||||
ok = false;
|
||||
|
||||
// QgsCanvasRefreshBlocker refreshBlocker;
|
||||
|
||||
QList<QgsMapLayer *> layersToAdd;
|
||||
QList<QgsMapLayer *> addedLayers;
|
||||
QgsSettings settings;
|
||||
bool userAskedToAddLayers = false;
|
||||
|
||||
for ( const QString &layerUri : layers )
|
||||
{
|
||||
const QString uri = layerUri.trimmed();
|
||||
QString baseName;
|
||||
if ( dataSourceType == QLatin1String( "file" ) )
|
||||
{
|
||||
QString srcWithoutLayername( uri );
|
||||
int posPipe = srcWithoutLayername.indexOf( '|' );
|
||||
if ( posPipe >= 0 )
|
||||
srcWithoutLayername.resize( posPipe );
|
||||
baseName = QgsProviderUtils::suggestLayerNameFromFilePath( srcWithoutLayername );
|
||||
|
||||
// if needed prompt for zipitem layers
|
||||
QString vsiPrefix = QgsZipItem::vsiPrefix( uri );
|
||||
if ( ! uri.startsWith( QLatin1String( "/vsi" ), Qt::CaseInsensitive ) &&
|
||||
( vsiPrefix == QLatin1String( "/vsizip/" ) || vsiPrefix == QLatin1String( "/vsitar/" ) ) )
|
||||
{
|
||||
if ( askUserForZipItemLayers( uri, { QgsMapLayerType::VectorLayer } ) )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ( dataSourceType == QLatin1String( "database" ) )
|
||||
{
|
||||
// Try to extract the database name and use it as base name
|
||||
// sublayers names (if any) will be appended to the layer name
|
||||
const QVariantMap parts( QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), uri ) );
|
||||
if ( parts.value( QStringLiteral( "databaseName" ) ).isValid() )
|
||||
baseName = parts.value( QStringLiteral( "databaseName" ) ).toString();
|
||||
else
|
||||
baseName = uri;
|
||||
}
|
||||
else //directory //protocol
|
||||
{
|
||||
baseName = QgsProviderUtils::suggestLayerNameFromFilePath( uri );
|
||||
}
|
||||
|
||||
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
|
||||
{
|
||||
baseName = QgsMapLayer::formatLayerName( baseName );
|
||||
}
|
||||
|
||||
QgsDebugMsgLevel( "completeBaseName: " + baseName, 2 );
|
||||
const bool isVsiCurl { uri.startsWith( QLatin1String( "/vsicurl" ), Qt::CaseInsensitive ) };
|
||||
const auto scheme { QUrl( uri ).scheme() };
|
||||
const bool isRemoteUrl { scheme.startsWith( QLatin1String( "http" ) ) || scheme == QLatin1String( "ftp" ) };
|
||||
|
||||
std::unique_ptr< QgsTemporaryCursorOverride > cursorOverride;
|
||||
if ( isVsiCurl || isRemoteUrl )
|
||||
{
|
||||
cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) )->querySublayers( uri, Qgis::SublayerQueryFlag::IncludeSystemTables );
|
||||
// filter out non-vector sublayers
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return sublayer.type() != QgsMapLayerType::VectorLayer;
|
||||
} ), sublayers.end() );
|
||||
|
||||
cursorOverride.reset();
|
||||
|
||||
const QVariantMap uriParts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), uri );
|
||||
const QString path = uriParts.value( QStringLiteral( "path" ) ).toString();
|
||||
|
||||
if ( !sublayers.empty() )
|
||||
{
|
||||
userAskedToAddLayers = true;
|
||||
|
||||
const bool detailsAreIncomplete = QgsProviderUtils::sublayerDetailsAreIncomplete( sublayers, QgsProviderUtils::SublayerCompletenessFlag::IgnoreUnknownFeatureCount );
|
||||
const bool singleSublayerOnly = sublayers.size() == 1;
|
||||
QString groupName;
|
||||
|
||||
if ( !singleSublayerOnly || detailsAreIncomplete )
|
||||
{
|
||||
// ask user for sublayers (unless user settings dictate otherwise!)
|
||||
switch ( shouldAskUserForSublayers( sublayers ) )
|
||||
{
|
||||
/*
|
||||
case SublayerHandling::AskUser:
|
||||
{
|
||||
// prompt user for sublayers
|
||||
QgsProviderSublayersDialog dlg( uri, path, sublayers, {QgsMapLayerType::VectorLayer}, QgisApp::instance() );
|
||||
|
||||
if ( dlg.exec() )
|
||||
sublayers = dlg.selectedLayers();
|
||||
else
|
||||
sublayers.clear(); // dialog was canceled, so don't add any sublayers
|
||||
groupName = dlg.groupName();
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case SublayerHandling::AskUser:
|
||||
case SublayerHandling::LoadAll:
|
||||
{
|
||||
if ( detailsAreIncomplete )
|
||||
{
|
||||
// requery sublayers, resolving geometry types
|
||||
sublayers = QgsProviderRegistry::instance()->querySublayers( uri, Qgis::SublayerQueryFlag::ResolveGeometryType );
|
||||
// filter out non-vector sublayers
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return sublayer.type() != QgsMapLayerType::VectorLayer;
|
||||
} ), sublayers.end() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SublayerHandling::AbortLoading:
|
||||
sublayers.clear(); // don't add any sublayers
|
||||
break;
|
||||
};
|
||||
}
|
||||
else if ( detailsAreIncomplete )
|
||||
{
|
||||
// requery sublayers, resolving geometry types
|
||||
sublayers = QgsProviderRegistry::instance()->querySublayers( uri, Qgis::SublayerQueryFlag::ResolveGeometryType );
|
||||
// filter out non-vector sublayers
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return sublayer.type() != QgsMapLayerType::VectorLayer;
|
||||
} ), sublayers.end() );
|
||||
}
|
||||
|
||||
// now add sublayers
|
||||
if ( !sublayers.empty() )
|
||||
{
|
||||
addedLayers << addSublayers( sublayers, baseName, groupName );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QString msg = QObject::tr( "%1 is not a valid or recognized data source." ).arg( uri );
|
||||
// If the failed layer was a vsicurl type, give the user a chance to try the normal download.
|
||||
if ( isVsiCurl &&
|
||||
QMessageBox::question( nullptr, QObject::tr( "Invalid Data Source" ),
|
||||
QObject::tr( "Download with \"Protocol\" source type has failed, do you want to try the \"File\" source type?" ) ) == QMessageBox::Yes )
|
||||
{
|
||||
QString fileUri = uri;
|
||||
fileUri.replace( QLatin1String( "/vsicurl/" ), " " );
|
||||
return addOgrVectorLayers( QStringList() << fileUri, encoding, dataSourceType, showWarningOnInvalid );
|
||||
}
|
||||
// else if ( showWarningOnInvalid )
|
||||
// {
|
||||
// QgisApp::instance()->visibleMessageBar()->pushMessage( QObject::tr( "Invalid Data Source" ), msg, Qgis::MessageLevel::Critical );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// make sure at least one layer was successfully added
|
||||
if ( layersToAdd.isEmpty() )
|
||||
{
|
||||
// we also return true if we asked the user for sublayers, but they choose none. In this case nothing
|
||||
// went wrong, so we shouldn't return false and cause GUI warnings to appear
|
||||
ok = userAskedToAddLayers || !addedLayers.isEmpty();
|
||||
}
|
||||
|
||||
// Register this layer with the layers registry
|
||||
QgsProject::instance()->addMapLayers( layersToAdd );
|
||||
// for ( QgsMapLayer *l : std::as_const( layersToAdd ) )
|
||||
// {
|
||||
// QgisApp::instance()->askUserForDatumTransform( l->crs(), QgsProject::instance()->crs(), l );
|
||||
// QgsAppLayerHandling::postProcessAddedLayer( l );
|
||||
// }
|
||||
// QgisApp::instance()->activateDeactivateLayerRelatedActions( QgisApp::instance()->activeLayer() );
|
||||
|
||||
ok = true;
|
||||
addedLayers.append( layersToAdd );
|
||||
|
||||
for ( QgsMapLayer *l : std::as_const( addedLayers ) )
|
||||
{
|
||||
if ( !encoding.isEmpty() )
|
||||
{
|
||||
if ( QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l ) )
|
||||
vl->setProviderEncoding( encoding );
|
||||
}
|
||||
}
|
||||
|
||||
return addedLayers;
|
||||
|
||||
}
|
||||
|
||||
QgsRasterLayer *ll_qgis_base_lib_layerhandling::addRasterLayer(const QString &uri, const QString &baseName, const QString &provider)
|
||||
{
|
||||
return addLayerPrivate< QgsRasterLayer >( QgsMapLayerType::RasterLayer, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "gdal" ), true );
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> ll_qgis_base_lib_layerhandling::addGdalRasterLayers(const QStringList &uris, bool &ok, bool showWarningOnInvalid)
|
||||
{
|
||||
ok = false;
|
||||
if ( uris.empty() )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
// QgsCanvasRefreshBlocker refreshBlocker;
|
||||
|
||||
// this is messy since some files in the list may be rasters and others may
|
||||
// be ogr layers. We'll set returnValue to false if one or more layers fail
|
||||
// to load.
|
||||
|
||||
QList< QgsMapLayer * > res;
|
||||
|
||||
for ( const QString &uri : uris )
|
||||
{
|
||||
QString errMsg;
|
||||
|
||||
// if needed prompt for zipitem layers
|
||||
QString vsiPrefix = QgsZipItem::vsiPrefix( uri );
|
||||
if ( ( !uri.startsWith( QLatin1String( "/vsi" ), Qt::CaseInsensitive ) || uri.endsWith( QLatin1String( ".zip" ) ) || uri.endsWith( QLatin1String( ".tar" ) ) ) &&
|
||||
( vsiPrefix == QLatin1String( "/vsizip/" ) || vsiPrefix == QLatin1String( "/vsitar/" ) ) )
|
||||
{
|
||||
if ( askUserForZipItemLayers( uri, { QgsMapLayerType::RasterLayer } ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool isVsiCurl { uri.startsWith( QLatin1String( "/vsicurl" ), Qt::CaseInsensitive ) };
|
||||
const bool isRemoteUrl { uri.startsWith( QLatin1String( "http" ) ) || uri == QLatin1String( "ftp" ) };
|
||||
|
||||
std::unique_ptr< QgsTemporaryCursorOverride > cursorOverride;
|
||||
if ( isVsiCurl || isRemoteUrl )
|
||||
{
|
||||
cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
|
||||
// QgisApp::instance()->visibleMessageBar()->pushInfo( QObject::tr( "Remote layer" ), QObject::tr( "loading %1, please wait …" ).arg( uri ) );
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
if ( QgsRasterLayer::isValidRasterFileName( uri, errMsg ) )
|
||||
{
|
||||
QFileInfo myFileInfo( uri );
|
||||
|
||||
// set the layer name to the file base name unless provided explicitly
|
||||
QString layerName;
|
||||
const QVariantMap uriDetails = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri );
|
||||
if ( !uriDetails[ QStringLiteral( "layerName" ) ].toString().isEmpty() )
|
||||
{
|
||||
layerName = uriDetails[ QStringLiteral( "layerName" ) ].toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
layerName = QgsProviderUtils::suggestLayerNameFromFilePath( uri );
|
||||
}
|
||||
|
||||
// try to create the layer
|
||||
cursorOverride.reset();
|
||||
QgsRasterLayer *layer = addLayerPrivate< QgsRasterLayer >( QgsMapLayerType::RasterLayer, uri, layerName, QStringLiteral( "gdal" ), showWarningOnInvalid );
|
||||
res << layer;
|
||||
|
||||
if ( layer && layer->isValid() )
|
||||
{
|
||||
//only allow one copy of a ai grid file to be loaded at a
|
||||
//time to prevent the user selecting all adfs in 1 dir which
|
||||
//actually represent 1 coverage,
|
||||
|
||||
if ( myFileInfo.fileName().endsWith( QLatin1String( ".adf" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if layer is invalid addLayerPrivate() will show the error
|
||||
|
||||
} // valid raster filename
|
||||
else
|
||||
{
|
||||
ok = false;
|
||||
|
||||
// Issue message box warning unless we are loading from cmd line since
|
||||
// non-rasters are passed to this function first and then successfully
|
||||
// loaded afterwards (see main.cpp)
|
||||
if ( showWarningOnInvalid )
|
||||
{
|
||||
QString msg = QObject::tr( "%1 is not a supported raster data source" ).arg( uri );
|
||||
if ( !errMsg.isEmpty() )
|
||||
msg += '\n' + errMsg;
|
||||
|
||||
// QgisApp::instance()->visibleMessageBar()->pushMessage( QObject::tr( "Unsupported Data Source" ), msg, Qgis::MessageLevel::Critical );
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> ll_qgis_base_lib_layerhandling::addSublayers(const QList<QgsProviderSublayerDetails> &layers, const QString &baseName, const QString &groupName)
|
||||
{
|
||||
QgsLayerTreeGroup *group = nullptr;
|
||||
//deal groud conditiation
|
||||
if ( !groupName.isEmpty() )
|
||||
{
|
||||
int index { 0 };
|
||||
QgsLayerTreeNode *currentNode { ll_qgis_base_lib::Instance()->layerTreeView()->currentNode() };
|
||||
if ( currentNode && currentNode->parent() )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( currentNode ) )
|
||||
{
|
||||
group = qobject_cast<QgsLayerTreeGroup *>( currentNode )->insertGroup( 0, groupName );
|
||||
}
|
||||
else if ( QgsLayerTree::isLayer( currentNode ) )
|
||||
{
|
||||
const QList<QgsLayerTreeNode *> currentNodeSiblings { currentNode->parent()->children() };
|
||||
int nodeIdx { 0 };
|
||||
for ( const QgsLayerTreeNode *child : std::as_const( currentNodeSiblings ) )
|
||||
{
|
||||
nodeIdx++;
|
||||
if ( child == currentNode )
|
||||
{
|
||||
index = nodeIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
group = qobject_cast<QgsLayerTreeGroup *>( currentNode->parent() )->insertGroup( index, groupName );
|
||||
}
|
||||
else
|
||||
{
|
||||
group = QgsProject::instance()->layerTreeRoot()->insertGroup( 0, groupName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
group = QgsProject::instance()->layerTreeRoot()->insertGroup( 0, groupName );
|
||||
}
|
||||
}
|
||||
// if we aren't adding to a group, we need to add the layers in reverse order so that they maintain the correct
|
||||
// order in the layer tree!
|
||||
QList<QgsProviderSublayerDetails> sortedLayers = layers;
|
||||
if ( groupName.isEmpty() )
|
||||
{
|
||||
std::reverse( sortedLayers.begin(), sortedLayers.end() );
|
||||
}
|
||||
QList< QgsMapLayer * > result;
|
||||
result.reserve( sortedLayers.size() );
|
||||
for ( const QgsProviderSublayerDetails &sublayer : std::as_const( sortedLayers ) )
|
||||
{
|
||||
QgsProviderSublayerDetails::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
options.loadDefaultStyle = false;
|
||||
std::unique_ptr<QgsMapLayer> layer( sublayer.toLayer( options ) );
|
||||
if ( !layer )
|
||||
continue;
|
||||
QgsMapLayer *ml = layer.get();
|
||||
// if we aren't adding to a group, then we're iterating the layers in the reverse order
|
||||
// so account for that in the returned list of layers
|
||||
if ( groupName.isEmpty() )
|
||||
result.insert( 0, ml );
|
||||
else
|
||||
result << ml;
|
||||
QString layerName = layer->name();
|
||||
const bool projectWasEmpty = QgsProject::instance()->mapLayers().empty();
|
||||
// if user has opted to add sublayers to a group, then we don't need to include the
|
||||
// filename in the layer's name, because the group is already titled with the filename.
|
||||
// But otherwise, we DO include the file name so that users can differentiate the source
|
||||
// when multiple layers are loaded from a GPX file or similar (refs https://github.com/qgis/QGIS/issues/37551)
|
||||
if ( group )
|
||||
{
|
||||
if ( !layerName.isEmpty() )
|
||||
layer->setName( layerName );
|
||||
else if ( !baseName.isEmpty() )
|
||||
layer->setName( baseName );
|
||||
QgsProject::instance()->addMapLayer( layer.release(), false );
|
||||
group->addLayer( ml );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( layerName != baseName && !layerName.isEmpty() && !baseName.isEmpty() )
|
||||
layer->setName( QString::fromLocal8Bit( "%1 — %2" ).arg( baseName, layerName ) );
|
||||
else if ( !layerName.isEmpty() )
|
||||
layer->setName( layerName );
|
||||
else if ( !baseName.isEmpty() )
|
||||
layer->setName( baseName );
|
||||
QgsProject::instance()->addMapLayer( layer.release() );
|
||||
}
|
||||
// Some of the logic relating to matching a new project's CRS to the first layer added CRS is deferred to happen when the event loop
|
||||
// next runs -- so in those cases we can't assume that the project's CRS has been matched to the actual desired CRS yet.
|
||||
// In these cases we don't need to show the coordinate operation selection choice, so just hardcode an exception in here to avoid that...
|
||||
QgsCoordinateReferenceSystem projectCrsAfterLayerAdd = QgsProject::instance()->crs();
|
||||
if ( projectWasEmpty )
|
||||
projectCrsAfterLayerAdd = ml->crs();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *ll_qgis_base_lib_layerhandling::addLayerPrivate(QgsMapLayerType type, const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarnings)
|
||||
{
|
||||
QVariantMap uriElements = QgsProviderRegistry::instance()->decodeUri( providerKey, uri );
|
||||
QString path = uri;
|
||||
if ( uriElements.contains( QStringLiteral( "path" ) ) )
|
||||
{
|
||||
// run layer path through QgsPathResolver so that all inbuilt paths and other localised paths are correctly expanded
|
||||
path = QgsPathResolver().readPath( uriElements.value( QStringLiteral( "path" ) ).toString() );
|
||||
uriElements[ QStringLiteral( "path" ) ] = path;
|
||||
}
|
||||
// Not all providers implement decodeUri(), so use original uri if uriElements is empty
|
||||
const QString updatedUri = uriElements.isEmpty() ? uri : QgsProviderRegistry::instance()->encodeUri( providerKey, uriElements );
|
||||
|
||||
const bool canQuerySublayers = QgsProviderRegistry::instance()->providerMetadata( providerKey ) &&
|
||||
( QgsProviderRegistry::instance()->providerMetadata( providerKey )->capabilities() & QgsProviderMetadata::QuerySublayers );
|
||||
|
||||
T *result = nullptr;
|
||||
if ( canQuerySublayers )
|
||||
{
|
||||
// query sublayers
|
||||
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( providerKey ) ?
|
||||
QgsProviderRegistry::instance()->providerMetadata( providerKey )->querySublayers( updatedUri, Qgis::SublayerQueryFlag::IncludeSystemTables )
|
||||
: QgsProviderRegistry::instance()->querySublayers( updatedUri );
|
||||
// filter out non-matching sublayers
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [type]( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return sublayer.type() != type;
|
||||
} ), sublayers.end() );
|
||||
|
||||
if ( sublayers.empty() )
|
||||
{
|
||||
if ( guiWarnings )
|
||||
{
|
||||
QString msg = QObject::tr( "%1 is not a valid or recognized data source." ).arg( uri );
|
||||
// QgisApp::instance()->visibleMessageBar()->pushMessage( QObject::tr( "Invalid Data Source" ), msg, Qgis::MessageLevel::Critical );
|
||||
}
|
||||
|
||||
// since the layer is bad, stomp on it
|
||||
return nullptr;
|
||||
}
|
||||
else if ( sublayers.size() > 1 || QgsProviderUtils::sublayerDetailsAreIncomplete( sublayers, QgsProviderUtils::SublayerCompletenessFlag::IgnoreUnknownFeatureCount ) )
|
||||
{
|
||||
//lld_temp just load all layers
|
||||
//qgsapplayerhandling line 1314 will choose askUser or loadall based on settings
|
||||
result = qobject_cast< T * >( addSublayers( sublayers, baseName, QString() ).value( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = qobject_cast< T * >( addSublayers( sublayers, baseName, QString() ).value( 0 ) );
|
||||
result->setName( baseName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsMapLayerFactory::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
options.loadDefaultStyle = false;
|
||||
result = qobject_cast< T * >( QgsMapLayerFactory::createLayer( uri, baseName, type, options, providerKey ) );
|
||||
if ( result )
|
||||
{
|
||||
|
||||
result->setName( baseName );
|
||||
QgsProject::instance()->addMapLayer( result );
|
||||
|
||||
// QgisApp::instance()->askUserForDatumTransform( result->crs(), QgsProject::instance()->crs(), result );
|
||||
// QgsAppLayerHandling::postProcessAddedLayer( result );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
bool ll_qgis_base_lib_layerhandling::askUserForZipItemLayers( const QString &path, const QList<QgsMapLayerType> &acceptableTypes )
|
||||
{
|
||||
// query sublayers
|
||||
QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::IncludeSystemTables );
|
||||
|
||||
// filter out non-matching sublayers
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() );
|
||||
} ), sublayers.end() );
|
||||
|
||||
if ( sublayers.empty() )
|
||||
return false;
|
||||
|
||||
const bool detailsAreIncomplete = QgsProviderUtils::sublayerDetailsAreIncomplete( sublayers, QgsProviderUtils::SublayerCompletenessFlag::IgnoreUnknownFeatureCount );
|
||||
const bool singleSublayerOnly = sublayers.size() == 1;
|
||||
QString groupName;
|
||||
|
||||
if ( !singleSublayerOnly || detailsAreIncomplete )
|
||||
{
|
||||
// ask user for sublayers (unless user settings dictate otherwise!)
|
||||
switch ( shouldAskUserForSublayers( sublayers ) )
|
||||
{
|
||||
/*
|
||||
case SublayerHandling::AskUser:
|
||||
{
|
||||
// prompt user for sublayers
|
||||
QgsProviderSublayersDialog dlg( path, path, sublayers, acceptableTypes, QgisApp::instance() );
|
||||
|
||||
if ( dlg.exec() )
|
||||
sublayers = dlg.selectedLayers();
|
||||
else
|
||||
sublayers.clear(); // dialog was canceled, so don't add any sublayers
|
||||
groupName = dlg.groupName();
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case SublayerHandling::AskUser:
|
||||
case SublayerHandling::LoadAll:
|
||||
{
|
||||
if ( detailsAreIncomplete )
|
||||
{
|
||||
// requery sublayers, resolving geometry types
|
||||
sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::ResolveGeometryType );
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() );
|
||||
} ), sublayers.end() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SublayerHandling::AbortLoading:
|
||||
sublayers.clear(); // don't add any sublayers
|
||||
break;
|
||||
};
|
||||
}
|
||||
else if ( detailsAreIncomplete )
|
||||
{
|
||||
// requery sublayers, resolving geometry types
|
||||
sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::ResolveGeometryType );
|
||||
sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer )
|
||||
{
|
||||
return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() );
|
||||
} ), sublayers.end() );
|
||||
}
|
||||
|
||||
// now add sublayers
|
||||
if ( !sublayers.empty() )
|
||||
{
|
||||
// QgsCanvasRefreshBlocker refreshBlocker;
|
||||
QgsSettings settings;
|
||||
|
||||
QString base = QgsProviderUtils::suggestLayerNameFromFilePath( path );
|
||||
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
|
||||
{
|
||||
base = QgsMapLayer::formatLayerName( base );
|
||||
}
|
||||
|
||||
addSublayers( sublayers, base, groupName );
|
||||
// QgisApp::instance()->activateDeactivateLayerRelatedActions( QgisApp::instance()->activeLayer() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ll_qgis_base_lib_layerhandling::SublayerHandling ll_qgis_base_lib_layerhandling::shouldAskUserForSublayers( const QList<QgsProviderSublayerDetails> &layers, bool hasNonLayerItems )
|
||||
{
|
||||
if ( hasNonLayerItems )
|
||||
return SublayerHandling::AskUser;
|
||||
|
||||
QgsSettings settings;
|
||||
const Qgis::SublayerPromptMode promptLayers = settings.enumValue( QStringLiteral( "qgis/promptForSublayers" ), Qgis::SublayerPromptMode::AlwaysAsk );
|
||||
|
||||
switch ( promptLayers )
|
||||
{
|
||||
case Qgis::SublayerPromptMode::AlwaysAsk:
|
||||
return SublayerHandling::AskUser;
|
||||
|
||||
case Qgis::SublayerPromptMode::AskExcludingRasterBands:
|
||||
{
|
||||
// if any non-raster layers are found, we ask the user. Otherwise we load all
|
||||
for ( const QgsProviderSublayerDetails &sublayer : layers )
|
||||
{
|
||||
if ( sublayer.type() != QgsMapLayerType::RasterLayer )
|
||||
return SublayerHandling::AskUser;
|
||||
}
|
||||
return SublayerHandling::LoadAll;
|
||||
}
|
||||
|
||||
case Qgis::SublayerPromptMode::NeverAskSkip:
|
||||
return SublayerHandling::AbortLoading;
|
||||
|
||||
case Qgis::SublayerPromptMode::NeverAskLoadAll:
|
||||
return SublayerHandling::LoadAll;
|
||||
}
|
||||
|
||||
return SublayerHandling::AskUser;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
#ifndef LD_LIB_APP_LAYERHANDLING_H
|
||||
#define LD_LIB_APP_LAYERHANDLING_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
#include "qgis.h"
|
||||
#include "qgsmaplayer.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QgsMapLayer;
|
||||
class QgsProviderSublayerDetails;
|
||||
class QgsPointCloudLayer;
|
||||
class QgsVectorLayer;
|
||||
class QgsRasterLayer;
|
||||
class QgsMeshLayer;
|
||||
class QgsPluginLayer;
|
||||
class QgsVectorTileLayer;
|
||||
|
||||
class LLQGISBASELIBAPI ll_qgis_base_lib_layerhandling
|
||||
{
|
||||
Q_GADGET
|
||||
public:
|
||||
enum class SublayerHandling
|
||||
{
|
||||
AskUser,
|
||||
LoadAll,
|
||||
AbortLoading
|
||||
};
|
||||
|
||||
static QgsVectorLayer *addVectorLayer( const QString &uri, const QString &baseName, const QString &provider = QLatin1String( "ogr" ) );
|
||||
static QList< QgsMapLayer * > addOgrVectorLayers( const QStringList &uris, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid = true );
|
||||
static QgsRasterLayer *addRasterLayer( QString const &uri, const QString &baseName, const QString &provider = QLatin1String( "gdal" ) );
|
||||
static QList< QgsMapLayer * > addGdalRasterLayers( const QStringList &uris, bool &ok, bool showWarningOnInvalid = true );
|
||||
private:
|
||||
template<typename T> static T *addLayerPrivate( QgsMapLayerType type, const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarnings = false );
|
||||
static QList< QgsMapLayer * > addSublayers( const QList< QgsProviderSublayerDetails> &layers, const QString &baseName, const QString &groupName );
|
||||
static bool askUserForZipItemLayers( const QString &path, const QList< QgsMapLayerType > &acceptableTypes );
|
||||
static SublayerHandling shouldAskUserForSublayers( const QList< QgsProviderSublayerDetails > &layers, bool hasNonLayerItems = false );
|
||||
};
|
||||
|
||||
#endif // LD_LIB_APP_LAYERHANDLING_H
|
|
@ -1,126 +0,0 @@
|
|||
#include "ll_qgis_base_lib_layertreeview_menu.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QModelIndex>
|
||||
#include <QIcon>
|
||||
#include <qgswkbtypes.h>
|
||||
|
||||
#include "qgslayertreeviewdefaultactions.h"
|
||||
#include "qgslayertreenode.h"
|
||||
#include "qgslayertree.h"
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
|
||||
#include "ll_qgis_base_lib.h"
|
||||
|
||||
ll_qgis_base_layertreeview_menu::ll_qgis_base_layertreeview_menu(QMainWindow* mainWindow,QgsLayerTreeView *view, QgsMapCanvas *canvas)
|
||||
{
|
||||
mMainWindow = mainWindow;
|
||||
mLayerTreeView = view;
|
||||
mMapCanvas = canvas;
|
||||
}
|
||||
|
||||
ll_qgis_base_layertreeview_menu::~ll_qgis_base_layertreeview_menu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QMenu *ll_qgis_base_layertreeview_menu::createContextMenu()
|
||||
{
|
||||
QMenu* menu = new QMenu;
|
||||
QgsLayerTreeViewDefaultActions* actions = mLayerTreeView->defaultActions();
|
||||
QModelIndex idx = mLayerTreeView->currentIndex();
|
||||
|
||||
// global menu
|
||||
if(!idx.isValid())
|
||||
{
|
||||
menu->addAction(actions->actionAddGroup(menu));
|
||||
menu->addAction(tr("&Expand All"),mLayerTreeView,SLOT(expandAll()));
|
||||
menu->addAction(tr("&Collapse All"),mLayerTreeView,SLOT(collapseAll()));
|
||||
}else
|
||||
{
|
||||
QgsLayerTreeNode* node = mLayerTreeView->index2node(idx);
|
||||
//如果是组,显示对应菜单项目
|
||||
if(QgsLayerTree::isGroup(node))
|
||||
{
|
||||
menu->addAction(actions->actionZoomToGroup(mMapCanvas,menu));
|
||||
menu->addAction(actions->actionRemoveGroupOrLayer(menu));
|
||||
menu->addAction(actions->actionRenameGroupOrLayer());
|
||||
if(mLayerTreeView->selectedNodes(true).count() >= 2)
|
||||
menu->addAction(actions->actionGroupSelected(menu));
|
||||
menu->addAction(actions->actionAddGroup(menu));
|
||||
}
|
||||
else if(QgsLayerTree::isLayer(node))
|
||||
{
|
||||
QgsMapLayer* layer = QgsLayerTree::toLayer(node)->layer();
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
|
||||
if ( layer && layer->isSpatial() )
|
||||
{
|
||||
//添加zoom to layer右键菜单项目
|
||||
QAction *zoomToLayers = actions->actionZoomToLayers( mMapCanvas, menu );
|
||||
zoomToLayers->setEnabled( layer->isValid() );
|
||||
menu->addAction(zoomToLayers);
|
||||
}
|
||||
if ( vlayer )
|
||||
{
|
||||
//显示图层Feature数量
|
||||
QAction *showFeatureCount = actions->actionShowFeatureCount( menu );
|
||||
menu->addAction( showFeatureCount );
|
||||
showFeatureCount->setEnabled( vlayer->isValid() );
|
||||
|
||||
const QString iconName = vlayer && vlayer->labeling() && vlayer->labeling()->type() == QLatin1String( "rule-based" )
|
||||
? QStringLiteral( "labelingRuleBased.png" )
|
||||
: QStringLiteral( "labelingSingle.png" );
|
||||
QString aIconName = QString(":/images/themes/default/%1").arg(iconName);
|
||||
//是否显示标签
|
||||
QAction *actionShowLabels = new QAction( QIcon(aIconName), tr( "Show &Labels" ), menu );
|
||||
actionShowLabels->setCheckable( true );
|
||||
actionShowLabels->setChecked( vlayer->labelsEnabled() );
|
||||
connect( actionShowLabels, &QAction::toggled, this, &ll_qgis_base_layertreeview_menu::toggleLabels );
|
||||
menu->addAction( actionShowLabels );
|
||||
}
|
||||
//删除图层
|
||||
menu->addAction(actions->actionRemoveGroupOrLayer(menu));
|
||||
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
|
||||
if ( rlayer )
|
||||
{
|
||||
QAction *zoomToNative = menu->addAction( QIcon( QString( ":/images/themes/default/mActionZoomActual.png" ) ), tr( "Zoom to Nat&ive Resolution (100%)" ), ll_qgis_base_lib::Instance(), &ll_qgis_base_lib::legendLayerZoomNative );
|
||||
zoomToNative->setEnabled( rlayer->isValid() );
|
||||
|
||||
if ( rlayer->rasterType() != QgsRasterLayer::Palette )
|
||||
{
|
||||
QAction *stretch = menu->addAction( tr( "&Stretch Using Current Extent" ), ll_qgis_base_lib::Instance(), &ll_qgis_base_lib::legendLayerStretchUsingCurrentExtent );
|
||||
stretch->setEnabled( rlayer->isValid() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return menu;
|
||||
|
||||
}
|
||||
|
||||
void ll_qgis_base_layertreeview_menu::toggleLabels(bool enabled)
|
||||
{
|
||||
const QList<QgsLayerTreeLayer *> selectedLayerNodes = mLayerTreeView->selectedLayerNodes();
|
||||
for ( QgsLayerTreeLayer *l : selectedLayerNodes )
|
||||
{
|
||||
QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( l->layer() );
|
||||
if ( !vlayer || !vlayer->isSpatial() )
|
||||
continue;
|
||||
|
||||
if ( enabled && !vlayer->labeling() )
|
||||
{
|
||||
// no labeling setup - create default labeling for layer
|
||||
const QgsPalLayerSettings settings = QgsAbstractVectorLayerLabeling::defaultSettingsForLayer( vlayer );
|
||||
vlayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) );
|
||||
vlayer->setLabelsEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
vlayer->setLabelsEnabled( enabled );
|
||||
}
|
||||
vlayer->emitStyleChanged();
|
||||
vlayer->triggerRepaint();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef LD_LIB_LAYERTREEVIEW_MENU_H
|
||||
#define LD_LIB_LAYERTREEVIEW_MENU_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
#include "ll_qgis_base_lib_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "qgslayertreeview.h"
|
||||
|
||||
class QAction;
|
||||
class QgsMapCanvas;
|
||||
class QMainWindow;
|
||||
|
||||
class LLQGISBASELIBAPI ll_qgis_base_layertreeview_menu : public QObject, public QgsLayerTreeViewMenuProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ll_qgis_base_layertreeview_menu(QMainWindow* mainWindow,QgsLayerTreeView* view,QgsMapCanvas* canvas);
|
||||
~ll_qgis_base_layertreeview_menu() override;
|
||||
QMenu *createContextMenu() override;
|
||||
|
||||
private slots:
|
||||
void toggleLabels( bool enabled );
|
||||
|
||||
private:
|
||||
QMainWindow* mMainWindow = nullptr;
|
||||
QgsLayerTreeView* mLayerTreeView = nullptr;
|
||||
QgsMapCanvas* mMapCanvas = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // LD_LIB_LAYERTREEVIEW_MENU_H
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef LD_LIB_SINGLETON_H
|
||||
#define LD_LIB_SINGLETON_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
#include <QMutex>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#define DECLARE_SINGLETON(Class) \
|
||||
Q_DISABLE_COPY(Class) \
|
||||
public: \
|
||||
static Class* Instance() \
|
||||
{ \
|
||||
static QMutex mutex; \
|
||||
static QScopedPointer<Class> inst; \
|
||||
if (Q_UNLIKELY(!inst)) { \
|
||||
mutex.lock(); \
|
||||
if (!inst) inst.reset(new Class); \
|
||||
mutex.unlock(); \
|
||||
} \
|
||||
return inst.data(); \
|
||||
}
|
||||
|
||||
|
||||
#endif // LD_LIB_SINGLETON_H
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef _LLQIGSBASELIBAPI_H_
|
||||
#define _LLQIGSBASELIBAPI_H_
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
|
||||
#if defined(LLQIGSBASELIB_API)
|
||||
#define LLQGISBASELIBAPI Q_DECL_EXPORT
|
||||
#else
|
||||
#define LLQGISBASELIBAPI Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,428 +0,0 @@
|
|||
/***************************************************************************
|
||||
qgsstatusbarcoordinateswidget.cpp
|
||||
--------------------------------------
|
||||
Date : 05.08.2015
|
||||
Copyright : (C) 2015 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QFont>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpacerItem>
|
||||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "qgsstatusbarcoordinateswidget.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgscoordinateutils.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsvectorlayerjoininfo.h"
|
||||
#include "qgscoordinatereferencesystemutils.h"
|
||||
|
||||
QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
, mMousePrecisionDecimalPlaces( 0 )
|
||||
{
|
||||
// calculate the size of two chars
|
||||
mTwoCharSize = fontMetrics().boundingRect( 'O' ).width();
|
||||
mMinimumWidth = mTwoCharSize * 4;
|
||||
|
||||
// add a label to show current position
|
||||
mLabel = new QLabel( QString(), this );
|
||||
mLabel->setObjectName( QStringLiteral( "mCoordsLabel" ) );
|
||||
mLabel->setMinimumWidth( 10 );
|
||||
//mCoordsLabel->setMaximumHeight( 20 );
|
||||
mLabel->setMargin( 3 );
|
||||
mLabel->setAlignment( Qt::AlignCenter );
|
||||
mLabel->setFrameStyle( QFrame::NoFrame );
|
||||
mLabel->setText( tr( "Coordinate" ) );
|
||||
mLabel->setToolTip( tr( "Current map coordinate" ) );
|
||||
|
||||
mLineEdit = new QLineEdit( this );
|
||||
mLineEdit->setMinimumWidth( 10 );
|
||||
//mLineEdit->setMaximumHeight( 20 );
|
||||
mLineEdit->setContentsMargins( 0, 0, 0, 0 );
|
||||
mLineEdit->setAlignment( Qt::AlignCenter );
|
||||
connect( mLineEdit, &QLineEdit::returnPressed, this, &QgsStatusBarCoordinatesWidget::validateCoordinates );
|
||||
|
||||
const QRegularExpression coordValidator( "[+-]?\\d+\\.?\\d*\\s*,\\s*[+-]?\\d+\\.?\\d*" );
|
||||
mCoordsEditValidator = new QRegularExpressionValidator( coordValidator, this );
|
||||
mLineEdit->setToolTip( tr( "Current map coordinate (longitude,latitude or east,north)" ) );
|
||||
|
||||
//toggle to switch between mouse pos and extents display in status bar widget
|
||||
mToggleExtentsViewButton = new QToolButton( this );
|
||||
mToggleExtentsViewButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "tracking.svg" ) ) );
|
||||
mToggleExtentsViewButton->setToolTip( tr( "Toggle extents and mouse position display" ) );
|
||||
mToggleExtentsViewButton->setCheckable( true );
|
||||
mToggleExtentsViewButton->setAutoRaise( true );
|
||||
connect( mToggleExtentsViewButton, &QAbstractButton::toggled, this, &QgsStatusBarCoordinatesWidget::extentsViewToggled );
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout( this );
|
||||
setLayout( layout );
|
||||
layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );
|
||||
layout->addWidget( mLabel );
|
||||
layout->addWidget( mLineEdit );
|
||||
layout->addWidget( mToggleExtentsViewButton );
|
||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
layout->setAlignment( Qt::AlignRight );
|
||||
layout->setSpacing( 0 );
|
||||
|
||||
// When you feel dizzy
|
||||
mDizzyTimer = new QTimer( this );
|
||||
connect( mDizzyTimer, &QTimer::timeout, this, &QgsStatusBarCoordinatesWidget::dizzy );
|
||||
|
||||
connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::coordinateCrsChanged, this, &QgsStatusBarCoordinatesWidget::coordinateDisplaySettingsChanged );
|
||||
connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::geographicCoordinateFormatChanged, this, &QgsStatusBarCoordinatesWidget::coordinateDisplaySettingsChanged );
|
||||
connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::coordinateTypeChanged, this, &QgsStatusBarCoordinatesWidget::coordinateDisplaySettingsChanged );
|
||||
|
||||
coordinateDisplaySettingsChanged();
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
|
||||
{
|
||||
if ( mMapCanvas )
|
||||
{
|
||||
disconnect( mMapCanvas, &QgsMapCanvas::xyCoordinates, this, &QgsStatusBarCoordinatesWidget::showMouseCoordinates );
|
||||
disconnect( mMapCanvas, &QgsMapCanvas::extentsChanged, this, &QgsStatusBarCoordinatesWidget::showExtent );
|
||||
}
|
||||
|
||||
mMapCanvas = mapCanvas;
|
||||
connect( mMapCanvas, &QgsMapCanvas::xyCoordinates, this, &QgsStatusBarCoordinatesWidget::showMouseCoordinates );
|
||||
connect( mMapCanvas, &QgsMapCanvas::extentsChanged, this, &QgsStatusBarCoordinatesWidget::showExtent );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::setFont( const QFont &myFont )
|
||||
{
|
||||
mLineEdit->setFont( myFont );
|
||||
mLabel->setFont( myFont );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::setMouseCoordinatesPrecision( unsigned int precision )
|
||||
{
|
||||
mMousePrecisionDecimalPlaces = precision;
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::validateCoordinates()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "world" ) )
|
||||
{
|
||||
world();
|
||||
}
|
||||
if ( mLineEdit->text() == QLatin1String( "contributors" ) )
|
||||
{
|
||||
contributors();
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "hackfests" ) )
|
||||
{
|
||||
hackfests();
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "user groups" ) )
|
||||
{
|
||||
userGroups();
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "dizzy" ) )
|
||||
{
|
||||
// sometimes you may feel a bit dizzy...
|
||||
if ( mDizzyTimer->isActive() )
|
||||
{
|
||||
mDizzyTimer->stop();
|
||||
mMapCanvas->setSceneRect( mMapCanvas->viewport()->rect() );
|
||||
mMapCanvas->setTransform( QTransform() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mDizzyTimer->start( 100 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "retro" ) )
|
||||
{
|
||||
mMapCanvas->setProperty( "retro", !mMapCanvas->property( "retro" ).toBool() );
|
||||
refreshMapCanvas();
|
||||
return;
|
||||
}
|
||||
else if ( mLineEdit->text() == QLatin1String( "bored" ) )
|
||||
{
|
||||
// it's friday afternoon and too late to start another piece of work...
|
||||
emit weAreBored();
|
||||
}
|
||||
|
||||
bool xOk = false;
|
||||
bool yOk = false;
|
||||
double first = 0;
|
||||
double second = 0;
|
||||
QString coordText = mLineEdit->text();
|
||||
const thread_local QRegularExpression sMultipleWhitespaceRx( QStringLiteral( " {2,}" ) );
|
||||
coordText.replace( sMultipleWhitespaceRx, QStringLiteral( " " ) );
|
||||
|
||||
QStringList parts = coordText.split( ',' );
|
||||
if ( parts.size() == 2 )
|
||||
{
|
||||
first = parts.at( 0 ).toDouble( &xOk );
|
||||
second = parts.at( 1 ).toDouble( &yOk );
|
||||
}
|
||||
|
||||
if ( !xOk || !yOk )
|
||||
{
|
||||
parts = coordText.split( ' ' );
|
||||
if ( parts.size() == 2 )
|
||||
{
|
||||
first = parts.at( 0 ).toDouble( &xOk );
|
||||
second = parts.at( 1 ).toDouble( &yOk );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !xOk || !yOk )
|
||||
return;
|
||||
|
||||
const Qgis::CoordinateOrder projectAxisOrder = QgsProject::instance()->displaySettings()->coordinateAxisOrder();
|
||||
|
||||
const Qgis::CoordinateOrder coordinateOrder = projectAxisOrder == Qgis::CoordinateOrder::Default ? QgsCoordinateReferenceSystemUtils::defaultCoordinateOrderForCrs( mMapCanvas->mapSettings().destinationCrs() ) : projectAxisOrder;
|
||||
// we may need to flip coordinates depending on crs axis ordering
|
||||
switch ( coordinateOrder )
|
||||
{
|
||||
case Qgis::CoordinateOrder::Default:
|
||||
case Qgis::CoordinateOrder::XY:
|
||||
mMapCanvas->setCenter( QgsPointXY( first, second ) );
|
||||
break;
|
||||
case Qgis::CoordinateOrder::YX:
|
||||
mMapCanvas->setCenter( QgsPointXY( second, first ) );
|
||||
break;
|
||||
}
|
||||
|
||||
mMapCanvas->refresh();
|
||||
}
|
||||
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::dizzy()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
// constants should go to options so that people can customize them to their taste
|
||||
const int d = 10; // max. translational dizziness offset
|
||||
const int r = 4; // max. rotational dizzines angle
|
||||
QRectF rect = mMapCanvas->sceneRect();
|
||||
if ( rect.x() < -d || rect.x() > d || rect.y() < -d || rect.y() > d )
|
||||
return; // do not affect panning
|
||||
|
||||
rect.moveTo( static_cast< int >( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d, static_cast< int >( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d );
|
||||
mMapCanvas->setSceneRect( rect );
|
||||
QTransform matrix;
|
||||
matrix.rotate( static_cast<int >( QRandomGenerator::global()->generate() % ( 2 * r ) ) - r );
|
||||
mMapCanvas->setTransform( matrix );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::contributors()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/contributors.json" );
|
||||
const QFileInfo fileInfo = QFileInfo( fileName );
|
||||
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
|
||||
tr( "QGIS Contributors" ), QStringLiteral( "ogr" ), options );
|
||||
// Register this layer with the layers registry
|
||||
QgsProject::instance()->addMapLayer( layer );
|
||||
layer->setAutoRefreshInterval( 500 );
|
||||
layer->setAutoRefreshEnabled( true );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::world()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.gpkg|layername=countries" );
|
||||
const QFileInfo fileInfo = QFileInfo( fileName );
|
||||
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
options.forceReadOnly = true;
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
|
||||
tr( "World Map" ), QStringLiteral( "ogr" ), options );
|
||||
// Register this layer with the layers registry
|
||||
QgsProject::instance()->addMapLayer( layer );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::hackfests()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/qgis-hackfests.json" );
|
||||
const QFileInfo fileInfo = QFileInfo( fileName );
|
||||
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
|
||||
tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ), options );
|
||||
// Register this layer with the layers registry
|
||||
QgsProject::instance()->addMapLayer( layer );
|
||||
layer->setAutoRefreshInterval( 500 );
|
||||
layer->setAutoRefreshEnabled( true );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::userGroups()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.gpkg|layername=countries" );
|
||||
const QFileInfo fileInfo = QFileInfo( fileName );
|
||||
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
|
||||
tr( "User Groups" ), QStringLiteral( "ogr" ), options );
|
||||
|
||||
const QString fileNameData = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/user_groups_data.json" );
|
||||
const QFileInfo fileInfoData = QFileInfo( fileNameData );
|
||||
QgsVectorLayer *layerData = new QgsVectorLayer( fileInfoData.absoluteFilePath(),
|
||||
tr( "user_groups_data" ), QStringLiteral( "ogr" ), options );
|
||||
|
||||
// Register layers with the layers registry
|
||||
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << layer << layerData );
|
||||
|
||||
// Create join
|
||||
QgsVectorLayerJoinInfo joinInfo;
|
||||
joinInfo.setTargetFieldName( QStringLiteral( "iso_a2" ) );
|
||||
joinInfo.setJoinLayer( layerData );
|
||||
joinInfo.setJoinFieldName( QStringLiteral( "country" ) );
|
||||
joinInfo.setUsingMemoryCache( true );
|
||||
joinInfo.setPrefix( QStringLiteral( "ug_" ) );
|
||||
joinInfo.setJoinFieldNamesSubset( nullptr ); // Use all join fields
|
||||
layer->addJoin( joinInfo );
|
||||
|
||||
// Load QML for polygon symbology and maptips
|
||||
const QString fileNameStyle = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/user_groups.qml" );
|
||||
bool styleFlag = false;
|
||||
layer->loadNamedStyle( fileNameStyle, styleFlag, true );
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::extentsViewToggled( bool flag )
|
||||
{
|
||||
if ( flag )
|
||||
{
|
||||
//extents view mode!
|
||||
mToggleExtentsViewButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "extents.svg" ) ) );
|
||||
mLineEdit->setToolTip( tr( "Map coordinates for the current view extents" ) );
|
||||
mLineEdit->setReadOnly( true );
|
||||
showExtent();
|
||||
}
|
||||
else
|
||||
{
|
||||
//mouse cursor pos view mode!
|
||||
mToggleExtentsViewButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "tracking.svg" ) ) );
|
||||
mLineEdit->setToolTip( tr( "Map coordinates at mouse cursor position" ) );
|
||||
mLineEdit->setReadOnly( false );
|
||||
mLabel->setText( tr( "Coordinate" ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::refreshMapCanvas()
|
||||
{
|
||||
if ( !mMapCanvas )
|
||||
return;
|
||||
|
||||
//stop any current rendering
|
||||
mMapCanvas->stopRendering();
|
||||
mMapCanvas->redrawAllLayers();
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
|
||||
{
|
||||
mLastCoordinate = p;
|
||||
updateCoordinateDisplay();
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::showExtent()
|
||||
{
|
||||
if ( !mToggleExtentsViewButton->isChecked() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mLabel->setText( tr( "Extents" ) );
|
||||
mLineEdit->setText( QgsCoordinateUtils::formatExtentForProject( QgsProject::instance(), mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs(),
|
||||
mMousePrecisionDecimalPlaces ) );
|
||||
|
||||
ensureCoordinatesVisible();
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::ensureCoordinatesVisible()
|
||||
{
|
||||
|
||||
//ensure the label is big (and small) enough
|
||||
const int width = std::max( mLineEdit->fontMetrics().boundingRect( mLineEdit->text() ).width() + 16, mMinimumWidth );
|
||||
if ( mLineEdit->minimumWidth() < width || ( mLineEdit->minimumWidth() - width ) > mTwoCharSize )
|
||||
{
|
||||
mLineEdit->setMinimumWidth( width );
|
||||
mLineEdit->setMaximumWidth( width );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::updateCoordinateDisplay()
|
||||
{
|
||||
if ( mToggleExtentsViewButton->isChecked() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mLastCoordinate.isEmpty() )
|
||||
mLineEdit->clear();
|
||||
else
|
||||
mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), mLastCoordinate, mMapCanvas->mapSettings().destinationCrs(),
|
||||
static_cast< int >( mMousePrecisionDecimalPlaces ) ) );
|
||||
|
||||
ensureCoordinatesVisible();
|
||||
}
|
||||
|
||||
void QgsStatusBarCoordinatesWidget::coordinateDisplaySettingsChanged()
|
||||
{
|
||||
const QgsCoordinateReferenceSystem coordinateCrs = QgsProject::instance()->displaySettings()->coordinateCrs();
|
||||
|
||||
const Qgis::CoordinateOrder projectOrder = QgsProject::instance()->displaySettings()->coordinateAxisOrder();
|
||||
const Qgis::CoordinateOrder order = projectOrder == Qgis::CoordinateOrder::Default
|
||||
? QgsCoordinateReferenceSystemUtils::defaultCoordinateOrderForCrs( coordinateCrs )
|
||||
: projectOrder;
|
||||
|
||||
switch ( order )
|
||||
{
|
||||
case Qgis::CoordinateOrder::XY:
|
||||
if ( coordinateCrs.isGeographic() )
|
||||
mLineEdit->setToolTip( tr( "Current map coordinate (Longitude, Latitude)" ) );
|
||||
else
|
||||
mLineEdit->setToolTip( tr( "Current map coordinate (Easting, Northing)" ) );
|
||||
break;
|
||||
case Qgis::CoordinateOrder::YX:
|
||||
if ( coordinateCrs.isGeographic() )
|
||||
mLineEdit->setToolTip( tr( "Current map coordinate (Latitude, Longitude)" ) );
|
||||
else
|
||||
mLineEdit->setToolTip( tr( "Current map coordinate (Northing, Easting)" ) );
|
||||
break;
|
||||
case Qgis::CoordinateOrder::Default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateCoordinateDisplay();
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/***************************************************************************
|
||||
qgsstatusbarcoordinateswidget.h
|
||||
--------------------------------------
|
||||
Date : 05.08.2015
|
||||
Copyright : (C) 2015 Denis Rouzaud
|
||||
Email : denis.rouzaud@gmail.com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSSTATUSBARCOORDINATESWIDGET_H
|
||||
#define QGSSTATUSBARCOORDINATESWIDGET_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
|
||||
class QFont;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QTimer;
|
||||
class QToolButton;
|
||||
class QValidator;
|
||||
|
||||
class QgsMapCanvas;
|
||||
|
||||
#include <QWidget>
|
||||
//#include "qgis_app.h"
|
||||
#include "qgspointxy.h"
|
||||
|
||||
class LLQGISBASELIBAPI QgsStatusBarCoordinatesWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum CrsMode
|
||||
{
|
||||
MapCanvas,
|
||||
Custom
|
||||
};
|
||||
|
||||
public:
|
||||
QgsStatusBarCoordinatesWidget( QWidget *parent );
|
||||
|
||||
//! define the map canvas associated to the widget
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas );
|
||||
|
||||
void setFont( const QFont &myFont );
|
||||
|
||||
void setMouseCoordinatesPrecision( unsigned int precision );
|
||||
|
||||
signals:
|
||||
void coordinatesChanged();
|
||||
void weAreBored();
|
||||
|
||||
private slots:
|
||||
void showMouseCoordinates( const QgsPointXY &p );
|
||||
void extentsViewToggled( bool flag );
|
||||
void validateCoordinates();
|
||||
void dizzy();
|
||||
void world();
|
||||
void contributors();
|
||||
void hackfests();
|
||||
void userGroups();
|
||||
void showExtent();
|
||||
void ensureCoordinatesVisible();
|
||||
void updateCoordinateDisplay();
|
||||
void coordinateDisplaySettingsChanged();
|
||||
|
||||
private:
|
||||
void refreshMapCanvas();
|
||||
|
||||
QLineEdit *mLineEdit = nullptr;
|
||||
QToolButton *mToggleExtentsViewButton = nullptr;
|
||||
//! Widget that will live on the statusbar to display "Coordinate / Extent"
|
||||
QLabel *mLabel = nullptr;
|
||||
|
||||
QValidator *mCoordsEditValidator = nullptr;
|
||||
QTimer *mDizzyTimer = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
int mTwoCharSize = 0;
|
||||
int mMinimumWidth = 0;
|
||||
|
||||
//! The number of decimal places to use if not automatic
|
||||
unsigned int mMousePrecisionDecimalPlaces;
|
||||
|
||||
QgsPointXY mLastCoordinate;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSSTATUSBARCOORDINATESWIDGET_H
|
|
@ -1,115 +0,0 @@
|
|||
/***************************************************************************
|
||||
qgsstatusbarscalewidget.cpp
|
||||
begin : May 2016
|
||||
copyright : (C) 2016 Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QValidator>
|
||||
|
||||
#include "qgsstatusbarscalewidget.h"
|
||||
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsscalecombobox.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsprojectviewsettings.h"
|
||||
|
||||
QgsStatusBarScaleWidget::QgsStatusBarScaleWidget( QgsMapCanvas *canvas, QWidget *parent )
|
||||
: QWidget( parent )
|
||||
, mMapCanvas( canvas )
|
||||
{
|
||||
// add a label to show current scale
|
||||
mLabel = new QLabel();
|
||||
mLabel->setObjectName( QStringLiteral( "mScaleLabel" ) );
|
||||
mLabel->setMinimumWidth( 10 );
|
||||
//mScaleLabel->setMaximumHeight( 20 );
|
||||
mLabel->setMargin( 3 );
|
||||
mLabel->setAlignment( Qt::AlignCenter );
|
||||
mLabel->setFrameStyle( QFrame::NoFrame );
|
||||
mLabel->setText( tr( "Scale" ) );
|
||||
mLabel->setToolTip( tr( "Current map scale" ) );
|
||||
|
||||
mScale = new QgsScaleComboBox();
|
||||
mScale->setObjectName( QStringLiteral( "mScaleEdit" ) );
|
||||
// seems setFont() change font only for popup not for line edit,
|
||||
// so we need to set font for it separately
|
||||
mScale->setMinimumWidth( 10 );
|
||||
mScale->setContentsMargins( 0, 0, 0, 0 );
|
||||
mScale->setToolTip( tr( "Current map scale" ) );
|
||||
|
||||
// layout
|
||||
mLayout = new QHBoxLayout( this );
|
||||
mLayout->addWidget( mLabel );
|
||||
mLayout->addWidget( mScale );
|
||||
mLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
mLayout->setAlignment( Qt::AlignRight );
|
||||
mLayout->setSpacing( 0 );
|
||||
|
||||
setLayout( mLayout );
|
||||
|
||||
connect( mScale, &QgsScaleComboBox::scaleChanged, this, &QgsStatusBarScaleWidget::userScale );
|
||||
connect( mMapCanvas, &QgsMapCanvas::scaleLockChanged, this, &QgsStatusBarScaleWidget::setLocked );
|
||||
}
|
||||
|
||||
void QgsStatusBarScaleWidget::setScale( double scale )
|
||||
{
|
||||
mScale->blockSignals( true );
|
||||
mScale->setScale( scale );
|
||||
mScale->blockSignals( false );
|
||||
|
||||
if ( mScale->width() > mScale->minimumWidth() )
|
||||
{
|
||||
mScale->setMinimumWidth( mScale->width() );
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsStatusBarScaleWidget::isLocked() const
|
||||
{
|
||||
return !mScale->isEnabled();
|
||||
}
|
||||
|
||||
void QgsStatusBarScaleWidget::setLocked( bool state )
|
||||
{
|
||||
mScale->setDisabled( state );
|
||||
}
|
||||
|
||||
void QgsStatusBarScaleWidget::setFont( const QFont &font )
|
||||
{
|
||||
mLabel->setFont( font );
|
||||
mScale->lineEdit()->setFont( font );
|
||||
}
|
||||
|
||||
void QgsStatusBarScaleWidget::updateScales()
|
||||
{
|
||||
if ( QgsProject::instance()->viewSettings()->useProjectScales() )
|
||||
{
|
||||
const QVector< double > scales = QgsProject::instance()->viewSettings()->mapScales();
|
||||
QStringList textScales;
|
||||
textScales.reserve( scales.size() );
|
||||
for ( const double scale : scales )
|
||||
textScales << QStringLiteral( "1:%1" ).arg( QLocale().toString( scale, 'f', 0 ) );
|
||||
mScale->updateScales( textScales );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use global scales
|
||||
mScale->updateScales();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsStatusBarScaleWidget::userScale() const
|
||||
{
|
||||
mMapCanvas->zoomScale( mScale->scale() );
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/***************************************************************************
|
||||
qgsstatusbarscalewidget.h
|
||||
begin : May 2016
|
||||
copyright : (C) 2016 Denis Rouzaud
|
||||
email : denis.rouzaud@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSSTATUSBARSCALEWIDGET_H
|
||||
#define QGSSTATUSBARSCALEWIDGET_H
|
||||
#include "llqgisbaselibAPI.h"
|
||||
class QFont;
|
||||
class QHBoxLayout;
|
||||
class QLabel;
|
||||
class QValidator;
|
||||
|
||||
class QgsMapCanvas;
|
||||
class QgsScaleComboBox;
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
//#include "qgis_app.h"
|
||||
|
||||
/**
|
||||
* Widget to define scale of the map canvas.
|
||||
* \since QGIS 2.16
|
||||
*/
|
||||
class LLQGISBASELIBAPI QgsStatusBarScaleWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QgsStatusBarScaleWidget( QgsMapCanvas *canvas, QWidget *parent = nullptr );
|
||||
|
||||
/**
|
||||
* Set the selected \a scale from double.
|
||||
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||
*/
|
||||
void setScale( double scale );
|
||||
|
||||
/**
|
||||
* Lock the scale widget.
|
||||
* \param state the lock state
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
void setLocked( bool state );
|
||||
|
||||
/**
|
||||
* \brief isLocked check if the scale should be locked to use magnifier instead of scale to zoom in/out
|
||||
* \returns TRUE if the scale shall be locked
|
||||
*/
|
||||
bool isLocked() const;
|
||||
|
||||
/**
|
||||
* Set the font of the text
|
||||
* \param font the font to use
|
||||
*/
|
||||
void setFont( const QFont &font );
|
||||
|
||||
public slots:
|
||||
void updateScales();
|
||||
|
||||
private slots:
|
||||
void userScale() const;
|
||||
|
||||
private:
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
QHBoxLayout *mLayout = nullptr;
|
||||
|
||||
//! Widget that will live on the statusbar to display "scale 1:"
|
||||
QLabel *mLabel = nullptr;
|
||||
//! Widget that will live on the statusbar to display scale value
|
||||
QgsScaleComboBox *mScale = nullptr;
|
||||
};
|
||||
|
||||
#endif // QGSSTATUSBARSCALEWIDGET_H
|
Loading…
Reference in New Issue