]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Redirecting diagnostic VTK output to SALOME log window
authorsan <san@opencascade.com>
Thu, 4 Dec 2008 15:27:25 +0000 (15:27 +0000)
committersan <san@opencascade.com>
Thu, 4 Dec 2008 15:27:25 +0000 (15:27 +0000)
src/PVGUI/Makefile.am
src/PVGUI/PVGUI_OutputWindowAdapter.cxx [new file with mode: 0644]
src/PVGUI/PVGUI_OutputWindowAdapter.h [new file with mode: 0644]
src/PVGUI/PVGUI_ProcessModuleHelper.cxx
src/PVGUI/PVGUI_ProcessModuleHelper.h

index 5bc31639055ae8152a5ae89da98fb9813edefae6..aab4b1e1eaf931f5b829c2afc284156d09b501b5 100644 (file)
@@ -42,7 +42,9 @@ dist_libPARAVIS_la_SOURCES =  \
        PVGUI_ViewModel.h \
        PVGUI_ViewModel.cxx \
        PVGUI_ViewWindow.h \
-       PVGUI_ViewWindow.cxx
+       PVGUI_ViewWindow.cxx \
+       PVGUI_OutputWindowAdapter.h \
+       PVGUI_OutputWindowAdapter.cxx
 
 # MOC pre-processing
 MOC_FILES = \
diff --git a/src/PVGUI/PVGUI_OutputWindowAdapter.cxx b/src/PVGUI/PVGUI_OutputWindowAdapter.cxx
new file mode 100644 (file)
index 0000000..2fb78e1
--- /dev/null
@@ -0,0 +1,84 @@
+
+#include "PVGUI_OutputWindowAdapter.h"
+
+#include <vtkObjectFactory.h>
+
+#include <LightApp_Application.h>
+#include <LogWindow.h>
+#include <SUIT_Session.h>
+
+vtkStandardNewMacro(PVGUI_OutputWindowAdapter);
+vtkCxxRevisionMacro(PVGUI_OutputWindowAdapter, "$Revision$");
+
+PVGUI_OutputWindowAdapter::PVGUI_OutputWindowAdapter() :
+  TextCount(0),
+  ErrorCount(0),
+  WarningCount(0),
+  GenericWarningCount(0)
+{
+}
+
+PVGUI_OutputWindowAdapter::~PVGUI_OutputWindowAdapter()
+{
+}
+
+const unsigned int PVGUI_OutputWindowAdapter::getTextCount()
+{
+  return this->TextCount;
+}
+
+const unsigned int PVGUI_OutputWindowAdapter::getErrorCount()
+{
+  return this->ErrorCount;
+}
+
+const unsigned int PVGUI_OutputWindowAdapter::getWarningCount()
+{
+  return this->WarningCount;
+}
+
+const unsigned int PVGUI_OutputWindowAdapter::getGenericWarningCount()
+{
+  return this->GenericWarningCount;
+}
+
+static LogWindow* getLogWindow()
+{
+  LogWindow* wnd = 0;
+  LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
+  if ( anApp )
+    wnd = anApp->logWindow();
+  return wnd;
+}
+
+void PVGUI_OutputWindowAdapter::DisplayText(const char* text)
+{
+  ++this->TextCount;
+  LogWindow* wnd = getLogWindow();
+  if ( wnd )
+    wnd->putMessage( text, Qt::darkGreen, LogWindow::DisplayNormal );
+}
+
+void PVGUI_OutputWindowAdapter::DisplayErrorText(const char* text)
+{
+  ++this->ErrorCount;
+  LogWindow* wnd = getLogWindow();
+  if ( wnd )
+    wnd->putMessage( text, Qt::darkRed, LogWindow::DisplayNormal );
+}
+
+void PVGUI_OutputWindowAdapter::DisplayWarningText(const char* text)
+{
+  ++this->WarningCount;
+  LogWindow* wnd = getLogWindow();
+  if ( wnd )
+    wnd->putMessage( text, Qt::black, LogWindow::DisplayNormal );
+}
+
+void PVGUI_OutputWindowAdapter::DisplayGenericWarningText(const char* text)
+{
+  ++this->GenericWarningCount;
+  LogWindow* wnd = getLogWindow();
+  if ( wnd )
+    wnd->putMessage( text, Qt::black, LogWindow::DisplayNormal );
+}
diff --git a/src/PVGUI/PVGUI_OutputWindowAdapter.h b/src/PVGUI/PVGUI_OutputWindowAdapter.h
new file mode 100644 (file)
index 0000000..cb79671
--- /dev/null
@@ -0,0 +1,48 @@
+
+
+#ifndef _PVGUI_OutputWindowAdapter_h
+#define _PVGUI_OutputWindowAdapter_h
+
+#include <vtkOutputWindow.h>
+
+/*!
+vtkOutputWindow implementation that puts VTK output messages to SALOME log window.
+
+To use, create an instance of PVGUI_OutputWindowAdapter and pass it to the
+vtkOutputWindow::setInstance() static method.
+
+This class is based on pqOutputWindow ParaView class.
+*/
+class PVGUI_OutputWindowAdapter : public vtkOutputWindow
+{
+public:
+  static PVGUI_OutputWindowAdapter *New();
+  vtkTypeRevisionMacro(PVGUI_OutputWindowAdapter, vtkOutputWindow);
+
+  //! Returns the number of text messages received
+  const unsigned int getTextCount();
+  //! Returns the number of error messages received
+  const unsigned int getErrorCount();
+  //! Returns the number of warning messages received
+  const unsigned int getWarningCount();
+  //! Returns the number of generic warning messages received
+  const unsigned int getGenericWarningCount();
+
+private:
+  PVGUI_OutputWindowAdapter();
+  PVGUI_OutputWindowAdapter(const PVGUI_OutputWindowAdapter&);
+  PVGUI_OutputWindowAdapter& operator=(const PVGUI_OutputWindowAdapter&);
+  ~PVGUI_OutputWindowAdapter();
+
+  unsigned int TextCount;
+  unsigned int ErrorCount;
+  unsigned int WarningCount;
+  unsigned int GenericWarningCount;
+
+  virtual void DisplayText(const char*);
+  virtual void DisplayErrorText(const char*);
+  virtual void DisplayWarningText(const char*);
+  virtual void DisplayGenericWarningText(const char*);
+};
+
+#endif // !_PVGUI_OutputWindowAdapter_h
index cf03dc254b8369a189585686917d0b43d7ab9598..213bdab6318da6bbe296eb062971a9e6d6f211a1 100644 (file)
@@ -5,16 +5,32 @@
 
 
 #include "PVGUI_ProcessModuleHelper.h"
