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.
AppFlow/FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoCommand.h

428 lines
14 KiB
C

/**
*
* @file FITKAbsGeoCommand.h
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*
*/
#ifndef _FITKABS_GEO_COMMAND_H___
#define _FITKABS_GEO_COMMAND_H___
#include "FITKInterfaceGeometryAPI.h"
#include "FITKGeoEnum.h"
#include "FITK_Kernel/FITKCore/FITKAbstractNDataObject.h"
#include "FITK_Kernel/FITKCore/FITKVarientParams.h"
#include "FITK_Interface/FITKInterfaceModel/FITKModelEnum.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKAbsGeoShapeAgent.h"
#include "FITK_Interface/FITKInterfaceGeometry/FITKVirtualTopoManager.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKSignalTransfer.h"
#include "FITK_Kernel/FITKCore/FITKAbstractDataManager.hpp"
namespace Interface
{
class FITKGeoCommandManager;
/**
* @brief .
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
class VirtualShape {
public:
/**
* @brief CommandID.
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
int CmdId{ 0 };
/**
* @brief ID.
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
int VirtualTopoId{ 0 };
/**
* @brief .
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
bool isNull() const { return CmdId <= 0 || VirtualTopoId <= 0; }
/**
* @brief (isNull() == true).
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
void reset() { CmdId = 0; VirtualTopoId = 0; }
/**
* @brief .
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-22
*/
bool operator==(const VirtualShape& other) {
return (CmdId == other.CmdId) && (VirtualTopoId == other.VirtualTopoId);
}
friend bool operator==(const VirtualShape& shape1, const VirtualShape& shape2);
};
inline bool operator==(const VirtualShape& shape1, const VirtualShape& shape2) {
return (shape1.CmdId == shape2.CmdId) && (shape1.VirtualTopoId == shape2.VirtualTopoId);
}
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*/
class FITKInterfaceGeometryAPI FITKAbsGeoCommand : public Core::FITKAbstractNDataObject,
public Core::FITKVarientParams
{
Q_OBJECT
FITKCLASS(Interface, FITKAbsGeoCommand);
public:
/**
* @brief Construct a new FITKAbsGeoCommand object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*/
explicit FITKAbsGeoCommand();
/**
* @brief Destroy the FITKAbsGeoCommand object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*/
virtual ~FITKAbsGeoCommand() = 0;
/**
* @brief
* @return FITKGeoEnum::FITKGeometryComType
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*/
virtual FITKGeoEnum::FITKGeometryComType getGeometryCommandType() = 0;
/**
* @brief
* @return true
* @return false
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-12
*/
virtual bool update() = 0;
/**
* @brief []
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
virtual bool undo();
/**
* @brief []
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
virtual bool redo();
/**
* @brief
* @param status
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
void setCommandStatus(FITKGeoEnum::FITKGeoStatus status);
/**
* @brief
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
FITKGeoEnum::FITKGeoStatus getCommandStatus();
/**
* @brief
* @return FITKAbsGeoShapeAgent
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-30
*/
FITKAbsGeoShapeAgent* getShapeAgent();
/**
* @brief shape.
* @param type
* @param id ID
* @return shape
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-20
*/
template<typename T>
T* getShapeT(Interface::FITKGeoEnum::VTopoShapeType type, int id) {
auto shapeAgent = getShapeAgent();
if (shapeAgent == nullptr) return nullptr;
auto manager = shapeAgent->getVirtualTopoManager();
if (manager == nullptr) return nullptr;
auto shapeManager = manager->getShapeVirtualTopoManager(type);
if (shapeManager == nullptr) return nullptr;
auto virShape = shapeManager->getDataByID(id);
if (virShape == nullptr) return nullptr;
return virShape->getShapeT<T>();
}
/**
* @brief shape.
* @param id ID
* @return shape
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-20
*/
template<typename T>
T* getShapeT(int id) {
auto shapeAgent = getShapeAgent();
if (shapeAgent == nullptr) return nullptr;
auto manager = shapeAgent->getVirtualTopoManager();
if (manager == nullptr) return nullptr;
for (int type = static_cast<int>(FITKGeoEnum::VTopoShapeType::VSPoint); type < static_cast<int>(FITKGeoEnum::VTopoShapeType::VSAssembly); ++type) {
auto shapeManager = manager->getShapeVirtualTopoManager(static_cast<FITKGeoEnum::VTopoShapeType>(type));
if (shapeManager == nullptr) continue;
auto virShape = shapeManager->getDataByID(id);
if (virShape == nullptr) continue;
return virShape->getShapeT<T>();
}
return nullptr;
}
/**
* @brief
* @return ShapeAgent
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-08-20
*/
FITKVirtualTopoManager* getVirtualTopoManager();
template<class T>
/**
* @brief
* @return FITKAbsGeoShapeAgent
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-30
*/
T* getTShapeAgent()
{
return dynamic_cast<T*>(_shapeAgent);
}
/**
* @brief .
* @param type 1-normal 2-warning 3-error 4-info
* @param msg
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-08-28
*/
void printLog(QString msg, int type = 1)
{
AppFrame::FITKSignalTransfer* sigTrans = FITKAPP->getSignalTransfer();
if (sigTrans)
{
sigTrans->outputMessageSig(type, msg);
}
}
/**
* @brief
* @param flag
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void enableReferenceList(bool flag);
/**
* @brief
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
bool getEnableReferenceList();
/**
* @brief
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
int getReferenceCount();
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void addOneReference();
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void removeOneReference();
/**
* @brief ID
* @param idID
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void addReferenceCmdID(int id);
/**
* @brief
* @param cmd
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void addReferenceCmdObj(FITKAbsGeoCommand* cmd, bool isSet = false);
/**
* @brief ID
* @param idID
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void removeReferenceCmdID(int id);
/**
* @brief
* @param cmd
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void removeReferenceCmdObj(FITKAbsGeoCommand* cmd);
/**
* @brief []
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
virtual void clearReference();
/**
* @brief
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
int getReferenceCmdCount();
/**
* @brief
* @param index
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
FITKAbsGeoCommand* getReferenceCmdByIndex(int index);
/**
* @brief
* @return
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
bool getDataValidInGUI();
/**
* @brief ID
* @param idID
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
void setModifiedCmdID(int id);
/**
* @brief ID
* @return ID
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
int getModifiedCmdID();
/**
* @brief
* @param
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
bool hasModifiedCommand();
protected:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-07-30
*/
FITKAbsGeoShapeAgent* _shapeAgent{};
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
FITKGeoEnum::FITKGeoStatus m_status = FITKGeoEnum::FGSNormal;
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
FITKGeoCommandManager* m_referenceCmdList{ nullptr };
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
int m_referenceCount = 0;
/**
* @brief ID
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
int m_modifiedCmdId = -1;
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-07
*/
bool m_enableRefer = true;
};
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
class FITKInterfaceGeometryAPI FITKGeoCommandManager : public Core::FITKAbstractDataManager<FITKAbsGeoCommand>
{
public:
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
explicit FITKGeoCommandManager() = default;
/**
* @brief
* @author ChengHaotian (yeguangbaozi@foxmail.com)
* @date 2024-09-06
*/
virtual ~FITKGeoCommandManager() = default;
};
}
#endif