]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0022856: EDF 9971 PARAVIS: Error message not displayed in Paravis
authorvsr <vsr@opencascade.com>
Fri, 19 Oct 2018 07:45:09 +0000 (10:45 +0300)
committervsr <vsr@opencascade.com>
Fri, 19 Oct 2018 11:40:10 +0000 (14:40 +0300)
- Refactor paraview output messages handling in PVViewer

26 files changed:
src/LightApp/LightApp_Application.cxx
src/LogWindow/LogWindow.cxx
src/LogWindow/LogWindow.h
src/PVViewer/CMakeLists.txt
src/PVViewer/PVViewer.h
src/PVViewer/PVViewer_Behaviors.h
src/PVViewer/PVViewer_Core.cxx
src/PVViewer/PVViewer_Core.h
src/PVViewer/PVViewer_GUIElements.cxx
src/PVViewer/PVViewer_GUIElements.h
src/PVViewer/PVViewer_InitSingleton.cxx
src/PVViewer/PVViewer_InitSingleton.h
src/PVViewer/PVViewer_LogWindowAdapter.cxx [deleted file]
src/PVViewer/PVViewer_LogWindowAdapter.h [deleted file]
src/PVViewer/PVViewer_OutputWindow.cxx [new file with mode: 0644]
src/PVViewer/PVViewer_OutputWindow.h [new file with mode: 0644]
src/PVViewer/PVViewer_ViewManager.cxx
src/PVViewer/PVViewer_ViewManager.h
src/PVViewer/PVViewer_ViewModel.cxx
src/PVViewer/PVViewer_ViewModel.h
src/PVViewer/PVViewer_ViewWindow.cxx
src/PVViewer/PVViewer_ViewWindow.h
src/Qtx/CMakeLists.txt
src/Qtx/QtxMsgHandler.cxx [new file with mode: 0644]
src/Qtx/QtxMsgHandler.h [new file with mode: 0644]
src/Session/SALOME_Session_Server.cxx

index ae03b893e602ddc15f590ac7437098e8a7163255..c240120a6ade672eb6b022bea21ab3845029c75a 100644 (file)
@@ -1654,7 +1654,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
       viewMgr->getActiveView()->setFocus();
       return 0;
     } else {
-      viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
+      viewMgr = new PVViewer_ViewManager( activeStudy(), desktop() );
     }
   }
 #endif
