OpenStructure
Loading...
Searching...
No Matches
prim_list.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_PRIM_LIST_HH
20#define OST_GFX_PRIM_LIST_HH
21
22/*
23 Author: Ansgar Philippsen
24*/
25
26#include <boost/shared_ptr.hpp>
27
28#include <ost/geom/geom.hh>
29
30#include "gfx_object.hh"
31#include "gfx_prim.hh"
32
33namespace ost { namespace gfx {
34
39{
40 struct PointEntry {
41 PointEntry(const geom::Vec3& p, float r, const Color& c):
42 pos(p), rad(r), col(c) {}
43 geom::Vec3 pos;
44 float rad;
45 Color col;
46 };
47
48 typedef std::vector<PointEntry> PointEntryList;
49
50 struct LineEntry {
51 LineEntry(const geom::Vec3& p1, const geom::Vec3& p2, float r1, float r2, const Color& c1, const Color& c2):
52 pos1(p1), pos2(p2), radius_1(r1), radius_2(r2), col1(c1), col2(c2) {}
53 geom::Vec3 pos1, pos2;
54 float radius_1, radius_2;
55 Color col1, col2;
56 };
57
58 typedef std::vector<LineEntry> LineEntryList;
59
60 public:
62 PrimList(const String& name);
63
64 virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=true) const;
65
66 virtual void ProcessLimits(geom::Vec3& minc, geom::Vec3& maxc,
67 const geom::Transform& tf) const;
69 virtual geom::Vec3 GetCenter() const;
70
71 virtual void CustomRenderPov(PovState& pov);
72
73 virtual void CustomRenderGL(RenderPass pass);
74
75 virtual void OnRenderModeChange();
76
77 virtual void SetLineWidth(float w);
79 void Clear();
80
88 void AddPoint(const geom::Vec3& p, const Color& col);
89
97 void AddLine(const geom::Vec3& p1, const geom::Vec3& p2, const Color& col1, const Color& col2);
98
106 void AddSphere(const geom::Vec3& cen, float rad, const Color& col);
107
115 void AddCyl(const geom::Vec3& p0, const geom::Vec3& p1, float r1, float r2, const Color& col1, const Color& col2);
116
124 void AddText(const std::string& text, const geom::Vec3& pos, const Color& col, float point_size);
125
127 void SetDiameter(float d);
128
130 void SetRadius(float r);
131
133 void SetColor(const Color& c);
134
135 void SetSphereDetail(unsigned int d);
136 unsigned int GetSphereDetail() const {return sphere_detail_;}
137
138 void SetArcDetail(unsigned int d);
139 unsigned int GetArcDetail() const {return arc_detail_;}
140
141 // TODO: add point and line pixel width
142
159 void AddMesh(float* v, float* n, float* c, size_t nv, unsigned int* i, size_t ni);
160
161 protected:
162 virtual void CustomPreRenderGL(bool flag);
163
164 private:
165 SpherePrimList points_;
166 CylinderPrimList lines_;
167 SpherePrimList spheres_;
168 CylinderPrimList cyls_;
169 TextPrimList texts_;
170 unsigned int sphere_detail_;
171 unsigned int arc_detail_;
172
173 IndexedVertexArray simple_va_;
174
175 std::vector<IndexedVertexArray> vas_;
176
177 void prep_simple_va();
178 void prep_va();
179 void render_text();
180};
181
187
192}} // ns
193
194#endif
axis-aligned cuboid
basic and essential transformation class, including translation, rotation and center of rotation
Definition transform.hh:39
Three dimensional vector class, using Real precision.
Definition vec3.hh:48
main class for all graphic objects
Definition gfx_object.hh:52
virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=true) const
returns the bounding box of this object
virtual void CustomRenderPov(PovState &pov)
virtual void OnRenderModeChange()
void SetArcDetail(unsigned int d)
unsigned int GetSphereDetail() const
Definition prim_list.hh:136
void AddSphere(const geom::Vec3 &cen, float rad, const Color &col)
add sphere
virtual void ProcessLimits(geom::Vec3 &minc, geom::Vec3 &maxc, const geom::Transform &tf) const
adjust minimum and maximum extent based on graphical object
void SetRadius(float r)
defunct
unsigned int GetArcDetail() const
Definition prim_list.hh:139
void SetColor(const Color &c)
set global prims color, overriding individual ones
void AddPoint(const geom::Vec3 &p, const Color &col)
add point
void SetDiameter(float d)
defunct
void AddLine(const geom::Vec3 &p1, const geom::Vec3 &p2, const Color &col1, const Color &col2)
add line
void Clear()
clear all prims
virtual geom::Vec3 GetCenter() const
get center
virtual void CustomRenderGL(RenderPass pass)
void AddCyl(const geom::Vec3 &p0, const geom::Vec3 &p1, float r1, float r2, const Color &col1, const Color &col2)
add cylinder
void AddMesh(float *v, float *n, float *c, size_t nv, unsigned int *i, size_t ni)
add triangle mesh
void SetSphereDetail(unsigned int d)
void AddText(const std::string &text, const geom::Vec3 &pos, const Color &col, float point_size)
add text
virtual void CustomPreRenderGL(bool flag)
PrimList(const String &name)
create new prim list
virtual void SetLineWidth(float w)
set line width
#define DLLEXPORT_OST_GFX
std::string String
Definition base.hh:54
std::vector< TextPrim > TextPrimList
Definition gfx_prim.hh:117
std::vector< CylinderPrim > CylinderPrimList
Definition gfx_prim.hh:105
std::vector< SpherePrim > SpherePrimList
Definition gfx_prim.hh:47
Definition base.dox:1