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