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 = \
--- /dev/null
+
+#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 );
+}
--- /dev/null
+
+
+#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
#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())
{
}
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;
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);
//! 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