Moved render_types.h, section_view.h, viewport_layout.h from include/vde/render/ to include/vde_render/ Moved appearance.h from include/vde/brep/ to include/vde_render/ (was orphan file) Updated all include paths and cross-references
155 lines
4.9 KiB
C++
155 lines
4.9 KiB
C++
#pragma once
|
||
/**
|
||
* @file viewport_layout.h
|
||
* @brief Multi-Viewport Layout API (VDE-211)
|
||
*
|
||
* 在 vde::render 命名空间下提供多视口布局管理功能:
|
||
* - 视口布局类型(单视图/水平分割/垂直分割/四象限/三左/三右/自定义)
|
||
* - 视口相机状态管理
|
||
* - 活动视口切换
|
||
* - 视口像素区域边界查询
|
||
* - 分割线样式
|
||
*
|
||
* @ingroup render
|
||
*/
|
||
|
||
#include "vde_render/render_types.h"
|
||
#include <vector>
|
||
#include <cstdint>
|
||
|
||
namespace vde::render {
|
||
|
||
// ═══════════════════════════════════════════════
|
||
// ViewportLayoutType 枚举
|
||
// ═══════════════════════════════════════════════
|
||
|
||
/**
|
||
* @brief 视口布局类型
|
||
*/
|
||
enum class ViewportLayoutType {
|
||
Single, ///< 单视图(全屏)
|
||
HorizontalSplit, ///< 水平分割(上下两个视口)
|
||
VerticalSplit, ///< 垂直分割(左右两个视口)
|
||
Quad, ///< 四象限(2×2)
|
||
ThreeLeft, ///< 三视口:左侧大 + 右侧上下
|
||
ThreeRight, ///< 三视口:左侧上下 + 右侧大
|
||
Custom ///< 自定义(通过 set_custom_bounds 设置)
|
||
};
|
||
|
||
// ═══════════════════════════════════════════════
|
||
// 分割线属性
|
||
// ═══════════════════════════════════════════════
|
||
|
||
/**
|
||
* @brief 分割线样式
|
||
*/
|
||
struct DividerProperties {
|
||
Color color{0.3, 0.3, 0.3}; ///< 分割线颜色(默认深灰)
|
||
double thickness = 2.0; ///< 分割线粗细(像素)
|
||
};
|
||
|
||
// ═══════════════════════════════════════════════
|
||
// LayoutState 内部状态
|
||
// ═══════════════════════════════════════════════
|
||
|
||
/**
|
||
* @brief 布局完整状态(get_viewport_layout 返回值)
|
||
*/
|
||
struct LayoutState {
|
||
ViewportLayoutType type = ViewportLayoutType::Single;
|
||
double split_ratio = 0.5; ///< 分割比例 [0.1, 0.9]
|
||
};
|
||
|
||
// ═══════════════════════════════════════════════
|
||
// API 声明
|
||
// ═══════════════════════════════════════════════
|
||
|
||
/**
|
||
* @brief 设置视口布局类型和分割比例
|
||
*
|
||
* @param type 布局类型
|
||
* @param split_ratio 分割比例 [0.1, 0.9](仅在分割布局时生效)
|
||
*/
|
||
void set_viewport_layout(ViewportLayoutType type,
|
||
double split_ratio = 0.5);
|
||
|
||
/**
|
||
* @brief 获取当前视口布局状态
|
||
* @return 布局类型 + 分割比例
|
||
*/
|
||
[[nodiscard]] LayoutState get_viewport_layout();
|
||
|
||
/**
|
||
* @brief 获取指定视口的相机状态
|
||
*
|
||
* @param viewport_index 视口索引(0-based)
|
||
* @return 相机状态(若视口不存在则返回默认值)
|
||
*/
|
||
[[nodiscard]] CameraState get_sub_viewport_camera(int viewport_index);
|
||
|
||
/**
|
||
* @brief 设置指定视口的相机状态
|
||
*
|
||
* @param viewport_index 视口索引
|
||
* @param camera 新相机状态
|
||
*/
|
||
void set_sub_viewport_camera(int viewport_index,
|
||
const CameraState& camera);
|
||
|
||
/**
|
||
* @brief 设置活动视口
|
||
* @param index 视口索引(0-based)
|
||
*/
|
||
void set_active_viewport(int index);
|
||
|
||
/**
|
||
* @brief 获取活动视口索引
|
||
* @return 当前活动视口索引(默认 0)
|
||
*/
|
||
[[nodiscard]] int get_active_viewport();
|
||
|
||
/**
|
||
* @brief 获取指定视口的像素区域边界
|
||
*
|
||
* @param index 视口索引(0-based)
|
||
* @return {x, y, width, height},单位为像素(若视口不存在返回全零)
|
||
*/
|
||
[[nodiscard]] std::vector<int> viewport_bounds(int index);
|
||
|
||
/**
|
||
* @brief 获取分割线样式属性
|
||
* @return 颜色 + 粗细
|
||
*/
|
||
[[nodiscard]] DividerProperties divider_properties();
|
||
|
||
/**
|
||
* @brief 设置分割线样式
|
||
*/
|
||
void set_divider_properties(const DividerProperties& props);
|
||
|
||
/**
|
||
* @brief 自定义视口边界(仅在 Custom 布局下生效)
|
||
*
|
||
* @param bounds_vec 每个元素为 {x, y, w, h}(像素坐标)
|
||
*/
|
||
void set_custom_viewport_bounds(
|
||
const std::vector<std::vector<int>>& bounds_vec);
|
||
|
||
/**
|
||
* @brief 获取当前布局下的视口数量
|
||
* @return 视口数量
|
||
*/
|
||
[[nodiscard]] int viewport_count();
|
||
|
||
/**
|
||
* @brief 设定视口总像素区域(用于计算视口边界)
|
||
*
|
||
* 渲染前端应在窗口 resize 时调用此 API,更新总视口区域。
|
||
*
|
||
* @param total_width 总像素宽度
|
||
* @param total_height 总像素高度
|
||
*/
|
||
void set_viewport_total_size(int total_width, int total_height);
|
||
|
||
} // namespace vde::render
|