2023-05-08 06:32:41 +00:00
/**
* @ file mainWindow . cpp
* @ brief 主 窗 口 类 源 文 件
2024-03-20 07:33:49 +00:00
* @ author LAMPCAE 研 发 小 组 ( LAMPCAE @ diso . cn )
2023-05-08 06:32:41 +00:00
* @ version 2.5 .0
* @ date 2022 - 03 - 29 16 : 12
* @ copyright Copyright ( c ) Since 2020 青 岛 数 智 船 海 科 技 有 限 公 司 All rights reserved .
*
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2024-03-20 07:33:49 +00:00
* Program : LAMPCAE
2023-05-08 06:32:41 +00:00
*
* Copyright ( c ) Since 2020 青 岛 数 智 船 海 科 技 有 限 公 司 All rights reserved .
2024-03-20 07:33:49 +00:00
* See License or http : //www.LAMPCAE.com/ for details.
2023-05-08 06:32:41 +00:00
*
* BSD 3 - Clause License
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS "
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED .
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
# include "MainWindow.h"
2023-05-09 11:00:22 +00:00
2023-05-08 06:32:41 +00:00
# include "ConfigOptions/ConfigOptions.h"
# include "ConfigOptions/GeometryConfig.h"
2023-05-09 11:00:22 +00:00
# include "ConfigOptions/GlobalConfig.h"
2023-05-08 06:32:41 +00:00
# include "ConfigOptions/MeshConfig.h"
# include "ConfigOptions/PostConfig.h"
# include "ConfigOptions/ProjectTreeConfig.h"
2023-05-09 11:00:22 +00:00
# include "CustomizerHelper.h"
# include "DialogAbout.h"
# include "Geometry/geometryData.h"
2024-07-10 10:52:22 +00:00
# include "Geometry/geometrySet.h"
# include "DataProperty/DataBase.h"
2023-05-09 11:00:22 +00:00
# include "GeometryWidgets/dialogSketchPlane.h"
# include "GmshModule/GmshModule.h"
# include "IO/IOConfig.h"
# include "MainWidgets/ControlPanel.h"
# include "MainWidgets/DialogCreateGeoComponent.h"
# include "MainWidgets/DialogCreateSet.h"
# include "MainWidgets/DialogFilterMesh.h"
# include "MainWidgets/DialogVTKTransform.h"
# include "MainWidgets/messageWindow.h"
# include "MainWidgets/preWindow.h"
# include "MainWidgets/ProcessWindow.h"
# include "MainWidgets/projectSolveDialog.h"
2024-07-23 03:40:54 +00:00
# include "MainWidgets/meshViewProvider.h"
# include "MainWidgets/meshKernalViewObject.h"
2024-07-31 06:32:53 +00:00
# include "MainWidgets/vtkMeshSelectTableModel.h"
# include "MainWidgets/SelectNodeShow.h"
2024-07-23 03:40:54 +00:00
2023-05-09 11:00:22 +00:00
# include "MainWindowPy.h"
# include "MeshData/meshKernal.h"
2024-04-07 15:51:25 +00:00
# include "MeshData/meshSet.h"
2023-05-09 11:00:22 +00:00
# include "MeshData/meshSingleton.h"
2023-05-08 06:32:41 +00:00
# include "ModelData/modelDataBaseExtend.h"
# include "ModelData/modelDataSingleton.h"
2023-05-09 11:00:22 +00:00
# include "ModuleBase/ModuleBase.h"
# include "ModuleBase/ModuleType.h"
# include "ModuleBase/ThreadTaskManager.h"
2023-05-08 06:32:41 +00:00
# include "PluginManager/PluginManager.h"
# include "PythonModule/PyAgent.h"
# include "SARibbonMWUi.h"
2023-05-09 11:00:22 +00:00
# include "Settings/BusAPI.h"
# include "Settings/GraphOption.h"
# include "SignalHandler.h"
# include "SolverControl/DialogSolverManager.h"
2024-07-10 10:52:22 +00:00
# include "PointCloudOperator/MeshOpearatorCommon.h"
2024-07-23 03:40:54 +00:00
# include "MainWidgets/createfekocadmodel.h"
2023-05-09 11:00:22 +00:00
# include "SubWindowManager.h"
# include "Translator.h"
# include <QApplication>
# include <QCloseEvent>
# include <QDebug>
# include <QDesktopServices>
# include <QFileDialog>
# include <QLabel>
# include <QList>
# include <QMdiSubWindow>
# include <QMessageBox>
# include <QSignalMapper>
# include <QTreeWidgetItem>
2024-04-07 15:51:25 +00:00
# include <vtkCellDataToPointData.h>
# include <pcl/io/vtk_lib_io.h>
2024-07-10 10:52:22 +00:00
# include <TopTools_HSequenceOfShape.hxx>
2023-05-09 11:00:22 +00:00
// ribbon
2023-05-08 06:32:41 +00:00
# include "SARibbonBar/SARibbonBar.h"
# include "SARibbonBar/SARibbonCategory.h"
# include "SARibbonBar/SARibbonContextCategory.h"
2023-05-09 11:00:22 +00:00
# include "SARibbonBar/SARibbonPannel.h"
2023-05-08 06:32:41 +00:00
# include "SARibbonBar/SARibbonTabBar.h"
// Post
2023-05-09 11:00:22 +00:00
# include "Common/Types.h"
2023-05-08 06:32:41 +00:00
# include "PostInterface/AnimationToolBar.h"
# include "PostInterface/RenderDirector.h"
2024-04-07 15:51:25 +00:00
// pcl
2024-04-11 08:13:53 +00:00
# include "PluginWBFZExchangePlugin/DialogPCLBilateralFilter.h"
# include "PluginWBFZExchangePlugin/DialogPCLGPMesh.h"
# include "PluginWBFZExchangePlugin/DialogPCLGuassFilter.h"
# include "PluginWBFZExchangePlugin/DialogPCLRadiusOutlierRemoval.h"
# include "PluginWBFZExchangePlugin/DialogPCLStatisticalRemoveFilter.h"
2024-04-07 15:51:25 +00:00
# include "IO/vtkDataRelated.h"
// logger
2024-03-13 05:58:12 +00:00
# include "Common/DebugLogger.h"
2024-07-10 10:52:22 +00:00
# include "PluginWBFZExchangePlugin/OCCTBase.h"
2024-07-23 03:40:54 +00:00
# include "PointCloudOperator/MeshOpearatorCommon.h"
# include "MainWidgets/fekocadTaskinit.h"
2024-03-13 05:58:12 +00:00
2025-01-02 12:20:29 +00:00
# include "MainWindow/dialogpointcloudscane.h"
# include "MainWindow/soilsurface3dmeasurementsystem.h"
2023-05-09 11:00:22 +00:00
namespace GUI {
2024-04-07 15:51:25 +00:00
MainWindow : : MainWindow ( bool useRibbon )
: SARibbonMainWindow ( nullptr , useRibbon )
, _ui ( new Ui : : MainWindowRibbon )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if ( useRibbon ) {
2023-05-08 06:32:41 +00:00
_ui - > setupRibbonUi ( this ) ;
// ribbon customize
// MainWindow的初始化, 生成QAction
2023-05-09 11:00:22 +00:00
// 生成ribbon布局
m_ribbonActionMgr = new SARibbonActionsManager ( static_cast < SARibbonMainWindow * > ( this ) ) ;
2023-05-08 06:32:41 +00:00
m_ribbonActionMgr - > setAllActionCanCustomize ( true ) ; // 设置所有管理的action可编辑
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
_ui - > setupUi ( this ) ;
}
this - > setContextMenuPolicy ( Qt : : NoContextMenu ) ;
2024-03-13 05:58:12 +00:00
QString lang = Setting : : BusAPI : : instance ( ) - > getLanguage ( ) ; // 获取语言
2023-05-08 06:32:41 +00:00
2024-03-13 05:58:12 +00:00
registerMoudel ( ) ; // 控制面版 参数设置面板、 日志输出面板、 进程面版
2023-05-09 11:00:22 +00:00
_signalHandler = new SignalHandler ( this ) ;
_translator = new Translator ( ) ;
2023-05-08 06:32:41 +00:00
_subWindowManager = new SubWindowManager ( this , _ui - > mdiArea , _signalHandler , _controlPanel ) ;
setPostAnimationToolBar ( useRibbon ) ;
connectSignals ( ) ;
// registerMoudel();
_ui - > mdiArea - > setViewMode ( QMdiArea : : TabbedView ) ;
_ui - > mdiArea - > setTabPosition ( QTabWidget : : North ) ;
_ui - > mdiArea - > setTabShape ( QTabWidget : : Rounded ) ;
this - > ChangeLanguage ( lang ) ;
QString workingdir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-09 11:00:22 +00:00
if ( workingdir . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
setWorkingDir ( ) ;
Setting : : BusAPI : : instance ( ) - > setMainWindow ( this ) ;
2023-05-09 11:00:22 +00:00
Setting : : GraphOption * gp = Setting : : BusAPI : : instance ( ) - > getGraphOption ( ) ;
2023-05-08 06:32:41 +00:00
_ui - > actionDisplayPoint - > setChecked ( gp - > isShowGeoPoint ( ) ) ;
_ui - > actionDisplayCurve - > setChecked ( gp - > isShowGeoEdge ( ) ) ;
_ui - > actionDisplayFace - > setChecked ( gp - > isShowGeoSurface ( ) ) ;
this - > setGeometryDisplay ( ) ;
updateRecentMenu ( ) ;
setCurrentFile ( " " ) ;
this - > startSketch ( false ) ;
QString slogo = ConfigOption : : ConfigOption : : getInstance ( ) - > getGlobalConfig ( ) - > getLogo ( ) ;
this - > setIcon ( QApplication : : applicationDirPath ( ) + " /../ConfigFiles/icon/ " + slogo ) ;
_signalHandler - > updateActionsStates ( ) ;
MainWindowPy : : init ( this , _signalHandler ) ;
Gmsh : : GmshModule : : getInstance ( this ) ;
this - > showGraphRange ( 0 , 0 ) ;
2024-03-13 05:58:12 +00:00
Py : : PythonAgent : : getInstance ( ) - > initialize ( this ) ; // 初始界面参数设置
2023-05-08 06:32:41 +00:00
Plugins : : PluginManager : : getInstance ( ) - > loadPlugs ( this ) ;
_customizerHelper = new CustomizerHelper ( this , _ui ) ;
_customizerHelper - > registerInterface ( ) ;
2024-04-02 18:37:27 +00:00
_subWindowManager - > openPreWindow ( ) ; // 前处理窗口展示 -- occt mesh pcl
2023-05-08 06:32:41 +00:00
isLoadRecordScripFile ( ) ;
// ribbon customize
// MainWindow的构造函数最后
2023-05-09 11:00:22 +00:00
if ( useRibbon ) {
2024-04-07 15:51:25 +00:00
const QString strCostomizePath =
QApplication : : applicationDirPath ( ) + " /customization.xml " ;
2023-05-08 06:32:41 +00:00
sa_apply_customize_from_xml_file ( strCostomizePath , this , m_ribbonActionMgr ) ;
}
2024-05-15 02:15:29 +00:00
// 控制菜单,这些功能后期开发仿真算法之后,再开放功能
{
2024-07-02 03:07:44 +00:00
qDebug ( ) < < " V1.2 " ;
2024-05-15 02:15:29 +00:00
_ui - > postEditorTtoolBar - > hide ( ) ;
_ui - > postToolBar - > hide ( ) ;
_ui - > postViewerToolBar - > hide ( ) ;
_postToolBar - > hide ( ) ;
_controlPanel - > setphysicsTab ( false ) ;
_controlPanel - > setpostTab ( false ) ;
_controlPanel - > setplotTab ( false ) ;
2024-07-02 03:07:44 +00:00
qDebug ( ) < < " _controlPaneld has tab : " + QString : : number ( _controlPanel - > getTabCount ( ) ) ;
2024-05-15 02:15:29 +00:00
}
2023-05-08 06:32:41 +00:00
}
MainWindow : : ~ MainWindow ( )
{
Py : : PythonAgent : : getInstance ( ) - > finalize ( ) ;
Plugins : : PluginManager : : getInstance ( ) - > releasePlugs ( ) ;
Gmsh : : GmshModule : : getInstance ( this ) - > finalize ( ) ;
ModuleBase : : ThreadTaskManager : : getInstance ( ) - > clearThreadTaskList ( ) ;
2023-05-09 11:00:22 +00:00
if ( _signalHandler ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _signalHandler ;
2023-05-09 11:00:22 +00:00
if ( _controlPanel ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _controlPanel ;
2023-05-09 11:00:22 +00:00
if ( _messageWindow ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _messageWindow ;
2023-05-09 11:00:22 +00:00
if ( _processWindow ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _processWindow ;
2023-05-09 11:00:22 +00:00
if ( _ui ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _ui ;
_ui = nullptr ;
2023-05-09 11:00:22 +00:00
if ( _translator ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _translator ;
2023-05-09 11:00:22 +00:00
if ( _viewSignalMapper ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _viewSignalMapper ;
2023-05-09 11:00:22 +00:00
if ( _selectSignalMapper ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _selectSignalMapper ;
// if (_displayModeSignalMapper != nullptr) delete _displayModeSignalMapper;
2023-05-09 11:00:22 +00:00
if ( _recentFileMapper ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _recentFileMapper ;
2023-05-09 11:00:22 +00:00
if ( _recentMenu ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _recentMenu ;
2023-05-09 11:00:22 +00:00
if ( _graphRange ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _graphRange ;
2023-05-09 11:00:22 +00:00
if ( _customizerHelper ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _customizerHelper ;
2023-05-09 11:00:22 +00:00
if ( _postToolBar ! = nullptr )
2023-05-08 06:32:41 +00:00
delete _postToolBar ;
// ribbon customize
2023-05-09 11:00:22 +00:00
if ( m_ribbonActionMgr ! = nullptr ) {
2023-05-08 06:32:41 +00:00
delete m_ribbonActionMgr ;
}
}
void MainWindow : : connectSignals ( )
{
connect ( this , SIGNAL ( closeMainWindow ( ) ) , this , SLOT ( closeWindow ( ) ) ) ;
connect ( this , SIGNAL ( sendInfoToStatesBar ( QString ) ) , this , SLOT ( setStatusBarInfo ( QString ) ) ) ;
2023-05-09 11:00:22 +00:00
// connect(this, SIGNAL(importMeshByNamesSig(QString)), this,
2023-07-04 06:33:32 +00:00
// SLOT(importMesh(QString)));
2023-05-09 11:00:22 +00:00
connect ( this , SIGNAL ( importMeshDataSetSig ( vtkDataSet * ) ) , this ,
SLOT ( importMeshDataset ( vtkDataSet * ) ) ) ;
connect ( this , SIGNAL ( printMessageSig ( Common : : Message , QString ) ) , this ,
SLOT ( printMessage ( Common : : Message , QString ) ) ) ;
2023-05-08 06:32:41 +00:00
2024-04-07 15:51:25 +00:00
// 文件
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionNew , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionNew ( ) ) ) ;
connect ( _ui - > actionOpen , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionOpen ( ) ) ) ;
connect ( _ui - > actionSave , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionSave ( ) ) ) ;
connect ( _ui - > actionSaveAs , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionSaveAs ( ) ) ) ;
connect ( _ui - > actionWorkingDir , SIGNAL ( triggered ( ) ) , this , SLOT ( setWorkingDir ( ) ) ) ;
connect ( _ui - > actionImportMesh , SIGNAL ( triggered ( ) ) , this , SLOT ( on_importMesh ( ) ) ) ;
connect ( _ui - > actionExportMesh , SIGNAL ( triggered ( ) ) , this , SLOT ( on_exportMesh ( ) ) ) ;
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionScaneExport , SIGNAL ( triggered ( ) ) , this , SLOT ( on_exportMesh ( ) ) ) ;
2024-04-02 18:37:27 +00:00
connect ( _ui - > actionLoadPointCloud , SIGNAL ( triggered ( ) ) , this , SLOT ( on_importPcl ( ) ) ) ; // 点云
connect ( _ui - > actionSavePointCloud , SIGNAL ( triggered ( ) ) , this , SLOT ( on_exportPcl ( ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionImportGeometry , SIGNAL ( triggered ( ) ) , this , SLOT ( on_importGeometry ( ) ) ) ;
connect ( _ui - > actionExportGeometry , SIGNAL ( triggered ( ) ) , this , SLOT ( on_exportGeometry ( ) ) ) ;
connect ( _ui - > actionClose , SIGNAL ( triggered ( ) ) , this , SLOT ( closeWindow ( ) ) ) ;
connect ( _ui - > actionSolver_Manager , SIGNAL ( triggered ( ) ) , this , SLOT ( on_solverManager ( ) ) ) ;
connect ( _ui - > actionSolve , SIGNAL ( triggered ( ) ) , this , SLOT ( on_solve ( ) ) ) ;
connect ( _ui - > actionSolve_Options , SIGNAL ( triggered ( ) ) , this , SLOT ( on_solveOption ( ) ) ) ;
connect ( _ui - > actionGraph_Options , SIGNAL ( triggered ( ) ) , this , SLOT ( on_graphOption ( ) ) ) ;
connect ( _ui - > actionAbout , SIGNAL ( triggered ( ) ) , this , SLOT ( on_about ( ) ) ) ;
connect ( _ui - > actionUser_Manual , SIGNAL ( triggered ( ) ) , this , SLOT ( on_userManual ( ) ) ) ;
connect ( _ui - > actionCreate_Set , SIGNAL ( triggered ( ) ) , this , SLOT ( on_CreateSet ( ) ) ) ;
2023-05-09 11:00:22 +00:00
connect ( _ui - > actionCreateGeoComponent , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_CreateGeoComponent ( ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionSave_Script , SIGNAL ( triggered ( ) ) , this , SLOT ( on_SaveScript ( ) ) ) ;
connect ( _ui - > actionExecute_Script , SIGNAL ( triggered ( ) ) , this , SLOT ( on_ExecuateScript ( ) ) ) ;
2023-05-09 11:00:22 +00:00
connect ( _ui - > actionPluginManager , SIGNAL ( triggered ( ) ) ,
Plugins : : PluginManager : : getInstance ( ) , SLOT ( manage ( ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionFilterMesh , SIGNAL ( triggered ( ) ) , this , SLOT ( on_FilterMesh ( ) ) ) ;
connect ( _ui - > actionVTKTranslation , SIGNAL ( triggered ( ) ) , this , SLOT ( on_VTKTranslation ( ) ) ) ;
2024-04-07 15:51:25 +00:00
// 点云
2024-07-02 03:07:44 +00:00
connect ( _ui - > actionPCLStatisticalRemoveFilter , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_pclStatisticalRemoveFilter ( ) ) ) ;
connect ( _ui - > actionPCLRadiusOutlierRemoval , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_pclRadiusOutlierRemoval ( ) ) ) ;
connect ( _ui - > actionPCLGuassFilter , SIGNAL ( triggered ( ) ) , this , SLOT ( on_pclGuassFilter ( ) ) ) ;
connect ( _ui - > actionPCLBilateralFilter , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_pclBilateralFilter ( ) ) ) ;
connect ( _ui - > actionPCLGPMesh , SIGNAL ( triggered ( ) ) , this , SLOT ( on_pclGPMesh ( ) ) ) ;
// connect(_ui->actionLoadPointCloudText,SIGNAL(triggered()),this,SLOT(on_actionLoadPointCloudText()));
connect ( _ui - > actionPCLPoissonMesh , SIGNAL ( triggered ( ) ) , this , SLOT ( on_pclPoissonMesh ( ) ) ) ;
2024-04-11 08:13:53 +00:00
// feko 参数
2024-07-02 03:07:44 +00:00
connect ( _ui - > actionImageSetting , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionImageSetting ( ) ) ) ;
connect ( _ui - > actionFEKO2csv , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionFEKO2csv ( ) ) ) ;
connect ( _ui - > actionScatterExport , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionScatterExport ( ) ) ) ;
connect ( _ui - > actionFEKOImage , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionFEKOImage ( ) ) ) ;
connect ( _ui - > actionantScatteringFEKOSetting , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionantScatteringFEKOSetting ( ) ) ) ;
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionFEKOScatterSetting , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionantScatteringFEKOSetting ( ) ) ) ;
connect ( _ui - > actionLoadFEKOScatterResult , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionFEKO2csv ( ) ) ) ;
connect ( _ui - > actionExportRCS , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionScatterExport ( ) ) ) ;
connect ( _ui - > actionFEKOImageSetting , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionImageSetting ( ) ) ) ;
connect ( _ui - > actionLoadFEKOImageResult , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionFEKO2csv ( ) ) ) ;
connect ( _ui - > actionExportFEKOResultToEcho , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionScatterExport ( ) ) ) ;
connect ( _ui - > actionFEKOImageCreate , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionFEKOImage ( ) ) ) ;
2024-07-02 03:07:44 +00:00
// 属性表
connect ( _ui - > actionAttriutionDBShow , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_AttriutionDBShow ( ) ) ) ;
2024-04-07 15:51:25 +00:00
2023-05-09 11:00:22 +00:00
// 设置视角
2023-05-08 06:32:41 +00:00
_viewSignalMapper = new QSignalMapper ( this ) ;
connect ( _ui - > actionFitView , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewXPlus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewXMinus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewYPlus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewYMinus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewZPlus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
connect ( _ui - > actionViewZMinus , SIGNAL ( triggered ( ) ) , _viewSignalMapper , SLOT ( map ( ) ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionFitView , QString ( " fit " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewXPlus , QString ( " XPlus " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewXMinus , QString ( " XMinus " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewYPlus , QString ( " YPlus " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewYMinus , QString ( " YMinus " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewZPlus , QString ( " ZPlus " ) ) ;
_viewSignalMapper - > setMapping ( _ui - > actionViewZMinus , QString ( " ZMinus " ) ) ;
2024-07-23 03:40:54 +00:00
connect ( _viewSignalMapper , SIGNAL ( mapped ( QString ) ) , _subWindowManager ,
SLOT ( setView ( QString ) ) ) ;
2023-05-09 11:00:22 +00:00
// 设置mesh选择模式
2023-05-08 06:32:41 +00:00
_selectSignalMapper = new QSignalMapper ( this ) ;
connect ( _ui - > actionSelectOff , SIGNAL ( triggered ( ) ) , _selectSignalMapper , SLOT ( map ( ) ) ) ;
// connect(_ui->actionSelectGeoBody, SIGNAL(triggered()), _selectSignalMapper, SLOT(map()));
2024-04-07 15:51:25 +00:00
connect ( _ui - > actionSelectMeshNode , SIGNAL ( triggered ( ) ) , _selectSignalMapper ,
SLOT ( map ( ) ) ) ; // 单点
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionSelectMeshCell , SIGNAL ( triggered ( ) ) , _selectSignalMapper , SLOT ( map ( ) ) ) ;
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionBoxMeshNode , SIGNAL ( triggered ( ) ) , _selectSignalMapper ,
SLOT ( map ( ) ) ) ; // 多选
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionBoxMeshCell , SIGNAL ( triggered ( ) ) , _selectSignalMapper , SLOT ( map ( ) ) ) ;
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionBoxMeshSurfaceNode , SIGNAL ( triggered ( ) ) , _selectSignalMapper ,
SLOT ( map ( ) ) ) ; // 多选
connect ( _ui - > actionBoxMeshSurfaceCell , SIGNAL ( triggered ( ) ) , _selectSignalMapper ,
SLOT ( map ( ) ) ) ;
2024-07-07 15:13:48 +00:00
2023-05-08 06:32:41 +00:00
_selectSignalMapper - > setMapping ( _ui - > actionSelectOff , ( int ) ModuleBase : : SelectModel : : None ) ;
2023-05-09 11:00:22 +00:00
//_selectSignalMapper->setMapping(_ui->actionSelectGeoBody,
//(int)ModuleBase::SelectModel::GeometryBody);
2024-04-07 15:51:25 +00:00
2023-05-09 11:00:22 +00:00
_selectSignalMapper - > setMapping ( _ui - > actionSelectMeshNode ,
( int ) ModuleBase : : SelectModel : : MeshNode ) ;
_selectSignalMapper - > setMapping ( _ui - > actionSelectMeshCell ,
( int ) ModuleBase : : SelectModel : : MeshCell ) ;
_selectSignalMapper - > setMapping ( _ui - > actionBoxMeshNode ,
( int ) ModuleBase : : SelectModel : : BoxMeshNode ) ;
_selectSignalMapper - > setMapping ( _ui - > actionBoxMeshCell ,
( int ) ModuleBase : : SelectModel : : BoxMeshCell ) ;
2024-07-07 15:13:48 +00:00
_selectSignalMapper - > setMapping ( _ui - > actionBoxMeshSurfaceNode ,
( int ) ModuleBase : : SelectModel : : BoxMeshSurfaceNode ) ;
_selectSignalMapper - > setMapping ( _ui - > actionBoxMeshSurfaceCell ,
( int ) ModuleBase : : SelectModel : : BoxMeshSurfaceCell ) ;
2024-04-07 15:51:25 +00:00
2024-07-02 03:07:44 +00:00
connect ( _selectSignalMapper , SIGNAL ( mapped ( int ) ) , this ,
SIGNAL ( selectModelChangedSig ( int ) ) ) ; // 选择模式更改信号
connect ( _selectSignalMapper , SIGNAL ( mapped ( int ) ) , this ,
SLOT ( selectModelChanged ( int ) ) ) ; // 选择模型更改为
2023-05-09 11:00:22 +00:00
// 网格显示模式
2023-05-08 06:32:41 +00:00
// _displayModeSignalMapper = new QSignalMapper(this);
connect ( _ui - > actionDisplayNode , SIGNAL ( triggered ( ) ) , this , SLOT ( setMeshDisplay ( ) ) ) ;
2023-07-04 06:33:32 +00:00
connect ( _ui - > actionPreDisplayWireFrame , SIGNAL ( triggered ( ) ) , this , SLOT ( setMeshDisplay ( ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionDisplaySurface , SIGNAL ( triggered ( ) ) , this , SLOT ( setMeshDisplay ( ) ) ) ;
2023-05-09 11:00:22 +00:00
// 几何显示模式(点、线、面)
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionDisplayPoint , SIGNAL ( triggered ( ) ) , this , SLOT ( setGeometryDisplay ( ) ) ) ;
connect ( _ui - > actionDisplayCurve , SIGNAL ( triggered ( ) ) , this , SLOT ( setGeometryDisplay ( ) ) ) ;
connect ( _ui - > actionDisplayFace , SIGNAL ( triggered ( ) ) , this , SLOT ( setGeometryDisplay ( ) ) ) ;
2023-05-09 11:00:22 +00:00
// 设置几何选取模式(点、线、面)
2023-05-08 06:32:41 +00:00
_selectGeometryModeMapper = new QSignalMapper ( this ) ;
connect ( _ui - > actionSelectOff , SIGNAL ( triggered ( ) ) , _selectGeometryModeMapper , SLOT ( map ( ) ) ) ;
2023-05-09 11:00:22 +00:00
connect ( _ui - > actionSelectPoint , SIGNAL ( triggered ( ) ) , _selectGeometryModeMapper ,
SLOT ( map ( ) ) ) ;
connect ( _ui - > actionSelectCurve , SIGNAL ( triggered ( ) ) , _selectGeometryModeMapper ,
SLOT ( map ( ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( _ui - > actionSelectFace , SIGNAL ( triggered ( ) ) , _selectGeometryModeMapper , SLOT ( map ( ) ) ) ;
2023-05-09 11:00:22 +00:00
connect ( _ui - > actionSelectGeometryBody , SIGNAL ( triggered ( ) ) , _selectGeometryModeMapper ,
SLOT ( map ( ) ) ) ;
2024-07-07 15:13:48 +00:00
2023-05-09 11:00:22 +00:00
_selectGeometryModeMapper - > setMapping ( _ui - > actionSelectOff ,
( int ) ModuleBase : : SelectModel : : None ) ;
_selectGeometryModeMapper - > setMapping ( _ui - > actionSelectPoint ,
( int ) ModuleBase : : SelectModel : : GeometryWinPoint ) ;
_selectGeometryModeMapper - > setMapping ( _ui - > actionSelectCurve ,
( int ) ModuleBase : : SelectModel : : GeometryWinCurve ) ;
_selectGeometryModeMapper - > setMapping ( _ui - > actionSelectFace ,
( int ) ModuleBase : : SelectModel : : GeometryWinSurface ) ;
_selectGeometryModeMapper - > setMapping ( _ui - > actionSelectGeometryBody ,
( int ) ModuleBase : : SelectModel : : GeometryWinBody ) ;
connect ( _selectGeometryModeMapper , SIGNAL ( mapped ( int ) ) , this ,
SLOT ( selectGeometryModelChanged ( int ) ) ) ;
connect ( _selectGeometryModeMapper , SIGNAL ( mapped ( int ) ) , this ,
SIGNAL ( selectModelChangedSig ( int ) ) ) ;
connect ( _ui - > actionPre_Window , SIGNAL ( triggered ( ) ) , _subWindowManager ,
SLOT ( openPreWindow ( ) ) ) ;
connect ( this , SIGNAL ( importGeometrySig ( QStringList ) ) , this ,
SLOT ( importGeometry ( QStringList ) ) ) ;
2023-05-08 06:32:41 +00:00
connect ( this , SIGNAL ( exportGeometrySig ( QString ) ) , this , SLOT ( exportGeometry ( QString ) ) ) ;
connect ( _ui - > actionCreate_Sketch , SIGNAL ( triggered ( ) ) , this , SLOT ( on_sketchClicked ( ) ) ) ;
2023-05-09 11:00:22 +00:00
connect ( this , SIGNAL ( showGraphRangeSig ( double , double ) ) , this ,
SLOT ( showGraphRange ( double , double ) ) ) ;
connect ( this , SIGNAL ( startSketchSig ( bool , double * , double * ) ) , this ,
SLOT ( startSketch ( bool ) ) ) ;
2023-05-08 06:32:41 +00:00
// connect(this, SIGNAL(updateActionsStatesSig()), this, SLOT(updateActionsStates()));
connect ( this , SIGNAL ( updatePreMeshActorSig ( ) ) , this , SLOT ( updatePreMeshActor ( ) ) ) ;
connect ( this , SIGNAL ( updatePreGeometryActorSig ( ) ) , this , SLOT ( updatePreGeometryActor ( ) ) ) ;
2023-07-04 06:33:32 +00:00
connect ( this , SIGNAL ( openPlot ( ) ) , _signalHandler , SLOT ( openPlotFile ( ) ) ) ;
2024-04-07 15:51:25 +00:00
// 点云模块
2024-07-02 03:07:44 +00:00
connect ( this , SIGNAL ( importMeshSIGN ( QString , QString , int ) ) , this ,
SLOT ( importMesh ( QString , QString , int ) ) ) ;
2024-05-15 02:15:29 +00:00
// 导入点云
2024-07-02 03:07:44 +00:00
connect ( this , SIGNAL ( importPclSIGN ( QString , QString , int ) ) , this ,
SLOT ( importPcl ( QString , QString , int ) ) ) ;
2024-05-15 02:15:29 +00:00
// 绑定 vtk 中世界坐标系
2024-07-02 03:07:44 +00:00
connect ( this , SIGNAL ( showStateToolbarPositionSIGNGAL ( double , double , double ) ) , this ,
SLOT ( showStateToolbarPosition ( double , double , double ) ) ) ;
2024-05-28 00:53:55 +00:00
// 采样相关事件
2024-07-02 03:07:44 +00:00
connect ( _ui - > actionvtkPointSamplor , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionvtkPointSamplor ( ) ) ) ;
2024-05-28 00:53:55 +00:00
2024-07-02 03:07:44 +00:00
connect ( _ui - > actionImageShowTool , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionImageShowTool ( ) ) ) ;
connect ( _ui - > actionRCShowTool , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionRCShowTool ( ) ) ) ;
2024-07-02 09:22:29 +00:00
// 加载预制模型
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionLoadPreForestMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreForestMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreCropMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreCropMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreGrasslandMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreGrasslandMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreWaterBodyMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreWaterBodyMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreSoilMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreSoilMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreDynamicWaterBodyMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreDynamicWaterBodyMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreRoadMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreRoadMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadPreArtificialMeshFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadPreArtificialMeshFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadForestPointCloudFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadForestPointCloudFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadRhounessPointCloudFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadRhounessPointCloudFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadGeometricCorrectionFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadGeometricCorrectionFile_triggereds ( ) ) ) ;
connect ( _ui - > actionLoadRadioModelFile , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionLoadRadioModelFile_triggereds ( ) ) ) ;
2025-01-02 12:20:29 +00:00
connect ( _ui - > actionAddTree , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionAddTree_triggereds ( ) ) ) ;
2024-07-02 09:22:29 +00:00
2024-07-09 02:15:46 +00:00
// 网格操作
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionMeshDelete , SIGNAL ( triggered ( ) ) , this , SLOT ( on_deleteMesh ( ) ) ) ;
connect ( _ui - > actionMeshCopy , SIGNAL ( triggered ( ) ) , this , SLOT ( on_copyMesh ( ) ) ) ;
connect ( _ui - > actionMeshClip , SIGNAL ( triggered ( ) ) , this , SLOT ( on_clipMesh ( ) ) ) ;
connect ( _ui - > actionMeshSave , SIGNAL ( triggered ( ) ) , this , SLOT ( on_saveMeshEdit ( ) ) ) ;
2024-07-09 02:15:46 +00:00
// 网格三角网
2024-07-23 03:40:54 +00:00
connect ( _ui - > actionMeshTriangleSurface , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionMeshTriangleSurface ( ) ) ) ;
2024-07-02 09:22:29 +00:00
2024-07-10 10:52:22 +00:00
// 网格转换为几何
2024-07-23 03:40:54 +00:00
connect ( _controlPanel , SIGNAL ( MeshToGeometrySig ( MeshData : : MeshKernal * ) ) , this ,
SLOT ( on_MeshToGeo ( MeshData : : MeshKernal * ) ) ) ;
2024-07-10 10:52:22 +00:00
// 网格
2024-07-23 03:40:54 +00:00
connect ( _ui - > action_generatorWaterPlane , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_action_generatorWaterPlane ( ) ) ) ;
// connect(_ui->actionMeshToOCCT,SIGNAL(triggered()),this,SLOT(on_actionMeshToOCCT()));
connect ( _ui - > actionBatchStartFEKOCADModel , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionBatchStartFEKOCADModel ( ) ) ) ;
connect ( _ui - > actionCreateLoadModelScript , SIGNAL ( triggered ( ) ) , this ,
SLOT ( on_actionCreateLoadModelScript ( ) ) ) ;
2025-01-02 12:20:29 +00:00
connect ( _ui - > actionCreateCADModel , SIGNAL ( triggered ( ) ) , this ,
2024-07-23 03:40:54 +00:00
SLOT ( on_actionCreateCADModel ( ) ) ) ;
2025-01-02 12:20:29 +00:00
connect ( _ui - > actionEditSelectDialog , SIGNAL ( triggered ( ) ) , this ,
2024-07-31 06:32:53 +00:00
SLOT ( on_actionEditSelectDialog ( ) ) ) ;
2025-01-02 12:20:29 +00:00
connect ( _ui - > action_ForestSance , SIGNAL ( triggered ( ) ) , this , SLOT ( on_action_ForestSance ( ) ) ) ;
2024-07-31 06:32:53 +00:00
2025-01-02 12:20:29 +00:00
connect ( _ui - > action_soilSurfaceScane , SIGNAL ( triggered ( ) ) , this , SLOT ( on_action_soilSurfaceScane ( ) ) ) ;
2025-01-13 02:55:05 +00:00
// 绑定散射实验数据加载
connect ( _ui - > action_LoadLaboratoryScatterResult , SIGNAL ( triggered ( ) ) , this , SLOT ( on_actionLoadLaboratoryScatterResult_triggereds ( ) ) ) ;
2023-05-08 06:32:41 +00:00
}
void MainWindow : : registerMoudel ( )
{
2024-04-02 18:37:27 +00:00
/// 添加ProjectWindow 为controlpanel 提供窗口绑定
2023-05-08 06:32:41 +00:00
_controlPanel = new MainWidget : : ControlPanel ( this ) ;
_controlPanel - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
addDockWidget ( Qt : : LeftDockWidgetArea , _controlPanel ) ;
this - > setCorner ( Qt : : Corner : : BottomLeftCorner , Qt : : LeftDockWidgetArea ) ;
2023-05-09 11:00:22 +00:00
/// 添加MessageWindow
2023-05-08 06:32:41 +00:00
_messageWindow = new MainWidget : : MessageWindow ( this ) ;
_messageWindow - > setAllowedAreas ( Qt : : BottomDockWidgetArea | Qt : : TopDockWidgetArea ) ;
addDockWidget ( Qt : : BottomDockWidgetArea , _messageWindow ) ;
2023-05-09 11:00:22 +00:00
/// 添加ProcessWindow
2023-05-08 06:32:41 +00:00
_processWindow = new MainWidget : : ProcessWindow ( this ) ;
_processWindow - > setAllowedAreas ( Qt : : BottomDockWidgetArea | Qt : : TopDockWidgetArea ) ;
addDockWidget ( Qt : : BottomDockWidgetArea , _processWindow ) ;
}
2023-05-09 11:00:22 +00:00
Ui : : MainWindowRibbon * MainWindow : : getUi ( )
2023-05-08 06:32:41 +00:00
{
return _ui ;
}
2023-05-09 11:00:22 +00:00
Translator * MainWindow : : GetTranslator ( )
2023-05-08 06:32:41 +00:00
{
return _translator ;
}
void MainWindow : : setStatusBarInfo ( QString info )
{
_ui - > statusbar - > showMessage ( info , 10000 ) ;
}
2023-05-09 11:00:22 +00:00
void MainWindow : : setMD5 ( const QString & md5 )
2023-05-08 06:32:41 +00:00
{
_MD5 = md5 ;
}
2023-05-09 11:00:22 +00:00
void MainWindow : : setCurrentFile ( const QString & file )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if ( ! file . isEmpty ( ) ) {
2023-05-08 06:32:41 +00:00
QFileInfo F ( file ) ;
2023-05-09 11:00:22 +00:00
if ( ! F . exists ( ) )
2023-05-08 06:32:41 +00:00
return ;
_currentFile = F . absoluteFilePath ( ) ;
}
2023-05-09 11:00:22 +00:00
QString lang = Setting : : BusAPI : : instance ( ) - > getLanguage ( ) ;
QString title ;
2024-04-07 15:51:25 +00:00
ConfigOption : : GlobalConfig * g =
ConfigOption : : ConfigOption : : getInstance ( ) - > getGlobalConfig ( ) ;
2023-05-08 06:32:41 +00:00
title = g - > getSoftName ( ) ;
2023-05-09 11:00:22 +00:00
if ( lang . toLower ( ) = = " chinese " )
2023-05-08 06:32:41 +00:00
title = g - > getChineseName ( ) ;
2023-05-09 11:00:22 +00:00
if ( title . isEmpty ( ) )
2024-03-13 05:58:12 +00:00
title = u8 " MicrowaveMeasurementSimulationSubSystemCAE " ;
2023-05-09 11:00:22 +00:00
if ( ! _currentFile . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
title = QString ( " %1-[%2] " ) . arg ( title ) . arg ( _currentFile ) ;
this - > setWindowTitle ( title ) ;
2024-03-13 05:58:12 +00:00
DebugInfo ( " setCurrentFile TitleName: %s \n " , title . toStdU16String ( ) . c_str ( ) ) ;
2023-05-08 06:32:41 +00:00
}
void MainWindow : : updatePreMeshActor ( )
{
_subWindowManager - > updatePreMeshActor ( ) ;
}
void MainWindow : : updatePreGeometryActor ( )
{
_subWindowManager - > updatePreGeometryActor ( ) ;
}
2023-05-09 11:00:22 +00:00
void MainWindow : : closeEvent ( QCloseEvent * event )
2023-05-08 06:32:41 +00:00
{
QString md5 = _signalHandler - > getMD5 ( ) ;
2023-05-09 11:00:22 +00:00
if ( md5 ! = _MD5 ) {
int nRet =
QMessageBox : : warning ( this , tr ( " Save " ) , tr ( " Do you want to save before exit ? " ) ,
tr ( " Yes " ) , tr ( " No " ) , tr ( " Cancel " ) ) ;
switch ( nRet ) {
case 2 :
event - > ignore ( ) ;
return ;
case 0 :
this - > on_actionSave ( ) ;
case 1 :
// clean data
default :
break ;
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
if ( nullptr ! = event )
2023-05-08 06:32:41 +00:00
event - > accept ( ) ;
}
// if (!_designModel)
_subWindowManager - > closeAllSubWindow ( ) ;
Setting : : BusAPI : : instance ( ) - > writeINI ( ) ;
}
void MainWindow : : closeWindow ( )
{
close ( ) ;
}
void MainWindow : : ChangeLanguage ( QString lang )
{
Setting : : BusAPI : : instance ( ) - > setLanguage ( lang ) ;
2023-05-09 11:00:22 +00:00
if ( nullptr = = _ui )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
if ( lang = = " English " ) {
2023-05-08 06:32:41 +00:00
_ui - > actionChinese - > setChecked ( false ) ;
_ui - > actionEnglish - > setChecked ( true ) ;
_translator - > toEnglish ( ) ;
2023-05-09 11:00:22 +00:00
} else if ( lang = = " Chinese " ) {
2023-05-08 06:32:41 +00:00
_ui - > actionChinese - > setChecked ( true ) ;
_ui - > actionEnglish - > setChecked ( false ) ;
_translator - > toChinese ( ) ;
}
Plugins : : PluginManager : : getInstance ( ) - > reTranslate ( lang ) ;
2023-05-09 11:00:22 +00:00
if ( isUseRibbon ( ) )
2023-05-08 06:32:41 +00:00
_ui - > retranslateRibbonUi ( this ) ;
else
_ui - > retranslateUi ( this ) ;
2023-05-09 11:00:22 +00:00
if ( _recentMenu ! = nullptr )
2023-05-08 06:32:41 +00:00
_recentMenu - > setTitle ( tr ( " Recent " ) ) ;
_controlPanel - > reTranslate ( ) ;
_messageWindow - > reTranslate ( ) ;
_subWindowManager - > reTranslate ( ) ;
2023-05-09 11:00:22 +00:00
if ( _processWindow ! = nullptr )
2023-05-08 06:32:41 +00:00
_processWindow - > reTranslate ( ) ;
2024-04-07 15:51:25 +00:00
ConfigOption : : GlobalConfig * g =
ConfigOption : : ConfigOption : : getInstance ( ) - > getGlobalConfig ( ) ;
2024-03-20 07:33:49 +00:00
QString title = " MicrowaveMeasurementSimulationSubSystemCAE " ; // 修改 标识 LAMPCAE
2023-05-09 11:00:22 +00:00
if ( lang . toLower ( ) = = " chinese " ) {
2023-05-08 06:32:41 +00:00
QString f = g - > getChineseName ( ) ;
2023-05-09 11:00:22 +00:00
if ( ! f . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
title = f ;
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
QString f = g - > getSoftName ( ) ;
2023-05-09 11:00:22 +00:00
if ( ! f . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
title = f ;
}
2023-05-09 11:00:22 +00:00
if ( ! _currentFile . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
title = QString ( " %1-[%2] " ) . arg ( title ) . arg ( _currentFile ) ;
this - > setWindowTitle ( title ) ;
}
void MainWindow : : on_actionNew ( )
{
// if (!_designModel)
_signalHandler - > on_actionNew ( ) ;
// emit updateActionStatesSig();
}
void MainWindow : : on_actionOpen ( )
{
/* emit sig_action_open();*/
QString md5 = _signalHandler - > getMD5 ( ) ;
2023-05-09 11:00:22 +00:00
if ( md5 ! = _MD5 ) {
2023-05-08 06:32:41 +00:00
QMessageBox : : StandardButton but ;
2023-05-09 11:00:22 +00:00
but =
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " Do you want to save current data ? " ) ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( but = = QMessageBox : : Yes )
2023-05-08 06:32:41 +00:00
on_actionSave ( ) ;
}
// _signalHandler->clearData();
2023-05-09 11:00:22 +00:00
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
QString fillter = tr ( " Project file(*.diso);;Project file(*.xml) " ) ;
# ifdef Q_OS_LINUX
fillter = tr ( " DISO file(*.diso);;XML file(*.xml) " ) ;
# endif
2023-05-09 11:00:22 +00:00
QString title = tr ( " Open a project " ) ;
2023-05-08 06:32:41 +00:00
QString filePath = QFileDialog : : getOpenFileName ( this , title , dir , fillter ) ;
2023-05-09 11:00:22 +00:00
if ( filePath . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
// _signalHandler->clearData();
// _signalHandler->openProjectFile(filePath);
QString pycode = QString ( " MainWindow.openProjectFile( \" %1 \" ) " ) . arg ( filePath ) ;
qDebug ( ) < < pycode ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pycode ) ;
}
void MainWindow : : on_actionSave ( )
{
2023-05-09 11:00:22 +00:00
if ( ! _currentFile . isEmpty ( ) ) {
2023-05-08 06:32:41 +00:00
QString pycode = QString ( " MainWindow.saveProjectFile( \" %1 \" ) " ) . arg ( _currentFile ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pycode ) ;
2023-05-09 11:00:22 +00:00
} else
2023-05-08 06:32:41 +00:00
on_actionSaveAs ( ) ;
}
void MainWindow : : on_actionSaveAs ( )
{
QString fillter = tr ( " Project file(*.diso);;Project file(*.xml) " ) ;
# ifdef Q_OS_LINUX
fillter = tr ( " DISO file(*.diso);;XML file(*.xml) " ) ;
# endif
2023-05-09 11:00:22 +00:00
QString title = tr ( " Save project " ) ;
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
// QString filePath = QFileDialog::getSaveFileName(this, title, dir, fillter);
QFileDialog dlg ( this , title , dir , fillter ) ;
dlg . setAcceptMode ( QFileDialog : : AcceptSave ) ;
2023-05-09 11:00:22 +00:00
if ( QDialog : : Accepted ! = dlg . exec ( ) )
2023-05-08 06:32:41 +00:00
return ;
QString filePath = dlg . selectedFiles ( ) . at ( 0 ) ;
2023-05-09 11:00:22 +00:00
if ( filePath . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
# ifdef Q_OS_LINUX
bool isproj = filePath . toLower ( ) . endsWith ( " .diso " ) | | filePath . toLower ( ) . endsWith ( " .xml " ) ;
2023-05-09 11:00:22 +00:00
if ( ! isproj ) {
2023-05-08 06:32:41 +00:00
QString suffix = dlg . selectedNameFilter ( ) ;
2023-05-09 11:00:22 +00:00
if ( suffix . contains ( " diso " ) )
2023-05-08 06:32:41 +00:00
suffix = " diso " ;
2023-05-09 11:00:22 +00:00
else if ( suffix . contains ( " xml " ) )
2023-05-08 06:32:41 +00:00
suffix = " xml " ;
filePath = filePath + " . " + suffix ;
}
# endif
bool empty = Geometry : : GeometryData : : getInstance ( ) - > isEmpty ( ) ;
2023-05-09 11:00:22 +00:00
if ( filePath . right ( 3 ) . toLower ( ) = = " xml " & & ! empty ) {
QMessageBox : : StandardButton bt = QMessageBox : : warning (
this , tr ( " Warning " ) , tr ( " Geometry will be lost! still continue? " ) ,
QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : Yes ) ;
if ( bt = = QMessageBox : : No )
2023-05-08 06:32:41 +00:00
return ;
}
2023-05-09 11:00:22 +00:00
if ( ! filePath . isEmpty ( ) ) {
2023-05-08 06:32:41 +00:00
QString pycode = QString ( " MainWindow.saveProjectFile( \" %1 \" ) " ) . arg ( filePath ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pycode ) ;
}
}
2024-07-02 03:07:44 +00:00
void MainWindow : : importMesh ( QString fileName , QString aSuffix , int modelID )
{
2024-05-13 01:12:04 +00:00
if ( fileName . isEmpty ( ) )
return ;
QString pyCode = QString ( " MainWindow.importMesh( \" %1 \" , \" %2 \" ,%3) " )
. arg ( fileName )
. arg ( aSuffix )
. arg ( modelID ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : importPcl ( QString fileName , QString aSuffix , int modelID )
{
2024-05-13 01:12:04 +00:00
if ( fileName . isEmpty ( ) )
return ;
QString pyCode = QString ( " MainWindow.importPcl( \" %1 \" , \" %2 \" ,%3) " )
. arg ( fileName )
. arg ( aSuffix )
. arg ( modelID ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2023-05-08 06:32:41 +00:00
void MainWindow : : on_importMesh ( )
{
QStringList suffixlist = IO : : IOConfigure : : getMeshImporters ( ) ;
// QStringList list = IO::IOConfigure::getMeshImporters();
2023-05-09 11:00:22 +00:00
if ( suffixlist . isEmpty ( ) ) {
2023-05-08 06:32:41 +00:00
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " The MeshPlugin is not installed ! " ) ) ;
return ;
}
2024-07-23 03:40:54 +00:00
QStringList meshsuffix = ConfigOption : : ConfigOption : : getInstance ( )
- > getMeshConfig ( )
- > getImportSuffix ( ConfigOption : : MeshDataType : : vtkMesh )
. split ( " ; " ) ;
2023-05-08 06:32:41 +00:00
QStringList list ;
2023-05-09 11:00:22 +00:00
for ( QString s : meshsuffix ) {
for ( int i = 0 ; i < suffixlist . size ( ) ; i + + ) {
2023-05-08 06:32:41 +00:00
QString suffix = suffixlist . at ( i ) ;
2024-07-23 03:40:54 +00:00
if ( suffix . contains ( s ) ) {
2023-05-08 06:32:41 +00:00
list . append ( suffix ) ;
2024-07-23 03:40:54 +00:00
}
2023-05-08 06:32:41 +00:00
}
}
std : : sort ( list . begin ( ) , list . end ( ) ) ;
2024-07-23 03:40:54 +00:00
// DebugInfo("import mesh data file format : %s \n ",
// list.join(";;").toUtf8().constData());
2023-05-09 11:00:22 +00:00
QString suffixes = list . join ( " ;; " ) ;
2023-05-08 06:32:41 +00:00
QString senderName = sender ( ) - > objectName ( ) ;
2023-05-09 11:00:22 +00:00
int modelID = - 1 ;
if ( senderName . contains ( " Only INP_ " ) ) {
2023-05-08 06:32:41 +00:00
suffixes = list . at ( 0 ) ;
2023-05-09 11:00:22 +00:00
modelID = senderName . right ( 1 ) . toInt ( ) ;
2023-05-08 06:32:41 +00:00
}
2024-07-23 03:40:54 +00:00
// DebugInfo("import mesh data file format : %s \n ", suffixes.toUtf8().constData());
2023-05-09 11:00:22 +00:00
QString workDir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
QFileDialog dlg ( this , tr ( " Import Mesh " ) , workDir , suffixes ) ;
dlg . setAcceptMode ( QFileDialog : : AcceptOpen ) ;
dlg . setFileMode ( QFileDialog : : ExistingFile ) ;
2023-05-09 11:00:22 +00:00
if ( dlg . exec ( ) ! = QFileDialog : : Accepted )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
QString aSuffix = dlg . selectedNameFilter ( ) ;
2023-05-08 06:32:41 +00:00
QString fileName = dlg . selectedFiles ( ) . join ( " , " ) ;
2023-05-09 11:00:22 +00:00
if ( fileName . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
QString pyCode = QString ( " MainWindow.importMesh( \" %1 \" , \" %2 \" ,%3) " )
. arg ( fileName )
. arg ( aSuffix )
. arg ( modelID ) ;
2023-05-08 06:32:41 +00:00
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2024-04-02 18:37:27 +00:00
void MainWindow : : on_importPcl ( )
{
QStringList suffixlist = IO : : IOConfigure : : getPclImporters ( ) ;
2024-04-07 15:51:25 +00:00
DebugInfo ( " import point cloud data file format : %s \n " ,
suffixlist . join ( " ; " ) . toUtf8 ( ) . constData ( ) ) ;
2024-04-02 18:37:27 +00:00
// QStringList list = IO::IOConfigure::getMeshImporters();
if ( suffixlist . isEmpty ( ) ) {
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " The MeshPlugin is not installed ! " ) ) ;
return ;
}
2024-04-07 15:51:25 +00:00
QStringList pclsuffix = ConfigOption : : ConfigOption : : getInstance ( )
- > getMeshConfig ( )
- > getImportSuffix ( ConfigOption : : MeshDataType : : PointCloud )
. split ( " ; " ) ;
2024-04-02 18:37:27 +00:00
QStringList list ;
for ( QString s : pclsuffix ) {
for ( int i = 0 ; i < suffixlist . size ( ) ; i + + ) {
QString suffix = suffixlist . at ( i ) ;
if ( suffix . contains ( s ) )
list . append ( suffix ) ;
}
}
std : : sort ( list . begin ( ) , list . end ( ) ) ;
QString suffixes = list . join ( " ;; " ) ;
QString senderName = sender ( ) - > objectName ( ) ;
int modelID = - 1 ;
if ( senderName . contains ( " Only INP_ " ) ) {
suffixes = list . at ( 0 ) ;
modelID = senderName . right ( 1 ) . toInt ( ) ;
}
QString workDir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
QFileDialog dlg ( this , tr ( " Import Point Cloud " ) , workDir , suffixes ) ;
dlg . setAcceptMode ( QFileDialog : : AcceptOpen ) ;
dlg . setFileMode ( QFileDialog : : ExistingFile ) ;
if ( dlg . exec ( ) ! = QFileDialog : : Accepted )
return ;
QString aSuffix = dlg . selectedNameFilter ( ) ;
QString fileName = dlg . selectedFiles ( ) . join ( " , " ) ;
if ( fileName . isEmpty ( ) )
return ;
QString pyCode = QString ( " MainWindow.importPcl( \" %1 \" , \" %2 \" ,%3) " )
2024-04-07 15:51:25 +00:00
. arg ( fileName )
. arg ( aSuffix )
. arg ( modelID ) ;
2024-04-02 18:37:27 +00:00
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2023-05-08 06:32:41 +00:00
void MainWindow : : on_exportGeometry ( )
{
2023-05-09 11:00:22 +00:00
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
ConfigOption : : GeometryConfig * geoconfig =
ConfigOption : : ConfigOption : : getInstance ( ) - > getGeometryConfig ( ) ;
QString conSuffix = geoconfig - > getExportSuffix ( ) . toLower ( ) ;
QStringList sl = conSuffix . split ( " ; " ) ;
2023-05-08 06:32:41 +00:00
conSuffix . clear ( ) ;
2023-05-09 11:00:22 +00:00
for ( QString s : sl ) {
2023-05-08 06:32:41 +00:00
conSuffix + = " *. " + s ;
}
conSuffix = QString ( " Geometry Files(%1) " ) . arg ( conSuffix ) ;
QString regSuffix { } ;
2023-05-09 11:00:22 +00:00
QString title = tr ( " Export Geometry " ) ;
QString filename = QFileDialog : : getSaveFileName (
this , title , dir , conSuffix + regSuffix /* + ";;All Files(*.*)"*/ ) ;
if ( filename . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
QString pycode = QString ( " MainWindow.exportGeometry( \" %1 \" ) " ) . arg ( filename ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pycode ) ;
}
void MainWindow : : on_exportMesh ( )
{
2024-07-23 03:40:54 +00:00
// 根据用户的选择做出响应
if ( QMessageBox : : question ( nullptr , " info " , u8 " 是否保存网格模型修改? " ,
QMessageBox : : Yes | QMessageBox : : No )
= = QMessageBox : : Yes ) {
this - > on_saveMeshEdit ( ) ;
// 执行相关操作
} else {
// this->on_saveMeshEdit();
}
2024-04-11 08:13:53 +00:00
if ( MeshData : : MeshData : : getInstance ( ) - > getKernalCount ( ) = = 0 ) {
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " No one has any grid! " ) ) ;
return ;
}
2023-05-08 06:32:41 +00:00
QStringList suffixlist = IO : : IOConfigure : : getMeshExporters ( ) ;
// QStringList list = IO::IOConfigure::getMeshImporters();
2023-05-09 11:00:22 +00:00
if ( suffixlist . isEmpty ( ) ) {
2023-05-08 06:32:41 +00:00
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " The MeshPlugin is not installed ! " ) ) ;
return ;
}
2023-05-09 11:00:22 +00:00
QStringList meshsuffix =
ConfigOption : : ConfigOption : : getInstance ( ) - > getMeshConfig ( ) - > getExportSuffix ( ) . split (
" ; " ) ;
2023-05-08 06:32:41 +00:00
QStringList list ;
2023-05-09 11:00:22 +00:00
for ( QString s : meshsuffix ) {
for ( int i = 0 ; i < suffixlist . size ( ) ; i + + ) {
2023-05-08 06:32:41 +00:00
QString suffix = suffixlist . at ( i ) ;
2023-05-09 11:00:22 +00:00
if ( suffix . contains ( s ) )
2023-05-08 06:32:41 +00:00
list . append ( suffix ) ;
}
}
std : : sort ( list . begin ( ) , list . end ( ) ) ;
2023-05-09 11:00:22 +00:00
QString suffixes = list . join ( " ;; " ) ;
2023-05-08 06:32:41 +00:00
QString senderName = sender ( ) - > objectName ( ) ;
2023-05-09 11:00:22 +00:00
int modelID = - 1 ;
if ( senderName . contains ( " Only INP_ " ) ) {
2023-05-08 06:32:41 +00:00
suffixes = list . at ( 0 ) ;
2023-05-09 11:00:22 +00:00
modelID = senderName . right ( 1 ) . toInt ( ) ;
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
QString workDir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
QFileDialog dlg ( this , tr ( " Export Mesh " ) , workDir , suffixes ) ;
dlg . setAcceptMode ( QFileDialog : : AcceptSave ) ;
2023-05-09 11:00:22 +00:00
if ( dlg . exec ( ) ! = QFileDialog : : FileName )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
QString aSuffix = dlg . selectedNameFilter ( ) ;
2023-05-08 06:32:41 +00:00
QString aFileName = dlg . selectedFiles ( ) . join ( " , " ) ;
2023-05-09 11:00:22 +00:00
if ( aFileName . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
2024-07-23 03:40:54 +00:00
2023-05-09 11:00:22 +00:00
QString pyCode = QString ( " MainWindow.exportMesh( \" %1 \" , \" %2 \" ,%3) " )
. arg ( aFileName )
. arg ( aSuffix )
. arg ( modelID ) ;
2023-05-08 06:32:41 +00:00
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2024-04-07 15:51:25 +00:00
void MainWindow : : on_exportPcl ( )
{
2024-04-02 18:37:27 +00:00
QStringList suffixlist = IO : : IOConfigure : : getPclExporters ( ) ;
if ( suffixlist . isEmpty ( ) ) {
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " The MeshPlugin is not installed ! " ) ) ;
return ;
}
if ( MeshData : : MeshData : : getInstance ( ) - > getKernalCount ( ) = = 0 ) {
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " No one has any grid! " ) ) ;
return ;
}
2024-04-07 15:51:25 +00:00
QStringList meshsuffix = ConfigOption : : ConfigOption : : getInstance ( )
- > getMeshConfig ( )
- > getExportSuffix ( ConfigOption : : MeshDataType : : PointCloud )
. split ( " ; " ) ;
2024-04-02 18:37:27 +00:00
QStringList list ;
for ( QString s : meshsuffix ) {
for ( int i = 0 ; i < suffixlist . size ( ) ; i + + ) {
QString suffix = suffixlist . at ( i ) ;
if ( suffix . contains ( s ) )
list . append ( suffix ) ;
}
}
std : : sort ( list . begin ( ) , list . end ( ) ) ;
QString suffixes = list . join ( " ;; " ) ;
QString senderName = sender ( ) - > objectName ( ) ;
int modelID = - 1 ;
if ( senderName . contains ( " Only INP_ " ) ) {
suffixes = list . at ( 0 ) ;
modelID = senderName . right ( 1 ) . toInt ( ) ;
}
QString workDir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
QFileDialog dlg ( this , tr ( " Export Pcl " ) , workDir , suffixes ) ;
dlg . setAcceptMode ( QFileDialog : : AcceptSave ) ;
if ( dlg . exec ( ) ! = QFileDialog : : FileName )
return ;
QString aSuffix = dlg . selectedNameFilter ( ) ;
QString aFileName = dlg . selectedFiles ( ) . join ( " , " ) ;
if ( aFileName . isEmpty ( ) )
return ;
QString pyCode = QString ( " MainWindow.exportPcl( \" %1 \" , \" %2 \" ,%3) " )
. arg ( aFileName )
. arg ( aSuffix )
. arg ( modelID ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCode ) ;
}
2023-05-08 06:32:41 +00:00
// void MainWindow::importMesh(QString fileName ,QString suffix, int modelId)
// {
// _signalHandler->importMesh(fileName, suffix, modelId);
// }
2023-05-09 11:00:22 +00:00
void MainWindow : : importMeshDataset ( vtkDataSet * dataset )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if ( dataset = = nullptr )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
MeshData : : MeshKernal * k = new MeshData : : MeshKernal ;
2023-05-08 06:32:41 +00:00
k - > setMeshData ( dataset ) ;
MeshData : : MeshData : : getInstance ( ) - > appendMeshKernal ( k ) ;
_subWindowManager - > openPreWindow ( ) ;
// _subWindowManager->updatePreMeshActor();
emit updateMeshTreeSig ( ) ;
emit updateActionStatesSig ( ) ;
}
void MainWindow : : on_importGeometry ( )
{
2023-05-09 11:00:22 +00:00
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
ConfigOption : : GeometryConfig * geoconfig =
ConfigOption : : ConfigOption : : getInstance ( ) - > getGeometryConfig ( ) ;
QString conSuffix = geoconfig - > getImportSuffix ( ) . toLower ( ) ;
QStringList sl = conSuffix . split ( " ; " ) ;
2023-05-08 06:32:41 +00:00
conSuffix . clear ( ) ;
2023-05-09 11:00:22 +00:00
for ( QString s : sl ) {
2023-05-08 06:32:41 +00:00
conSuffix + = " *. " + s ;
}
conSuffix = QString ( " Geometry Files(%1) " ) . arg ( conSuffix ) ;
2023-05-09 11:00:22 +00:00
QString regSuffix { } ;
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
QString title = tr ( " Import Geometry " ) ;
QStringList filenames = QFileDialog : : getOpenFileNames (
this , title , dir , conSuffix + regSuffix /*+ ";;All Files(*.*)"*/ ) ;
if ( filenames . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
/*
QString files = filenames . join ( " , " ) ;
2023-05-09 11:00:22 +00:00
QString pycode =
QString ( " MainWindow.importGeometry( \" %1 \" ) " ) . arg ( files ) ;
2023-05-08 06:32:41 +00:00
*/
QStringList pyCodes ;
2023-05-09 11:00:22 +00:00
for ( int i = 0 ; i < filenames . size ( ) ; i + + ) {
2023-05-08 06:32:41 +00:00
pyCodes . append ( QString ( " MainWindow.importGeometry( \" %1 \" ) " ) . arg ( filenames [ i ] ) ) ;
}
Py : : PythonAgent : : getInstance ( ) - > submit ( pyCodes ) ;
}
void MainWindow : : importGeometry ( QStringList filenames )
{
_subWindowManager - > openPreWindow ( ) ;
2023-05-09 11:00:22 +00:00
if ( ! _signalHandler - > importGeometry ( filenames ) )
2023-05-08 06:32:41 +00:00
return ;
}
void MainWindow : : exportGeometry ( QString f )
{
2023-05-09 11:00:22 +00:00
if ( ! _signalHandler - > exportGeometry ( f ) )
2023-05-08 06:32:41 +00:00
return ;
Py : : PythonAgent : : getInstance ( ) - > unLock ( ) ;
}
void MainWindow : : on_solidMesh ( )
{
_signalHandler - > generateSolidMesh ( ) ;
}
void MainWindow : : on_surfaceMesh ( )
{
_signalHandler - > generateSurfaceMesh ( ) ;
}
2023-05-09 11:00:22 +00:00
void MainWindow : : on_genMesh ( ) { }
2023-05-08 06:32:41 +00:00
void MainWindow : : setWorkingDir ( )
{
Setting : : BusAPI : : instance ( ) - > setWorkingDir ( ) ;
}
void MainWindow : : on_solverManager ( )
{
SolverControl : : SolverManagerDialog dlg ( this ) ;
dlg . exec ( ) ;
}
void MainWindow : : on_solve ( )
{
2023-05-09 11:00:22 +00:00
bool showDlg = true ;
2023-05-08 06:32:41 +00:00
MainWidget : : ProjcctSolveDialog dlg ( this , showDlg ) ;
2023-05-09 11:00:22 +00:00
if ( showDlg )
2023-05-08 06:32:41 +00:00
dlg . exec ( ) ;
}
void MainWindow : : solveProject ( int id )
{
2023-05-09 11:00:22 +00:00
bool showDlg = true ;
2023-05-08 06:32:41 +00:00
MainWidget : : ProjcctSolveDialog dlg ( this , showDlg , id ) ;
2023-05-09 11:00:22 +00:00
if ( showDlg )
2023-05-08 06:32:41 +00:00
dlg . exec ( ) ;
}
void MainWindow : : on_solveOption ( )
{
// Setting::BusAPI::instance()->setSolverOptions();
}
void MainWindow : : on_graphOption ( )
{
Setting : : BusAPI : : instance ( ) - > setGraphOptions ( ) ;
}
2024-04-07 15:51:25 +00:00
/*
* 选 择 模 式 更 改 为
* @ param model 选 择 模 式 ModuleBase : : SelectModel
*/
2023-05-08 06:32:41 +00:00
void MainWindow : : selectModelChanged ( int model )
{
_ui - > actionSelectOff - > setChecked ( false ) ;
//_ui->actionSelectGeoBody->setChecked(false);
_ui - > actionSelectMeshNode - > setChecked ( false ) ;
_ui - > actionSelectMeshCell - > setChecked ( false ) ;
_ui - > actionBoxMeshNode - > setChecked ( false ) ;
_ui - > actionBoxMeshCell - > setChecked ( false ) ;
2024-07-07 15:13:48 +00:00
_ui - > actionBoxMeshSurfaceNode - > setChecked ( false ) ;
_ui - > actionBoxMeshSurfaceCell - > setChecked ( false ) ;
2023-05-09 11:00:22 +00:00
switch ( model ) {
case ( int ) ModuleBase : : SelectModel : : None :
_ui - > actionSelectOff - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : MeshNode :
_ui - > actionSelectMeshNode - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : MeshCell :
_ui - > actionSelectMeshCell - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : BoxMeshNode :
_ui - > actionBoxMeshNode - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : BoxMeshCell :
_ui - > actionBoxMeshCell - > setChecked ( true ) ;
break ;
2024-07-07 15:13:48 +00:00
case ( int ) ModuleBase : : SelectModel : : BoxMeshSurfaceNode :
_ui - > actionBoxMeshSurfaceNode - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : BoxMeshSurfaceCell :
_ui - > actionBoxMeshSurfaceCell - > setChecked ( true ) ;
break ;
2023-05-09 11:00:22 +00:00
default :
break ;
2023-05-08 06:32:41 +00:00
}
}
2023-05-09 11:00:22 +00:00
SubWindowManager * MainWindow : : getSubWindowManager ( )
2023-05-08 06:32:41 +00:00
{
return _subWindowManager ;
}
void MainWindow : : on_about ( )
{
AboutDialog dlg ;
dlg . exec ( ) ;
}
void MainWindow : : on_userManual ( )
{
2023-05-09 11:00:22 +00:00
QString file =
ConfigOption : : ConfigOption : : getInstance ( ) - > getGlobalConfig ( ) - > GetUserManual ( ) ;
2023-05-08 06:32:41 +00:00
QString userManulFile = QApplication : : applicationDirPath ( ) + " /../Doc/ " + file ;
2023-05-09 11:00:22 +00:00
if ( file . isEmpty ( ) ) {
2024-03-20 07:33:49 +00:00
QDesktopServices : : openUrl ( QUrl ( " http://www.LAMPCAE.com/index.php?mod=document " ) ) ;
2023-05-08 06:32:41 +00:00
return ;
}
QFile f ( userManulFile ) ;
2023-05-09 11:00:22 +00:00
if ( ! f . exists ( ) ) {
2023-05-08 06:32:41 +00:00
ModuleBase : : Message msg ;
2023-05-09 11:00:22 +00:00
msg . type = Common : : Message : : Warning ;
2023-05-08 06:32:41 +00:00
msg . message = tr ( " Please make sure \" %1 \" file exist! " ) . arg ( userManulFile ) ;
emit printMessageToMessageWindow ( msg ) ;
2023-05-09 11:00:22 +00:00
} else {
if ( ! QDesktopServices : : openUrl ( QUrl : : fromLocalFile ( userManulFile ) ) ) {
2023-05-08 06:32:41 +00:00
QString mess = QString ( tr ( " %1 not exist ! " ) ) . arg ( file ) ;
QMessageBox : : warning ( this , QString ( tr ( " Warning " ) ) , mess ) ;
}
}
}
void MainWindow : : setMeshDisplay ( )
{
bool showNode = _ui - > actionDisplayNode - > isChecked ( ) ;
2023-07-04 06:33:32 +00:00
bool showEdge = _ui - > actionPreDisplayWireFrame - > isChecked ( ) ;
2023-05-08 06:32:41 +00:00
bool showFace = _ui - > actionDisplaySurface - > isChecked ( ) ;
2023-05-09 11:00:22 +00:00
auto gp = Setting : : BusAPI : : instance ( ) - > getGraphOption ( ) ;
2023-05-08 06:32:41 +00:00
gp - > isShowMeshNode ( showNode ) ;
gp - > isShowMeshEdge ( showEdge ) ;
gp - > isShowMeshFace ( showFace ) ;
emit this - > meshDisplayModeChangedSig ( ) ;
}
void MainWindow : : selectGeometryModelChanged ( int m )
{
// bool active{true};
_ui - > actionSelectOff - > setChecked ( false ) ;
_ui - > actionSelectPoint - > setChecked ( false ) ;
_ui - > actionSelectCurve - > setChecked ( false ) ;
_ui - > actionSelectFace - > setChecked ( false ) ;
_ui - > actionSelectGeometryBody - > setChecked ( false ) ;
2023-05-09 11:00:22 +00:00
switch ( m ) {
case ( int ) ModuleBase : : SelectModel : : None :
_ui - > actionSelectOff - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : GeometryPoint :
case ( int ) ModuleBase : : SelectModel : : GeometryWinPoint :
_ui - > actionSelectPoint - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : GeometryCurve :
case ( int ) ModuleBase : : SelectModel : : GeometryWinCurve :
_ui - > actionSelectCurve - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : GeometrySurface :
case ( int ) ModuleBase : : SelectModel : : GeometryWinSurface :
_ui - > actionSelectFace - > setChecked ( true ) ;
break ;
case ( int ) ModuleBase : : SelectModel : : GeometryBody :
case ( int ) ModuleBase : : SelectModel : : GeometryWinBody :
_ui - > actionSelectGeometryBody - > setChecked ( true ) ;
break ;
;
default :
break ;
2023-05-08 06:32:41 +00:00
}
// emit selectGeoActiveSig(active);
}
void MainWindow : : setGeometryDisplay ( )
{
2023-05-09 11:00:22 +00:00
bool checkvertex = _ui - > actionDisplayPoint - > isChecked ( ) ;
bool checkcurve = _ui - > actionDisplayCurve - > isChecked ( ) ;
bool checkface = _ui - > actionDisplayFace - > isChecked ( ) ;
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
Setting : : GraphOption * gp = Setting : : BusAPI : : instance ( ) - > getGraphOption ( ) ;
2023-05-08 06:32:41 +00:00
gp - > isShowGeoPoint ( checkvertex ) ;
gp - > isShowGeoEdge ( checkcurve ) ;
gp - > isShowGeoSurface ( checkface ) ;
emit selectGeometryDisplay ( checkvertex , checkcurve , checkface ) ;
}
void MainWindow : : updateRecentMenu ( )
{
2023-05-09 11:00:22 +00:00
if ( _recentMenu = = nullptr ) {
2023-05-08 06:32:41 +00:00
_recentMenu = new QMenu ( tr ( " Recent " ) ) ;
_ui - > menuFile - > addMenu ( _recentMenu ) ;
}
_recentMenu - > clear ( ) ;
2023-05-09 11:00:22 +00:00
if ( _recentFileMapper = = nullptr ) {
2023-05-08 06:32:41 +00:00
_recentFileMapper = new QSignalMapper ;
}
_recentFileMapper - > disconnect ( ) ;
QStringList rencentFile = Setting : : BusAPI : : instance ( ) - > getRencetFiles ( ) ;
2023-05-09 11:00:22 +00:00
for ( int i = 0 ; i < rencentFile . size ( ) ; + + i ) {
QString f = rencentFile . at ( i ) ;
QAction * action = _recentMenu - > addAction ( f ) ;
2023-05-08 06:32:41 +00:00
action - > setStatusTip ( f ) ;
connect ( action , SIGNAL ( triggered ( ) ) , _recentFileMapper , SLOT ( map ( ) ) ) ;
_recentFileMapper - > setMapping ( action , f ) ;
}
connect ( _recentFileMapper , SIGNAL ( mapped ( QString ) ) , this , SLOT ( openRencentFile ( QString ) ) ) ;
}
void MainWindow : : setActionVisible ( QString objname , bool enable )
{
2023-05-09 11:00:22 +00:00
QList < QAction * > acs = this - > findChildren < QAction * > ( ) ;
for ( QAction * a : acs ) {
if ( a - > objectName ( ) . toLower ( ) = = objname . toLower ( ) ) {
2023-05-08 06:32:41 +00:00
a - > setVisible ( enable ) ;
break ;
}
}
}
void MainWindow : : openRencentFile ( QString file )
{
QFileInfo info ( file ) ;
2023-05-09 11:00:22 +00:00
if ( ! info . exists ( ) ) {
2023-05-08 06:32:41 +00:00
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " File \" %1 \" is not exist ! " ) ) ;
return ;
}
QString md5 = _signalHandler - > getMD5 ( ) ;
2023-05-09 11:00:22 +00:00
if ( md5 ! = _MD5 ) {
2023-05-08 06:32:41 +00:00
QMessageBox : : StandardButton but ;
2023-05-09 11:00:22 +00:00
but =
QMessageBox : : warning ( this , tr ( " Warning " ) , tr ( " Do you want to save current data ? " ) ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( but = = QMessageBox : : Yes )
2023-05-08 06:32:41 +00:00
on_actionSave ( ) ;
}
_signalHandler - > clearData ( false ) ;
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-09 11:00:22 +00:00
bool ok = _signalHandler - > openProjectFile ( file ) ;
if ( ! ok )
2023-05-08 06:32:41 +00:00
return ;
_subWindowManager - > openPreWindow ( ) ;
_subWindowManager - > updatePreActors ( ) ;
setCurrentFile ( file ) ;
updateRecentMenu ( ) ;
emit updateActionStatesSig ( ) ;
}
2023-05-09 11:00:22 +00:00
void MainWindow : : keyPressEvent ( QKeyEvent * e )
2023-05-08 06:32:41 +00:00
{
Q_UNUSED ( e )
2023-05-09 11:00:22 +00:00
qDebug ( ) < < " press " ;
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
void MainWindow : : keyReleaseEvent ( QKeyEvent * e )
2023-05-08 06:32:41 +00:00
{
Q_UNUSED ( e )
2023-05-09 11:00:22 +00:00
qDebug ( ) < < " release " ;
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
void MainWindow : : showEvent ( QShowEvent * e )
2023-05-08 06:32:41 +00:00
{
QMainWindow : : showEvent ( e ) ;
_signalHandler - > showUserGuidence ( true ) ;
}
bool MainWindow : : isLoadRecordScripFile ( )
{
QFile file ( qApp - > applicationDirPath ( ) + " /../temp/RecordScript.py " ) ;
2023-05-09 11:00:22 +00:00
if ( ! file . exists ( ) | | file . size ( ) = = 0 )
2023-05-08 06:32:41 +00:00
return false ;
2023-05-09 11:00:22 +00:00
QMessageBox : : StandardButton result = QMessageBox : : warning (
this , tr ( " Do you need to load? " ) ,
tr ( " The program quit with an exception before, do you want to reload the contents? " ) ,
QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : Yes ) ;
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
switch ( result ) {
case QMessageBox : : Yes :
Py : : PythonAgent : : getInstance ( ) - > execScript ( file . fileName ( ) ) ;
break ;
case QMessageBox : : No :
QFile : : remove ( qApp - > applicationDirPath ( ) + " /../temp/RecordScript.py " ) ;
break ;
default :
break ;
2023-05-08 06:32:41 +00:00
}
return true ;
}
void MainWindow : : setSketchPageVisible ( bool visible )
{
2023-05-09 11:00:22 +00:00
SARibbonBar * ribbon = ribbonBar ( ) ;
if ( ribbon - > ribbonTabBar ( ) - > currentIndex ( ) = = 0 )
2023-05-08 06:32:41 +00:00
return ;
// int index = -1;
2023-05-09 11:00:22 +00:00
if ( visible ) {
2023-05-08 06:32:41 +00:00
ribbon - > showContextCategory ( _ui - > sketch_tool_context ) ;
// index = ribbon->tabIndex(_ui->sketch_tool_page);
ribbon - > raiseCategory ( _ui - > sketch_tool_page ) ;
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
ribbon - > hideContextCategory ( _ui - > sketch_tool_context ) ;
// index = ribbon->tabIndex(_ui->geometry_page);
ribbon - > raiseCategory ( _ui - > sketch_tool_page ) ;
}
// ribbon->setCurrentIndex(index);
// ribbon->onCurrentRibbonTabChanged(index);
}
void MainWindow : : changeStyleToRibbon ( bool ok )
{
Setting : : BusAPI : : instance ( ) - > isUseRibbon ( ok ) ;
bool isRibbon = this - > isUseRibbon ( ) ;
2023-05-09 11:00:22 +00:00
if ( isRibbon = = ok )
2023-05-08 06:32:41 +00:00
return ;
QMessageBox mbox ( QMessageBox : : Information , tr ( " Info " ) , tr ( " Restart to load the style! " ) ) ;
/*QPushButton *button1 = */
mbox . addButton ( tr ( " Restart later " ) , QMessageBox : : RejectRole ) ;
2023-05-09 11:00:22 +00:00
QPushButton * button2 = mbox . addButton ( tr ( " Restart now " ) , QMessageBox : : YesRole ) ;
2023-05-08 06:32:41 +00:00
mbox . exec ( ) ;
2023-05-09 11:00:22 +00:00
if ( mbox . clickedButton ( ) = = button2 ) {
2023-05-08 06:32:41 +00:00
this - > closeEvent ( nullptr ) ;
qApp - > exit ( - 1000 ) ;
}
}
void MainWindow : : setPostAnimationToolBar ( bool ribbon )
{
_postToolBar = new Post : : AnimationToolBar ( this , _controlPanel - > getPostTreeWidget ( ) ) ;
Post : : RenderDirector : : getInstance ( ) - > setAnimationToolBar ( _postToolBar ) ;
2023-05-09 11:00:22 +00:00
if ( ribbon ) {
2023-05-08 06:32:41 +00:00
_postToolBar - > setVisible ( false ) ;
auto rBar = this - > ribbonBar ( ) ;
2023-05-09 11:00:22 +00:00
if ( rBar = = nullptr )
2023-05-08 06:32:41 +00:00
return ;
auto category = rBar - > categoryByName ( tr ( " 3DRender " ) ) ;
2023-05-09 11:00:22 +00:00
if ( category = = nullptr )
2023-05-08 06:32:41 +00:00
return ;
2023-05-09 11:00:22 +00:00
auto pannel = category - > addPannel ( QString ( ) ) ;
2023-05-08 06:32:41 +00:00
auto actList = _postToolBar - > actions ( ) ;
2023-05-09 11:00:22 +00:00
for ( auto action : actList ) {
2023-05-08 06:32:41 +00:00
action - > setEnabled ( false ) ;
2023-05-09 11:00:22 +00:00
if ( action - > objectName ( ) = = " QWidget " ) {
2023-05-08 06:32:41 +00:00
auto widget = _postToolBar - > widgetForAction ( action ) ;
2023-05-09 11:00:22 +00:00
if ( widget = = nullptr )
2023-05-08 06:32:41 +00:00
continue ;
widget - > setVisible ( true ) ;
pannel - > addLargeWidget ( widget ) ;
continue ;
}
pannel - > addLargeAction ( action ) ;
}
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
_postToolBar - > setVisible ( true ) ;
this - > addToolBar ( _postToolBar ) ;
}
}
/*void MainWindow::changeActionState(actionState state)
{
if ( state = = normalState )
{
}
else if ( state = = customState )
{
}
} */
void MainWindow : : on_CreateSet ( )
{
MainWidget : : CreateSetDialog dlg ( this , _subWindowManager - > getPreWindow ( ) ) ;
dlg . exec ( ) ;
}
void MainWindow : : on_CreateGeoComponent ( )
{
MainWidget : : CreateGeoComponentDialog dlg ( this , _subWindowManager - > getPreWindow ( ) ) ;
dlg . exec ( ) ;
}
void MainWindow : : clearWidgets ( )
{
_subWindowManager - > closeAllSubWindow ( ) ;
_subWindowManager - > openPreWindow ( ) ;
_controlPanel - > clearWidget ( ) ;
}
void MainWindow : : printMessage ( Common : : Message type , QString m )
{
2024-07-02 03:07:44 +00:00
// 比较长的 提示 做截断
if ( m . size ( ) > 100 ) {
m = m . left ( 100 ) + " ... " ;
}
2023-05-08 06:32:41 +00:00
ModuleBase : : Message s ( type , m ) ;
2023-05-09 11:00:22 +00:00
emit printMessageToMessageWindow ( s ) ;
2023-05-08 06:32:41 +00:00
}
void MainWindow : : on_SaveScript ( )
{
2023-05-09 11:00:22 +00:00
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
QString suffix = " Python(*.py) " ;
QString title = tr ( " Save Script " ) ;
2023-05-08 06:32:41 +00:00
QString filenames = QFileDialog : : getSaveFileName ( this , title , dir , suffix ) ;
2023-05-09 11:00:22 +00:00
if ( filenames . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
Py : : PythonAgent : : getInstance ( ) - > saveScript ( filenames ) ;
}
void MainWindow : : on_ExecuateScript ( )
{
2023-05-09 11:00:22 +00:00
QString fillter = " Python(*.py) " ;
QString title = tr ( " Execute Script " ) ;
QString dir = Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ;
2023-05-08 06:32:41 +00:00
QString filePath = QFileDialog : : getOpenFileName ( this , title , dir , fillter ) ;
2023-05-09 11:00:22 +00:00
if ( filePath . isEmpty ( ) )
2023-05-08 06:32:41 +00:00
return ;
bool ok = Py : : PythonAgent : : getInstance ( ) - > execScript ( filePath ) ;
2023-05-09 11:00:22 +00:00
if ( ! ok )
QMessageBox : : warning ( this , tr ( " Warning " ) ,
QString ( tr ( " %1 execute failed ! " ) ) . arg ( filePath ) ) ;
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
MainWidget : : ControlPanel * MainWindow : : getControlPanel ( )
2023-05-08 06:32:41 +00:00
{
return _controlPanel ;
}
void MainWindow : : on_sketchClicked ( )
{
bool ischecked = _ui - > actionCreate_Sketch - > isChecked ( ) ;
2023-05-09 11:00:22 +00:00
if ( ischecked ) {
if ( ! _subWindowManager - > isPreWindowOpened ( ) )
2023-05-08 06:32:41 +00:00
_subWindowManager - > openPreWindow ( ) ;
2023-05-09 11:00:22 +00:00
auto dlg =
new GeometryWidget : : SketchPlanDialog ( this , _subWindowManager - > getPreWindow ( ) ) ;
2023-05-08 06:32:41 +00:00
dlg - > show ( ) ;
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
// auto p = _subWindowManager->getPreWindow();
emit startSketchSig ( false , nullptr , nullptr ) ;
}
}
void MainWindow : : startSketch ( bool s )
{
_ui - > actionCreate_Sketch - > setChecked ( s ) ;
2023-05-09 11:00:22 +00:00
if ( isUseRibbon ( ) )
2023-05-08 06:32:41 +00:00
setSketchPageVisible ( s ) ;
2023-05-09 11:00:22 +00:00
else {
2023-05-08 06:32:41 +00:00
_ui - > GeomertryFeatureToolBar - > setVisible ( ! s ) ;
_ui - > ChamferToolBar - > setVisible ( ! s ) ;
_ui - > BoolToolBar - > setVisible ( ! s ) ;
_ui - > FeatureOpertionToolBar - > setVisible ( ! s ) ;
_ui - > SketchToolBar - > setVisible ( s ) ;
}
}
void MainWindow : : on_FilterMesh ( )
{
MainWidget : : FilterMeshDialog dlg ( this , _subWindowManager - > getPreWindow ( ) ) ;
dlg . exec ( ) ;
}
void MainWindow : : on_VTKTranslation ( )
{
MainWidget : : DialogVTKTransform dlg ( this ) ;
dlg . exec ( ) ;
}
void MainWindow : : showGraphRange ( double w , double h )
{
2023-05-09 11:00:22 +00:00
if ( _graphRange = = nullptr ) {
2023-05-08 06:32:41 +00:00
_graphRange = new QLabel ( this ) ;
_ui - > statusbar - > addPermanentWidget ( _graphRange ) ;
}
2024-07-31 06:32:53 +00:00
QString text = QString ( tr ( " 画布 %1mm * %2mm " ) ) . arg ( w ) . arg ( h ) ;
2024-05-15 02:15:29 +00:00
2023-05-08 06:32:41 +00:00
_graphRange - > setText ( text ) ;
}
// void MainWindow::updateActionsStates()
// {
// _signalHandler->updateActionsStates();
// }
2023-05-09 11:00:22 +00:00
CustomizerHelper * MainWindow : : getCustomizerHelper ( )
2023-05-08 06:32:41 +00:00
{
return _customizerHelper ;
}
2023-05-09 11:00:22 +00:00
SignalHandler * MainWindow : : getSignalHandler ( )
2023-05-08 06:32:41 +00:00
{
return _signalHandler ;
}
2023-05-09 11:00:22 +00:00
MainWidget : : MessageWindow * MainWindow : : getMessageWindow ( )
2023-05-08 06:32:41 +00:00
{
return _messageWindow ;
}
void MainWindow : : setIcon ( QString iconPath )
{
this - > setWindowIcon ( QIcon ( iconPath ) ) ;
_subWindowManager - > setIcon ( iconPath ) ;
}
2023-05-09 11:00:22 +00:00
QAction * MainWindow : : getAction ( QString & objName )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QList < QAction * > acs = this - > findChildren < QAction * > ( ) ;
for ( QAction * a : acs ) {
if ( a - > objectName ( ) . toLower ( ) = = objName . toLower ( ) )
2023-05-08 06:32:41 +00:00
return a ;
}
return nullptr ;
}
2023-05-09 11:00:22 +00:00
QToolBar * MainWindow : : getToolBar ( QString & objName )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QList < QToolBar * > tbs = this - > findChildren < QToolBar * > ( ) ;
for ( auto a : tbs ) {
if ( a - > objectName ( ) . toLower ( ) = = objName . toLower ( ) )
2023-05-08 06:32:41 +00:00
return a ;
}
return nullptr ;
}
2023-05-09 11:00:22 +00:00
QMenu * MainWindow : : getMenu ( QString & objName )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QList < QMenu * > mes = this - > findChildren < QMenu * > ( ) ;
for ( auto a : mes ) {
if ( a - > objectName ( ) . toLower ( ) = = objName . toLower ( ) )
2023-05-08 06:32:41 +00:00
return a ;
}
return nullptr ;
}
2023-05-09 11:00:22 +00:00
QPair < QWidget * , QList < QAction * > >
MainWindow : : createWidgetAndAction ( const QString & title , const QStringList & actionStrs )
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QAction * action { } ;
QList < QAction * > actions ;
QPair < QWidget * , QList < QAction * > > value ;
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
if ( isUseRibbon ( ) ) {
SARibbonCategory * page = ribbonBar ( ) - > addCategoryPage ( title ) ;
2023-05-08 06:32:41 +00:00
// 给定制的panel添加名称
2023-05-09 11:00:22 +00:00
SARibbonPannel * pannel = page - > addPannel ( QObject : : tr ( " Customization " ) ) ;
2023-05-08 06:32:41 +00:00
pannel - > setCanCustomize ( false ) ; // 不能编辑
2023-05-09 11:00:22 +00:00
for ( QString actionStr : actionStrs ) {
2023-05-08 06:32:41 +00:00
action = new QAction ( actionStr , this ) ;
action - > setObjectName ( actionStr ) ;
actions . append ( action ) ;
pannel - > addLargeAction ( action ) ;
}
value . first = page ;
2023-05-09 11:00:22 +00:00
} else {
QMenu * menu = new QMenu ( title ) ;
for ( QString actionStr : actionStrs ) {
2023-05-08 06:32:41 +00:00
action = new QAction ( actionStr , this ) ;
action - > setObjectName ( actionStr ) ;
actions . append ( action ) ;
menu - > addAction ( action ) ;
}
value . first = menu ;
}
value . second = actions ;
return value ;
}
2023-05-09 11:00:22 +00:00
Post : : AnimationToolBar * MainWindow : : getAnimationToolBar ( )
2023-05-08 06:32:41 +00:00
{
return _postToolBar ;
}
2023-05-09 11:00:22 +00:00
SARibbonActionsManager * MainWindow : : getActionManager ( )
2023-05-08 06:32:41 +00:00
{
return m_ribbonActionMgr ;
}
2024-04-11 08:13:53 +00:00
// 点云
void MainWindow : : on_pclStatisticalRemoveFilter ( )
{
DebugInfo ( " on_pclStatisticalRemoveFilter \n " ) ;
emit this - > on_pclStatisticalRemoveFilter ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-04-11 08:13:53 +00:00
void MainWindow : : on_pclRadiusOutlierRemoval ( )
{
DebugInfo ( " on_pclRadiusOutlierRemoval \n " ) ;
emit this - > on_pclRadiusOutlierRemoval ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-04-11 08:13:53 +00:00
void MainWindow : : on_pclGuassFilter ( )
{
DebugInfo ( " on_pclGuassFilter \n " ) ;
emit this - > on_pclGuassFilter ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-04-11 08:13:53 +00:00
void MainWindow : : on_pclBilateralFilter ( )
{
DebugInfo ( " on_pclBilateralFilter \n " ) ;
emit this - > on_pclBilateralFilter ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-04-11 08:13:53 +00:00
void MainWindow : : on_pclGPMesh ( )
{
DebugInfo ( " on_pclGPMesh \n " ) ;
emit this - > on_pclGPMesh ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-04-11 08:13:53 +00:00
// FEKO
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionImageSetting ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_actionImageSetting \n " ) ;
emit this - > on_actionImageSetting ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionFEKO2csv ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_actionFEKO2csv \n " ) ;
emit this - > on_actionFEKO2csv ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionScatterExport ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_actionScatterExport \n " ) ;
emit this - > on_actionScatterExport ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionFEKOImage ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_actionFEKOImage \n " ) ;
emit this - > on_actionFEKOImage ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionantScatteringFEKOSetting ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_actionantScatteringFEKOSetting \n " ) ;
emit this - > on_actionantScatteringFEKOSetting ( this ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_AttriutionDBShow ( )
{
2024-04-11 08:13:53 +00:00
DebugInfo ( " on_AttriutionDBShow \n " ) ;
emit this - > on_actionAttriutionDBShow ( this ) ;
2024-04-07 15:51:25 +00:00
}
2024-07-02 03:07:44 +00:00
void MainWindow : : showStateToolbarPosition ( double x , double y , double z )
{
2024-05-15 02:15:29 +00:00
if ( _vtkworldPostion = = nullptr ) {
_vtkworldPostion = new QLabel ( this ) ;
_ui - > statusbar - > addPermanentWidget ( _vtkworldPostion ) ;
}
2024-07-31 06:32:53 +00:00
QString text = QString ( tr ( u8 " 世界坐标 : %1 mm, %2 mm, %3 mm " ) ) . arg ( x ) . arg ( y ) . arg ( z ) ;
2024-05-15 02:15:29 +00:00
_vtkworldPostion - > setText ( text ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionvtkPointSamplor ( )
{
2024-05-28 00:53:55 +00:00
DebugInfo ( " on_actionvtkPointSamplor \n " ) ;
emit this - > on_actionvtkPointSamplorTriggleSIGNAL ( this ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionImageShowTool ( )
{
2024-05-28 00:53:55 +00:00
DebugInfo ( " on_actionImageShowTool \n " ) ;
emit this - > on_actionImageShowToolTriggleSIGNAL ( this ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_actionRCShowTool ( )
{
2024-05-28 00:53:55 +00:00
DebugInfo ( " on_actionRCShowTool \n " ) ;
emit this - > on_actionRCShowToolSIGNAL ( this ) ;
}
2024-07-02 03:07:44 +00:00
void MainWindow : : on_pclPoissonMesh ( )
{
2024-05-28 00:53:55 +00:00
DebugInfo ( " on_pclPoissonMesh \n " ) ;
emit this - > on_pclPoissonMesh ( this ) ;
2024-07-02 03:07:44 +00:00
}
void MainWindow : : on_actionLoadPointCloudText ( )
{
DebugInfo ( " on_actionLoadPointCloudText \n " ) ;
// emit this->actionLoadPointCloudText(this);
2024-05-28 00:53:55 +00:00
}
2024-07-07 15:13:48 +00:00
2024-07-23 03:40:54 +00:00
//"forest", "crop", "grass", "uav", "water", "dwater", "road", "geo", "radi", "soil", "land",
//"vegetation", "water_scene"
void MainWindow : : on_actionLoadPreForestMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreForestMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " forest " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreCropMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreCropMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " crop " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreGrasslandMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreGrasslandMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " grass " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreWaterBodyMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreWaterBodyMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " water " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreSoilMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreSoilMeshFile_triggered \n " ) ;
2024-07-23 03:40:54 +00:00
emit this - > on_loadPreMeshFile ( this , " soil " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreDynamicWaterBodyMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreDynamicWaterBodyMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " dwater " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreRoadMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreRoadMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " road " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadPreArtificialMeshFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadPreArtificialMeshFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " uav " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadForestPointCloudFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadForestPointCloudFile_triggered \n " ) ; // 加载点云
on_importPcl ( ) ;
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadRhounessPointCloudFile_triggereds ( )
{ // 加载粗糙度点云
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadRhounessPointCloudFile_triggered \n " ) ;
on_importPcl ( ) ;
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadGeometricCorrectionFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadGeometricCorrectionFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " geo " ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionLoadRadioModelFile_triggereds ( )
{
2024-07-02 09:22:29 +00:00
DebugInfo ( " on_actionLoadRadioModelFile_triggered \n " ) ;
2024-07-07 15:13:48 +00:00
emit this - > on_loadPreMeshFile ( this , " radi " ) ;
2024-07-09 02:15:46 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_deleteMesh ( )
{
2024-07-09 02:15:46 +00:00
DebugInfo ( " MainWindow::on_deleteMesh \n " ) ;
emit this - > on_deleteMeshSIGNAL ( this ) ;
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_copyMesh ( )
{
2024-07-09 02:15:46 +00:00
DebugInfo ( " MainWindow::on_copyMesh \n " ) ;
emit this - > on_copyMeshSIGNAL ( this ) ;
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_clipMesh ( )
{
2024-07-09 02:15:46 +00:00
DebugInfo ( " MainWindow::on_clipMesh \n " ) ;
emit this - > on_clipMeshSIGNAL ( this ) ;
}
2025-01-13 02:55:05 +00:00
void MainWindow : : on_actionLoadLaboratoryScatterResult_triggereds ( ) {
DebugInfo ( " on_actionLoadLaboratoryScatterResult_triggered \n " ) ;
emit this - > on_action_LoadLaboratoryScatterResultSIGN ( this ) ;
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_saveMeshEdit ( )
{
2024-07-09 02:15:46 +00:00
DebugInfo ( " MainWindow::on_saveMeshEdit \n " ) ;
2024-07-23 03:40:54 +00:00
MeshData : : MeshData * _meshData = MeshData : : MeshData : : getInstance ( ) ;
MainWidget : : MeshViewProvider * _meshProvider =
this - > getSubWindowManager ( ) - > getPreWindow ( ) - > getMeshViewProvider ( ) ;
// 更新保存模型
int nKernal = _meshData - > getKernalCount ( ) ;
if ( nKernal = = 0 )
return ;
for ( int i = 0 ; i < nKernal ; + + i ) {
auto k = _meshData - > getKernalAt ( i ) ; // 获取对应的kernal
auto vObjs = _meshProvider - > getViewObjects ( k ) ; // 获取对应的view对象
if ( ! ( k - > isVisible ( ) ) | | nullptr = = vObjs )
continue ;
// 根据显示更新实体
vtkSmartPointer < vtkGeometryFilter > geometryFilter =
vtkSmartPointer < vtkGeometryFilter > : : New ( ) ;
geometryFilter - > AddInputData ( vObjs - > getDisplayData ( ) ) ;
geometryFilter - > Update ( ) ;
k - > setMeshData ( geometryFilter - > GetOutput ( ) ) ;
qDebug ( ) < < QString ( " %1 Point Number %2,Cel Number %3 " )
. arg ( k - > getName ( ) )
. arg ( k - > getMeshData ( ) - > GetNumberOfPoints ( ) )
. arg ( k - > getMeshData ( ) - > GetNumberOfCells ( ) ) ;
// k->getMeshData()->DeepCopy(vObjs->getDisplayData());
}
// emit this->on_saveMeshSIGNAL(this);
2024-07-09 02:15:46 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionMeshTriangleSurface ( )
{
2024-07-09 02:15:46 +00:00
DebugInfo ( " MainWindow::on_actionMeshTriangleSurface \n " ) ;
emit this - > on_actionMeshTriangleSurfaceSIGNAL ( this ) ;
2024-07-10 10:52:22 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_MeshToGeo ( MeshData : : MeshKernal * k )
{
2024-07-10 10:52:22 +00:00
DebugInfo ( " MainWindow::on_MeshToGeo \n " ) ;
2024-07-23 03:40:54 +00:00
vtkDataSet * meshdata = k - > getMeshData ( ) ;
TopoDS_Shape * polyshp = MeshOpearator : : MeshOpearatorCommon : : vtkdataSetToOCC ( meshdata ) ;
if ( nullptr = = polyshp ) {
2024-07-10 10:52:22 +00:00
return ;
}
2024-07-23 03:40:54 +00:00
Geometry : : GeometrySet * geoSet =
new Geometry : : GeometrySet ( Geometry : : GeometryType : : STL , true ) ;
qDebug ( ) < < " Model geoSet " ;
geoSet - > setShape ( polyshp ) ;
geoSet - > setName ( k - > getName ( ) + " _mesh2OCCT " ) ;
2024-07-10 10:52:22 +00:00
Geometry : : GeometryData : : getInstance ( ) - > appendGeometrySet ( geoSet ) ;
2024-07-23 03:40:54 +00:00
qDebug ( ) < < " Model geoSet " ;
2024-07-10 10:52:22 +00:00
emit this - > updateActionStatesSig ( ) ;
2024-07-23 03:40:54 +00:00
emit this - > _subWindowManager - > getPreWindow ( ) - > showGeoSet ( geoSet , true ) ;
2024-07-10 10:52:22 +00:00
emit this - > updateGeometryTreeSig ( ) ;
2024-07-23 03:40:54 +00:00
qDebug ( ) < < " Model over " ;
2024-07-10 10:52:22 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_action_generatorWaterPlane ( )
{
2024-07-10 10:52:22 +00:00
DebugInfo ( " MainWindow::on_action_generatorWaterPlane \n " ) ;
emit this - > on_action_generatorWaterPlaneSIGNAL ( this ) ;
2024-07-02 09:22:29 +00:00
}
2024-07-23 03:40:54 +00:00
void MainWindow : : on_actionBatchStartFEKOCADModel ( ) {
MainWidget : : fekocadTaskinit * dlg = new MainWidget : : fekocadTaskinit ( this ) ;
dlg - > exec ( ) ;
}
void MainWindow : : on_actionCreateCADModel ( ) {
DebugInfo ( " MainWindow::on_actionCreateCADModel \n " ) ;
QStringList stlList ;
{
// 弹出对话框,询问是否导入场景中模型
if ( MeshData : : MeshData : : getInstance ( ) - > getKernalCount ( ) ! = 0 & & QMessageBox : : information ( this , tr ( " Warning " ) , tr ( u8 " 是否导入当前场景中的网格模型? " ) ,
QMessageBox : : Yes | QMessageBox : : No )
= = QMessageBox : : Yes ) {
// 根据显示更新实体
stlList = this - > on_saveMesh2StlFile_InScane ( ) ;
} else {
QStringList fileNames = QFileDialog : : getOpenFileNames (
this , // Parent widget
tr ( u8 " 选择stl文件导入到FEKOCAD中 " ) , // Dialog title
Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) , // Starting directory
tr ( u8 " STL(*.stl) " ) // File filter
) ;
// Add the selected file paths to the list widget
for ( const QString & fileName : fileNames ) {
stlList . append ( fileName ) ;
}
}
}
QStringList geoList ;
{
if ( Geometry : : GeometryData : : getInstance ( ) - > getGeometrySetCount ( ) ! = 0 & & QMessageBox : : information ( this , tr ( " Warning " ) , tr ( u8 " 是否导入当前场景中的几何模型? " ) ,
QMessageBox : : Yes | QMessageBox : : No )
= = QMessageBox : : Yes ) {
// 根据显示更新实体
geoList = this - > on_saveGeometryModel2StlFile_InScane ( ) ;
} else {
QStringList fileNames = QFileDialog : : getOpenFileNames (
this , // Parent widget
tr ( u8 " 选择iges文件导入到FEKOCAD中 " ) , // Dialog title
Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) , // Starting directory
tr ( u8 " IGES(*.igs) " ) // File filter
) ;
// Add the selected file paths to the list widget
for ( const QString & fileName : fileNames ) {
geoList . append ( fileName ) ;
}
}
}
for ( QString igsname : geoList ) {
stlList . append ( igsname ) ;
}
MainWidget : : CreateFEKOCADModel * DialogcreateFekoCAD = new MainWidget : : CreateFEKOCADModel ( this ) ;
DialogcreateFekoCAD - > setSTLFilePathList ( stlList ) ;
DialogcreateFekoCAD - > exec ( ) ;
}
QStringList MainWindow : : on_saveGeometryModel2StlFile_InScane ( )
{
QStringList geofileList ;
QString geoPath = QFileDialog : : getSaveFileName ( this , " Save Geometry in FEKOCAD WorkSpace " , " " , " IGES(*.igs) " ) ;
if ( geoPath . isEmpty ( ) )
{
return QStringList ( ) ;
}
QString pycode = QString ( " MainWindow.exportGeometry( \" %1 \" ) " ) . arg ( geoPath ) ;
Py : : PythonAgent : : getInstance ( ) - > submit ( pycode ) ;
geofileList . append ( geoPath ) ;
return geofileList ;
}
QStringList MainWindow : : on_saveMesh2StlFile_InScane ( )
{
int KernalCount = MeshData : : MeshData : : getInstance ( ) - > getKernalCount ( ) ;
QStringList stlfileList ;
for ( int ki = 0 ; ki < KernalCount ; ki + + ) {
MeshData : : MeshKernal * k = MeshData : : MeshData : : getInstance ( ) - > getKernalAt ( ki ) ;
if ( k - > isVisible ( ) ) {
MainWidget : : MeshKernalViewObj * viewObj = this - > getSubWindowManager ( )
- > getPreWindow ( )
- > getMeshViewProvider ( )
- > getViewObjects ( k ) ;
if ( viewObj - > getDisplayData ( ) - > GetNumberOfCells ( ) ! = k - > getMeshData ( ) - > GetNumberOfCells ( ) | | viewObj - > getDisplayData ( ) - > GetNumberOfPoints ( ) ! = k - > getMeshData ( ) - > GetNumberOfPoints ( ) ) {
if ( QMessageBox : : information ( this , tr ( " Warning " ) , tr ( u8 " 模型已经修改, 是否保存模型并导入到FEKOCAD中? " ) , QMessageBox : : Yes | QMessageBox : : No ) = = QMessageBox : : Yes ) {
// 根据显示更新实体
k - > getMeshData ( ) - > Initialize ( ) ;
vtkSmartPointer < vtkGeometryFilter > geometryFilter =
vtkSmartPointer < vtkGeometryFilter > : : New ( ) ;
geometryFilter - > AddInputData ( viewObj - > getDisplayData ( ) ) ;
geometryFilter - > Update ( ) ;
k - > setMeshData ( geometryFilter - > GetOutput ( ) ) ;
}
} else { }
QString stlPath = QFileDialog : : getSaveFileName ( this , " Save File in FEKOCAD WorkSpace " , Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) + " / " + k - > getName ( ) , " STL(*.stl) " ) ;
if ( stlPath . isEmpty ( ) )
{
continue ;
}
else {
// 保存模型
if ( MeshOpearator : : MeshOpearatorCommon : : saveMeshDataToSTL ( stlPath , k - > getMeshData ( ) ) ) {
this - > printMessageToMessageWindow ( ModuleBase : : Message ( Common : : Message : : Normal , QString ( tr ( " Save %1 success! " ) ) . arg ( stlPath ) ) ) ;
stlfileList . append ( stlPath ) ;
} else {
this - > printMessageToMessageWindow ( ModuleBase : : Message ( Common : : Message : : Error , QString ( tr ( " Save %1 failed! " ) ) . arg ( stlPath ) ) ) ;
}
}
}
else { }
}
return stlfileList ;
}
void MainWindow : : on_actionCreateLoadModelScript ( )
{
QStringList stlList ;
{
// 弹出对话框,询问是否导入场景中模型
if ( MeshData : : MeshData : : getInstance ( ) - > getKernalCount ( ) ! = 0 & & QMessageBox : : information ( this , tr ( " Warning " ) , tr ( u8 " 是否导入当前场景中的网格模型? " ) ,
QMessageBox : : Yes | QMessageBox : : No )
= = QMessageBox : : Yes ) {
// 根据显示更新实体
stlList = this - > on_saveMesh2StlFile_InScane ( ) ;
} else {
QStringList fileNames = QFileDialog : : getOpenFileNames (
this , // Parent widget
tr ( u8 " 选择stl文件导入到FEKOCAD中 " ) , // Dialog title
Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) , // Starting directory
tr ( u8 " STL(*.stl) " ) // File filter
) ;
// Add the selected file paths to the list widget
for ( const QString & fileName : fileNames ) {
stlList . append ( fileName ) ;
}
}
}
QStringList geoList ;
{
if ( Geometry : : GeometryData : : getInstance ( ) - > getGeometrySetCount ( ) ! = 0 & & QMessageBox : : information ( this , tr ( " Warning " ) , tr ( u8 " 是否导入当前场景中的几何模型? " ) ,
QMessageBox : : Yes | QMessageBox : : No )
= = QMessageBox : : Yes ) {
// 根据显示更新实体
geoList = this - > on_saveGeometryModel2StlFile_InScane ( ) ;
} else {
QStringList fileNames = QFileDialog : : getOpenFileNames (
this , // Parent widget
tr ( u8 " 选择IGES文件导入到FEKOCAD中 " ) , // Dialog title
Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) , // Starting directory
u8 " IGES(*.igs) " // File filter
) ;
// Add the selected file paths to the list widget
for ( const QString & fileName : fileNames ) {
geoList . append ( fileName ) ;
}
}
}
if ( stlList . count ( ) ! = 0 | | geoList . count ( ) ! = 0 ) {
// 生成FEKO模型加载参数
QString scriptPath = QFileDialog : : getSaveFileName (
this , u8 " 保存为CAD模型创建文件 " , Setting : : BusAPI : : instance ( ) - > getWorkingDir ( ) ,
" _model_init_script(*.lua) " ) ;
if ( scriptPath . isEmpty ( ) ) {
return ;
} else {
}
Setting : : TaskDesc * newTaskDesc = Setting : : BusAPI : : instance ( ) - > getNewTask ( ) ;
newTaskDesc - > setTaskClass ( Setting : : TaskClassDesc : : WriteTask ) ;
newTaskDesc - > setState ( Setting : : TaskDescState : : Running ) ;
newTaskDesc - > setTaskName ( scriptPath ) ;
emit actionGenerateImportModelScript ( newTaskDesc - > getTaskId ( ) , this , stlList , geoList ,
scriptPath ) ;
} else { }
}
2024-07-31 06:32:53 +00:00
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 ( ) ;
}
2025-01-02 12:20:29 +00:00
void MainWindow : : on_actionAddTree_triggereds ( ) {
emit this - > on_actionAddTreeClickedSIG ( this ) ;
}
void MainWindow : : on_action_ForestSance ( ) {
WBFZEquipment : : DialogPointCloudScane * dialogPointCloudScane = new WBFZEquipment : : DialogPointCloudScane ( this ) ;
dialogPointCloudScane - > exec ( ) ;
}
void MainWindow : : on_action_soilSurfaceScane ( ) {
WBFZEquipment : : SoilSurface3DMeasurementSystem * dlg = new WBFZEquipment : : SoilSurface3DMeasurementSystem ( this ) ;
dlg - > exec ( ) ;
}
2023-05-09 11:00:22 +00:00
} // namespace GUI