@@ -2186,6 +2186,7 @@ QWidget* LightApp_Application::createWindow( const int flag )
   else if ( flag == WT_LogWindow )
   {
     LogWindow* logWin = new LogWindow( desktop() );
+    logWin->handleQtMessages( true );
     logWin->setObjectName( "logWindow" );
     logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
     logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
index 84fbefd29fcfdd753fa0887cbdf43b53042f147d..25e2dc86b588c1943b295eadb0235a6761dd9a0e 100755 (executable)
@@ -31,6 +31,7 @@
 #include <QDate>
 #include <QFile>
 #include <QMenu>
+#include <QTextBlock>
 #include <QTextEdit>
 #include <QTextStream>
 #include <QTime>
 
 #define DEFAULT_SEPARATOR "***"
 
-/*!
-  \brief Convert rich text to plain text.
-  \internal
-  \param richText rich text string
-  \return converted plain text string
-*/
-static QString plainText( const QString& richText )
+namespace
 {
-  QString aText = richText;
-  int startTag = aText.indexOf( '<' );
-  while ( true )
+  /*!
+    \brief Convert rich text to plain text.
+    \internal
+    \param richText rich text string
+    \return converted plain text string
+  */
+  QString plainText( const QString& richText )
   {
-    if ( startTag < 0 )
-      break;
-
-    int finishTag = aText.indexOf( '>', startTag );
-    if ( finishTag < 0 )
-      break;
-
-    aText = aText.remove( startTag, finishTag - startTag + 1 );
-    startTag = aText.indexOf( '<' );
+    QString aText = richText;
+    int startTag = aText.indexOf( '<' );
+    while ( true )
+    {
+      if ( startTag < 0 )
+        break;
+      
+      int finishTag = aText.indexOf( '>', startTag );
+      if ( finishTag < 0 )
+        break;
+      
+      aText = aText.remove( startTag, finishTag - startTag + 1 );
+      startTag = aText.indexOf( '<' );
+    }
+    return aText;
   }
-  return aText;
 }
 
 /*!
@@ -88,8 +92,7 @@ static QString plainText( const QString& richText )
   \param parent parent widget
 */
 LogWindow::LogWindow( QWidget* parent )
-: QWidget( parent ),
-  SUIT_PopupClient()
+  : QWidget( parent ), SUIT_PopupClient(), QtxMsgHandlerCallback( false )
 {
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
 
@@ -100,13 +103,12 @@ LogWindow::LogWindow( QWidget* parent )
   myView = new QTextEdit( this );
   myView->setReadOnly( true );
   myView->viewport()->installEventFilter( this );
+  myView->setPlaceholderText( "Message Log" );
 
   QVBoxLayout* main = new QVBoxLayout( this );
   main->setMargin( 0 );
   main->addWidget( myView );
 
-  myBannerSize = 0;
-  myBanner = "<b>Message Log</b>\n********************";
   mySeparator = DEFAULT_SEPARATOR;
 
   clear();
@@ -124,12 +126,12 @@ LogWindow::~LogWindow()
 }
 
 /*!
-  \brief Get current banner (message log window header text).
+  \brief Get current banner (text shown when log window is empty).
   \return string representing the current banner
 */
 QString LogWindow::banner() const
 {
-  return myBanner;
+  return myView->placeholderText();
 }
 
 /*!
@@ -142,14 +144,12 @@ QString LogWindow::separator() const
 }
 
 /*!
-  \brief Set current banner (message log window header text).
+  \brief Set current banner (text shown when log window is empty).
   \param banner new banner
 */
 void LogWindow::setBanner( const QString& banner )
 {
-  myBanner = banner;
-
-  clear( false );
+  myView->setPlaceholderText( banner );
 }
 
 /*!
@@ -229,17 +229,35 @@ void LogWindow::putMessage( const QString& message, const QColor& color, const i
   if ( !dateTime.isEmpty() )
     msg = QString( "[%1] %2" ).arg( dateTime ).arg( msg );
 
-  myView->append( msg );
+  append( msg );
   myHistory.append( plainText( message ) );
 
   if ( flags & DisplaySeparator && !mySeparator.isEmpty() )
   {
-    myView->append( mySeparator );   // add separator
+    // add separator
+    append( mySeparator );
     myHistory.append( plainText( mySeparator ) );
   }
   myView->moveCursor( QTextCursor::End );
 }
 
+/*!
+  \brief Append text to the log window.
+  \param text Text being added.
+*/
+void LogWindow::append( const QString text )
+{
+  if ( !text.isEmpty() )
+  {
+    myView->append( text );
+    QTextBlock block = myView->document()->lastBlock();
+    QTextCursor cursor( block );
+    QTextBlockFormat format = cursor.blockFormat();
+    format.setBottomMargin( 10 );
+    cursor.setBlockFormat( format );
+  }
+}
+
 /*!
   \brief Clear message log.
   \param clearHistory if True, clear also the messages history
@@ -249,14 +267,6 @@ void LogWindow::clear( bool clearHistory )
   myView->clear();
   if ( clearHistory )
     myHistory.clear();
-
-  if ( !myBanner.isEmpty() )
-  {
-    myView->append( myBanner );
-    myBannerSize = myView->document()->blockCount();
-  }
-  else
-    myBannerSize = 0;
 }
 
 /*!
@@ -340,7 +350,7 @@ void LogWindow::contextMenuPopup( QMenu* popup )
 void LogWindow::updateActions()
 {
   myActions[CopyId]->setEnabled( myView->textCursor().hasSelection() );
-  myActions[ ClearId ]->setEnabled( myView->document()->blockCount() > myBannerSize );
+  myActions[ ClearId ]->setEnabled( !myView->document()->isEmpty() );
   myActions[SelectAllId]->setEnabled( !myView->document()->isEmpty() );
   myActions[ SaveToFileId ]->setEnabled( myHistory.count() > 0 );
 }
@@ -426,6 +436,49 @@ int LogWindow::menuActions() const
   return ret;
 }
 
+/*!
+  \brief Activate/deactivate Qt messages handling.
+  \param on If \c true, Qt messags are handled by log window.
+*/
+void LogWindow::handleQtMessages(bool on)
+{
+  if ( on )
+    activate();
+  else
+    deactivate();
+}
+
+/*!
+  \brief Handle Qt messages.
+  \param type Qt message type.
+  \param context Message context.
+  \param message Message text.
+*/
+void LogWindow::qtMessage( QtMsgType type, const QMessageLogContext&, const QString& message )
+{
+  QColor color;
+  switch ( type )
+  {
+  case QtInfoMsg:
+    color = QColor("#008000"); // dark green
+    break;
+  case QtCriticalMsg:
+    color = QColor("#ff0000"); // red
+    break;
+  case QtFatalMsg:
+    color = QColor("#800000"); // dark red
+    break;
+  case QtWarningMsg:
+    color = QColor("#ff9000"); // orange
+    break;
+  case QtDebugMsg:
+  default:
+    color = QColor("#000000"); // black
+    break;
+  }
+  putMessage( message, color, DisplayNormal);
+}
+
 /*!
   \fn virtual QString LogWindow::popupClientType() const;
   \brief Get popup client symbolic name, used in popup menu management system.
index a15937859c5baf55b553431140d29f919de55349..a150c1e78b601285dacb645e4ab605ddc9aa7963 100755 (executable)
@@ -37,7 +37,8 @@
 #  define LOGWINDOW_EXPORT
 #endif
 
-#include <SUIT_PopupClient.h>
+#include "QtxMsgHandler.h"
+#include "SUIT_PopupClient.h"
 
 #include <QWidget>
 #include <QMap>
@@ -50,7 +51,7 @@
 class QAction;
 class QTextEdit;
 
-class LOGWINDOW_EXPORT LogWindow : public QWidget, public SUIT_PopupClient
+class LOGWINDOW_EXPORT LogWindow : public QWidget, public SUIT_PopupClient, public QtxMsgHandlerCallback
 {
   Q_OBJECT
 
@@ -77,7 +78,7 @@ public:
   };
 
 public:
-  LogWindow( QWidget* theParent );
+  LogWindow( QWidget* );
   virtual ~LogWindow();
 
   virtual             QString popupClientType() const { return QString( "LogWindow" ); }
@@ -100,6 +101,8 @@ public:
   void                setMenuActions( const int );
   int                 menuActions() const;
 
+  void                handleQtMessages(bool);
+
 protected slots:
   void                onSaveToFile();
   void                onSelectAll();
@@ -107,8 +110,10 @@ protected slots:
   void                onCopy();
 
 private:
+  void                append( const QString text );
   void                createActions();
   void                updateActions();
+  void                qtMessage( QtMsgType, const QMessageLogContext&, const QString& );
 
 private:
   QTextEdit*          myView;           //!< internal view window
index 05910b4817670a6f541dfbf6e15f66b6eaa35626..0e3a19dd6b8b7ee5520b9f23c6392f8006e6b669 100644 (file)
@@ -25,13 +25,9 @@ INCLUDE(UseQtExt)
 # --- options ---
 
 INCLUDE_DIRECTORIES(
-  ${PROJECT_SOURCE_DIR}/src/SUIT
-  ${PROJECT_SOURCE_DIR}/src/STD
   ${PROJECT_SOURCE_DIR}/src/Qtx
-  ${PROJECT_SOURCE_DIR}/src/Event
-  ${PROJECT_SOURCE_DIR}/src/PyInterp
+  ${PROJECT_SOURCE_DIR}/src/SUIT
   ${PROJECT_SOURCE_DIR}/src/PVServerService
-  ${CMAKE_SOURCE_DIR}/src/LogWindow
   )
 
 ADD_DEFINITIONS(
@@ -42,9 +38,7 @@ ADD_DEFINITIONS(
 SET(_link_LIBRARIES 
   ${KERNEL_SALOMELocalTrace} 
   ${KERNEL_OpUtil}
-  PyInterp  
   suit 
-  Event 
   PVServerService
   pqApplicationComponents
   #vtkRenderingFreeTypeOpenGL
@@ -67,7 +61,7 @@ SET(_moc_HEADERS
 # header files / no moc processing
 SET(_other_HEADERS
   PVViewer.h
-  PVViewer_LogWindowAdapter.h
+  PVViewer_OutputWindow.h
   PVViewer_Core.h
 )
 # header files / to install
@@ -93,7 +87,7 @@ SET(_other_SOURCES
   PVViewer_ViewManager.cxx
   PVViewer_ViewModel.cxx
   PVViewer_ViewWindow.cxx
-  PVViewer_LogWindowAdapter.cxx
+  PVViewer_OutputWindow.cxx
   PVViewer_Behaviors.cxx
   PVViewer_GUIElements.cxx
   PVViewer_Core.cxx
index 4959685cef4e4d0dd61bb551f23bff72e071469a..8db5a578d013650ebfbfb7d01b3e89af625db671 100644 (file)
 #define PVVIEWER_H
 
 #ifdef WIN32
-#if defined PVViewer_EXPORTS
-#define PVVIEWER_EXPORT __declspec(dllexport)
+#  if defined PVVIEWER_EXPORTS || defined PVViewer_EXPORTS
+#    define PVVIEWER_EXPORT __declspec(dllexport)
+#  else
+#    define PVVIEWER_EXPORT __declspec(dllimport)
+#  endif
 #else
-#define PVVIEWER_EXPORT __declspec(dllimport)
-#endif
-#else
-#define PVVIEWER_EXPORT
+#   define PVVIEWER_EXPORT
 #endif
 
-#endif //PVVIEWER_H
+#endif // PVVIEWER_H
index 8eb1665fd6c2aafb5fe1e7745fc910a226ec5c24..9f7d71aa2009fab80c64bc178ac46f7dc91600b4 100644 (file)
@@ -19,8 +19,8 @@
 // Author: Adrien Bruneton (CEA)
 
 
-#ifndef PVGUIBEHAVIORS_H_
-#define PVGUIBEHAVIORS_H_
+#ifndef PVVIEWER_BEHAVIORS_H
+#define PVVIEWER_BEHAVIORS_H
 
 #include "PVViewer.h"
 
@@ -39,10 +39,10 @@ class PVVIEWER_EXPORT PVViewer_Behaviors: public QObject
   Q_OBJECT
 
 public:
-  PVViewer_Behaviors(QMainWindow * parent);
+  PVViewer_Behaviors(QMainWindow*);
 
-  void instanciateMinimalBehaviors(QMainWindow * desk);
-  void instanciateAllBehaviors(QMainWindow * desk);
+  void instanciateMinimalBehaviors(QMainWindow*);
+  void instanciateAllBehaviors(QMainWindow*);
 
   virtual ~PVViewer_Behaviors() {}
 
@@ -50,4 +50,4 @@ private:
   static int BehaviorLoadingLevel;
 };
 
-#endif /* PVGUIBEHAVIORS_H_ */
+#endif // PVVIEWER_BEHAVIORS_H
index 6e9e6920380ee8e58a4a5ff1789c2ad1566498a4..c249d8a6734830d561372780c1886a4e2e80519e 100644 (file)
@@ -20,7 +20,7 @@
 //
 
 #include "PVViewer_Core.h"
-#include "PVViewer_LogWindowAdapter.h"
+#include "PVViewer_OutputWindow.h"
 #include "PVViewer_GUIElements.h"
 #include "PVViewer_Behaviors.h"
 #include "PVViewer_Core.h"
@@ -58,7 +58,7 @@ pqPVApplicationCore * PVViewer_Core::GetPVApplication()
   \param fullSetup whether to instanciate all behaviors or just the minimal ones.
   \return \c true if ParaView has been initialized successfully, otherwise false
 */
-bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindow)
+bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop)
 {
   if ( ! MyCoreApp) {
       // Obtain command-line arguments
@@ -103,8 +103,7 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * aDesktop, LogWindow * logWindo
       }
 
       // Direct VTK log messages to our SALOME window - TODO: review this
-      PVViewer_LogWindowAdapter * w = PVViewer_LogWindowAdapter::New();
-      w->setLogWindow(logWindow);
+      PVViewer_OutputWindow * w = PVViewer_OutputWindow::New();
       vtkOutputWindow::SetInstance(w);
 
       new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation
index 28e0ba3e3cdbe065a0fc2f93ebe83e6dd91ffb27..7c66b015c002b2418ca4d521c610ba96df8b0514 100644 (file)
@@ -18,8 +18,8 @@
 //
 // Author : Adrien Bruneton (CEA)
 
-#ifndef SRC_PVVIEWER_PVVIEWER_CORE_H_
-#define SRC_PVVIEWER_PVVIEWER_CORE_H_
+#ifndef PVVIEWER_CORE_H
+#define PVVIEWER_CORE_H
 
 #include "PVViewer.h"
 
@@ -27,7 +27,6 @@
 
 class PVServer_ServiceWrapper;
 class PVViewer_Behaviors;
-class LogWindow;
 class QMainWindow;
 class pqPVApplicationCore;
 
@@ -38,14 +37,13 @@ class pqPVApplicationCore;
 class PVVIEWER_EXPORT PVViewer_Core
 {
 public:
-  static pqPVApplicationCore * GetPVApplication();
-
+  static pqPVApplicationCore* GetPVApplication();
 
   //! Initialize ParaView if not yet done (once per session)
-  static bool   ParaviewInitApp(QMainWindow* aDesktop, LogWindow * w);
-  static void   ParaviewInitBehaviors(bool fullSetup=false, QMainWindow* aDesktop=0);
-  static void   ParaviewLoadConfigurations(const QString & configPath, bool force=false);
-  static void   ParaviewCleanup();
+  static bool ParaviewInitApp(QMainWindow*);
+  static void ParaviewInitBehaviors(bool = false, QMainWindow* = 0);
+  static void ParaviewLoadConfigurations(const QString&, bool = false);
+  static void ParaviewCleanup();
 
 private:
   PVViewer_Core();
@@ -53,7 +51,7 @@ private:
 
   static pqPVApplicationCore* MyCoreApp;
   static bool ConfigLoaded;
-  static PVViewer_Behaviors * ParaviewBehaviors;
+  static PVViewer_Behaviors* ParaviewBehaviors;
 };
 
-#endif /* SRC_PVVIEWER_PVVIEWER_CORE_H_ */
+#endif // PVVIEWER_CORE_H
index 6026eb462b4c31646ab39c60bfedf543fc0fc7f1..79f25db34cff78ca153d4b1f55ea9abd060678b1 100644 (file)
@@ -61,8 +61,7 @@
 
 PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
 
-PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
-  myDesktop(desk),
+PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desktop) :
   propertiesPanel(0),
   pipelineBrowserWidget(0),
   pipelineModel(0),
