anatomist  5.0.5
3D neuroimaging data viewer
Graph.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_GRAPH_GRAPH_H
36 #define ANA_GRAPH_GRAPH_H
37 
38 
43 #include <graph/graph/graph.h>
44 #include <aims/data/data.h>
45 
46 
47 class QGraphProperties;
48 
49 namespace anatomist
50 {
51 
52  class AGraphObject;
53 
56  class AGraph : public MObject, public GLComponent, public AttributedAObject
57  {
58  public:
59  enum ColorMode
60  {
62  };
63  AGraph( Graph *dataGraph, const std::string & filename,
64  bool init,
65  const Point3d& labelDimension );
66  AGraph( Graph *dataGraph, const std::string & filename,
67  bool init = true,
68  const Point3dl& labelDimension = Point3dl(64, 64, 64) );
69  AGraph( carto::rc_ptr<Graph> dataGraph, const std::string & filename,
70  bool init,
71  const Point3d& labelDimension );
72  AGraph( carto::rc_ptr<Graph> dataGraph, const std::string & filename,
73  bool init = true,
74  const Point3dl& labelDimension = Point3dl(64, 64, 64) );
75 
76  virtual ~AGraph();
77 
78  virtual AObject* clone( bool shallow = true );
79 
80  virtual int MType() const { return( AObject::GRAPH ); }
81  virtual size_t size() const;
82  virtual iterator begin();
83  virtual const_iterator begin() const;
84  virtual iterator end();
85  virtual const_iterator end() const;
86  virtual void insert( AObject * );
87  virtual void insert( AObject* obj, std::string syntacticAtt );
88  virtual void insert( const carto::shared_ptr<AObject> & obj,
89  std::string syntacticAtt = "fold" );
90  void insert( AObject* obj, carto::GenericObject* vertex );
91  virtual const_iterator find( const AObject * ) const;
92  virtual void erase( iterator & );
94  Graph* graph() const;
96 
97  virtual bool render( PrimList &, const ViewState & );
98 
99  virtual void setGeomExtrema();
100  virtual bool boundingBox( std::vector<float> & bmin,
101  std::vector<float> & bmax ) const;
102  virtual bool boundingBox2D( std::vector<float> & bmin,
103  std::vector<float> & bmax ) const
104  { return boundingBox( bmin, bmax ); }
106  bool Is2DObject() { return(true); }
108  bool Is3DObject() { return(true); }
109  virtual AObject* objectAt( const std::vector<float> & pos, float tol = 0 );
110  virtual void SetMaterial( const Material & mat );
111  virtual bool shouldRemoveChildrenWithMe() const;
112 
113  virtual carto::GenericObject* attributed();
114  virtual const carto::GenericObject* attributed() const;
115 
116  static AObject* LoadGraph( const std::string & filename,
117  carto::Object options=carto::none() );
118  virtual bool save( const std::string & filename );
119  virtual bool savable() const { return true; }
120  void loadSubObjects( int mask );
121  ColorMode colorMode() const;
122  void setColorMode( ColorMode, bool update = true );
123  int colorPropertyMask() const;
125  void setColorPropertyMask( int, bool update = true );
127  std::string colorProperty() const;
128  void setColorProperty( const std::string &, bool update = true );
129  void updateColors(void);
130 
135  static bool (*specialColorFunc)( AGraph* ag, AGraphObject* go,
136  Material & mat );
137 
139  objAttColors() const;
141  objAttColors();
142  void copyAttributes( const std::string & oldatt,
143  const std::string & newatt, bool removeOld = false,
144  bool dorels = false );
151  std::string labelProperty( bool allowDefault = true ) const;
152  void setLabelProperty( const std::string & prop );
153 
154  virtual std::vector<float> voxelSize() const;
155  virtual void setVoxelSize( const std::vector<float> & vs );
156  void clearLabelsVolume();
157  void setLabelsVolumeDimension( unsigned dx, unsigned dy, unsigned dz );
158  void setLabelsVolumeDimension( const Point3d & vd );
159  void setLabelsVolumeDimension( const Point3dl & vd );
161  AimsData<AObject *>& volumeOfLabels( int t = 0 ) ;
162  virtual void createDefaultPalette( const std::string & name );
163  virtual void setPalette( const AObjectPalette & pal );
165  void updateAfterAimsChange();
166 
167  virtual GLComponent* glAPI();
168  virtual const GLComponent* glAPI() const;
169  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
170  virtual void setProperties( carto::Object options );
171  std::set<std::string> mappableVertexProperties() const;
172  std::set<std::string> mappableEdgeProperties() const;
173 
174  protected:
175  void saveSubObjects( bool filenamechanged = false );
177  virtual void fillVol( AimsData<AObject *> & vol, int t, float mx,
178  float my, float mz, float Mx, float My, float Mz );
179  void recolor();
180  void updateExtrema();
181 
183  typedef std::set<carto::shared_ptr<AObject> > datatype;
184 
185  private:
186  friend class ::QGraphProperties;
187 
188  void initialize( const std::string & filename, bool init,
189  const Point3dl& labelDimension );
190 
191  struct Private;
192  Private *d;
193  };
194 
195 }
196 
197 
198 namespace carto
199 {
201 }
202 
203 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
virtual bool boundingBox(std::vector< float > &bmin, std::vector< float > &bmax) const
Fills bmin and bmax with the N-D bounding box extrema in the object&#39;s referential coordinates...
void updateAfterAimsChange()
to be called when there has been a structural modif on the AIMS graph
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:66
Anatomist graph object: a list that manages destruction of its sub-elements.
Definition: GraphObject.h:52
virtual bool render(PrimList &, const ViewState &)
rendering (generally 2D or 3D using OpenGL).
ColorMode colorMode() const
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)
virtual size_t size() const
virtual AObject * clone(bool shallow=true)
Makes a copy of the object, with a duplicated object structure, palette and material, but which may share the underlying low-level data object (Aims object).
Base Anatomist object (abstract)
Definition: Object.h:95
Multi-object generic iterator.
Definition: MObject.h:114
virtual void insert(AObject *)
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
std::string labelProperty(bool allowDefault=true) const
property used to store the current label.
Multi-object : base abstract class for objects that contain others.
Definition: MObject.h:234
void copyAttributes(const std::string &oldatt, const std::string &newatt, bool removeOld=false, bool dorels=false)
Graph * graph() const
low-level data acces
virtual void update(const Observable *observable, void *arg)
This class is an Observer of each of the AObject it groups.
AGraph object class.
Definition: Graph.h:56
const carto::rc_ptr< std::map< std::string, std::vector< int > > > objAttColors() const
void setColorPropertyMask(int, bool update=true)
bitwise combination of 1: nodes, 2: relations
virtual carto::GenericObject * attributed()
virtual const AObjectPalette * glPalette(unsigned tex=0) const
void setLabelProperty(const std::string &prop)
std::string name() const
Name shown in control window.
Definition: Object.h:165
void setColorMode(ColorMode, bool update=true)
Attributed objects wrapper.
Definition: pythonAObject.h:45
int colorPropertyMask() const
bool Is3DObject()
Can be display in 3D windows.
Definition: Graph.h:108
std::set< std::string > mappableEdgeProperties() const
virtual void erase(iterator &)
This class has to be rewritten, it&#39;s really really a shame.......
Definition: Material.h:47
virtual bool boundingBox2D(std::vector< float > &bmin, std::vector< float > &bmax) const
Bounding box in 2D views mode.
Definition: Graph.h:102
Point3dl labelsVolumeDimension() const
std::set< std::string > mappableVertexProperties() const
virtual bool shouldRemoveChildrenWithMe() const
tells whether children objects should be removed from views when this MObject is removed from a view...
virtual void fillVol(AimsData< AObject *> &vol, int t, float mx, float my, float mz, float Mx, float My, float Mz)
Fills a volume of labels for a given time.
static bool(* specialColorFunc)(AGraph *ag, AGraphObject *go, Material &mat)
Used to map special colors on graph objects while changing the graph material.
Definition: Graph.h:135
virtual void setVoxelSize(const std::vector< float > &vs)
virtual bool savable() const
Definition: Graph.h:119
virtual void setGeomExtrema()
Scans the object internals and determines its geometry extrema.
void setGraph(carto::rc_ptr< Graph >)
static AObject * LoadGraph(const std::string &filename, carto::Object options=carto::none())
void clearLabelsVolume()
virtual void SetMaterial(const Material &mat)
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
Find the object (sub-object) at given postion with a tolerence.
bool Is2DObject()
Can be display in 2D windows.
Definition: Graph.h:106
AimsData< AObject * > & volumeOfLabels(int t=0)
virtual GLComponent * glAPI()
std::set< carto::shared_ptr< AObject > > datatype
Data storage type, to be redefined by children classes.
Definition: Graph.h:183
void setLabelsVolumeDimension(unsigned dx, unsigned dy, unsigned dz)
virtual const_iterator find(const AObject *) const
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:66
virtual int MType() const
Precise type of multi-object.
Definition: Graph.h:80
virtual iterator begin()
void loadSubObjects(int mask)
virtual std::vector< float > voxelSize() const
Returns at least 4 sizes. For 3D objects, returns (1, 1, 1, 1)
AGraph(Graph *dataGraph, const std::string &filename, bool init, const Point3d &labelDimension)
std::string colorProperty() const
property mapped with colormap
Object none()
void updateColors(void)
virtual void setPalette(const AObjectPalette &pal)
virtual void setProperties(carto::Object options)
Same as setHeaderOptions() and used by it, allows passing a dictionary.
void setColorProperty(const std::string &, bool update=true)
virtual bool save(const std::string &filename)
virtual iterator end()
virtual void createDefaultPalette(const std::string &name)
function called by getOrCreatePalette() - overloadable, need not be called directly ...
void saveSubObjects(bool filenamechanged=false)