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