增加了 点云的 选择筛选功能

LAMPCAE-dev-addTree
剑古敛锋 2024-07-31 14:32:53 +08:00
parent 1196289cfd
commit ed821fb003
55 changed files with 1640 additions and 568 deletions

View File

@ -3,7 +3,7 @@
#include "Geometry/geometryData.h"
#include "Geometry/geometrySet.h"
#include "Geometry/geometryParaSphere.h"
#include <QDebug>
namespace Command
{
GeoCommandCreateSphere::GeoCommandCreateSphere(GUI::MainWindow *m, MainWidget::PreWindow *p)
@ -13,6 +13,8 @@ namespace Command
bool GeoCommandCreateSphere::execute()
{
qDebug()<<"localtion: "<<_location[0]<<" "<<_location[1]<<" "<<_location[2];
qDebug()<<"radius: "<<_radius;
gp_Pnt pt(_location[0], _location[1], _location[2]);
TopoDS_Shape aTopoBox = BRepPrimAPI_MakeSphere(pt, _radius).Shape();
TopoDS_Shape *shape = new TopoDS_Shape;

View File

@ -134,5 +134,4 @@ namespace Command
{
return _sketchUndoList;
}
}

View File

@ -41,7 +41,16 @@ target_compile_definitions(GeometryWidgets PRIVATE "GEOMETRYWIDGETS_API")
list(APPEND _depend_library PythonModule Settings DataProperty SelfDefObject Geometry ModuleBase GeometryCommand)
list(APPEND _runtimes_libraries
OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKMath OpenCASCADE::TKPrim OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKernel Qt5::Core Qt5::Gui Qt5::Widgets VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo
OpenCASCADE::TKGeomBase OpenCASCADE::TKMath OpenCASCADE::TKPrim OpenCASCADE::TKShHealing
OpenCASCADE::TKTopAlgo OpenCASCADE::TKernel Qt5::Core Qt5::Gui Qt5::Widgets
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel
VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem
VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral
VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser
VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY
VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2
VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
)
#-----------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -64,7 +64,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -84,7 +84,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -102,7 +102,7 @@
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -120,7 +120,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -61,7 +61,7 @@
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -86,7 +86,7 @@
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -111,7 +111,7 @@
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -147,7 +147,7 @@
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -172,7 +172,7 @@
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -197,7 +197,7 @@
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -222,7 +222,7 @@
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -247,7 +247,7 @@
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -284,7 +284,7 @@
</sizepolicy>
</property>
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -309,7 +309,7 @@
<item>
<widget class="QLabel" name="label_19">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -75,7 +75,7 @@
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxR2">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>100000000000000004384584304507619735463404765184.000000000000000</double>
@ -92,7 +92,7 @@
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxL">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>10000000000.000000000000000</double>
@ -105,7 +105,7 @@
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxR">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>9999999999999999932209486743616279764617084419440640.000000000000000</double>

View File

@ -68,7 +68,7 @@
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxR">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>100000000000.000000000000000</double>
@ -88,7 +88,7 @@
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxL">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>10000000000.000000000000000</double>

View File

@ -53,7 +53,7 @@
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -74,7 +74,7 @@
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -95,7 +95,7 @@
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -125,7 +125,7 @@
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -146,7 +146,7 @@
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -167,7 +167,7 @@
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -188,7 +188,7 @@
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -222,7 +222,7 @@
</sizepolicy>
</property>
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateLineDialog</class>
<widget class="QDialog" name="CreateLineDialog">
@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>358</height>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
@ -86,7 +86,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="pointTab">
<attribute name="title">

View File

@ -84,7 +84,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -102,7 +102,7 @@
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -120,7 +120,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -68,7 +68,7 @@
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxR">
<property name="suffix">
<string>m</string>
<string>mm</string>
</property>
<property name="maximum">
<double>100000000000.000000000000000</double>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeoSplitterDialog</class>
<widget class="QDialog" name="GeoSplitterDialog">
@ -128,7 +128,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">

View File

@ -110,7 +110,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -135,7 +135,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogFillGap</class>
<widget class="QDialog" name="DialogFillGap">

View File

@ -86,7 +86,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateRevol</class>
<widget class="QDialog" name="CreateRevol">
@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>412</width>
<height>465</height>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
@ -180,7 +180,7 @@
<item row="1" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>408</width>
<height>430</height>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
@ -72,7 +72,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -317,7 +317,7 @@
</size>
</property>
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -426,7 +426,7 @@
</size>
</property>
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MirrorFeatureDialog</class>
<widget class="QDialog" name="MirrorFeatureDialog">
@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>434</width>
<height>383</height>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
@ -118,7 +118,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MoveFeatureDialog</class>
<widget class="QDialog" name="MoveFeatureDialog">
@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>456</width>
<height>399</height>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
@ -95,7 +95,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RotateFeatureDialog</class>
<widget class="QDialog" name="RotateFeatureDialog">
@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>456</width>
<height>439</height>
<height>514</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -228,7 +228,7 @@
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -35,7 +35,7 @@
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -60,7 +60,7 @@
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>
@ -85,7 +85,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>m</string>
<string>mm</string>
</property>
</widget>
</item>

View File

@ -31,13 +31,8 @@ add_library(MainWidgets
${_interface}
${_header}
${_source}
fekocadTaskinit.cpp
fekocadTaskinit.h
fekocadTaskinit.ui
createfekocadmodel.cpp
createfekocadmodel.h
createfekocadmodel.ui
vtkMeshSelectTableModel.cpp
vtkMeshSelectTableModel.h
)
#-----------------------------------------------------------------------------
@ -52,13 +47,15 @@ if(OpenMP_CXX_FOUND)
endif()
list(APPEND _runtimes_libraries
OpenCASCADE::Freetype OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIVtk OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKernel Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersModeling VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingGL2PSOpenGL2 VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
OpenCASCADE::Freetype OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIVtk OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKernel
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml Qt5::OpenGL
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersModeling VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingGL2PSOpenGL2 VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
OpenMeshCore OpenMeshTools
)
list(APPEND _runtimes_libraries
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersSources VTK::IOCore VTK::IOChemistry VTK::IOGeometry VTK::IOImage VTK::IOLegacy VTK::ImagingCore VTK::ImagingSources VTK::RenderingCore VTK::RenderingLOD VTK::doubleconversion VTK::jpeg VTK::jsoncpp VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------s
#
#-----------------------------------------------------------------------------
target_link_libraries(MainWidgets PRIVATE

View File

@ -102,7 +102,13 @@ namespace MainWidget {
{
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
// MeshKernalViewObj::setPointDisplayColor start ";
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
// std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
QSet<int> indexSet;
foreach (int value, indexs) {
indexSet.insert(value); // Insert each element of list into set
}
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
// MeshKernalViewObj::setPointDisplayColor create set ";
vtkDataArray* colorArray = _displayData->GetPointData()->GetScalars();
@ -119,8 +125,7 @@ namespace MainWidget {
if(indexs.isEmpty())
break;
int pointindex = indexArray->GetComponent(i, 1);
if(indexSet.find(pointindex)
!= indexSet.end()) // 选择点是否在 渲染 点集中, 选中 && 渲染 修改
if(indexSet.contains(pointindex)) // 选择点是否在 渲染 点集中, 选中 && 渲染 修改
{
colorArray->SetComponent(i, 0, col[0]);
colorArray->SetComponent(i, 1, col[1]);
@ -172,7 +177,11 @@ namespace MainWidget {
{
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
// MeshKernalViewObj::setCellDisplayColor start ";
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
//std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
QSet<int> indexSet;
foreach (int value, indexs) {
indexSet.insert(value); // Insert each element of list into set
}
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
// MeshKernalViewObj::setPointDisplayColor create set ";
vtkDataArray* colorArray = _displayData->GetCellData()->GetScalars();
@ -202,8 +211,7 @@ namespace MainWidget {
auto serial = [=](int beg, int end) {
for(int i = beg; i <= end; ++i) {
int cellid = indexArray->GetComponent(i, 1);
// if(indexs.contains(cellid))
if(indexSet.find(cellid) != indexSet.end()) // 判断是否在显示对象中
if(indexSet.contains(cellid))// if(indexSet.find(cellid) != indexSet.end()) // 判断是否在显示对象中
{
colorArray->SetComponent(i, 0, col[0]);
colorArray->SetComponent(i, 1, col[1]);
@ -271,10 +279,16 @@ namespace MainWidget {
if(show)
value = 1;
std::set<int> indexSet(indexs.begin(), indexs.end());
// std::set<int> indexSet(indexs.begin(), indexs.end());
QSet<int> indexSet;
foreach (int value, indexs) {
indexSet.insert(value); // Insert each element of list into set
}
for(int i = 0; i < showArray->GetNumberOfTuples(); ++i) {
int cellid = IDSArray->GetComponent(i, 1);
if(indexSet.find(cellid) != indexSet.end()) // 判断是否正确
if(indexSet.contains(cellid)) // 判断是否正确
{
showArray->SetComponent(i, 0, value);
}
@ -445,7 +459,13 @@ namespace MainWidget {
}
void MeshKernalViewObj::showPoints(const QList<int>& index, bool show)
{
std::set<int> indexSet(index.begin(), index.end());
// std::set<int> indexSet(index.begin(), index.end());
QSet<int> indexSet;
foreach (int value, index) {
indexSet.insert(value); // Insert each element of list into set
}
// 判断是否需要显示
auto dataSet = _kernal->getMeshData();
vtkDataArray* showArray = dataSet->GetPointData()->GetArray("SHOW");
@ -458,7 +478,7 @@ namespace MainWidget {
int pointid = -1;
for(int i = 0; i < showArray->GetNumberOfTuples(); ++i) {
int pointid =IDSArray->GetComponent(i, 1);
if(indexSet.find(pointid) != indexSet.end()) // 判断是否正确
if(indexSet.contains(pointid))//if(indexSet.find(pointid) != indexSet.end()) // 判断是否正确
{
showArray->SetComponent(i, 0, value);
}

View File

@ -162,7 +162,6 @@ namespace MainWidget
* @brief
*/
bool _isKernalHighLight{ false };
};
}

View File

@ -394,7 +394,7 @@ namespace MainWidget
{
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
auto vObjs = _viewObjects.value(k); // 获取对应的view对象
QList<int> members = items->values(); //
QList<int> members = items->values(dataset); //
if (vObjs == nullptr)
continue;
if(members.isEmpty()){

View File

@ -241,6 +241,9 @@ namespace MainWidget
}
}
}
void PreWindow::setSelectItems(QMultiHash<int, int> items, ModuleBase::SelectModel model) {
this->_interactionStyle->setSelectItems(items);
this->_interactionStyle->setSelectModel((int)model);
}
}

View File

@ -58,6 +58,9 @@ namespace MainWidget
QMultiHash<int, int> *getSelectItems();
MeshViewProvider *getMeshViewProvider();
void setSelectItems(QMultiHash<int, int> items, ModuleBase::SelectModel model);
signals:
//关闭
void closed();

View File

@ -151,7 +151,8 @@ namespace MainWidget
_axisYActor->GetProperty()->SetLineWidth(3);
_axisYActor->GetProperty()->SetColor(0, 1, 0);
_preWindow->AppendActor(_axisXActor, ModuleBase::D3, false);
_preWindow->AppendActor(_axisYActor, ModuleBase::D3, false);
_preWindow->AppendActor(_axisYActor, ModuleBase::D3, false); // 绘制坐标轴
_pointWidget = new GeometryWidget::SketchPointWidget(_mainWindow, _preWindow, _creater);
emit showDialog(_pointWidget);

View File

@ -0,0 +1,536 @@
/**
* @file vtkMeshSelectTableModel.cpp
* @brief None
* @author (3045316072@qq.com)
* @version 2.5.0
* @date 24-7-30
* @copyright Copyright (c) Since 2024 All rights reserved.
*/
#include "vtkMeshSelectTableModel.h"
#include <QDebug>
#include <QColor>
#include <QIcon>
#include <QVariantMap>
#include <QVariantList>
#include <QVariant>
#include <QList>
#include <QMultiHash>
#include "preWindow.h"
#include "MeshData/meshKernal.h"
#include "meshViewProvider.h"
#include "meshKernalViewObject.h"
#include "MeshData/meshSet.h"
#include "MeshData/meshSingleton.h"
#include "Settings/busAPI.h" // 获取高亮颜色
#include "Settings/GraphOption.h" // 获取高亮颜色
namespace MainWidget {
vtkMeshSelectTableModel::vtkMeshSelectTableModel(PreWindow* _preWindow,QObject* parent)
: QAbstractTableModel(parent)
, _preWindow(_preWindow)
{
this->_meshData = MeshData::MeshData::getInstance();
if(nullptr!=_preWindow){
this->_meshProvider = _preWindow->getMeshViewProvider();
}
connect(this,SIGNAL(itemChanged(const QModelIndex&, const QVariant&)),this,SLOT(onItemChanged(const QModelIndex&, const QVariant&)));
}
vtkMeshSelectTableModel::~vtkMeshSelectTableModel() {}
// void vtkMeshSelectTableModel::SetData(const QVariantMap& map)
// {
// beginResetModel();
// m_hor_hedlbls = map["headerlabel"].toStringList();
// m_table_map = map;
// m_vec_hedlbls = map.keys();
// endResetModel();
// }
void vtkMeshSelectTableModel::setHignlightIndex(QVector<QPair<int, int>> vec_index)
{
beginResetModel();
m_highlight_indexs = vec_index;
endResetModel();
}
Qt::ItemFlags vtkMeshSelectTableModel::flags(const QModelIndex& index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
flags |= Qt::ItemIsEditable;
return flags;
}
QVariant vtkMeshSelectTableModel::data(const QModelIndex& _index, int role) const
{
if(role == Qt::DisplayRole || role == Qt::EditRole) {
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[_index.row()]].data());
return (*_map)[m_hor_hedlbls[_index.column()]];
} else if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter; // 文字居中
else if(role == Qt::BackgroundColorRole) // 设置背景色
{
if(m_highlight_indexs.contains(qMakePair<int, int>(_index.row(), _index.column()))) {
return QColor(230, 247, 255);
} else {
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[_index.row()]].data());
if((*_map)[SELECTSAVEDFIELDNAME].toInt() ==0) {
return QColor(255, 0, 0);
}
}
}
// else if(role == Qt::DecorationRole) // 为item添加图标
// {
// return QIcon(":/images/device.svg");
// }
return QVariant();
}
QVariant vtkMeshSelectTableModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if(orientation == Qt::Horizontal) {
if(role == Qt::DisplayRole)
return m_hor_hedlbls.at(section);
else
return QVariant();
}
return QAbstractTableModel::headerData(section, orientation, role); // 垂直表头的序号
}
bool vtkMeshSelectTableModel::setData(const QModelIndex& _index, const QVariant& value,
int role)
{
if(_index.isValid() && role == Qt::EditRole) {
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[_index.row()]].data());
if((*_map)[m_hor_hedlbls[_index.column()]] != value) {
(*_map)[m_hor_hedlbls[_index.column()]] = value;
emit dataChanged(_index, _index);
emit itemChanged(_index, value);
return true;
}
}
return false;
}
int vtkMeshSelectTableModel::rowCount() const
{
return m_vec_hedlbls.size();
}
int vtkMeshSelectTableModel::columnCount() const
{
return m_hor_hedlbls.size();
}
QString vtkMeshSelectTableModel::itemText(int row, int column) const
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
return (*_map)[m_hor_hedlbls[column]].toString();
}
QString vtkMeshSelectTableModel::itemText(const QModelIndex& index) const
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[index.row()]].data());
return (*_map)[m_hor_hedlbls[index.column()]].toString();
}
void vtkMeshSelectTableModel::setItemText(const QModelIndex& index, const QString& str)
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[index.row()]].data());
(*_map)[m_hor_hedlbls[index.column()]] = str;
}
void vtkMeshSelectTableModel::setItemText(int row, int column, const QString& str)
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
(*_map)[m_hor_hedlbls[column]] = str;
}
QVariant vtkMeshSelectTableModel::ItemData(const QModelIndex& index) const
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[index.row()]].data());
return (*_map)[m_hor_hedlbls[index.column()]];
}
QVariant vtkMeshSelectTableModel::ItemData(int row, int column) const
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
return (*_map)[m_hor_hedlbls[column]];
}
void vtkMeshSelectTableModel::SetItemData(const QModelIndex& index, const QVariant& data)
{
int vec_lbl = m_vec_hedlbls[index.row()];
if(!m_data_map.contains(vec_lbl))
m_data_map[vec_lbl] = QVariantMap();
QVariantMap* _map = (QVariantMap*)(m_data_map[vec_lbl].data());
(*_map)[m_hor_hedlbls[index.column()]] = data;
}
void vtkMeshSelectTableModel::SetItemData(int row, int column, const QVariant& data)
{
int vec_lbl = m_vec_hedlbls[row];
if(!m_data_map.contains(vec_lbl))
m_data_map[vec_lbl] = QVariantMap();
QVariantMap* _map = (QVariantMap*)(m_data_map[vec_lbl].data());
(*_map)[m_hor_hedlbls[column]] = data;
}
void vtkMeshSelectTableModel::clear()
{
beginResetModel();
// m_table_map.clear();
m_data_map.clear();
m_hor_hedlbls.clear();
m_vec_hedlbls.clear();
m_highlight_indexs.clear();
endResetModel();
}
void vtkMeshSelectTableModel::SetData(QMultiHash<int, int>* items,
ModuleBase::SelectModel _selectModel)
{
qDebug()<<"\tvoid vtkMeshSelectTableModel::SetData(QMultiHash<int, int>* items,ModuleBase::SelectModel _selectModel)";
beginResetModel();
this->_selectModel = _selectModel;
// m_hor_hedlbls = map["headerlabel"].toStringList();
// m_table_map = map;
// m_vec_hedlbls = map.keys();
switch(_selectModel) {
case ModuleBase::SelectModel::MeshNode:
case ModuleBase::SelectModel::BoxMeshNode:
case ModuleBase::SelectModel::BoxMeshSurfaceNode: { // 选择点集
m_hor_hedlbls << "SELECTID" << "MeshSetID" << "PointID" << "X" << "Y" << "Z"
<< SELECTSAVEDFIELDNAME; // 点击
this->m_data_map.clear();
int selectId = 1;
// 处理实体数据
if(items->isEmpty()) {
break;
} else {
QList<int> datasetList = items->uniqueKeys(); // 获取所有的key
qDebug() << QString("kernel size: %1").arg(datasetList.size());
for(auto dataset : datasetList) {
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
if(!(k->isVisible())) {
continue;
}
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
QList<int> members = items->values(); // 获取所有的value
QSet<int> indexSet;
foreach(int value, members) {
indexSet.insert(value); // Insert each element of list into set
}
if(vObjs == nullptr || members.isEmpty()) {
continue;
}
vtkDataSet* displayData = vObjs->getDisplayData();
vtkDataArray* IDSArray = displayData->GetPointData()->GetArray("IDS");
vtkSmartPointer<vtkGeometryFilter> geometryfilter = vtkSmartPointer<vtkGeometryFilter>::New();
geometryfilter->SetInputData(displayData);
geometryfilter->Update();
vtkPolyData* polyData = geometryfilter->GetOutput();
if(nullptr==polyData) {
qDebug()<<"polyData is nullptr";
break;
}
vtkPoints* points = polyData->GetPoints();
double p[3];
for(int i = 0; i < displayData->GetNumberOfPoints(); ++i) {
int pointid = IDSArray->GetComponent(i, 1);
if(indexSet.contains(pointid)) // if(indexSet.find(pointid) !=
// indexSet.end()) // 判断是否正确
{
points->GetPoint(i, p);
QVariantMap temp_map;
temp_map["SELECTID"] = selectId++;
temp_map["MeshSetID"] = dataset;
temp_map["PointID"] = pointid;
temp_map["X"] = p[0];
temp_map["Y"] = p[1];
temp_map["Z"] = p[2];
temp_map[SELECTSAVEDFIELDNAME] = 1;
this->m_data_map[selectId] = temp_map;
}
}
}
}
m_vec_hedlbls = m_data_map.keys();
break;
}
case ModuleBase::SelectModel::MeshCell:
case ModuleBase::SelectModel::BoxMeshCell:
case ModuleBase::SelectModel::BoxMeshSurfaceCell: { // 选择网格单元
m_hor_hedlbls << "SELECTID" << "MeshSetID" << "CellID" << SELECTSAVEDFIELDNAME; // 点击
// 处理网格数据
int selectId = 1;
// 处理实体数据
if(items->isEmpty()) {
break;
} else {
QList<int> datasetList = items->uniqueKeys(); // 获取所有的key
qDebug() << QString("kernel size: %1").arg(datasetList.size());
for(auto dataset : datasetList) {
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
if(!(k->isVisible())) {
continue;
}
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
QList<int> members = items->values(); // 获取所有的value
QSet<int> indexSet;
foreach(int value, members) {
indexSet.insert(value); // Insert each element of list into set
}
if(vObjs == nullptr || members.isEmpty()) {
continue;
}
vtkDataSet* displayData = vObjs->getDisplayData();
vtkDataArray* IDSArray = displayData->GetCellData()->GetArray("IDS");
for(int i = 0; i < displayData->GetNumberOfPoints(); ++i) {
int cellid = IDSArray->GetComponent(i, 1);
if(indexSet.contains(cellid)) // if(indexSet.find(pointid) !=
// indexSet.end()) // 判断是否正确
{
QVariantMap temp_map;
temp_map["SELECTID"] = selectId++;
temp_map["MeshSetID"] = dataset;
temp_map["CellID"] = cellid;
temp_map[SELECTSAVEDFIELDNAME] = 1;
this->m_data_map[selectId] = temp_map;
}
}
}
}
m_vec_hedlbls = m_data_map.keys();
break;
}
default:
break;
}
endResetModel();
}
int vtkMeshSelectTableModel::rowCount(const QModelIndex& parent) const
{
if(parent.isValid()){
return 0;
}
return m_vec_hedlbls.size();
}
int vtkMeshSelectTableModel::columnCount(const QModelIndex& parent) const
{
if(parent.isValid()){
return 0;
}
return m_hor_hedlbls.size();
}
void vtkMeshSelectTableModel::setRemoveFlag(int row, bool isdelete) {
// 当前行的删除标记
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
(*_map)[SELECTSAVEDFIELDNAME] = isdelete ? 0 : 1;
auto gp = Setting::BusAPI::instance()->getGraphOption();
// if(isdelete) {
// auto c = gp->getMeshNodeColor();
// this->HightlightCurrentRow(row,c);
// }
// else{
// auto c = gp->getHighLightColor();
// this->HightlightCurrentRow(row,c);
// }
}
bool vtkMeshSelectTableModel::getRemoveFlag(int row)
{
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
return (*_map)[SELECTSAVEDFIELDNAME].toInt() == 0;
}
QMultiHash<int, int> vtkMeshSelectTableModel::getSelectItems()
{
switch(this->_selectModel) {
case ModuleBase::SelectModel::MeshNode:
case ModuleBase::SelectModel::BoxMeshNode:
case ModuleBase::SelectModel::BoxMeshSurfaceNode: { // 选择点集
QMultiHash<int, int> items;
for(auto key : m_data_map.keys()) {
QVariantMap* _map = (QVariantMap*)(m_data_map[key].data());
if((*_map)[SELECTSAVEDFIELDNAME].toInt() == 1) {
items.insert((*_map)["MeshSetID"].toInt(), (*_map)["PointID"].toInt());
}
}
return items;
// break;
}
case ModuleBase::SelectModel::MeshCell:
case ModuleBase::SelectModel::BoxMeshCell:
case ModuleBase::SelectModel::BoxMeshSurfaceCell: { // 选择网格单元
QMultiHash<int, int> items;
for(auto key : m_data_map.keys()) {
QVariantMap* _map = (QVariantMap*)(m_data_map[key].data());
if((*_map)[SELECTSAVEDFIELDNAME].toInt() == 1) {
items.insert((*_map)["MeshSetID"].toInt(), (*_map)["CellID"].toInt());
}
}
return items;
// break;
}
default:
return QMultiHash<int, int>();
}
}
ModuleBase::SelectModel vtkMeshSelectTableModel::getSelectModel()
{
return this->_selectModel;
}
void vtkMeshSelectTableModel::setCurrentRowIndex(const QModelIndex& current) {
// int row=current.row();
// QColor selectc = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor(); // 获取高亮颜色
// this->HightlightCurrentRow(currentRow,selectc);
// QColor preselectc = Setting::BusAPI::instance()->getGraphOption()->getPreHighLightColor(); // 获取高亮颜色
// this->HightlightCurrentRow(row,selectc);
// this->currentRow=row;
}
void vtkMeshSelectTableModel::HightlightRow(int row,QColor c ) {
if(row<0){
return;
}
// 根据不同的选择模式,进行不同的操作
switch(this->_selectModel) {
case ModuleBase::SelectModel::MeshNode:
case ModuleBase::SelectModel::BoxMeshNode:
case ModuleBase::SelectModel::BoxMeshSurfaceNode: { // 选择点集
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
int meshSetID = (*_map)["MeshSetID"].toInt();
int pointID = (*_map)["PointID"].toInt();
// 根据meshSetID和pointID选中对应的点
auto k = _meshData->getKernalByID(meshSetID); // 获取对应的kernal
auto vObjs = _meshProvider->getViewObjects(k);//_viewObjects.value(k); // 获取对应的view对象
if(vObjs == nullptr) {
return;
}
QList<int> members;
members.push_back(pointID);
vObjs->setPointDisplayColor(members, c,true);
break;
}
case ModuleBase::SelectModel::MeshCell:
case ModuleBase::SelectModel::BoxMeshCell:
case ModuleBase::SelectModel::BoxMeshSurfaceCell: { // 选择网格单元
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
int meshSetID = (*_map)["MeshSetID"].toInt();
int cellID = (*_map)["CellID"].toInt();
// 根据meshSetID和cellID选中对应的单元
auto k = _meshData->getKernalByID(meshSetID); // 获取对应的kernal
auto vObjs = _meshProvider->getViewObjects(k);//_viewObjects.value(k); // 获取对应的view对象
if(vObjs == nullptr) {
return;
}
QList<int> members;
members.push_back(cellID);
vObjs->setCellDisplayColor(members, c,true);
break;
}
default:
break;
}
_preWindow->reRender();
}
void vtkMeshSelectTableModel::onItemChanged(const QModelIndex& index, const QVariant& value) {
}
void vtkMeshSelectTableModel::HightlightRows(QList<int> rows, QColor c) {
if(rows.count()==0){
return;
}
QMultiHash<int, int> items;
// 根据不同的选择模式,进行不同的操作
switch(this->_selectModel) {
case ModuleBase::SelectModel::MeshNode:
case ModuleBase::SelectModel::BoxMeshNode:
case ModuleBase::SelectModel::BoxMeshSurfaceNode: { // 选择点集
for(int i=0;i<rows.count();i++) {
int row=rows[i];
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
int meshSetID = (*_map)["MeshSetID"].toInt();
int pointID = (*_map)["PointID"].toInt();
items.insert(meshSetID,pointID);
}
break;
}
case ModuleBase::SelectModel::MeshCell:
case ModuleBase::SelectModel::BoxMeshCell:
case ModuleBase::SelectModel::BoxMeshSurfaceCell: { // 选择网格单元
for(int i=0;i<rows.count();i++) {
int row=rows[i];
QVariantMap* _map = (QVariantMap*)(m_data_map[m_vec_hedlbls[row]].data());
int meshSetID = (*_map)["MeshSetID"].toInt();
int cellID = (*_map)["CellID"].toInt();
items.insert(meshSetID,cellID);
}
break;
}
default:
break;
}
if(items.isEmpty()){
return;
}
QList<int> datasetList = items.uniqueKeys(); // 获取所有的key
qDebug()<<QString("kernel size: %1").arg(datasetList.size());
for (auto dataset : datasetList)
{
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
if(!(k->isVisible())){
continue;
}
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
QList<int> members = items.values(); // 获取所有的value
if (vObjs == nullptr)
continue;
if(members.isEmpty()){
continue;
}
if(_selectModel == ModuleBase::BoxMeshNode || _selectModel == ModuleBase::MeshNode||_selectModel==ModuleBase::BoxMeshSurfaceNode) {
vObjs->setPointDisplayColor(members,c,true);
} else if(_selectModel == ModuleBase::BoxMeshCell || _selectModel == ModuleBase::MeshCell||_selectModel==ModuleBase::BoxMeshSurfaceCell) {
vObjs->setCellDisplayColor(members,c,true);
}
//
//k->getMeshData()->DeepCopy(vObjs->getDisplayData());// 更新结果 与 显示保持一致
//vObjs->getDisplayData()->DeepCopy(k->getMeshData());
vObjs->modifyPointDisplay();
}
_preWindow->reRender();
}
void vtkMeshSelectTableModel::UpdateHightlight() {
}
} // namespace MainWidget

