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.

106 lines
4.1 KiB
C++

#include "GUIPickInfo.h"
#include "OperatorsInterface/GraphInteractionOperator.h"
#include "FITK_Kernel/FITKCore/FITKEnumTransformer.hpp"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"
#include "FITK_Kernel/FITKAppFramework/FITKRunTimeSetting.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#define ComponentManagerStr "ComponentManagerStr"
#define PickObjTypeStr "PickObjType"
#define PickMethodStr "PickMethod"
#define PickParamStr "PickParam"
#define CreateComponentStr "CreateComponent"
#define ComponentNameStr "ComponentName"
namespace GUI
{
/**
* @brief
*
*/
void GUIPickInfo::ClearPickInfo()
{
auto RTsetting = FITKAPP->getGlobalData()->getRunTimeSetting();
if (RTsetting == nullptr) return;
// 移除运行时设置中的变量
RTsetting->removeVarient(ComponentManagerStr);
RTsetting->removeVarient(PickObjTypeStr);
RTsetting->removeVarient(PickMethodStr);
RTsetting->removeVarient(PickParamStr);
RTsetting->removeVarient(CreateComponentStr);
RTsetting->removeVarient(ComponentNameStr);
//设置到交互器
auto operPick = Core::FITKOperatorRepo::getInstance()->getOperatorT<EventOper::GraphInteractionOperator>("GraphPick");
if (operPick)
operPick->setActorStateByPickInfo(GUIPickInfo::PickObjType::POBJNone, GUIPickInfo::PickMethod::PMNone);
}
/**
* @brief
* @param info
*
*/
void GUIPickInfo::SetPickInfo(GUIPickInfoStru info, int dataObjId)
{
auto RTsetting = FITKAPP->getGlobalData()->getRunTimeSetting();
if (RTsetting == nullptr) return;
// 设置运行时设置中的变量值
RTsetting->setValue(PickObjTypeStr, (int)info._pickObjType);
RTsetting->setValue(PickMethodStr, (int)info._pickMethod);
RTsetting->setValue(PickParamStr, info._pickParam );
RTsetting->setValue(CreateComponentStr, info._createComponent);
RTsetting->setValue(ComponentNameStr, info._componentName);
//设置到交互器
auto operPick = Core::FITKOperatorRepo::getInstance()->getOperatorT<EventOper::GraphInteractionOperator>("GraphPick");
if(operPick)
operPick->setActorStateByPickInfo(info._pickObjType, info._pickMethod, dataObjId);
}
/**
* @brief
* @return GUIPickInfoStru
*
*/
GUIPickInfoStru GUIPickInfo::GetPickInfo()
{
GUIPickInfoStru pickInfo;
auto RTsetting = FITKAPP->getGlobalData()->getRunTimeSetting();
if (RTsetting == nullptr) return pickInfo;
// 从运行时设置中获取变量值
pickInfo._pickObjType = (GUIPickInfo::PickObjType)RTsetting->getValueT<int>(PickObjTypeStr);
pickInfo._pickMethod = (GUIPickInfo::PickMethod)RTsetting->getValueT<int>(PickMethodStr);
pickInfo._pickParam = RTsetting->getValueT<double>(PickParamStr);
pickInfo._createComponent = RTsetting->getValueT<bool>(CreateComponentStr);
pickInfo._componentName = RTsetting->getValueT<QString>(ComponentNameStr);
return pickInfo;
}
/**
* @brief UI
* @param uiText UI
* @return PickMethod
* UI
*/
// GUI::GUIPickInfo::PickMethod GUIPickInfo::GetPickMethod(QString uiText)
// {
// Core::FITKEnumTransfer<PickMethod> pe;
//
// bool ok = false;
// QString text = "PM" + uiText.remove(" ");
// // 从字符串中解析选择方法枚举
// return pe.fromString(text,ok);
// }
}