6 #include "IDetailsView.h" 7 #include "IDetailCustomization.h" 8 #include "IDetailGroup.h" 9 #include "DetailCategoryBuilder.h" 10 #include "DetailLayoutBuilder.h" 11 #include "DetailWidgetRow.h" 12 #include "EditorDirectories.h" 13 #include "DesktopPlatformModule.h" 14 #include "Widgets/Text/STextBlock.h" 15 #include "Widgets/Input/SNumericEntryBox.h" 16 #include "Widgets/Input/SFilePathPicker.h" 22 void FRealSenseDetailCustomization::Register()
24 FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>(
"PropertyEditor");
25 PropertyModule.RegisterCustomClassLayout(
"RealSenseInspector", FOnGetDetailCustomizationInstance::CreateStatic(&FRealSenseInspectorCustomization::MakeInstance));
27 PropertyModule.NotifyCustomizationModuleChanged();
30 void FRealSenseDetailCustomization::Unregister()
32 FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>(
"PropertyEditor");
33 PropertyModule.UnregisterCustomClassLayout(
"RealSenseInspector");
41 TSharedRef<IDetailCustomization> FRealSenseInspectorCustomization::MakeInstance() {
return MakeShareable(
new FRealSenseInspectorCustomization); }
43 FRealSenseInspectorCustomization::FRealSenseInspectorCustomization()
45 DetailLayoutPtr =
nullptr;
49 void FRealSenseInspectorCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
52 REALSENSE_TRACE(TEXT(
"FRealSenseInspectorCustomization::CustomizeDetails"));
56 DetailLayoutPtr = &DetailLayout;
58 auto* Category = &DetailLayout.EditCategory(
"Hardware Inspector");
61 if (RsDevices->size() == 0)
66 Category->AddCustomRow(FText::FromString(TEXT(
"Refresh")))
70 .Text(FText::FromString(TEXT(
"Refresh")))
71 .OnClicked_Lambda([This]()
73 This->UpdateDevices();
74 This->DetailLayoutPtr->ForceRefreshDetails();
75 return FReply::Handled();
80 for (
auto Device : *RsDevices)
84 auto* DeviceGroup = &Category->AddGroup(TEXT(
"Device"), FText::FromString(DevName));
86 DeviceGroup->AddWidgetRow()
90 .Text(FText::FromString(TEXT(
"Serial Number")))
91 .Font(IDetailLayoutBuilder::GetDetailFont())
96 .Text(FText::FromString(DevSerial))
97 .Font(IDetailLayoutBuilder::GetDetailFont())
101 DeviceGroup->AddWidgetRow()
105 .Text(FText::FromString(TEXT(
"Load preset")))
106 .OnClicked_Lambda([This, Device, ParentWindow]()
109 if (This->PickFile(Path, ParentWindow, TEXT(
"Select preset"), TEXT(
"Preset file|*.json")))
114 This->UpdateDevices();
117 return FReply::Handled();
122 DeviceGroup->AddWidgetRow()
126 .Text(FText::FromString(TEXT(
"Save preset")))
127 .OnClicked_Lambda([This, Device, ParentWindow]()
130 if (This->PickFile(Path, ParentWindow, TEXT(
"Select preset"), TEXT(
"Preset file|*.json"),
true))
135 return FReply::Handled();
140 for (
auto Sensor : Device.query_sensors())
143 auto* SensorGroup = &DeviceGroup->AddGroup(TEXT(
"Sensor"), FText::FromString(SensorName));
149 if (Sensor.supports(Option))
152 auto Range = Sensor.get_option_range(Option);
154 auto UniqId = DevName +
"_" + SensorName +
"_" + OptionName;
155 if (!ValueCache.Contains(UniqId))
157 auto Value = Sensor.get_option(Option);
158 ValueCache.Add(UniqId,
Value);
161 SensorGroup->AddWidgetRow()
165 .Text(FText::FromString(OptionName))
166 .Font(IDetailLayoutBuilder::GetDetailFont())
170 SNew(SNumericEntryBox<float>)
172 .MinSliderValue(
Range.min)
174 .MaxSliderValue(
Range.max)
176 .Value_Lambda([This, UniqId]()
178 return This->ValueCache.Contains(UniqId) ? This->ValueCache[UniqId] : 0;
180 .OnValueChanged_Lambda([This, Sensor, Option, UniqId,
Range](
float NewValue)
182 NewValue = FMath::RoundToFloat(NewValue /
Range.step) *
Range.step;
183 Sensor.set_option(Option, NewValue);
184 if (This->ValueCache.Contains(UniqId)) This->ValueCache[UniqId] = NewValue;
else This->ValueCache.Add(UniqId, NewValue);
194 void FRealSenseInspectorCustomization::UpdateDevices()
197 REALSENSE_TRACE(TEXT(
"FRealSenseInspectorCustomization::UpdateDevices"));
200 *RsDevices = RsContext.query_devices();
203 bool FRealSenseInspectorCustomization::PickFile(FString& OutPath,
const void* ParentWindow,
const FString& Title,
const FString& Filter,
bool SaveFlag)
208 TArray<FString> OutFiles;
212 if (DesktopPlatform->SaveFileDialog(ParentWindow, Title, DefaultPath, TEXT(
""), Filter, EFileDialogFlags::None, OutFiles))
214 OutPath = OutFiles[0];
221 if (DesktopPlatform->OpenFileDialog(ParentWindow, Title, DefaultPath, TEXT(
""), Filter, EFileDialogFlags::None, OutFiles))
223 OutPath = OutFiles[0];
231 #endif // WITH_EDITOR
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
static IRealSensePlugin & Get()
bool SavePreset(const FString &FileName)
const char * rs2_option_to_string(rs2_option option)
::sensor_msgs::Range_< std::allocator< void > > Range
bool LoadPreset(const FString &FileName)
UTexture2D * Get(TUniquePtr< T > &Dtex)
IMGUI_API void Value(const char *prefix, bool b)
#define REALSENSE_TRACE(Format,...)
FString uestr(const char *str)