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++
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);
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|