1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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
19 // File: LightApp_DataModel.cxx
20 // Created: 10/25/2004 10:36:06 AM
21 // Author: Sergey LITONIN
22 // Copyright (C) CEA 2004
24 #include "LightApp_DataModel.h"
25 #include "LightApp_Study.h"
26 #include "LightApp_RootObject.h"
27 #include "LightApp_DataObject.h"
28 #include "LightApp_Module.h"
29 #include "LightApp_Application.h"
31 #include <OB_Browser.h>
33 #include <SUIT_Application.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_DataObject.h>
41 LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
42 : CAM_DataModel( theModule )
49 LightApp_DataModel::~LightApp_DataModel()
56 bool LightApp_DataModel::open( const QString&, CAM_Study* study, QStringList )
58 emit opened(); //TODO: is it really needed? to be removed maybe...
65 bool LightApp_DataModel::save( QStringList& )
74 bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& )
83 bool LightApp_DataModel::close()
90 Build whole data model tree
92 void LightApp_DataModel::build()
97 Updates data model presentation in some widgets (for example, in object browser
99 void LightApp_DataModel::updateWidgets()
101 LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
103 app->objectBrowser()->updateTree( 0, false );
107 Default behaviour of data model update for light modules
109 void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* )
111 LightApp_ModuleObject* modelRoot = dynamic_cast<LightApp_ModuleObject*>( root() );
113 QMap<SUIT_DataObject*,int> aMap;
116 ch = modelRoot->children();
117 for ( DataObjectListIterator it( ch ); it.current(); ++it )
118 it.current()->setParent( 0 );
123 modelRoot = dynamic_cast<LightApp_ModuleObject*>( root() );
126 DataObjectList new_ch = modelRoot->children();
127 for ( DataObjectListIterator it1( new_ch ); it1.current(); ++it1 )
128 aMap.insert( it1.current(), 0 );
133 for( DataObjectListIterator it( ch ); it.current(); ++it )
134 if( !aMap.contains( it.current() ) )
139 \return corresponding module
141 LightApp_Module* LightApp_DataModel::getModule() const
143 return dynamic_cast<LightApp_Module*>( module() );
147 \return corresponding study
149 LightApp_Study* LightApp_DataModel::getStudy() const
151 LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root()->root() );
154 return aRoot->study();
158 default implementation, always returns false so as not to mask study's isModified()
160 bool LightApp_DataModel::isModified() const
166 default implementation, always returns true so as not to mask study's isSaved()
168 bool LightApp_DataModel::isSaved() const