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 #ifndef VisuGUI_ViewTools_HeaderFile
00029 #define VisuGUI_ViewTools_HeaderFile
00030
00031 #include "VisuGUI.h"
00032
00033 #include "VisuGUI_Tools.h"
00034
00035 #include "VISU_Prs3d_i.hh"
00036 #include "VISU_Table_i.hh"
00037 #include "VISU_PointMap3d_i.hh"
00038 #include "VISU_ViewManager_i.hh"
00039
00040 #include "VISU_Actor.h"
00041
00042 #include "SalomeApp_Module.h"
00043 #include "SalomeApp_Application.h"
00044
00045
00046
00047
00048 #include "SVTK_Functor.h"
00049 #include "SVTK_ViewModel.h"
00050 #include "SVTK_ViewWindow.h"
00051
00052 #include "SPlot2d_ViewModel.h"
00053
00054 #include "VTKViewer_Algorithm.h"
00055
00056 #include "SUIT_Session.h"
00057 #include "SUIT_Desktop.h"
00058 #include "SUIT_MessageBox.h"
00059 #include "SUIT_ViewManager.h"
00060 #include "SUIT_ViewWindow.h"
00061
00062 #include "SALOME_ListIO.hxx"
00063 #include "SALOME_ListIteratorOfListIO.hxx"
00064
00065 #include <vtkActorCollection.h>
00066 #include <vtkRenderer.h>
00067
00068
00069
00070 namespace VISU
00071 {
00077 template<class TViewer>
00078 inline
00079 typename TViewer::TViewWindow*
00080 GetViewWindow(VisuGUI* theModule)
00081 {
00082 typedef typename TViewer::TViewWindow TViewWindow;
00083 if (SalomeApp_Application* anApp = theModule->getApp()) {
00084 if (TViewWindow* aView = dynamic_cast<TViewWindow*>(anApp->desktop()->activeWindow()))
00085 return aView;
00086 }
00087 SUIT_ViewManager* aViewManager =
00088 theModule->getViewManager(TViewer::Type(), true);
00089 if (aViewManager) {
00090 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
00091 if (TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)) {
00092 aViewWindow->raise();
00093 aViewWindow->setFocus();
00094 return aView;
00095 }
00096 }
00097 }
00098 return NULL;
00099 }
00100
00105 template<class TViewWindow>
00106 inline
00107 TViewWindow*
00108 GetActiveViewWindow(const SalomeApp_Module* theModule = NULL)
00109 {
00110 SalomeApp_Application* anApp = NULL;
00111 if (theModule)
00112 anApp = theModule->getApp();
00113 else
00114 anApp = dynamic_cast<SalomeApp_Application*>
00115 (SUIT_Session::session()->activeApplication());
00116
00117 if (anApp)
00118 if (SUIT_ViewManager* aViewManager = anApp->activeViewManager())
00119 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView())
00120 return dynamic_cast<TViewWindow*>(aViewWindow);
00121
00122 return NULL;
00123 }
00124
00125
00126
00127 VISU_Actor*
00128 PublishInView(VisuGUI* theModule,
00129 Prs3d_i* thePrs,
00130 SVTK_ViewWindow* theViewWindow,
00131 const bool theIsHighlight = false);
00132
00133
00134
00135 VISU_Actor*
00136 UpdateViewer(VisuGUI* theModule,
00137 VISU::Prs3d_i* thePrs,
00138 bool theDispOnly = false,
00139 const bool theIsHighlight = false);
00140
00141
00142
00143 template<class TViewer>
00144 inline
00145 void
00146 OnEraseAll(VisuGUI* theModule)
00147 {
00148 typedef typename TViewer::TViewWindow TViewWindow;
00149 if (TViewWindow* aViewWindow = GetActiveViewWindow<TViewWindow>(theModule)) {
00150 aViewWindow->unHighlightAll();
00151 if (vtkRenderer *aRen = aViewWindow->getRenderer()) {
00152 VTK::ActorCollectionCopy aCopy(aRen->GetActors());
00153 vtkActorCollection *aCollection = aCopy.GetActors();
00154 aCollection->InitTraversal();
00155 while (vtkActor *anAct = aCollection->GetNextActor()) {
00156 if (anAct->GetVisibility() > 0)
00157 if (SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)) {
00158 anActor->VisibilityOff();
00159 }
00160 }
00161 aViewWindow->Repaint();
00162 }
00163 }
00164 }
00165
00166 template<>
00167 inline
00168 void
00169 OnEraseAll<SPlot2d_Viewer>(VisuGUI* theModule)
00170 {
00171 if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(theModule, false))
00172 aPlot2d->EraseAll();
00173 }
00174
00175
00176
00177 void
00178 ErasePrs3d(VisuGUI* theModule,
00179 VISU::Prs3d_i* thePrs,
00180 bool theDoRepaint = true);
00181
00182 void
00183 ErasePrs(VisuGUI* theModule,
00184 Base_i* theBase,
00185 bool theDoRepaintVW);
00186 }
00187
00188 #endif