Visual Computing Library  devel
Loading...
Searching...
No Matches
drawable_object.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_RENDER_DRAWABLE_DRAWABLE_OBJECT_H
24#define VCL_RENDER_DRAWABLE_DRAWABLE_OBJECT_H
25
26#include "draw_object_settings.h"
27
28#include <vclib/space/core/box.h>
29#include <vclib/space/core/point.h>
30
31namespace vcl {
32
57{
58 std::string mName;
60 std::string mInfo;
62public:
64 DrawableObject() = default;
65
66 virtual ~DrawableObject() {}
67
73 virtual void init() {};
74
81 virtual void draw(const DrawObjectSettings& settings = {}) const = 0;
82
90 virtual void drawId(const DrawObjectSettings& settings) const {};
91
99 virtual vcl::Box3d boundingBox() const = 0;
100
121 virtual std::shared_ptr<DrawableObject> clone() const& = 0;
122
145 virtual std::shared_ptr<DrawableObject> clone() && = 0;
146
152
157 virtual void setVisibility(bool vis) = 0;
158
163 virtual const std::string& name() const { return mName; }
164
170 virtual std::string& name() { return mName; }
171
176 const std::string& info() const { return mInfo; }
177
183 std::string& info() { return mInfo; }
184
185protected:
196 {
197 using std::swap;
198 swap(mName, other.mName);
199 swap(mInfo, other.mInfo);
200 }
201};
202
203} // namespace vcl
204
205#endif // VCL_RENDER_DRAWABLE_DRAWABLE_OBJECT_H
A class representing a box in N-dimensional space.
Definition box.h:46
The DrawableObject class is the base class for all the objects that can be drawn in a 3D viewer.
Definition drawable_object.h:57
void swap(DrawableObject &other)
Utility swap function that allows to swap the content of two DrawableObject instances.
Definition drawable_object.h:195
std::string mName
Name of the object.
Definition drawable_object.h:58
std::string mInfo
Info about the object.
Definition drawable_object.h:60
virtual void setVisibility(bool vis)=0
This member function is used to set the visibility of the object.
std::string & info()
Returns a reference of the info of the object, that allows to modify it.
Definition drawable_object.h:183
virtual vcl::Box3d boundingBox() const =0
This member function is used to find a good camera position to render object. It should return the th...
virtual bool isVisible() const =0
This member function is used to check if the object is visible.
virtual void draw(const DrawObjectSettings &settings={}) const =0
This member function must draw the object. It will be called at every frame.
const std::string & info() const
Returns the info of the object.
Definition drawable_object.h:176
virtual void drawId(const DrawObjectSettings &settings) const
This member function should draw the object. It will be called on request when the renderer needs to ...
Definition drawable_object.h:90
virtual const std::string & name() const
Returns the name of the object.
Definition drawable_object.h:163
virtual void init()
This member function is called after the initialization of the Context. It must initialize and bind d...
Definition drawable_object.h:73
virtual std::string & name()
Returns a reference of the name of the object, that allows to modify it.
Definition drawable_object.h:170
virtual std::shared_ptr< DrawableObject > clone() const &=0
This member function is used to create a new copy of the DrawableObject. Each derived class must impl...
DrawableObject()=default
Empty constructor.