Back to index

salome-paravis  6.5.0
PVGUI_OutputWindowAdapter.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "PVGUI_OutputWindowAdapter.h"
00021 
00022 #include <vtkObjectFactory.h>
00023 
00024 #include <LightApp_Application.h>
00025 #include <LogWindow.h>
00026 #include <SUIT_Session.h>
00027 #include <SALOME_Event.h>
00028 
00029 vtkStandardNewMacro(PVGUI_OutputWindowAdapter);
00030 vtkCxxRevisionMacro(PVGUI_OutputWindowAdapter, "$Revision: 1.1.12.1.12.1 $");
00031 
00032 
00033 
00037 class TEvent: public SALOME_Event {
00038   LogWindow* myWindow;
00039   QString    myMsg;
00040   QColor     myColor;
00041   int        myFlags;
00042   public:
00043   TEvent( LogWindow* theWindow,  const QString theMsg, const QColor theColor, const int flags) :
00044     myWindow ( theWindow ),
00045     myMsg ( theMsg ),
00046     myColor ( theColor ),
00047     myFlags (flags)
00048   {}
00049 
00050   virtual void Execute() {
00051     if(myWindow)
00052       myWindow->putMessage(myMsg, myColor, myFlags);
00053   }
00054 };
00055 
00056 
00057 PVGUI_OutputWindowAdapter::PVGUI_OutputWindowAdapter() :
00058   TextCount(0),
00059   ErrorCount(0),
00060   WarningCount(0),
00061   GenericWarningCount(0)
00062 {
00063 }
00064 
00065 PVGUI_OutputWindowAdapter::~PVGUI_OutputWindowAdapter()
00066 {
00067 }
00068 
00069 const unsigned int PVGUI_OutputWindowAdapter::getTextCount()
00070 {
00071   return this->TextCount;
00072 }
00073 
00074 const unsigned int PVGUI_OutputWindowAdapter::getErrorCount()
00075 {
00076   return this->ErrorCount;
00077 }
00078 
00079 const unsigned int PVGUI_OutputWindowAdapter::getWarningCount()
00080 {
00081   return this->WarningCount;
00082 }
00083 
00084 const unsigned int PVGUI_OutputWindowAdapter::getGenericWarningCount()
00085 {
00086   return this->GenericWarningCount;
00087 }
00088 
00089 static LogWindow* getLogWindow()
00090 {
00091   LogWindow* wnd = 0;
00092   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() );
00093   if ( anApp )
00094     wnd = anApp->logWindow();
00095   return wnd;
00096 }
00097 
00098 void PVGUI_OutputWindowAdapter::DisplayText(const char* text)
00099 {
00100   ++this->TextCount;
00101   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
00102 }
00103 
00104 void PVGUI_OutputWindowAdapter::DisplayErrorText(const char* text)
00105 {
00106   ++this->ErrorCount;
00107   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
00108 }
00109 
00110 void PVGUI_OutputWindowAdapter::DisplayWarningText(const char* text)
00111 {
00112   ++this->WarningCount;
00113   ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
00114 }
00115 
00116 void PVGUI_OutputWindowAdapter::DisplayGenericWarningText(const char* text)
00117 {
00118   ++this->GenericWarningCount;
00119   ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
00120 }