1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
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.
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 #include "HEXABLOCKGUI_Browser.hxx"
21 #include "HEXABLOCKGUI.hxx"
24 #include "HexDocument.hxx"
26 #include <LightApp_Module.h>
27 #include <LightApp_Study.h>
28 #include <LightApp_Application.h>
29 #include <LightApp_DataModel.h>
30 #include <LightApp_DataObject.h>
32 // --------------------------------------------------- classe SaLObject
33 class SalObject : public LightApp_DataObject
36 SalObject (cpchar nom="") : LightApp_DataObject (NULL)
37 { obj_name = nom ; obj_entry = "6.6.66" ; }
39 virtual ~SalObject () { cout << "SalObject::delete" << endl ; }
40 virtual QString name () const { return obj_name ; }
41 virtual QString entry () const { return obj_entry ; }
42 void rename (cpchar nom) { obj_name = nom ; }
48 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
49 // --------------------------------------------------- classe SaLModel
50 class SalModel : public LightApp_DataModel
53 SalModel (HEXABLOCKGUI* guy);
55 void addItem (cpchar fils);
58 CAM_ModuleObject* obj_root;
61 // =================================================== Constructeur SalModel
62 SalModel::SalModel (HEXABLOCKGUI* guy)
63 : LightApp_DataModel (guy)
65 /* **********************************************
66 LightApp_Study* study = (LightApp_Study*) guy->activeStudy();
67 obj_root = createModuleObject (study->root());
69 obj_root ->setDataModel (this);
72 SalObject* obj1 = new SalObject ("Document1");
73 SalObject* obj2 = new SalObject ("Document2");
75 PutData (obj1->name ().toStdString());
76 PutData (obj2->name ().toStdString());
78 obj_root->appendChild (obj1);
79 obj_root->appendChild (obj2);
80 PutData (obj_root->childCount());
82 ********************************************** */
84 // ================================================================ clear
85 void SalModel::clear ()
87 const bool nodel = false;
90 SUIT_DataObject* obj = obj_root->firstChild ();
93 obj_root->removeChild (obj, nodel);
94 cout << " Delete object " << obj->name ().toStdString()
98 // ================================================================ addItem
99 void SalModel::addItem (cpchar name)
101 SalObject* obj1 = new SalObject (name);
102 obj_root->appendChild (obj1);
104 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
105 // =================================================== Constructeur H.G.Browser
106 HEXABLOCKGUI_Browser::HEXABLOCKGUI_Browser (HEXABLOCKGUI* guy)
109 hexa_root = HEXA_NS::Hex::getInstance ();
113 // =============================================================== rebuildTree
114 void HEXABLOCKGUI_Browser::rebuildTree ()
116 if (data_model==NULL)
117 data_model = new SalModel (hexa_gui);
119 data_model->clear ();
121 int nbre = hexa_root->countDocument ();
122 for (int nro=0 ; nro<nbre ; nro++)
124 Document* doc = hexa_root->getDocument (nro);
125 cpchar nom = doc->getName ();
126 data_model->addItem (nom);
129 hexa_gui->updateObjBrowser( true );