Salome HOME
fc3801103696ac564e81363f818b2919bd3f37d8
[modules/gui.git] / src / PVViewer / PVViewer_LogWindowAdapter.cxx
1 // Copyright (C) 2010-2015  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, or (at your option) any later version.
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 "PVViewer_LogWindowAdapter.h"
21
22 #include <vtkObjectFactory.h>
23
24 #include <LogWindow.h>
25 #include <LogWindow.h>
26 #include <SUIT_Session.h>
27 #include <SALOME_Event.h>
28
29 vtkStandardNewMacro(PVViewer_LogWindowAdapter);
30
31
32
33 /*!
34  * Put the message in the log window. 
35  */
36 class TEvent: public SALOME_Event {
37   LogWindow* myWindow;
38   QString    myMsg;
39   QColor     myColor;
40   int        myFlags;
41   public:
42   TEvent( LogWindow* theWindow,  const QString theMsg, const QColor theColor, const int flags) :
43     myWindow ( theWindow ),
44     myMsg ( theMsg ),
45     myColor ( theColor ),
46     myFlags (flags)
47   {}
48
49   virtual void Execute() {
50     if(myWindow)
51       myWindow->putMessage(myMsg, myColor, myFlags);
52   }
53 };
54
55
56 PVViewer_LogWindowAdapter::PVViewer_LogWindowAdapter() :
57   TextCount(0),
58   ErrorCount(0),
59   WarningCount(0),
60   GenericWarningCount(0),
61   logWindow(0)
62 {
63 }
64
65 PVViewer_LogWindowAdapter::~PVViewer_LogWindowAdapter()
66 {
67 }
68
69 const unsigned int PVViewer_LogWindowAdapter::getTextCount()
70 {
71   return this->TextCount;
72 }
73
74 const unsigned int PVViewer_LogWindowAdapter::getErrorCount()
75 {
76   return this->ErrorCount;
77 }
78
79 const unsigned int PVViewer_LogWindowAdapter::getWarningCount()
80 {
81   return this->WarningCount;
82 }
83
84 const unsigned int PVViewer_LogWindowAdapter::getGenericWarningCount()
85 {
86   return this->GenericWarningCount;
87 }
88
89 //LogWindow* PVViewer_LogWindowAdapter::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 PVViewer_LogWindowAdapter::DisplayText(const char* text)
99 {
100   ++this->TextCount;
101   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
102 }
103
104 void PVViewer_LogWindowAdapter::DisplayErrorText(const char* text)
105 {
106   ++this->ErrorCount;
107   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
108 }
109
110 void PVViewer_LogWindowAdapter::DisplayWarningText(const char* text)
111 {
112   ++this->WarningCount;
113   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
114 }
115
116 void PVViewer_LogWindowAdapter::DisplayGenericWarningText(const char* text)
117 {
118   ++this->GenericWarningCount;
119   ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
120 }