1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author: Guillaume Boulant (EDF/R&D)
22 #include "TreeGuiManager.hxx"
25 #include <QStringList>
28 #include "TreeView.hxx"
29 #include "QtHelper.hxx"
32 // IMP: The constructor should have a dockwidget as argument.
33 // The creation of the void dockwidget (without the data tree
34 // embedded) should be done previously by the StandardApp_Module.
35 // The constructor would fill the dockwidget with a data tree view
38 * The construction of the gui manager setups a graphic framework that
39 * consists in a set of dock widgets implanted in the SALOME GUI and
40 * embedding a tree view rendering a data model (collection of data
41 * objects) in a hierarchic graphical organisation.
43 * The data model is a straith list of data objects while the view is
44 * a tree representation of this collection where folders corresponds
45 * to specific properties of the objects.
47 * This represention is for the needs of navigation in a huge amount
48 * of data and to ease the selection and processing of items.
50 TreeGuiManager::TreeGuiManager(SalomeApp_Application * salomeApp, const char * title)
53 _salomeApp = salomeApp;
56 _dockWidgets = new DockWidgets(_salomeApp, tabify, title);
58 // Create a TreeView to be associated to a TreeModel dedicated to
60 _dataTreeView = new TreeView();
62 headers << tr("Name") << tr("Value");
63 _dataTreeModel = new TreeModel(headers);
64 _dataTreeView->setModel(_dataTreeModel);
66 // Then plug the TreeView in the dock widget:
67 _dockWidgets->setDataView(_dataTreeView);
69 // We specify here the dataview to be observed
70 this->observe(_dataTreeView);
74 * This returns the SALOME application (SalomeApp_Application
75 * instance) associated to this TreeGuiManager.
77 SalomeApp_Application * TreeGuiManager::getSalomeApplication() {
83 * This function set a layout of the different dock widgets in one
84 * single tabbed widget.
86 void TreeGuiManager::tabifyDockWidgets(bool tabify) {
87 _dockWidgets->tabify(tabify);
91 * This function switch on/off the dock widgets managed by this
94 void TreeGuiManager::showDockWidgets(bool isVisible) {
95 _dockWidgets->show(isVisible);
99 * This returns the data tree model defined in this
100 * TreeGuiManager. The data tree model is a tree representation of the
101 * data model associated to this TreeGuiManager.
103 TreeModel * TreeGuiManager::getDataTreeModel() {
104 return _dataTreeModel;
108 * This returns the data tree view defined in this
109 * TreeGuiManager. The data tree view can be request to customize the
110 * popup menu associated to the tree representation.
112 TreeView * TreeGuiManager::getDataTreeView() {
113 return _dataTreeView;
118 * This function specifies the data model to be used by the
121 void TreeGuiManager::setDataModel(DataModel * dataModel) {
122 _dataModel = dataModel;
125 DataModel * TreeGuiManager::getDataModel() {
130 * This function processes the edit signals received from the
131 * TreeView. This is a default implementation that only prints the
132 * reception of the signal and some information about the dataObject
133 * associated to the item whose id is specified. In practice, the data
134 * model could be requested here to retrieve the data object to be
135 * edited from the nameId.
136 * TO BE IMPLEMENTED IN A DOMAIN SPECIFIC VERSION OF THIS CLASS
139 void TreeGuiManager::processItemList(QStringList itemNameIdList,
142 // WARN: THIS IS A DEFAULT IMPLEMENTATION GIVEN FOR DEMONSTRATION
143 // OF WHAT TO DO WITH THE PARAMETERS
145 QString itemNameId = itemNameIdList[0];
146 LOG("TreeGuiManager: signal received : process item "<<itemNameId);
147 DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
148 if ( dataObject != NULL ) {
149 LOG("TreeGuiManager: dataObject = "<<dataObject->toString().c_str());
151 LOG("TreeGuiManager: no data object associated to this item");