@@ -70,7 +69,28 @@ PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
   filtersMenu(0),
   macrosMenu(0),
   catalystMenu(0),
-  myPVWidgetsFlag(false)
+  mainToolBar(0),
+  vcrToolbar(0),
+  timeToolbar(0),
+  colorToolbar(0),
+  reprToolbar(0),
+  cameraToolbar(0),
+  axesToolbar(0),
+  macrosToolbar(0),
+  commonToolbar(0),
+  dataToolbar(0),
+  myDesktop(desktop),
+  myPVWidgetsFlag(false),
+  mainAction(0),
+  vcrAction(0),
+  timeAction(0),
+  colorAction(0),
+  reprAction(0),
+  cameraAction(0),
+  axesAction(0),
+  macrosAction(0),
+  commonAction(0),
+  dataAction(0)
 {
 }
 
index 57c2e735e1f0df5553280ece6d082e9e5e915f1a..9d64636267ae80e1c0eada476e6a87cd0cddc633 100644 (file)
 //
 // Author: Adrien Bruneton (CEA)
 
-#ifndef PVVIEWERGUIELEMENTS_H_
-#define PVVIEWERGUIELEMENTS_H_
+#ifndef PVVIEWER_GUIELEMENTS_H
+#define PVVIEWER_GUIELEMENTS_H
 
 #include "PVViewer.h"
 
 #include <QObject>
 #include <QList>
 
