OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
include
ost
gfx
entity.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-2011 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_ENTITY_HH
20
#define OST_GFX_ENTITY_HH
21
22
/*
23
Author: Ansgar Philippsen, Marco Biasini
24
*/
25
#include <vector>
26
27
#include <boost/ptr_container/ptr_map.hpp>
28
29
#include <
ost/geom/geom.hh
>
30
31
#include <
ost/mol/query_view_wrapper.hh
>
32
#include <
ost/gfx/render_options/render_options.hh
>
33
#include <
ost/gfx/color_ops/color_op.hh
>
34
#include <
ost/gfx/color_ops/by_element_color_op.hh
>
35
#include <
ost/gfx/color_ops/by_chain_color_op.hh
>
36
#include <
ost/gfx/color_ops/uniform_color_op.hh
>
37
#include <
ost/gfx/color_ops/gradient_level_color_op.hh
>
38
#include <
ost/gfx/color_ops/entity_view_color_op.hh
>
39
40
#if OST_IMG_ENABLED
41
#include <
ost/gfx/color_ops/map_handle_color_op.hh
>
42
#endif //OST_IMG_ENABLED
43
44
#include <
ost/gfx/impl/entity_renderer.hh
>
45
46
#include "
gradient.hh
"
47
#include "
entity_fw.hh
"
48
#include "
impl/backbone_trace.hh
"
49
#include "
impl/entity_detail.hh
"
50
51
namespace
ost {
namespace
gfx {
52
53
typedef
std::vector<RenderMode::Type>
RenderModeTypes
;
54
63
class
DLLEXPORT_OST_GFX
Entity
:
public
GfxObj
{
64
65
public
:
71
Entity
(
const
String
& name,
72
const
mol::EntityHandle
& eh,
73
const
mol::Query
& q=
mol::Query
(),
74
mol::QueryFlags
f=0);
75
77
Entity
(
const
String
& name,
78
RenderMode::Type
m,
79
const
mol::EntityHandle
& eh,
80
const
mol::Query
& q=
mol::Query
(),
81
mol::QueryFlags
f=0);
82
85
Entity
(
const
String
& name,
86
const
mol::EntityView
& ev);
87
89
Entity
(
const
String
& name,
90
RenderMode::Type
m,
91
const
mol::EntityView
& ev);
92
93
virtual
geom::AlignedCuboid
GetBoundingBox(
bool
use_tf=
false
)
const
;
94
95
// ProcessLimits uses the default implementation of bounding box
96
98
virtual
void
CustomRenderGL(
RenderPass
pass);
99
100
virtual
void
RefreshVA();
101
102
virtual
bool
OnSelect(
const
geom::Line3
& l,
geom::Vec3
& result,
float
zlim,
103
bool
pick_flag);
104
111
mol::AtomHandle
PickAtom(
const
geom::Line3
& line,
Real
line_width=0.5);
112
113
120
mol::BondHandle
PickBond(
const
geom::Line3
& line,
Real
line_width=0.5);
121
122
123
virtual
void
OnRenderModeChange();
124
125
const
String
GetRenderModeName(
RenderMode::Type
mode);
126
127
void
SetEnableRenderMode(
RenderMode::Type
mode,
bool
enable);
128
129
bool
IsRenderModeEnabled(
RenderMode::Type
mode);
130
131
RenderModeTypes
GetNotEmptyRenderModes();
132
133
void
SetRenderMode(
RenderMode::Type
mode,
const
mol::EntityView
& view,
134
bool
keep=
false
);
135
void
SetRenderMode(
RenderMode::Type
mode,
const
String
& selection,
136
bool
keep=
false
);
137
virtual
void
SetRenderMode(
RenderMode::Type
mode);
138
139
mol::EntityView
GetRenderView(
RenderMode::Type
mode);
140
141
virtual
void
SetVisible(
const
mol::EntityView
& view,
bool
visible);
142
143
virtual
void
SetVisible(
const
String
& sel,
bool
visible);
144
virtual
void
OptionsChanged(
RenderMode::Type
mode);
145
146
virtual
void
SetOpacity(
float
f);
147
virtual
float
GetOpacity
()
const
{
return
opacity_;}
148
virtual
void
SetOutlineWidth(
float
f);
149
virtual
void
SetOutlineExpandFactor(
float
f);
150
virtual
void
SetOutlineExpandColor(
const
Color
& c);
151
154
void
Reset(
const
mol::EntityHandle
& eh);
157
void
Reset(
const
mol::EntityHandle
& eh,
const
mol::Query
& q);
160
void
Reset(
const
mol::EntityHandle
& eh,
const
mol::Query
& q,
mol::QueryFlags
flags);
163
void
Reset(
const
mol::EntityView
& ev);
165
/*
166
the naming here is misleading - this method WON'T be called upon FlagRebuild
167
*/
168
void
Rebuild();
169
172
void
UpdatePositions();
173
175
void
UpdateView();
176
178
void
SetColor(
const
Color
& col,
const
String
& selection=
String
(
""
));
179
180
// \brief detail coloring
181
void
SetDetailColor(
const
Color
& col,
const
String
& selection=
String
(
""
));
182
184
void
SetColorForAtom(
const
Color
& col,
185
const
mol::AtomHandle
& atom);
186
188
void
ColorByElement();
189
191
void
ColorByElement(
const
String
& selection);
192
194
void
ColorByChain();
195
197
void
ColorByChain(
const
String
& selection);
198
200
mol::EntityView
GetView()
const
;
201
204
void
SetQuery(
const
mol::Query
& q);
205
207
mol::QueryViewWrapper
GetQueryView()
const
;
209
void
SetQueryView(
const
mol::QueryViewWrapper
& qv);
210
212
mol::EntityHandle
GetEntity()
const
;
213
214
// turn blur on or off (experimental feature)
215
void
SetBlur(
bool
f);
216
// set atom positions as n-1 for blur (experimental feature)
217
void
BlurSnapshot();
218
// blur transparency falloffs (experimental feature)
219
void
SetBlurFactors(
float
bf1,
float
bf2);
220
223
void
SetSelection(
const
mol::EntityView
& view);
224
227
mol::EntityView
GetSelection()
const
;
228
229
// GfxObj property interface
230
virtual
void
ColorBy(
const
mol::EntityView
& ev,
231
const
String
& prop,
232
const
Gradient
& g,
float
minv,
float
maxv);
233
234
#if OST_IMG_ENABLED
235
// GfxObj property interface
236
virtual
void
ColorBy(
const
img::MapHandle
& mh,
237
const
String
& prop,
238
const
Gradient
& g,
float
minv,
float
maxv);
239
#endif
240
241
// map property to color gradient from minv to maxv
242
void
ColorBy(
const
String
& prop,
243
const
Gradient
& gradient,
244
float
minv,
float
maxv,
245
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
246
247
// temporarily here, will be moved to py interface
248
void
ColorBy(
const
String
& prop,
249
const
Gradient
& gradient,
250
float
minv,
float
maxv,
251
bool
clamp);
252
253
// temporary, should be incorporated with ColorBy
254
void
DetailColorBy(
const
String
& prop,
255
const
Gradient
& gradient,
256
float
minv,
float
maxv,
257
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
258
259
// convenience
260
void
ColorBy(
const
String
& prop,
261
const
Gradient
& gradient,
262
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
263
264
// convenience
265
void
ColorBy(
const
String
& prop,
266
const
Gradient
& gradient,
267
const
String
& selection);
268
269
// convenience
270
void
ColorBy(
const
String
& prop,
271
const
Color
& c1,
const
Color
& c2,
272
float
min,
float
max,
273
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
274
275
// convenience
276
void
ColorBy(
const
String
& prop,
277
const
Color
& c1,
const
Color
& c2,
278
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
279
280
281
void
RadiusBy(
const
String
& prop,
282
float
rmin,
float
rmax,
283
float
vmin,
float
vmax,
284
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
285
286
void
RadiusBy(
const
String
& prop,
287
float
rmin,
float
rmax,
288
mol::Prop::Level
hint=
mol::Prop::UNSPECIFIED
);
289
290
void
ResetRadiusBy();
291
292
void
Apply(
const
gfx::ByElementColorOp
& op,
bool
store=
true
);
293
void
Apply(
const
gfx::ByChainColorOp
& op,
bool
store=
true
);
294
void
Apply(
const
gfx::UniformColorOp
& op,
bool
store=
true
);
295
296
void
Apply(
const
gfx::GradientLevelColorOp
& op,
bool
store=
true
);
297
void
Apply(
const
gfx::EntityViewColorOp
& op,
bool
store=
true
);
298
299
#if OST_IMG_ENABLED
300
void
Apply(
const
gfx::MapHandleColorOp
& op,
bool
store=
true
);
301
#endif
302
303
void
CleanColorOps();
304
void
ReapplyColorOps();
305
316
RenderOptionsPtr
GetOptions(
RenderMode::Type
render_mode);
317
void
SetOptions(
RenderMode::Type
render_mode,
318
RenderOptionsPtr
& render_options);
319
void
ApplyOptions(
RenderMode::Type
render_mode,
320
RenderOptionsPtr
& render_options);
321
bool
HasSelection()
const
;
322
323
void
SetSeqHack(
bool
b);
324
bool
GetSeqHack()
const
;
325
326
virtual
void
Export(
Exporter
* ex);
327
328
protected
:
329
330
virtual
void
CustomPreRenderGL(
bool
flag);
331
virtual
void
CustomRenderPov(
PovState
& pov);
332
void
UpdateSelection();
333
bool
UpdateIfNeeded()
const
;
334
void
CacheBoundingBox()
const
;
335
impl::EntityRenderer
* GetOrCreateRenderer(
RenderMode::Type
);
336
private
:
337
mol::QueryViewWrapper
qv_;
338
339
mutable
mol::EntityView
cached_view_;
340
mutable
bool
update_view_;
341
342
mutable
geom::AlignedCuboid
bbox_;
343
mol::EntityView
sel_;
344
bool
sel_update_;
345
mutable
impl::BackboneTrace
trace_;
346
347
void
init(
RenderMode::Type
);
348
349
void
set_static_max_rad();
350
void
do_update_view()
const
;
351
352
typedef
boost::ptr_map<RenderMode::Type, impl::EntityRenderer> RendererMap;
353
mutable
RendererMap renderer_;
354
355
float
opacity_;
356
bool
blur_;
357
float
blurf1_;
358
float
blurf2_;
359
mutable
bool
needs_update_;
360
};
361
362
368
374
384
385
390
}}
// ns
391
392
#endif
Generated on Mon Nov 11 2013 09:56:11 for OpenStructure by
1.8.1.1