anatomist  5.1.2
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 
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 
104 
105  std::string getPathType() { return shortestPathSelectedType; }
106 
107  void setClosePath( bool c ) { pathClosed = c; }
108  bool pathIsClosed() { return pathClosed; }
109 
110  aims::GeodesicPath* getMeshStructSP() { return sp; }
111  aims::GeodesicPath* getMeshStructSulciP() { return sp_sulci; }
112  aims::GeodesicPath* getMeshStructGyriP() { return sp_gyri; }
113 
114  void addGeodesicPath( int indexNearestVertex,
115  Point3df positionNearestVertex);
122 
123  void computeDistanceMap( int indexNearestVertex );
124 
125  void changeControl( int control ) { IDActiveControl = control; }
126  int getActiveControl() { return IDActiveControl; }
127  AWindow3D* getWindow3D() { return win3D; }
128 
136  bool isValid() const;
137 
138  public slots:
139 
140  void colorPicker();
142  void path();
143  void shortestPath();
144  void sulciPath();
145  void gyriPath();
146  void brush();
147  void magicBrush();
148  void validateEdit();
149  void distance();
150  void clearPath();
151  void clearRegion();
152  void clearHoles();
153  void clearAll();
154  void erase();
155  void save();
157  void undo();
159  void redo();
160 
162  void loadConstraintsList( std::vector<std::string> clist );
163 
164  void changeToleranceSpinBox( int v );
166 
167  void changeMinValueSpinBox( double v );
168  void changeMaxValueSpinBox( double v );
169 
170  private :
171  void popAllButtonPaintToolBar();
172  void clearUndoneGeodesicPath();
173  void addSimpleShortPath( int indexSource, int indexDest );
174  void undoSimpleShortPath();
175  void redoSimpleShortPath();
176  void clearUndoneHolesPaths();
177  void clearUndoneSelectFill();
178  float currentTextureValue( unsigned vertexIndex ) const;
179  void clearRedoBuffer();
180 
181  struct Private;
182  Private *d;
183 
185  ATexture *at;
186  TimeTexture<float> texCurv;
187 
188  carto::Object options;
189 
190  Texture1d *surfpaintTexInit;
191  AWindow3D *win3D;
192 
193  AObject *objselect;
194  QToolBar *tbTextureValue;
195  QDoubleSpinBox *textureFloatSpinBox;
196 
197  std::string textype;
198  std::string objtype;
199 
200  QToolBar *tbInfos3D;
201  QSpinBox *IDPolygonSpinBox;
202  QSpinBox *IDVertexSpinBox;
203 
204  QToolBar *tbControls;
205 
206  QToolButton *colorPickerAction;
207  QToolButton *selectionAction;
208  QToolButton *pathAction;
209  QAction *shortestPathAction;
210  QAction *sulciPathAction;
211  QAction *gyriPathAction;
212 
213  QToolButton *paintBrushAction;
214  QToolButton *magicBrushAction;
215 
216  QToolButton *distanceAction;
217 
218  QToolButton *validateEditAction;
219  QToolButton *eraseAction;
220  QToolButton *clearPathAction;
221  QToolButton *saveAction;
222 
223  QComboBox *constraintList;
224 
225  QSpinBox *toleranceSpinBox;
226  QLabel *toleranceSpinBoxLabel;
227  QSpinBox *constraintPathSpinBox;
228  QLabel *constraintPathSpinBoxLabel;
229 
230  QDoubleSpinBox *textureValueMinSpinBox;
231  QDoubleSpinBox *textureValueMaxSpinBox;
232 
233  GLuint constraintPathValue;
234  GLuint toleranceValue;
235  float stepToleranceValue;
236 
237  int IDActiveControl;
238  std::string shortestPathSelectedType;
239 
240  aims::GeodesicPath *sp;
241  aims::GeodesicPath *sp_sulci;
242  aims::GeodesicPath *sp_gyri;
243 
244  std::vector<std::set<uint> > neighbours;
245  bool pathClosed;
246 
247  std::vector<unsigned> listIndexVertexPathSP;
248  std::vector<unsigned> listIndexVertexSelectSP;
249 
250  std::vector<unsigned> listIndexVertexBrushPath;
251  std::vector<unsigned> listIndexVertexHolesPath;
252 
253  std::set<int> listIndexVertexFill;
254 
255  std::vector<carto::rc_ptr<ATriangulated> > pathObject;
256  std::vector<carto::rc_ptr<ATriangulated> > fillObject;
257  std::vector<carto::rc_ptr<ATriangulated> > holesObject;
258  };
259 }
260 #endif
#define slots
3D window, OpenGL rendering
Definition: window3D.h:74
Base Anatomist object (abstract)
Definition: Object.h:96
High-level Texture object in Anatomist.
Definition: texture.h:52
void updateTexture(std::vector< float > values)
void addToolBarInfosTexture(AWindow3D *w3)
void addToolBarControls(AWindow3D *w3)
AObject * workingObject() const
void changeToleranceSpinBox(int v)
void changeMaxValueSpinBox(double v)
void changeControl(int control)
aims::GeodesicPath * getMeshStructSP()
void fastFillMove(int indexVertex, float newTextureValue, float oldTextureValue)
void removeToolBarControls(AWindow3D *w3)
void changeMinValueSpinBox(double v)
void addGeodesicPath(int indexNearestVertex, Point3df positionNearestVertex)
void restoreTextureValue(int indexVertex)
bool magicBrushStarted() const
void updateTextureValue(int indexVertex, float value)
void removeToolBarInfosTexture(AWindow3D *w3)
void floodFillStart(int indexVertex)
aims::GeodesicPath * getMeshStructSulciP()
void computeDistanceMap(int indexNearestVertex)
void loadConstraintsList(std::vector< std::string > clist)
aims::GeodesicPath * getMeshStructGyriP()
void redo()
redo the last texture modification
void newEditOperation()
start a new buffer to store texture modifications.
float getTextureValueFloat() const
void setMinMaxTexture(float min, float max)
void setTextureValueFloat(double v)
bool initSurfPaintModule(AWindow3D *w3)
void changeConstraintPathSpinBox(int v)
void undo()
undo the last texture modification
T min(const Volume< T > &vol)
T max(const Volume< T > &vol)
AIMSDATA_API TimeTexture< float > Texture1d