当前位置:网站首页>【项目实训】线形组件的细节
【项目实训】线形组件的细节
2022-06-23 05:59:00 【从冬】
组件大致可以分为矩形类组件和线形组件,矩形组件最典型的就是普通矩形,它的变化形式较为规范,变换过程中外部轮廓始终是矩形。线形的变化则相对灵活,线形组件的绘制由转折点构成,按照特定的顺序连接。
线形组件面临着一些细节问题
1.线形组件关键点的增加和减少。
2.如何正确维护线形组件关键点的顺序。
对于第一个问题,采用动态数组去维护线形组件的关键点顺序。
当移动透明关键点时,改关键点会变为非透明点,而且该点分别与其相邻的节点的中点会产生新的节点,产生新节点后,要将其插入改关键点的前后相邻位置。
关键代码
//透明关键点
*now += createPoint(dx, dy);
now->setVirtual(0);
auto nextP = pointList[realId + 1];
auto preP = pointList[realId - 1];
double n,nextN,preN;
if(nextP->getId() == "end"){
nextN = 1;
}
else{
nextN = stod(nextP->getId());
}
if(preP->getId() == "start"){
preN = 0;
}
else{
preN = stod(preP->getId());
}
n = std::stod(now->getId());
std::string name1 = std::to_string((n + preN)/2.0);
//"mid" + std::to_string(ndSize++);
std::string name2 = std::to_string((n+nextN)/2.0);
//"mid" + std::to_string(ndSize++);
auto m1 = createCorePoint(name1, (now->getX() + preP->getX()) / 2,
(now->getY() + preP->getY()) / 2);
auto m2 = createCorePoint(name2, (now->getX() + nextP->getX()) / 2,
(now->getY() + nextP->getY()) / 2);
m1->setVirtual(1);
m2->setVirtual(1);
setCorePoints({m1, m2});
pointList.insert(pointList.begin() + realId + 1, m2);
pointList.insert(pointList.begin() + realId, m1);对于第二个问题,主要是在save与load的时候会碰到,由于线的关键点变化并没有规律,每个关键点的id对于区分顺序便显得尤为重要。
最终采取的方式是将起点和终点的id分别设为“0”和“1”,中间点设为“0.5”,当“0”与“0.5”之间产生新的关键点时,新关键点id是“0.25”。
关键点的id公式为:(pre.id+next.id)/2
由此,点的id越小,其位置越靠前,便可以通过id区分关键点的顺序
边栏推荐
- 聚焦智慧城市,华为携手中科星图共同开拓数字化新蓝海
- centos7 mysql 记录
- Easy EDA learning notes 09 esp32-wroom-32e module esp32-devkitc-v4 development board one click download circuit
- 1161 Merging Linked Lists
- mysql 基础查询
- Detailed explanation of callback function
- 利用fuser查看文件使用情况
- mingw-w64、msys和ffmpeg的配置与编译
- 如何迁移virtualbox 的虚拟机到hype-v
- 关于监督
猜你喜欢

Measurement principle and thickness measurement mode of spectral confocal

idea自动生成serialVersionUID

leetcode - 572. A subtree of another tree

Chrome删除重复书签

如何迁移virtualbox 的虚拟机到hype-v

QT设计师无法修改窗口大小,无法通过鼠标拖动窗口改变大小的解决方案

redux Actions may not have an undefined “type“ property. Have you misspelled a constant?

Sword finger offer 42 Maximum sum of successive subarrays

【STL】关联容器之map用法总结

ssm + ftp +ueditor
随机推荐
Qt 中 QVariant 使用总结
中台库存中的实仓与虚仓的业务逻辑设计
js中if逻辑过多,常见优化
20220621 Three Conjugates of Dual Quaternions
疫情下的传媒产业,小程序生态驱动数字化转型探索
centos7 mysql 记录
QT中的item views与Item widgets控件的用法总结
Haas506 2.0 development tutorial - Advanced Component Library -modem Sim (only supports versions above 2.2)
How to view native IP
redux Actions may not have an undefined “type“ property. Have you misspelled a constant?
常见设置模式(抽象工厂&责任链模式&观察者模式)
mysql 优化
js 动态创建a href 循环下载文件只能下载10个或者固定数目的问题
leetcode - 572. 另一棵树的子树
DQL、DML、DDL、DCL的概念与区别
Centos7 MySQL records
【STL】关联容器之unordered_map用法总结
Storage mode of data in memory (C language)
Concepts and differences of DQL, DML, DDL and DCL
Mysql5.6 (5.7-8) is based on shardingsphere5.1.1 sharding proxy mode. Read / write separation