View File

@ -0,0 +1,92 @@
/**
* @file vtkMeshSelectTableModel.h
* @brief vtkMesh
* @author (3045316072@qq.com)
* @version 2.5.0
* @date 24-7-30
* @copyright Copyright (c) Since 2024 All rights reserved.
*/
#ifndef LAMPCAE_VTKMESHSELECTTABLEMODEL_H
#define LAMPCAE_VTKMESHSELECTTABLEMODEL_H
#include "mainWidgetsAPI.h"
#include <QAbstractTableModel>
#include <QObject>
#include <QStringList>
#include <QVector>
#include "preWindow.h"
#include "MeshData/meshKernal.h"
#include "meshViewProvider.h"
#include "meshKernalViewObject.h"
#include "MeshData/meshSet.h"
namespace MainWidget {
const QString SELECTSAVEDFIELDNAME("isSaved"); // 保存选择的字段名
class MAINWIDGETSAPI vtkMeshSelectTableModel : public QAbstractTableModel {
Q_OBJECT
public:
//
void SetData(QMultiHash<int, int>* _selectItems, ModuleBase::SelectModel _selectModel);
explicit vtkMeshSelectTableModel(PreWindow* _preWindow, QObject* parent = NULL);
~vtkMeshSelectTableModel();
// void SetData(const QVariantMap& map);
void setHignlightIndex(QVector<QPair<int, int>> vec_index);
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
virtual int rowCount(const QModelIndex& parent) const;
virtual int columnCount(const QModelIndex& parent) const;
virtual int rowCount() const;
virtual int columnCount() const;
virtual QVariant data(const QModelIndex& index, int role) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role);
QString itemText(int row, int column) const;
QString itemText(const QModelIndex& index) const;
void setItemText(const QModelIndex& index, const QString& str);
void setItemText(int row, int column, const QString& str);
QVariant ItemData(const QModelIndex& index) const;
QVariant ItemData(int row, int column) const;
void SetItemData(const QModelIndex& index, const QVariant& data);
void SetItemData(int row, int column, const QVariant& data);
void clear();
void setRemoveFlag(int row, bool isdelete);
bool getRemoveFlag(int row);
QMultiHash<int, int> getSelectItems();
ModuleBase::SelectModel getSelectModel();
void setCurrentRowIndex(const QModelIndex& index);
void HightlightRow(int row,QColor c );
void HightlightRows(QList<int> rows,QColor c );
void UpdateHightlight();
signals:
void itemChanged(const QModelIndex& index, const QVariant& value);
public slots:
void onItemChanged(const QModelIndex& index, const QVariant& value);
private:
QStringList m_hor_hedlbls; // headerlabels
QList<int> m_vec_hedlbls; // oids - map.keys()
QMap<int, QVariant> m_data_map;
QVector<QPair<int, int>> m_highlight_indexs; // 背景高亮的indexs
ModuleBase::SelectModel _selectModel;
MeshData::MeshData* _meshData;
PreWindow* _preWindow;
MeshViewProvider* _meshProvider;
int currentRow;
};
} // namespace MainWidget
#endif // LAMPCAE_VTKMESHSELECTTABLEMODEL_H

