anatomist  5.0.5
3D neuroimaging data viewer
surfpainttools.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 #ifndef ANATOMIST_MODULE_SURFPAINTTOOLS_H
35 #define ANATOMIST_MODULE_SURFPAINTTOOLS_H
36 
39 #include <aims/mesh/surface.h>
40 #include <aims/mesh/texture.h>
42 #include <qwidget.h>
43 #include <qspinbox.h>
44 
45 
46 class AWindow3D;
47 class QToolBar;
48 class QToolButton;
49 class QAction;
50 class QComboBox;
51 class QLabel;
52 
53 namespace aims
54 {
55  class GeodesicPath;
56 }
57 
58 namespace anatomist
59 {
60  class AObject;
61  class ATexture;
62 
63  class SurfpaintTools: public QWidget
64  {
65  Q_OBJECT
66 
67  public:
68 
70  virtual ~SurfpaintTools() ;
71 
72  bool initSurfPaintModule( AWindow3D *w3 );
73  void addToolBarControls( AWindow3D *w3 );
74  void removeToolBarControls( AWindow3D *w3 );
75  void addToolBarInfosTexture( AWindow3D *w3 );
76  void removeToolBarInfosTexture( AWindow3D *w3 );
77  AObject* workingObject() const { return objselect; }
78 
79  void setPolygon(int p) { IDPolygonSpinBox->setValue(p); }
80  void setMaxPoly(int max) { IDPolygonSpinBox->setRange(-1,max); }
81  void setVertex(int v) { IDVertexSpinBox->setValue(v); }
82  void setMaxVertex(int max) { IDVertexSpinBox->setRange(-1,max); }
83 
84  void setMinMaxTexture( float min, float max )
85  { textureFloatSpinBox->setRange( min, max ); }
86  float getTextureValueFloat() const
87  { return textureFloatSpinBox->value(); }
88  void setTextureValueFloat( double v )
89  { textureFloatSpinBox->setValue(v); }
90  void updateTextureValue( int indexVertex, float value );
91  void updateTexture ( std::vector<float> values );
92  void restoreTextureValue( int indexVertex );
93  void floodFillStart( int indexVertex );
94  void floodFillStop();
95  void fastFillMove( int indexVertex, float newTextureValue,
96  float oldTextureValue );
97  bool magicBrushStarted() const
98  {
99  return !listIndexVertexBrushPath.empty() || !listIndexVertexHolesPath.empty() || !holesObject.empty();
100  }
101 
102  void fillHolesOnPath();
103 
104  std::string getPathType() { return shortestPathSelectedType; }
105 
106  void setClosePath( bool c ) { pathClosed = c; }
107  bool pathIsClosed() { return pathClosed; }
108 
109  aims::GeodesicPath* getMeshStructSP() { return sp; }
110  aims::GeodesicPath* getMeshStructSulciP() { return sp_sulci; }
111  aims::GeodesicPath* getMeshStructGyriP() { return sp_gyri; }
112 
113  void addGeodesicPath( int indexNearestVertex,
114  Point3df positionNearestVertex);
115  void undoGeodesicPath();
116  void redoGeodesicPath();
117  void undoHolesPaths();
118  void redoHolesPaths();
119  void undoSelectFill();
120  void redoSelectFill();
121 
122  void computeDistanceMap( int indexNearestVertex );
123 
124  void changeControl( int control ) { IDActiveControl = control; }
125  int getActiveControl() { return IDActiveControl; }
126  AWindow3D* getWindow3D() { return win3D; }
127 
132  void newEditOperation();
133  void undoTextureOperation();
134  void redoTextureOperation();
135  bool isValid() const;
136 
137  public slots:
138 
139  void colorPicker();
140  void magicSelection();
141  void path();
142  void shortestPath();
143  void sulciPath();
144  void gyriPath();
145  void brush();
146  void magicBrush();
147  void validateEdit();
148  void distance();
149  void clearPath();
150  void clearRegion();
151  void clearHoles();
152  void clearAll();
153  void erase();
154  void save();
156  void undo();
158  void redo();
159 
160  void updateConstraintList();
161  void loadConstraintsList( std::vector<std::string> clist );
162 
163  void changeToleranceSpinBox( int v );
164  void changeConstraintPathSpinBox( int v );
165 
166  void changeMinValueSpinBox( double v );
167  void changeMaxValueSpinBox( double v );
168 
169  private :
170  void popAllButtonPaintToolBar();
171  void clearUndoneGeodesicPath();
172  void addSimpleShortPath( int indexSource, int indexDest );
173  void undoSimpleShortPath();
174  void redoSimpleShortPath();
175  void clearUndoneHolesPaths();
176  void clearUndoneSelectFill();
177  float currentTextureValue( unsigned vertexIndex ) const;
178  void clearRedoBuffer();
179 
180  struct Private;
181  Private *d;
182 
184  ATexture *at;
185  TimeTexture<float> texCurv;
186 
187  carto::Object options;
188 
189  Texture1d *surfpaintTexInit;
190  AWindow3D *win3D;
191 
192  AObject *objselect;
193  QToolBar *tbTextureValue;
194  QDoubleSpinBox *textureFloatSpinBox;
195 
196  std::string textype;
197  std::string objtype;
198 
199  QToolBar *tbInfos3D;
200  QSpinBox *IDPolygonSpinBox;
201  QSpinBox *IDVertexSpinBox;
202 
203  QToolBar *tbControls;
204 
205  QToolButton *colorPickerAction;
206  QToolButton *selectionAction;
207  QToolButton *pathAction;
208  QAction *shortestPathAction;
209  QAction *sulciPathAction;
210  QAction *gyriPathAction;
211 
212  QToolButton *paintBrushAction;
213  QToolButton *magicBrushAction;
214 
215  QToolButton *distanceAction;
216 
217  QToolButton *validateEditAction;
218  QToolButton *eraseAction;
219  QToolButton *clearPathAction;
220  QToolButton *saveAction;
221 
222  QComboBox *constraintList;
223 
224  QSpinBox *toleranceSpinBox;
225  QLabel *toleranceSpinBoxLabel;
226  QSpinBox *constraintPathSpinBox;
227  QLabel *constraintPathSpinBoxLabel;
228 
229  QDoubleSpinBox *textureValueMinSpinBox;
230  QDoubleSpinBox *textureValueMaxSpinBox;
231 
232  GLuint constraintPathValue;
233  GLuint toleranceValue;
234  float stepToleranceValue;
235 
236  int IDActiveControl;
237  std::string shortestPathSelectedType;
238 
239  aims::GeodesicPath *sp;
240  aims::GeodesicPath *sp_sulci;
241  aims::GeodesicPath *sp_gyri;
242 
243  std::vector<std::set<uint> > neighbours;
244  bool pathClosed;
245 
246  std::vector<unsigned> listIndexVertexPathSP;
247  std::vector<unsigned> listIndexVertexSelectSP;
248 
249  std::vector<unsigned> listIndexVertexBrushPath;
250  std::vector<unsigned> listIndexVertexHolesPath;
251 
252  std::set<int> listIndexVertexFill;
253 
254  std::vector<carto::rc_ptr<ATriangulated> > pathObject;
255  std::vector<carto::rc_ptr<ATriangulated> > fillObject;
256  std::vector<carto::rc_ptr<ATriangulated> > holesObject;
257  };
258 }
259 #endif
Base Anatomist object (abstract)
Definition: Object.h:95
3D window, OpenGL rendering
Definition: window3D.h:69
#define slots
void setTextureValueFloat(double v)
AObject * workingObject() const
aims::GeodesicPath * getMeshStructGyriP()
bool magicBrushStarted() const
void changeControl(int control)
High-level Texture object in Anatomist.
Definition: texture.h:51
void setMinMaxTexture(float min, float max)
aims::GeodesicPath * getMeshStructSP()
AIMSDATA_API TimeTexture< float > Texture1d
float getTextureValueFloat() const
aims::GeodesicPath * getMeshStructSulciP()