LAMPCAE/src/MainWindow/SignalHandler.cpp

1560 lines
53 KiB
C++
Raw Normal View History

2023-05-09 11:00:22 +00:00
#include "SignalHandler.h"
#include "Common/Types.h"
2023-05-08 06:32:41 +00:00
#include "ConfigOptions/ConfigOptions.h"
#include "ConfigOptions/ProjectTreeConfig.h"
#include "ConfigOptions/SolverConfig.h"
#include "DataProperty/modelTreeItemType.h"
2023-05-09 11:00:22 +00:00
#include "Geometry/geometryData.h"
#include "Geometry/geometryExporter.h"
2023-05-08 06:32:41 +00:00
#include "GeometryCommand/GeoCommandImport.h"
2023-05-09 11:00:22 +00:00
#include "GeometryCommand/GeoCommandList.h"
#include "GeometryWidgets/dialogBoolOperation.h"
2023-05-08 06:32:41 +00:00
#include "GeometryWidgets/dialogCreateBox.h"
2023-05-09 11:00:22 +00:00
#include "GeometryWidgets/dialogCreateBoxComplex.h"
#include "GeometryWidgets/dialogCreateCone.h"
2023-05-08 06:32:41 +00:00
#include "GeometryWidgets/dialogCreateCylinder.h"
2023-05-09 11:00:22 +00:00
#include "GeometryWidgets/dialogCreateCylindricalComplex.h"
#include "GeometryWidgets/dialogCreateDatumplane.h"
#include "GeometryWidgets/dialogCreateFace.h"
#include "GeometryWidgets/dialogCreateLine.h"
#include "GeometryWidgets/dialogCreatePoint.h"
2023-05-08 06:32:41 +00:00
#include "GeometryWidgets/dialogCreateSphere.h"
2023-05-09 11:00:22 +00:00
#include "GeometryWidgets/dialogGeoSplitter.h"
2023-05-08 06:32:41 +00:00
#include "GeometryWidgets/dialogMakeChamfer.h"
#include "GeometryWidgets/dialogMakeExtrusion.h"
2023-05-09 11:00:22 +00:00
#include "GeometryWidgets/dialogMakeFillet.h"
#include "GeometryWidgets/dialogMakeFillGap.h"
#include "GeometryWidgets/dialogMakeFillHole.h"
2023-05-08 06:32:41 +00:00
#include "GeometryWidgets/dialogMakeLoft.h"
#include "GeometryWidgets/dialogMakeMatrix.h"
#include "GeometryWidgets/dialogMakeRemoveSurface.h"
2023-05-09 11:00:22 +00:00
#include "GeometryWidgets/dialogMakeRevol.h"
#include "GeometryWidgets/dialogMakeSweep.h"
#include "GeometryWidgets/dialogMeasureDistance.h"
#include "GeometryWidgets/dialogMirrorFeature.h"
#include "GeometryWidgets/dialogMoveFeature.h"
#include "GeometryWidgets/dialogRotateFeature.h"
#include "GeometryWidgets/dialogVariableFillet.h"
2023-05-08 06:32:41 +00:00
#include "GmshModule/GmshModule.h"
2023-05-09 11:00:22 +00:00
#include "IO/IOConfig.h"
#include "IO/ProjectFileIO.h"
#include "IO/SolverInfoWriter.h"
#include "MainWidgets/ControlPanel.h"
#include "MainWidgets/DialogGeoMeshRotate.h"
#include "MainWidgets/DialogMeshChecking.h"
#include "MainWidgets/DialogSavePicture.h"
#include "MainWidgets/DialogSelectMesher.h"
#include "MainWidgets/preWindow.h"
#include "MainWindow.h"
#include "Material/MaterialSingletion.h"
#include "MeshData/meshKernal.h"
#include "MeshData/meshSingleton.h"
#include "ModelData/modelDataBase.h"
#include "ModelData/modelDataSingleton.h"
2023-05-08 06:32:41 +00:00
#include "ModuleBase/ThreadControl.h"
2023-05-09 11:00:22 +00:00
#include "PluginManager/pluginBase.h"
#include "PluginManager/PluginManager.h"
#include "PostInterface/DialogCreateCalculate.h"
2023-05-08 06:32:41 +00:00
#include "PostInterface/DialogCreateClip.h"
#include "PostInterface/DialogCreateISO.h"
#include "PostInterface/DialogCreateReflection.h"
2023-05-09 11:00:22 +00:00
#include "PostInterface/DialogCreateStreamLine.h"
#include "PostInterface/DialogCreateVector.h"
#include "PostInterface/DialogFileDirectory.h"
2023-05-08 06:32:41 +00:00
#include "PostInterface/DialogSaveAnimation.h"
2023-05-09 11:00:22 +00:00
#include "PostInterface/GraphWidget.h"
2023-05-08 06:32:41 +00:00
#include "PostInterface/PostProcessPy.h"
2023-05-09 11:00:22 +00:00
#include "PostInterface/PostTreeWidget.h"
2023-05-08 06:32:41 +00:00
#include "PostRenderData/RenderDataImportUnSteady.h"
2023-05-09 11:00:22 +00:00
#include "PostWidgets/Post2DInterface.h"
#include "PostWidgets/Post2DWidget.h"
#include "PostWidgets/Post3DInterface.h"
#include "PostWidgets/Post3DWidget.h"
#include "PostWidgets/RealTimeWindowBase.h"
#include "PythonModule/PyAgent.h"
#include "SARibbonMWUi.h"
#include "Settings/BusAPI.h"
#include "Settings/GraphOption.h"
#include "SolveProcessManager.h"
#include "SolverControl/SolverControlerBase.h"
#include "SubWindowManager.h"
#include "UserGuidence/DialogUserGuidence.h"
#include <assert.h>
2023-05-08 06:32:41 +00:00
#include <QDebug>
2023-05-09 11:00:22 +00:00
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QProcess>
#include <QTreeWidgetItem>
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
namespace GUI {
SignalHandler::SignalHandler(MainWindow* mainwindow)
: _mainWindow(mainwindow)
{
/// 注册工程树鼠标事件传递给signalHandler
connect(mainwindow, SIGNAL(treeMouseEvent(int, QTreeWidgetItem*, int)), this,
SLOT(handleTreeMouseEvent(int, QTreeWidgetItem*, int)));
connect(mainwindow, SIGNAL(solveProjectSig(int, int)), this,
SLOT(solveProjectPy(int, int))); // liu
connect(mainwindow->getUi()->actionSurfaceMesh, SIGNAL(triggered()), this,
SLOT(generateSurfaceMesh()));
connect(mainwindow->getUi()->actionSolidMesh, SIGNAL(triggered()), this,
SLOT(generateSolidMesh()));
connect(mainwindow->getUi()->actionFluidMesh, SIGNAL(triggered()), this,
SLOT(generateFluidMesh()));
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionGenMesh, SIGNAL(triggered()), this, SLOT(genMesh()));
2023-05-09 11:00:22 +00:00
connect(mainwindow, SIGNAL(appendGeneratedMesh(QString, vtkDataSet*)), this,
SLOT(appendGeneratedMesh(QString, vtkDataSet*)));
connect(mainwindow->getUi()->actionEnglish, SIGNAL(triggered()), this,
SLOT(on_actionEnglish()));
connect(mainwindow->getUi()->actionChinese, SIGNAL(triggered()), this,
SLOT(on_actionChinese()));
connect(mainwindow->getUi()->actionRibbon, SIGNAL(triggered()), this,
SLOT(on_actionRibbon()));
connect(mainwindow->getUi()->actionNormal, SIGNAL(triggered()), this,
SLOT(on_actionNormal()));
2023-05-08 06:32:41 +00:00
connect(mainwindow, SIGNAL(updateActionStatesSig()), this, SLOT(updateActionsStates()));
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->action2DPlot, SIGNAL(triggered()), this,
SLOT(open2DPlotWindow()));
connect(mainwindow->getUi()->action3DGraph, SIGNAL(triggered()), this,
SLOT(open3DGraphWindow()));
connect(mainwindow, SIGNAL(closePostWindowSig(Post::PostWindowBase*)), this,
SLOT(closePostWindow(Post::PostWindowBase*)));
connect(mainwindow->getUi()->actionSave_Picture, SIGNAL(triggered()), this,
SLOT(saveImange()));
connect(mainwindow->getUi()->actionChecking, SIGNAL(triggered()), this,
SLOT(meshChecking()));
connect(mainwindow, SIGNAL(showDialogSig(QDialog*)), this, SLOT(showDialog(QDialog*)));
2023-05-08 06:32:41 +00:00
connect(mainwindow, SIGNAL(clearDataSig()), this, SLOT(clearData()));
2023-05-09 11:00:22 +00:00
connect(this, SIGNAL(importMeshPySig(QString, QString, int)), this,
SLOT(importMeshSlot(QString, QString, int)));
connect(this, SIGNAL(exportMeshPySig(QString, QString, int)), this,
SLOT(exportMeshSlot(QString, QString, int)));
2023-05-08 06:32:41 +00:00
connect(this, SIGNAL(open3DGraphWindowPySig()), this, SLOT(open3DGraphWindowPy()));
connect(this, SIGNAL(open2DPlotWindowPySig()), this, SLOT(open2DPlotWindowPy()));
connect(this, SIGNAL(openProjectFileSig(QString)), this, SLOT(openProjectFile(QString)));
2023-05-09 11:00:22 +00:00
connect(this, SIGNAL(saveToProjectFileSig(QString)), this,
SLOT(saveToProjectFile(QString)));
2023-05-08 06:32:41 +00:00
connect(this, SIGNAL(solveProjectSig(int, int)), this, SLOT(solveProject(int, int)));
2023-05-09 11:00:22 +00:00
connect(this, SIGNAL(projectFileProcessedSig(QString, bool, bool)), this,
SLOT(projectFileProcessed(QString, bool, bool)));
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->actionUser_Guidance, SIGNAL(triggered()), this,
SLOT(showUserGuidence()));
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
// 创建几何
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionUndo, SIGNAL(triggered()), this, SLOT(undo()));
connect(mainwindow->getUi()->actionRedo, SIGNAL(triggered()), this, SLOT(redo()));
connect(mainwindow->getUi()->actionCreateBox, SIGNAL(triggered()), this, SLOT(createBox()));
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->actionCreateCylinder, SIGNAL(triggered()), this,
SLOT(createCylinder()));
connect(mainwindow->getUi()->actionCreaterSphere, SIGNAL(triggered()), this,
SLOT(CreateSphere()));
connect(mainwindow->getUi()->actionCreaterCone, SIGNAL(triggered()), this,
SLOT(CreateCone()));
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionFillet, SIGNAL(triggered()), this, SLOT(CreateFilet()));
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->actionVariable_Fillet, SIGNAL(triggered()), this,
SLOT(CreateVariableFillet()));
connect(mainwindow->getUi()->actionChamfer, SIGNAL(triggered()), this,
SLOT(CreateChamfer()));
connect(mainwindow->getUi()->actionBoolCut, SIGNAL(triggered()), this,
SLOT(CreateBoolCut()));
connect(mainwindow->getUi()->actionBoolFause, SIGNAL(triggered()), this,
SLOT(CreateBoolFause()));
connect(mainwindow->getUi()->actionBoolCommon, SIGNAL(triggered()), this,
SLOT(CreateBoolCommon()));
connect(mainwindow->getUi()->actionMirrorFeature, SIGNAL(triggered()), this,
SLOT(MirrorFeature()));
connect(mainwindow->getUi()->actionExtrude, SIGNAL(triggered()), this,
SLOT(CreateExtrusion()));
connect(mainwindow->getUi()->actionCreate_Point, SIGNAL(triggered()), this,
SLOT(CreatePoint()));
connect(mainwindow->getUi()->actionCreate_Line, SIGNAL(triggered()), this,
SLOT(CreateEdge()));
connect(mainwindow->getUi()->actionCreate_Face, SIGNAL(triggered()), this,
SLOT(CreateFace()));
connect(mainwindow->getUi()->actionMoveFeature, SIGNAL(triggered()), this,
SLOT(MoveFeature()));
connect(mainwindow->getUi()->actionRotateFeature, SIGNAL(triggered()), this,
SLOT(RotateFeature()));
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionRevol, SIGNAL(triggered()), this, SLOT(CreateRevol()));
connect(mainwindow->getUi()->actionLoft, SIGNAL(triggered()), this, SLOT(CreateLoft()));
2023-05-09 11:00:22 +00:00
// connect(mainwindow->getUi()->actionCreateCylindricalComplex, SIGNAL(triggered()), this,
// SLOT(CreateCylindricalComplex())); connect(mainwindow->getUi()->actionCreateBoxComplex,
// SIGNAL(triggered()), this, SLOT(CreateBoxComplex()));
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionSweep, SIGNAL(triggered()), this, SLOT(CreateSweep()));
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->actionCreateDatumPlane, SIGNAL(triggered()), this,
SLOT(CreateDatumplane()));
connect(mainwindow->getUi()->actionDrawLine, SIGNAL(triggered()), this,
SLOT(DrawGraphicsLine()));
connect(mainwindow->getUi()->actionDrawRectangle, SIGNAL(triggered()), this,
SLOT(DrawGraphicsRectangle()));
connect(mainwindow->getUi()->actionDrawCircle, SIGNAL(triggered()), this,
SLOT(DrawGraphicsCircle()));
connect(mainwindow->getUi()->actionDrawArc, SIGNAL(triggered()), this,
SLOT(DrawGraphicsArc()));
connect(mainwindow->getUi()->actionDrawPolyline, SIGNAL(triggered()), this,
SLOT(DrawGraphicsPolyline()));
connect(mainwindow->getUi()->actionMakeMatrix, SIGNAL(triggered()), this,
SLOT(MakeMatrix()));
connect(mainwindow->getUi()->actionDrawSpline, SIGNAL(triggered()), this,
SLOT(DrawGraphSpline()));
connect(mainwindow->getUi()->actionMeasure_Distance, SIGNAL(triggered()), this,
SLOT(MeasureDistance()));
connect(mainwindow->getUi()->actionGeoSplitter, SIGNAL(triggered()), this,
SLOT(GeoSplitter()));
connect(mainwindow->getUi()->actionFillHole, SIGNAL(triggered()), this,
SLOT(MakeFillHole()));
connect(mainwindow->getUi()->actionRemoveSurface, SIGNAL(triggered()), this,
SLOT(MakeRemoveSurface()));
2023-05-08 06:32:41 +00:00
connect(mainwindow->getUi()->actionFillGap, SIGNAL(triggered()), this, SLOT(MakeFillGap()));
// connect(mainwindow->getUi()->actionDemo, SIGNAL(triggered()), this, SLOT(showDemo()));
2023-05-09 11:00:22 +00:00
connect(mainwindow->getUi()->actionOpenPostFile, SIGNAL(triggered()), this,
SLOT(openPostFile()));
connect(mainwindow->getUi()->actionDisplayPoints, &QAction::triggered,
[=] { this->setPostDisplayMode(0); });
connect(mainwindow->getUi()->actionDisplayWireframe, &QAction::triggered,
[=] { this->setPostDisplayMode(1); });
connect(mainwindow->getUi()->actionDisplaySurfaceWithoutEdge, &QAction::triggered,
[=] { this->setPostDisplayMode(2); });
connect(mainwindow->getUi()->actionDisplaySurfaceWithEdge, &QAction::triggered,
[=] { this->setPostDisplayMode(3); });
connect(mainwindow->getUi()->actionCreateVector, SIGNAL(triggered()), this,
SLOT(createPostVector()));
connect(mainwindow->getUi()->actionCreateClip, SIGNAL(triggered()), this,
SLOT(createPostClip()));
connect(mainwindow->getUi()->actionCreateSlice, SIGNAL(triggered()), this,
SLOT(createPostSlice()));
connect(mainwindow->getUi()->actionCreateStreamLine, SIGNAL(triggered()), this,
SLOT(createPostStreamLine()));
connect(mainwindow->getUi()->actionCreateISOSurface, SIGNAL(triggered()), this,
SLOT(createPostISOSurface()));
connect(mainwindow->getUi()->actionCreateISOCurve, SIGNAL(triggered()), this,
SLOT(createPostISOCurve()));
connect(mainwindow->getUi()->actionCreateCalculator, SIGNAL(triggered()), this,
SLOT(createPostCalculator()));
connect(mainwindow->getUi()->actionCreateReflection, SIGNAL(triggered()), this,
SLOT(createPostReflection()));
connect(mainwindow->getUi()->actionSaveImage, SIGNAL(triggered()), this,
SLOT(savePostPicture()));
connect(mainwindow->getUi()->actionSaveVideo, SIGNAL(triggered()), this,
SLOT(savePostAnimation()));
connect(mainwindow->getUi()->actionGeoMeshRotate, SIGNAL(triggered()), this,
SLOT(GeoMeshRotate()));
2023-05-08 06:32:41 +00:00
_solveProcessManager = new SolveProcessManager;
}
SignalHandler::~SignalHandler()
{
clearData();
// ModuleBase::ProjectTreeInfo::getInstance()->clearData();
ConfigOption::ConfigOption::getInstance()->clearAllConfig();
// ConfigOption::ProjectTreeConfig::getInstance()->clearData();
delete _solveProcessManager;
}
void SignalHandler::on_actionNew()
{
emit _mainWindow->createPhysiceModelSig();
}
2023-05-09 11:00:22 +00:00
SolveProcessManager* SignalHandler::getSolveProcessManager()
2023-05-08 06:32:41 +00:00
{
return _solveProcessManager;
}
bool SignalHandler::openProjectFile(QString fileName)
{
// add a reader
QFile f(fileName);
2023-05-09 11:00:22 +00:00
if(!f.exists())
2023-05-08 06:32:41 +00:00
return false;
this->clearData(false);
2023-05-09 11:00:22 +00:00
IO::ProjectFileIO* reader = new IO::ProjectFileIO(_mainWindow, this, fileName, true);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(reader);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
return true;
}
void SignalHandler::projectFileProcessed(QString fileName, bool success, bool read)
{
ModuleBase::Message m;
m.type = Common::Message::Error;
2023-05-09 11:00:22 +00:00
if(success)
2023-05-08 06:32:41 +00:00
m.type = Common::Message::Normal;
2023-05-09 11:00:22 +00:00
if(read) {
if(success) {
2023-05-08 06:32:41 +00:00
emit _mainWindow->updateGeometryTreeSig();
emit _mainWindow->updateMeshTreeSig();
emit _mainWindow->updateSetTreeSig();
emit _mainWindow->updatePhysicsTreeSignal();
_mainWindow->setCurrentFile(fileName);
QString md5 = getMD5();
_mainWindow->setMD5(md5);
_mainWindow->getSubWindowManager()->openPreWindow();
emit _mainWindow->updateActionStatesSig();
m.message = QString("\"%1\" has been Opened !").arg(fileName);
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
clearData(false);
m.message = QString("\"%1\" open failed !").arg(fileName);
}
Setting::BusAPI::instance()->appendRecentFile(fileName);
_mainWindow->updateRecentMenu();
2023-05-09 11:00:22 +00:00
} else {
if(success) {
2023-05-08 06:32:41 +00:00
Setting::BusAPI::instance()->appendRecentFile(fileName);
_mainWindow->setCurrentFile(fileName);
QString md5 = getMD5();
_mainWindow->setMD5(md5);
_mainWindow->updateRecentMenu();
m.message = QString("\"%1\" has been Saved !").arg(fileName);
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
m.message = QString("\"%1\" save failed !").arg(fileName);
}
}
emit _mainWindow->printMessageToMessageWindow(m);
Py::PythonAgent::getInstance()->unLock();
}
void SignalHandler::saveToProjectFile(QString filename)
{
// add a writer
2023-05-09 11:00:22 +00:00
IO::ProjectFileIO* writer = new IO::ProjectFileIO(_mainWindow, this, filename, false);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(writer);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
}
2023-05-09 11:00:22 +00:00
void SignalHandler::on_actionSolve() {}
2023-05-08 06:32:41 +00:00
void SignalHandler::on_actionEnglish()
{
_mainWindow->ChangeLanguage("English");
}
void SignalHandler::on_actionChinese()
{
_mainWindow->ChangeLanguage("Chinese");
}
void SignalHandler::on_actionRibbon()
{
_mainWindow->changeStyleToRibbon(true);
}
void SignalHandler::on_actionNormal()
{
_mainWindow->changeStyleToRibbon(false);
}
2023-05-09 11:00:22 +00:00
void SignalHandler::handleTreeMouseEvent(int eventtype, QTreeWidgetItem* item, int proID)
2023-05-08 06:32:41 +00:00
{
Q_UNUSED(proID);
2023-05-09 11:00:22 +00:00
if(item->type() != ProjectPostSetting)
return;
switch(eventtype) {
case 0:
// Post3D::Post3DWindow* w = _mainWindow->getPostWindowByID(proID);
// if (w == nullptr) return;
// w->showWindow();
break;
2023-05-08 06:32:41 +00:00
}
}
2023-05-09 11:00:22 +00:00
void SignalHandler::handleSingleClickEvent(QTreeWidgetItem* item, int proID)
2023-05-08 06:32:41 +00:00
{
Q_UNUSED(item);
Q_UNUSED(proID);
}
2023-05-09 11:00:22 +00:00
bool SignalHandler::importMeshSlot(const QString& fileName, const QString& suffix, int modelId)
2023-05-08 06:32:41 +00:00
{
IMPORTMESHFUN fp = IO::IOConfigure::getMeshImporter(suffix);
2023-05-09 11:00:22 +00:00
if(!fp) {
2023-05-08 06:32:41 +00:00
ModuleBase::Message m;
2023-05-09 11:00:22 +00:00
m.type = Common::Message::Error;
2023-05-08 06:32:41 +00:00
m.message = QString("\"%1\" interface has not been registered !").arg(suffix);
emit _mainWindow->printMessageToMessageWindow(m);
return false;
}
fp(fileName, modelId);
return true;
}
2023-05-09 11:00:22 +00:00
bool SignalHandler::exportMeshSlot(const QString& fileName, const QString& suffix, int modelId)
2023-05-08 06:32:41 +00:00
{
EXPORTMESHFUN fp = IO::IOConfigure::getMeshExporter(suffix);
2023-05-09 11:00:22 +00:00
if(!fp) {
2023-05-08 06:32:41 +00:00
ModuleBase::Message m;
2023-05-09 11:00:22 +00:00
m.type = Common::Message::Error;
2023-05-08 06:32:41 +00:00
m.message = QString("\"%1\" interface has not been registered !").arg(suffix);
emit _mainWindow->printMessageToMessageWindow(m);
return false;
}
fp(fileName, modelId);
// MeshData::MeshData::getInstance()->generateDisplayDataSet();
return true;
}
2023-05-09 11:00:22 +00:00
bool SignalHandler::importGeometry(const QStringList& filenames)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
Command::GeoCommandImport* c = new Command::GeoCommandImport(
_mainWindow, _mainWindow->getSubWindowManager()->getPreWindow());
2023-05-08 06:32:41 +00:00
c->setFileName(filenames);
c->IsRead(true);
bool ok = Command::GeoComandList::getInstance()->executeCommand(c);
// _mainWindow->getSubWindowManager()->setView(-1, "PreWindow", "fit");
return ok;
}
bool SignalHandler::exportGeometry(QString f)
{
2023-05-09 11:00:22 +00:00
Command::GeoCommandImport* c = new Command::GeoCommandImport(
_mainWindow, _mainWindow->getSubWindowManager()->getPreWindow());
2023-05-08 06:32:41 +00:00
c->setExportFile(f);
c->IsRead(false);
bool ok = Command::GeoComandList::getInstance()->executeCommand(c);
return ok;
}
QString SignalHandler::getMD5()
{
QString md5 = "";
2023-05-09 11:00:22 +00:00
QString p = ModelData::ModelDataSingleton::getinstance()->getMD5();
QString g = Geometry::GeometryData::getInstance()->getMD5();
QString m = MeshData::MeshData::getInstance()->getMD5();
md5 = p + g + m;
2023-05-08 06:32:41 +00:00
return md5;
}
void SignalHandler::clearData(bool unlock)
{
_mainWindow->clearWidgets();
ModelData::ModelDataSingleton::getinstance()->clear();
Geometry::GeometryData::getInstance()->clear();
MeshData::MeshData::getInstance()->clear();
Material::MaterialSingleton::getInstance()->clear();
Command::GeoComandList::getInstance()->clearAllCommands();
emit _mainWindow->updateMeshTreeSig();
emit _mainWindow->updateSetTreeSig();
emit _mainWindow->updateGeometryTreeSig();
emit _mainWindow->updatePhysicsTreeSignal();
emit _mainWindow->updateMaterialTreeSig();
2023-05-09 11:00:22 +00:00
if(unlock)
2023-05-08 06:32:41 +00:00
Py::PythonAgent::getInstance()->unLock();
}
void SignalHandler::solveProjectPy(int projectIndex, int solverIndex)
{
2023-05-09 11:00:22 +00:00
ModelData::ModelDataSingleton* modelData = ModelData::ModelDataSingleton::getinstance();
ModelData::ModelDataBase* model = modelData->getModelAt(projectIndex);
const int id = model->getID();
if(_solveProcessManager->isSolving(id)) {
2023-05-08 06:32:41 +00:00
QString name = model->getName();
2023-05-09 11:00:22 +00:00
QMessageBox::warning(_mainWindow, QString(tr("Warning")),
QString(tr("%1 is Solving , Please wait...")).arg(name));
2023-05-08 06:32:41 +00:00
return;
}
2023-05-09 11:00:22 +00:00
QString pycode =
QString("MainWindow.solveProject(%1,%2)").arg(projectIndex).arg(solverIndex);
2023-05-08 06:32:41 +00:00
qDebug() << pycode;
Py::PythonAgent::getInstance()->submit(pycode);
}
void SignalHandler::solveProject(int projectIndex, int solverIndex)
{
2023-05-09 11:00:22 +00:00
ModelData::ModelDataSingleton* modelData = ModelData::ModelDataSingleton::getinstance();
ModelData::ModelDataBase* model = modelData->getModelAt(projectIndex);
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
ConfigOption::SolverOption* solvers =
ConfigOption::ConfigOption::getInstance()->getSolverOption();
ConfigOption::SolverInfo* solver = solvers->getSolverAt(solverIndex);
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
SolverControl::SolverControlBase* solverControl =
new SolverControl::SolverControlBase(_mainWindow, solver, model);
2023-05-08 06:32:41 +00:00
solverControl->setSolverDescription(QString(tr("Solving-%1")).arg(model->getName()));
int id = model->getID();
_solveProcessManager->insertProcess(id, solverControl);
solverControl->startSolver();
// Py::PythonAgent::getInstance()->unLock();
}
void SignalHandler::generateSurfaceMesh()
{
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* prewin = _mainWindow->getSubWindowManager()->getPreWindow();
2023-05-08 06:32:41 +00:00
Gmsh::GmshModule::getInstance(_mainWindow)->exec(1, prewin);
}
void SignalHandler::generateSolidMesh()
{
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* prewin = _mainWindow->getSubWindowManager()->getPreWindow();
2023-05-08 06:32:41 +00:00
Gmsh::GmshModule::getInstance(_mainWindow)->exec(2, prewin);
}
void SignalHandler::generateFluidMesh()
{
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* prewin = _mainWindow->getSubWindowManager()->getPreWindow();
2023-05-08 06:32:41 +00:00
Gmsh::GmshModule::getInstance(_mainWindow)->exec(0, prewin);
}
void SignalHandler::genMesh()
{
2023-05-09 11:00:22 +00:00
DataProperty::DataBase* info = nullptr;
2023-05-08 06:32:41 +00:00
MainWidget::MesherDialog dlg(_mainWindow);
2023-05-09 11:00:22 +00:00
if(dlg.isSingleMesher() || (dlg.exec() == QDialog::Accepted))
2023-05-08 06:32:41 +00:00
info = dlg.getMesherInfo();
else
return;
emit _mainWindow->updateProperty(info);
}
2023-05-09 11:00:22 +00:00
void SignalHandler::appendGeneratedMesh(QString name, vtkDataSet* dataset)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
MeshData::MeshKernal* k = new MeshData::MeshKernal;
2023-05-08 06:32:41 +00:00
k->setName(name);
k->setMeshData(dataset);
MeshData::MeshData::getInstance()->appendMeshKernal(k);
_mainWindow->getSubWindowManager()->updatePreMeshActor();
ModuleBase::Message m;
2023-05-09 11:00:22 +00:00
m.type = Common::Message::Normal;
2023-05-08 06:32:41 +00:00
m.message = tr("Mesh Generated \"%1\"").arg(name);
emit _mainWindow->printMessageToMessageWindow(m);
emit _mainWindow->updateMeshTreeSig();
}
void SignalHandler::updateActionsStates()
{
2023-05-09 11:00:22 +00:00
Ui::MainWindow* ui = _mainWindow->getUi();
SubWindowManager* subwins = _mainWindow->getSubWindowManager();
MeshData::MeshData* meshData = MeshData::MeshData::getInstance();
Geometry::GeometryData* geoData = Geometry::GeometryData::getInstance();
ModelData::ModelDataSingleton* modelData = ModelData::ModelDataSingleton::getinstance();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
// 全部置灰
2023-05-08 06:32:41 +00:00
ui->actionSave->setEnabled(false);
ui->actionSaveAs->setEnabled(false);
ui->actionSolve->setEnabled(false);
ui->actionViewXPlus->setEnabled(false);
ui->actionViewXMinus->setEnabled(false);
ui->actionViewYPlus->setEnabled(false);
ui->actionViewYMinus->setEnabled(false);
ui->actionViewZPlus->setEnabled(false);
ui->actionViewZMinus->setEnabled(false);
ui->actionFitView->setEnabled(false);
ui->actionSelectOff->setEnabled(false);
ui->actionSelectMeshNode->setEnabled(false);
ui->actionSelectMeshCell->setEnabled(false);
ui->actionBoxMeshNode->setEnabled(false);
ui->actionBoxMeshCell->setEnabled(false);
// ui->actionSelectGeoBody->setEnabled(false);
ui->actionGenMesh->setEnabled(false);
ui->actionSurfaceMesh->setEnabled(false);
ui->actionSolidMesh->setEnabled(false);
ui->actionFluidMesh->setEnabled(false);
ui->actionExportMesh->setEnabled(false);
ui->actionExportGeometry->setEnabled(false);
ui->actionSelectOff->setEnabled(false);
ui->actionDisplayNode->setEnabled(false);
ui->actionDisplaySurface->setEnabled(false);
// ui->actionDisplaySurfaceEdge->setEnabled(false);
ui->actionDisplayWireFrame->setEnabled(false);
ui->actionCreate_Set->setEnabled(false);
ui->actionChecking->setEnabled(false);
ui->actionFilterMesh->setEnabled(false);
ui->actionDisplayPoint->setEnabled(false);
ui->actionDisplayCurve->setEnabled(false);
ui->actionDisplayFace->setEnabled(false);
ui->actionSelectPoint->setEnabled(false);
ui->actionSelectCurve->setEnabled(false);
ui->actionSelectFace->setEnabled(false);
ui->actionSelectGeometryBody->setEnabled(false);
ui->actionCreateGeoComponent->setEnabled(false);
ui->actionVTKTranslation->setEnabled(false);
// post
ui->actionOpenPostFile->setEnabled(false);
ui->actionSaveImage->setEnabled(false);
ui->actionSaveVideo->setEnabled(false);
ui->actionDisplayPoints->setEnabled(false);
ui->actionDisplayWireframe->setEnabled(false);
ui->actionDisplaySurfaceWithEdge->setEnabled(false);
ui->actionDisplaySurfaceWithoutEdge->setEnabled(false);
ui->actionCreateClip->setEnabled(false);
ui->actionCreateSlice->setEnabled(false);
ui->actionCreateISOSurface->setEnabled(false);
ui->actionCreateISOCurve->setEnabled(false);
ui->actionCreateVector->setEnabled(false);
ui->actionCreateStreamLine->setEnabled(false);
ui->actionCreateCalculator->setEnabled(false);
ui->actionCreateReflection->setEnabled(false);
2023-05-09 11:00:22 +00:00
// 打开可用Action
const int nMesh = meshData->getKernalCount();
const int ngeo = geoData->getGeometrySetCount();
const int nModel = modelData->getModelCount();
bool needSave = Plugins::PluginManager::getInstance()->hasInfoToSave();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
if(nMesh + ngeo + nModel > 0 || needSave) {
2023-05-08 06:32:41 +00:00
ui->actionSave->setEnabled(true);
ui->actionSaveAs->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
if(nModel > 0 || needSave) {
2023-05-08 06:32:41 +00:00
ui->actionSolve->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
if(subwins->isPreWindowOpened() || subwins->isPostWindowOpened()) {
2023-05-08 06:32:41 +00:00
ui->actionViewXPlus->setEnabled(true);
ui->actionViewXMinus->setEnabled(true);
ui->actionViewYPlus->setEnabled(true);
ui->actionViewYMinus->setEnabled(true);
ui->actionViewZPlus->setEnabled(true);
ui->actionViewZMinus->setEnabled(true);
ui->actionFitView->setEnabled(true);
ui->actionSelectOff->setEnabled(true);
ui->actionSelectMeshNode->setEnabled(true);
ui->actionSelectMeshCell->setEnabled(true);
// ui->actionSelectGeoBody->setEnabled(true);
ui->actionBoxMeshNode->setEnabled(true);
ui->actionBoxMeshCell->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
if(ngeo > 0 && subwins->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
ui->actionSurfaceMesh->setEnabled(true);
ui->actionSolidMesh->setEnabled(true);
ui->actionFluidMesh->setEnabled(true);
ui->actionDisplayPoint->setEnabled(true);
ui->actionDisplayCurve->setEnabled(true);
ui->actionDisplayFace->setEnabled(true);
ui->actionSelectPoint->setEnabled(true);
ui->actionSelectCurve->setEnabled(true);
ui->actionSelectFace->setEnabled(true);
ui->actionSelectGeometryBody->setEnabled(true);
ui->actionCreateGeoComponent->setEnabled(true);
ui->actionExportGeometry->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
if(nMesh > 0 && subwins->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
ui->actionFilterMesh->setEnabled(true);
ui->actionCreate_Set->setEnabled(true);
ui->actionChecking->setEnabled(true);
ui->actionExportMesh->setEnabled(true);
ui->actionDisplayNode->setEnabled(true);
ui->actionDisplaySurface->setEnabled(true);
// ui->actionDisplaySurfaceEdge->setEnabled(true);
ui->actionDisplayWireFrame->setEnabled(true);
ui->actionVTKTranslation->setEnabled(true);
auto gp = Setting::BusAPI::instance()->getGraphOption();
ui->actionDisplayNode->setChecked(gp->isShowMeshNode());
ui->actionDisplaySurface->setChecked(gp->isShowMeshFace());
ui->actionDisplayWireFrame->setChecked(gp->isShowMeshEdge());
}
2023-05-09 11:00:22 +00:00
if(subwins->isPostWindowOpened()) {
2023-05-08 06:32:41 +00:00
ui->actionViewXPlus->setEnabled(true);
ui->actionViewXMinus->setEnabled(true);
ui->actionViewYPlus->setEnabled(true);
ui->actionViewYMinus->setEnabled(true);
ui->actionViewZPlus->setEnabled(true);
ui->actionViewZMinus->setEnabled(true);
ui->actionFitView->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
if(subwins->isPostWindowOpening()) {
2023-05-08 06:32:41 +00:00
ui->actionOpenPostFile->setEnabled(true);
ui->actionSaveImage->setEnabled(true);
ui->actionSaveVideo->setEnabled(true);
ui->actionDisplayPoints->setEnabled(true);
ui->actionDisplayWireframe->setEnabled(true);
ui->actionDisplaySurfaceWithEdge->setEnabled(true);
ui->actionDisplaySurfaceWithoutEdge->setEnabled(true);
ui->actionCreateClip->setEnabled(true);
ui->actionCreateSlice->setEnabled(true);
ui->actionCreateISOSurface->setEnabled(true);
ui->actionCreateISOCurve->setEnabled(true);
ui->actionCreateVector->setEnabled(true);
ui->actionCreateStreamLine->setEnabled(true);
ui->actionCreateCalculator->setEnabled(true);
ui->actionCreateReflection->setEnabled(true);
}
2023-05-09 11:00:22 +00:00
const int n =
ConfigOption::ConfigOption::getInstance()->getSolverOption()->getSolverCount();
if(n > 0)
2023-05-08 06:32:41 +00:00
ui->actionGenMesh->setEnabled(true);
// bool showGuidence = Setting::BusAPI::instance()->isEnableUserGuidence();
}
2023-05-09 11:00:22 +00:00
void SignalHandler::updatePostActionStates() {}
2023-05-08 06:32:41 +00:00
void SignalHandler::open2DPlotWindow()
{
QString pycode = QString("MainWindow.openPost2D()");
Py::PythonAgent::getInstance()->submit(pycode);
}
void SignalHandler::open3DGraphWindow()
{
QString pycode = QString("MainWindow.openPost3D()");
Py::PythonAgent::getInstance()->submit(pycode);
}
void SignalHandler::open2DPlotWindowPy()
{
// QString pycode = QString("MainWindow.openNew2d()");
// Py::PythonAgent::getInstance()->submit(pycode);
2023-05-09 11:00:22 +00:00
QAction* act = _mainWindow->getUi()->action2DPlot;
if(!act->isEnabled())
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post2DWindowInterface* p2w = new Post::Post2DWindowInterface(_mainWindow, -1);
2023-05-08 06:32:41 +00:00
p2w->reTranslate();
emit _mainWindow->openPostWindowSig(p2w);
emit _mainWindow->updateActionStatesSig();
act->setEnabled(false);
}
void SignalHandler::open3DGraphWindowPy()
{
2023-05-09 11:00:22 +00:00
QAction* act = _mainWindow->getUi()->action3DGraph;
if(!act->isEnabled())
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* post3d = new Post::Post3DWindowInterface(_mainWindow, -1);
2023-05-08 06:32:41 +00:00
post3d->reTranslate();
// Post::PostProcessPy::init(_mainWindow->getControlPanel()->getPostTreeWidget());
emit _mainWindow->openPostWindowSig(post3d);
emit _mainWindow->updateActionStatesSig();
act->setEnabled(false);
}
2023-05-09 11:00:22 +00:00
void SignalHandler::closePostWindow(Post::PostWindowBase* p)
2023-05-08 06:32:41 +00:00
{
int id = p->getID();
2023-05-09 11:00:22 +00:00
if(id != -1)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
if(p->getPostWindowType() == Post::D2)
2023-05-08 06:32:41 +00:00
_mainWindow->getUi()->action2DPlot->setEnabled(true);
2023-05-09 11:00:22 +00:00
else if(p->getPostWindowType() == Post::D3)
2023-05-08 06:32:41 +00:00
_mainWindow->getUi()->action3DGraph->setEnabled(true);
}
void SignalHandler::saveImange()
{
2023-05-09 11:00:22 +00:00
MainWidget::SavePictureDialog d(_mainWindow,
_mainWindow->getSubWindowManager()->getCurrentWindow());
2023-05-08 06:32:41 +00:00
d.exec();
}
void SignalHandler::meshChecking()
{
MainWidget::MeshCheckingDialog dlg(_mainWindow);
dlg.exec();
}
void SignalHandler::showUserGuidence(bool start)
{
2023-05-09 11:00:22 +00:00
bool show = false;
QAction* ac = _mainWindow->getUi()->actionUser_Guidance;
bool inis = Setting::BusAPI::instance()->isEnableUserGuidence();
if(start) {
2023-05-08 06:32:41 +00:00
show = inis;
ac->setChecked(inis);
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
bool che = ac->isChecked();
2023-05-09 11:00:22 +00:00
show = che;
2023-05-08 06:32:41 +00:00
Setting::BusAPI::instance()->isEnableUserGuidence(show);
}
2023-05-09 11:00:22 +00:00
if(!show)
2023-05-08 06:32:41 +00:00
return;
/*
if (!_launched) _launched = true;
else return;
*/
auto dlg = new Guidence::UserGuidenceDialog(_mainWindow, ac);
dlg->show();
}
void SignalHandler::undo()
{
QString pycode = QString("MainWindow.undo()");
Py::PythonAgent::getInstance()->submit(pycode);
// Command::GeoComandList::getInstance()->undo();
}
void SignalHandler::redo()
{
QString pycode = QString("MainWindow.redo()");
Py::PythonAgent::getInstance()->submit(pycode);
// Command::GeoComandList::getInstance()->redo();
}
void SignalHandler::createBox()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateBoxDialog* dlg = new GeometryWidget::CreateBoxDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::createCylinder()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateCylinderDialog* dlg =
new GeometryWidget::CreateCylinderDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateCone()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateConeDialog* dlg =
new GeometryWidget::CreateConeDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateSphere()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateSphereDialog* dlg =
new GeometryWidget::CreateSphereDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateFilet()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateFiletDialog* dlg =
new GeometryWidget::CreateFiletDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateChamfer()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateChamferDialog* dlg =
new GeometryWidget::CreateChamferDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateBoolCut()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::BoolOpertionDialog* dlg =
new GeometryWidget::BoolOpertionDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
dlg->setType(BoolCut);
this->showDialog(dlg);
}
void SignalHandler::CreateBoolFause()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::BoolOpertionDialog* dlg =
new GeometryWidget::BoolOpertionDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
dlg->setType(BoolFause);
this->showDialog(dlg);
}
void SignalHandler::CreateBoolCommon()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::BoolOpertionDialog* dlg =
new GeometryWidget::BoolOpertionDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
dlg->setType(BoolCommon);
this->showDialog(dlg);
}
void SignalHandler::MirrorFeature()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::MirorFeatureDialog* dlg =
new GeometryWidget::MirorFeatureDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateExtrusion()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateExtrusionDialog* dlg =
new GeometryWidget::CreateExtrusionDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateVariableFillet()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::VariableFilletDialog* dlg =
new GeometryWidget::VariableFilletDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreatePoint()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreatePointDialog* dlg =
new GeometryWidget::CreatePointDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateEdge()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateLineDialog* dlg =
new GeometryWidget::CreateLineDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateFace()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened())
2023-05-08 06:32:41 +00:00
this->openPreWinPy();
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateFaceDialog* dlg =
new GeometryWidget::CreateFaceDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::MoveFeature()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
auto dlg = new GeometryWidget::MoveFeatureDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::RotateFeature()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
auto dlg = new GeometryWidget::RotateFeatureDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateLoft()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateLoftDialog* dlg =
new GeometryWidget::CreateLoftDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::CreateSweep()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::SweepDialog* dlg = new GeometryWidget::SweepDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
/*void SignalHandler::CreateCylindricalComplex()
{
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if (!sw->isPreWindowOpened())
this->openPreWinPy();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateCylindricalComplexDialog* dlg = new
GeometryWidget::CreateCylindricalComplexDialog(_mainWindow, p); this->showDialog(dlg);
2023-05-08 06:32:41 +00:00
}
void SignalHandler::CreateBoxComplex()
{
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if (!sw->isPreWindowOpened())
this->openPreWinPy();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-09 11:00:22 +00:00
GeometryWidget::CreateBoxComplexDialog* dlg = new
GeometryWidget::CreateBoxComplexDialog(_mainWindow, p); this->showDialog(dlg);
2023-05-08 06:32:41 +00:00
}*/
void SignalHandler::CreateDatumplane()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateDatumplaneDialog* dlg =
new GeometryWidget::CreateDatumplaneDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::DrawGraphicsLine()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
// QAction* action = _mainWindow->getUi()->actionDrawLine;
// if (action->isChecked())
p->setSketchType(ModuleBase::SketchLine);
// else
// p->setSketchType(ModuleBase::SketchNone);
}
void SignalHandler::DrawGraphicsRectangle()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
// QAction* action = _mainWindow->getUi()->actionDrawRectangle;
// if (action->isChecked())
p->setSketchType(ModuleBase::SketchRect);
// else
// p->setSketchType(ModuleBase::SketchNone);
}
void SignalHandler::DrawGraphicsCircle()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
// QAction* action = _mainWindow->getUi()->actionDrawCircle;
// if (action->isChecked())
p->setSketchType(ModuleBase::SketchCircle);
// else
// p->setSketchType(ModuleBase::SketchNone);
}
void SignalHandler::DrawGraphicsArc()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
// QAction* action = _mainWindow->getUi()->actionDrawArc;
// bool l = action->isChecked();
// if (action->isChecked())
p->setSketchType(ModuleBase::SketchArc);
// else
// p->setSketchType(ModuleBase::SketchNone);
}
void SignalHandler::DrawGraphicsPolyline()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
p->setSketchType(ModuleBase::SketchPolyline);
}
void SignalHandler::DrawGraphSpline()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
MainWidget::PreWindow* p = sw->getPreWindow();
2023-05-08 06:32:41 +00:00
p->setSketchType(ModuleBase::SketchSpline);
}
void SignalHandler::CreateRevol()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::CreateRevolDialog* dlg =
new GeometryWidget::CreateRevolDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
2023-05-09 11:00:22 +00:00
void SignalHandler::showDialog(QDialog* d)
2023-05-08 06:32:41 +00:00
{
int mx = _mainWindow->pos().x();
int my = _mainWindow->pos().y();
d->move(mx + 20, my + 70);
d->show();
}
void SignalHandler::MakeMatrix()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::MakeMatrixDialog* dlg =
new GeometryWidget::MakeMatrixDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::MeasureDistance()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::MeasureDistanceDialog* dlg =
new GeometryWidget::MeasureDistanceDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::GeoSplitter()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::GeoSplitterDialog* dlg =
new GeometryWidget::GeoSplitterDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::MakeFillHole()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::MakeFillHoleDialog* dlg =
new GeometryWidget::MakeFillHoleDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::MakeRemoveSurface()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::MakeRemoveSurfaceDialog* dlg =
new GeometryWidget::MakeRemoveSurfaceDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::MakeFillGap()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
GeometryWidget::MakeFillGapDialog* dlg =
new GeometryWidget::MakeFillGapDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::openPostFile()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
const int id = gw->getID();
const QString type = gw->getStringGraphWindowType();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
FileDirectoryDialog dlg;
2023-05-09 11:00:22 +00:00
QStringList filterTypes = { "VTK(*.vtk)", "CGNS(*.cgns)", "Plot3D(*.x)",
"Tecplot(*.szplt)" };
2023-05-08 06:32:41 +00:00
dlg.iniFileFilterType(filterTypes);
2023-05-09 11:00:22 +00:00
if(dlg.exec() != QDialog::Accepted)
2023-05-08 06:32:41 +00:00
return;
QString files = dlg.getCurrentFullPath();
2023-05-09 11:00:22 +00:00
if(files.isEmpty())
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
QString pycode =
QString("PostProcess.openPostFile(%1,'%2','%3')").arg(id).arg(type).arg(files);
2023-05-08 06:32:41 +00:00
Py::PythonAgent::getInstance()->submit(pycode);
// pWindow->openFile(files);
2023-05-09 11:00:22 +00:00
// QString pycode =
// QString("MainWindow.openPostFile(%1,%2,%3)").arg(id).arg(type).arg(files);
2023-05-08 06:32:41 +00:00
// Py::PythonAgent::getInstance()->submit(pycode);
}
void SignalHandler::openPlotFile()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
const int id = gw->getID();
const QString type = gw->getStringGraphWindowType();
2023-05-08 06:32:41 +00:00
/*
FileDirectoryDialog dlg;
dlg.iniFileFilterType("Support Files(*.dat)");
if (dlg.exec() != QDialog::Accepted) return;
QString files = dlg.getCurrentFullPath();
*/
2023-05-09 11:00:22 +00:00
QString files = QFileDialog::getOpenFileName(_mainWindow, tr("open file"), " ",
tr("dat(*.dat);;Allfile(*.*)"));
if(files.isEmpty())
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post2DWindowInterface* pInterface = dynamic_cast<Post::Post2DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post2DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
pWindow->openFile(files);
}
void SignalHandler::setPostDisplayMode(int type)
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
QString pycode = QString("PostProcess.setDisplayMode(%1,%2)").arg(gw->getID()).arg(type);
Py::PythonAgent::getInstance()->submit(pycode);
/*pWindow->setDisplayMode(type);*/
}
void SignalHandler::createPostVector()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateVectorDialog* dlg = new Post::CreateVectorDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
// pWindow->setDisplayMode(type);
}
void SignalHandler::createPostClip()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateClipDialog* dlg = new Post::CreateClipDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), true, _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostSlice()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateClipDialog* dlg = new Post::CreateClipDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), false, _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostStreamLine()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateStreamLineDialog* dlg = new Post::CreateStreamLineDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostISOSurface()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateISODialog* dlg = new Post::CreateISODialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), true, _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostISOCurve()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateISODialog* dlg = new Post::CreateISODialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), false, _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostCalculator()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateCalculateDialog* dlg = new Post::CreateCalculateDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::createPostReflection()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::CreateReflectionDialog* dlg = new Post::CreateReflectionDialog(
_mainWindow->getControlPanel()->getPostTreeWidget(), _mainWindow);
2023-05-08 06:32:41 +00:00
dlg->show();
}
void SignalHandler::savePostPicture()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
QString fileName = QFileDialog::getSaveFileName(
_mainWindow, tr("Select File."), qApp->applicationDirPath(),
"PNG files(*.png);;BMP files(*.bmp);;JPG files(*.jpg)");
2023-05-08 06:32:41 +00:00
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("PostProcess.savePostImage(%1,'%2')").arg(gw->getID()).arg(fileName);
2023-05-08 06:32:41 +00:00
Py::PythonAgent::getInstance()->submit(pycode);
// pWindow->saveImage(fileName);
}
void SignalHandler::savePostAnimation()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
ModuleBase::GraphWindowBase* gw = sw->getCurrentWindow();
if(gw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindowInterface* pInterface = dynamic_cast<Post::Post3DWindowInterface*>(gw);
if(pInterface == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
Post::Post3DWindow* pWindow = pInterface->getWindow();
if(pWindow == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
auto tree = _mainWindow->getControlPanel()->getPostTreeWidget();
auto obj = tree->getCurrentRenderData();
auto unSteady = dynamic_cast<Post::RenderDataImportUnSteady*>(obj);
if(unSteady == nullptr)
2023-05-08 06:32:41 +00:00
return;
Post::SaveAnimationDialog dlg(_mainWindow->getAnimationToolBar(), _mainWindow);
2023-05-09 11:00:22 +00:00
if(dlg.exec() == QDialog::Accepted) {
2023-05-08 06:32:41 +00:00
QString file;
2023-05-09 11:00:22 +00:00
int id = -1, fps = -1;
2023-05-08 06:32:41 +00:00
dlg.getAnimationInfo(id, file, fps);
2023-05-09 11:00:22 +00:00
QString code =
QString("PostProcess.savePostAnimation(%1,'%2',%3)").arg(id).arg(file).arg(fps);
2023-05-08 06:32:41 +00:00
Py::PythonAgent::getInstance()->submit(code);
}
}
void SignalHandler::GeoMeshRotate()
{
2023-05-09 11:00:22 +00:00
SubWindowManager* sw = _mainWindow->getSubWindowManager();
if(!sw->isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
QMessageBox::warning(_mainWindow, tr("Warning"), tr("Open PreWindow First!"));
return;
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* p = sw->getPreWindow();
MainWidget::GeoMeshRotateDialog* dlg = new MainWidget::GeoMeshRotateDialog(_mainWindow, p);
2023-05-08 06:32:41 +00:00
this->showDialog(dlg);
}
void SignalHandler::openPreWinPy()
{
QString pycode = QString("MainWindow.openPreWindow()");
Py::PythonAgent::getInstance()->submit(pycode);
}
2023-05-09 11:00:22 +00:00
} // namespace GUI