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: SalomeApp_Module.cxx
20 // Created: 10/25/2004 11:39:56 AM
21 // Author: Sergey LITONIN
22 // Copyright (C) CEA 2004
24 #include "SalomeApp_Module.h"
25 #include "SalomeApp_DataModel.h"
26 #include "SalomeApp_Application.h"
27 #include "SalomeApp_Study.h"
29 #include "LightApp_Selection.h"
30 #include "LightApp_Operation.h"
31 #include "LightApp_Preferences.h"
32 //#include "LightApp_Displayer.h"
34 #include "CAM_DataModel.h"
36 #include "OB_Browser.h"
38 #include <SALOME_ListIO.hxx>
39 #include <SALOME_ListIteratorOfListIO.hxx>
40 #include <SALOME_InteractiveObject.hxx>
41 //#include <SALOME_Actor.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_ViewModel.h>
46 #include <SVTK_ViewWindow.h>
47 //#include <SVTK_ViewModel.h>
48 //#include <SVTK_MainWindow.h>
49 //#include <SVTK_RenderWindowInteractor.h>
54 //#include <vtkActorCollection.h>
55 //#include <vtkRenderer.h>
58 SalomeApp_Module::SalomeApp_Module( const QString& name )
59 : LightApp_Module( name )
64 SalomeApp_Module::~SalomeApp_Module()
68 /*!Gets application.*/
69 SalomeApp_Application* SalomeApp_Module::getApp() const
71 return (SalomeApp_Application*)application();
74 /*!Create new instance of data model and return it.*/
75 CAM_DataModel* SalomeApp_Module::createDataModel()
77 return new SalomeApp_DataModel(this);
80 /*!Create and return instance of LightApp_Selection.*/
81 LightApp_Selection* SalomeApp_Module::createSelection() const
83 return LightApp_Module::createSelection();
87 Converts objects-containers to list of objects, those are contained
88 Other objects must be added without conversion
89 \param source - source list of objects
90 \param dest - list of converted objects
92 void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const
94 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
101 SALOME_ListIteratorOfListIO anIt( source );
102 for( ; anIt.More(); anIt.Next() )
104 Handle( SALOME_InteractiveObject ) obj = anIt.Value();
105 if( obj->hasEntry() )
107 _PTR(SObject) SO = study->studyDS()->FindObjectID( obj->getEntry() );
108 if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
109 { //component is selected
110 _PTR(SComponent) SC( SO->GetFatherComponent() );
111 _PTR(ChildIterator) anIter ( study->studyDS()->NewChildIterator( SC ) );
112 anIter->InitEx( true );
113 while( anIter->More() )
115 _PTR(SObject) valSO ( anIter->Value() );
117 if( !valSO->ReferencedObject( refSO ) )
119 QString id = valSO->GetID().c_str(),
120 comp = SC->ComponentDataType().c_str(),
121 val = valSO->GetName().c_str();
123 Handle( SALOME_InteractiveObject ) new_obj =
124 new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
125 dest.Append( new_obj );
137 * \brief Virtual public
139 * This method is called just before the study document is saved, so the module has a possibility
140 * to store visual parameters in AttributeParameter attribue(s)
142 void SalomeApp_Module::storeVisualParameters(int savePoint)
147 * \brief Virtual public
149 * This method is called after the study document is opened, so the module has a possibility to restore
152 void SalomeApp_Module::restoreVisualParameters(int savePoint)