anatomist 6.0.4
3D neuroimaging data viewer
selectFactory.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef ANA_SELECTION_SELECTFACTORY_H
36#define ANA_SELECTION_SELECTFACTORY_H
37
38
39#include <aims/vector/vector.h>
40#include <list>
41#include <map>
42#include <set>
43
44
45class Tree;
46
47
48namespace anatomist
49{
50 class AObject;
51 class AWindow;
52 class WSelectChooser;
53 class Referential;
54 class Selector;
55 class PostSelector;
56
57
65 {
66 public:
68 {
69 Normal = 0,
70 Add = 1,
72 };
73
74 struct HColor
75 {
76 HColor() {}
77 HColor( float red, float grn, float blu, float al = 1.,
78 bool ntalp = false )
79 : r( red), g( grn ), b( blu ), a( al ), na( ntalp ) {}
80 bool operator == ( const HColor & ) const;
81 bool operator != ( const HColor & ) const;
82
83 float r;
84 float g;
85 float b;
86 float a;
88 bool na;
89 };
90
92 virtual ~SelectFactory();
93
99 virtual WSelectChooser*
100 createSelectChooser( unsigned group,
101 const std::set<AObject *> & objects ) const;
102 const std::map<unsigned, std::set<AObject *> > & selected() const
103 { return( _selected() ); }
104 virtual void select( unsigned group, const std::set<AObject *> & obj,
105 const HColor* col = 0 ) const;
106 virtual void unselect( unsigned group,
107 const std::set<AObject *> & obj ) const;
108 virtual void unselectAll( unsigned group ) const;
110 virtual void selectAll( AWindow* win, const HColor* col = 0 ) const;
112 virtual void flip( unsigned group, const std::set<AObject *> & obj,
113 const HColor* col = 0 ) const;
114 virtual void select( SelectMode mode, unsigned group,
115 const std::set<AObject *> & obj,
116 const HColor* col = 0 ) const;
117 virtual bool isSelected( unsigned group, AObject* obj ) const;
118 virtual HColor highlightColor( AObject* obj ) const;
119 virtual void setHighlightColor( AObject* obj,
120 const HColor* col = 0 ) const;
122 virtual void refresh() const;
125 virtual void refreshSelectionRendering() const;
134 virtual void handleSelectionMenu( AWindow *win, int x, int y,
135 const Tree* specific = 0 );
136 virtual void propagateSelection( unsigned group ) const;
137
138 static void setFactory( SelectFactory* fac );
141 static bool hasAncestor( const AWindow* win, AObject* obj );
142 static AObject* objectAt( AObject* o, const std::vector<float> & pos,
143 float tolerence, const Referential* wref,
144 const Point3df & wgeom,
145 const std::string & selector = "default" );
146 static void select( AWindow* w, const std::vector<float> & pos,
147 float tolerence, int modifier,
148 const std::string & selector = "default" );
149 static void findObjectsAt( AWindow* w, const std::vector<float> & pos,
150 float tolerence, std::set<AObject *>& shown,
151 std::set<AObject *>& hidden,
152 const std::string & selector );
153 static void registerSelector( const std::string & key, Selector* s );
155 static void registerPostSelector( const std::string & key,
156 PostSelector* s );
159 static void activatePostSelector( int priority, const std::string & psel );
161 static void deactivatePostSelector( const std::string & psel );
162 static void setSelectColor( const HColor & col );
163
164 static HColor & selectColor();
165 static bool & selectColorInverse();
166
167 virtual void remove( anatomist::AWindow* win );
169
170 protected:
171
172 private:
174 static std::map<AObject*, HColor> & _highlightColors();
176 static std::set<AWindow *> & _winToRefresh();
177 static std::map<unsigned, std::set<AObject *> > & _selected();
178 };
179
180
181
183 const Tree* )
184 {
185 }
186
187}
188
189#endif
Base Anatomist object (abstract)
Definition Object.h:97
Abstract base class Anatomist window.
Definition Window.h:59
Performs an action after an object has been selected (fiber tracking, ...)
Referential: marker for transformations, with an associated color.
Definition Referential.h:56
static void activatePostSelector(int priority, const std::string &psel)
Activates a registered post-selector, it will be used after every object selection with a given prior...
virtual void flip(unsigned group, const std::set< AObject * > &obj, const HColor *col=0) const
Inverts state of given objects.
static void deactivatePostSelector(const std::string &psel)
Dectivates a post-selector: won't be called anymore.
virtual bool isSelected(unsigned group, AObject *obj) const
static void setFactory(SelectFactory *fac)
static HColor & selectColor()
static void setSelectColor(const HColor &col)
virtual void refresh() const
Redraws objects in involved windows.
virtual void refreshSelectionRendering() const
Redraws all windows containing selected objects (called after selection rendering mode has changed)
virtual void unselectAll(unsigned group) const
static bool & selectColorInverse()
virtual void removeFromThisWindow(anatomist::AWindow *win)
virtual void select(unsigned group, const std::set< AObject * > &obj, const HColor *col=0) const
static void registerSelector(const std::string &key, Selector *s)
virtual void remove(anatomist::AWindow *win)
static void registerPostSelector(const std::string &key, PostSelector *s)
Registers possible actions to be taken after object selection.
static void findObjectsAt(AWindow *w, const std::vector< float > &pos, float tolerence, std::set< AObject * > &shown, std::set< AObject * > &hidden, const std::string &selector)
static void select(AWindow *w, const std::vector< float > &pos, float tolerence, int modifier, const std::string &selector="default")
virtual void unselect(unsigned group, const std::set< AObject * > &obj) const
virtual WSelectChooser * createSelectChooser(unsigned group, const std::set< AObject * > &objects) const
Creates a selection choice window.
const std::map< unsigned, std::set< AObject * > > & selected() const
static SelectFactory * factory()
virtual void handleSelectionMenu(AWindow *win, int x, int y, const Tree *specific=0)
draws / handles the selection menu (right click)
virtual void selectAll(AWindow *win, const HColor *col=0) const
Selects all selectable objects in a given window.
virtual HColor highlightColor(AObject *obj) const
static bool hasAncestor(const AWindow *win, AObject *obj)
tells if win sees obj or one of its ancestors
static AObject * objectAt(AObject *o, const std::vector< float > &pos, float tolerence, const Referential *wref, const Point3df &wgeom, const std::string &selector="default")
virtual void select(SelectMode mode, unsigned group, const std::set< AObject * > &obj, const HColor *col=0) const
virtual void setHighlightColor(AObject *obj, const HColor *col=0) const
virtual void propagateSelection(unsigned group) const
Base class for selection chooser windows.
Definition wSelChooser.h:51
bool operator!=(const HColor &) const
HColor(float red, float grn, float blu, float al=1., bool ntalp=false)
bool operator==(const HColor &) const
AimsVector< float, 3 > Point3df