-class pqPropertiesPanel;
-class pqPipelineBrowserWidget;
-class pqPipelineModel;
+class QAction;
 class QMainWindow;
 class QMenu;
 class QToolBar;
-class QAction;
 class pqAnimationTimeToolbar;
+class pqPipelineBrowserWidget;
+class pqPipelineModel;
+class pqPropertiesPanel;
 class pqVCRToolbar;
 
 /*!
@@ -45,10 +45,10 @@ class PVVIEWER_EXPORT PVViewer_GUIElements: public QObject
   Q_OBJECT
 
 public:
-  static PVViewer_GUIElements * GetInstance(QMainWindow * desk);
+  static PVViewer_GUIElements* GetInstance(QMainWindow*);
 
-  pqPropertiesPanel * getPropertiesPanel();
-  pqPipelineBrowserWidget * getPipelineBrowserWidget();
+  pqPropertiesPanel* getPropertiesPanel();
+  pqPipelineBrowserWidget* getPipelineBrowserWidget();
 
   QMenu* getFiltersMenu();
   QMenu* getSourcesMenu();
@@ -58,14 +58,14 @@ public:
   pqVCRToolbar* getVCRToolbar();
   pqAnimationTimeToolbar* getTimeToolbar();
 
-  void setToolBarVisible(bool show);
-  void setToolBarEnabled(bool enabled);
+  void setToolBarVisible(bool);
+  void setToolBarEnabled(bool);
   QList<QToolBar*> getToolbars();
 
-  void setVCRTimeToolBarVisible(bool show);
+  void setVCRTimeToolBarVisible(bool);
 
 private:
-  PVViewer_GUIElements(QMainWindow* desk);
+  PVViewer_GUIElements(QMainWindow*);
   virtual ~PVViewer_GUIElements() {}
 
   static PVViewer_GUIElements* theInstance;
@@ -98,7 +98,7 @@ private:
   QToolBar* dataToolbar;
   
   QMainWindow* myDesktop;
-  bool    myPVWidgetsFlag;
+  bool myPVWidgetsFlag;
 
 public:
   QAction* mainAction;
@@ -113,4 +113,4 @@ public:
   QAction* dataAction;
 };
 
-#endif /* PVVIEWERGUIELEMENTS_H_ */
+#endif // PVVIEWER_GUIELEMENTS_H
index 538e0d085ae981442dc88f8d1d6ed4bccd0efac5..e329b498e82ea4b003965e89b84d9159764dddb1 100644 (file)
 
 bool PVViewer_InitSingleton::IS_INIT=false;
 
-void PVViewer_InitSingleton::Init(QMainWindow *aDesktop, LogWindow *logWindow)
+void PVViewer_InitSingleton::Init(QMainWindow* desktop)
 {
   if(IS_INIT)
     return ;
-  PVViewer_Core::ParaviewInitApp(aDesktop,logWindow);
+  PVViewer_Core::ParaviewInitApp(desktop);
   // Finish ParaView set up: behaviors, connection and configurations.
   const QString configPath(PVViewer_ViewManager::GetPVConfigPath());
-  PVViewer_Core::ParaviewInitBehaviors(true,aDesktop);
-  PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop);
+  PVViewer_Core::ParaviewInitBehaviors(true, desktop);
+  PVViewer_ViewManager::ConnectToExternalPVServer(desktop);
   PVViewer_Core::ParaviewLoadConfigurations(configPath);
   IS_INIT=true;
 }
index 93eba85b59f47210d50463420826048ae379cd97..af8d884c0affc14dd4142c465e432736d8eb9899 100644 (file)
 //
 // Author : Anthony GEAY (EDF R&D)
 
-#ifndef __PVVIEWER_INITSINGLETON_H__
-#define __PVVIEWER_INITSINGLETON_H__
+#ifndef PVVIEWER_INITSINGLETON_H
+#define PVVIEWER_INITSINGLETON_H
 
 #include "PVViewer.h"
 
 class QMainWindow;
