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 <vclib/space/core/box.h>
27#include <vclib/space/core/point.h>
28
29namespace vcl {
30
55{
56 std::string mName;
58 std::string mInfo;
60public:
62 DrawableObject() = default;
63
64 virtual ~DrawableObject() {}
65
71 virtual void init() {};
72
80 virtual void draw(uint viewId = 0) const = 0;
81
91 virtual void drawId(uint viewId, uint id) const {};
92
100 virtual vcl::Box3d boundingBox() const = 0;
101
122 virtual std::shared_ptr<DrawableObject> clone() const& = 0;
123
146 virtual std::shared_ptr<DrawableObject> clone() && = 0;
147
153
158 virtual void setVisibility(bool vis) = 0;
159
164 virtual const std::string& name() const { return mName; }
165
171 virtual std::string& name() { return mName; }
172
177 const std::string& info() const { return mInfo; }
178
184 std::string& info() { return mInfo; }
185
186protected:
197 {
198 using std::swap;
199 swap(mName, other.mName);
200 swap(mInfo, other.mInfo);
201 }
202};
203
204} // namespace vcl
205
206#endif // VCL_RENDER_DRAWABLE_DRAWABLE_OBJECT_H
The DrawableObject class is the base class for all the objects that can be drawn in a 3D viewer.
Definition drawable_object.h:55
void swap(DrawableObject &other)
Utility swap function that allows to swap the content of two DrawableObject instances.
Definition drawable_object.h:196
std::string mName
Name of the object.
Definition drawable_object.h:56
std::string mInfo
Info about the object.
Definition drawable_object.h:58
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:184
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.
const std::string & info() const
Returns the info of the object.
Definition drawable_object.h:177
virtual const std::string & name() const
Returns the name of the object.
Definition drawable_object.h:164
virtual void drawId(uint viewId, uint id) const
This member function should draw the object. It will be called on request when the renderer needs to ...
Definition drawable_object.h:91
virtual void init()
This member function is called after the initialization of the Context. It must initialize and bind d...
Definition drawable_object.h:71
virtual std::string & name()
Returns a reference of the name of the object, that allows to modify it.
Definition drawable_object.h:171
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.
virtual void draw(uint viewId=0) const =0
This member function must draw the object. It will be called at every frame.