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