Clipper
container_map.h
1
4//C Copyright (C) 2000-2006 Kevin Cowtan and University of York
5//L
6//L This library is free software and is distributed under the terms
7//L and conditions of version 2.1 of the GNU Lesser General Public
8//L Licence (LGPL) with the following additional clause:
9//L
10//L `You may also combine or link a "work that uses the Library" to
11//L produce a work containing portions of the Library, and distribute
12//L that work under terms of your choice, provided that you give
13//L prominent notice with each copy of the work that the specified
14//L version of the Library is used in it, and that you include or
15//L provide public access to the complete corresponding
16//L machine-readable source code for the Library including whatever
17//L changes were used in the work. (i.e. If you make changes to the
18//L Library you must distribute those, but you do not need to
19//L distribute source or object code to those portions of the work
20//L not covered by this licence.)'
21//L
22//L Note that this clause grants an additional right and does not impose
23//L any additional restriction, and so does not affect compatibility
24//L with the GNU General Public Licence (GPL). If you wish to negotiate
25//L other terms, please contact the maintainer.
26//L
27//L You can redistribute it and/or modify the library under the terms of
28//L the GNU Lesser General Public License as published by the Free Software
29//L Foundation; either version 2.1 of the License, or (at your option) any
30//L later version.
31//L
32//L This library is distributed in the hope that it will be useful, but
33//L WITHOUT ANY WARRANTY; without even the implied warranty of
34//L MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35//L Lesser General Public License for more details.
36//L
37//L You should have received a copy of the CCP4 licence and/or GNU
38//L Lesser General Public License along with this library; if not, write
39//L to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
40//L The GNU Lesser General Public can also be obtained by writing to the
41//L Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42//L MA 02111-1307 USA
43
44
45#ifndef CLIPPER_CONTAINER_MAP
46#define CLIPPER_CONTAINER_MAP
47
48
49#include "container_types.h"
50#include "nxmap_operator.h"
51
52
53namespace clipper
54{
55
57
58 template<class T> class CXmap : public Container, public Xmap<T>
59 {
60 public:
62 CXmap() {}
64 CXmap( Container& parent, const String name = "" );
66 void init( const Spacegroup& spacegroup, const Cell& cell, const Grid_sampling& grid_sampling );
68 void update();
69 };
70
71
73
76 template<class T> class CNXmap : public Container, public NXmap<T>
77 {
78 public:
80 CNXmap() {}
82 CNXmap( Container& parent, const String name = "" ) :
83 Container( parent, name ) {}
84 };
85
86
88
91 template<class T> class CNXmap_operator : public Container, public NXmap_operator<T>
92 {
93 public:
101 void init( const Cell& cell, const Grid_sampling& grid, const NXmap<T>& nxmap, const RTop_orth& nxop );
103 void update();
104 private:
105 const NXmap<T>* nxmap_;
106 RTop_orth nxop_;
107 };
108
109
110 // template implementations
111
112
120 template<class T> CXmap<T>::CXmap( Container& parent, const String name ) : Container( parent, name )
121 {
122 init( NullSpacegroup, NullCell, NullGrid_sampling );
123 }
124
125
132 template<class T> void CXmap<T>::init( const Spacegroup& spacegroup, const Cell& cell, const Grid_sampling& grid_sampling )
133 {
134 // use supplied values by default
135 const Spacegroup* sp = &spacegroup; // use pointers so we can reassign
136 const Cell* cp = &cell;
137 const Grid_sampling* gp = &grid_sampling;
138 // otherwise get them from the tree
139 if ( sp->is_null() ) sp = parent_of_type_ptr<const Spacegroup>();
140 if ( cp->is_null() ) cp = parent_of_type_ptr<const Cell>();
141 if ( gp->is_null() ) gp = parent_of_type_ptr<const Grid_sampling>();
142 // initialise
143 if ( sp != NULL && cp != NULL && gp != NULL )
144 if ( !sp->is_null() && !cp->is_null() && !gp->is_null() )
145 Xmap<T>::init( *sp, *cp, *gp );
147 }
148
149
153 template<class T> void CXmap<T>::update()
154 {
155 if ( Xmap_base::is_null() )
156 init( NullSpacegroup, NullCell, NullGrid_sampling );
157 else
159 }
160
161
165 template<class T> CNXmap_operator<T>::CNXmap_operator( Container& parent, const String name ) : Container( parent, name ), nxmap_( NULL ), nxop_( RTop_orth::null() ) {}
166
167
174 template<class T> CNXmap_operator<T>::CNXmap_operator( Container& parent, const String name, const NXmap<T>& nxmap, const RTop_orth& nxop ) : Container( parent, name ), nxmap_( &nxmap ), nxop_( nxop )
175 {
176 init( NullCell, NullGrid_sampling, NXmap<T>(), RTop_orth::null() );
177 }
178
179
187 template<class T> void CNXmap_operator<T>::init( const Cell& cell, const Grid_sampling& grid_sampling, const NXmap<T>& nxmap, const RTop_orth& nxop )
188 {
189 // use supplied values by default
190 const Cell* cp = &cell;
191 const Grid_sampling* gp = &grid_sampling;
192 // otherwise get them from the tree
193 if ( cp->is_null() ) cp = parent_of_type_ptr<const Cell>();
194 if ( gp->is_null() ) gp = parent_of_type_ptr<const Grid_sampling>();
195 if ( !nxmap.is_null() ) nxmap_ = &nxmap;
196 if ( !nxop.is_null() ) nxop_ = nxop;
197 // initialise
198 if ( cp != NULL && gp != NULL && nxmap_ != NULL )
199 if ( !cp->is_null() && !gp->is_null() && !nxmap_->is_null() )
200 NXmap_operator<T>::init( *cp, *gp, *nxmap_, nxop_ );
202 }
203
204
208 template<class T> void CNXmap_operator<T>::update()
209 {
210 if ( NX_operator::is_null() )
211 init( NullCell, NullGrid_sampling, NXmap<T>(), RTop_orth::null() );
212 else
214 }
215
216
217} // namespace clipper
218
219#endif
Non-Crystallographic map operator container.
Definition: container_map.h:92
void init(const Cell &cell, const Grid_sampling &grid, const NXmap< T > &nxmap, const RTop_orth &nxop)
initialier: supply or inherit cell, grid, NXmap, RTop_orth
Definition: container_map.h:187
void update()
hierarchical update
Definition: container_map.h:208
CNXmap_operator()
null constructor
Definition: container_map.h:95
Non-Crystallographic map container.
Definition: container_map.h:77
CNXmap(Container &parent, const String name="")
constructor:
Definition: container_map.h:82
CNXmap()
null constructor
Definition: container_map.h:80
Crystallographic map container.
Definition: container_map.h:59
CXmap()
null constructor
Definition: container_map.h:62
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sampling)
initialiser: supply or inherit spacegroup, cell and grid
Definition: container_map.h:132
void update()
hierarchical update
Definition: container_map.h:153
Cell object.
Definition: cell.h:122
bool is_null() const
test if object has been initialised
Definition: cell.cpp:151
Definition for a generic container Object.
Definition: container.h:69
const Container & parent() const
get the parent of this object
Definition: container.cpp:142
String name() const
get the name of this tree object
Definition: container.cpp:127
virtual void update()
update: hierarchical content update function
Definition: container.cpp:65
Grid sampling of a unit cell.
Definition: coords.h:516
bool is_null() const
test if object has been initialised
Definition: coords.cpp:532
bool is_null() const
test if object has been initialised
Definition: nxmap_operator.cpp:139
bool is_null() const
test if object has been initialised
Definition: nxmap.cpp:94
NXmap_operator: non-crystal map operator referencing a particular NXmap.
Definition: nxmap_operator.h:128
const NXmap< T > & nxmap() const
get the target NXmap of this operator
Definition: nxmap_operator.h:146
void init(const Xmap_base &xmap, const NXmap< T > &nxmap, const RTop_orth &rtop)
initialiser:: from Xmap, NXmap, and operator
Definition: nxmap_operator.h:137
NXmap<T>: actual non-crystallographic map class.
Definition: nxmap.h:261
Orthogonal operator class.
Definition: coords.h:113
static RTop_orth null()
return null (uninitialised) operator
Definition: coords.cpp:267
Rotation-translation operator.
Definition: clipper_types.h:323
bool is_null() const
test for null operator
Definition: clipper_types.h:348
Spacegroup object.
Definition: spacegroup.h:173
bool is_null() const
test if object has been initialised
Definition: spacegroup.cpp:885
String extension with simple parsing methods.
Definition: clipper_types.h:65
bool is_null() const
test if object has been initialised
Definition: xmap.cpp:200
Xmap<T>: actual crystallographic map class.
Definition: xmap.h:357
void init(const Spacegroup &spacegroup, const Cell &cell, const Grid_sampling &grid_sam)
initialiser: from spacegroup, cell, and grid
Definition: xmap.h:364