2024-03-18 01:05:42 +00:00
|
|
|
|
|
2024-03-13 05:58:12 +00:00
|
|
|
|
#include "OCCTopoShapeTreeViewer.h"
|
|
|
|
|
#include <qDebug>
|
|
|
|
|
#include "SharedModuleLib/BaseUiTool.h"
|
2024-03-18 01:05:42 +00:00
|
|
|
|
#include <opencascade/BRep_Tool.hxx>
|
|
|
|
|
#include <opencascade/TopoDS_Vertex.hxx>
|
2024-03-13 05:58:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OCCTopoShapeTreeViewer::OCCTopoShapeTreeViewer(QWidget* parent)
|
|
|
|
|
: QTreeWidget(parent)
|
|
|
|
|
{
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 构造函数
|
2024-03-13 05:58:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OCCTopoShapeTreeViewer::setTopoShape(const TopoDS_Shape& shape)
|
|
|
|
|
{
|
|
|
|
|
this->displayTopoShape(shape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OCCTopoShapeTreeViewer::displayTopoShape(const TopoDS_Shape& shape)
|
|
|
|
|
{
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 清空QTreeWidget
|
2024-03-13 05:58:12 +00:00
|
|
|
|
clear();
|
|
|
|
|
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 调用递归函数来添加Topo_Shape的层次结构
|
2024-03-13 05:58:12 +00:00
|
|
|
|
addTopoShapeToTreeWidget(shape, nullptr);
|
|
|
|
|
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 展开所有项目
|
2024-03-13 05:58:12 +00:00
|
|
|
|
expandAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OCCTopoShapeTreeViewer::addTopoShapeToTreeWidget(const TopoDS_Shape& shape, QTreeWidgetItem* parentItem)
|
|
|
|
|
{
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 获取当前Topo_Shape的类型
|
2024-03-13 05:58:12 +00:00
|
|
|
|
TopAbs_ShapeEnum shapeType = shape.ShapeType();
|
|
|
|
|
|
2024-03-18 01:05:42 +00:00
|
|
|
|
// 创建一个新的QTreeWidgetItem来表示当前Topo_Shape
|
2024-03-13 05:58:12 +00:00
|
|
|
|
QTreeWidgetItem* currentItem = new QTreeWidgetItem(parentItem);
|
|
|
|
|
currentItem->setText(0, TopAbs_ShapeEnum2QString(shapeType));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|