View File

@ -47,6 +47,8 @@
#include "MainWidgets/projectSolveDialog.h"
#include "MainWidgets/meshViewProvider.h"
#include "MainWidgets/meshKernalViewObject.h"
#include "MainWidgets/vtkMeshSelectTableModel.h"
#include "MainWidgets/SelectNodeShow.h"
#include "MainWindowPy.h"
#include "MeshData/meshKernal.h"
@ -490,6 +492,11 @@ namespace GUI {
connect(_ui->actionCreateCADModel, SIGNAL(triggered()), this,
SLOT(on_actionCreateCADModel()));
connect(_ui->actionEditSelectDialog, SIGNAL(triggered()), this,
SLOT(on_actionEditSelectDialog()));
}
@ -1559,7 +1566,7 @@ namespace GUI {
_graphRange = new QLabel(this);
_ui->statusbar->addPermanentWidget(_graphRange);
}
QString text = QString(tr("Canvas %1m * %2m ")).arg(w).arg(h);
QString text = QString(tr("画布 %1mm * %2mm ")).arg(w).arg(h);
_graphRange->setText(text);
}
@ -1732,7 +1739,7 @@ namespace GUI {
_ui->statusbar->addPermanentWidget(_vtkworldPostion);
}
QString text = QString(tr("model world position : %2m, %3m, %4m ")).arg(x).arg(y).arg(z);
QString text = QString(tr(u8"世界坐标 : %1 mm, %2 mm, %3 mm ")).arg(x).arg(y).arg(z);
_vtkworldPostion->setText(text);
}
void MainWindow::on_actionvtkPointSamplor()
@ -2080,5 +2087,10 @@ namespace GUI {
scriptPath);
}else{}
}
void MainWindow::on_actionEditSelectDialog() {
MainWidget::SelectNodeShow* selectNodeShow=new MainWidget::SelectNodeShow(this->getSubWindowManager()->getPreWindow(),this);
selectNodeShow->initSelectNodeShow(this->getSubWindowManager()->getPreWindow()->getSelectItems(),this->getSubWindowManager()->getPreWindow()->getSelectModel()) ;
selectNodeShow->show();
}
} // namespace GUI

View File

