WQtDatasetBrowser.h 9.3 KB
Newer Older
wiebel's avatar
wiebel committed
1 2
//---------------------------------------------------------------------------
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
wiebel's avatar
wiebel committed
4
//
5 6
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
wiebel's avatar
wiebel committed
7
//
wiebel's avatar
wiebel committed
8
// This file is part of OpenWalnut.
wiebel's avatar
wiebel committed
9
//
wiebel's avatar
wiebel committed
10
// OpenWalnut is free software: you can redistribute it and/or modify
wiebel's avatar
wiebel committed
11 12 13 14
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
wiebel's avatar
wiebel committed
15
// OpenWalnut is distributed in the hope that it will be useful,
wiebel's avatar
wiebel committed
16 17 18 19 20
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
wiebel's avatar
wiebel committed
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
wiebel's avatar
wiebel committed
22
//
wiebel's avatar
wiebel committed
23 24
//---------------------------------------------------------------------------

25 26 27
#ifndef WQTDATASETBROWSER_H
#define WQTDATASETBROWSER_H

Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
28
#include <list>
29
#include <string>
30
#include <vector>
wiebel's avatar
wiebel committed
31 32

#include <QtGui/QDockWidget>
33 34 35
#include <QtGui/QTabWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
36
#include <QtGui/QListWidget>
wiebel's avatar
wiebel committed
37

Mathias Goldau's avatar
Mathias Goldau committed
38 39
#include "../../../dataHandler/WDataSet.h"
#include "../../../graphicsEngine/WROI.h"
40
#include "../../../kernel/modules/fiberDisplay/WRMROIRepresentation.h"
41
#include "../WQtCombinerToolbar.h"
42
#include "WQtDSBWidget.h"
schurade's avatar
schurade committed
43
#include "WQtModuleHeaderTreeItem.h"
Mathias Goldau's avatar
Mathias Goldau committed
44
#include "WQtModuleTreeItem.h"
schurade's avatar
schurade committed
45
#include "WQtRoiHeaderTreeItem.h"
Mathias Goldau's avatar
Mathias Goldau committed
46
#include "WQtSubjectTreeItem.h"
47
#include "WQtTreeWidget.h"
48
#include "WQtTextureSorter.h"
49

50 51
class WMainWindow;

wiebel's avatar
wiebel committed
52
/**
53
 * container widget for a tree widget with context menu and some control widgets
wiebel's avatar
wiebel committed
54
 */
