Visual Computing Library
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
89 virtual vcl::Box3d boundingBox() const = 0;
90
111 virtual std::shared_ptr<DrawableObject> clone() const& = 0;
112
135 virtual std::shared_ptr<DrawableObject> clone() && = 0;
136
142
147 virtual void setVisibility(bool vis) = 0;
148
153 virtual const std::string& name() const { return mName; }
154
160 virtual std::string& name() { return mName; }
161
166 const std::string& info() const { return mInfo; }
167
173 std::string& info() { return mInfo; }
174
175protected:
186 {
187 using std::swap;
188 swap(mName, other.mName);
189 swap(mInfo, other.mInfo);
190 }
191};
192
193} // namespace vcl
194
195#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:185
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:173
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:166
virtual const std::string & name() const
Returns the name of the object.
Definition drawable_object.h:153
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:160
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.
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43