@ -155,10 +155,10 @@ namespace GUI {
// Ribbon Customize
SARibbonActionsManager* getActionManager();
// 导入mesh
void importMesh(QString filepath,QString aSuffix,int modelID);
/// 导入点云
void importPcl(QString filepath,QString aSuffix,int modelID);
// // 导入mesh
// void importMesh(QString filepath,QString aSuffix,int modelID);
// /// 导入点云
// void importPcl(QString filepath,QString aSuffix,int modelID);
signals:
@ -363,6 +363,9 @@ namespace GUI {
public slots:
void on_actionEditSelectDialog();
void on_actionCreateLoadModelScript();
/*状态栏显示信息 */

View File

@ -375,6 +375,8 @@
<addaction name="actionBoxMeshCell"/>
<addaction name="actionBoxMeshSurfaceNode"/>
<addaction name="actionBoxMeshSurfaceCell"/>
<addaction name="separator"/>
<addaction name="actionEditSelectDialog"/>
</widget>
<widget class="QMenu" name="menuMeshEdit">
<property name="title">
@ -1262,12 +1264,12 @@
</action>
<action name="actionFEKOScatterSetting">
<property name="text">
<string>FEKO散射仿真参数设置</string>
<string>微波测量仿真分系统散射仿真参数设置</string>
</property>
</action>
<action name="actionLoadFEKOScatterResult">
<property name="text">
<string>加载FEKO散射仿真结果</string>
<string>加载散射仿真结果</string>
</property>
</action>
<action name="actionExportRCS">
@ -1282,7 +1284,7 @@
</action>
<action name="actionLoadFEKOImageResult">
<property name="text">
<string>加载FEKO图像回波仿真结果</string>
<string>加载仿真图像回波仿真结果</string>
</property>
</action>
<action name="actionExportFEKOResultToEcho">
@ -1292,7 +1294,7 @@
</action>
<action name="actionFEKOImageCreate">
<property name="text">
<string>FEKO成像结果</string>
<string>仿真成像结果</string>
</property>
</action>
<action name="actionNew">
@ -2633,27 +2635,27 @@
</action>
<action name="actionImageSetting">
<property name="text">
<string>Image FEKO Simulation Setting</string>
<string>图像仿真设置</string>
</property>
</action>
<action name="actionFEKOImage">
<property name="text">
<string>Feko Result Image</string>
<string>仿真图像生成</string>
</property>
</action>
<action name="actionantScatteringFEKOSetting">
<property name="text">
<string>LAMP Scattering Ant Setting</string>
<string>微波测量仿真分系统散射测量装置参数设置</string>
</property>
</action>
<action name="actionFEKO2csv">
<property name="text">
<string>FEKO Result Import</string>
<string>仿真结果转散射数据</string>
</property>
</action>
<action name="actionScatterExport">
<property name="text">
<string>FEKO Scatter Data Export</string>
<string>仿真散射结果导出</string>
</property>
</action>
<action name="actionAttriutionDBShow">
@ -2798,6 +2800,11 @@
<string>生成加载模型参数文件</string>
</property>
</action>
<action name="actionEditSelectDialog">
<property name="text">
<string>EditSelectDialog</string>
</property>
</action>
</widget>
<resources>
<include location="../qrc/qianfan.qrc"/>

View File

@ -82,6 +82,8 @@ add_library(ModuleBase
${_interface}
${_header}
${_source}
sketchViewInteractorStyle.cpp
sketchViewInteractorStyle.h
)

View File

@ -956,5 +956,11 @@ namespace ModuleBase
same = false;
return same;
}
void PropPickerInteractionStyle::setSelectItems(QMultiHash<int, int> items) {
// 设置选中的单元或点
_selectItems.clear();
_selectItems = items;
emit highLight(&_selectItems);
}
}

View File

@ -78,6 +78,9 @@ namespace ModuleBase
void connectToMainWindow(GUI::MainWindow *mw, QWidget *parent);
void setRenderWindow(vtkRenderWindow *w);
void setRender(vtkRenderer *r);
void setSelectItems(QMultiHash<int, int> items);
// private:
// vtkSmartPointer<vtkPolyData> Points;
//

View File

@ -48,6 +48,7 @@
#include "PreWindowInteractorStyle.h"
#include "sketchViewInteractorStyle.h"
#include "MainWindow/MainWindow.h"
#include "MeshData/meshSet.h"
#include "MeshData/meshKernal.h"
@ -82,6 +83,8 @@ namespace ModuleBase
if (_interactionStyle)
_interactionStyle->Delete();
if(_sketchViewInteractorStyle)
_sketchViewInteractorStyle->Delete();
}
void Graph3DWindow::enableKeyBoard(bool on)
{
@ -561,15 +564,6 @@ namespace ModuleBase
}
void Graph3DWindow::mouseMoveEvent(QMouseEvent* event)
{
// // 获取鼠标当前位置
// QPointF pos=event->pos();
// double dispCoord[2] = {pos.x(), pos.y()};
// vtkSmartPointer<vtkCoordinate> pCoorPress = vtkSmartPointer<vtkCoordinate>::New();
// pCoorPress->SetCoordinateSystemToDisplay();
// pCoorPress->SetValue(dispCoord);
// double *worldCoord = pCoorPress->GetComputedWorldValue(_render);
//// qDebug() << worldCoord[0] << worldCoord[1] << worldCoord[2];
// emit this->WorldPointMouseMove(worldCoord[0],worldCoord[1],worldCoord[2]);
}
{}
}

View File

