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