Computer Assited Medical Intervention Tool Kit  version 5.0
Explorer.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef EXPLORER_H
28 #define EXPLORER_H
29 
30 #include "ExplorerAPI.h"
31 
32 // -- Core stuff
33 #include <Viewer.h>
34 
35 // -- QT stuff
36 #include <QTreeWidget>
37 #include <QTreeWidgetItem>
38 
39 namespace camitk {
40 // -- Core stuff classes
41 class InterfaceNode;
42 class Component;
43 class ExplorerItem;
44 }
45 
65  Q_OBJECT
66 
67 public:
70 
72  Q_INVOKABLE Explorer(QString);
73 
75  ~Explorer() override;
76 
79  void refresh(camitk::Viewer* whoIsAsking = nullptr) override;
82 
84  QWidget* getWidget() override;
85 
87  QMenu* getMenu() override;
88 
90 
91 public slots :
92 
94  void renameItem();
95 
96 private slots :
97 
99  void explorerSelectionChanged();
100 
102  void doubleClicked(QTreeWidgetItem*, int);
103 
105  void rightButtonPressed(const QPoint&);
106 
107 private:
108 
112  QMap<QTreeWidgetItem*, camitk::Component*> itemComponentMap;
113 
115  QMap<camitk::Component*, QTreeWidgetItem*> topLevelCompItemMap;
116 
118  QTreeWidgetItem* getItem(camitk::Component*);
120 
124  QTreeWidgetItem* getNewItem(QTreeWidgetItem* parent, camitk::Component*);
125 
127  QTreeWidgetItem* add(QTreeWidgetItem*, camitk::Component*);
128 
133  void addTopLevel(camitk::Component* comp, int index = -1);
134 
136  void remove(QTreeWidgetItem*);
137 
141  void removeTopLevel(camitk::Component* comp);
142 
150  void refreshInterfaceNode(camitk::Component* comp);
151 
153  QTreeWidget* explorerTree;
155 
159  QMenu* explorerMenu;
160 
162  QAction* editRename;
164 };
165 
166 #endif
Explorer::~Explorer
~Explorer() override
Destructor.
Definition: Explorer.cpp:55
camitk::Component::inItalic
bool inItalic() const override
A component name is not displayed in italic by default.
Definition: sdk/libraries/core/component/Component.h:927
Explorer
The Explorer viewer displays the list of all data currently opened in the application....
Definition: Explorer.h:64
Explorer::getItem
QTreeWidgetItem * getItem(camitk::Component *)
Return the QTreeWidgetItem of a given Component (return nullptr if not found)
Definition: Explorer.cpp:176
camitk::Viewer::setDescription
void setDescription(QString)
set the viewer's description
Definition: Viewer.cpp:104
Explorer::editRename
QAction * editRename
the possible action
Definition: Explorer.h:162
Explorer::topLevelCompItemMap
QMap< camitk::Component *, QTreeWidgetItem * > topLevelCompItemMap
the map to get the QTreeWidgetItem corresponding to a parentComp
Definition: Explorer.h:115
Explorer::explorerSelectionChanged
void explorerSelectionChanged()
slot called whenever the selection changed in the explorer
Definition: Explorer.cpp:334
Explorer::renameItem
void renameItem()
slot called by the explorer menu when the user wants to rename the currently selected Component
Definition: Explorer.cpp:385
camitk::Component::isSelected
virtual bool isSelected() const
Check if this data component is selected.
Definition: sdk/libraries/core/component/Component.h:892
CAMITK_INFO
#define CAMITK_INFO(MSG)
Log for info verbosity (the second most verbose one) The msg will appear only if the user asked for I...
Definition: Log.h:261
Explorer::add
QTreeWidgetItem * add(QTreeWidgetItem *, camitk::Component *)
recursively add the Component in the tree explorer and return the QTreeWidgetItem of the InterfaceNod...
Definition: Explorer.cpp:238
ExplorerAPI.h
Explorer::refresh
void refresh(camitk::Viewer *whoIsAsking=nullptr) override
Definition: Explorer.cpp:114
camitk::Component::getActionMenu
QMenu * getActionMenu()
Get a QMenu that contains all the action that can be applied to this component.
Definition: sdk/libraries/core/component/Component.cpp:355
Explorer::getMenu
QMenu * getMenu() override
get the explorer menu
Definition: Explorer.cpp:91
camitk::rightButtonPressed
void rightButtonPressed()
send when the mouse right button is clicked
Explorer::explorerTree
QTreeWidget * explorerTree
the list view
Definition: Explorer.h:153
Explorer::getWidget
QWidget * getWidget() override
get the explorer widget (QTreeWidget)
Definition: Explorer.cpp:64
Explorer::rightButtonPressed
void rightButtonPressed(const QPoint &)
slot called on right button click
Definition: Explorer.cpp:369
Explorer::doubleClicked
void doubleClicked(QTreeWidgetItem *, int)
slot called when an item was double clicked
Definition: Explorer.cpp:354
camitk::Viewer::setIcon
void setIcon(QPixmap icon)
set the default icon for the viewer extension
Definition: Viewer.cpp:84
Explorer::remove
void remove(QTreeWidgetItem *)
remove a given item from the explorer (return its index in the parent item list)
Definition: Explorer.cpp:314
Log.h
camitk::Viewer::getName
QString getName() const
get the name of the viewer
Definition: Viewer.h:200
Explorer::itemComponentMap
QMap< QTreeWidgetItem *, camitk::Component * > itemComponentMap
Definition: Explorer.h:112
EXPLORER_API
#define EXPLORER_API
Definition: ExplorerAPI.h:54
camitk::Viewer::getMenu
virtual QMenu * getMenu()
get the viewer menu (returns nullptr by default, i.e. there are no default edit menu)
Definition: Viewer.h:245
camitk::Component::getName
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:907
camitk::Component::doubleClicked
bool doubleClicked() override
This method is called each time the InterfaceNode is double clicked by the user.
Definition: sdk/libraries/core/component/Component.h:897
camitk::ComponentList
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127
Explorer::getNewItem
QTreeWidgetItem * getNewItem(QTreeWidgetItem *parent, camitk::Component *)
Definition: Explorer.cpp:192
camitk::Component::setVisibility
virtual void setVisibility(QString, bool)
set the visibility inside the viewer of the given name (the viewer needs to be a registered viewer)
Definition: sdk/libraries/core/component/Component.cpp:224
camitk::Component::getChildren
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:902
Component
A component is something that composed something and could also be a part of something.
Definition: modeling/libraries/pml/Component.h:48
Explorer.h
camitk::Viewer
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
Explorer::removeTopLevel
void removeTopLevel(camitk::Component *comp)
Remove the Component (its Component and its sub-item) from the explorer list (if present).
Definition: Explorer.cpp:300
camitk::Viewer::getWidget
virtual QWidget * getWidget()=0
get the viewer widget.
Viewer.h
camitk::Viewer::refresh
virtual void refresh(Viewer *whoIsAsking=nullptr)=0
refresh the view (can be interesting to know which other viewer is calling this)
camitk::Component::setName
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:932
camitk::Component::getParent
InterfaceNode * getParent() override
get the parent Component
Definition: sdk/libraries/core/component/Component.h:912
camitk::Component::refresh
virtual void refresh()
refresh all the viewer that are currently displaying this Component At the end the InterfaceNode modi...
Definition: sdk/libraries/core/component/Component.cpp:286
Explorer::addTopLevel
void addTopLevel(camitk::Component *comp, int index=-1)
Add the given Component to the explorer (at top level) and automatically create children Component it...
Definition: Explorer.cpp:219
camitk::Component::getIcon
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: sdk/libraries/core/component/Component.h:922
Explorer::explorerMenu
QMenu * explorerMenu
Definition: Explorer.h:159
Explorer::Explorer
Q_INVOKABLE Explorer(QString)
Construtor.
Definition: Explorer.cpp:46
Explorer::refreshInterfaceNode
void refreshInterfaceNode(camitk::Component *comp)
Update the interface node representation of a given Component, (creates a new sub-item for all the ne...
Definition: Explorer.cpp:257
camitk::Component
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
Application.h
camitk
Definition: Action.cpp:35