@ -142,6 +142,7 @@ namespace ModuleBase
};
class PropPickerInteractionStyle;
class sketchViewInteractorStyle;
class MODULEBASEAPI Graph3DWindow : /*public QWidget,*/ public GraphWindowBase
{
@ -180,10 +181,16 @@ namespace ModuleBase
void createCubeAxes(double minx=-1000,double maxx=1000,double miny=-1000,double maxy=1000,double minz=-1000,double maxz=1000);
// 切换草图
public slots:
//重绘
void reRender();
protected slots:
void setSelectType(int model);
void enableKeyBoard(bool on);
@ -244,6 +251,7 @@ namespace ModuleBase
//拾取相关
PropPickerInteractionStyle* _interactionStyle{};
sketchViewInteractorStyle* _sketchViewInteractorStyle{};
SelectModel _selectModel{ None };
// 世界坐标系

View File

@ -0,0 +1,106 @@
/**
* @file sketchViewInteractorStyle.cpp
* @brief None
* @author (3045316072@qq.com)
* @version 2.5.0
* @date 24-7-26
* @copyright Copyright (c) Since 2024 All rights reserved.
*/
#include <vtkPolyData.h>
#include <vtkConeSource.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCamera.h>
#include "sketchViewInteractorStyle.h"
void ModuleBase::sketchViewInteractorStyle::Pan() {
int x, y;
this->Interactor->GetEventPosition(x, y);
int lastX, lastY;
this->Interactor->GetLastEventPosition(lastX, lastY);
double deltaX = (x - lastX) * 0.01; // 调整平移速度
double deltaY = (y - lastY) * 0.01; // 调整平移速度
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
camera->Azimuth(deltaX);
camera->Elevation(deltaY);
camera->OrthogonalizeViewUp();
this->Interactor->Render();
}
void ModuleBase::sketchViewInteractorStyle::Rotate()
{
int x, y;
this->Interactor->GetEventPosition(x, y);
int lastX, lastY;
this->Interactor->GetLastEventPosition(lastX, lastY);
double deltaAngle = (x - lastX) * 0.5; // 调整旋转速度
this->CurrentRenderer->GetActiveCamera()->Roll(deltaAngle);
this->Interactor->Render();
}
void ModuleBase::sketchViewInteractorStyle::OnMouseMove() {
if (this->LeftButtonDown)
{
this->Rotate();
}
else if (this->MiddleButtonDown)
{
this->Pan();
}
else if (this->RightButtonDown)
{
// 禁止缩放
return;
}
vtkInteractorStyleTrackballCamera::OnMouseMove();
}
ModuleBase::sketchViewInteractorStyle::sketchViewInteractorStyle() : LeftButtonDown(false), MiddleButtonDown(false), RightButtonDown(false) {}
ModuleBase::sketchViewInteractorStyle::~sketchViewInteractorStyle() {
}
ModuleBase::sketchViewInteractorStyle* ModuleBase::sketchViewInteractorStyle::New(){
return new sketchViewInteractorStyle;
}
void ModuleBase::sketchViewInteractorStyle::OnLeftButtonDown()
{
this->LeftButtonDown = true;
vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
}
void ModuleBase::sketchViewInteractorStyle::OnLeftButtonUp()
{
this->LeftButtonDown = false;
vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
}
void ModuleBase::sketchViewInteractorStyle::OnMiddleButtonDown()
{
this->MiddleButtonDown = true;
vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
}
void ModuleBase::sketchViewInteractorStyle::OnMiddleButtonUp()
{
this->MiddleButtonDown = false;
vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
}
void ModuleBase::sketchViewInteractorStyle::OnRightButtonDown()
{
this->RightButtonDown = true;
vtkInteractorStyleTrackballCamera::OnRightButtonDown();
}
void ModuleBase::sketchViewInteractorStyle::OnRightButtonUp()
{
this->RightButtonDown = false;
vtkInteractorStyleTrackballCamera::OnRightButtonUp();
}

View File

@ -0,0 +1,95 @@
/**
* @file sketchViewInteractorStyle.h
* @brief None
* @author (3045316072@qq.com)
* @version 2.5.0
* @date 24-7-26
* @copyright Copyright (c) Since 2024 All rights reserved.
*/
#ifndef LAMPCAE_SKETCHVIEWINTERACTORSTYLE_H
#define LAMPCAE_SKETCHVIEWINTERACTORSTYLE_H
#include <vtkActor.h>
#include <vtkCubeSource.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkInteractorStyleRubberBandPick.h>
#include <vtkDataSetMapper.h>
#include <QObject>
#include "ModuleBase/ModuleType.h"
#include <vtkIdTypeArray.h>
#include <QMultiHash>
#include <QList>
#include "moduleBaseAPI.h"
//
#include <vtkSmartPointer.h>
#include <vtkPointData.h>
#include <vtkIdTypeArray.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkRendererCollection.h>
#include <vtkProperty.h>
#include <vtkPlanes.h>
#include <vtkObjectFactory.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkPointSource.h>
#include <vtkInteractorStyleRubberBandPick.h>
#include <vtkAreaPicker.h>
#include <vtkExtractGeometry.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
#include <vtkVertexGlyphFilter.h>
#include <vtkIdFilter.h>
#include <vtkWorldPointPicker.h>
class vtkActor;
class vtkProperty;
class vtkDataSet;
class vtkIdTypeArray;
class vtkAreaPicker;
class vtkRenderWindow;
class vtkRenderer;
class QKeyEvent;
class QWidget;
class vtkCoordinate;
namespace ModuleBase {
class sketchViewInteractorStyle: public QObject, public vtkInteractorStyleTrackballCamera
{
Q_OBJECT
public:
static sketchViewInteractorStyle* New();
vtkTypeMacro(sketchViewInteractorStyle, vtkInteractorStyleTrackballCamera);
sketchViewInteractorStyle();
~sketchViewInteractorStyle();
protected:
void Rotate() override;
void Pan() override;
void OnLeftButtonDown() override;
void OnLeftButtonUp() override;
void OnMiddleButtonDown() override;
void OnMiddleButtonUp() override;
void OnRightButtonDown() override;
void OnRightButtonUp() override;
void OnMouseMove() override;
private:
bool LeftButtonDown;
bool MiddleButtonDown;
bool RightButtonDown;
};
}
#endif // LAMPCAE_SKETCHVIEWINTERACTORSTYLE_H

View File

@ -251,7 +251,11 @@ namespace MeshData {
void MeshOperator::SearchPoints(vtkDataSet* dataSet,const QList<int>& index ,int value)
{
std::set<int> indexSet(index.begin(), index.end());
//std::set<int> indexSet(index.begin(), index.end());
QSet<int> indexSet;
foreach (int value, index) {
indexSet.insert(value); // Insert each element of list into set
}
// 判断是否需要显示
vtkDataArray* showArray = dataSet->GetPointData()->GetArray("SHOW");
vtkDataArray* IDSArray=dataSet->GetPointData()->GetArray("IDS");
@ -261,7 +265,7 @@ namespace MeshData {
int pointid = -1;
for(int i = 0; i < showArray->GetNumberOfTuples(); ++i) {
int pointid =IDSArray->GetComponent(i, 1);
if(indexSet.find(pointid) != indexSet.end()) // 判断是否正确
if(indexSet.contains(pointid))//if(indexSet.find(pointid) != indexSet.end()) // 判断是否正确
{
showArray->SetComponent(i, 0, value);
}
@ -295,10 +299,15 @@ namespace MeshData {
if(nullptr==IDSArray||nullptr == showArray)
return;
std::set<int> indexSet(indexs.begin(), indexs.end());
//std::set<int> indexSet(indexs.begin(), indexs.end());
QSet<int> indexSet;
foreach (int value, indexs) {
indexSet.insert(value); // Insert each element of list into set
}
for(int i = 0; i < showArray->GetNumberOfTuples(); ++i) {
int cellid = IDSArray->GetComponent(i, 1);
if(indexSet.find(cellid) != indexSet.end()) // 判断是否正确
if(indexSet.contains(cellid))//if(indexSet.find(cellid) != indexSet.end()) // 判断是否正确
{
showArray->SetComponent(i, 0, value);
}

View File

@ -293,8 +293,8 @@ namespace WBFZ {
// 创建 vtkCellDataToPointData 过滤器
vtkSmartPointer<vtkGeometryFilter> cellToPointFilter = vtkSmartPointer<vtkGeometryFilter>::New();
vtkSmartPointer<vtkPolyData> inpolyData=vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPolyData> polydata2 = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
for (QString compontId: qCompontIds) {
meshSet = meshData->getMeshSetByID(compontId.toInt());
DebugInfo("point count %d : %d \n", compontId.toInt(), meshSet == nullptr);
@ -312,15 +312,54 @@ namespace WBFZ {
inpolyData = cellToPointFilter->GetOutput();
if(PointCloudOperator::PointCloudMeshOperator::GP(inpolyData,polydata,_SearchRadius,_Mu,_MaximumNearestNeighbors,_MaximumSurfaceAngle,_MaximumAngle,_MinimumAngle)){
}else{
return false;
}
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_with_rgba(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_filtered( new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output( new pcl::PointCloud<pcl::PointXYZRGBA>); // 输出结果
pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals(new pcl::PointCloud<pcl::PointNormal>); // 法线向量
pcl::search::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::search::KdTree<pcl::PointNormal>);
pcl::io::vtkPolyDataToPointCloud(inpolyData, *cloud_with_rgba);
qDebug()<<"cloud_with_rgba "<<cloud_with_rgba->size();
PointCloudOperator::PointCloudCommon::NormalEstimation(cloud_with_rgba, cloud_with_normals);
tree2->setInputCloud(cloud_with_normals); // 构建搜索树
std::shared_ptr<pcl::PolygonMesh> mesh (new pcl::PolygonMesh); // 非智能指针,需要释放
pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3; // 定义三角化对象
gp3.setSearchRadius(_SearchRadius); // 设置连接点之间的最大距离(即三角形的最大边长)
gp3.setMu(_Mu); // 设置被样本点搜索其临近点的最远距离,为了适应点云密度的变化
gp3.setMaximumNearestNeighbors(_MaximumNearestNeighbors); // 设置样本点可搜索的邻域个数
gp3.setMaximumSurfaceAngle(_MaximumSurfaceAngle); // 设置某点法线方向偏离样本点法线方向的最大角度
gp3.setMinimumAngle(_MaximumAngle); // 设置三角化后得到三角形内角的最小角度
gp3.setMaximumAngle(_MinimumAngle); // 设置三角化后得到三角形内角的最大角度
gp3.setNormalConsistency(false); // 设置该参数保证法线朝向一致
gp3.setInputCloud(cloud_with_normals); // 设置输入点云为有向点云
gp3.setSearchMethod(tree2); // 设置搜索方式
gp3.reconstruct(*mesh); // 重建提取三角化 -- 这里会导致程序崩溃,可能存在内存泄露,
// DebugInfo("remesh over GP \n");
// return false;
size_t pointcount = PointCloudOperator::PointCloudCommon::mesh2vtk(*mesh, polydata2);
vtkSmartPointer<vtkGeometryFilter> geofilter=vtkSmartPointer<vtkGeometryFilter>::New();
geofilter->SetInputData(polydata2);
geofilter->Update();
polydata=geofilter->GetOutput();
qDebug()<<"cellToPointFilter successfully!! wait for writing file dataset : "<<inpolyData->GetNumberOfPoints()<<" "<<inpolyData->GetNumberOfCells();
// if(PointCloudOperator::PointCloudMeshOperator::GP(inpolyData,polydata,_SearchRadius,_Mu,_MaximumNearestNeighbors,_MaximumSurfaceAngle,_MaximumAngle,_MinimumAngle)){
//
// }else{
// return false;
// }
DebugInfo("PCLGPMeshAlg successfully!! wait for writing file dataset : %d \n",nullptr==polydata);
if(nullptr!=polydata){
DebugInfo("PCLGPMeshAlg successfully!! wait for writing file dataset : %d %d\n",polydata->GetNumberOfPoints(),polydata->GetNumberOfCells());
}else{
return false;
}
QString filepath = _fileName;
QFile outfile_presave(_fileName);

View File

@ -37,6 +37,9 @@ EchoTableEditWindow::EchoTableEditWindow(QWidget* parent)
connect(ui->actionSave, SIGNAL(triggered()),this, SLOT(on_actionSave_triggered()));
connect(ui->actionSaveAs, SIGNAL(triggered()),this, SLOT(on_actionSaveAs_triggered()));
connect(ui->actionRCSExport ,SIGNAL(triggered()),this,SLOT(on_actionRCSExport()));
QObject::connect(ui->actiondeleteRows, SIGNAL(triggered()), this, SLOT(tableView_RemoveSelectRows()));
QObject::connect(ui->actionundeleteRows, SIGNAL(triggered()), this, SLOT(tableView_unRemoveSelectRows()));
}
EchoTableEditWindow::~EchoTableEditWindow()
@ -66,8 +69,6 @@ int EchoTableEditWindow::initTableViewContextMenu()
this->tableViewContextMenu->addAction(m_undoAction);
this->tableViewContextMenu->addAction(m_redoAction);
QAction *copyAction= this->tableViewContextMenu->addAction(u8"复制"); // 复制
copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
QObject::connect(copyAction, SIGNAL(triggered()), this, SLOT(tableView_CopyAction()));
@ -78,6 +79,7 @@ int EchoTableEditWindow::initTableViewContextMenu()
QAction* CheckFieldHasEmptyCeilAction = this->tableViewContextMenu->addAction(u8"检查单元格为空");
QObject::connect(CheckFieldHasEmptyCeilAction, SIGNAL(triggered()), this, SLOT(tableView_CheckFieldHasEmptyCeilAction()));
//qDebug() << u8"初始化contextMenu结束";
return 0;
}
@ -225,8 +227,6 @@ void EchoTableEditWindow::tableView_CheckFieldHasEmptyCeilAction()
}
this->ui->tableView->show();
this->ui->tableView->scrollTo(cellIndexes[0], QAbstractItemView::EnsureVisible);
}
void EchoTableEditWindow::on_actionOpen_triggered()
@ -244,6 +244,167 @@ void EchoTableEditWindow::on_actionSaveAs_triggered()
this->SaveAsDialog();
}
void EchoTableEditWindow::on_actionCalibrationConst_triggered()
{
// 补充定标软件功能
}
int EchoTableEditWindow::LockFileOpen(bool flag)
{
this->FILEOPENLOCK = flag;
return 0;
}
int EchoTableEditWindow::setCheckFieldContextHasEmptyCeilLOCK(bool flag)
{
this->CheckFieldContextHasEmptyCeilLOCK = flag;
return 0;
}
int EchoTableEditWindow::loadTablemode(std::shared_ptr<AbstractTableModel> mode)
{
this->model = mode;
this->ui->tableView->setModel(this->model.get());
if (this->model->rowCount() > 1e4) {
this->ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
}
return 0;
}
int EchoTableEditWindow::setTableViewAutoSort(bool flag)
{
this->ui->tableView->setSortingEnabled(flag);
return flag;
}
int EchoTableEditWindow::initTableViewStatusBarControl()
{
this->statusprogressBar = new QProgressBar();
this->statusprogressBar->setRange(0, 100); // 设置进度条范围
this->statusprogressBar->setValue(0); // 设置当前进度
this->ui->statusbar->addPermanentWidget(this->statusprogressBar); // 在状态栏中添加进度条
return 0;
}
int EchoTableEditWindow::OpenCSVDialog()
{
if (this->FILEOPENLOCK) {
return 0;
}
else {}
QString tableFilepath = getOpenFilePath(
this,
QString::fromUtf8(u8"打开表格文件"),
QString::fromUtf8(u8"csv文件 (*.csv);;xls文件(*.xls)"));
this->ui->statusbar->showMessage(u8"正在打开文件....");
std::shared_ptr< FEKOResultCsvTableModel> tablemode = std::make_shared< FEKOResultCsvTableModel>();
tablemode->loadCSVFilePath(tableFilepath);
this->loadTablemode(tablemode);
this->setTableViewAutoSort(true);
this->LockFileOpen();
this->ui->statusbar->showMessage(u8"文件打开结束");
QFileInfo fileinfo(tableFilepath);
this->setWindowTitle(fileinfo.fileName());
return -1;
}
int EchoTableEditWindow::SaveCSVDialog()
{
this->model->saveFilePath();
return 0;
}
int EchoTableEditWindow::SaveAsDialog()
{
QString filepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"csv文件 (*.csv)"));//多组扩展名用双分号";;"隔开
this->model->saveAsFilePath(filepath);
return 0;
}
void EchoTableEditWindow::on_actionRCSExport() {
// 检查是否远场回波
bool isfar=false;
bool isnear=false;
//this->model;
//判断指针
std::shared_ptr<FEKOResultCsvTableModel> echoTableModel(new FEKOResultCsvTableModel);
echoTableModel->loadCSVFilePath(this->model->getCSVPath());
if(echoTableModel->rowCount()<=0||echoTableModel->colCount()<=0){
QMessageBox::warning(this, u8"警告", u8"回波文件结构解析错误,请检查文件");
return ;
}else{}
if(echoTableModel){
QStringList colnames=echoTableModel->getColumnNames();
for(size_t i=0;i<colnames.count();i++){
if(colnames[i].toLower().contains("file type")||colnames[i]=="File Type"){
size_t colidx=echoTableModel->getColumnIdxByColumName(colnames[i]);
QString filetypeStr=echoTableModel->itemText(0,colidx);
if(filetypeStr.toLower().contains("far field")||filetypeStr.contains("Far Field")||filetypeStr=="Far Field"){
isfar=true;
}else{}
if(filetypeStr.toLower().contains("near field")||filetypeStr=="Electric near field"){
isnear= true;
}else{}
}
}
}else{
QMessageBox::warning(this, u8"警告", u8"回波文件结构解析错误,请检查文件");
return ;
}
// ---------------------- 远场结果 --------------------------------------------------
if(isfar){
QString filepath =
getSaveFilePath(this, QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"RCS (*.csv)")); // 多组扩展名用双分号";;"隔开
// 保存并导出RCS文件
FEKOBase::RCSEchoDataComputer rsccomputer;
rsccomputer.ComputerFromFile(this->model->getCSVPath());
rsccomputer.toCSV(filepath);
QMessageBox::information(this, u8"信息",QString(u8"保存至:%1").arg(filepath));
}else{
QMessageBox::warning(this, u8"警告",u8"请使用远场数据作为RCS计算输入");
};
}
void EchoTableEditWindow::tableView_RemoveSelectRows() {
// 删除指定行数
QItemSelectionModel* selectionModel = this->ui->tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
if (selectedIndexes.count() == 0) {
return;
}
QList<int> rows;
for (int i = 0; i < selectedIndexes.count(); i++) {
this->model->setDeleteFlag(selectedIndexes[i].row(), true);
}
this->ui->tableView->show();
// this->m_undoStack->push(new RemoveRowsCommand(this->ui->tableView, rows));
// this->ui->tableView->show();
}
void EchoTableEditWindow::tableView_unRemoveSelectRows() {
// int index = this->m_undoStack->index();
// this->m_undoStack->setIndex(index );
QItemSelectionModel* selectionModel = this->ui->tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
if (selectedIndexes.count() == 0) {
return;
}
QList<int> rows;
for (int i = 0; i < selectedIndexes.count(); i++) {
this->model->setDeleteFlag(selectedIndexes[i].row(), false);
}
this->ui->tableView->show();
}
void EchoTableEditWindow::on_actionEchoSplitExport_triggered()
{
// 在窗口关闭事件中询问用户是否关闭
@ -316,9 +477,9 @@ void EchoTableEditWindow::on_actionEchoSplitExport_triggered()
getSaveFilePath(this, QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"phi文件 (*.phi)")); // 多组扩展名用双分号";;"隔开
// QString Rfilepath =
// getSaveFilePath(this, QString::fromUtf8(u8"另存为"),
// QString::fromUtf8(u8"R文件 (*.R)")); // 多组扩展名用双分号";;"隔开
// QString Rfilepath =
// getSaveFilePath(this, QString::fromUtf8(u8"另存为"),
// QString::fromUtf8(u8"R文件 (*.R)")); // 多组扩展名用双分号";;"隔开
this->ui->statusbar->showMessage(u8"正在导出theta极化");
farfilePraseclass.toThetapolar(thetafilepath);
@ -378,147 +539,4 @@ void EchoTableEditWindow::on_actionEchoSplitExport_triggered()
} else {
QMessageBox::information(this, u8"信息", u8"文件格式读取错误");
}
}
void EchoTableEditWindow::on_actionCalibrationConst_triggered()
{
// 补充定标软件功能
}
int EchoTableEditWindow::LockFileOpen(bool flag)
{
this->FILEOPENLOCK = flag;
return 0;
}
int EchoTableEditWindow::setCheckFieldContextHasEmptyCeilLOCK(bool flag)
{
this->CheckFieldContextHasEmptyCeilLOCK = flag;
return 0;
}
int EchoTableEditWindow::loadTablemode(std::shared_ptr<AbstractTableModel> mode)
{
this->model = mode;
this->ui->tableView->setModel(this->model.get());
if (this->model->rowCount() > 1e4) {
this->ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
}
return 0;
}
int EchoTableEditWindow::setTableViewAutoSort(bool flag)
{
this->ui->tableView->setSortingEnabled(flag);
return flag;
}
int EchoTableEditWindow::initTableViewStatusBarControl()
{
this->statusprogressBar = new QProgressBar();
this->statusprogressBar->setRange(0, 100); // 设置进度条范围
this->statusprogressBar->setValue(0); // 设置当前进度
this->ui->statusbar->addPermanentWidget(this->statusprogressBar); // 在状态栏中添加进度条
return 0;
}
int EchoTableEditWindow::OpenCSVDialog()
{
if (this->FILEOPENLOCK) {
return 0;
}
else {}
QString tableFilepath = getOpenFilePath(
this,
QString::fromUtf8(u8"打开表格文件"),
QString::fromUtf8(u8"csv文件 (*.csv);;xls文件(*.xls)"));
this->ui->statusbar->showMessage(u8"正在打开文件....");
std::shared_ptr< FEKOResultCsvTableModel> tablemode = std::make_shared< FEKOResultCsvTableModel>();
tablemode->loadCSVFilePath(tableFilepath);
this->loadTablemode(tablemode);
this->setTableViewAutoSort(true);
this->LockFileOpen();
this->ui->statusbar->showMessage(u8"文件打开结束");
QFileInfo fileinfo(tableFilepath);
this->setWindowTitle(fileinfo.fileName());
return -1;
}
int EchoTableEditWindow::SaveCSVDialog()
{
this->model->saveFilePath();
return 0;
}
int EchoTableEditWindow::SaveAsDialog()
{
QString filepath = getSaveFilePath(
this,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"csv文件 (*.csv)"));//多组扩展名用双分号";;"隔开
this->model->saveAsFilePath(filepath);
return 0;
}
void EchoTableEditWindow::on_actionRCSExport() {
// 检查是否远场回波
bool isfar=false;
bool isnear=false;
//this->model;
//判断指针
std::shared_ptr<FEKOResultCsvTableModel> echoTableModel(new FEKOResultCsvTableModel);
echoTableModel->loadCSVFilePath(this->model->getCSVPath());
if(echoTableModel->rowCount()<=0||echoTableModel->colCount()<=0){
QMessageBox::warning(this, u8"警告", u8"回波文件结构解析错误,请检查文件");
return ;
}else{}
if(echoTableModel){
QStringList colnames=echoTableModel->getColumnNames();
for(size_t i=0;i<colnames.count();i++){
if(colnames[i].toLower().contains("file type")||colnames[i]=="File Type"){
size_t colidx=echoTableModel->getColumnIdxByColumName(colnames[i]);
QString filetypeStr=echoTableModel->itemText(0,colidx);
if(filetypeStr.toLower().contains("far field")||filetypeStr.contains("Far Field")||filetypeStr=="Far Field"){
isfar=true;
}else{}
if(filetypeStr.toLower().contains("near field")||filetypeStr=="Electric near field"){
isnear= true;
}else{}
}
}
}else{
QMessageBox::warning(this, u8"警告", u8"回波文件结构解析错误,请检查文件");
return ;
}
// ---------------------- 远场结果 --------------------------------------------------
if(isfar){
QString filepath =
getSaveFilePath(this, QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"RCS (*.csv)")); // 多组扩展名用双分号";;"隔开
FEKOBase::RCSEchoDataComputer rsccomputer;
rsccomputer.ComputerFromFile(this->model->getCSVPath());
rsccomputer.toCSV(filepath);
QMessageBox::information(this, u8"信息",QString(u8"保存至:%1").arg(filepath));
}else{
QMessageBox::warning(this, u8"警告",u8"请使用远场数据作为RCS计算输入");
};
}

