LAMPCAE/src/MainWindow/SubWindowManager.cpp

690 lines
20 KiB
C++
Raw Normal View History

2023-05-08 06:32:41 +00:00
#include "SubWindowManager.h"
2023-05-09 11:00:22 +00:00
#include "Common/Types.h"
#include "Geometry/geometryData.h"
#include "GeometryCommand/GeoCommandPy.h"
2023-05-08 06:32:41 +00:00
#include "MainWidgets/ControlPanel.h"
2023-05-09 11:00:22 +00:00
#include "MainWidgets/preWindow.h"
#include "MainWindow.h"
2023-05-08 06:32:41 +00:00
#include "MeshData/meshSingleton.h"
2023-05-09 11:00:22 +00:00
#include "ModuleBase/graphWindowBase.h"
#include "PostInterface/PostProcessPy.h"
2023-05-08 06:32:41 +00:00
#include "PostWidgets/PostWindowBase.h"
#include "PostWidgets/RealTimeWindowBase.h"
#include "PythonModule/PyAgent.h"
#include "SARibbonBar/SARibbonBar.h"
2023-05-09 11:00:22 +00:00
#include "SARibbonMWUi.h"
#include "SignalHandler.h"
#include "XGenerateReport/ReportWindow.h"
2023-05-08 06:32:41 +00:00
#include <assert.h>
2023-05-09 11:00:22 +00:00
#include <QDebug>
#include <QList>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QToolBar>
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
namespace GUI {
SubWindowManager::SubWindowManager(MainWindow* mainwindow, QMdiArea* mdiArea,
SignalHandler* hander, MainWidget::ControlPanel* cp)
: _mainWindow(mainwindow)
, _mdiArea(mdiArea)
, _signalHander(hander)
, _controlPanel(cp)
2023-05-08 06:32:41 +00:00
{
connect(mainwindow, SIGNAL(closePreWindowSig()), this, SLOT(closePreWindow()));
2023-05-09 11:00:22 +00:00
connect(mainwindow, SIGNAL(openPostWindowSig(Post::PostWindowBase*)), this,
SLOT(openPostWindow(Post::PostWindowBase*)));
connect(mainwindow, SIGNAL(openRealTimeWindowSig(Post::RealTimeWindowBase*, int)), this,
SLOT(openRealTimeWindow(Post::RealTimeWindowBase*)));
connect(mainwindow, SIGNAL(showPostWindowInfoSig(int, int)), this,
SLOT(showPostWindowInfo(int, int)));
connect(mainwindow, SIGNAL(closePostWindowSig(Post::PostWindowBase*)), this,
SLOT(closePostWindow(Post::PostWindowBase*)));
connect(_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this,
SLOT(subWindowActived(QMdiSubWindow*)));
connect(mainwindow, SIGNAL(closeRealTimeWindowSig(Post::RealTimeWindowBase*)), this,
SLOT(closeRealTimeWindow(Post::RealTimeWindowBase*)));
connect(mainwindow, SIGNAL(openReportWindowSig(XReport::ReportWindow*)), this,
SLOT(openReportWindow(XReport::ReportWindow*)));
connect(mainwindow, SIGNAL(closeReportWindowSig(XReport::ReportWindow*)), this,
SLOT(closeReportWindow(XReport::ReportWindow*)));
connect(mainwindow, SIGNAL(saveImageSig(QString, int, Post::PostWindowBase*, int, int)),
this, SLOT(saveImage(QString, int, Post::PostWindowBase*, int, int)));
connect(mainwindow, SIGNAL(saveImage(int, int, QString)), this,
SLOT(saveImage(int, int, QString)));
connect(this, SIGNAL(setViewSig(int, QString, QString)), this,
SLOT(setView(int, QString, QString)));
connect(this,
SIGNAL(setViewValueSig(int, QString, int, int, int, int, int, int, int, int, int)),
this,
SLOT(setViewValue(int, QString, int, int, int, int, int, int, int, int, int)));
connect(this, SIGNAL(saveImageSig(int, int, int, QString, QString)), this,
SLOT(saveImage(int, int, int, QString, QString)));
2023-05-08 06:32:41 +00:00
connect(this, SIGNAL(openPreWindowSig()), this, SLOT(openPreWindow()));
}
2023-05-09 11:00:22 +00:00
SubWindowManager::~SubWindowManager() {}
2023-05-08 06:32:41 +00:00
void SubWindowManager::openPreWindow()
{
2023-05-09 11:00:22 +00:00
if(isPreWindowOpened()) {
2023-05-08 06:32:41 +00:00
Py::PythonAgent::getInstance()->unLock();
return;
}
2023-05-09 11:00:22 +00:00
if(_preWindow.first == nullptr || _preWindow.second == nullptr) {
2023-05-08 06:32:41 +00:00
_preWindow.second = new MainWidget::PreWindow(_mainWindow);
2023-05-09 11:00:22 +00:00
_preWindow.first = _mdiArea->addSubWindow(_preWindow.second);
2023-05-08 06:32:41 +00:00
_signalHander->updateActionsStates();
Command::GeometryCommandPy::init(_mainWindow, _preWindow.second);
}
// else
updatePreActors();
_preWindow.first->showMaximized();
_preWindow.first->setFocus();
_mdiArea->setActiveSubWindow(_preWindow.first);
_mainWindow->getUi()->actionPre_Window->setEnabled(false);
emit _mainWindow->preWindowOpenedSig(_preWindow.second);
Py::PythonAgent::getInstance()->unLock();
}
void SubWindowManager::openGeometryWindow()
{
// if (_geometryWindow.first == nullptr || _geometryWindow.second == nullptr)
//{
// _geometryWindow.second = new GenerateGeometry::GenerateGeometryWidget(_mainWindow);
// _geometryWindow.first = _mdiArea->addSubWindow(_geometryWindow.second);
// }
//_preWindow.first->showMaximized();
//_preWindow.first->setFocus();
}
2023-05-09 11:00:22 +00:00
QMdiArea* SubWindowManager::getMdiArea() const
2023-05-08 06:32:41 +00:00
{
return _mdiArea;
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::add3dRenderPage(const QList<QToolBar*>& toolbars)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if(_threeD_render_page || toolbars.size() != 4)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
QList<QAction*> actions;
QAction* action{};
SARibbonBar* ribbon = _mainWindow->ribbonBar();
_threeD_render_page = ribbon->addCategoryPage(QObject::tr("3D Render"));
SARibbonPannel* pannel0 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar0 = toolbars.at(0);
actions = toolbar0->actions();
for(int j = 0; j < actions.size(); j++) {
2023-05-08 06:32:41 +00:00
action = actions.at(j);
pannel0->addLargeAction(action);
}
2023-05-09 11:00:22 +00:00
SARibbonPannel* pannel2 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar2 = toolbars.at(2);
actions = toolbar2->actions();
for(int j = 0; j < actions.size(); j++) {
2023-05-08 06:32:41 +00:00
action = actions.at(j);
pannel2->addLargeAction(action);
}
2023-05-09 11:00:22 +00:00
SARibbonPannel* pannel3 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar3 = toolbars.at(3);
actions = toolbar3->actions();
for(int j = 0; j < actions.size(); j++) {
2023-05-08 06:32:41 +00:00
action = actions.at(j);
pannel3->addLargeAction(action);
}
2023-05-09 11:00:22 +00:00
SARibbonPannel* pannel1 = _threeD_render_page->addPannel(QString());
QToolBar* toolbar1 = toolbars.at(1);
actions = toolbar1->actions();
QList<QAction*> realActions;
QList<QWidget*> comboxs;
QWidget* widget{};
for(int j = 0; j < actions.size(); j++) {
2023-05-08 06:32:41 +00:00
action = actions.at(j);
2023-05-09 11:00:22 +00:00
if(action->objectName() == "QComboBox") {
2023-05-08 06:32:41 +00:00
widget = toolbar1->widgetForAction(action);
widget->setVisible(true);
comboxs.append(widget);
2023-05-09 11:00:22 +00:00
} else if(action->objectName() == "QAction")
2023-05-08 06:32:41 +00:00
realActions.append(action);
}
2023-05-09 11:00:22 +00:00
if(realActions.size() != 4 && comboxs.size() != 3)
2023-05-08 06:32:41 +00:00
return;
pannel1->addLargeAction(realActions.at(0));
pannel1->addLargeAction(realActions.at(1));
pannel1->addLargeAction(realActions.at(2));
pannel1->addLargeAction(realActions.at(3));
pannel1->addSmallWidget(comboxs.at(0));
pannel1->addSmallWidget(comboxs.at(1));
pannel1->addLargeWidget(comboxs.at(2));
// modify
/*
int index = ribbon->tabIndex(_threeD_render_page);
ribbon->setCurrentIndex(index);
ribbon->onCurrentRibbonTabChanged(index);
*/
ribbon->raiseCategory(_threeD_render_page);
}
void SubWindowManager::remove3dRenderPage()
{
2023-05-09 11:00:22 +00:00
if(_threeD_render_page == nullptr)
2023-05-08 06:32:41 +00:00
return;
auto pannels = _threeD_render_page->pannelList();
2023-05-09 11:00:22 +00:00
for(SARibbonPannel* pannel : pannels) {
2023-05-08 06:32:41 +00:00
_threeD_render_page->removePannel(pannel);
pannel = nullptr;
}
2023-05-09 11:00:22 +00:00
SARibbonBar* ribbon = _mainWindow->ribbonBar();
2023-05-08 06:32:41 +00:00
ribbon->removeCategory(_threeD_render_page);
_threeD_render_page = nullptr;
ribbon->setCurrentIndex(4);
// ribbon->onCurrentRibbonTabChanged(4);
}
void SubWindowManager::updatePreActors()
{
updatePreGeometryActor();
updatePreMeshActor();
}
void SubWindowManager::updatePreMeshActor()
{
2023-05-09 11:00:22 +00:00
if(_preWindow.second != nullptr) {
2023-05-08 06:32:41 +00:00
emit _preWindow.second->updateMeshActorSig();
}
}
void SubWindowManager::updatePreGeometryActor()
{
2023-05-09 11:00:22 +00:00
if(_preWindow.second != nullptr) {
2023-05-08 06:32:41 +00:00
_preWindow.second->updateGeometryActor();
}
}
void SubWindowManager::closePreWindow()
{
2023-05-09 11:00:22 +00:00
_preWindow.first = nullptr;
2023-05-08 06:32:41 +00:00
_preWindow.second = nullptr;
_mainWindow->getUi()->actionPre_Window->setEnabled(true);
emit _mainWindow->updateGeometryTreeSig();
emit _mainWindow->updateMeshTreeSig();
emit _mainWindow->updateSetTreeSig();
emit _mainWindow->updatePhysicsTreeSignal();
emit _mainWindow->updateProperty(nullptr);
emit _mainWindow->updateActionStatesSig();
// _signalHander->clearData();
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::openPostWindow(Post::PostWindowBase* pw)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if(pw == nullptr) {
2023-05-08 06:32:41 +00:00
assert(0);
return;
}
2023-05-09 11:00:22 +00:00
QMdiSubWindow* sw = nullptr;
QList<Post::PostWindowBase*> pwl = _postWindow.values();
if(pwl.contains(pw)) {
2023-05-08 06:32:41 +00:00
sw = _postWindow.key(pw);
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
sw = _mdiArea->addSubWindow(pw);
_mdiArea->cascadeSubWindows();
_postWindow[sw] = pw;
}
2023-05-09 11:00:22 +00:00
if(sw != nullptr) {
2023-05-08 06:32:41 +00:00
sw->activateWindow();
sw->showMaximized();
sw->setFocus();
}
Post::PostProcessPy::init(_mainWindow, _mainWindow->getControlPanel()->getPostTreeWidget());
Py::PythonAgent::getInstance()->unLock();
emit _mainWindow->updateActionStatesSig();
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::openRealTimeWindow(Post::RealTimeWindowBase* pw)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* sw = nullptr;
QList<Post::RealTimeWindowBase*> pwl = _realTimeWindow.values();
if(pwl.contains(pw)) {
2023-05-08 06:32:41 +00:00
sw = _realTimeWindow.key(pw);
2023-05-09 11:00:22 +00:00
} else {
sw = _mdiArea->addSubWindow(pw);
2023-05-08 06:32:41 +00:00
_realTimeWindow[sw] = pw;
}
2023-05-09 11:00:22 +00:00
if(sw != nullptr) {
2023-05-08 06:32:41 +00:00
sw->showMaximized();
sw->setFocus();
}
emit _mainWindow->updateActionStatesSig();
}
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* SubWindowManager::getCurrentWindow()
2023-05-08 06:32:41 +00:00
{
QMdiSubWindow* activeWindow = nullptr;
2023-05-09 11:00:22 +00:00
auto subWins = _mdiArea->subWindowList();
2023-05-08 06:32:41 +00:00
if(subWins.size() == 1) {
activeWindow = subWins.at(0);
} else {
activeWindow = _mdiArea->activeSubWindow();
}
2023-05-09 11:00:22 +00:00
if(activeWindow == nullptr)
2023-05-08 06:32:41 +00:00
return nullptr;
2023-05-09 11:00:22 +00:00
else if(activeWindow == _preWindow.first)
2023-05-08 06:32:41 +00:00
return _preWindow.second;
2023-05-09 11:00:22 +00:00
else if(_postWindow.contains(activeWindow))
2023-05-08 06:32:41 +00:00
return _postWindow[activeWindow];
else
return nullptr;
}
2023-05-09 11:00:22 +00:00
Post::PostWindowBase* SubWindowManager::getPostWindowByIDType(int id, int type)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QList<Post::PostWindowBase*> pwl = _postWindow.values();
for(int i = 0; i < pwl.size(); ++i) {
Post::PostWindowBase* w = pwl.at(i);
if(w == nullptr)
2023-05-08 06:32:41 +00:00
continue;
2023-05-09 11:00:22 +00:00
int wid = w->getID();
2023-05-08 06:32:41 +00:00
int wtype = (int)w->getPostWindowType();
2023-05-09 11:00:22 +00:00
if(wid == id && wtype == type)
2023-05-08 06:32:41 +00:00
return w;
}
return nullptr;
}
void SubWindowManager::removeToolBars()
{
const int n = _currentToolBars.size();
2023-05-09 11:00:22 +00:00
for(int i = 0; i < n; ++i) {
QToolBar* t = _currentToolBars.at(i);
2023-05-08 06:32:41 +00:00
_mainWindow->removeToolBar(t);
}
_currentToolBars.clear();
}
void SubWindowManager::showPostWindowInfo(int id, int type)
{
2023-05-09 11:00:22 +00:00
Post::PostWindowBase* pwb = getPostWindowByIDType(id, type);
if(pwb == nullptr)
2023-05-08 06:32:41 +00:00
return;
// QWidget* ptree = pwb->getTreeWidget();
// QWidget* pprop = pwb->getPropWidget();
2023-05-09 11:00:22 +00:00
QMdiSubWindow* subWin = _postWindow.key(pwb);
if(subWin != nullptr) {
2023-05-08 06:32:41 +00:00
subWin->showMaximized();
subWin->setFocus();
}
//_controlPanel->updatePostWidget(ptree, pprop);
2023-05-09 11:00:22 +00:00
if(type == 2)
2023-05-08 06:32:41 +00:00
_controlPanel->updatePostWidget();
2023-05-09 11:00:22 +00:00
QList<QToolBar*> toolBars = pwb->getToolBarList();
if(_mainWindow->isUseRibbon()) {
if(_threeD_render_page)
2023-05-08 06:32:41 +00:00
return;
add3dRenderPage(toolBars);
2023-05-09 11:00:22 +00:00
} else {
2023-05-08 06:32:41 +00:00
this->removeToolBars();
_mainWindow->addToolBarBreak();
2023-05-09 11:00:22 +00:00
for(int i = 0; i < toolBars.size(); ++i) {
2023-05-08 06:32:41 +00:00
_mainWindow->addToolBar(toolBars.at(i));
(toolBars.at(i))->show();
_currentToolBars.append(toolBars.at(i));
}
}
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::closePostWindow(Post::PostWindowBase* w)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* subw = _postWindow.key(w);
if(subw == nullptr)
2023-05-08 06:32:41 +00:00
return;
Post::PostWindowType type = w->getPostWindowType();
removeToolBars();
2023-05-09 11:00:22 +00:00
if(type == Post::PostWindowType::D3
&& _mainWindow->isUseRibbon()) // 使用ribbon并且关闭的是3维窗口
2023-05-08 06:32:41 +00:00
remove3dRenderPage();
2023-05-09 11:00:22 +00:00
if(_controlPanel != nullptr)
2023-05-08 06:32:41 +00:00
_controlPanel->updatePostWidget(nullptr, nullptr);
emit _mainWindow->updateProperty(nullptr);
_postWindow.remove(subw);
2023-05-09 11:00:22 +00:00
QList<Post::PostWindowBase*> postsubwlist = _postWindow.values();
if(_preWindow.first != nullptr)
2023-05-08 06:32:41 +00:00
showPreWindow();
2023-05-09 11:00:22 +00:00
else if(postsubwlist.size() > 0) {
Post::PostWindowBase* w = postsubwlist.at(0);
int id = w->getID();
Post::PostWindowType type = w->getPostWindowType();
2023-05-08 06:32:41 +00:00
showPostWindowInfo(id, type);
}
emit _mainWindow->updateActionStatesSig();
}
void SubWindowManager::showPreWindow()
{
removeToolBars();
2023-05-09 11:00:22 +00:00
if(_controlPanel == nullptr)
2023-05-08 06:32:41 +00:00
return;
_controlPanel->updatePostWidget(nullptr, nullptr);
2023-05-09 11:00:22 +00:00
if(_preWindow.first != nullptr) {
2023-05-08 06:32:41 +00:00
_preWindow.first->showMaximized();
_preWindow.first->setFocus();
}
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::showRealTimeWindow(QMdiSubWindow* w)
2023-05-08 06:32:41 +00:00
{
removeToolBars();
_controlPanel->updatePostWidget(nullptr, nullptr);
2023-05-09 11:00:22 +00:00
if(_realTimeWindow.contains(w)) {
2023-05-08 06:32:41 +00:00
w->showMaximized();
w->setFocus();
}
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::subWindowActived(QMdiSubWindow* sw)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if(sw == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
if(sw == _preWindow.first)
2023-05-08 06:32:41 +00:00
showPreWindow();
2023-05-09 11:00:22 +00:00
else if(_realTimeWindow.contains(sw))
2023-05-08 06:32:41 +00:00
showRealTimeWindow(sw);
2023-05-09 11:00:22 +00:00
else if(_postWindow.contains(sw)) {
Post::PostWindowBase* pwb = _postWindow.value(sw);
int id = pwb->getID();
Post::PostWindowType type = pwb->getPostWindowType();
2023-05-08 06:32:41 +00:00
showPostWindowInfo(id, type);
}
emit _mainWindow->updateActionStatesSig();
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::closeRealTimeWindow(Post::RealTimeWindowBase* w)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* subw = _realTimeWindow.key(w);
if(subw == nullptr)
2023-05-08 06:32:41 +00:00
return;
_realTimeWindow.remove(subw);
2023-05-09 11:00:22 +00:00
if(_preWindow.first != nullptr)
2023-05-08 06:32:41 +00:00
showPreWindow();
emit _mainWindow->updateActionStatesSig();
}
void SubWindowManager::setView(QString view)
{
/*qDebug() << view;
ModuleBase::GraphWindowBase* gwb = getCurrentWindow();
if (gwb == nullptr) return;
gwb->setView(view);*/
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* gwb = getCurrentWindow();
if(gwb == nullptr)
2023-05-08 06:32:41 +00:00
return;
2023-05-09 11:00:22 +00:00
const int id = gwb->getID();
QString win = gwb->getStringGraphWindowType();
2023-05-08 06:32:41 +00:00
qDebug() << win;
QString pycode = QString("MainWindow.setView(%1,\"%2\",\"%3\")").arg(id).arg(win).arg(view);
qDebug() << pycode;
Py::PythonAgent::getInstance()->submit(pycode);
// gwb->setView(view);
}
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* SubWindowManager::getPreWindow()
2023-05-08 06:32:41 +00:00
{
return _preWindow.second;
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::openReportWindow(XReport::ReportWindow* w)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* sw = nullptr;
QList<XReport::ReportWindow*> rws = _reportWindow.values();
if(rws.contains(w)) {
2023-05-08 06:32:41 +00:00
sw = _reportWindow.key(w);
2023-05-09 11:00:22 +00:00
} else {
sw = _mdiArea->addSubWindow(w);
2023-05-08 06:32:41 +00:00
_reportWindow[sw] = w;
}
2023-05-09 11:00:22 +00:00
if(sw != nullptr) {
2023-05-08 06:32:41 +00:00
sw->showMaximized();
sw->setFocus();
}
emit _mainWindow->updateActionStatesSig();
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::closeReportWindow(XReport::ReportWindow* w)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* s = _reportWindow.key(w);
if(s != nullptr) {
2023-05-08 06:32:41 +00:00
_reportWindow.remove(s);
}
}
bool SubWindowManager::isPreWindowOpened()
{
2023-05-09 11:00:22 +00:00
if(_preWindow.first == nullptr || _preWindow.second == nullptr)
2023-05-08 06:32:41 +00:00
return false;
return true;
}
bool SubWindowManager::isPostWindowOpened()
{
2023-05-09 11:00:22 +00:00
if(_postWindow.size() > 0)
2023-05-08 06:32:41 +00:00
return true;
return false;
}
bool SubWindowManager::isPostWindowOpening()
{
2023-05-09 11:00:22 +00:00
QMdiSubWindow* activeWindow = _mdiArea->activeSubWindow();
if(activeWindow == nullptr)
2023-05-08 06:32:41 +00:00
return false;
2023-05-09 11:00:22 +00:00
else if(_postWindow.contains(activeWindow))
2023-05-08 06:32:41 +00:00
return true;
else
return false;
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::saveImage(QString fileName, int winType, Post::PostWindowBase* winhandle,
int w, int h)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if(winType == 0) {
MainWidget::PreWindow* preW = _preWindow.second;
if(preW == nullptr)
2023-05-08 06:32:41 +00:00
return;
preW->saveImage(fileName, w, h, false);
2023-05-09 11:00:22 +00:00
} else if(winType == 1) {
if(_postWindow.key(winhandle) == nullptr)
2023-05-08 06:32:41 +00:00
return;
winhandle->saveImage(fileName, w, h, false);
}
}
void SubWindowManager::saveImage(int w, int h, QString f)
{
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* gw = this->getCurrentWindow();
if(gw == nullptr) {
2023-05-08 06:32:41 +00:00
_mainWindow->printMessage(Common::Message::Error, tr("No GraphWindow opened!"));
return;
}
2023-05-09 11:00:22 +00:00
QString type = gw->getStringGraphWindowType();
const int id = gw->getID();
QString pycode = QString("MainWindow.saveImage(%1,%2,%3,\"%4\",\"%5\")")
.arg(w)
.arg(h)
.arg(id)
.arg(type)
.arg(f);
2023-05-08 06:32:41 +00:00
qDebug() << pycode;
Py::PythonAgent::getInstance()->submit(pycode);
}
void SubWindowManager::saveImage(int w, int h, int id, QString winType, QString file)
{
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* win = this->getWindowByTypeID(winType, id);
if(win == nullptr)
2023-05-08 06:32:41 +00:00
return;
win->saveImage(file, w, h, false);
Py::PythonAgent::getInstance()->unLock();
}
void SubWindowManager::setView(int id, QString winType, QString view) // liu
{
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(winType, id);
if(gwb == nullptr)
2023-05-08 06:32:41 +00:00
return;
gwb->setView(view);
Py::PythonAgent::getInstance()->unLock();
}
2023-05-09 11:00:22 +00:00
void SubWindowManager::setViewValue(int id, QString win, int x1, int x2, int x3, int y1, int y2,
int y3, int z1, int z2, int z3)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* gwb = getWindowByTypeID(win, id);
if(gwb == nullptr)
2023-05-08 06:32:41 +00:00
return;
gwb->setViewValue(x1, x2, x3, y1, y2, y3, z1, z2, z3);
Py::PythonAgent::getInstance()->unLock();
}
2023-05-09 11:00:22 +00:00
/*void SubWindowManager::setViewPreValue(int id, QString win, int x1, int x2, int x3, int y1,
int y2, int y3, int z1, int z2, int z3)
2023-05-08 06:32:41 +00:00
{
ModuleBase::GraphWindowBase* gwb = getCurrentWindow();
if (gwb == nullptr) return;
gwb->setViewPreValue(x1, x2, x3, y1, y2, y3, z1, z2, z3);
}*/
void SubWindowManager::reTranslate()
{
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* prew = _preWindow.second;
if(prew != nullptr)
2023-05-08 06:32:41 +00:00
prew->reTranslate();
2023-05-09 11:00:22 +00:00
int n = 0;
QList<Post::PostWindowBase*> postWinList = _postWindow.values();
n = postWinList.size();
for(int i = 0; i < n; ++i) {
Post::PostWindowBase* pw = postWinList.at(i);
if(pw != nullptr)
2023-05-08 06:32:41 +00:00
pw->reTranslate();
}
2023-05-09 11:00:22 +00:00
QList<Post::RealTimeWindowBase*> rwList = _realTimeWindow.values();
n = rwList.size();
for(int i = 0; i < n; ++i) {
Post::RealTimeWindowBase* rw = rwList.at(i);
if(rw != nullptr)
2023-05-08 06:32:41 +00:00
rw->reTranslate();
}
2023-05-09 11:00:22 +00:00
QList<XReport::ReportWindow*> repWin = _reportWindow.values();
n = repWin.size();
for(int i = 0; i < n; ++i) {
XReport::ReportWindow* w = repWin.at(i);
2023-05-08 06:32:41 +00:00
w->reTranslate();
}
2023-05-09 11:00:22 +00:00
if(_threeD_render_page != nullptr)
2023-05-08 06:32:41 +00:00
_threeD_render_page->setWindowTitle(tr("3D Render"));
}
void SubWindowManager::closeGeometryWindow()
{
2023-05-09 11:00:22 +00:00
_geometryWindow.first = nullptr;
2023-05-08 06:32:41 +00:00
_geometryWindow.second = nullptr;
_signalHander->clearData(false);
emit _mainWindow->updateGeometryTreeSig();
emit _mainWindow->updateMeshTreeSig();
emit _mainWindow->updatePhysicsTreeSignal();
emit _mainWindow->updateProperty(nullptr);
}
2023-05-09 11:00:22 +00:00
GenerateGeometry::GenerateGeometryWidget* SubWindowManager::getGeometryWindow()
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
if(!_geometryWindow.second) {
2023-05-08 06:32:41 +00:00
openGeometryWindow();
}
return _geometryWindow.second;
}
void SubWindowManager::closeAllSubWindow()
{
// _mdiArea->setViewMode(QMdiArea::SubWindowView);
// _mdiArea->setTabPosition(QTabWidget::North);
2023-05-09 11:00:22 +00:00
MainWidget::PreWindow* pre = _preWindow.second;
if(pre != nullptr) {
2023-05-08 06:32:41 +00:00
_preWindow.first->close();
_mdiArea->removeSubWindow(pre);
pre->close();
delete pre;
}
2023-05-09 11:00:22 +00:00
QList<Post::PostWindowBase*> postlist = _postWindow.values();
for(int i = 0; i < postlist.size(); ++i) {
Post::PostWindowBase* p = postlist.at(i);
2023-05-08 06:32:41 +00:00
_postWindow.key(p)->close();
_mdiArea->removeSubWindow(p);
p->close();
delete p;
}
2023-05-09 11:00:22 +00:00
QList<Post::RealTimeWindowBase*> realtimelist = _realTimeWindow.values();
for(int i = 0; i < realtimelist.size(); ++i) {
Post::RealTimeWindowBase* r = realtimelist.at(i);
2023-05-08 06:32:41 +00:00
_realTimeWindow.key(r)->close();
_mdiArea->removeSubWindow(r);
r->close();
delete r;
}
2023-05-09 11:00:22 +00:00
QList<XReport::ReportWindow*> reportlist = _reportWindow.values();
for(int i = 0; i < reportlist.size(); ++i) {
XReport::ReportWindow* r = reportlist.at(i);
2023-05-08 06:32:41 +00:00
_reportWindow.key(r)->close();
_mdiArea->removeSubWindow(r);
r->close();
delete r;
}
}
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* SubWindowManager::getWindowByTypeID(QString type, int id)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
ModuleBase::GraphWindowBase* g = nullptr;
type = type.toLower();
if(type == "prewindow") {
2023-05-08 06:32:41 +00:00
g = _preWindow.second;
2023-05-09 11:00:22 +00:00
} else if(type == "realtime") {
QList<Post::RealTimeWindowBase*> wlist = _realTimeWindow.values();
for(int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID();
if(id == d) {
2023-05-08 06:32:41 +00:00
g = t;
break;
}
}
2023-05-09 11:00:22 +00:00
} else if(type == "post2d") {
QList<Post::PostWindowBase*> wlist = _postWindow.values();
for(int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID();
if(id == d && t->getGraphWindowType() == ModuleBase::Post2D) {
2023-05-08 06:32:41 +00:00
g = t;
break;
}
}
2023-05-09 11:00:22 +00:00
} else if(type == "post3d") {
QList<Post::PostWindowBase*> wlist = _postWindow.values();
for(int i = 0; i < wlist.size(); ++i) {
ModuleBase::GraphWindowBase* t = wlist.at(i);
const int d = t->getID();
if(id == d && t->getGraphWindowType() == ModuleBase::Post3D) {
2023-05-08 06:32:41 +00:00
g = t;
break;
}
}
}
return g;
}
void SubWindowManager::setIcon(QString icon)
{
2023-05-09 11:00:22 +00:00
if(_preWindow.first != nullptr)
2023-05-08 06:32:41 +00:00
_preWindow.first->setWindowIcon(QIcon(icon));
2023-05-09 11:00:22 +00:00
QList<QMdiSubWindow*> subw =
_postWindow.keys() + _realTimeWindow.keys() + _reportWindow.keys();
for(auto w : subw) {
2023-05-08 06:32:41 +00:00
w->setWindowIcon(QIcon(icon));
}
}
2023-05-09 11:00:22 +00:00
} // namespace GUI