You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
6.3 KiB
C

/**
*
* @file FITKGolbalData.h
* @brief 线
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*
*/
#ifndef __FITKLGOLBALDATA_H__
#define __FITKLGOLBALDATA_H__
#include <QObject>
#include <QHash>
#include "FITKAppFrameworkAPI.h"
#include <QMutex>
#include <QMutexLocker>
class QWidget;
namespace Core
{
class FITKAbstractDataObject;
}
namespace AppFrame
{
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
enum FITKGlobalDT
{
GDTNone = 0,
GDTMesh,
GDTGeom,
GDTPhysics,
GDTPost,
GDTOther = 1000,
GDTEND = 3000,
};
class FITKAbstractGlobalDataFactory;
class FITKRunTimeSetting;
class FITKKeyMouseStates;
/**
* @brief 线
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
class FITKAppFrameworkAPI FITKGlobalData : public QObject
{
friend FITKAbstractGlobalDataFactory;
Q_OBJECT
public:
/**
* @brief Construct a new FITKGolbalData object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
FITKGlobalData();
/**
* @brief Destroy the FITKGolbalData object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
~FITKGlobalData();
/**
* @brief
* @param[i] mw
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
void setMainWindow(QWidget* mw);
/**
* @brief
* @return QWidget*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
QWidget* getMainWindow();
template<class T>
/**
* @brief
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-08
*/
T* getMainWindowT()
{
QMutexLocker locker(&_mutex);
return dynamic_cast<T*>(this->getMainWindow());
}
template<class T>
/**
* @brief
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
T* getMeshData()
{
QMutexLocker locker(&_mutex);
return dynamic_cast<T*>(_gData.value(GDTMesh));
}
template<class T>
/**
* @brief
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
T* getGeometryData()
{
QMutexLocker locker(&_mutex);
return dynamic_cast<T*>(_gData.value(GDTGeom));
}
template<class T>
/**
* @brief
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
T* getPhysicsData()
{
return dynamic_cast<T*>(_gData.value(GDTPhysics));
}
template<class T>
/**
* @brief
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
T* getPostData()
{
QMutexLocker locker(&_mutex);
return dynamic_cast<T*>(_gData.value(GDTPost));
}
// template<class T>
// /**
// * @brief 获取运行时数据
// * @return T*
// * @author LiBaojun (libaojunqd@foxmail.com)
// * @date 2024-02-29
// */
// T* getRunTimeData()
// {
// return dynamic_cast<T*>(_gData.value(GDTRunTime));
// }
template<class T>
/**
* @brief
* @param[i] d FITKGlobalDT
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
T* getData(int d)
{
QMutexLocker locker(&_mutex);
return dynamic_cast<T*>(_gData.value(d));
}
/**
* @brief
* @return FITKRunTimeSetting*
* @author libaojun (libaojunqd@Foxmail.com)
* @date 2024-04-10
*/
FITKRunTimeSetting* getRunTimeSetting();
/**
* @brief
* @return FITKRunTimeSetting*
* @author libaojun (libaojunqd@Foxmail.com)
* @date 2024-04-30
*/
FITKKeyMouseStates* getKeyMouseStates();
/**
* @brief ID
* @return QList<int>
* @author libaojun (libaojunqd@Foxmail.com)
* @date 2024-04-30
*/
QList<int> getGlobalDataIDs();
private:
/**
* @brief
* @param[i] dt FITKGlobalDT
* @param[i] d
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
void insertData(int dt, Core::FITKAbstractDataObject* d);
private:
/**
* @brief 线
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
static QMutex _mutex;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*/
QWidget* _mainwindow{};
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-29
*/
QHash<int, Core::FITKAbstractDataObject*> _gData{};
/**
* @brief
* @author libaojun (libaojunqd@Foxmail.com)
* @date 2024-04-10
*/
FITKRunTimeSetting* _runtimeSetting{};
/**
* @brief
* @author libaojun (libaojunqd@Foxmail.com)
* @date 2024-04-10
*/
FITKKeyMouseStates* _keyMouseStates{};
};
}
#endif // !__FITKLGOLBALDATA_H__