View File

@ -62,13 +62,17 @@ private:
public slots:
void calBackSCatter();
// void calBackSCatter();
// tableview 右键菜单
void ShowTableViewContextMenu(QPoint p);
void tableView_CopyAction();
void tableView_PasteAction();
void tableView_UndoAction();
void tableView_RedoAction();
void tableView_RemoveSelectRows();
void tableView_unRemoveSelectRows();
void tableView_CheckFieldHasEmptyCeilAction();
void on_actionOpen_triggered();

View File

@ -124,8 +124,16 @@
<addaction name="actionEchoSplitExport"/>
<addaction name="actionRCSExport"/>
</widget>
<widget class="QMenu" name="menuTableEdit">
<property name="title">
<string>表格编辑</string>
</property>
<addaction name="actiondeleteRows"/>
<addaction name="actionundeleteRows"/>
</widget>
<addaction name="menu"/>
<addaction name="menu_4"/>
<addaction name="menuTableEdit"/>
</widget>
<action name="actionOpen">
<property name="text">
@ -272,6 +280,16 @@
<string>RCS导出</string>
</property>
</action>
<action name="actiondeleteRows">
<property name="text">
<string>删除指定行</string>
</property>
</action>
<action name="actionundeleteRows">
<property name="text">
<string>撤销删除</string>
</property>
</action>
</widget>
<resources/>
<connections/>

View File

