anatomist  5.1.2
3D neuroimaging data viewer
transformer.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 ANATOMIST_WINDOW3D_TRANSFORMER_H
36 #define ANATOMIST_WINDOW3D_TRANSFORMER_H
37 
39 #include <aims/resampling/motion.h>
40 #include <qobject.h>
41 #include <map>
42 
43 class QGraphicsItem;
44 class QTableWidget;
45 class QLineEdit;
46 class QComboBox;
47 
48 namespace anatomist
49 {
50  class Transformation;
51  class AWindow;
52  class Referential;
53 
54  namespace internal
55  {
56 
57  class TransformerActionData : public QObject
58  {
59  Q_OBJECT
60 
61  public:
65 
69  bool isMainTransDirect() const;
73  bool absolute=false,
74  bool addToHistory = false);
76  virtual View* tadView() = 0;
83  void undo();
85  void redo();
87  bool undoable();
89  bool redoable();
90 
91  signals:
93 
94  public slots:
95  virtual void resetTransform();
96  virtual void resetRotation();
97  virtual void fromRefButtonClicked();
98  virtual void toRefButtonClicked();
100  virtual void centerOnObjectsToggled( int state );
101 
102  protected slots:
103  virtual void rotationAngleEdited( const QString & );
104  virtual void rotationScaleEdited( const QString & );
105 
106  protected:
108  std::map<Transformation*, Transformation> _trans;
109  std::map<Transformation*, Transformation> _itrans;
115 
117  const aims::Quaternion & rotation ) = 0;
118  virtual void updateGVInfo( const aims::Quaternion & q ) = 0;
119  virtual void matrixCellChanged( int row, int col, QTableWidget* twid );
120  virtual void axisCellChanged( int row, int col, QTableWidget* twid );
121  virtual void centerCellChanged( int row, int col, QTableWidget* twid );
122  virtual void rotationAngleChanged( QLineEdit* ledit, QComboBox* unit );
123  virtual void rotationScaleChanged( QLineEdit* ledit );
127  const Motion & pendingMotion() const
128  {
129  return _pendingMotion;
130  }
132  void transmitValidatedMotion(Motion motion, bool notify=false);
133  };
134 
135  }
136 
137 
140  {
141  Q_OBJECT
142 
143  public:
144  static Action * creator() ;
145 
147  Transformer( const Transformer & a );
148  virtual ~Transformer();
149 
150  virtual std::string name() const;
151 
152  virtual void beginTrackball( int x, int y, int globalX, int globalY );
153  virtual void moveTrackball( int x, int y, int globalX, int globalY );
154  virtual void endTrackball( int x, int y, int globalX, int globalY );
155  virtual aims::Quaternion rotation( int x, int y );
157  virtual void showGraphicsView();
158  virtual void clearGraphicsView();
160  virtual View* tadView() { return view(); }
161 
162  struct Private; // not private since it is used by TranslaterAction
163  Private* data();
164 
165  public slots:
166  virtual void matrixCellChanged( int row, int col );
167  virtual void axisCellChanged( int row, int col );
168  virtual void centerCellChanged( int row, int col );
169  virtual void rotationAngleChanged();
170  virtual void rotationScaleChanged();
171 
172  private:
173  // Restore the visibility of these overloaded virtuals to prevent warning
179 
180  protected:
181  Private *d;
182 
184  virtual void updateGVInfo( const aims::Quaternion & q );
185  };
186 
187 
189  : public internal::TransformerActionData, public Action
190  {
191  Q_OBJECT
192  public:
193  static Action * creator() ;
194 
197  virtual ~TranslaterAction();
198 
199  virtual std::string name() const;
200 
201  virtual void begin( int x, int y, int globalX, int globalY );
202  virtual void move( int x, int y, int globalX, int globalY );
203  virtual void end( int x, int y, int globalX, int globalY );
204  virtual View* tadView() { return view(); }
206 
207  protected:
208  struct Private;
209  Private *d;
210  bool _started;
211  int _beginx;
212  int _beginy;
213 
214  virtual void updateTemporaryObjects( const aims::Quaternion & rotation );
215  virtual void updateGVInfo( const aims::Quaternion & q );
216  };
217 
218 
220  {
221  public:
222  static Action * creator() ;
223 
227 
228  virtual std::string name() const;
229 
230  virtual aims::Quaternion rotation( int x, int y );
232  };
233 
234 
236  {
237  public:
238  static Action * creator() ;
239 
242  virtual ~ResizerAction();
243 
244  virtual std::string name() const;
245 
246  virtual void begin( int x, int y, int globalX, int globalY );
247  virtual void move( int x, int y, int globalX, int globalY );
248 
249  protected:
250  // Restore visibility of overloaded virtual to prevent warning
252  virtual void updateTemporaryObjects( float zoom );
253  };
254 
255 }
256 
257 #endif
258 
259 
#define slots
Abstract base class Anatomist window.
Definition: Window.h:58
View * view()
Definition: action.h:63
PlanarTransformer(const PlanarTransformer &a)
virtual aims::Quaternion rotation(int x, int y)
static Action * creator()
virtual aims::Quaternion initialQuaternion()
virtual std::string name() const
Referential: marker for transformations, with an associated color.
Definition: Referential.h:55
ResizerAction(const ResizerAction &a)
virtual void begin(int x, int y, int globalX, int globalY)
virtual void move(int x, int y, int globalX, int globalY)
virtual std::string name() const
static Action * creator()
virtual void updateTemporaryObjects(float zoom)
Transformation between two referentials.
virtual void beginTrackball(int x, int y, int globalX, int globalY)
virtual void matrixCellChanged(int row, int col)
virtual aims::Quaternion rotation(int x, int y)
virtual void moveTrackball(int x, int y, int globalX, int globalY)
virtual void axisCellChanged(int row, int col)
virtual void rotationScaleChanged()
virtual void showGraphicsView()
virtual std::string name() const
static Action * creator()
virtual void rotationAngleChanged()
virtual View * tadView()
Definition: transformer.h:160
virtual void updateGVInfo(const aims::Quaternion &q)
virtual void updateTemporaryObjects(const aims::Quaternion &rotation)
virtual void clearGraphicsView()
virtual void centerCellChanged(int row, int col)
virtual void endTrackball(int x, int y, int globalX, int globalY)
virtual aims::Quaternion initialQuaternion()
Transformer(const Transformer &a)
virtual std::string name() const
virtual View * tadView()
Definition: transformer.h:204
virtual void begin(int x, int y, int globalX, int globalY)
virtual void move(int x, int y, int globalX, int globalY)
TranslaterAction(const TranslaterAction &a)
virtual void updateGVInfo(const aims::Quaternion &q)
static Action * creator()
virtual void end(int x, int y, int globalX, int globalY)
virtual aims::Quaternion initialQuaternion()
virtual void updateTemporaryObjects(const aims::Quaternion &rotation)
virtual void updateTemporaryObjects(const aims::Quaternion &rotation)=0
void emitTransformationChanged()
Emits the transformationChanged Qt signal.
void updatePendingMotion(const Motion &)
Updates the pending motion.
std::map< Transformation *, Transformation > _trans
Definition: transformer.h:108
virtual void centerOnObjectsToggled(int state)
virtual void rotationAngleChanged(QLineEdit *ledit, QComboBox *unit)
virtual void centerCellChanged(int row, int col, QTableWidget *twid)
TransformerActionData(const TransformerActionData &)
virtual void axisCellChanged(int row, int col, QTableWidget *twid)
virtual aims::Quaternion initialQuaternion()=0
virtual void rotationScaleEdited(const QString &)
virtual void updateGVInfo(const aims::Quaternion &q)=0
void setTransformData(const Transformation &t, bool absolute=false, bool addToHistory=false)
Transformation * mainTransformation() const
void transmitValidatedMotion(Motion motion, bool notify=false)
Transmits a validated motion to the history.
bool redoable()
Returns true if the transformation is redoable and false otherwise.
bool getCurrentMotion(Motion &)
Gets the current motion.
bool undoable()
Returns true if the transformation is undoable and false otherwise.
virtual void matrixCellChanged(int row, int col, QTableWidget *twid)
const Motion & pendingMotion() const
Returns the pending motion.
Definition: transformer.h:127
virtual void rotationScaleChanged(QLineEdit *ledit)
virtual void rotationAngleEdited(const QString &)
std::map< Transformation *, Transformation > _itrans
Definition: transformer.h:109
void setMainTransformation(Transformation *t)