diff --git a/src/GeometryCommand/GeoCommandCommon.cpp b/src/GeometryCommand/GeoCommandCommon.cpp index 6aa1731ea4dc26f1c24b808a8804c469a29af2d0..50207324a2a46e3fc35c32b85688052f5de47f64 100644 --- a/src/GeometryCommand/GeoCommandCommon.cpp +++ b/src/GeometryCommand/GeoCommandCommon.cpp @@ -81,7 +81,8 @@ namespace Command return TopoDS_Shape(); std::vector wires = w; - std::sort(wires.begin(), wires.end(), Wire_Compare()); + std::sort(wires.begin(), wires.end(), + std::function (Wire_Compare())); std::list wire_list; wire_list.insert(wire_list.begin(), wires.rbegin(), wires.rend()); diff --git a/src/GeometryCommand/GeoCommandCommon.h b/src/GeometryCommand/GeoCommandCommon.h index 81770161cecb898e0ca2e4afcdd532d661f49a26..8c63639b897facf6cff717e75ff8def7a82ffd38 100644 --- a/src/GeometryCommand/GeoCommandCommon.h +++ b/src/GeometryCommand/GeoCommandCommon.h @@ -51,8 +51,7 @@ namespace Command // sort bounding boxes according to diagonal length - class Wire_Compare : public std::binary_function + class Wire_Compare { public: bool operator() (const TopoDS_Wire& w1, const TopoDS_Wire& w2) diff --git a/src/MainWindow/MainWindow.cpp b/src/MainWindow/MainWindow.cpp index c19e3dbd2df7b3ae0b7bed7067e29ae4e35283af..d658319c8734841e15730e64d5c032b60176f4b2 100644 --- a/src/MainWindow/MainWindow.cpp +++ b/src/MainWindow/MainWindow.cpp @@ -119,7 +119,7 @@ namespace GUI { setWorkingDir(); Setting::BusAPI::instance()->setMainWindow(this); - Setting::GraphOption* gp = Setting::BusAPI::instance()->getGraphOption(); + auto gp = Setting::BusAPI::instance()->getGraphOption(); _ui->actionDisplayPoint->setChecked(gp->isShowGeoPoint()); _ui->actionDisplayCurve->setChecked(gp->isShowGeoEdge()); _ui->actionDisplayFace->setChecked(gp->isShowGeoSurface()); @@ -936,7 +936,7 @@ namespace GUI { bool checkcurve = _ui->actionDisplayCurve->isChecked(); bool checkface = _ui->actionDisplayFace->isChecked(); - Setting::GraphOption* gp = Setting::BusAPI::instance()->getGraphOption(); + auto gp = Setting::BusAPI::instance()->getGraphOption(); gp->isShowGeoPoint(checkvertex); gp->isShowGeoEdge(checkcurve); gp->isShowGeoSurface(checkface); diff --git a/src/ModuleBase/graph3DWindow.cpp b/src/ModuleBase/graph3DWindow.cpp index 62ac3bf72b26057c544075abd4062d32bc534e8f..824e123beafb76e2effb73c333ccfbdf856d709b 100644 --- a/src/ModuleBase/graph3DWindow.cpp +++ b/src/ModuleBase/graph3DWindow.cpp @@ -42,6 +42,7 @@ #include "MeshData/meshSingleton.h" #include "PreWindowInteractorStyle.h" #include +#include namespace ModuleBase { @@ -346,7 +347,7 @@ namespace ModuleBase void Graph3DWindow::updateGraphOption() { - Setting::GraphOption *option = Setting::BusAPI::instance()->getGraphOption(); + auto option = Setting::BusAPI::instance()->getGraphOption(); QColor topcolor = option->getBackgroundTopColor(); QColor bottomcolor = option->getBackgroundBottomColor(); _render->SetBackground2(topcolor.redF(), topcolor.greenF(), topcolor.blueF()); diff --git a/src/Settings/BusAPI.cpp b/src/Settings/BusAPI.cpp index cb3eadbc7e23bcdf18b7ecf2a52d3069d1b5dba8..4228f6bcc7816a425c215105e80089142657814a 100644 --- a/src/Settings/BusAPI.cpp +++ b/src/Settings/BusAPI.cpp @@ -36,32 +36,25 @@ namespace Setting { - BusAPI *BusAPI::_ins = nullptr; + std::shared_ptr BusAPI::_ins = nullptr; - BusAPI *BusAPI::instance() + std::shared_ptr BusAPI::instance() { - if (_ins == nullptr) - { - _ins = new BusAPI; + class TempBusAPI : public BusAPI {}; + if(_ins == nullptr) { + _ins = std::make_shared(); } return _ins; } BusAPI::BusAPI() { - _mainSetting = new MainSetting; + _mainSetting = std::make_shared(); // _solvers = new SolverManager; // _solveOption = new SolveOption; - _graphOption = new GraphOption; - _messageSetting = new MessageSetting; + _graphOption = std::make_shared(); + _messageSetting = std::make_shared(); readINI(); } - BusAPI::~BusAPI() - { - delete _mainSetting; - // delete _solvers; - // delete _solveOption; - delete _graphOption; - } void BusAPI::setWorkingDir() { WorkingDirDialog dlg(_mainWindow, _mainSetting); @@ -158,7 +151,7 @@ namespace Setting return _mainWindow; } - GraphOption *BusAPI::getGraphOption() + std::shared_ptr BusAPI::getGraphOption() { return _graphOption; } diff --git a/src/Settings/BusAPI.h b/src/Settings/BusAPI.h index 338e795107bb071fcd37b68ac3d3e4a3814923d9..4de2cfeca3e15da9aa6e814d848916e0c45defd9 100644 --- a/src/Settings/BusAPI.h +++ b/src/Settings/BusAPI.h @@ -27,6 +27,7 @@ #include #include #include "SettingAPI.h" +#include namespace GUI { @@ -53,7 +54,7 @@ namespace Setting * @return BusAPI* 返回设置信息管理类的单例对象 * @since 2.5.0 */ - static BusAPI *instance(); + static std::shared_ptr instance(); /** * @brief 将设置信息写出ini配置文件 * @since 2.5.0 @@ -104,7 +105,7 @@ namespace Setting * @return GraphOption* 返回绘图选项设置对象 * @since 2.5.0 */ - GraphOption *getGraphOption(); + std::shared_ptr getGraphOption(); /** * @brief 获取最近打开文件的列表 * @return QStringList 返回最近打开文件的列表 @@ -208,7 +209,7 @@ namespace Setting * @brief 析构函数 * @since 2.5.0 */ - ~BusAPI(); + ~BusAPI() = default; /** * @brief 从ini文件读取配置信息 * @since 2.5.0 @@ -220,29 +221,29 @@ namespace Setting * @brief 配置信息管理类的单例对象 * @since 2.5.0 */ - static BusAPI *_ins; + static std::shared_ptr _ins; /** * @brief 主窗口配置信息类对象 * @since 2.5.0 */ - MainSetting *_mainSetting{}; + std::shared_ptr _mainSetting; // SolverManager* _solvers{}; // SolveOption* _solveOption{}; /** * @brief 绘图选项配置信息类对象 * @since 2.5.0 */ - GraphOption *_graphOption{}; + std::shared_ptr _graphOption; /** * @brief 输出消息配置信息类对象 * @since 2.5.0 */ - MessageSetting *_messageSetting{}; + std::shared_ptr _messageSetting; /** * @brief 主窗口对象 * @since 2.5.0 */ - GUI::MainWindow *_mainWindow{}; + GUI::MainWindow *_mainWindow = nullptr; // bool _isDesignModel{ false }; }; } diff --git a/src/Settings/DialogGraphOption.cpp b/src/Settings/DialogGraphOption.cpp index f8827bcf3c6a7365e6e38041fd1a559c3776b3db..7b764d8f55bdf2846e6a753ed9d545401885d062 100644 --- a/src/Settings/DialogGraphOption.cpp +++ b/src/Settings/DialogGraphOption.cpp @@ -27,7 +27,7 @@ namespace Setting { - GraphOptionDialog::GraphOptionDialog(GUI::MainWindow *mainwindow, GraphOption *op) : /* QFDialog(mainwindow),*/ + GraphOptionDialog::GraphOptionDialog(GUI::MainWindow *mainwindow, std::shared_ptr op) : /* QFDialog(mainwindow),*/ _ui(new Ui::GraphOptionDialog), _mainWindow(mainwindow), _graphOption(op) { _ui->setupUi(this); diff --git a/src/Settings/DialogGraphOption.h b/src/Settings/DialogGraphOption.h index 4e0237da36a95de87fde461bbe200d4dcebd62db..97e5b935da6d84e9db01e1520997d0ca55d612b2 100644 --- a/src/Settings/DialogGraphOption.h +++ b/src/Settings/DialogGraphOption.h @@ -54,7 +54,7 @@ namespace Setting * @param option 绘图信息配置类对象 * @since 2.5.0 */ - GraphOptionDialog(GUI::MainWindow *mainwindow, GraphOption *option); + GraphOptionDialog(GUI::MainWindow *mainwindow, std::shared_ptr option); /** * @brief 析构函数 * @since 2.5.0 @@ -112,7 +112,7 @@ namespace Setting * @brief 绘图信息配置类对象 * @since 2.5.0 */ - GraphOption *_graphOption{}; + std::shared_ptr _graphOption; }; } diff --git a/src/Settings/DialogWorkingDir.cpp b/src/Settings/DialogWorkingDir.cpp index 67184caedec9ff1aac5e853bf96664356c33b6d2..d0c71dee908549dbbd45301095e258478a113b20 100644 --- a/src/Settings/DialogWorkingDir.cpp +++ b/src/Settings/DialogWorkingDir.cpp @@ -31,7 +31,8 @@ namespace Setting { - WorkingDirDialog::WorkingDirDialog(GUI::MainWindow *mw, MainSetting *setting) : /*QFDialog(mw),*/ + WorkingDirDialog::WorkingDirDialog(GUI::MainWindow* mw, std::shared_ptr setting) + : /*QFDialog(mw),*/ _ui(new Ui::DialogWorkingDir), _setting(setting) { Q_UNUSED(mw); diff --git a/src/Settings/DialogWorkingDir.h b/src/Settings/DialogWorkingDir.h index cbe06a0bd3e45f35151307fc8c2bf09fdeacea49..4b73c4505276768537a4784c3e8871d5f37e6653 100644 --- a/src/Settings/DialogWorkingDir.h +++ b/src/Settings/DialogWorkingDir.h @@ -25,6 +25,7 @@ //#include "SelfDefObject/QFDialog.h" #include +#include namespace Ui { @@ -53,7 +54,7 @@ namespace Setting * @param setting 主窗口配置信息对象 * @since 2.5.0 */ - WorkingDirDialog(GUI::MainWindow *mw, MainSetting *setting); + WorkingDirDialog(GUI::MainWindow *mw, std::shared_ptr setting); /** * @brief 析构函数 * @since 2.5.0 @@ -95,7 +96,7 @@ namespace Setting * @brief 主窗口配置信息管理类对象 * @since 2.5.0 */ - MainSetting *_setting{}; + std::shared_ptr _setting; /** * @brief 工作目录设置对话框的ui对象 * @since 2.5.0