PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
annotation_record.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
18#pragma once
19
20#include <chrono>
21#include <optional>
22#include <string>
23
24namespace kcenon::pacs::storage {
25
29enum class annotation_type {
30 arrow,
31 line,
32 rectangle,
33 ellipse,
34 polygon,
35 freehand,
36 text,
37 angle,
38 roi
39};
40
44[[nodiscard]] inline auto to_string(annotation_type type) -> std::string {
45 switch (type) {
46 case annotation_type::arrow: return "arrow";
47 case annotation_type::line: return "line";
48 case annotation_type::rectangle: return "rectangle";
49 case annotation_type::ellipse: return "ellipse";
50 case annotation_type::polygon: return "polygon";
51 case annotation_type::freehand: return "freehand";
52 case annotation_type::text: return "text";
53 case annotation_type::angle: return "angle";
54 case annotation_type::roi: return "roi";
55 }
56 return "unknown";
57}
58
62[[nodiscard]] inline auto annotation_type_from_string(std::string_view str)
63 -> std::optional<annotation_type> {
64 if (str == "arrow") return annotation_type::arrow;
65 if (str == "line") return annotation_type::line;
66 if (str == "rectangle") return annotation_type::rectangle;
67 if (str == "ellipse") return annotation_type::ellipse;
68 if (str == "polygon") return annotation_type::polygon;
69 if (str == "freehand") return annotation_type::freehand;
70 if (str == "text") return annotation_type::text;
71 if (str == "angle") return annotation_type::angle;
72 if (str == "roi") return annotation_type::roi;
73 return std::nullopt;
74}
75
80 std::string color{"#FFFF00"};
81 int line_width{2};
82 std::string fill_color;
83 float fill_opacity{0.0f};
84 std::string font_family{"Arial"};
85 int font_size{14};
86};
87
96 int64_t pk{0};
97
99 std::string annotation_id;
100
102 std::string study_uid;
103
105 std::string series_uid;
106
108 std::string sop_instance_uid;
109
111 std::optional<int> frame_number;
112
114 std::string user_id;
115
118
120 std::string geometry_json;
121
123 std::string text;
124
127
129 std::chrono::system_clock::time_point created_at;
130
132 std::chrono::system_clock::time_point updated_at;
133
139 [[nodiscard]] auto is_valid() const noexcept -> bool {
140 return !annotation_id.empty() && !study_uid.empty();
141 }
142};
143
160 std::optional<std::string> study_uid;
161
163 std::optional<std::string> series_uid;
164
166 std::optional<std::string> sop_instance_uid;
167
169 std::optional<std::string> user_id;
170
172 std::optional<annotation_type> type;
173
175 size_t limit{0};
176
178 size_t offset{0};
179
185 [[nodiscard]] auto has_criteria() const noexcept -> bool {
186 return study_uid.has_value() || series_uid.has_value() ||
187 sop_instance_uid.has_value() || user_id.has_value() ||
188 type.has_value();
189 }
190};
191
192} // namespace kcenon::pacs::storage
auto annotation_type_from_string(std::string_view str) -> std::optional< annotation_type >
Parse string to annotation_type.
auto to_string(annotation_type type) -> std::string
Convert annotation_type to string.
annotation_type
Annotation types supported by the system.
@ angle
Angle measurement annotation.
auto has_criteria() const noexcept -> bool
Check if any filter criteria is set.
std::optional< std::string > series_uid
Series Instance UID filter.
std::optional< std::string > user_id
User ID filter.
std::optional< std::string > sop_instance_uid
SOP Instance UID filter.
size_t limit
Maximum number of results to return (0 = unlimited)
std::optional< annotation_type > type
Annotation type filter.
std::optional< std::string > study_uid
Study Instance UID filter.
Annotation record from the database.
std::string annotation_id
Unique annotation identifier (UUID)
annotation_type type
Type of annotation.
int64_t pk
Primary key (auto-generated)
std::optional< int > frame_number
Frame number for multi-frame images (1-based)
std::string text
Text content for text annotations or labels.
std::string series_uid
Series Instance UID - DICOM tag (0020,000E)
std::string study_uid
Study Instance UID - DICOM tag (0020,000D)
annotation_style style
Visual style of the annotation.
std::chrono::system_clock::time_point created_at
Record creation timestamp.
std::chrono::system_clock::time_point updated_at
Record last update timestamp.
std::string sop_instance_uid
SOP Instance UID - DICOM tag (0008,0018)
std::string geometry_json
Geometry data as JSON string (type-specific coordinates)
std::string user_id
User who created the annotation.
auto is_valid() const noexcept -> bool
Check if this record has valid data.
Style information for annotations.
float fill_opacity
Fill opacity (0.0-1.0)
std::string font_family
Font family for text.
std::string fill_color
Fill color (hex), empty for no fill.
std::string color
Stroke/line color (hex)