]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Module.cxx
Salome HOME
b22992cf4daadf35ef64e9f05c12719cf3875d05
[modules/gui.git] / src / SalomeApp / SalomeApp_Module.cxx
1 // File:      SalomeApp_Module.cxx
2 // Created:   10/25/2004 11:39:56 AM
3 // Author:    Sergey LITONIN
4 // Copyright (C) CEA 2004
5
6 #include "SalomeApp_Module.h"
7 #include "SalomeApp_DataModel.h"
8 #include "SalomeApp_Application.h"
9 #include "SalomeApp_Study.h"
10
11 #include "LightApp_Selection.h"
12 #include "LightApp_Operation.h"
13 #include "LightApp_Preferences.h"
14 //#include "LightApp_Displayer.h"
15
16 #include "CAM_DataModel.h"
17
18 #include "OB_Browser.h"
19
20 #include <SALOME_ListIO.hxx>
21 #include <SALOME_ListIteratorOfListIO.hxx>
22 #include <SALOME_InteractiveObject.hxx>
23 //#include <SALOME_Actor.h>
24
25 //#include "SALOMEDS_IParameters.hxx"
26
27 #include <SUIT_Session.h>
28 #include <SUIT_ViewModel.h>
29
30 #include <SVTK_ViewWindow.h>
31 //#include <SVTK_ViewModel.h>
32 //#include <SVTK_MainWindow.h>
33 //#include <SVTK_RenderWindowInteractor.h>
34
35 #include <qstring.h>
36 #include <qmap.h>
37
38 //#include <vtkActorCollection.h>
39 //#include <vtkRenderer.h>
40
41 /*!Constructor.*/
42 SalomeApp_Module::SalomeApp_Module( const QString& name )
43 : LightApp_Module( name )
44 {
45 }
46
47 /*!Destructor.*/
48 SalomeApp_Module::~SalomeApp_Module()
49 {
50 }
51
52 /*!Gets application.*/
53 SalomeApp_Application* SalomeApp_Module::getApp() const
54 {
55   return (SalomeApp_Application*)application();
56 }
57
58 /*!Create new instance of data model and return it.*/
59 CAM_DataModel* SalomeApp_Module::createDataModel()
60 {
61   return new SalomeApp_DataModel(this);
62 }
63
64 /*!Create and return instance of LightApp_Selection.*/
65 LightApp_Selection* SalomeApp_Module::createSelection() const
66 {
67   return LightApp_Module::createSelection();
68 }
69
70 void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const
71 {
72   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
73   if( !study )
74   {
75     dest = source;
76     return;
77   }
78
79   SALOME_ListIteratorOfListIO anIt( source );
80   for( ; anIt.More(); anIt.Next() )
81   {
82     Handle( SALOME_InteractiveObject ) obj = anIt.Value();
83     if( obj->hasEntry() )
84     {
85       _PTR(SObject) SO = study->studyDS()->FindObjectID( obj->getEntry() );
86       if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
87       { //component is selected
88         _PTR(SComponent) SC( SO->GetFatherComponent() );
89         _PTR(ChildIterator) anIter ( study->studyDS()->NewChildIterator( SC ) );
90         anIter->InitEx( true );
91         while( anIter->More() )
92         {
93           _PTR(SObject) valSO ( anIter->Value() );
94           _PTR(SObject) refSO;
95           if( !valSO->ReferencedObject( refSO ) )
96           {
97             QString id = valSO->GetID().c_str(),
98                     comp = SC->ComponentDataType().c_str(),
99                     val = valSO->GetName().c_str();
100
101             Handle( SALOME_InteractiveObject ) new_obj =
102               new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
103             dest.Append( new_obj );
104           }
105           anIter->Next();
106         }
107         continue;
108       }
109     }
110     dest.Append( obj );
111   }
112 }
113
114 /*!
115  * \brief Virtual public
116  *
117  * This method is called just before the study document is saved, so the module has a possibility
118  * to store visual parameters in AttributeParameter attribue(s)
119  */
120 void SalomeApp_Module::storeVisualParameters(int savePoint)
121 {
122 }
123
124 /*!
125  * \brief Virtual public
126  *
127  * This method is called after the study document is opened, so the module has a possibility to restore
128  * visual parameters
129  */
130 void SalomeApp_Module::restoreVisualParameters(int savePoint)
131 {
132 }
133