Salome HOME
PARAVIS HTML docs
[modules/paravis.git] / src / PVGUI / PVGUI_ProcessModuleHelper.cxx
1 // File:        PVGUI_ProcessModuleHelper.cxx
2 // Created:     Tue Nov 11 13:03:19 2008
3 // Author:      Sergey ANIKIN
4 //              <san@portrex.nnov.opencascade.com>
5
6
7 #include "PVGUI_Module.h"
8 #include "PVGUI_ProcessModuleHelper.h"
9 #include "PVGUI_OutputWindowAdapter.h"
10
11 #include <CAM_Application.h>
12 #include <CAM_Module.h>
13 #include <SUIT_Session.h>
14
15 #include <vtkObjectFactory.h>
16 #include <vtkOutputWindow.h>
17 #include <vtkSmartPointer.h>
18
19 vtkStandardNewMacro(PVGUI_ProcessModuleHelper);
20 vtkCxxRevisionMacro(PVGUI_ProcessModuleHelper, "$Revision$");
21
22 class PVGUI_ProcessModuleHelper::pqImplementation
23 {
24 public:
25   pqImplementation() :
26     OutputWindowAdapter(vtkSmartPointer<PVGUI_OutputWindowAdapter>::New())
27   {}
28
29   ~pqImplementation()
30   {}
31
32   //! Displays VTK debug output in SALOME log window
33   vtkSmartPointer<PVGUI_OutputWindowAdapter> OutputWindowAdapter;
34 };
35
36 //-----------------------------------------------------------------------------
37 PVGUI_ProcessModuleHelper::PVGUI_ProcessModuleHelper()
38   : Implementation(new pqImplementation())
39 {
40 }
41
42 //-----------------------------------------------------------------------------
43 PVGUI_ProcessModuleHelper::~PVGUI_ProcessModuleHelper()
44 {
45 }
46
47 //-----------------------------------------------------------------------------
48 void PVGUI_ProcessModuleHelper::PrintSelf(ostream& os, vtkIndent indent)
49 {
50   this->Superclass::PrintSelf(os, indent);
51 }
52
53 //-----------------------------------------------------------------------------
54 /*!
55   \brief Used by ParaView testing capabilities, not usable in SALOME.
56  */
57 bool PVGUI_ProcessModuleHelper::compareView(const QString& ReferenceImage,
58   double Threshold, ostream& Output, const QString& TempDirectory)
59 {
60   if ( CAM_Application* anApp = dynamic_cast<CAM_Application*>( SUIT_Session::session()->activeApplication() ) )
61     if ( PVGUI_Module* aPVM = dynamic_cast<PVGUI_Module*>( anApp->module("ParaVis") ) )
62       return aPVM->compareView( ReferenceImage, Threshold, Output, TempDirectory );
63   
64   return false;
65 }
66
67 //-----------------------------------------------------------------------------
68 /*! 
69   \brief Reimplemented to suppress default ParaView client behavior. Does nothing.
70 */
71 void PVGUI_ProcessModuleHelper::showOutputWindow()
72 {
73   // Do nothing here
74 }
75
76 //-----------------------------------------------------------------------------
77 /*! 
78   \brief Reimplemented to suppress default ParaView client behavior. Does nothing.
79 */
80 void PVGUI_ProcessModuleHelper::showWindow()
81 {
82 }
83
84 //-----------------------------------------------------------------------------
85 /*! 
86   \brief Reimplemented to suppress default ParaView client behavior. Does nothing.
87 */
88 void PVGUI_ProcessModuleHelper::hideWindow()
89 {
90 }
91
92 //-----------------------------------------------------------------------------
93 /*! 
94   \brief Calls the base implementation and redirects ParaView output to PVGUI_OutputWindowAdapter instance.
95   \sa PVGUI_OutputWindowAdapter
96 */
97 int PVGUI_ProcessModuleHelper::InitializeApplication(int argc, char** argv)
98 {
99   if ( pqProcessModuleGUIHelper::InitializeApplication( argc, argv ) ){
100     // Redirect VTK debug output to SALOME GUI message console 
101     vtkOutputWindow::SetInstance(Implementation->OutputWindowAdapter);
102   }
103
104   return 1;
105 }
106
107 //-----------------------------------------------------------------------------
108 /*! 
109   \brief Reimplemented to suppress default ParaView client behavior and not to run Qt event loop. Does nothing.
110 */
111 int PVGUI_ProcessModuleHelper::appExec()
112 {
113   return 0;
114 }
115
116 /*! 
117   \brief Reimplemented to suppress default ParaView client behavior and not to exit after the client initalization. Does nothing.
118 */
119 //-----------------------------------------------------------------------------
120 int PVGUI_ProcessModuleHelper::postAppExec()
121 {
122   return 0;
123 }
124
125 /*! 
126   \brief Reimplemented to suppress default ParaView client behavior. Does nothing.
127 */
128 //-----------------------------------------------------------------------------
129 QWidget* PVGUI_ProcessModuleHelper::CreateMainWindow()
130 {
131   return 0;
132 }
133
134 //-----------------------------------------------------------------------------
135 /*! 
136   \brief Reimplemented to suppress default ParaView client behavior. Does nothing.
137 */
138 void PVGUI_ProcessModuleHelper::ExitApplication()
139 {
140   // Cannot exit here, so do nothing
141 }