anatomist 6.0.4
3D neuroimaging data viewer
minipalette.h
Go to the documentation of this file.
1#ifndef ANA_COLOR_MINIPALETTE_H
2#define ANA_COLOR_MINIPALETTE_H
3
7
8
9class QSlider;
10
11
12namespace anatomist
13{
14
26 {
27 public:
49 MiniPaletteGraphics( QGraphicsView *graphicsview, AObject *object = 0,
50 int dims = 0,
51 float width = -10000, float height = -10000,
52 float left = -10000, float top = -10000,
53 bool with_view = true );
55
58 void setObject( AObject *obj, int dims = 1 );
59 void setRange( double min, double max, int dim );
61 void resize( float x, float y, float w, float h );
62 float width() const;
63 float height() const;
64 float top() const;
65 float left() const;
66 void clear();
67 void update( const Observable *observable, void *arg );
68 double min( int dim ) const;
69 double max( int dim ) const;
70 int observedDimensions() const;
71 std::pair<double, double> range( int dim ) const;
72
73 private:
74 struct Private;
75
76 void _drawPaletteInGraphicsView();
77 std::string _format( double num ) const;
78 QGraphicsSimpleTextItem* _textGraphicsItem(
79 const std::string & text, float xpos, float ypos, float xmax,
80 float hardmax=-1, QGraphicsItem *parentitem=0 ) const;
81
82 Private *d;
83 };
84
85
110 class MiniPaletteWidget : public QWidget
111 {
112 Q_OBJECT
113
114 public:
141 MiniPaletteWidget( AObject *object = 0, int dim = 0,
142 bool allow_edit = true,
143 bool self_parent = true, QWidget *edit_parent = 0,
144 bool click_to_edit = true, bool auto_range = false,
145 bool with_view = true );
150 void setObject( AObject *obj, int dim = 0 );
165 void allowEdit( bool allow, bool self_parent = true,
166 QWidget *edit_parent = 0 );
168 void setRange( double min1, double max1 );
171 void clear();
176 QGraphicsView *graphicsView();
177 int observedDimension() const;
178 std::pair<double, double> range() const;
179
180 signals:
184 void rangeChanged( double, double );
189
190 protected:
191 void resizeEvent( QResizeEvent *event );
192 void focusInEvent( QFocusEvent *event );
193 void focusOutEvent( QFocusEvent *event );
194#if QT_VERSION >= 0x060000
195 void enterEvent( QEnterEvent *event );
196#else
197 void enterEvent( QEvent *event );
198#endif
199 void leaveEvent( QEvent *event );
200 void mouseReleaseEvent( QMouseEvent *event );
201 void wheelEvent( QWheelEvent *event );
202
203 protected slots:
204 void gvReleased( QMouseEvent *event );
206
207 private:
208 struct Private;
209
210 Private *d;
211 };
212
213
233 class MiniPaletteWidgetEdit : public QWidget, public Observer
234 {
235 Q_OBJECT
236
237 public:
238 MiniPaletteWidgetEdit( AObject *object = 0, int dim = 0,
239 bool auto_range = false, bool with_view = true,
240 bool allow_no_palette = false );
242
244 void setObject( AObject *obj, int dim = 0 );
248 virtual void update( const Observable *observable, void *arg );
250 QSlider *minSlider();
251 QSlider *maxSlider();
252 int observedDimension() const;
253 std::pair<double, double> range() const;
254
255 signals:
256 void paletteSelected( const std::string & );
257
258 public slots:
262 void setAutoRange( bool auto_range );
263 void minChanged( double value );
264 void maxChanged( double value );
265 void setRange( double rmin, double rmax );
267 void setPalette( const std::string & palname );
268 void gvMoved( QMouseEvent *event );
270
271 private:
272 struct Private;
273
274 Private *d;
275 };
276
277
292 class MiniPaletteWidgetTranscient : public QWidget
293 {
294 Q_OBJECT
295
296 public:
298 int dim = 0,
299 MiniPaletteWidget* pw = 0,
300 QWidget *parent = 0,
301 bool opened_by_click = false,
302 bool auto_range = false );
309
310 public slots:
314
315 signals:
318
319 protected:
320 void leaveEvent( QEvent *event );
321 void focusOutEvent( QFocusEvent *event );
322#if QT_VERSION >= 0x060000
323 void enterEvent( QEnterEvent *event );
324#else
325 void enterEvent( QEvent *event );
326#endif
327 void focusInEvent( QFocusEvent *event );
328 void keyPressEvent( QKeyEvent *event );
329 void closeEvent( QCloseEvent *event );
330
331 private:
332 struct Private;
333
334 Private *d;
335 };
336
337}
338
339#endif
#define slots
Base Anatomist object (abstract)
Definition Object.h:97
MiniPaletteGraphics is an element which draws a palette in a GraphicsView scene.
Definition minipalette.h:26
std::pair< double, double > range(int dim) const
double max(int dim) const
void resize(float x, float y, float w, float h)
void setObject(AObject *obj, int dims=1)
set or change the observed object
void update(const Observable *observable, void *arg)
This method is called whenever the observed object is changed.
double min(int dim) const
MiniPaletteGraphics(QGraphicsView *graphicsview, AObject *object=0, int dims=0, float width=-10000, float height=-10000, float left=-10000, float top=-10000, bool with_view=true)
Parameters: graphicsview: the existing graphic view where the palette should be drawn object: object ...
void setRange(double min, double max, int dim)
Mini palette editor widget.
void updateDisplay()
redraws the palette and sliders values
void setAutoRange(bool auto_range)
allows or disables the auto-zoom mode
MiniPaletteWidgetEdit(AObject *object=0, int dim=0, bool auto_range=false, bool with_view=true, bool allow_no_palette=false)
void gvMoved(QMouseEvent *event)
void paletteSelected(const std::string &)
void setPalette(const std::string &palname)
MiniPaletteWidget * miniPaletteWidget()
void setRange(double rmin, double rmax)
virtual void update(const Observable *observable, void *arg)
This method is called whenever the observed object is changed.
void adjustRange()
auto-range function
void setObject(AObject *obj, int dim=0)
set or change the observed object
std::pair< double, double > range() const
void focusOutEvent(QFocusEvent *event)
void closeEvent(QCloseEvent *event)
MiniPaletteWidgetTranscient(AObject *object=0, int dim=0, MiniPaletteWidget *pw=0, QWidget *parent=0, bool opened_by_click=false, bool auto_range=false)
void keyPressEvent(QKeyEvent *event)
void editorClosed()
signal emitted when the editor widget closes
void reposition()
Repositions / resizes the widget to superpose on its MiniPaletteWidget.
void focusInEvent(QFocusEvent *event)
MiniPaletteWidgetEdit * editor()
void leaveEvent(QEvent *event)
void focusOutEvent(QFocusEvent *event)
void mouseReleaseEvent(QMouseEvent *event)
void focusInEvent(QFocusEvent *event)
void enterEvent(QEvent *event)
void wheelEvent(QWheelEvent *event)
void gvReleased(QMouseEvent *event)
std::pair< double, double > range() const
void allowEdit(bool allow, bool self_parent=true, QWidget *edit_parent=0)
Enalbes or disable the edition capabilities.
MiniPaletteGraphics * miniPaletteGraphics()
void setRange(double min1, double max1)
set the view range in object values
MiniPaletteWidget(AObject *object=0, int dim=0, bool allow_edit=true, bool self_parent=true, QWidget *edit_parent=0, bool click_to_edit=true, bool auto_range=false, bool with_view=true)
Parameters:
void rangeChanged(double, double)
signal emitted when the zoom range has changed (after a mouse wheel event, typically)
void setObject(AObject *obj, int dim=0)
set or change the observed object, dim is the texture dimension observed
QGraphicsView * graphicsView()
void resizeEvent(QResizeEvent *event)
void paletteClicked()
signal emitted when the palete view is clicked, and click_to_edit mode is disabled.
void updateDisplay()
redraws the palette view
void showEditor()
pops up the editor, if the edition is allowed
A class can implement the Observer interface when it wants to be informed of changes in observable ob...
Definition Observer.h:55
friend class Observable
Definition Observer.h:90