463 lines
24 KiB
Markdown
463 lines
24 KiB
Markdown
|
|
SSProcessManager 是 SunvStation 地理信息系统中的核心进程管理类,提供了对工作空间、地图、几何对象选择与编辑的完整操作能力。该类通过 Mixin 设计模式将功能模块化,为高级开发者提供了灵活且强大的地理数据处理接口。本文档将系统性地介绍 SSProcessManager 的完整 API 接口、架构设计以及使用方法。
|
|||
|
|
|
|||
|
|
## 核心架构设计
|
|||
|
|
|
|||
|
|
SSProcessManager 采用多重继承的 Mixin 设计模式,将复杂的功能拆分为五个独立的模块,每个模块负责特定的领域功能。这种设计使得代码具有高度的可维护性和扩展性,同时保持了良好的关注点分离原则。
|
|||
|
|
|
|||
|
|
### 类继承结构
|
|||
|
|
|
|||
|
|
```mermaid
|
|||
|
|
classDiagram
|
|||
|
|
class SSProcessManager {
|
|||
|
|
+workspace: WorkSpace
|
|||
|
|
+map: ScaleMap
|
|||
|
|
+selGeoList: GeoBaseList
|
|||
|
|
+selNoteList: GeoBaseList
|
|||
|
|
+bufferObjList: GeoBaseList
|
|||
|
|
+curNewObj: tuple
|
|||
|
|
+logger: Logger
|
|||
|
|
+progress: Progress
|
|||
|
|
-__init__()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class SelectionMixin {
|
|||
|
|
+clearSelection()
|
|||
|
|
+clearSelectCondition()
|
|||
|
|
+setSelectCondition()
|
|||
|
|
+selectFilter()
|
|||
|
|
+getSelGeoCount()
|
|||
|
|
+getSelGeoValue()
|
|||
|
|
+setSelGeoValue()
|
|||
|
|
+updateSysSelection()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class GeoEditMixin {
|
|||
|
|
+createDefaultGeoBase()
|
|||
|
|
+createNewObjByCode()
|
|||
|
|
+createNewObjByClass()
|
|||
|
|
+setNewObjValue()
|
|||
|
|
+addNewObjPoint()
|
|||
|
|
+saveBufferObjToDatabase()
|
|||
|
|
+explodeGeoObject()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class ProjectMixin {
|
|||
|
|
+getWorkspace()
|
|||
|
|
+getCurrentMap()
|
|||
|
|
+getSysPathName()
|
|||
|
|
+getLayerCount()
|
|||
|
|
+setLayerStatus()
|
|||
|
|
+pushUndoMark()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class LogMixin {
|
|||
|
|
+set_logger()
|
|||
|
|
+log_error_msg()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
class ProgressMixin {
|
|||
|
|
+disable_progress()
|
|||
|
|
+startProgress()
|
|||
|
|
+stepProgress()
|
|||
|
|
+closeProgress()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SSProcessManager --> SelectionMixin
|
|||
|
|
SSProcessManager --> GeoEditMixin
|
|||
|
|
SSProcessManager --> ProjectMixin
|
|||
|
|
SSProcessManager --> LogMixin
|
|||
|
|
SSProcessManager --> ProgressMixin
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 模块职责划分
|
|||
|
|
|
|||
|
|
**SelectionMixin** - 负责选择集管理,提供条件过滤、属性读写和系统选择集同步功能
|
|||
|
|
**GeoEditMixin** - 负责地理对象编辑,包括对象创建、属性设置、缓存管理和打散操作
|
|||
|
|
**ProjectMixin** - 负责项目和工作空间管理,包括图层控制、路径管理和地图帧操作
|
|||
|
|
**LogMixin** - 负责日志记录,提供统一的错误日志接口
|
|||
|
|
**ProgressMixin** - 负责进度条管理,提供可视化进度反馈
|
|||
|
|
|
|||
|
|
Sources: [PySSProcess.py](PySSProcess.py#L40-L63)
|
|||
|
|
|
|||
|
|
## 选择集操作 API
|
|||
|
|
|
|||
|
|
选择集操作是 SSProcessManager 的核心功能之一,提供了强大的条件查询和属性管理能力。选择集分为脚本选择集和系统选择集,两者可以通过特定方法进行双向同步。
|
|||
|
|
|
|||
|
|
### 基础选择集管理
|
|||
|
|
|
|||
|
|
`clearSelection()` - 清除脚本选择集中的全部点线面和注记对象。此方法不会影响地图显示的选择集,仅清理脚本内部的缓存。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L36-L43)
|
|||
|
|
|
|||
|
|
`clearSelectCondition()` - 清除所有已设置的选择条件。在执行新的查询前,通常需要调用此方法以避免条件累积。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L45-L52)
|
|||
|
|
|
|||
|
|
`clearSysSelection()` - 清除地图上的系统选择集并触发选择变更事件。此方法会影响地图的显示状态。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L139-L142)
|
|||
|
|
|
|||
|
|
### 条件设置与过滤
|
|||
|
|
|
|||
|
|
`setSelectCondition(conditionName, operateMode, conditionValue)` - 向选择条件集合中添加过滤条件。条件支持三种类型:
|
|||
|
|
|
|||
|
|
| 条件类型 | 前缀符号 | 示例 | 说明 |
|
|||
|
|
|---------|---------|------|------|
|
|||
|
|
| 基本属性 | SSObj_ | SSObj_Code, SSObj_Name | 对象固有属性 |
|
|||
|
|
| 几何特性 | <> | <Overlap>, <Close> | 几何拓扑关系 |
|
|||
|
|
| 扩展属性 | [] | [JG], [CS] | 用户自定义属性 |
|
|||
|
|
|
|||
|
|
支持的运算符包括:`==`, `>`, `<`, `<>`, `LIKE`, `NOT LIKE`, `CompareNoCase`(不区分大小写比较), `Dec`(小数位控制)
|
|||
|
|
|
|||
|
|
Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L54-L122)
|
|||
|
|
|
|||
|
|
`selectFilter()` - 执行选择集过滤操作。该方法会清除旧的字段缓存,根据当前设置的条件从数据源中筛选对象,并将结果分类存储到 `selGeoList`(点线面)和 `selNoteList`(注记)中。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L124-L145)
|
|||
|
|
|
|||
|
|
### 选择集查询
|
|||
|
|
|
|||
|
|
`getSelGeoCount()` - 返回脚本选择集中点线面对象的数量。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L147-L154)
|
|||
|
|
|
|||
|
|
`getSelNoteCount()` - 返回脚本选择集中注记对象的数量。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L156-L163)
|
|||
|
|
|
|||
|
|
`getSysSelGeoList()` - 获取地图当前选中的几何对象列表。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L166-L177)
|
|||
|
|
|
|||
|
|
`getSysSelNoteList()` - 获取地图当前选中的注记对象列表。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L179-L190)
|
|||
|
|
|
|||
|
|
### 属性读写
|
|||
|
|
|
|||
|
|
`getSelGeoValue(index, fieldName)` - 获取选择集中指定索引对象的属性值。该方法会自动识别属性类型:
|
|||
|
|
|
|||
|
|
- **基本属性**:以 `SSObj_` 开头,直接通过 `ObjBaseAttr` 获取
|
|||
|
|
- **扩展属性**:以 `[]` 包裹,从扩展属性表中查询
|
|||
|
|
- **多属性查询**:支持使用逗号分隔多个属性名,如 `[JG,CS]`
|
|||
|
|
|
|||
|
|
Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L175-L219)
|
|||
|
|
|
|||
|
|
`getSelNoteValue(index, fieldName)` - 获取注记对象的属性值,方法与 `getSelGeoValue` 类似。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L221-L265)
|
|||
|
|
|
|||
|
|
`setSelGeoValue(index, fieldName, value)` - 设置选择集中指定对象的属性值。特殊处理:
|
|||
|
|
|
|||
|
|
- **SSObj_Code**:修改对象编码时直接设置整数值
|
|||
|
|
- **SSObj_LayerName**:修改图层时需要克隆对象、删除原始对象并创建新对象,同时保留扩展属性
|
|||
|
|
- **其他属性**:通过 `ObjBaseAttr` 统一处理
|
|||
|
|
|
|||
|
|
Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L267-L320)
|
|||
|
|
|
|||
|
|
`setSelNoteValue(index, fieldName, value)` - 设置注记对象的属性值。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L322-L375)
|
|||
|
|
|
|||
|
|
### 坐标操作
|
|||
|
|
|
|||
|
|
`getSelGeoPoint(index, pointIndex)` - 获取选择集中指定对象的指定点坐标。返回值为 `Point3D` 对象。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L385-L400)
|
|||
|
|
|
|||
|
|
`deleteSelGeoPoint(index, pointIndex)` - 删除选择集中指定对象的指定点。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L541-L553)
|
|||
|
|
|
|||
|
|
### 选择集同步
|
|||
|
|
|
|||
|
|
`updateSysSelection(mode)` - 实现脚本选择集与系统选择集的双向同步。mode 参数控制同步方向:
|
|||
|
|
|
|||
|
|
| mode | 同步方向 | 说明 |
|
|||
|
|
|------|---------|------|
|
|||
|
|
| 0 | 系统 → 脚本 | 从地图选择集同步到脚本选择集 |
|
|||
|
|
| 1 | 脚本 → 系统 | 从脚本选择集同步到地图选择集(更新显示) |
|
|||
|
|
| 2 | 脚本 → 系统 | 从脚本选择集同步到地图选择集(不更新显示) |
|
|||
|
|
|
|||
|
|
Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L147-L168)
|
|||
|
|
|
|||
|
|
## 地理对象编辑 API
|
|||
|
|
|
|||
|
|
地理对象编辑模块提供了完整的对象生命周期管理能力,包括创建、修改、缓存和持久化等操作。
|
|||
|
|
|
|||
|
|
### 对象创建
|
|||
|
|
|
|||
|
|
`createDefaultGeoBase(obj_type, dataset)` - 创建基础几何对象。obj_type 参数指定对象类型:
|
|||
|
|
|
|||
|
|
| obj_type | 几何类型 | 对应类 |
|
|||
|
|
|----------|---------|--------|
|
|||
|
|
| 0 | 点 | PointObject |
|
|||
|
|
| 1 | 线 | LineObject |
|
|||
|
|
| 2 | 面 | AreaObject |
|
|||
|
|
| 3 | 注记 | MarkNote |
|
|||
|
|
|
|||
|
|
返回值为包含 `GeoObject` 和具体几何对象的元组。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L62-L89)
|
|||
|
|
|
|||
|
|
`createNewObjByCode(code)` - 根据要素代码创建新对象。该方法会自动查询要素代码表,获取对应的数据集、对象类型和样式属性,并创建完整的几何对象。创建成功后会更新 `curNewObj` 成员变量。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L113-L154)
|
|||
|
|
|
|||
|
|
`createNewObjByClass(noteClass)` - 根据注记分类号创建新注记对象。该方法会从注记模板表中获取模板,创建注记对象并应用模板样式。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L156-L180)
|
|||
|
|
|
|||
|
|
### 新建对象操作
|
|||
|
|
|
|||
|
|
`setNewObjValue(fieldName, value)` - 设置当前新建对象的属性值。该方法支持批量属性设置,用逗号分隔多个属性名和值。属性类型自动识别:
|
|||
|
|
|
|||
|
|
- **扩展属性**:以 `[]` 包裹,直接设置到 memoData
|
|||
|
|
- **基本属性**:以 `SSObj_` 开头,调用对应设置方法
|
|||
|
|
- **注记专属属性**:仅当对象类型为注记时有效
|
|||
|
|
|
|||
|
|
Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L182-L349)
|
|||
|
|
|
|||
|
|
`addNewObjPoint(x, y, z, type, name)` - 向当前新建对象添加坐标点。type 参数使用二进制位存储点信息枚举。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L351-L371)
|
|||
|
|
|
|||
|
|
`deleteNewObj()` - 删除当前新建对象并清理 `curNewObj` 成员变量。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L373-L382)
|
|||
|
|
|
|||
|
|
`addNewObjToSelObjList()` - 将当前新建对象添加到脚本选择集。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L384-L394)
|
|||
|
|
|
|||
|
|
`addNewObjToSaveObjList()` - 将当前新建对象添加到持久化保存列表。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L396-L407)
|
|||
|
|
|
|||
|
|
### 缓存与持久化
|
|||
|
|
|
|||
|
|
`saveBufferObjToDatabase()` - 将缓存的对象批量保存到数据库。该方法处理三种缓存类型:
|
|||
|
|
|
|||
|
|
1. **新建对象缓存**:`newBufferObjList` 和 `newBufferNoteList`
|
|||
|
|
2. **修改对象缓存**:`bufferObjList` 和 `bufferNoteList`
|
|||
|
|
3. **删除对象缓存**:`delBufferGeoList`
|
|||
|
|
|
|||
|
|
保存时会将 memoData 转换为扩展属性,确保数据完整性。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L427-L456)
|
|||
|
|
|
|||
|
|
`transMemoDataToExtendAttr(geoList)` - 将几何对象的备忘数据转换为扩展属性。该方法使用事务模式批量更新,提高性能。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L409-L424)
|
|||
|
|
|
|||
|
|
`addSelGeoToSaveGeoList(index)` - 将选择集中的几何对象添加到保存缓存。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L555-L566)
|
|||
|
|
|
|||
|
|
`addSelNoteToSaveNoteList(index)` - 将选择集中的注记对象添加到保存缓存。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L568-L579)
|
|||
|
|
|
|||
|
|
### 对象重置
|
|||
|
|
|
|||
|
|
`resetSelGeoByCode(index, code)` - 根据要素代码重置选择集中的几何对象。该方法会:
|
|||
|
|
|
|||
|
|
1. 查询新代码对应的特征信息
|
|||
|
|
2. 如果在相同数据集,仅修改代码
|
|||
|
|
3. 如果在不同数据集,创建新对象并复制几何和扩展属性
|
|||
|
|
4. 将旧对象加入删除缓存,新对象加入新建缓存
|
|||
|
|
|
|||
|
|
Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L381-L451)
|
|||
|
|
|
|||
|
|
`resetSelNoteByClass(index, noteClass)` - 根据注记分类号重置选择集中的注记对象。逻辑与 `resetSelGeoByCode` 类似,但处理注记特有属性。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L453-L511)
|
|||
|
|
|
|||
|
|
### 对象打散
|
|||
|
|
|
|||
|
|
`explodeGeoObject(geo, explodeWay, callback)` - 将几何对象打散为多个子对象。explodeWay 参数控制打散方式:
|
|||
|
|
|
|||
|
|
| explodeWay | 打散方式 | 说明 |
|
|||
|
|
|-----------|---------|------|
|
|||
|
|
| 0 | 图形打散 | 保持颜色,打散为基本图形 |
|
|||
|
|
| 1 | 按编码表打散 | 根据符号表进行分解 |
|
|||
|
|
| 11 | 拆分为线 | 转换为线对象列表 |
|
|||
|
|
| 12 | 拆分环 | 按环拆分复杂多边形 |
|
|||
|
|
|
|||
|
|
callback 参数为回调函数名,用于处理打散后的对象。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L577-L762)
|
|||
|
|
|
|||
|
|
`explodeNoteObject(note, forExchange, callback)` - 将注记对象打散为多个子注记。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L509-L576)
|
|||
|
|
|
|||
|
|
`explodeSelectionObj(explodeWay, delSrcObj, callback)` - 批量打散选择集中的所有对象。delSrcObj 参数控制是否删除原始对象。Sources: [selection_mixin.py](ssprocess_mixins/selection_mixin.py#L600-L655)
|
|||
|
|
|
|||
|
|
### 辅助计算
|
|||
|
|
|
|||
|
|
`getPolar(pt0, pt1)` - 计算两点之间的距离和角度。返回值为 `(距离, 角度)` 元组。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L91-L105)
|
|||
|
|
|
|||
|
|
`getPoint(pt0, dist, angle)` - 根据起点、距离和角度计算终点坐标。返回值为 `Point3D` 对象。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L107-L119)
|
|||
|
|
|
|||
|
|
`getObjectAttr(objId, attrField)` - 根据对象 ID 获取属性值。该方法会先查询对象是否存在,然后读取指定属性。Sources: [geo_edit_mixin.py](ssprocess_mixins/geo_edit_mixin.py#L458-L507)
|
|||
|
|
|
|||
|
|
## 项目与工作空间 API
|
|||
|
|
|
|||
|
|
项目模块提供了对 SunvStation 工作空间和地图环境的高级访问能力,包括图层管理、路径操作和地图帧控制等功能。
|
|||
|
|
|
|||
|
|
### 工作空间与地图
|
|||
|
|
|
|||
|
|
`getWorkspace()` - 获取当前工作空间实例。工作空间是 SunvStation 数据组织的顶层容器。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L22-L32)
|
|||
|
|
|
|||
|
|
`getCurrentMap()` - 获取当前比例尺地图实例。地图是地理对象的显示和管理容器。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L34-L43)
|
|||
|
|
|
|||
|
|
`pushUndoMark(action)` - 创建撤销标记。在执行可撤销操作前调用此方法,action 参数描述操作名称,默认为 "CommandGroup"。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L45-L58)
|
|||
|
|
|
|||
|
|
### 系统路径管理
|
|||
|
|
|
|||
|
|
`getSysPathName(mode)` - 根据模式获取系统路径。mode 参数支持的路径类型:
|
|||
|
|
|
|||
|
|
| mode | 路径类型 | 说明 |
|
|||
|
|
|------|---------|------|
|
|||
|
|
| 0 | 配置路径 | GlobalOptions 配置目录 |
|
|||
|
|
| 1 | 模板路径 | 系统模板目录 |
|
|||
|
|
| 2 | Comm路径 | 通用文件目录 |
|
|||
|
|
| 3 | Script路径 | 脚本文件目录 |
|
|||
|
|
| 4 | SSTemp路径 | 临时文件目录 |
|
|||
|
|
| 5 | 工程文件路径 | 当前工程所在目录 |
|
|||
|
|
| 6 | 系统目录 | Windows/System32 或 /usr |
|
|||
|
|
| 7/8 | 方案路径 | 当前方案文件目录 |
|
|||
|
|
|
|||
|
|
Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L60-L118)
|
|||
|
|
|
|||
|
|
### 图层管理
|
|||
|
|
|
|||
|
|
`getLayerCount()` - 获取当前地图中的图层数量。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L175-L184)
|
|||
|
|
|
|||
|
|
`getLayerName(index)` - 获取指定索引的图层名称。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L186-L198)
|
|||
|
|
|
|||
|
|
`setLayerStatus(layerName, status, type)` - 设置图层状态。type 参数控制状态类型:
|
|||
|
|
|
|||
|
|
| type | 控制类型 | status 含义 |
|
|||
|
|
|------|---------|------------|
|
|||
|
|
| 1 | 图层显示 | True=可见,False=隐藏 |
|
|||
|
|
| 2 | 编辑锁定 | True=锁定,False=解锁 |
|
|||
|
|
|
|||
|
|
Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L200-L215)
|
|||
|
|
|
|||
|
|
### 地图帧操作
|
|||
|
|
|
|||
|
|
`createMapFrame()` - 创建地图帧。该方法会计算地图范围并生成地图帧点列表。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L120-L149)
|
|||
|
|
|
|||
|
|
`getMapFrameCount()` - 获取地图帧数量。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L151-L154)
|
|||
|
|
|
|||
|
|
`getMapFrameCenterPoint(index)` - 获取指定地图帧的中心点坐标。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L156-L163)
|
|||
|
|
|
|||
|
|
`setCurMapFrame(x, y)` - 设置当前地图帧。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L165-L171)
|
|||
|
|
|
|||
|
|
`getCurMapFrame()` - 获取当前地图帧的对象 ID。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L173-L178)
|
|||
|
|
|
|||
|
|
`getMapFrameNumber(x, y)` - 获取指定坐标所在的地图帧编号。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L180-L186)
|
|||
|
|
|
|||
|
|
`freeMapFrame()` - 释放地图帧缓存。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L188-L190)
|
|||
|
|
|
|||
|
|
### 系统表管理
|
|||
|
|
|
|||
|
|
`getFeatureCodeTB()` - 获取当前要素代码表名称。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L217-L226)
|
|||
|
|
|
|||
|
|
`getSymbolScriptTB()` - 获取当前符号表名称。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L228-L237)
|
|||
|
|
|
|||
|
|
`getNoteTemplateTB()` - 获取当前注记模板表名称。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L239-L248)
|
|||
|
|
|
|||
|
|
`setFeatureCodeTB(featureCodeTB, symbolScriptTB)` - 设置要素代码表和符号表。如果与当前设置不同,会重新加载并触发系统表变更事件。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L250-L262)
|
|||
|
|
|
|||
|
|
`setNoteTemplateTB(noteTemplateTB)` - 设置注记模板表。Sources: [project_mixin.py](ssprocess_mixins/project_mixin.py#L264-L273)
|
|||
|
|
|
|||
|
|
## 进度与日志 API
|
|||
|
|
|
|||
|
|
进度和日志模块为长时间操作提供了用户反馈和错误跟踪能力。
|
|||
|
|
|
|||
|
|
### 进度条管理
|
|||
|
|
|
|||
|
|
`disable_progress()` - 禁用进度条显示并立即关闭当前进度条。Sources: [progress_mixin.py](ssprocess_mixins/progress_mixin.py#L35-L44)
|
|||
|
|
|
|||
|
|
`startProgress(title, total)` - 创建并启动进度条。title 为进度条标题,total 为总进度值。Sources: [progress_mixin.py](ssprocess_mixins/progress_mixin.py#L46-L58)
|
|||
|
|
|
|||
|
|
`stepProgress(message)` - 更新进度条。message 为当前步骤描述信息。Sources: [progress_mixin.py](ssprocess_mixins/progress_mixin.py#L60-L70)
|
|||
|
|
|
|||
|
|
`closeProgress()` - 关闭进度条。Sources: [progress_mixin.py](ssprocess_mixins/progress_mixin.py#L72-L78)
|
|||
|
|
|
|||
|
|
### 日志记录
|
|||
|
|
|
|||
|
|
`set_logger(logger)` - 设置日志记录器实例。Sources: [log_mixin.py](ssprocess_mixins/log_mixin.py#L34-L37)
|
|||
|
|
|
|||
|
|
`log_error_msg(error_msg)` - 记录错误日志。如果设置了 logger,调用 logger.error();否则使用 print 输出。Sources: [log_mixin.py](ssprocess_mixins/log_mixin.py#L39-L42)
|
|||
|
|
|
|||
|
|
## 完整 API 参考表
|
|||
|
|
|
|||
|
|
下表列出了 SSProcessManager 的所有公共方法及其所属模块:
|
|||
|
|
|
|||
|
|
| 方法名 | 所属模块 | 功能描述 | 返回值 |
|
|||
|
|
|--------|---------|---------|--------|
|
|||
|
|
| **选择集操作** |
|
|||
|
|
| `clearSelection()` | SelectionMixin | 清除脚本选择集 | None |
|
|||
|
|
| `clearSelectCondition()` | SelectionMixin | 清除选择条件 | None |
|
|||
|
|
| `setSelectCondition(name, mode, value)` | SelectionMixin | 添加选择条件 | None |
|
|||
|
|
| `selectFilter()` | SelectionMixin | 执行过滤查询 | None |
|
|||
|
|
| `getSelGeoCount()` | SelectionMixin | 获取点线面对象数量 | int |
|
|||
|
|
| `getSelNoteCount()` | SelectionMixin | 获取注记对象数量 | int |
|
|||
|
|
| `getSelGeoValue(index, fieldName)` | SelectionMixin | 获取几何对象属性 | str |
|
|||
|
|
| `getSelNoteValue(index, fieldName)` | SelectionMixin | 获取注记对象属性 | str |
|
|||
|
|
| `setSelGeoValue(index, fieldName, value)` | SelectionMixin | 设置几何对象属性 | None |
|
|||
|
|
| `setSelNoteValue(index, fieldName, value)` | SelectionMixin | 设置注记对象属性 | None |
|
|||
|
|
| `getSelGeoPoint(index, pointIndex)` | SelectionMixin | 获取坐标点 | Point3D |
|
|||
|
|
| `deleteSelGeoPoint(index, pointIndex)` | SelectionMixin | 删除坐标点 | bool |
|
|||
|
|
| `updateSysSelection(mode)` | SelectionMixin | 同步选择集 | None |
|
|||
|
|
| `getSysSelGeoList()` | SelectionMixin | 获取系统几何选择集 | GeoBaseList |
|
|||
|
|
| `getSysSelNoteList()` | SelectionMixin | 获取系统注记选择集 | GeoBaseList |
|
|||
|
|
| `clearSysSelection()` | SelectionMixin | 清除系统选择集 | None |
|
|||
|
|
| `resetSelGeoByCode(index, code)` | SelectionMixin | 按代码重置对象 | bool |
|
|||
|
|
| `resetSelNoteByClass(index, noteClass)` | SelectionMixin | 按分类重置注记 | bool |
|
|||
|
|
| `addSelGeoToSaveGeoList(index)` | SelectionMixin | 添加到保存列表 | None |
|
|||
|
|
| `addSelNoteToSaveNoteList(index)` | SelectionMixin | 添加注记到保存列表 | None |
|
|||
|
|
| `explodeSelectionObj(explodeWay, delSrcObj, callback)` | SelectionMixin | 批量打散对象 | bool |
|
|||
|
|
| **对象编辑** |
|
|||
|
|
| `createDefaultGeoBase(obj_type, dataset)` | GeoEditMixin | 创建基础几何对象 | tuple |
|
|||
|
|
| `createNewObjByCode(code)` | GeoEditMixin | 按代码创建对象 | tuple |
|
|||
|
|
| `createNewObjByClass(noteClass)` | GeoEditMixin | 按分类创建注记 | tuple |
|
|||
|
|
| `setNewObjValue(fieldName, value)` | GeoEditMixin | 设置新建对象属性 | bool |
|
|||
|
|
| `addNewObjPoint(x, y, z, type, name)` | GeoEditMixin | 添加坐标点 | bool |
|
|||
|
|
| `deleteNewObj()` | GeoEditMixin | 删除新建对象 | None |
|
|||
|
|
| `addNewObjToSelObjList()` | GeoEditMixin | 添加到选择集 | None |
|
|||
|
|
| `addNewObjToSaveObjList()` | GeoEditMixin | 添加到保存列表 | None |
|
|||
|
|
| `saveBufferObjToDatabase()` | GeoEditMixin | 保存缓存到数据库 | None |
|
|||
|
|
| `transMemoDataToExtendAttr(geoList)` | GeoEditMixin | 转换扩展属性 | None |
|
|||
|
|
| `explodeGeoObject(geo, explodeWay, callback)` | GeoEditMixin | 打散几何对象 | tuple |
|
|||
|
|
| `explodeNoteObject(note, forExchange, callback)` | GeoEditMixin | 打散注记对象 | tuple |
|
|||
|
|
| `getPolar(pt0, pt1)` | GeoEditMixin | 计算距离和角度 | tuple |
|
|||
|
|
| `getPoint(pt0, dist, angle)` | GeoEditMixin | 计算终点坐标 | Point3D |
|
|||
|
|
| `getObjectAttr(objId, attrField)` | GeoEditMixin | 获取对象属性 | str |
|
|||
|
|
| **项目工作空间** |
|
|||
|
|
| `getWorkspace()` | ProjectMixin | 获取工作空间实例 | WorkSpace |
|
|||
|
|
| `getCurrentMap()` | ProjectMixin | 获取地图实例 | ScaleMap |
|
|||
|
|
| `pushUndoMark(action)` | ProjectMixin | 创建撤销标记 | None |
|
|||
|
|
| `getSysPathName(mode)` | ProjectMixin | 获取系统路径 | str |
|
|||
|
|
| `getLayerCount()` | ProjectMixin | 获取图层数量 | int |
|
|||
|
|
| `getLayerName(index)` | ProjectMixin | 获取图层名称 | str |
|
|||
|
|
| `setLayerStatus(name, status, type)` | ProjectMixin | 设置图层状态 | bool |
|
|||
|
|
| `createMapFrame()` | ProjectMixin | 创建地图帧 | bool |
|
|||
|
|
| `getMapFrameCount()` | ProjectMixin | 获取地图帧数量 | int |
|
|||
|
|
| `getMapFrameCenterPoint(index)` | ProjectMixin | 获取地图帧中心点 | tuple |
|
|||
|
|
| `setCurMapFrame(x, y)` | ProjectMixin | 设置当前地图帧 | GeoBase |
|
|||
|
|
| `getCurMapFrame()` | ProjectMixin | 获取当前地图帧ID | int |
|
|||
|
|
| `getMapFrameNumber(x, y)` | ProjectMixin | 获取地图帧编号 | int |
|
|||
|
|
| `freeMapFrame()` | ProjectMixin | 释放地图帧缓存 | None |
|
|||
|
|
| `getFeatureCodeTB()` | ProjectMixin | 获取要素代码表名 | str |
|
|||
|
|
| `getSymbolScriptTB()` | ProjectMixin | 获取符号表名 | str |
|
|||
|
|
| `getNoteTemplateTB()` | ProjectMixin | 获取注记模板表名 | str |
|
|||
|
|
| `setFeatureCodeTB(featTB, symTB)` | ProjectMixin | 设置要素代码表 | bool |
|
|||
|
|
| `setNoteTemplateTB(noteTB)` | ProjectMixin | 设置注记模板表 | bool |
|
|||
|
|
| **进度与日志** |
|
|||
|
|
| `disable_progress()` | ProgressMixin | 禁用进度条 | None |
|
|||
|
|
| `startProgress(title, total)` | ProgressMixin | 启动进度条 | None |
|
|||
|
|
| `stepProgress(message)` | ProgressMixin | 更新进度条 | None |
|
|||
|
|
| `closeProgress()` | ProgressMixin | 关闭进度条 | None |
|
|||
|
|
| `set_logger(logger)` | LogMixin | 设置日志记录器 | None |
|
|||
|
|
| `log_error_msg(error_msg)` | LogMixin | 记录错误日志 | None |
|
|||
|
|
|
|||
|
|
Sources: [PySSProcess.py](PySSProcess.py#L1-L140)
|
|||
|
|
|
|||
|
|
## 实例化与使用
|
|||
|
|
|
|||
|
|
SSProcessManager 提供了一个全局单例 `SSProcess`,供开发者直接使用:
|
|||
|
|
|
|||
|
|
```python
|
|||
|
|
from sunvpy.PySSProcess import SSProcess
|
|||
|
|
|
|||
|
|
# 清除选择条件和选择集
|
|||
|
|
SSProcess.clearSelectCondition()
|
|||
|
|
SSProcess.clearSelection()
|
|||
|
|
|
|||
|
|
# 设置选择条件并执行过滤
|
|||
|
|
SSProcess.setSelectCondition("SSObj_Code", "==", "3103013")
|
|||
|
|
SSProcess.selectFilter()
|
|||
|
|
|
|||
|
|
# 遍历选择集
|
|||
|
|
count = SSProcess.getSelGeoCount()
|
|||
|
|
for i in range(count):
|
|||
|
|
code = SSProcess.getSelGeoValue(i, "SSObj_Code")
|
|||
|
|
name = SSProcess.getSelGeoValue(i, "SSObj_Name")
|
|||
|
|
print(f"对象 {i}: 编码={code}, 名称={name}")
|
|||
|
|
|
|||
|
|
# 修改属性
|
|||
|
|
SSProcess.setSelGeoValue(i, "SSObj_Name", f"新名称_{i}")
|
|||
|
|
|
|||
|
|
# 添加到保存列表
|
|||
|
|
SSProcess.addSelGeoToSaveGeoList(i)
|
|||
|
|
|
|||
|
|
# 批量保存到数据库
|
|||
|
|
SSProcess.pushUndoMark("批量修改属性")
|
|||
|
|
SSProcess.saveBufferObjToDatabase()
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Sources: [PySSProcess.py](PySSProcess.py#L110-L140)
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
|
|||
|
|
要深入了解特定功能模块,请参考以下文档:
|
|||
|
|
|
|||
|
|
- [使用 SSProcess 管理选择集](4-shi-yong-ssprocess-guan-li-xuan-ze-ji) - 选择集操作的最佳实践和示例
|
|||
|
|
- [创建默认地物对象](19-chuang-jian-mo-ren-di-wu-dui-xiang) - 对象创建的详细教程
|
|||
|
|
- [批量保存到数据库](24-pi-liang-bao-cun-dao-shu-ju-ku) - 缓存机制和批量保存策略
|
|||
|
|
- [撤销标记管理](25-che-xiao-biao-ji-guan-li) - 撤销功能的实现原理
|
|||
|
|
- [配置日志记录器](37-pei-zhi-ri-zhi-ji-lu-qi) - 日志系统的配置方法
|
|||
|
|
- [进度条使用指南](38-jin-du-tiao-shi-yong-zhi-nan) - 进度反馈的最佳实践
|