+#include "PVGUI_OutputWindowAdapter.h"
 
-//#include <pqApplicationCore.h>
 #include <vtkObjectFactory.h>
-//#include <vtkPVConfig.h>
+#include <vtkOutputWindow.h>
+#include <vtkSmartPointer.h>
 
 vtkStandardNewMacro(PVGUI_ProcessModuleHelper);
 vtkCxxRevisionMacro(PVGUI_ProcessModuleHelper, "$Revision$");
 
+class PVGUI_ProcessModuleHelper::pqImplementation
+{
+public:
+  pqImplementation() :
+    OutputWindowAdapter(vtkSmartPointer<PVGUI_OutputWindowAdapter>::New())
+  {}
+
+  ~pqImplementation()
+  {}
+
+  //! Displays VTK debug output in SALOME log window
+  vtkSmartPointer<PVGUI_OutputWindowAdapter> OutputWindowAdapter;
+};
+
 //-----------------------------------------------------------------------------
 PVGUI_ProcessModuleHelper::PVGUI_ProcessModuleHelper()
+  : Implementation(new pqImplementation())
 {
 }
 
@@ -62,18 +78,8 @@ void PVGUI_ProcessModuleHelper::hideWindow()
 int PVGUI_ProcessModuleHelper::InitializeApplication(int argc, char** argv)
 {
   if ( pqProcessModuleGUIHelper::InitializeApplication( argc, argv ) ){
-    // TODO: Redirect VTK debug output to SALOME GUI message console ...
-    /*this->Implementation->OutputWindow = new pqOutputWindow(0);
-    this->Implementation->OutputWindow->setAttribute(Qt::WA_QuitOnClose, false);
-    this->Implementation->OutputWindow->connect(this->Implementation->OutputWindowAdapter,
-                                                SIGNAL(displayText(const QString&)), SLOT(onDisplayText(const QString&)));
-    this->Implementation->OutputWindow->connect(this->Implementation->OutputWindowAdapter,
-                                                SIGNAL(displayErrorText(const QString&)), SLOT(onDisplayErrorText(const QString&)));
-    this->Implementation->OutputWindow->connect(this->Implementation->OutputWindowAdapter,
-                                                SIGNAL(displayWarningText(const QString&)), SLOT(onDisplayWarningText(const QString&)));
-    this->Implementation->OutputWindow->connect(this->Implementation->OutputWindowAdapter,
-                                                SIGNAL(displayGenericWarningText(const QString&)), SLOT(onDisplayGenericWarningText(const QString&)));
-    vtkOutputWindow::SetInstance(Implementation->OutputWindowAdapter);*/
+    // Redirect VTK debug output to SALOME GUI message console 
+    vtkOutputWindow::SetInstance(Implementation->OutputWindowAdapter);
   }
 
   return 1;
index 0206e41143c9b54ab009db34dd15a2046f5649fd..5550d096ada71fc23685148b7754a916095f50ea 100644 (file)
@@ -44,7 +44,6 @@ public:
   vtkTypeRevisionMacro(PVGUI_ProcessModuleHelper, pqProcessModuleGUIHelper);
   void PrintSelf(ostream& os, vtkIndent indent);
 
-
   //! Compares the contents of the window with the given reference image, returns true iff they "match" within some tolerance
   virtual  bool compareView(const QString& ReferenceImage, double Threshold, ostream& Output, const QString& TempDirectory);
 
@@ -78,9 +77,15 @@ protected:
   //! Called by vtkProcessModule,  but we cannot exit here.
   virtual void ExitApplication();
 
+  //! Returns the number of errors registered in the OutputWindow
+  //virtual int ErrorCount();
+
 private:
   PVGUI_ProcessModuleHelper(const PVGUI_ProcessModuleHelper&); // Not implemented.
   void operator=(const PVGUI_ProcessModuleHelper&); // Not implemented.
+
+  class pqImplementation;
+  pqImplementation* const Implementation;
 };
 
 #endif