Line |
Branch |
Exec |
Source |
1 |
|
|
/************************************************************************ |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2014-2023 IRCAD France |
4 |
|
|
* Copyright (C) 2014-2020 IHU Strasbourg |
5 |
|
|
* |
6 |
|
|
* This file is part of Sight. |
7 |
|
|
* |
8 |
|
|
* Sight is free software: you can redistribute it and/or modify it under |
9 |
|
|
* the terms of the GNU Lesser General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* Sight is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU Lesser General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU Lesser General Public |
19 |
|
|
* License along with Sight. If not, see <https://www.gnu.org/licenses/>. |
20 |
|
|
* |
21 |
|
|
***********************************************************************/ |
22 |
|
|
|
23 |
|
|
#include "viz/scene3d/light_adaptor.hpp" |
24 |
|
|
|
25 |
|
|
#include <service/registry.hpp> |
26 |
|
|
|
27 |
|
|
#include <string> |
28 |
|
|
|
29 |
|
|
namespace sight::viz::scene3d |
30 |
|
|
{ |
31 |
|
|
|
32 |
|
|
//----------------------------------------------------------------------------- |
33 |
|
|
|
34 |
|
|
const std::string light_adaptor::REGISTRY_KEY = "sight::viz::scene3d::light_adaptor::REGISTRY_KEY"; |
35 |
|
|
|
36 |
|
|
const std::string light_adaptor::POINT_LIGHT = "Point"; |
37 |
|
|
const std::string light_adaptor::DIRECTIONAL_LIGHT = "Directional"; |
38 |
|
|
const std::string light_adaptor::SPOT_LIGHT = "Spot"; |
39 |
|
|
|
40 |
|
|
const int viz::scene3d::light_adaptor::OFFSET_RANGE = 180; |
41 |
|
|
|
42 |
|
|
//----------------------------------------------------------------------------- |
43 |
|
|
|
44 |
|
57 |
viz::scene3d::light_adaptor::sptr light_adaptor::create_light_adaptor( |
45 |
|
|
data::color::sptr _diffuse, |
46 |
|
|
data::color::sptr _specular |
47 |
|
|
) |
48 |
|
|
{ |
49 |
|
57 |
viz::scene3d::light_adaptor::sptr light_adaptor = viz::scene3d::light_factory::make( |
50 |
|
|
viz::scene3d::light_adaptor::REGISTRY_KEY |
51 |
|
57 |
); |
52 |
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
|
114 |
service::register_service(light_adaptor); |
53 |
|
57 |
SIGHT_ASSERT("The factory process to create an light_adaptor failed.", light_adaptor); |
54 |
|
57 |
SIGHT_ASSERT("The light adaptor must be registered with existing data objects.", _diffuse && _specular); |
55 |
|
|
|
56 |
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
|
114 |
light_adaptor->set_inout(_diffuse, "diffuseColor"); |
57 |
2/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
114 |
light_adaptor->set_inout(_specular, "specularColor"); |
58 |
|
|
|
59 |
|
57 |
return light_adaptor; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
//----------------------------------------------------------------------------- |
63 |
|
|
|
64 |
|
57 |
void light_adaptor::destroy_light_adaptor(light_adaptor::sptr _light_adaptor) |
65 |
|
|
{ |
66 |
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
|
57 |
if(_light_adaptor) |
67 |
|
|
{ |
68 |
|
57 |
_light_adaptor->stop(); |
69 |
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
|
171 |
service::unregister_service(_light_adaptor); |
70 |
|
|
} |
71 |
|
57 |
} |
72 |
|
|
|
73 |
|
|
//----------------------------------------------------------------------------- |
74 |
|
|
|
75 |
|
57 |
viz::scene3d::light_adaptor::light_adaptor() |
76 |
|
|
= default; |
77 |
|
|
|
78 |
|
|
//----------------------------------------------------------------------------- |
79 |
|
|
|
80 |
|
114 |
viz::scene3d::light_adaptor::~light_adaptor() |
81 |
|
|
= default; |
82 |
|
|
|
83 |
|
|
//----------------------------------------------------------------------------- |
84 |
|
|
|
85 |
|
|
} // namespace sight::viz::scene3d |
86 |
|
|
|