Salome HOME
Merge from V6_main 11/02/2013
[modules/paravis.git] / src / PVGUI / PVGUI_OutputWindowAdapter.cxx
index 2fb78e18af08291a75b5ff49b6f4b979afedc5cf..8c5c5734edd06534c2eae7e8ef68ee750ff0f63f 100644 (file)
@@ -1,3 +1,21 @@
+// Copyright (C) 2010-2012  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "PVGUI_OutputWindowAdapter.h"
 
 #include <LightApp_Application.h>
 #include <LogWindow.h>
 #include <SUIT_Session.h>
+#include <SALOME_Event.h>
 
 vtkStandardNewMacro(PVGUI_OutputWindowAdapter);
 vtkCxxRevisionMacro(PVGUI_OutputWindowAdapter, "$Revision$");
 
+
+
+/*!
+ * Put the message in the log window. 
+ */
+class TEvent: public SALOME_Event {
+  LogWindow* myWindow;
+  QString    myMsg;
+  QColor     myColor;
+  int        myFlags;
+  public:
+  TEvent( LogWindow* theWindow,  const QString theMsg, const QColor theColor, const int flags) :
+    myWindow ( theWindow ),
+    myMsg ( theMsg ),
+    myColor ( theColor ),
+    myFlags (flags)
+  {}
+
+  virtual void Execute() {
+    if(myWindow)
+      myWindow->putMessage(myMsg, myColor, myFlags);
+  }
+};
+
+
 PVGUI_OutputWindowAdapter::PVGUI_OutputWindowAdapter() :
   TextCount(0),
   ErrorCount(0),
@@ -54,31 +98,23 @@ static LogWindow* getLogWindow()
 void PVGUI_OutputWindowAdapter::DisplayText(const char* text)
 {
   ++this->TextCount;
-  LogWindow* wnd = getLogWindow();
-  if ( wnd )
-    wnd->putMessage( text, Qt::darkGreen, LogWindow::DisplayNormal );
+  ProcessVoidEvent( new TEvent( getLogWindow(), 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 );
+  ProcessVoidEvent( new TEvent( getLogWindow(), 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 );
+  ProcessVoidEvent( new TEvent( getLogWindow(), 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 );
+  ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
 }