OpenStructure
gfx_object_base.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_OBJ_BASE_HH
20 #define OST_GFX_OBJ_BASE_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <ost/geom/geom.hh>
27 #include <ost/mol/entity_handle.hh>
28 #include <ost/mol/entity_view.hh>
29 #include <ost/img/map.hh>
30 
31 #include <ost/config.hh>
32 #include "module_config.hh"
33 
34 #include "gfx_node.hh"
35 #include "color.hh"
36 #include "render_mode.hh"
37 #include "gradient.hh"
38 #include "material.hh"
39 #include "color_ops/color_op.hh"
40 
41 namespace ost { namespace gfx {
42 
43 class Scene; // fw decl
44 
46 /*
47  this abstract base class is for both the actual GfxObj as well as a
48  shortly implemented re-design of the GfxNode, and hence temporary in
49  its current form
50 */
52 {
53  public:
54  GfxObjBase(const String& name): GfxNode(name) {}
55 
57  virtual void SetMatAmb(const Color& c) = 0;
59  virtual void SetMatDiff(const Color& c) = 0;
61  virtual void SetMatSpec(const Color& c) = 0;
63  virtual void SetMatShin(float s) = 0;
65  virtual void SetMatEmm(const Color& c) = 0;
66 
68  virtual void ContextSwitch() = 0;
69 
71  virtual void SetRenderMode(RenderMode::Type m) = 0;
73  virtual RenderMode::Type GetRenderMode() const = 0;
74 
76  virtual geom::Vec3 GetCenter() const = 0;
77 
79  virtual void SetLineWidth(float w) = 0;
80 
82  virtual void SetPolyMode(unsigned int m) = 0;
83 
85  virtual void SetAALines(bool f) = 0;
86 
88  virtual void SetLineHalo(float f) = 0;
89 
91  virtual void SetOutline(bool f) = 0;
93  virtual bool GetOutline() const = 0;
95  virtual void SetOutlineMode(int m) = 0;
97  virtual int GetOutlineMode() const = 0;
100  virtual void SetOutlineWidth(float f) = 0;
102  virtual float GetOutlineWidth() const = 0;
105  virtual void SetOutlineExpandFactor(float f) = 0;
107  virtual float GetOutlineExpandFactor() const = 0;
109  virtual void SetOutlineExpandColor(const Color& c) = 0;
111  virtual Color GetOutlineExpandColor() const = 0;
112 
114  virtual void SetOpacity(float f) = 0;
116  virtual float GetOpacity() const = 0;
117 
118  virtual void SetSolid(bool f) = 0;
119  virtual bool GetSolid() const = 0;
120  virtual void SetSolidColor(const Color& c) = 0;
121  virtual Color GetSolidColor() const = 0;
122 
123  virtual void SetClip(bool f) = 0;
124  virtual bool GetClip() const = 0;
125  virtual void SetClipPlane(const geom::Vec4&) = 0;
126  virtual geom::Vec4 GetClipPlane() const = 0;
127  virtual void SetClipOffset(float f) = 0;
128  virtual float GetClipOffset() const = 0;
129 
132  virtual void ColorBy(const mol::EntityView& ev,
133  const String& prop,
134  const Gradient& g, float minv, float maxv) = 0;
135 
137  virtual void ColorBy(const img::MapHandle& mh,
138  const String& prop,
139  const Gradient& g,float minv, float maxv) = 0;
140 };
141 
142 }} // ns
143 
144 #endif
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
main interface for all graphic objects, both in C++ and Python
virtual int GetOutlineMode() const =0
get current outline mode
virtual void SetOutlineExpandFactor(float f)=0
set outline expansion factor (mode 3) this scales with resolution
virtual void SetMatSpec(const Color &c)=0
material specular color
virtual float GetOutlineExpandFactor() const =0
get current outline expand factor (mode 3)
virtual float GetOutlineWidth() const =0
get current outline width
GfxObjBase(const String &name)
virtual void ContextSwitch()=0
rendering context switch, some things need to be regenerated
virtual bool GetClip() const =0
virtual void SetAALines(bool f)=0
turn on sophisticated line anti-aliasing, requires shader
virtual Color GetSolidColor() const =0
virtual void SetClipPlane(const geom::Vec4 &)=0
virtual geom::Vec3 GetCenter() const =0
get geometric center
virtual void SetMatAmb(const Color &c)=0
material ambient color
virtual void ColorBy(const img::MapHandle &mh, const String &prop, const Gradient &g, float minv, float maxv)=0
color based on image
virtual float GetOpacity() const =0
returns a value smaller than 1.0 if transparency is used in this object
virtual void SetRenderMode(RenderMode::Type m)=0
change render mode
virtual void SetClip(bool f)=0
virtual bool GetSolid() const =0
virtual void SetMatDiff(const Color &c)=0
material diffuse color
virtual void SetClipOffset(float f)=0
virtual void SetLineHalo(float f)=0
turn on line halo of given strength
virtual geom::Vec4 GetClipPlane() const =0
virtual void SetOpacity(float f)=0
set opacity (1 = no transparency)
virtual RenderMode::Type GetRenderMode() const =0
current render mode
virtual float GetClipOffset() const =0
virtual void SetMatShin(float s)=0
material shininess
virtual void ColorBy(const mol::EntityView &ev, const String &prop, const Gradient &g, float minv, float maxv)=0
color each component based on the gradient-mapped property of the given entity
virtual void SetMatEmm(const Color &c)=0
material emmissive color
virtual void SetOutlineWidth(float f)=0
set outline width in pixels (modes 1 + 2) this does not scale with resolution
virtual Color GetOutlineExpandColor() const =0
get current outline color (mode 3)
virtual void SetOutlineExpandColor(const Color &c)=0
set outline color (mode 3)
virtual void SetOutlineMode(int m)=0
set outline mode, 1, 2 or 3
virtual void SetSolid(bool f)=0
virtual void SetPolyMode(unsigned int m)=0
set polygon mode
virtual void SetLineWidth(float w)=0
set line width
virtual bool GetOutline() const =0
get state of outline rendering
virtual void SetSolidColor(const Color &c)=0
virtual void SetOutline(bool f)=0
turn outline rendering on or off
color gradient
Definition: gradient.hh:59
Manage shared instances of images.
definition of EntityView
Definition: entity_view.hh:86
#define DLLEXPORT_OST_GFX
std::string String
Definition: base.hh:54
Definition: base.dox:1