anatomist  5.0.5
3D neuroimaging data viewer
qwObjectBrowser.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 ANAQT_BROWSER_QWOBJECTBROWSER_H
36 #define ANAQT_BROWSER_QWOBJECTBROWSER_H
37 
41 #include <set>
42 
43 class QStatusBar;
44 class QLabel;
45 class QLabelEdit;
46 class QTreeWidgetItem;
47 
48 namespace anatomist
49 {
50  class Hierarchy;
51  class StaticInitializers;
52  class AttDescr;
53 }
54 
55 
59 {
60  Q_OBJECT
61 
62 public:
64  enum EditMode
65  {
66  NORMAL = 0,
67  EDIT = 1,
68  SENDEDIT = 2 //,
69  };
70 
72  typedef bool (*EditFunc)( const std::set<carto::GenericObject*> & ao,
73  const std::string & att,
75  const std::set<QTreeWidgetItem*> & item );
76 
77  QObjectBrowser( QWidget * parent=0, const char * name=0,
78  carto::Object options = carto::none(),
79  Qt::WindowFlags f = 0 );
80  virtual ~QObjectBrowser();
81 
82  virtual Type type() const;
83  void displayClickPoint();
84  void Draw( bool flush = true );
85  virtual void update( const anatomist::Observable* observable, void* arg );
87  virtual void registerObject( anatomist::AObject* object,
88  bool temporaryObject = false,
89  int position = -1 );
91  virtual void unregisterObject( anatomist::AObject* object );
93  virtual void updateObject( anatomist::AObject* obj );
94 
97  virtual void setMode( unsigned mode );
98  unsigned mode() const;
99  virtual std::string modeString() const;
100  void editCancel();
101  void editValidate();
103 
104  void setShowDetailsUponRegister( bool );
105  bool showDetailsUponRegister() const;
106 
107  static int classType();
108  static anatomist::AttDescr & attDescr();
109  static void registerTypeEditor( const std::string & type, EditFunc func );
110  static void registerAttributeEditor( const std::string & syntax,
111  const std::string & att,
112  EditFunc func );
113  static bool stringEditor( const std::set<carto::GenericObject*> & ao,
114  const std::string & att,
116  const std::set<QTreeWidgetItem*> & item );
117  static bool intEditor( const std::set<carto::GenericObject*> & ao,
118  const std::string & att,
120  const std::set<QTreeWidgetItem*> & item );
121  static bool floatEditor( const std::set<carto::GenericObject*> & ao,
122  const std::string & att,
124  const std::set<QTreeWidgetItem*> & item );
125  static bool doubleEditor( const std::set<carto::GenericObject*> & ao,
126  const std::string & att,
128  const std::set<QTreeWidgetItem*> & item );
129  static bool labelEditor( const std::set<carto::GenericObject*> & ao,
130  const std::string & att,
132  const std::set<QTreeWidgetItem*> & item );
133  static bool colorEditor( const std::set<carto::GenericObject*> & ao,
134  const std::string & att,
136  const std::set<QTreeWidgetItem*> & item );
137 
138  static anatomist::AWindow* createBrowser( void *, carto::Object );
139 
140  virtual const std::set<unsigned> & typeCount() const;
141  virtual std::set<unsigned> & typeCount();
142  virtual const std::string & baseTitle() const;
143 
144  virtual anatomist::View* view();
145  virtual const anatomist::View* view() const;
146 
147 protected:
148  void updateRightPanel();
150  Tree* buildSpecificMenuTree( QObjectBrowserWidget* br,
151  QTreeWidgetItem* item,
152  Tree & tr );
153  static void modifyAttributeStatic( void* parent );
154  virtual void modifyAttribute();
155  static void modifNameStatic( void* parent );
156  static void modifLabelStatic( void* parent );
157  virtual void modifAttrib( const std::string & attrib );
158  static void addAttributeStatic( void* parent );
159  virtual void addAttribute();
160  static void removePropertyStatic( void* parent );
161  virtual void removeProperty();
164  virtual carto::GenericObject*
165  attributeCaract( const QObjectBrowserWidget* br, const QTreeWidgetItem* item,
166  std::string & attrib );
167  virtual carto::GenericObject* gObject( const QObjectBrowserWidget* br,
168  const QTreeWidgetItem* item,
169  int type );
170  virtual anatomist::AObject* aObject( const QObjectBrowserWidget* br,
171  const QTreeWidgetItem* item );
173  bool editAttribute( carto::GenericObject* ao, const std::string & att,
174  QObjectBrowserWidget* br, QTreeWidgetItem* item,
175  bool & edited );
176  bool editAttribute( const std::set<carto::GenericObject*> & objs,
177  const std::string & att,
179  const std::set<QTreeWidgetItem*> & items,
180  bool & edited );
182  void normalModeSelectionChanged();
184  static void sendModeSelection( void *parent );
185  static void setAttributeToAllSelected( void *parent );
187  std::string canSend( QObjectBrowserWidget* br, QTreeWidgetItem* item );
189  std::string canSendToAny( QObjectBrowserWidget* br, QTreeWidgetItem* item );
191  void nomenclatureClick( anatomist::Hierarchy* h,
193  std::set<anatomist::AObject *> & tosel );
194  static unsigned countSelected( QTreeWidgetItem* parent,
195  QTreeWidgetItem* & current );
197  void updateRightSelectionChange( int modifier );
198  virtual bool event( QEvent* ev );
199  virtual void keyPressEvent( QKeyEvent* ev );
200 
201 protected slots:
202  virtual void leftSelectionChangedSlot();
203  virtual void rightButtonClickedSlot( QTreeWidgetItem *, const QPoint & );
204  virtual void rightButtonRightPanel( QTreeWidgetItem *, const QPoint & );
205  virtual void doubleClickedSlot( QTreeWidgetItem*, int );
206  void rightPanelDoubleClicked( QTreeWidgetItem*, int );
207  virtual void leftItemRenamed( QTreeWidgetItem * item, int col,
208  const QString & text );
209  virtual void rightSelectionChangedSlot();
210  virtual void refreshNow();
211  void updateRightPanelNow();
212  void startDrag( QTreeWidgetItem*, Qt::MouseButtons, Qt::KeyboardModifiers );
213  virtual void leftItemStartsRename( QTreeWidgetItem * item, int col );
214  virtual void leftItemCancelsRename( QTreeWidgetItem * item, int col );
215 
216 private:
217  struct Private;
218  struct Static;
219  friend class anatomist::StaticInitializers;
220 
222  static int registerClass();
223  static Static & staticState();
224 
225  Private *d;
226 };
227 
228 
229 #endif
230 
Base Anatomist object (abstract)
Definition: Object.h:95
Abstract base class Anatomist window.
Definition: Window.h:57
This class can be subclassed to represent an object that the programmer wants to have observed...
Definition: Observable.h:67
#define slots
Specialized QTreeWidget class for AObjects / GenericObjects / attributes visualization / selection / ...
EditMode
Bit combinations for edit mode.
Editor window for labels (interaction with hierarchies)
Definition: labeledit.h:48
Nomenclature hierarchy object.
Definition: hierarchy.h:51
Anatomist Window using Qt and controler system, providing a toolbar for controls. ...
Attributed object descriptor.
Definition: attDescr.h:53
Objects browser window.
Structure used for item description.
Object none()