-class LogWindow;
 
 /**
  * This class deals with initialization of SALOME_Session to make it a PV based application.
@@ -34,9 +33,9 @@ class LogWindow;
 class PVVIEWER_EXPORT PVViewer_InitSingleton
 {
 public:
-  static void Init(QMainWindow *aDesktop, LogWindow *logWindow);
+  static void Init(QMainWindow*);
 private:
   static bool IS_INIT;
 };
 
-#endif /* SRC_PVVIEWER_PVVIEWER_CORE_H_ */
+#endif // PVVIEWER_INITSINGLETON_H
diff --git a/src/PVViewer/PVViewer_LogWindowAdapter.cxx b/src/PVViewer/PVViewer_LogWindowAdapter.cxx
deleted file mode 100644 (file)
index 78fb6af..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (C) 2014-2016  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// 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, or (at your option) any later version.
-//
-// 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 "PVViewer_LogWindowAdapter.h"
-
-#include <vtkObjectFactory.h>
-
-#include <LogWindow.h>
-#include <LogWindow.h>
-#include <SUIT_Session.h>
-#include <SALOME_Event.h>
-
-vtkStandardNewMacro(PVViewer_LogWindowAdapter);
-
-/*!
- * 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);
-  }
-};
-
-
-PVViewer_LogWindowAdapter::PVViewer_LogWindowAdapter() :
-  TextCount(0),
-  ErrorCount(0),
-  WarningCount(0),
-  GenericWarningCount(0),
-  logWindow(0)
-{
-}
-
-PVViewer_LogWindowAdapter::~PVViewer_LogWindowAdapter()
-{
-}
-
-const unsigned int PVViewer_LogWindowAdapter::getTextCount()
-{
-  return this->TextCount;
-}
-
-const unsigned int PVViewer_LogWindowAdapter::getErrorCount()
-{
-  return this->ErrorCount;
-}
-
-const unsigned int PVViewer_LogWindowAdapter::getWarningCount()
-{
-  return this->WarningCount;
-}
-
-const unsigned int PVViewer_LogWindowAdapter::getGenericWarningCount()
-{
-  return this->GenericWarningCount;
-}
-
-void PVViewer_LogWindowAdapter::DisplayText(const char* text)
-{
-  ++this->TextCount;
-  ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal ));
-}
-
-void PVViewer_LogWindowAdapter::DisplayErrorText(const char* text)
-{
-  ++this->ErrorCount;
-  ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal ));
-}
-
-void PVViewer_LogWindowAdapter::DisplayWarningText(const char* text)
-{
-  ++this->WarningCount;
-  ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal ));
-}
-
-void PVViewer_LogWindowAdapter::DisplayGenericWarningText(const char* text)
-{
-  ++this->GenericWarningCount;
-  ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal ));
-}
diff --git a/src/PVViewer/PVViewer_LogWindowAdapter.h b/src/PVViewer/PVViewer_LogWindowAdapter.h
deleted file mode 100644 (file)
index 9be72e2..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2014-2016  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// 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, or (at your option) any later version.
-//
-// 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
-//
-
-#ifndef _PVViewer_LogWindowAdapter_h
-#define _PVViewer_LogWindowAdapter_h
-
-#include "PVViewer.h"
-
-#include <vtkOutputWindow.h>
-
-class LogWindow;
-
-/*!
-vtkOutputWindow implementation that puts VTK output messages to SALOME log window.
-
-To use, create an instance of PVViewer_LogWindowAdapter and pass it to the
-vtkOutputWindow::setInstance() static method.
-
-This class is based on pqOutputWindow ParaView class.
-*/
-class PVVIEWER_EXPORT PVViewer_LogWindowAdapter : public vtkOutputWindow
-{
-public:
-  static PVViewer_LogWindowAdapter *New();
-  vtkTypeMacro(PVViewer_LogWindowAdapter, 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();
-
-  void setLogWindow( LogWindow* w) { logWindow = w; }
-  LogWindow* getLogWindow() { return logWindow; }
-
-private:
-  PVViewer_LogWindowAdapter();
-  PVViewer_LogWindowAdapter(const PVViewer_LogWindowAdapter&);
-  PVViewer_LogWindowAdapter& operator=(const PVViewer_LogWindowAdapter&);
-  ~PVViewer_LogWindowAdapter();
-
-  unsigned int TextCount;
-  unsigned int ErrorCount;
-  unsigned int WarningCount;
-  unsigned int GenericWarningCount;
-  LogWindow * logWindow;
-
-  virtual void DisplayText(const char*);
-  virtual void DisplayErrorText(const char*);
-  virtual void DisplayWarningText(const char*);
-  virtual void DisplayGenericWarningText(const char*);
-};
-
-#endif // !_PVViewer_LogWindowAdapter_h
diff --git a/src/PVViewer/PVViewer_OutputWindow.cxx b/src/PVViewer/PVViewer_OutputWindow.cxx
new file mode 100644 (file)
index 0000000..ebef841
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2014-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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 "PVViewer_OutputWindow.h"
+
+#include <vtkObjectFactory.h>
+
+vtkStandardNewMacro(PVViewer_OutputWindow);
+
+PVViewer_OutputWindow::PVViewer_OutputWindow()
+{
+}
+
+PVViewer_OutputWindow::~PVViewer_OutputWindow()
+{
+}
+
+const unsigned int PVViewer_OutputWindow::getTextCount()
+{
+  return count(MESSAGE_TYPE_TEXT);
+}
+
+const unsigned int PVViewer_OutputWindow::getErrorCount()
+{
+  return count(MESSAGE_TYPE_ERROR);
+}
+
+const unsigned int PVViewer_OutputWindow::getWarningCount()
+{
+  return count(MESSAGE_TYPE_WARNING);
+}
+
+const unsigned int PVViewer_OutputWindow::getGenericWarningCount()
+{
+  return count(MESSAGE_TYPE_GENERIC_WARNING);
+}
+
+const unsigned int PVViewer_OutputWindow::getDebugCount()
+{
+  return count(MESSAGE_TYPE_DEBUG);
+}
+
+void PVViewer_OutputWindow::DisplayText(const char* text)
+{
+  MessageTypes type = GetCurrentMessageType();
+  myCounter[type] = count(type) + 1;
+  switch (type)
+  {
+  case MESSAGE_TYPE_ERROR:
+    qCritical(text);
+    break;
+  case MESSAGE_TYPE_WARNING:
+  case MESSAGE_TYPE_GENERIC_WARNING:
+    qWarning(text);
+    break;
+  case MESSAGE_TYPE_DEBUG:
+    qDebug(text);
+    break;
+  case MESSAGE_TYPE_TEXT:
+  default:
+    qInfo(text);
+    break;
+  }
+}
+
+int PVViewer_OutputWindow::count(const MessageTypes& type)
+{
+  return myCounter.value(type, 0);
+}
diff --git a/src/PVViewer/PVViewer_OutputWindow.h b/src/PVViewer/PVViewer_OutputWindow.h
new file mode 100644 (file)
index 0000000..fa27829
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (C) 2014-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef PVVIEWER_OUTPUTWINDOW_H
+#define PVVIEWER_OUTPUTWINDOW_H
+
+#include "PVViewer.h"
+
+#include <QMap>
+#include <vtkOutputWindow.h>
+
+/**
+  vtkOutputWindow implementation that redirects VTK output messages
+  to dedicated sinals which are then handled by SALOME log window.
+  
+  To use, create an instance of PVViewer_OutputWindow and pass it to the
+  vtkOutputWindow::setInstance() static method.
+  
+  This class is based on pqOutputWindow ParaView class.
+ */
+class PVVIEWER_EXPORT PVViewer_OutputWindow : public vtkOutputWindow
+{
+public:
+  static PVViewer_OutputWindow* New();
+  vtkTypeMacro(PVViewer_OutputWindow, 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();
+  //! Returns the number of debug messages received
+  const unsigned int getDebugCount();
+
+private:
+  PVViewer_OutputWindow();
+  PVViewer_OutputWindow(const PVViewer_OutputWindow&);
+  PVViewer_OutputWindow& operator=(const PVViewer_OutputWindow&);
+  ~PVViewer_OutputWindow();
+
+  QMap<MessageTypes, int> myCounter;
+
+  void DisplayText(const char*);
+  int count(const MessageTypes&);
+};
+
+#endif // PVVIEWER_OUTPUTWINDOW_H
index 42a7947994b759a822a56cd4d918a45f633b0276..29eddef95e8f2d6d91664b360247a13fcbb18d47 100644 (file)
 
 #include <utilities.h>
 
-#include <LogWindow.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_Study.h>
-#include <SUIT_Session.h>
-#include <SUIT_MessageBox.h>
-#include <SUIT_ResourceMgr.h>
+#include "SUIT_Desktop.h"
+#include "SUIT_Study.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
 
 #include <pqServer.h>
 #include <pqServerConnectReaction.h>
 /*!
   Constructor
 */
-PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* desk, LogWindow * logWindow )
-: SUIT_ViewManager( study, desk, new PVViewer_Viewer() ),
-  desktop(desk)
+PVViewer_ViewManager::PVViewer_ViewManager(SUIT_Study* study, SUIT_Desktop* desktop)
+: SUIT_ViewManager( study, desktop, new PVViewer_Viewer() )
 {
   MESSAGE("PVViewer - view manager created ...")
   setTitle( tr( "PARAVIEW_VIEW_TITLE" ) );
 
   // Initialize minimal paraview stuff (if not already done)
-  PVViewer_InitSingleton::Init(desk, logWindow);
+  PVViewer_InitSingleton::Init(desktop);
 
-  connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+  connect( desktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
            this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
 }
 
-
 PVServer_ServiceWrapper * PVViewer_ViewManager::GetService()
 {
   return PVServer_ServiceWrapper::GetInstance();
@@ -68,7 +65,7 @@ QString PVViewer_ViewManager::GetPVConfigPath()
   return resMgr->stringValue("resources", "PVViewer", QString());
 }
 
-bool PVViewer_ViewManager::ConnectToExternalPVServer(QMainWindow* aDesktop)
+bool PVViewer_ViewManager::ConnectToExternalPVServer(QMainWindow* desktop)
 {
   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
   bool noConnect = aResourceMgr->booleanValue( "PARAVIS", "no_ext_pv_server", false );
@@ -77,23 +74,23 @@ bool PVViewer_ViewManager::ConnectToExternalPVServer(QMainWindow* aDesktop)
 
   pqServer* server = pqActiveObjects::instance().activeServer();
   if (server && server->isRemote())
-    {
-      // Already connected to an external server, do nothing
-      MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect.");
-      return false;
-    }
+  {
+    // Already connected to an external server, do nothing
+    MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect.");
+    return false;
+  }
 
   if (GetService()->GetGUIConnected())
-    {
-      // Should never be there as the above should already tell us that we are connected.
-      std::stringstream msg2;
-      msg2 << "Internal error while connecting to the pvserver.";
-      msg2 << "ParaView doesn't see a connection, but PARAVIS engine tells us there is already one!" << std::endl;
-      qWarning(msg2.str().c_str());  // will go to the ParaView console (see ParavisMessageOutput below)
-      SUIT_MessageBox::warning( aDesktop,
-                                      QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
-      return false;
-    }
+  {
+    // Should never be there as the above should already tell us that we are connected.
+    std::stringstream msg2;
+    msg2 << "Internal error while connecting to the pvserver.";
+    msg2 << "ParaView doesn't see a connection, but PARAVIS engine tells us there is already one!" << std::endl;
+    qWarning(msg2.str().c_str());  // will go to the ParaView console (see ParavisMessageOutput below)
+    SUIT_MessageBox::warning( desktop,
+                             QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
+    return false;
+  }
 
   std::stringstream msg;
 
@@ -101,43 +98,44 @@ bool PVViewer_ViewManager::ConnectToExternalPVServer(QMainWindow* aDesktop)
   QString serverUrlEnv = getenv("PARAVIEW_PVSERVER_URL");
   std::string serverUrl;
   if (!serverUrlEnv.isEmpty())
+  {
     serverUrl = serverUrlEnv.toStdString();
+  }
   else
-    {
-      // Get the URL from the engine (possibly starting the pvserver)
-      serverUrl = GetService()->FindOrStartPVServer(0);  // take the first free port
-    }
-
+  {
+    // Get the URL from the engine (possibly starting the pvserver)
+    serverUrl = GetService()->FindOrStartPVServer(0);  // take the first free port
+  }
+  
   msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ...";
   MESSAGE(msg.str());
 
   if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str())))
-    {
-      std::stringstream msg2;
-      msg2 << "Error while connecting to the requested pvserver '" << serverUrl;
-      msg2 << "'. Might use default built-in connection instead!" << std::endl;
-      qWarning(msg2.str().c_str());  // will go to the ParaView console (see ParavisMessageOutput below)
-      SUIT_MessageBox::warning( aDesktop,
-                                QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
-      return false;
-    }
+  {
+    std::stringstream msg2;
+    msg2 << "Error while connecting to the requested pvserver '" << serverUrl;
+    msg2 << "'. Might use default built-in connection instead!" << std::endl;
+    qWarning(msg2.str().c_str());  // will go to the ParaView console (see ParavisMessageOutput below)
+    SUIT_MessageBox::warning( desktop,
+                             QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
+    return false;
+  }
   else
-    {
-      MESSAGE("connectToExternalPVServer(): Connected!");
-      GetService()->SetGUIConnected(true);
-    }
+  {
+    MESSAGE("connectToExternalPVServer(): Connected!");
+    GetService()->SetGUIConnected(true);
+  }
   return true;
 }
 
-
 /*!Enable toolbars if view \a view is ParaView viewer and disable otherwise.
 */
 void PVViewer_ViewManager::onWindowActivated(SUIT_ViewWindow* view)
 {
   if (view)
-    {
+  {
     PVViewer_ViewWindow* pvWindow = dynamic_cast<PVViewer_ViewWindow*>(view);
-    PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance(desktop);
+    PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance( myDesktop );
     guiElements->setToolBarEnabled(pvWindow!=0);
-    }
+  }
 }
index 2e7404b6eda0d5c3d029551f8e01d5c44d0abdbf..5157a2a577343101f482b882c8cd63281079c38b 100644 (file)
 //
 // Author: Adrien Bruneton (CEA)
 
-#ifndef PVViewer_VIEWMANAGER_H
-#define PVViewer_VIEWMANAGER_H
+#ifndef PVVIEWER_VIEWMANAGER_H
+#define PVVIEWER_VIEWMANAGER_H
 
 #include "PVViewer.h"
 
-#include <SUIT_ViewManager.h>
+#include "SUIT_ViewManager.h"
 
 class SUIT_Desktop;
 class SUIT_Study;
 class SUIT_ViewWindow;
-class LogWindow;
 class PVServer_ServiceWrapper;
 class QMainWindow;
 
@@ -37,24 +36,21 @@ class PVVIEWER_EXPORT PVViewer_ViewManager : public SUIT_ViewManager
   Q_OBJECT
 
 public:
-  PVViewer_ViewManager( SUIT_Study*, SUIT_Desktop*, LogWindow *);
+  PVViewer_ViewManager(SUIT_Study*, SUIT_Desktop*);
   ~PVViewer_ViewManager() {}
 
   //! Get the CORBA engine wrapper.
-  static PVServer_ServiceWrapper * GetService();
+  static PVServer_ServiceWrapper* GetService();
 
   //! Get PVViewer configuration path as stored by SALOME's resource manager:
   static QString GetPVConfigPath();
 
   //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
   //! already up.
-  static bool   ConnectToExternalPVServer(QMainWindow* aDesktop);
+  static bool ConnectToExternalPVServer(QMainWindow*);
 
 protected slots:
   void onWindowActivated(SUIT_ViewWindow*);
-
-private:
-  SUIT_Desktop * desktop;
 };
 
-#endif
+#endif // PVVIEWER_VIEWMANAGER_H
index 4198557a2fcbbbfcc1e0d8f76d5723626ccdbaba..aaacbfebd3148d6a471f9e2d7f4a275efe6cbd75 100644 (file)
@@ -22,7 +22,7 @@
 #include "PVViewer_ViewWindow.h"
 
 #include <utilities.h>
-#include <SUIT_Desktop.h>
+#include "SUIT_Desktop.h"
 
 //----------------------------------------
 PVViewer_Viewer::PVViewer_Viewer()
@@ -35,9 +35,8 @@ PVViewer_Viewer::PVViewer_Viewer()
   Create new instance of view window on desktop \a theDesktop.
   \retval SUIT_ViewWindow* - created view window pointer.
 */
-SUIT_ViewWindow* PVViewer_Viewer::createView(SUIT_Desktop* theDesktop)
+SUIT_ViewWindow* PVViewer_Viewer::createView(SUIT_Desktop* desktop)
 {
-  PVViewer_ViewWindow* aPVView = new PVViewer_ViewWindow(theDesktop, this);
-  return aPVView;
+  return new PVViewer_ViewWindow(desktop, this);
 }
 
index e252c92c5641176b58fc89d8b1f1178b76b91e75..8533f79b64fd9854e8e862e314a0cbd578fd32ff 100644 (file)
 //
 // Author: Adrien Bruneton (CEA)
 
-#if !defined(_PVViewer_VIEWMODEL_H)
-#define _PVViewer_VIEWMODEL_H
+#ifndef PVVIEWER_VIEWMODEL_H
+#define PVVIEWER_VIEWMODEL_H
 
 #include "PVViewer.h"
 
-#include <SUIT_ViewModel.h>
+#include "SUIT_ViewModel.h"
 
 class SUIT_ViewWindow;
 class SUIT_Desktop;
@@ -37,10 +37,9 @@ public:
   PVViewer_Viewer();
   virtual ~PVViewer_Viewer() {}
 
-  virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+  virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
   virtual QString getType() const { return Type(); }
   static QString Type() { return "ParaView"; }
 };
 
-#endif // !defined(_PVViewer_VIEWMODEL_H)
-
+#endif // PVVIEWER_VIEWMODEL_H
index f2c7f9221c048da06bdcdf2fc62057efec6d88ec..68694b81e7972e5f308f5cb372f59aaa02cb6d38 100644 (file)
 #include "PVViewer_GUIElements.h"
 #include "PVViewer_ViewManager.h"
 
-#include <SUIT_ViewManager.h>
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_Application.h>
+#include "SUIT_ViewManager.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Application.h"
 
 #include <pqTabbedMultiViewWidget.h>
 #include <pqApplicationCore.h>
@@ -117,8 +117,3 @@ pqTabbedMultiViewWidget* PVViewer_ViewWindow::getMultiViewManager() const
 {
   return myPVMgr;
 }
-
-//void PVViewer_ViewWindow::onEmulateApply()
-//{
-//  emit this->applyRequest();
-//}
index 4f8633f9eb6f448dc5fc31f0cf581f5dc27dde5a..e75c720f7b6ef004890e982d8c38ab9168a59fd4 100644 (file)
 //
 // Author : Adrien Bruneton (CEA)
 
-
-#ifndef PVViewer_VIEWWINDOW_H
-#define PVViewer_VIEWWINDOW_H
+#ifndef PVVIEWER_VIEWWINDOW_H
+#define PVVIEWER_VIEWWINDOW_H
 
 #include "PVViewer.h"
 
-#include <SUIT_ViewWindow.h>
+#include "SUIT_ViewWindow.h"
 #include <QMap>
 
 class SUIT_Desktop;
@@ -39,17 +38,17 @@ public:
   PVViewer_ViewWindow( SUIT_Desktop*, PVViewer_Viewer* );
   virtual ~PVViewer_ViewWindow();
 
-  virtual QString   getVisualParameters();
-  virtual void      setVisualParameters( const QString& );
+  virtual QString getVisualParameters();
+  virtual void setVisualParameters( const QString& );
   
-  pqTabbedMultiViewWidget*    getMultiViewManager() const;
+  pqTabbedMultiViewWidget* getMultiViewManager() const;
 
   static void removePVMgr();
 
 private:
-  SUIT_Desktop*     myDesktop;
-  PVViewer_Viewer*     myModel;
-  pqTabbedMultiViewWidget*    myPVMgr;
+  SUIT_Desktop* myDesktop;
+  PVViewer_Viewer* myModel;
+  pqTabbedMultiViewWidget* myPVMgr;
 };
 
