Blue Brain BioExplorer
MultiviewPlugin.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  *
5  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,l
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "MultiviewPlugin.h"
22 
23 #include <Version.h>
24 
32 
33 const std::string RENDERER_MULTI_VIEW = "multiview";
34 
35 namespace core
36 {
38  : _properties(std::move(properties))
39 {
40  const double armLength = _properties.getProperty<double>(PARAM_ARM_LENGTH);
41  if (armLength <= 0.0f)
42  CORE_THROW("The " + RENDERER_MULTI_VIEW + " camera arm length must be strictly positive");
43 }
44 
46 {
47  auto& engine = _api->getEngine();
48  auto& params = engine.getParametersManager();
49  if (params.getApplicationParameters().getEngine() == ENGINE_OSPRAY)
50  {
52  engine.addCameraType(RENDERER_MULTI_VIEW, _properties);
53  }
54  else
55  CORE_THROW("The " + RENDERER_MULTI_VIEW + " camera is only available for " + ENGINE_OSPRAY + " engine");
56 }
57 } // namespace core
58 
59 extern "C" core::ExtensionPlugin* core_plugin_create(const int argc, const char** argv)
60 {
61  CORE_INFO("");
62  CORE_INFO(" _| _| _| _| _| _| ");
63  CORE_INFO(" _|_| _|_| _| _| _| _|_|_|_| _| _| _|_| _| _| _|");
64  CORE_INFO(" _| _| _| _| _| _| _| _| _|_|_|_|_| _| _| _| _|_|_|_| _| _| _|");
65  CORE_INFO(" _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| ");
66  CORE_INFO(" _| _| _|_|_| _| _|_| _| _| _| _|_|_| _| _| ");
67  CORE_INFO("");
68  CORE_INFO("Initializing Multi-view plug-in (version " << PACKAGE_VERSION_STRING << ")");
69 
70  core::PropertyMap properties;
71  properties.setProperty(
72  {PARAM_ARM_LENGTH, 5.0, 0.0, 100.0, {"Arm length", "The distance between the cameras and the view center"}});
73  properties.setProperty({core::CAMERA_PROPERTY_HEIGHT.name,
74  10.0,
75  0.0,
76  100.0,
77  {"View height", "The height of the viewport in world space"}});
78 
79  if (!properties.parse(argc, argv))
80  return nullptr;
81  return new core::MultiviewPlugin(std::move(properties));
82 }
const std::string PARAM_ARM_LENGTH
Definition: CommonStructs.h:28
const std::string RENDERER_MULTI_VIEW
core::ExtensionPlugin * core_plugin_create(const int argc, const char **argv)
PLATFORM_API const auto & getParametersManager() const
Returns the parameter manager.
Definition: Engine.h:210
MultiviewPlugin(PropertyMap &&properties)
virtual Engine & getEngine()=0
void setProperty(const Property &newProperty)
Definition: PropertyMap.h:307
T getProperty(const std::string &name, T valIfNotFound) const
Definition: PropertyMap.h:323
bool parse(int argc, const char **argv)
#define CORE_THROW(__msg)
Definition: Logs.h:42
#define PLUGIN_REGISTER_CAMERA(__msg)
Definition: Logs.h:69
#define CORE_INFO(__msg)
Definition: Logs.h:33
const std::string name
Definition: PropertyMap.h:209