21template <
bool V,
bool C2,
bool C3>
28 template <
typename VT,
typename C2T,
typename C3T>
30 : component_v(v_type), component_2d(c2_type), component_3d(c3_type) {
33 static_assert(V == !std::is_same_v<VT, std::nullptr_t>);
34 static_assert(C2 == !std::is_same_v<C2T, std::nullptr_t>);
35 static_assert(C3 == !std::is_same_v<C3T, std::nullptr_t>);
65 return std::move(*
this);
88 return std::move(*
this);
100 static_assert(V || C2,
101 "onClick can be set only for View, Canvas2D components");
116 return std::move(*
this);
127 static_assert(V || C2,
128 "onClick can be set only for View, Canvas2D components");
142 return std::move(*
this);
152 template <
typename T,
typename std::enable_if_t<std::is_invocable_v<T>,
153 std::
nullptr_t> =
nullptr>
155 static_assert(V || C2,
156 "onClick can be set only for View, Canvas2D components");
161 component_v.
onClick(func_shared);
164 component_2d.
onClick(func_shared);
171 template <
typename T,
typename std::enable_if_t<std::is_invocable_v<T>,
172 std::
nullptr_t> =
nullptr>
174 this->onClick(std::move(func));
175 return std::move(*
this);
184 "origin can be set only for Canvas2D, Canvas3D components");
186 component_2d.
origin(origin);
189 component_3d.
origin(origin);
197 this->origin(origin);
198 return std::move(*
this);
210 component_2d.
color(c);
213 component_3d.
color(c);
222 return std::move(*
this);
229 static_assert(V || C2,
230 "text can be set only for View, Canvas2D components");
232 component_v.
text(str);
235 component_2d.
text(str);
244 return std::move(*
this);
251 static_assert(V || C2,
252 "text can be set only for View, Canvas2D components");
254 component_v.
text(str);
257 component_2d.
text(str);
266 return std::move(*
this);
275 V || C2,
"textColor can be set only for View, Canvas2D components");
289 return std::move(*
this);
297 V || C2,
"fillColor can be set only for View, Canvas2D components");
311 return std::move(*
this);
318 static_assert(V || C2,
319 "bgColor can be set only for View, Canvas2D components");
327 return std::move(*
this);
336 "strokeWidth can be set only for Canvas2D components");
346 this->strokeWidth(s);
347 return std::move(*
this);
354 static_assert(C2,
"textSize can be set only for Canvas2D components");
365 return std::move(*
this);
374 Geometry(type, std::move(properties)) {
375 this->component_2d.geometry(
static_cast<Geometry &
>(*
this));
376 this->component_3d.geometry(
static_cast<Geometry &
>(*
this));
380inline namespace components {
381inline namespace geometries {
387 throw std::invalid_argument(
"number of properties does not match");
401 {begin.
pos()[0], begin.
pos()[1], begin.
pos()[2],
402 end.
pos()[0], end.
pos()[1], end.
pos()[2]});
407 if (base.
properties.size() % 3 != 0 || size() == 0) {
408 throw std::invalid_argument(
"number of properties does not match");
414 throw std::out_of_range(
"Polygon::at(" + std::to_string(i) +
415 "), size = " + std::to_string(size()));
423 std::vector<double> properties;
424 properties.reserve(points.size() * 3);
425 for (
const auto &p : points) {
426 properties.push_back(p.pos(0));
427 properties.push_back(p.pos(1));
428 properties.push_back(p.pos(2));
436 throw std::invalid_argument(
"number of properties does not match");
463 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2],
465 origin.
rotEuler()[2], width, height});
470 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2],
471 0, 0, 0, width, height}};
475 for (
int i = 0; i < 2; i++) {
476 origin.
pos(i) = (p1.
pos(i) + p2.
pos(i)) / 2;
478 double width = std::abs(p1.
pos(0) - p2.
pos(0));
479 double height = std::abs(p1.
pos(0) - p2.
pos(0));
481 {origin.
pos(0), origin.
pos(1), origin.
pos(2),
483 origin.
rotEuler()[2], width, height}};
490 throw std::invalid_argument(
"number of properties does not match");
504 {vertex1.
pos()[0], vertex1.
pos()[1],
505 vertex1.
pos()[2], vertex2.
pos()[0],
506 vertex2.
pos()[1], vertex2.
pos()[2]}};
513 throw std::invalid_argument(
"number of properties does not match");
526 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2],
532 GeometryType::circle,
533 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2], 0, 0, 0, radius}};
540 throw std::invalid_argument(
"number of properties does not match");
555 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2],
557 origin.
rotEuler()[2], radius, length}};
564 throw std::invalid_argument(
"number of properties does not match");
575 GeometryType::sphere,
576 {origin.
pos()[0], origin.
pos()[1], origin.
pos()[2], radius}};
582namespace Geometries = geometries;
590 ViewComponentType::text, Canvas2DComponentType::text,
nullptr)
599 ViewComponentType::text, Canvas2DComponentType::text,
nullptr)
618 .
onClick(std::forward<T>(func));
628 .
onClick(std::forward<T>(func));
691namespace Components = components;
692namespace ViewComponents = components;
Canvas2Dの送受信データを表すクラス
Definition canvas2d.h:24
Canvas3Dの送受信データを表すクラス
Definition canvas3d.h:28
関数1つを表すクラス
Definition func.h:95
3次元 or 2次元の座標を表すクラス。
Definition transform.h:23
std::array< double, 3 > pos() const
3次元座標を取得
Definition transform.h:62
Definition component_canvas2d.h:137
TemporalCanvas2DComponent & onClick(const Func &func) &
クリック時に実行される関数を設定 (Funcオブジェクト)
Definition component_canvas2d.cc:181
TemporalCanvas2DComponent & strokeWidth(double s) &
線の太さ
Definition component_canvas2d.cc:131
TemporalCanvas2DComponent & color(const ViewColor &color) &
図形の輪郭の色
Definition component_canvas2d.cc:114
TemporalCanvas2DComponent & text(std::string_view text) &
表示する文字列を設定
Definition component_canvas2d.cc:140
TemporalCanvas2DComponent & textSize(double s) &
文字の大きさ(高さ)
Definition component_canvas2d.h:251
TemporalCanvas2DComponent & id(std::string_view id)
idを設定
Definition component_canvas2d.cc:85
TemporalCanvas2DComponent & origin(const Transform &origin) &
要素の移動・回転
Definition component_canvas2d.cc:104
TemporalCanvas2DComponent & fillColor(const ViewColor &color) &
塗りつぶし色
Definition component_canvas2d.cc:123
Canvas3Dを構築するときに使う一時的なCanvas3DComponent.
Definition component_canvas3d.h:116
TemporalCanvas3DComponent & color(ViewColor color) &
色
Definition component_canvas3d.cc:96
TemporalCanvas3DComponent & origin(const Transform &origin) &
要素の移動
Definition component_canvas3d.cc:87
TemporalCanvas3DComponent & id(std::string_view id)
idを設定
Definition component_canvas3d.cc:69
Definition components.h:369
TemporalGeometry(GeometryType type, std::vector< double > &&properties)
Definition components.h:371
Viewを構築するときに使う一時的なViewComponent.
Definition component_view.h:267
TemporalViewComponent & id(std::string_view id)
idを設定
Definition component_view.cc:250
TemporalViewComponent & text(std::string_view text) &
表示する文字列を設定
Definition component_view.cc:266
TemporalViewComponent & init(const T &init) &
デフォルト値を設定する。
Definition component_view.h:490
TemporalViewComponent & bgColor(ViewColor c) &
背景色を設定
Definition component_view.cc:340
TemporalViewComponent & textColor(ViewColor c) &
文字色を設定
Definition component_view.cc:332
TemporalViewComponent & onClick(const Func &func) &
クリック時に実行される関数を設定 (登録済みFunc)
Definition component_view.cc:286
Viewの送受信データを表すクラス
Definition view.h:26
Viewの送信用データを保持する
Definition data_buffer.h:108
TemporalGeometry line(const Point &begin, const Point &end)
Definition components.h:399
TemporalGeometry rect(const Point &origin, double width, double height)
Definition components.h:468
TemporalGeometry circle(const Transform &origin, double radius)
Definition components.h:524
TemporalGeometry cylinder(const Transform &origin, double radius, double length)
Definition components.h:552
TemporalGeometry plane(const Transform &origin, double width, double height)
Definition components.h:460
TemporalGeometry polygon(const std::vector< Point > &points)
Definition components.h:422
TemporalGeometry box(const Point &vertex1, const Point &vertex2)
Definition components.h:502
TemporalGeometry sphere(const Point &origin, double radius)
Definition components.h:573
TemporalViewComponent toggleInput(std::string_view text="")
Definition components.h:657
TemporalViewComponent numberInput(std::string_view text="")
Definition components.h:647
TemporalViewComponent selectInput(std::string_view text="")
Definition components.h:663
TemporalViewComponent newLine()
newLineコンポーネント
Definition components.h:606
TemporalViewComponent button(std::string_view text, T &&func)
buttonコンポーネント
Definition components.h:615
TemporalViewComponent sliderInput(std::string_view text="")
Definition components.h:669
TemporalViewComponent checkInput(std::string_view text="")
Definition components.h:679
TemporalViewComponent textInput(std::string_view text="")
Definition components.h:631
TemporalViewComponent decimalInput(std::string_view text="")
Definition components.h:637
Canvas2DComponentType
Definition component_canvas2d.h:22
GeometryType
Canvas3Dと2Dで共用、図形の種類を表す
Definition geometry.h:15
ViewColor
Definition component_view.h:40
Rotation rotFromEuler(const std::array< double, 3 > &rot, AxisSequence axis=AxisSequence::ZYX)
回転をオイラー角から初期化
Definition transform.h:482
Transform identity()
移動なし、回転なしのTransform
Definition transform.h:794
Canvas3DComponentType
Definition component_canvas3d.h:20
std::vector< double > properties
Definition geometry.h:28
Canvas2D, Canvas3D (, View) に要素をaddするときに使うインタフェース
Definition components.h:22
TemporalComponent & onClick(T func) &
クリック時に実行される関数を設定 (Viewまたは2D)
Definition components.h:154
TemporalComponent && onClick(const Func &func) &&
Definition components.h:114
TemporalComponent && fillColor(ViewColor c) &&
Definition components.h:309
TemporalComponent & strokeWidth(double s) &
線の太さ (2Dのみ)
Definition components.h:334
TemporalComponent && strokeWidth(double s) &&
Definition components.h:345
TemporalComponent & textColor(ViewColor c) &
文字色 (Viewまたは2D)
Definition components.h:273
TemporalComponent & color(ViewColor c) &
色
Definition components.h:205
TemporalComponent & id(std::wstring_view id) &
idを設定(wstring)
Definition components.h:71
TemporalComponent && origin(const Transform &origin) &&
Definition components.h:196
TemporalComponent && bgColor(ViewColor c) &&
Definition components.h:325
TemporalComponent & origin(const Transform &origin) &
要素の移動 (2Dまたは3D)
Definition components.h:181
TemporalComponent && textColor(ViewColor c) &&
Definition components.h:287
TemporalComponent && text(std::string_view str) &&
Definition components.h:242
TemporalComponent()=default
TemporalComponent && id(std::wstring_view id) &&
Definition components.h:86
TemporalCanvas2DComponent component_2d
Definition components.h:24
TemporalComponent & bgColor(ViewColor c) &
背景色 (Viewまたは2D)
Definition components.h:317
TemporalComponent & textSize(double s) &
文字の大きさ (2Dのみ)
Definition components.h:353
TemporalCanvas3DComponent component_3d
Definition components.h:25
TemporalComponent & text(std::wstring_view str) &
表示する文字列(wstring) (View, Canvas2D)
Definition components.h:250
TemporalComponent & text(std::string_view str) &
表示する文字列 (View, Canvas2D)
Definition components.h:228
TemporalComponent & id(std::string_view id) &
idを設定
Definition components.h:48
TemporalViewComponent component_v
Definition components.h:23
TemporalComponent & fillColor(ViewColor c) &
背景色 (Viewまたは2D)
Definition components.h:295
TemporalComponent && textSize(double s) &&
Definition components.h:363
TemporalComponent & onClick(const FuncListener &func) &
クリック時に実行される関数を設定 (Viewまたは2D, FuncListener)
Definition components.h:126
TemporalComponent & onClick(const Func &func) &
クリック時に実行される関数を設定 (Viewまたは2D, Funcオブジェクト)
Definition components.h:99
TemporalComponent && id(std::string_view id) &&
Definition components.h:63
TemporalComponent && onClick(T func) &&
Definition components.h:173
TemporalComponent && onClick(const FuncListener &func) &&
Definition components.h:140
TemporalComponent && text(std::wstring_view str) &&
Definition components.h:264
TemporalComponent && color(ViewColor c) &&
Definition components.h:220
TemporalComponent(VT v_type, C2T c2_type, C3T c3_type)
Definition components.h:29
Definition components.h:486
const Geometry & base
Definition components.h:487
Box(const Geometry &rg)
Definition components.h:488
Point vertex2() const
Definition components.h:497
Point vertex1() const
Definition components.h:493
Definition components.h:509
const Geometry & base
Definition components.h:510
Circle(const Geometry &rg)
Definition components.h:511
double radius() const
Definition components.h:522
Transform origin() const
Definition components.h:516
Definition components.h:536
const Geometry & base
Definition components.h:537
double radius() const
Definition components.h:549
double length() const
Definition components.h:550
Cylinder(const Geometry &rg)
Definition components.h:538
Transform origin() const
Definition components.h:543
Definition components.h:383
const Geometry & base
Definition components.h:384
Point end() const
Definition components.h:394
Line(const Geometry &rg)
Definition components.h:385
Point begin() const
Definition components.h:390
Definition components.h:432
const Geometry & base
Definition components.h:433
double width() const
Definition components.h:445
double height() const
Definition components.h:446
Transform origin() const
Definition components.h:439
Point vertex2() const
Definition components.h:455
Plane(const Geometry &rg)
Definition components.h:434
Point vertex1() const
Definition components.h:451
Definition components.h:404
const Geometry & base
Definition components.h:405
Point at(std::size_t i) const
Definition components.h:412
Point operator[](std::size_t i) const
Definition components.h:420
Polygon(const Geometry &rg)
Definition components.h:406
std::size_t size() const
Definition components.h:411
Definition components.h:560
const Geometry & base
Definition components.h:561
double radius() const
Definition components.h:571
Point origin() const
Definition components.h:567
Sphere(const Geometry &rg)
Definition components.h:562
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103
#define WEBCFACE_CALL_FP
Definition webcface-config.h:98