Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "SMESHGUI_Displayer.h"
00030 #include "SMESHGUI_VTKUtils.h"
00031 #include "SMESHGUI_Utils.h"
00032
00033
00034 #include <SalomeApp_Study.h>
00035 #include <SalomeApp_Application.h>
00036 #include <SUIT_ViewManager.h>
00037 #include <SVTK_ViewModel.h>
00038 #include <SVTK_ViewWindow.h>
00039
00040
00041
00042 #include <SALOMEconfig.h>
00043 #include CORBA_SERVER_HEADER(SMESH_Group)
00044 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00045
00046
00047 SMESHGUI_Displayer::SMESHGUI_Displayer( SalomeApp_Application* app )
00048 : LightApp_Displayer(),
00049 myApp( app )
00050 {
00051 }
00052
00053 SMESHGUI_Displayer::~SMESHGUI_Displayer()
00054 {
00055 }
00056
00057 SALOME_Prs* SMESHGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
00058 {
00059 SALOME_Prs* prs = 0;
00060
00061 SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView();
00062
00063 if ( aViewFrame )
00064 {
00065 SVTK_Viewer* vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
00066 if( vtk_viewer )
00067 {
00068 SUIT_ViewWindow* wnd = vtk_viewer->getViewManager()->getActiveView();
00069 SMESH_Actor* anActor = SMESH::FindActorByEntry( wnd, entry.toLatin1().data() );
00070 if( !anActor )
00071 anActor = SMESH::CreateActor( study()->studyDS(), entry.toLatin1().data(), true );
00072 if( anActor )
00073 {
00074 SMESH::DisplayActor( wnd, anActor );
00075 prs = LightApp_Displayer::buildPresentation( entry.toLatin1().data(), aViewFrame );
00076 }
00077 if( prs )
00078 UpdatePrs( prs );
00079 else if( anActor )
00080 SMESH::RemoveActor( vtk_viewer->getViewManager()->getActiveView(), anActor );
00081 }
00082 }
00083
00084 return prs;
00085 }
00086
00087 SalomeApp_Study* SMESHGUI_Displayer::study() const
00088 {
00089 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
00090 }
00091
00092 bool SMESHGUI_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const {
00093 bool res = false;
00094 if(viewer_type != SVTK_Viewer::Type())
00095 return res;
00096
00097 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
00098 if( !study )
00099 return res;
00100
00101
00102 _PTR(SObject) obj = study->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
00103 CORBA::Object_var anObj = SMESH::SObjectToObject( obj );
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 if( !CORBA::is_nil( anObj ) ) {
00120 if(!SMESH::SMESH_Mesh::_narrow( anObj )->_is_nil() ||
00121 !SMESH::SMESH_subMesh::_narrow( anObj )->_is_nil() ||
00122 !SMESH::SMESH_GroupBase::_narrow( anObj )->_is_nil())
00123 res = true;
00124 }
00125 return res;
00126 }