码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • QGIS+qt 二次开发 缩放要素


    目录

    1 前言

    2 缩放要素

    3 代码调整

    4 如何调用

    5 最后效果


    1 前言

            上一篇文章《QGIS+qt 二次开发 移动要素》中提到了如何实现要素移动的功能,本文来说一下要素的缩放功能怎么实现。

    2 缩放要素

            打开QGIS,先导入一张shp图层文件:

     观察到要素工具栏里有缩放要素按钮,按下激活要素缩放功能。

     然后和移动要素一样,鼠标点击图层中的要素,再移动鼠标,会有缩放调整效果的展示,如下:

     

             有了之前移动要素的实现经验,我们还是先来看一下源码,在qgsmaptoolmovefeature.cpp的目录下,很快就能看见一个叫qgsmaptoolscalefeature.cpp的文件,打开看一下。

    qgsmaptoolscalefeature.cpp

    1. /***************************************************************************
    2. qgsmaptoolscalefeature.cpp - map tool for scaling features by mouse drag
    3. ---------------------
    4. Date : December 2020
    5. Copyright : (C) 2020 by roya0045
    6. Contact : ping me on github
    7. ***************************************************************************
    8. * *
    9. * This program is free software; you can redistribute it and/or modify *
    10. * it under the terms of the GNU General Public License as published by *
    11. * the Free Software Foundation; either version 2 of the License, or *
    12. * (at your option) any later version. *
    13. * *
    14. ***************************************************************************/
    15. #include
    16. #include
    17. #include
    18. #include
    19. #include
    20. #include
    21. #include
    22. #include "qgsadvanceddigitizingdockwidget.h"
    23. #include "qgsmaptoolscalefeature.h"
    24. #include "qgsfeatureiterator.h"
    25. #include "qgsgeometry.h"
    26. #include "qgslogger.h"
    27. #include "qgsmapcanvas.h"
    28. #include "qgsrubberband.h"
    29. #include "qgsvectorlayer.h"
    30. #include "qgstolerance.h"
    31. #include "qgisapp.h"
    32. #include "qgsspinbox.h"
    33. #include "qgsdoublespinbox.h"
    34. #include "qgssnapindicator.h"
    35. #include "qgsmapmouseevent.h"
    36. QgsScaleMagnetWidget::QgsScaleMagnetWidget( const QString &label, QWidget *parent )
    37. : QWidget( parent )
    38. {
    39. mLayout = new QHBoxLayout( this );
    40. mLayout->setContentsM
  • 相关阅读:
    【Ubuntu】安装企业微信(Wine)
    Git仓库4(分支操作冲突,标签管理)
    如何使用阿里云国际版控制台使用海外云服务器-Unirech
    基于混沌搜索策略的鲸鱼优化算法-附代码
    Dubbo3应用开发—XML形式的Dubbo应用开发和SpringBoot整合Dubbo开发
    看界面控件DevExpress WinForms——如何自定义辅助功能属性(下)
    Paket在Linux下使用
    Jenkins 基础配置
    vue3 快速入门系列 —— 基础
    Java模板方法模式源码剖析及使用场景
  • 原文地址:https://blog.csdn.net/dinjay/article/details/127921475
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号