-#endif // PLOT2D_VIEWWINDOW_H
+#endif // PVVIEWER_VIEWWINDOW_H
index bca0f0dc98f67ca1e50b9ef7ceda8ae79bcc59f5..b0848fe4706b79cba4643c40b95673872e5d7b6b 100755 (executable)
@@ -96,6 +96,7 @@ SET(_other_HEADERS
   Qtx.h
   QtxEvalExpr.h
   QtxMap.h
+  QtxMsgHandler.h
   QtxPreferenceMgr.h
   QtxResourceMgr.h
   QtxTranslator.h
@@ -152,6 +153,7 @@ SET(_other_SOURCES
   QtxMRUAction.cxx
   QtxMainWindow.cxx
   QtxMenu.cxx
+  QtxMsgHandler.cxx
   QtxMultiAction.cxx
   QtxNotify.cxx
   QtxPagePrefMgr.cxx
diff --git a/src/Qtx/QtxMsgHandler.cxx b/src/Qtx/QtxMsgHandler.cxx
new file mode 100644 (file)
index 0000000..347165c
--- /dev/null
@@ -0,0 +1,119 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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, or (at your option) any later version.
+//
+// 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 "QtxMsgHandler.h"
+
+/*!
+  \brief Custom Qt messages handler.
+  
+  To install message handler use qInstallMessageHandler() function:
+
+  \code
+  #include <QtxMsgHandler.h>
+  qInstallMessageHandler(QtxMsgHandler);
+  \code
+
+  To process Qt message implement a callback class by inheriting from
+  QtxMsgHandlerCallback and override its qtMessage() function.
+
+  \sa QtxMsgHandlerCallback
+*/
+void QtxMsgHandler(QtMsgType type, const QMessageLogContext& context, const QString& message)
+{
+  foreach(QtxMsgHandlerCallback* callback, QtxMsgHandlerCallback::callbacks)
+  {
+    callback->qtMessage( type, context, message );
+  }
+}
+
+/*!
+  \class QtxMsgHandlerCallback
+  \brief A callback object to handle Qt messages.
+
+  The QtxMsgHandlerCallback class works in conjunction with QtxMsgHandler()
+  function which is a message handler itself. 
+
+  Implement your own callback class by inheriting from QtxMsgHandlerCallback
+  and override its qtMessage() function. Default implementation does nothing.
+
+  \sa QtxMsgHandler()
+*/
+
+QList<QtxMsgHandlerCallback*> QtxMsgHandlerCallback::callbacks;
+
+/*!
+  \brief Create new callback instance and activate it \a on is \c true.
+  \param on Automatically activate callback on creation. Defaults to \c true.
+  \sa activate()
+*/
+QtxMsgHandlerCallback::QtxMsgHandlerCallback(bool on)
+{
+  if ( on )
+    activate();
+}
+
+/*!
+  \brief Deactivate and destroy callback instance.
+  \sa deactivate()
+*/
+QtxMsgHandlerCallback::~QtxMsgHandlerCallback()
+{
+  deactivate();
+}
+
+/*!
+  \brief Activate this callback instance in the message handler.
+  \sa deactivate()
+*/
+void QtxMsgHandlerCallback::activate()
+{
+  if ( !callbacks.contains( this ) )
+    callbacks.push_back( this );
+}
+
+/*!
+  \brief Deactivate this callback instance from the message handler.
+  \sa activate()
+*/
+void QtxMsgHandlerCallback::deactivate()
+{
+  if ( callbacks.contains( this ) )
+    callbacks.removeAll( this );
+}
+
+/*!
+  \brief This function is called when a new Qt message is reported.
+
+  Override this method in your custom callback class to handle Qt
+  messages.
+
+  Default implementation does nothing.
+
+  \param type Qt message type.
+  \param context Message context.
+  \param message Message text.
+*/
+void QtxMsgHandlerCallback::qtMessage(QtMsgType /*type*/,
+                                     const QMessageLogContext& /*context*/,
+                                     const QString& /*message*/)
+{
+}
diff --git a/src/Qtx/QtxMsgHandler.h b/src/Qtx/QtxMsgHandler.h
new file mode 100644 (file)
index 0000000..a0836de
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef QTXMSGHANDLER_H
+#define QTXMSGHANDLER_H
+
+#include "Qtx.h"
+#include <QList>
+
+void QTX_EXPORT QtxMsgHandler(QtMsgType, const QMessageLogContext&, const QString&);
+
+class QTX_EXPORT QtxMsgHandlerCallback
+{
+  friend void QtxMsgHandler(QtMsgType, const QMessageLogContext&, const QString&);
+
+public:
+  QtxMsgHandlerCallback(bool = true);
+  virtual ~QtxMsgHandlerCallback();
+
+protected:
+  virtual void qtMessage(QtMsgType, const QMessageLogContext&, const QString&);
+
+  void activate();
+  void deactivate();
+
+private:
+  static QList<QtxMsgHandlerCallback*> callbacks;
+};
+
+#endif // QTXMSGHANDLER_H
index 439a516e15d5567915440c779eec235565d1a982..380ac23e8e91d1c03e68efd19081a7b0a091597e 100755 (executable)
@@ -46,6 +46,7 @@
 #include "Session_Session_i.hxx"
 
 #include <Qtx.h>
+#include <QtxMsgHandler.h>
 #include <QtxSplash.h>
 
 #ifdef USE_SALOME_STYLE
  * - stop Session ( must be idle )
  * - get session state
  */
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-void MessageOutput( QtMsgType type, const char* msg )
-#else
-void MessageOutput( QtMsgType type, const QMessageLogContext &context, const QString &msg )
-#endif
+
+class SessionMsgHandler: public QtxMsgHandlerCallback
 {
-  switch ( type )
+public:
+  SessionMsgHandler() {}
+  void qtMessage(QtMsgType type, const QMessageLogContext& context, const QString& message)
   {
-  case QtDebugMsg:
+    switch ( type )
+    {
+    case QtDebugMsg:
 #ifdef QT_DEBUG_MESSAGE
-    MESSAGE( "Debug: " << qPrintable( QString(msg) ) );
+      MESSAGE( "Debug: " << qPrintable( message ) );
 #endif
-    break;
-  case QtWarningMsg:
-    MESSAGE( "Warning: " << qPrintable( QString(msg) ) );
-    break;
-  case QtFatalMsg:
-    MESSAGE( "Fatal: " << qPrintable( QString(msg) ) );
-    break;
+      break;
+    case QtWarningMsg:
+      MESSAGE( "Warning: " << qPrintable( message ) );
+      break;
+    case QtCriticalMsg:
+      MESSAGE( "Critical: " << qPrintable( message ) );
+      break;
+    case QtFatalMsg:
+      MESSAGE( "Fatal: " << qPrintable( message ) );
+      break;
+    case QtInfoMsg:
+    default:
+      MESSAGE( "Information: " << qPrintable( message ) );
+      break;
+    }
   }
-}
+};
 
 QString salomeVersion()
 {
@@ -332,11 +342,8 @@ void shutdownServers( SALOME_NamingService* theNS )
 int main( int argc, char **argv )
 {
   // Install Qt debug messages handler
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-  qInstallMsgHandler( MessageOutput );
-#else
-  qInstallMessageHandler( MessageOutput );
-#endif
+  SessionMsgHandler msgHandler;
+  qInstallMessageHandler(QtxMsgHandler);
 
 // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)