Salome HOME
removed DEBUG macros
[modules/gui.git] / src / LightApp / LightApp_Study.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "LightApp_Study.h"
24
25 #include "CAM_DataModel.h"
26 #include "CAM_Module.h"
27 #include "LightApp_Application.h"
28 #include "LightApp_DataModel.h"
29 #include "LightApp_DataObject.h"
30 #include "LightApp_HDFDriver.h"
31
32 #include "SUIT_ResourceMgr.h"
33 #include "SUIT_DataObjectIterator.h"
34 #include "SUIT_DataBrowser.h"
35 #include "SUIT_TreeModel.h"
36
37 #include <set>
38
39
40 /*!
41   Constructor.
42 */
43 LightApp_Study::LightApp_Study( SUIT_Application* app )
44 : CAM_Study( app )
45 {
46   // HDF persistence
47   myDriver = new LightApp_HDFDriver();
48   //myDriver = new LightApp_Driver();
49 }
50
51 /*!
52   Destructor.
53 */
54 LightApp_Study::~LightApp_Study()
55 {
56   delete myDriver; myDriver = 0;
57 }
58
59 /*!
60   Create document.
61 */
62 bool LightApp_Study::createDocument( const QString& theStr )
63 {
64   // create myRoot
65   setRoot( new LightApp_RootObject( this ) );
66
67   bool aRet = CAM_Study::createDocument( theStr );
68
69   emit created( this );
70
71   return aRet;
72 }
73
74 /*!
75   Opens document
76 */
77 bool LightApp_Study::openDocument( const QString& theFileName )
78 {
79   myDriver->ClearDriverContents();
80   // create files for models from theFileName
81   if( !openStudyData(theFileName, 0)) // 0 means persistence file
82     return false;
83
84   setRoot( new LightApp_RootObject( this ) ); // create myRoot
85
86   // update loaded data models: call open() and update() on them.
87   ModelList dm_s;
88   dataModels( dm_s );
89   QListIterator<CAM_DataModel*> it( dm_s );
90   while ( it.hasNext() )
91     openDataModel( studyName(), it.next() );
92   // this will build a SUIT_DataObject-s tree under myRoot member field
93   // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
94   // but tree that corresponds to not-loaded data models will be updated any way. 
95   ((LightApp_Application*)application())->updateObjectBrowser( false ); 
96
97   bool res = CAM_Study::openDocument( theFileName );
98
99   emit opened( this );
100   return res;
101 }
102
103 /*!
104   Loads document
105 */
106 bool LightApp_Study::loadDocument( const QString& theStudyName )
107 {
108   myDriver->ClearDriverContents();
109   if( !openStudyData(theStudyName, 0)) // 0 means persistence file
110     return false;
111
112   setRoot( new LightApp_RootObject( this ) ); // create myRoot
113
114   //SRN: BugID IPAL9021, put there the same code as in a method openDocument
115
116   // update loaded data models: call open() and update() on them.
117   ModelList dm_s;
118   dataModels( dm_s );
119
120   QListIterator<CAM_DataModel*> it( dm_s );
121   while ( it.hasNext() )
122     openDataModel( studyName(), it.next() );
123
124   // this will build a SUIT_DataObject-s tree under myRoot member field
125   // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
126   // but tree that corresponds to not-loaded data models will be updated any way. 
127   ((LightApp_Application*)application())->updateObjectBrowser( false ); 
128
129   bool res = CAM_Study::openDocument( theStudyName );
130   emit opened( this );
131   //SRN: BugID IPAL9021: End
132   return res;
133 }
134
135 /*!
136   Saves document
137 */
138 bool LightApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/*=false*/ )
139 {
140   SUIT_ResourceMgr* resMgr = application()->resourceMgr();
141   if( !resMgr )
142     return false;
143
144   ModelList list; 
145   dataModels( list );
146
147   QStringList listOfFiles;
148   bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
149   QListIterator<CAM_DataModel*> itList( list );
150   while ( itList.hasNext() )
151   {
152     LightApp_DataModel* aModel = (LightApp_DataModel*)itList.next();
153     if ( !aModel ) continue;
154
155     std::vector<std::string> anOldList = myDriver->GetListOfFiles( aModel->module()->name().toLatin1().constData() );
156     listOfFiles.clear();
157     aModel->saveAs( theFileName, this, listOfFiles );
158     if ( !listOfFiles.isEmpty() )
159       saveModuleData(aModel->module()->name(), 0, // 0 means persistence file
160                      listOfFiles);
161
162     // Remove files if necessary. File is removed if it was in the list of files before
163     // saving and it is not contained in the list after saving. This provides correct 
164     // removing previous temporary files. These files are not removed before saving
165     // because they may be required for it.
166
167     std::vector<std::string> aNewList = myDriver->GetListOfFiles( aModel->module()->name().toLatin1().constData() );
168     
169     std::set<std::string> aNewNames;
170     std::set<std::string> toRemove;
171     size_t i, n;
172     for( i = 0, n = aNewList.size(); i < n; i++ )
173       aNewNames.insert( aNewList[ i ] );
174     for( i = 0, n = anOldList.size(); i < n; i++ )
175     {
176       if ( i == 0 ) // directory is always inserted in list
177         toRemove.insert( anOldList[ i ] );
178       else if ( aNewNames.find( anOldList[ i ] ) == aNewNames.end() )
179         toRemove.insert( anOldList[ i ] );
180     }
181         
182     std::vector<std::string> toRemoveList( toRemove.size() );
183     std::set<std::string>::iterator anIter;
184     for( anIter = toRemove.begin(), i = 0; anIter != toRemove.end(); ++anIter, ++i )
185       toRemoveList[ i ] = *anIter;
186
187     
188     myDriver->RemoveFiles( toRemoveList, isMultiFile );
189   }
190
191   bool res = saveStudyData(theFileName, 0); // 0 means persistence file
192   res = res && CAM_Study::saveDocumentAs( theFileName );
193   //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
194   if ( res && !isBackup)
195     emit saved( this );
196
197   return res;
198 }
199
200 /*!
201   Saves document
202 */
203 bool LightApp_Study::saveDocument()
204 {
205   ModelList list; dataModels( list );
206
207   myDriver->ClearDriverContents();
208   QStringList listOfFiles;
209   QListIterator<CAM_DataModel*> itList( list );
210   while ( itList.hasNext() ) {
211     LightApp_DataModel* aModel = (LightApp_DataModel*)itList.next();
212     if ( !aModel ) continue;
213
214     listOfFiles.clear();
215     aModel->save( listOfFiles );
216     saveModuleData(aModel->module()->name(), 0, // 0 means persistence file
217                    listOfFiles);
218   }
219
220   bool res = saveStudyData(studyName(), 0); // 0 means persistence file
221   res = res && CAM_Study::saveDocument();
222   if (res)
223     emit saved( this );
224
225   return res;
226 }
227
228 /*!
229   Closes document
230 */
231 void LightApp_Study::closeDocument(bool permanently)
232 {
233   // Inform everybody that this study is going to close when it's most safe to,
234   // i.e. in the very beginning
235   emit closed( this );
236
237   CAM_Study::closeDocument(permanently);
238   
239   // Remove temporary files
240   myDriver->ClearDriverContents();
241 }
242
243 /*!
244   \return real entry by entry of reference
245   \param entry - entry of reference object
246 */
247 QString LightApp_Study::referencedToEntry( const QString& entry ) const
248 {
249   return entry;
250 }
251
252 /*!
253   \return entries of object children
254 */
255 void LightApp_Study::children( const QString&, QStringList& ) const
256 {
257 }
258
259 /*!
260   \return true if entry corresponds to component
261 */
262 bool LightApp_Study::isComponent( const QString& entry ) const
263 {
264   if( !root() )
265     return false;
266
267   DataObjectList ch;
268   root()->children( ch );
269   DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
270   for( ; anIt!=aLast; anIt++ )
271   {
272     LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( *anIt );
273     if( obj && obj->entry()==entry )
274       return true;
275   }
276   return false;
277 }
278
279 /*!
280   \return component data type for entry
281 */
282 QString LightApp_Study::componentDataType( const QString& entry ) const
283 {
284   LightApp_DataObject* aCurObj;
285   for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
286     aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
287     if ( aCurObj && aCurObj->entry() == entry ) {
288       return aCurObj->componentDataType();
289     }
290   }
291   return "";
292 }
293
294 /*!
295   \return true if study is modified
296 */
297 bool LightApp_Study::isModified() const
298 {
299   bool isAnyChanged = CAM_Study::isModified();
300   ModelList list; dataModels( list );
301
302   LightApp_DataModel* aModel = 0;
303   QListIterator<CAM_DataModel*> it( list );
304   while ( it.hasNext() && !isAnyChanged ) {
305     aModel = dynamic_cast<LightApp_DataModel*>( it.next() );
306     if ( aModel )
307       isAnyChanged = aModel->isModified();
308   }
309   return isAnyChanged; 
310 }
311
312 /*!
313   \return true if data model is saved
314 */
315 bool LightApp_Study::isSaved() const
316 {
317   return CAM_Study::isSaved();
318 }
319
320 /*!
321   Creates SComponent for module, necessary for SalomeApp study
322 */
323 void LightApp_Study::addComponent(const CAM_DataModel* /*dm*/)
324 {
325 }
326
327 /*!
328   Saves list file for module 'theModuleName'
329 */
330 void LightApp_Study::saveModuleData(QString theModuleName, int type, QStringList theListOfFiles)
331 {
332   int aNb = theListOfFiles.count();
333   if ( aNb == 0 )
334     return;
335
336   std::vector<std::string> aListOfFiles ( aNb );
337   int anIndex = 0;
338   for ( QStringList::Iterator it = theListOfFiles.begin(); it != theListOfFiles.end(); ++it ) {
339     if ( (*it).isEmpty() )
340       continue;
341     aListOfFiles[anIndex] = (*it).toUtf8().constData();
342     anIndex++;
343   }
344   SetListOfFiles(theModuleName.toLatin1().constData(), type, aListOfFiles);
345 }
346
347 /*!
348   Gets list of file for module 'theModuleNam'
349 */
350 void LightApp_Study::openModuleData(QString theModuleName, int /*type*/, QStringList& theListOfFiles)
351 {
352   std::vector<std::string> aListOfFiles =  myDriver->GetListOfFiles(theModuleName.toLatin1().constData());
353   int i, aLength = (int)aListOfFiles.size() - 1; //!< TODO: conversion size_t to int
354   if (aLength < 0)
355     return;
356
357   //Get a temporary directory for saved a file
358   theListOfFiles.append(aListOfFiles[0].c_str());
359   for(i = 0; i < aLength; i++)
360     theListOfFiles.append(aListOfFiles[i+1].c_str());
361 }
362
363 /*!
364   Saves data from study
365 */
366 bool LightApp_Study::saveStudyData( const QString& theFileName, int /*type*/ )
367 {
368   ModelList list; dataModels( list );
369   SUIT_ResourceMgr* resMgr = application()->resourceMgr();
370   if( !resMgr )
371     return false;
372   bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
373
374   bool aRes = myDriver->SaveDatasInFile(theFileName.toUtf8(), isMultiFile);
375   return aRes;
376 }
377
378 /*!
379   Opens data for study
380 */
381 bool LightApp_Study::openStudyData( const QString& theFileName, int /*type*/ )
382 {
383   SUIT_ResourceMgr* resMgr = application()->resourceMgr();
384   if( !resMgr )
385     return false;
386   bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
387
388   bool aRes = myDriver->ReadDatasFromFile(theFileName.toUtf8(), isMultiFile);
389   return aRes;
390 }
391
392 /*!
393   Opens data model
394 */
395 bool LightApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm )
396 {
397   if (!dm)
398     return false;
399
400   QStringList listOfFiles;
401   openModuleData(dm->module()->name(), 0, // 0 means persistence file
402                  listOfFiles);
403   if (dm && dm->open(studyName, this, listOfFiles)) {
404     // Something has been read -> create data model tree
405     LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>( dm );
406     if ( aDM )
407       aDM->update(NULL, this);
408     return true;
409   }
410   return false;
411 }
412
413 /*!
414   \return temporary directory for saving files of modules
415 */
416 std::string LightApp_Study::GetTmpDir (const char* theURL,
417                                        const bool  isMultiFile)
418 {
419   return myDriver->GetTmpDir(theURL, isMultiFile);
420 }
421
422 /*!
423   \return list of files necessary for module
424   \param theModuleName - name of module
425 */
426 std::vector<std::string> LightApp_Study::GetListOfFiles(const char* theModuleName, int /*type*/) const
427 {
428   return myDriver->GetListOfFiles(theModuleName);
429 }
430
431 /*!
432   Sets list of files necessary for module
433   \param theModuleName - name of module
434   \param theListOfFiles - list of files
435 */
436 void LightApp_Study::SetListOfFiles (const char* theModuleName, int /*type*/, const std::vector<std::string> theListOfFiles)
437 {
438   myDriver->SetListOfFiles(theModuleName, theListOfFiles);
439 }
440
441 /*!
442   Removes temporary files
443 */
444 void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, bool isMultiFile, bool /*force*/)
445 {
446   if (isMultiFile)
447     return;
448   bool isDirDeleted = true;
449   myDriver->RemoveTemporaryFiles(theModuleName, isDirDeleted);
450 }
451
452 /*!
453   Virtual method that creates the root object (module object) for the given data model.
454   The type of the created object depends on the study class, therefore data model classes
455   should not create their module objects directly and should instead use 
456   LightApp_DataModel::createModuleObject() that in its turn relies on this method.
457
458   \param theDataModel - data model instance to create a module object for
459   \param theParent - the module object's parent (normally it's the study root)
460   \return the module object instance
461   \sa LightApp_DataModel class, SalomeApp_Study class, LightApp_ModuleObject class
462 */
463 CAM_ModuleObject* LightApp_Study::createModuleObject( LightApp_DataModel* theDataModel, 
464                                                       SUIT_DataObject* theParent ) const
465 {
466   // Calling addComponent() for symmetry with SalomeApp_Study
467   // Currently it has empty implementation, but maybe in the future things will change...
468   LightApp_Study* that = const_cast<LightApp_Study*>( this );
469   that->addComponent( theDataModel );
470
471   // Avoid creating multiple module objects for the same module
472   CAM_ModuleObject* res = 0;
473
474   DataObjectList children = root()->children();
475   DataObjectList::const_iterator anIt = children.begin(), aLast = children.end();
476   for( ; !res && anIt!=aLast; anIt++ )
477   {
478     LightApp_ModuleObject* obj = dynamic_cast<LightApp_ModuleObject*>( *anIt );
479     if ( obj && obj->name() == theDataModel->module()->moduleName() )
480       res = obj;
481   }
482
483   if ( !res ){
484     res = new LightApp_ModuleObject( theDataModel, theParent );
485   }
486
487   return res;
488 }
489
490 /*!
491   Fills list with components names
492   \param comp - list to be filled
493 */
494 void LightApp_Study::components( QStringList& comp ) const
495 {
496   DataObjectList children = root()->children();
497   DataObjectList::const_iterator anIt = children.begin(), aLast = children.end();
498   for( ; anIt!=aLast; anIt++ )
499   {
500     LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( *anIt );
501     if ( obj && obj->entry() != getVisualComponentName() )
502       comp.append( obj->entry() );
503   }
504 }
505
506 /*!
507   Get the entry for the given module
508   \param comp - list to be filled
509   \return module root's entry
510 */
511 QString LightApp_Study::centry( const QString& comp ) const
512 {
513   QString e;
514   ModelList dmlist;
515   dataModels( dmlist );
516   QListIterator<CAM_DataModel*> it( dmlist );
517   while ( it.hasNext() && e.isEmpty() ) {
518     CAM_DataModel* dm = it.next();
519     if ( dm->module() && dm->module()->name() == comp ) {
520       LightApp_DataObject* r = dynamic_cast<LightApp_DataObject*>( dm->root() );
521       if ( r ) e = r->entry();
522     }
523   }
524   return e;
525 }
526
527 /*!
528   \return a name of the component where visual parameters are stored
529 */
530 QString LightApp_Study::getVisualComponentName() const
531 {
532   return "Interface Applicative";
533 }
534
535 /*!
536   Set a visual property of the object
537   \param theViewMgrId - Id of the viewer namager
538   \param theEntry - Entry of the object
539   \param thePropName - the name of the visual property
540   \param theValue - the value of the visual property
541 */
542 void LightApp_Study::setObjectProperty( int theViewMgrId,
543                                         const QString& theEntry,
544                                         const QString& thePropName,
545                                         const QVariant& theValue )
546 {
547   myViewMgrMap[theViewMgrId][theEntry][thePropName] = theValue;
548 }
549
550 /*!
551   Get a visual property of the object identified by theViewMgrId, theEntry and thePropName.
552   \param theViewMgrId - Id of the viewer manager.
553   \param theEntry - Entry of the object.
554   \param thePropName - the name of the visual property.
555   \param theDefValue - the default value of the visual property.
556   \return value of the visual propetry. If value is't found then return theDefValue.
557 */
558 QVariant LightApp_Study::getObjectProperty( int theViewMgrId,
559                                             const QString& theEntry,
560                                             const QString& thePropName,
561                                             const QVariant& theDefValue ) const
562 {
563   QVariant aResult = theDefValue;
564   ViewMgrMap::ConstIterator v_it = myViewMgrMap.find( theViewMgrId );
565   if ( v_it != myViewMgrMap.end() ) {
566     const ObjMap& anObjectMap = v_it.value();
567     ObjMap::ConstIterator o_it = anObjectMap.find( theEntry );
568     if ( o_it != anObjectMap.end() ) {
569       const PropMap& aPropMap = o_it.value();
570       PropMap::ConstIterator p_it = aPropMap.find( thePropName );
571       if ( p_it != aPropMap.end() ) {
572         aResult = p_it.value();
573       }
574     }
575   }
576   return aResult;
577 }
578
579 /*!
580   Set a visual property of the object for all registered viewers
581   \param theEntry - Entry of the object
582   \param thePropName - the name of the visual property
583   \param theValue - the value of the visual property
584 */
585 void LightApp_Study::setObjectProperty( const QString& theEntry,
586                                         const QString& thePropName,
587                                         const QVariant& theValue )
588 {
589   const ViewMgrMap& vm = getObjectProperties();
590   ViewMgrMap::ConstIterator v_it;
591   for ( v_it = vm.begin(); v_it != vm.end(); ++v_it ) {
592     setObjectProperty( v_it.key(), theEntry, thePropName, theValue );
593   }
594 }
595
596 /*!
597   Set a visual property for all registered objects for given viewer
598   \param theViewMgrId - Id of the viewer manager.
599   \param thePropName - the name of the visual property
600   \param theValue - the value of the visual property
601 */
602 void LightApp_Study::setObjectProperty( int theViewMgrId,
603                                         const QString& thePropName,
604                                         const QVariant& theValue )
605 {
606   const ObjMap& om = getObjectProperties( theViewMgrId );
607   ObjMap::ConstIterator o_it;
608   for ( o_it = om.begin(); o_it != om.end(); ++o_it ) {
609     setObjectProperty( theViewMgrId, o_it.key(), thePropName, theValue );
610   }
611 }
612
613 /*!
614   Get a map of the properties of the object identified by theViewMgrId and theEntry.
615   \param theViewMgrId - Id of the viewer manager.
616   \param theEntry - Entry of the object.
617   \return a map of the properties of the object.
618 */
619 const PropMap& LightApp_Study::getObjectProperties( int theViewMgrId, const QString& theEntry )
620 {
621   ViewMgrMap::Iterator v_it = myViewMgrMap.find( theViewMgrId );
622   if ( v_it == myViewMgrMap.end() )
623     v_it = myViewMgrMap.insert( theViewMgrId, ObjMap() );
624   
625   ObjMap& anObjectMap = v_it.value();
626   ObjMap::Iterator o_it = anObjectMap.find( theEntry );
627   if ( o_it == anObjectMap.end() )
628     o_it = anObjectMap.insert( theEntry, PropMap() );
629   
630   return o_it.value();
631 }
632
633 /*!
634   Set a map of the properties of the object identified by theViewMgrId and theEntry.
635   \param theViewMgrId - Id of the viewer manager.
636   \param theEntry - Entry of the object.
637 */
638 void LightApp_Study::setObjectProperties( int theViewMgrId,
639                                           const QString& theEntry,
640                                           const PropMap& thePropMap )
641 {
642   myViewMgrMap[theViewMgrId][theEntry] = thePropMap;
643 }
644
645 /*!
646   Remove view manager with all objects.
647   \param theViewMgrId - Id of the viewer manager.
648 */
649 void LightApp_Study::removeObjectProperties( int theViewMgrId )
650
651   myViewMgrMap.remove( theViewMgrId );
652 }
653
654
655 /*!
656    Remove object's properties from all view managers.
657   \param theEntry - Entry of the object.
658 */
659 void LightApp_Study::removeObjectProperties( const QString& theEntry )
660 {
661   ViewMgrMap::Iterator v_it;
662   for ( v_it = myViewMgrMap.begin(); v_it != myViewMgrMap.end(); v_it++ )
663     v_it.value().remove( theEntry );
664 }
665
666 /*!
667   Get all objects and it's properties from view manager identified by theViewMgrId.
668   \param theEntry - Entry of the object.
669 */
670 const ObjMap& LightApp_Study::getObjectProperties( int theViewMgrId )
671 {
672   ViewMgrMap::Iterator v_it = myViewMgrMap.find( theViewMgrId );
673   if ( v_it == myViewMgrMap.end() )
674     v_it = myViewMgrMap.insert( theViewMgrId, ObjMap() );
675   return v_it.value();
676 }
677
678 /*!
679   Get global properties map
680 */
681 const ViewMgrMap& LightApp_Study::getObjectProperties() const
682 {
683   return myViewMgrMap;
684 }
685
686 /*!
687   Set 'visibility state' property of the object.
688   \param theEntry - Entry of the object.
689   \param theState - visibility status
690 */
691 void LightApp_Study::setVisibilityState( const QString& theEntry, Qtx::VisibilityState theState )
692  {
693   LightApp_Application* app = (LightApp_Application*)application();
694   if ( !app ) return;
695   SUIT_DataBrowser* db = app->objectBrowser();
696   if ( !db ) return;
697   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( db->model() );
698   if ( treeModel ) {
699     treeModel->setVisibilityState( theEntry, theState );
700     emit objVisibilityChanged( theEntry, theState );
701   }
702 }
703
704 /*!
705   Set 'visibility state' property for all object.
706   \param theEntry - Entry of the object.
707 */
708 void LightApp_Study::setVisibilityStateForAll( Qtx::VisibilityState theState )
709 {
710   LightApp_Application* app = (LightApp_Application*)application();
711   if ( !app ) return;
712   SUIT_DataBrowser* db = app->objectBrowser();
713   if ( !db ) return;
714   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( db->model() );
715   if ( treeModel )
716     treeModel->setVisibilityStateForAll( theState );
717 }
718
719 /*!
720   Get 'visibility state' property of the object.
721   \param theEntry - Entry of the object.
722   \return 'visibility state' property of the object.
723 */
724 Qtx::VisibilityState LightApp_Study::visibilityState( const QString& theEntry ) const
725 {
726   Qtx::VisibilityState state = Qtx::UnpresentableState;
727   LightApp_Application* app = (LightApp_Application*)application();
728   if ( app ) {
729     SUIT_DataBrowser* db = app->objectBrowser();
730     if ( db ) {
731       SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( db->model() );
732       if ( treeModel )
733         state = treeModel->visibilityState( theEntry );
734     }
735   }
736   return state;
737 }
738
739 /*!
740   Find a data object by the specified entry.
741   \param theEntry - Entry of the object.
742   \return data object.
743 */
744 LightApp_DataObject* LightApp_Study::findObjectByEntry( const QString& theEntry )
745 {
746   LightApp_DataObject* aCurObj;
747   for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
748     aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
749     if ( aCurObj && aCurObj->entry() == theEntry )
750       return aCurObj;
751   }
752   return NULL;
753 }