载入中...
搜索中...
未找到
EditorArchSpaceTools.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
9#include "editor/EditorTool.h"
10
11#include <array>
12#include <cstdint>
13#include <optional>
14#include <string>
15
16namespace eve::editor {
17
20 std::array<double, 3> origin{0.0, 0.0, 0.0};
21 std::array<double, 3> direction{0.0, 0.0, -1.0};
22};
23
31public:
33 virtual ~IArchSpaceViewportAdapter() = default;
34
38 virtual editing::Result<OverlayPoint> projectWorld(const std::array<double, 3>& world) const = 0;
39};
40
47public:
50
52 const ToolDescriptor& descriptor() const override { return descriptor_; }
54 void setViewportAdapter(IArchSpaceViewportAdapter* viewport);
56 void setAuthority(editing::IEditAuthority* authority);
58 void setLevelId(std::string levelId);
60 void setWallHeight(double height) { wallHeight_ = height; }
62 void setWallThickness(double thickness) { wallThickness_ = thickness; }
64 void setContiguous(bool enabled) { contiguous_ = enabled; }
66 void setIdPrefix(std::string prefix) { idPrefix_ = std::move(prefix); }
67
69 ToolResponse pointerEvent(EditorContext& context, const EditorPointerEvent& event) override;
71 void deactivate(EditorContext& context) override;
73 void cancel(EditorContext& context) override;
75 void drawOverlay(EditorContext& context, IEditorOverlay& overlay) override;
77 void inspect(EditorContext& context, IEditorInspector& inspector) override;
78
80 [[nodiscard]] bool isDrawing() const { return drawing_; }
82 [[nodiscard]] const std::optional<editing::TransactionReceipt>& lastReceipt() const { return lastReceipt_; }
84 [[nodiscard]] const std::string& lastWallId() const { return lastWallId_; }
85
86private:
88 ToolResponse move(const EditorPointerEvent& event);
90 [[nodiscard]] bool hitFloor(const EditorPointerEvent& event, archspace::Vec2& out) const;
93
94 ToolDescriptor descriptor_{"archspace.wall.draw", "Draw Wall", {}};
95 IArchSpaceViewportAdapter* viewport_ = nullptr;
96 editing::IEditAuthority* authority_ = nullptr;
97 std::string levelId_;
98 std::string idPrefix_{"wall"};
99 double wallHeight_ = 3.0;
100 double wallThickness_ = 0.2;
101 bool contiguous_ = true;
102 bool drawing_ = false;
103 bool haveAnchor_ = false;
104 archspace::Vec2 anchor_{};
105 archspace::Vec2 cursor_{};
106 std::string lastWallId_;
107 std::optional<editing::TransactionReceipt> lastReceipt_;
108 std::uint64_t sequence_ = 0;
109};
110
113public:
116
118 const ToolDescriptor& descriptor() const override { return descriptor_; }
120 void setViewportAdapter(IArchSpaceViewportAdapter* viewport);
122 void setAuthority(editing::IEditAuthority* authority);
126 void setWidth(double width) { width_ = width; }
128 void setHeight(double height) { height_ = height; }
130 void setSill(double sill) { sill_ = sill; }
132 void setIdPrefix(std::string prefix) { idPrefix_ = std::move(prefix); }
133
135 ToolResponse pointerEvent(EditorContext& context, const EditorPointerEvent& event) override;
137 void deactivate(EditorContext& context) override;
139 void cancel(EditorContext& context) override;
141 void drawOverlay(EditorContext& context, IEditorOverlay& overlay) override;
143 void inspect(EditorContext& context, IEditorInspector& inspector) override;
144
146 [[nodiscard]] const std::optional<editing::TransactionReceipt>& lastReceipt() const { return lastReceipt_; }
148 [[nodiscard]] const std::string& lastOpeningId() const { return lastOpeningId_; }
149
150private:
151 struct Pick {
152 std::string wallId;
153 double t = 0.5;
155 };
156 [[nodiscard]] bool hitFloor(const EditorPointerEvent& event, archspace::Vec2& out) const;
157 [[nodiscard]] std::optional<Pick> pickWall(const archspace_editing::ArchSpaceDocumentTarget& target,
158 const archspace::Vec2& point) const;
159
160 ToolDescriptor descriptor_{"archspace.opening.place", "Place Opening", {}};
161 IArchSpaceViewportAdapter* viewport_ = nullptr;
162 editing::IEditAuthority* authority_ = nullptr;
163 archspace::OpeningKind kind_ = archspace::OpeningKind::Door;
164 double width_ = 0.9;
165 double height_ = 2.1;
166 double sill_ = 0.0;
167 std::string idPrefix_{"opening"};
168 std::optional<Pick> preview_;
169 std::string lastOpeningId_;
170 std::optional<editing::TransactionReceipt> lastReceipt_;
171 std::uint64_t sequence_ = 0;
172};
173
176public:
179
181 const ToolDescriptor& descriptor() const override { return descriptor_; }
183 void setViewportAdapter(IArchSpaceViewportAdapter* viewport);
185 void setAuthority(editing::IEditAuthority* authority);
187 void setLevelId(std::string levelId);
189 void setCatalogId(std::string catalogId);
191 void setYawDegrees(double yaw) { yawDegrees_ = yaw; }
193 void setIdPrefix(std::string prefix) { idPrefix_ = std::move(prefix); }
194
196 ToolResponse pointerEvent(EditorContext& context, const EditorPointerEvent& event) override;
198 void deactivate(EditorContext& context) override;
200 void cancel(EditorContext& context) override;
202 void drawOverlay(EditorContext& context, IEditorOverlay& overlay) override;
204 void inspect(EditorContext& context, IEditorInspector& inspector) override;
205
207 [[nodiscard]] const std::optional<editing::TransactionReceipt>& lastReceipt() const { return lastReceipt_; }
209 [[nodiscard]] const std::string& lastItemId() const { return lastItemId_; }
210
211private:
212 [[nodiscard]] bool hitFloor(const EditorPointerEvent& event, archspace::Vec2& out) const;
213
214 ToolDescriptor descriptor_{"archspace.item.place", "Place Item", {}};
215 IArchSpaceViewportAdapter* viewport_ = nullptr;
216 editing::IEditAuthority* authority_ = nullptr;
217 std::string levelId_;
218 std::string catalogId_{"furniture.desk"};
219 std::string idPrefix_{"item"};
220 double yawDegrees_ = 0.0;
221 std::optional<archspace::Vec2> preview_;
222 std::string lastItemId_;
223 std::optional<editing::TransactionReceipt> lastReceipt_;
224 std::uint64_t sequence_ = 0;
225};
226
227} // namespace eve::editor
LogicalId target
Duration start
float thickness
Definition CaveMesh.cpp:83
#define EVENGINE_API_EDITORS
Definition Export.h:112
std::uint32_t height
std::uint32_t width
TokenKind kind
World3D * world
float begin
float t
const VegetationPresetContext & context
glm::vec3 point
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Revisioned ArchSpace document target for Inspector, tools and automation.
Final validation and commit boundary for editor mutations.
Click-to-place furniture tool committing makePlaceItem with catalog id + yaw.
const ToolDescriptor & descriptor() const override
Descriptor.
const std::optional< editing::TransactionReceipt > & lastReceipt() const
Last receipt.
void setIdPrefix(std::string prefix)
Sets the id prefix.
const std::string & lastItemId() const
Last item id.
void setYawDegrees(double yaw)
Sets the yaw degrees.
Click-to-place door/window tool committing makeCreateOpening on the nearest wall.
const ToolDescriptor & descriptor() const override
Descriptor.
void setSill(double sill)
Sets the sill.
void setWidth(double width)
Sets the width.
void setIdPrefix(std::string prefix)
Sets the id prefix.
void setHeight(double height)
Sets the height.
const std::string & lastOpeningId() const
Last opening id.
void setOpeningKind(archspace::OpeningKind kind)
Sets the opening kind.
const std::optional< editing::TransactionReceipt > & lastReceipt() const
Last receipt.
Click-drag wall draw tool. Down starts, Move previews, Up commits makeCreateWall.
void setWallThickness(double thickness)
Sets the wall thickness.
bool isDrawing() const
True when drawing.
const std::optional< editing::TransactionReceipt > & lastReceipt() const
Last receipt.
const ToolDescriptor & descriptor() const override
Descriptor.
void setContiguous(bool enabled)
Sets the contiguous.
const std::string & lastWallId() const
Last wall id.
void setIdPrefix(std::string prefix)
Sets the id prefix.
void setWallHeight(double height)
Sets the wall height.
Context supplied by EditorSession to tools.
Definition EditorTool.h:71
Host-owned conversion boundary between pointer coordinates and the ArchSpace viewport.
virtual editing::Result< OverlayPoint > projectWorld(const std::array< double, 3 > &world) const =0
Project a world position into the coordinate space accepted by IEditorOverlay.
virtual ~IArchSpaceViewportAdapter()=default
Releases IArchSpaceViewportAdapter resources.
virtual editing::Result< ArchSpaceViewportRay > pointerRay(const EditorPointerEvent &event) const =0
Build a world ray for one normalized pointer event.
UI-independent property editor used by tools to expose settings.
Sink implemented by a 2D or 3D viewport to render tool feedback.
Protocol implemented by every editor tool.
Definition EditorTool.h:110
OpeningKind
Opening semantic used by doors and windows hosted on walls.
bool enabled
Metres on the level XZ plane.
World-space ray produced by an ArchSpace editor viewport.
Pointer input normalized by an editor viewport adapter.
Definition EditorTool.h:20
UI-facing metadata supplied by a tool implementation.
Definition EditorTool.h:98
Result returned by a tool after processing input.
Definition EditorTool.h:50