MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMcpCommon.h
Go to the documentation of this file.
1#pragma once
2#ifndef MESHLIB_NO_MCP
3
4#include "MRMesh/MRExpected.h"
5
6#include <nlohmann/json.hpp>
7
8#include <chrono>
9#include <cstdint>
10#include <functional>
11#include <memory>
12#include <stdexcept>
13#include <string>
14#include <string_view>
15
16namespace MR
17{
20
21
22class Object;
23struct Color;
24
25namespace Mcp
26{
27
29uint64_t idOf( const Object* obj );
30
34
36Color parseColor( const nlohmann::json& j, std::string_view field );
37
40inline constexpr std::chrono::seconds cMainThreadTimeout{ 20 };
41
43std::runtime_error busyError( std::string_view what );
44
46void runOnMainThread( const std::function<void()>& func );
47
51[[nodiscard]] std::string waitFramesAfterInput( const std::function<void()>& after = {} );
52
54nlohmann::json inputResult( std::string busy );
55
56}
57
58}
59
60#endif
named object in the data model
Definition MRObject.h:61
Expected< std::shared_ptr< Object > > resolveId(uint64_t id)
uint64_t idOf(const Object *obj)
Pointer -> id (as a JSON number). Matches the ##<id> suffix in ImGui labels for the same object.
Color parseColor(const nlohmann::json &j, std::string_view field)
Color from [r, g, b] or [r, g, b, a] floats in [0, 1].
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::string waitFramesAfterInput(const std::function< void()> &after={})
void runOnMainThread(const std::function< void()> &func)
CommandLoop::runCommandFromGUIThread, but throws busyError if the main thread does not start func in ...
nlohmann::json inputResult(std::string busy)
The result of a tool that sends an input: {}, or {busy: <message>} from waitFramesAfterInput
constexpr std::chrono::seconds cMainThreadTimeout
Definition MRMcpCommon.h:40
std::runtime_error busyError(std::string_view what)
The error for a main thread that did not respond within cMainThreadTimeout
Definition MRMcp.h:16
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12