2 //=============================================================================
3 // File : SALOMEGUI_Swig.cxx
4 // Created : ven oct 12 15:44:16 CEST 2001
5 // Author : Paul RASCLE, EDF
7 // Copyright : EDF 2001
9 // Modified : Mon Jul 29 21:38:07 2002
10 // Author : Nicolas REJNERI
11 // Copyright : OPEN CASCADE 2002
13 //=============================================================================
15 #include "QAD_Application.h"
16 #include "QAD_Desktop.h"
17 #include "QAD_Study.h"
18 #include "QAD_RightFrame.h"
19 #include "QAD_StudyFrame.h"
20 #include "SALOMEGUI_Swig.hxx"
21 #include "utilities.h"
23 #include "SALOME_Selection.h"
24 #include "SALOME_InteractiveObject.hxx"
25 #include "SALOME_ListIteratorOfListIO.hxx"
31 SALOMEGUI_Swig::SALOMEGUI_Swig(): _studyId(0)
33 // MESSAGE("Constructeur");
39 SALOMEGUI_Swig::~SALOMEGUI_Swig()
41 // MESSAGE("Destructeur");
45 Call when updated object browser.
47 void SALOMEGUI_Swig::updateObjBrowser( bool updateSelection )
49 QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
50 myActiveStudy->updateObjBrowser( updateSelection );
54 Returns active Study Id.
56 int SALOMEGUI_Swig::getActiveStudyId()
61 // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
62 // _name = myStudy->getTitle();
63 _studyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId();
70 Returns active Study Name.
72 const char *SALOMEGUI_Swig::getActiveStudyName()
74 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
75 _name = myStudy->getTitle();
78 // getActiveStudyId();
79 return _name.latin1();
83 Returns the name of component.
85 const char* SALOMEGUI_Swig::getComponentName( const char* ComponentUserName )
87 return QAD_Application::getDesktop()->getComponentName( ComponentUserName );
90 Returns the user name of component.
92 const char* SALOMEGUI_Swig::getComponentUserName( const char* ComponentName )
94 return QAD_Application::getDesktop()->getComponentUserName( ComponentName );
98 Returns the number of selected objects.
100 int SALOMEGUI_Swig::SelectedCount()
102 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
103 SALOME_Selection* Sel
104 = SALOME_Selection::Selection( myStudy->getSelection() );
105 return Sel->IObjectCount();
109 Returns the selected object at index i.
111 const char* SALOMEGUI_Swig::getSelected(int i)
113 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
114 SALOME_Selection* Sel
115 = SALOME_Selection::Selection( myStudy->getSelection() );
116 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
118 for(;It.More();It.Next())
120 Handle(SALOME_InteractiveObject) IObject = It.Value();
123 if ( IObject->hasEntry() )
124 return IObject->getEntry();
131 Add object with Entry into selection.
133 void SALOMEGUI_Swig::AddIObject(const char *Entry)
135 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
136 SALOME_Selection* Sel
137 = SALOME_Selection::Selection( myStudy->getSelection() );
139 if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) )
142 Handle(SALOME_InteractiveObject) IO =
143 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
144 Sel->AddIObject( IO );
149 Removes object with Entry into selection.
151 void SALOMEGUI_Swig::RemoveIObject(const char *Entry)
154 = QAD_Application::getDesktop()->getActiveStudy();
155 SALOME_Selection* Sel
156 = SALOME_Selection::Selection( myStudy->getSelection() );
158 if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) )
161 Handle(SALOME_InteractiveObject) IO =
162 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
163 Sel->RemoveIObject( IO );
168 Removes all objects into selection.
170 void SALOMEGUI_Swig::ClearIObjects()
172 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
173 SALOME_Selection* Sel
174 = SALOME_Selection::Selection( myStudy->getSelection() );
175 Sel->ClearIObjects();
181 void SALOMEGUI_Swig::Display(const char *Entry)
183 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
185 if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) )
188 Handle(SALOME_InteractiveObject) IO =
189 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
191 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Display(IO);
197 void SALOMEGUI_Swig::DisplayOnly(const char *Entry)
199 if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) )
202 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
204 Handle(SALOME_InteractiveObject) IO =
205 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
207 if ( !IO.IsNull() ) {
208 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayOnly(IO);
215 void SALOMEGUI_Swig::Erase(const char *Entry)
217 if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) )
220 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
222 Handle(SALOME_InteractiveObject) IO =
223 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
225 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Erase(IO);
231 void SALOMEGUI_Swig::DisplayAll()
233 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
234 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayAll();
240 void SALOMEGUI_Swig::EraseAll()
242 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
243 SALOME_Selection* Sel
244 = SALOME_Selection::Selection( myStudy->getSelection() );
246 Sel->ClearIObjects();
247 myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->EraseAll();
253 bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry)
255 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
256 return myStudy->isInViewer( Entry, myStudy->getActiveStudyFrame()->entry() );
259 vtkRenderer *SALOMEGUI_Swig::getRenderer(int viewId)
261 QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
262 int nbStudyFrames = myStudy->getStudyFramesCount();
263 vtkRenderer *myRenderer = NULL;
264 if (viewId == -1) // find the first frame with VTK viewer & get renderer
267 for(i=0; i<nbStudyFrames; i++)
269 if ( myStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK )
271 myRenderer = myStudy->getStudyFrame(i)->getRightFrame()->getViewFrame()->getRenderer();
276 else // get the VTK renderer of a given frame
279 if ((viewId >=0) && (viewId <nbStudyFrames))
280 myRenderer = myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer();
282 if (myRenderer == NULL) INFOS("No VTK Renderer available !");