]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_OutputWindowAdapter.cxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/paravis.git] / src / PVGUI / PVGUI_OutputWindowAdapter.cxx
1 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "PVGUI_OutputWindowAdapter.h"
21
22 #include <vtkObjectFactory.h>
23
24 #include <LightApp_Application.h>
25 #include <LogWindow.h>
26 #include <SUIT_Session.h>
27 #include <SALOME_Event.h>
28
29 vtkStandardNewMacro(PVGUI_OutputWindowAdapter);
30 vtkCxxRevisionMacro(PVGUI_OutputWindowAdapter, "$Revision$");
31
32
33
34 /*!
35  * Put the message in the log window. 
36  */
37 class TEvent: public SALOME_Event {
38   LogWindow* myWindow;
39   QString    myMsg;
40   QColor     myColor;
41   int        myFlags;
42   public:
43   TEvent( LogWindow* theWindow,  const QString theMsg, const QColor theColor, const int flags) :
44     myWindow ( theWindow ),
45     myMsg ( theMsg ),
46     myColor ( theColor ),
47     myFlags (flags)
48   {}
49
50   virtual void Execute() {
51     if(myWindow)
52       myWindow->putMessage(myMsg, myColor, myFlags);
53   }
54 };
55
56
57 PVGUI_OutputWindowAdapter::PVGUI_OutputWindowAdapter() :
58   TextCount(0),
59   ErrorCount(0),
60   WarningCount(0),
61   GenericWarningCount(0)
62 {
63 }
64
65 PVGUI_OutputWindowAdapter::~PVGUI_OutputWindowAdapter()
66 {
67 }
68
69 const unsigned int PVGUI_OutputWindowAdapter::getTextCount()
70 {
71   return this->TextCount;
72 }
73
74 const unsigned int PVGUI_OutputWindowAdapter::getErrorCount()
75 {
76   return this->ErrorCount;
77 }
78
79 const unsigned int PVGUI_OutputWindowAdapter::getWarningCount()
80 {
81   return this->WarningCount;
82 }
83
84 const unsigned int PVGUI_OutputWindowAdapter::getGenericWarningCount()
85 {
86   return this->GenericWarningCount;
87 }
88
89 static LogWindow* getLogWindow()
90 {
91   LogWindow* wnd = 0;
92   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
93   if ( anApp )
94     wnd = anApp->logWindow();
95   return wnd;
96 }
97
98 void PVGUI_OutputWindowAdapter::DisplayText(const char* text)
99 {
100   ++this->TextCount;
101   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
102 }
103
104 void PVGUI_OutputWindowAdapter::DisplayErrorText(const char* text)
105 {
106   ++this->ErrorCount;
107   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
108 }
109
110 void PVGUI_OutputWindowAdapter::DisplayWarningText(const char* text)
111 {
112   ++this->WarningCount;
113   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
114 }
115
116 void PVGUI_OutputWindowAdapter::DisplayGenericWarningText(const char* text)
117 {
118   ++this->GenericWarningCount;
119   ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
120 }