@ -2141,7 +2141,6 @@ bool FEKOBase::FBPImage_ISARNEAR(QString& restiffpath, MatrixXcd& echoData, Matr
Eigen::MatrixXcd pluse_R = Eigen::MatrixXcd::Zero(PRFCount, 1);
for(long ii=start_ii;ii<start_ii+block_len &&ii<image_height ;ii++)
#else
Eigen::MatrixXd im_R = Eigen::MatrixXd::Zero(PRFCount, 1); // 图像到脉冲矩阵 prf*1
Eigen::MatrixXcd term_R = Eigen::MatrixXcd::Zero(1, frepoints);
Eigen::MatrixXcd pluse_R = Eigen::MatrixXcd::Zero(PRFCount, 1);

View File

@ -1281,7 +1281,7 @@ Eigen::MatrixXcd gdalImageComplex::getDataComplex(int start_row, int start_col,
void gdalImageComplex::saveImage()
{
this->saveImage(this->data, this->start_row, this->start_col, this->data_band_ids);
this->savePreViewImage();
// this->savePreViewImage(); // 存在内存泄露问题2024-07-29 发现,后续修改
}
void gdalImageComplex::savePreViewImage()
{

View File

@ -357,3 +357,5 @@ void PasteCommand::redo()
}
this->tableItem->show();
}

View File

@ -36,6 +36,24 @@ public:
void redo() override;
};
class RemoveRowsCommand : public QUndoCommand { // 删除行命令
private:
QTableView* tableItem;
std::vector<std::vector<QString>> oldText;
std::vector<std::vector<QString>> newText;
size_t start_row;
public:
RemoveRowsCommand(QTableView* tableItem, QList<int> rows , QUndoCommand* parent = 0);
~RemoveRowsCommand();
//撤销
void undo() override;
//回退
void redo() override;
};
/*
*

View File

@ -9,426 +9,448 @@
#include <QDebug>
#include "SharedModuleLib/ProcessOn.h"
AbstractTableModel::AbstractTableModel(QObject* parent ):QAbstractTableModel(parent)
{}
AbstractTableModel::~AbstractTableModel(){
AbstractTableModel::AbstractTableModel(QObject* parent)
: QAbstractTableModel(parent)
{
}
AbstractTableModel::~AbstractTableModel() {}
FEKOResultCsvTableModel::FEKOResultCsvTableModel(QObject* parent)
:AbstractTableModel(parent)
{
}
FEKOResultCsvTableModel::~FEKOResultCsvTableModel()
: AbstractTableModel(parent)
{
}
FEKOResultCsvTableModel::~FEKOResultCsvTableModel() {}
void FEKOResultCsvTableModel::loadFilePath(QString csvPath)
{
return this->loadCSVFilePath(csvPath);
return this->loadCSVFilePath(csvPath);
}
void FEKOResultCsvTableModel::saveFilePath()
{
if (!isExists(this->csvPath)) {
this->csvPath = getSaveFilePath(
nullptr,
QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"csv文件 (*.csv)"));//多组扩展名用双分号";;"隔开
}
return this->saveCSVFilePath(this->csvPath);
if(!isExists(this->csvPath)) {
this->csvPath =
getSaveFilePath(nullptr, QString::fromUtf8(u8"另存为"),
QString::fromUtf8(u8"csv文件 (*.csv)")); // 多组扩展名用双分号";;"隔开
}
return this->saveCSVFilePath(this->csvPath);
}
void FEKOResultCsvTableModel::saveAsFilePath(QString csvpath)
{
return this->saveCSVFilePath(csvpath);
return this->saveCSVFilePath(csvpath);
}
void FEKOResultCsvTableModel::loadCSVFilePath(QString csvPath)
{
this->csvPath = csvPath;
QFile inFile(csvPath);
QStringList colnames;
QVector<QVector<QVariant>> datamap(0);
QStringList rowIDlist;
bool hascolnames = true;
size_t rowid = 0;
if (inFile.open(QIODevice::ReadOnly))
{
QTextStream stream_text(&inFile);
while (!stream_text.atEnd())
{
QString line = stream_text.readLine();
QStringList linesplit = line.split(QRegularExpression(",(?!\\s)")); // 字段切分
if (hascolnames) { // 列名
linesplit[0] = "id";
for (int col = 0; col < linesplit.size(); col++) {
QString colname_temp = linesplit.at(col);
colnames.append(linesplit.at(col)); // 追加字段名称
}
hascolnames = false;
}
else {
QVector<QVariant> mapline(colnames.count()); // 单行数据
mapline[0] =linesplit.at(0);
for (int col = 1; col < colnames.size(); col++) {
mapline[col] = linesplit.at(col);
}
datamap.append(mapline);
rowIDlist.append(QString::number(rowid));
rowid = rowid + 1;
//qDebug() << line;
}
}
inFile.close();
}
this->csvPath = csvPath;
QFile inFile(csvPath);
QStringList colnames;
QVector<QVector<QVariant>> datamap(0);
QStringList rowIDlist;
bool hascolnames = true;
size_t rowid = 0;
if(inFile.open(QIODevice::ReadOnly)) {
QTextStream stream_text(&inFile);
while(!stream_text.atEnd()) {
QString line = stream_text.readLine();
QStringList linesplit = line.split(QRegularExpression(",(?!\\s)")); // 字段切分
if(hascolnames) { // 列名
linesplit[0] = "id";
for(int col = 0; col < linesplit.size(); col++) {
QString colname_temp = linesplit.at(col);
colnames.append(linesplit.at(col)); // 追加字段名称
}
hascolnames = false;
} else {
QVector<QVariant> mapline(colnames.count()); // 单行数据
mapline[0] = linesplit.at(0);
for(int col = 1; col < colnames.size(); col++) {
mapline[col] = linesplit.at(col);
}
datamap.append(mapline);
rowIDlist.append(QString::number(rowid));
rowid = rowid + 1;
// qDebug() << line;
}
}
inFile.close();
} else {
}
// this->SetData(datamap, colnames, rowIDlist);
// QStringList tempColNames;
// for(int i=0;i<colnames.size();i++){
// if(colnames[i].indexOf("Re")>=0){
// QString colname=colnames[i];
// colname.replace("Re","");
// colname.replace("(","");
// colname.replace(")","");
// tempColNames.append(colname);
// }
// }
//
//
// for(int ii=0;ii<tempColNames.size();ii++) {
// colnames.append(tempColNames[ii]);
// for(size_t i = 0; i < datamap.size(); i++) {
// QVector<QVariant> mapline = datamap[i];
// double re = 0;
// double im = 0;
// for(int col = 1; col < mapline.size(); col++) {
// if(colnames[col].contains("Re") && colnames[col].contains(tempColNames[ii])){
// re=mapline[col].toDouble();
// }else{}
// if(colnames[col].contains("Im") && colnames[col].contains(tempColNames[ii])){
// im=mapline[col].toDouble();
// }else{}
// }
// double RCS=(re*re+im*im)*4*M_PI;
// mapline.append(QString::number(RCS));
// }
// }
//
this->SetData(datamap, colnames, rowIDlist);
if(0)
{
int iii=0;
// 废弃代码
// this->SetData(datamap, colnames, rowIDlist);
// QStringList tempColNames;
// for(int i=0;i<colnames.size();i++){
// if(colnames[i].indexOf("Re")>=0){
// QString colname=colnames[i];
// colname.replace("Re","");
// colname.replace("(","");
// colname.replace(")","");
// tempColNames.append(colname);
// }
// }
//
//
// for(int ii=0;ii<tempColNames.size();ii++) {
// colnames.append(tempColNames[ii]);
// for(size_t i = 0; i < datamap.size(); i++) {
// QVector<QVariant> mapline = datamap[i];
// double re = 0;
// double im = 0;
// for(int col = 1; col < mapline.size(); col++) {
// if(colnames[col].contains("Re") &&
// colnames[col].contains(tempColNames[ii])){ re=mapline[col].toDouble(); }else{} if(colnames[col].contains("Im") && colnames[col].contains(tempColNames[ii])){ im=mapline[col].toDouble(); }else{}
// }
// double RCS=(re*re+im*im)*4*M_PI;
// mapline.append(QString::number(RCS));
// }
// }
//
}
this->SetData(datamap, colnames, rowIDlist);
QStringList tempColNames;
for(int i=0;i<colnames.size();i++){
if(colnames[i].indexOf("Re")>=0){
QString colname=colnames[i];
colname.replace("Re","");
colname.replace("(","");
colname.replace(")","");
for(int i = 0; i < colnames.size(); i++) {
if(colnames[i].indexOf("Re") >= 0) {
QString colname = colnames[i];
colname.replace("Re", "");
colname.replace("(", "");
colname.replace(")", "");
tempColNames.append(colname);
}
}
// for(int ii=0;ii<tempColNames.size();ii++) {
// colnames.append(tempColNames[ii]);
// for(size_t i = 0; i < datamap.size(); i++) {
// QVector<QVariant> mapline = datamap[i];
// double re = 0;
// double im = 0;
// for(int col = 1; col < mapline.size(); col++) {
// if(colnames[col].contains("Re") && colnames[col].contains(tempColNames[ii])){
// re=mapline[col].toDouble();
// }else{}
// if(colnames[col].contains("Im") && colnames[col].contains(tempColNames[ii])){
// im=mapline[col].toDouble();
// }else{}
// }
// double RCS=sqrt(re*re+im*im);
// mapline.append(QString::number(RCS));
// }
// }
// for(int ii=0;ii<tempColNames.size();ii++) {
// colnames.append(tempColNames[ii]);
// for(size_t i = 0; i < datamap.size(); i++) {
// QVector<QVariant> mapline = datamap[i];
// double re = 0;
// double im = 0;
// for(int col = 1; col < mapline.size(); col++) {
// if(colnames[col].contains("Re") && colnames[col].contains(tempColNames[ii])){
// re=mapline[col].toDouble();
// }else{}
// if(colnames[col].contains("Im") && colnames[col].contains(tempColNames[ii])){
// im=mapline[col].toDouble();
// }else{}
// }
// double RCS=sqrt(re*re+im*im);
// mapline.append(QString::number(RCS));
// }
// }
}
void FEKOResultCsvTableModel::saveCSVFilePath(QString csvpath)
{
qDebug() << u8"正在保存为 csv文件中";
QFile file(csvpath);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
QTextStream stream(&file);
// 写入表头
for (const QString& header : this->m_hor_hedlbls) // 写入表头
{
stream << header;
if (&header != &this->m_hor_hedlbls.last()) // 如果不是最后一列,写入逗号
stream << ",";
}
stream << "\n";
// 写入数据
for (int i = 0; i < this->m_vec_hedlbls.count(); i++) {
for (int j = 0; j < this->m_hor_hedlbls.count()-1; j++) {
stream << this->m_data_map[i][j].toString();
stream << ",";
}
stream << this->m_data_map[i][this->m_hor_hedlbls.count() - 1].toString();
stream << "\n";
}
file.close();
}
qDebug() << csvpath;
qDebug() << u8"正在保存为 csv文件中";
QFile file(csvpath);
if(file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QTextStream stream(&file);
// 写入表头
for(const QString& header : this->m_hor_hedlbls) // 写入表头
{
stream << header;
if(&header != &this->m_hor_hedlbls.last()) // 如果不是最后一列,写入逗号
stream << ",";
}
stream << "\n";
// 写入数据
for(int i = 0; i < this->m_vec_hedlbls.count(); i++) {
if(this->isdeletes[i]) {
} else { // 非删除目标
for(int j = 0; j < this->m_hor_hedlbls.count() - 1; j++) {
stream << this->m_data_map[i][j].toString();
stream << ",";
}
stream << this->m_data_map[i][this->m_hor_hedlbls.count() - 1].toString();
stream << "\n";
}
}
file.close();
}
qDebug() << csvpath;
}
QStringList FEKOResultCsvTableModel::getColumnNames()
{
return this->m_hor_hedlbls;
return this->m_hor_hedlbls;
}
QStringList FEKOResultCsvTableModel::getItemDataByColumn(int colidx)
{
QStringList result;
for (size_t i = 0; i < this->rowCount(); i++) {
result.append(this->m_data_map[i][colidx].toString());
}
return result;
QStringList result;
for(size_t i = 0; i < this->rowCount(); i++) {
result.append(this->m_data_map[i][colidx].toString());
}
return result;
}
QString FEKOResultCsvTableModel::getCSVPath() {
return this->csvPath;
}
int FEKOResultCsvTableModel::getColumnIdxByColumName(QString ColumnName) {
for (int i = 0; i < this->colCount(); i++) {
if (ColumnName == this->m_hor_hedlbls[i]) {
return i;
}
}
return -1;
}
void FEKOResultCsvTableModel::SetData(const QVector<QVector<QVariant>>& map,QStringList &colnames, QStringList& rowIds)
QString FEKOResultCsvTableModel::getCSVPath()
{
beginResetModel();
m_hor_hedlbls = colnames; // 列名
m_data_map = map;
m_vec_hedlbls = rowIds; // 行名
this->colorData = QVector<QVector<QColor>>(m_vec_hedlbls.count(), QVector<QColor>(m_hor_hedlbls.count()));
for (int i = 0; i < m_hor_hedlbls.count(); i++) {
for (int j = 0; j < m_vec_hedlbls.count(); j++) {
this->colorData[j][i] = QColor(255, 255, 255);
}
}
endResetModel();
return this->csvPath;
}
void FEKOResultCsvTableModel::setHignlightIndex(QVector<QPair<int, int> > vec_index)
int FEKOResultCsvTableModel::getColumnIdxByColumName(QString ColumnName)
{
beginResetModel();
m_highlight_indexs = vec_index;
endResetModel();
for(int i = 0; i < this->colCount(); i++) {
if(ColumnName == this->m_hor_hedlbls[i]) {
return i;
}
}
return -1;
}
void FEKOResultCsvTableModel::SetData(const QVector<QVector<QVariant>>& map, QStringList& colnames,
QStringList& rowIds)
{
beginResetModel();
m_hor_hedlbls = colnames; // 列名
m_data_map = map;
m_vec_hedlbls = rowIds; // 行名
this->colorData =
QVector<QVector<QColor>>(m_vec_hedlbls.count(), QVector<QColor>(m_hor_hedlbls.count()));
// 增加标记
this->isdeletes = QVector<bool>(m_vec_hedlbls.count(), false);
for(int j = 0; j < m_vec_hedlbls.count(); j++) {
this->isdeletes[j] = false;
}
for(int i = 0; i < m_hor_hedlbls.count(); i++) {
for(int j = 0; j < m_vec_hedlbls.count(); j++) {
this->colorData[j][i] = QColor(255, 255, 255);
}
}
endResetModel();
}
void FEKOResultCsvTableModel::setHignlightIndex(QVector<QPair<int, int>> vec_index)
{
beginResetModel();
m_highlight_indexs = vec_index;
endResetModel();
}
Qt::ItemFlags FEKOResultCsvTableModel::flags(const QModelIndex& index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
flags |= Qt::ItemIsEditable;
return flags;
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
flags |= Qt::ItemIsEditable;
return flags;
}
QVariant FEKOResultCsvTableModel::data(const QModelIndex& _index, int role) const
{
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
return this->m_data_map[_index.row()][_index.column()];
}
else if (role == Qt::TextAlignmentRole) return Qt::AlignCenter; // 文字居中
else if (role == Qt::BackgroundColorRole) // 设置背景色
{
if (m_highlight_indexs.contains(qMakePair<int, int>(_index.row(), _index.column())))
{
return QColor(230, 247, 255);
}
else {
return this->colorData[_index.row()][_index.column()];
}
}
if(role == Qt::DisplayRole || role == Qt::EditRole) {
return this->m_data_map[_index.row()][_index.column()];
} else if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter; // 文字居中
else if(role == Qt::BackgroundColorRole) // 设置背景色
{
if(m_highlight_indexs.contains(qMakePair<int, int>(_index.row(), _index.column()))) {
return QColor(230, 247, 255);
} else {
return this->colorData[_index.row()][_index.column()];
}
}
// else if(role == Qt::DecorationRole) // 为item添加图标
// {
// return QIcon(":/images/device.svg");
// }
// else if(role == Qt::DecorationRole) // 为item添加图标
// {
// return QIcon(":/images/device.svg");
// }
return QVariant();
return QVariant();
}
QVariant FEKOResultCsvTableModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant FEKOResultCsvTableModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal)
{
if (role == Qt::DisplayRole) return m_hor_hedlbls.at(section);
else return QVariant();
}
if(orientation == Qt::Horizontal) {
if(role == Qt::DisplayRole)
return m_hor_hedlbls.at(section);
else
return QVariant();
}
return QAbstractTableModel::headerData(section, orientation, role); // 垂直表头的序号
return QAbstractTableModel::headerData(section, orientation, role); // 垂直表头的序号
}
bool FEKOResultCsvTableModel::setData(const QModelIndex& _index, const QVariant& value, int role)
{
if (_index.isValid() && role == Qt::EditRole)
{
this->isNeedExtendTable(_index.row(), _index.column());
if (this->m_data_map[_index.row()][_index.column()]== value) {
return false;
}
else {}
this->m_data_map[_index.row()][_index.column()] = value;
emit dataChanged(_index, _index);
emit itemChanged(_index, value);
return true;
}
else if (role == Qt::BackgroundColorRole) {
this->colorData[_index.row()][_index.column()] = value.value<QColor>();
}
return false;
if(_index.isValid() && role == Qt::EditRole) {
this->isNeedExtendTable(_index.row(), _index.column());
if(this->m_data_map[_index.row()][_index.column()] == value) {
return false;
} else {
}
this->m_data_map[_index.row()][_index.column()] = value;
emit dataChanged(_index, _index);
emit itemChanged(_index, value);
return true;
} else if(role == Qt::BackgroundColorRole) {
this->colorData[_index.row()][_index.column()] = value.value<QColor>();
}
return false;
}
int FEKOResultCsvTableModel::rowCount(const QModelIndex& parent) const
{
return this->m_vec_hedlbls.count();
return this->m_vec_hedlbls.count();
}
int FEKOResultCsvTableModel::columnCount(const QModelIndex& parent) const
{
return this->m_hor_hedlbls.count();
return this->m_hor_hedlbls.count();
}
QString FEKOResultCsvTableModel::itemText(int row, int column) const
{
return this->m_data_map[row][column].toString();
return this->m_data_map[row][column].toString();
}
QString FEKOResultCsvTableModel::itemText(const QModelIndex& index) const
{
return this->m_data_map[index.row()][index.column()].toString();
return this->m_data_map[index.row()][index.column()].toString();
}
void FEKOResultCsvTableModel::setItemText(const QModelIndex& index, const QString& str)
{
this->isNeedExtendTable(index.row(), index.column());
this->m_data_map[index.row()][index.column()] = str;
this->isNeedExtendTable(index.row(), index.column());
this->m_data_map[index.row()][index.column()] = str;
}
void FEKOResultCsvTableModel::setItemText(int row, int column, const QString& str)
{
this->isNeedExtendTable(row, column);
this->m_data_map[row][column] = str;
this->isNeedExtendTable(row, column);
this->m_data_map[row][column] = str;
}
QVariant FEKOResultCsvTableModel::ItemData(const QModelIndex& index) const
{
return this->m_data_map[index.row()][index.column()];
if(index.row() >= this->m_data_map.count()
|| index.column() >= this->m_data_map[index.row()].count()) {
return QVariant();
}
return this->m_data_map[index.row()][index.column()];
}
QVariant FEKOResultCsvTableModel::ItemData(int row, int column) const
{
return this->m_data_map[row][column];
if(row >= this->m_data_map.count() || column >= this->m_data_map[row].count()) {
return this->m_data_map[row][column];
} else {
return QVariant();
}
}
void FEKOResultCsvTableModel::SetItemData(const QModelIndex& index, const QVariant& data)
{
this->isNeedExtendTable(index.row(), index.column());
this->m_data_map[index.row()][index.column()] = data;
this->isNeedExtendTable(index.row(), index.column());
this->m_data_map[index.row()][index.column()] = data;
}
void FEKOResultCsvTableModel::SetItemData(int row, int column, const QVariant& data)
{
this->isNeedExtendTable(row, column);
this->m_data_map[row][column] = data;
this->isNeedExtendTable(row, column);
this->m_data_map[row][column] = data;
}
size_t FEKOResultCsvTableModel::rowCount()
{
return this->m_data_map.count();
return this->m_data_map.count();
}
size_t FEKOResultCsvTableModel::colCount()
{
return this->m_vec_hedlbls.count();
return this->m_vec_hedlbls.count();
}
void FEKOResultCsvTableModel::isNeedExtendTable(size_t row, size_t column) {
size_t max_colnum = this->m_hor_hedlbls.count() - 1 < column ? column + 1 : this->m_hor_hedlbls.count(); // 判断是否扩展列名
if (this->m_hor_hedlbls.count() <= column) {
for (int i = this->m_hor_hedlbls.count(); i <= column; i++) {
this->m_hor_hedlbls.append(QString::number(i));
}
}
if (0 > row || column < 0) {
return;
}
else if (row > this->m_vec_hedlbls.count()-1 || column > this->m_hor_hedlbls.count()-1) {
for (int i = 0; i <= row; i++) {
if (i >= this->m_data_map.count()) {
this->m_data_map.append(QVector<QVariant>(max_colnum));
this->colorData.append(QVector<QColor>(max_colnum));
this->m_vec_hedlbls.append(QString::number(i));
}
else {
if (this->m_data_map[i].count() < column + 1) { // 扩充
this->m_data_map[i].reserve(max_colnum);
//this->colorData[i].reserve(max_colnum);
for (size_t ci = this->colorData[i].count(); ci < max_colnum; ci++) {
this->colorData[i].append(QColor(255, 255, 255));
}
}
else {
}
}
}
}
void FEKOResultCsvTableModel::isNeedExtendTable(size_t row, size_t column)
{
size_t max_colnum = this->m_hor_hedlbls.count() - 1 < column
? column + 1
: this->m_hor_hedlbls.count(); // 判断是否扩展列名
if(this->m_hor_hedlbls.count() <= column) {
for(int i = this->m_hor_hedlbls.count(); i <= column; i++) {
this->m_hor_hedlbls.append(QString::number(i));
}
}
if(0 > row || column < 0) {
return;
} else if(row > this->m_vec_hedlbls.count() - 1 || column > this->m_hor_hedlbls.count() - 1) {
for(int i = 0; i <= row; i++) {
if(i >= this->m_data_map.count()) {
this->m_data_map.append(QVector<QVariant>(max_colnum));
this->colorData.append(QVector<QColor>(max_colnum));
this->m_vec_hedlbls.append(QString::number(i));
} else {
if(this->m_data_map[i].count() < column + 1) { // 扩充
this->m_data_map[i].reserve(max_colnum);
// this->colorData[i].reserve(max_colnum);
for(size_t ci = this->colorData[i].count(); ci < max_colnum; ci++) {
this->colorData[i].append(QColor(255, 255, 255));
}
} else {
}
}
}
}
}
void FEKOResultCsvTableModel::clear()
{
beginResetModel();
//m_table_map.clear();
m_data_map.clear();
m_hor_hedlbls.clear();
m_vec_hedlbls.clear();
m_highlight_indexs.clear();
endResetModel();
beginResetModel();
// m_table_map.clear();
m_data_map.clear();
m_hor_hedlbls.clear();
m_vec_hedlbls.clear();
m_highlight_indexs.clear();
endResetModel();
}
QVariant* FEKOResultCsvTableModel::getVariantPtr(size_t row, size_t col)
{
return &(this->m_data_map[row][col]);
//return nullptr;
return &(this->m_data_map[row][col]);
// return nullptr;
}
void AbstractTableModel::loadFilePath(QString csvPath)
void FEKOResultCsvTableModel::setDeleteFlag(int row, bool flag)
{
this->isdeletes[row] = flag;
if(flag) {
for(int i = 0; i < this->m_hor_hedlbls.size(); i++) {
this->colorData[row][i] = QColor(255, 0, 0); // 删除标记
}
} else {
for(int i = 0; i < this->m_hor_hedlbls.size(); i++) {
this->colorData[row][i] = QColor(255, 255, 255); // 非删除标记
}
}
}
void AbstractTableModel::saveFilePath()
bool FEKOResultCsvTableModel::getDeleteFlag(int row)
{
return this->isdeletes[row];
}
void AbstractTableModel::saveAsFilePath(QString csvpath)
{
}
void AbstractTableModel::loadFilePath(QString csvPath) {}
void AbstractTableModel::saveFilePath() {}
void AbstractTableModel::saveAsFilePath(QString csvpath) {}
QString AbstractTableModel::getCSVPath()
{
return QString();
return QString();
}
void AbstractTableModel::setDeleteFlag(int row, bool flag) {}
bool AbstractTableModel::getDeleteFlag(int row)
{
return false;
}

View File

@ -20,6 +20,8 @@ public:
virtual void saveFilePath();
virtual void saveAsFilePath(QString csvpath);
virtual QString getCSVPath();
virtual void setDeleteFlag(int row, bool flag);
virtual bool getDeleteFlag(int row);
};
// FKEOResult.csv 表格对应类 2023.07.25 重写类
@ -33,6 +35,7 @@ private:
QVector<QPair<int, int>> m_highlight_indexs; // 背景高亮的indexs
QVector<QVector<QColor>> colorData;
QString csvPath;
QVector<bool> isdeletes;// 用于标记是否删除
public:
explicit FEKOResultCsvTableModel(QObject* parent = nullptr);
@ -83,6 +86,9 @@ public:
QVariant* getVariantPtr(size_t row, size_t col);
virtual void setDeleteFlag(int row, bool flag);
virtual bool getDeleteFlag(int row);
signals:
void itemChanged(const QModelIndex& index, const QVariant& value);
};

View File

@ -11,7 +11,7 @@
#include "PointCloudMesh.h"
#include "PointCloudCommon.h"
#include "Common/DebugLogger.h"
#include <QDebug>
namespace PointCloudOperator {
PointCloudMeshOperator::PointCloudMeshOperator(QObject* parent)
: QObject(parent)
@ -35,6 +35,7 @@ namespace PointCloudOperator {
pcl::search::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::search::KdTree<pcl::PointNormal>);
pcl::io::vtkPolyDataToPointCloud(inpolygon, *cloud_with_rgba);
qDebug()<<"cloud_with_rgba "<<cloud_with_rgba->size();
PointCloudOperator::PointCloudCommon::NormalEstimation(cloud_with_rgba, cloud_with_normals);
tree2->setInputCloud(cloud_with_normals); // 构建搜索树

View File

@ -55,7 +55,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>3</number>
</property>
<widget class="QWidget" name="colorTab">
<attribute name="title">
@ -459,6 +459,45 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>模型选择参数</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_NearPointGap">
<property name="text">
<string>最近点捕捉</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>