55
class WQtDatasetBrowser : public QDockWidget
wiebel's avatar
wiebel committed
56
{
57 58
    Q_OBJECT

59
public:
60
    /**
61
     * Constructor.
62 63 64
     *
     * \param parent Parent widget.
     */
65
    explicit WQtDatasetBrowser( WMainWindow* parent = 0 );
wiebel's avatar
wiebel committed
66

67
    /**
68
     * Default Destructor.
69
     */
70 71
    virtual ~WQtDatasetBrowser();

72
    /**
73
     * Adds a page to the context widget
schurade's avatar
schurade committed
74 75
     *
     * \param content A widget with controls
76 77
     *
     * \return the index of the new tab
78
     */
79
    int addTabWidgetContent( WQtDSBWidget* content );
80

81
    /**
82
     * Adds a subject entry to the tree widget
schurade's avatar
schurade committed
83 84 85
     *
     * \param name The entry name of the subjectin the tree widget
     * \return A pointer to the tree widget item
86 87
     */
    WQtSubjectTreeItem* addSubject( std::string name );
wiebel's avatar
wiebel committed
88

89
    /**
90
     * Adds a dataset entry to any given subject in the tree widget
schurade's avatar
schurade committed
91 92 93 94 95
     *
     * \param module shared pointer to the module associated with this tree widget entry
     * \param subjectId subject id this dataset belongs to
     *
     * \return A pointer to the tree widget item
96
     */
97
    WQtDatasetTreeItem* addDataset( boost::shared_ptr< WModule > module, int subjectId = 0 );
98

99 100 101 102 103 104 105
    /**
     * Adds a module to the dataset browser.
     *
     * \param module the module to add.
     *
     * \return the representation in dataset browser.
     */
106 107
    WQtModuleTreeItem* addModule( boost::shared_ptr< WModule > module );

schurade's avatar
[DOC]  
schurade committed
108 109 110 111 112
    /**
     * Adds a roi entry to the dataset browser
     *
     * \param roi pointer to the roi representation object
     */
schurade's avatar
schurade committed
113 114
    void addRoi( boost::shared_ptr< WRMROIRepresentation > roi );

115 116 117 118 119 120 121
    /**
     * Removes a roi entry from the dataset browser
     *
     * \param roi pointer to the roi representation object
     */
    void removeRoi( boost::shared_ptr< WRMROIRepresentation > roi );

122
    /**
123
     * helper funtion to connect all qt widgets with their functions
124 125 126
     */
    void connectSlots();

127 128 129 130 131 132 133
    /**
     * Returns the module currently selected in dataset browser.
     *
     * \return the module.
     */
    boost::shared_ptr< WModule > getSelectedModule();

schurade's avatar
schurade committed
134
    /**
schurade's avatar
[DOC]  
schurade committed
135
     * Returns the currently selected roi.
schurade's avatar
schurade committed
136
     *
schurade's avatar
[DOC]  
schurade committed
137
     * \return pointer to roi representation
schurade's avatar
schurade committed
138 139 140
     */
    boost::shared_ptr< WRMROIRepresentation > getSelectedRoi();

schurade's avatar
schurade committed
141 142 143 144 145 146 147
    /**
     * Returns the first roi in the currently selected branch.
     *
     * \return pointer to roi representation
     */
    boost::shared_ptr< WRMROIRepresentation > getFirstRoiInSelectedBranch();

148 149 150 151 152 153 154 155 156 157
    /**
     * Returns a checkable action that can be used to show or close this dock widget.
     * The action's text is set to the dock widget's window title.
     *
     * This member function is overwritten to add a keyboard shortcut to this action.
     *
     * \return Modified QAction
     */
    QAction* toggleViewAction() const;

158 159 160 161 162 163 164
    /**
     * Add the specified toolbar to the top of the dsb.
     *
     * \param tb the toolbar to add
     */
    void addToolbar( QToolBar* tb );

165 166 167 168 169
    /**
     * Selects the uppermost entry in the module tree.
     */
    void selectUpperMostEntry();

170 171
protected:

172 173 174 175 176 177 178 179 180 181
    /**
     * Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
     * processes several custom events, like WModuleAssocEvent.
     *
     * \param event the event that got transmitted.
     *
     * \return true if the event got handled properly.
     */
    virtual bool event( QEvent* event );

schurade's avatar
schurade committed
182 183 184 185 186 187
    /**
     * Helper function to return the first subject id in the tree widget
     */
    int getFirstSubject();

    /**
schurade's avatar
[DOC]  
schurade committed
188 189
     * fills the modul toolbar with buttons for modules that are compatible with the currently
     * selected dataset
schurade's avatar
schurade committed
190
     *
schurade's avatar
[DOC]  
schurade committed
191
     * \param module pointer to the currently selected module
192 193
     *
     * \return the new toolbar instance
schurade's avatar
schurade committed
194
     */
195
    WQtCombinerToolbar* createCompatibleButtons( boost::shared_ptr< WModule >module );
schurade's avatar
schurade committed
196

197 198 199 200
    /**
     * Reference to the main window of the application.
     */
    WMainWindow* m_mainWindow;
201

202
    /**
203
     * Searches the specified tree for all tree items matching the specified module.
204 205
     *
     * \param module the module uses as search criteria.
206
     * \param where in which subtree to search.
207 208 209
     *
     * \return a list of all matching items.
     */
210 211 212 213 214 215 216 217 218
    std::list< WQtTreeItem* > findItemsByModule( boost::shared_ptr< WModule > module, QTreeWidgetItem* where );

    /**
     * Searches the tree for all tree items matching the specified module.
     *
     * \param module the module uses as search criteria.
          *
     * \return a list of all matching items.
     */
219 220
    std::list< WQtTreeItem* > findItemsByModule( boost::shared_ptr< WModule > module );

221
private:
222
    WQtTreeWidget* m_moduleTreeWidget; //!< pointer to the tree widget
223 224 225

    WQtTreeWidget* m_roiTreeWidget; //!< pointer to the tree widget

226
    WQtTextureSorter* m_textureSorter; //!< pointer to the tree widget
schurade's avatar
schurade committed
227

schurade's avatar
[DOC]  
schurade committed
228
    QTabWidget* m_tabWidget; //!< pointer to the tab widget
schurade's avatar
schurade committed
229

230 231
    QTabWidget* m_tabWidget2; //!< pointer to the tab widget

schurade's avatar
[DOC]  
schurade committed
232
    QWidget* m_panel; //!< panel
schurade's avatar
schurade committed
233

schurade's avatar
[DOC]  
schurade committed
234
    QVBoxLayout* m_layout; //!< layout
235

schurade's avatar
[DOC]  
schurade committed
236
    WQtModuleHeaderTreeItem* m_tiModules; //!< header for modules
schurade's avatar
schurade committed
237

schurade's avatar
[DOC]  
schurade committed
238
    WQtRoiHeaderTreeItem* m_tiRois; //!< header for rois
schurade's avatar
schurade committed
239

240 241
    bool m_showToolBarText; //!< Show tool bar icons with text

242 243 244 245 246
    /**
     * The action to remove a module from the tree.
     */
    QAction* m_deleteModuleAction;

247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
    /**
     * Action which uses a compatibles list (submenu) to connect a selected item with other existing modules.
     */
    QAction* m_connectWithModuleAction;

    /**
     * Action which uses a compatibles list (submenu) to connect a selected item with other prototypes.
     */
    QAction* m_connectWithPrototypeAction;

    /**
     * Action which disconnects a connector from the module.
     */
    QAction* m_disconnectAction;

262 263 264 265 266 267
    /**
     * If true, a selection change does not cause the property tab to rebuild. This is useful if multiple items get selected at once
     * programatically.
     */
    bool m_ignoreSelectionChange;

268 269
private slots:
    /**
schurade's avatar
schurade committed
270 271
     * function that gets called when a tree item is selected, on a new select that tab widget
     * is rebuilt with the controls provided by the tree item
272 273
     */
    void selectTreeItem();
274

275 276 277 278 279 280
    /**
     * function that gets called when a tree item is selected, on a new select that tab widget
     * is rebuilt with the controls provided by the tree item
     */
    void selectRoiTreeItem();

281 282 283 284 285 286
    /**
     * Will be called to select the data module for the given dataset.
     * \param dataSet the module for this dataset will be selected.
     */
    void selectDataModule( boost::shared_ptr< WDataSet > dataSet );

287 288 289
    /**
     * function that builds the property tab
     *
290
     * \param props the properties.
291
     * \param infoProps the information properties shown on a separate tab
292
     */
293
    void buildPropTab( boost::shared_ptr< WProperties > props, boost::shared_ptr< WProperties > infoProps );
294

295 296 297 298 299 300
    /**
     * Method builds a widgets containing all properties in props. It recursively calls itself to build group widgets for WPropGroup properties.
     *
     * \param props the properties.
     */
    WQtDSBWidget* buildPropWidget( boost::shared_ptr< WProperties > props );
301

302
    /**
schurade's avatar
schurade committed
303
     * function gets called when a change to a tree item, eg. check box status, occurs
304 305
     */
    void changeTreeItem();
306

schurade's avatar
schurade committed
307 308 309 310 311
    /**
     * function gets called when a change to a tree item, eg. check box status, occurs
     */
    void changeRoiTreeItem();

schurade's avatar
schurade committed
312
    /**
313
     * delete a ROI tree item
schurade's avatar
schurade committed
314
     */
315
    void deleteROITreeItem();
schurade's avatar
schurade committed
316

317 318 319 320
    /**
     * delete a module tree item
     */
    void deleteModuleTreeItem();
wiebel's avatar
wiebel committed
321 322
};

323
#endif  // WQTDATASETBROWSER_H