Salome HOME
no message
authorstv <stv@opencascade.com>
Mon, 30 May 2005 04:44:19 +0000 (04:44 +0000)
committerstv <stv@opencascade.com>
Mon, 30 May 2005 04:44:19 +0000 (04:44 +0000)
13 files changed:
src/Qtx/Makefile.in
src/Qtx/QtxDockWindow.cxx
src/Qtx/QtxPopupMenu.cxx [new file with mode: 0644]
src/Qtx/QtxPopupMenu.h [new file with mode: 0644]
src/Qtx/QtxToolBar.cxx
src/STD/STD_Application.cxx
src/STD/STD_Application.h
src/SUIT/SUIT_Application.cxx
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_Session.cxx
src/TOOLSGUI/ToolsGUI.h
src/VTKViewer/VTKViewer_ConvexTool.cxx
src/VTKViewer/VTKViewer_ConvexTool.h

index 54a54311abf304dd6449c921e0e8c69b73a57b35..726818f956ab6d5768e9737db47f7183df235a3a 100755 (executable)
@@ -35,6 +35,7 @@ EXPORT_HEADERS= Qtx.h \
                QtxToolBar.h \
                QtxToolTip.h \
                QtxParser.h \
+                QtxPopupMenu.h \
                QtxActionMgr.h \
                QtxActionMenuMgr.h \
                QtxActionToolMgr.h \
@@ -77,6 +78,7 @@ LIB_SRC= \
        QtxToolTip.cxx \
        QtxOperations.cxx \
        QtxParser.cxx \
+        QtxPopupMenu.cxx \
        QtxActionMgr.cxx \
        QtxActionMenuMgr.cxx \
        QtxActionToolMgr.cxx \
@@ -103,6 +105,7 @@ LIB_MOC = \
         QtxMRUAction.h \
         QtxPathDialog.h \
         QtxPopupMgr.h \
+        QtxPopupMenu.h \
        QtxToolBar.h \
         QtxToolTip.h \
        QtxActionMgr.h \
index 3053938de0ad4a70c69d7cc4a0fe49b742dc3743..0432faa5cd5e91eb6117707c350df86a22305e7b 100644 (file)
@@ -121,10 +121,8 @@ void QtxDockWindow::Watcher::updateVisibility()
     }
   }
 
-  if ( vis )
-    myCont->show();
-  else
-    myCont->hide();
+  if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
+    vis ? myCont->show() : myCont->hide();
 }
 
 void QtxDockWindow::Watcher::updateIcon()
diff --git a/src/Qtx/QtxPopupMenu.cxx b/src/Qtx/QtxPopupMenu.cxx
new file mode 100644 (file)
index 0000000..f041f5d
--- /dev/null
@@ -0,0 +1,237 @@
+#include "QtxPopupMenu.h"
+
+#include <qpainter.h>
+
+/*!
+    Class: QtxPopupMenu::TitleMenuItem [Internal]
+    Descr: Custom menu item for popup title.
+*/
+
+class QtxPopupMenu::TitleMenuItem : public QCustomMenuItem
+{
+public:
+  TitleMenuItem( const QString&, const QIconSet&, const int );
+  virtual ~TitleMenuItem();
+
+  virtual bool  fullSpan() const;
+  virtual bool  isSeparator() const;
+  virtual void  setFont( const QFont& );
+
+  virtual void  paint( QPainter*, const QColorGroup&, bool, bool, int, int, int, int );
+  virtual QSize sizeHint();
+
+private:
+  QString       myText;
+  QIconSet      myIcon;
+  QFont         myFont;
+  int           myAlign;
+};
+
+QtxPopupMenu::TitleMenuItem::TitleMenuItem( const QString& txt, const QIconSet& ico, const int align )
+: QCustomMenuItem(),
+myText( txt ),
+myIcon( ico ),
+myAlign( align )
+{
+}
+
+QtxPopupMenu::TitleMenuItem::~TitleMenuItem()
+{
+}
+
+bool QtxPopupMenu::TitleMenuItem::fullSpan() const
+{
+  return true;
+}
+
+bool QtxPopupMenu::TitleMenuItem::isSeparator() const
+{
+  return false;
+}
+
+void QtxPopupMenu::TitleMenuItem::setFont( const QFont& font )
+{
+  myFont = font;
+  myFont.setBold( true );
+}
+
+void QtxPopupMenu::TitleMenuItem::paint( QPainter* p, const QColorGroup& cg,
+                                         bool act, bool enabled, int x, int y, int w, int h )
+{
+  QFont f = p->font();
+  p->setFont( myFont );
+
+  p->fillRect( x, y, w, h, cg.brush( QColorGroup::Mid ) );
+
+  p->setPen( cg.shadow() );
+  p->drawRect( x, y, w, h );
+
+  int m = 3;
+  int s = 3;
+  int iw = p->fontMetrics().width( myText ) + ( myIcon.isNull() ? 0 : myIcon.pixmap().width() + s );
+  int ih = QMAX( ( myIcon.isNull() ? 0 : myIcon.pixmap().height() ), p->fontMetrics().height() );
+
+  int ix = x;
+  int iy = y + m;
+
+  if ( myAlign & AlignLeft )
+    ix = x;
+  else if ( myAlign & AlignRight )
+    ix = x + ( w - iw );
+  else if ( myAlign & AlignHCenter )
+    ix = x + ( w - iw ) / 2;
+
+  if ( myAlign & AlignTop )
+    iy = y;
+  else if ( myAlign & AlignBottom )
+    iy = y + ( h - ih - m );
+  else if ( myAlign & AlignVCenter )
+    iy = y + ( h - ih ) / 2;
+
+  if ( !myIcon.isNull() )
+  {
+    p->drawPixmap( ix, iy + ( ih - myIcon.pixmap().height() ) / 2, myIcon.pixmap() );
+    ix += myIcon.pixmap().width() + s;
+  }
+
+  p->setPen( cg.brightText() );
+  p->drawText( ix, iy + ( ih - p->fontMetrics().height() ) / 2 +
+               p->fontMetrics().ascent(), myText, 0, -1 );
+
+  p->setFont( f );
+}
+
+QSize QtxPopupMenu::TitleMenuItem::sizeHint()
+{
+  QFontMetrics fM( myFont );
+
+  int m = 3;
+  int s = 3;
+  int w = fM.width( myText ) + ( myIcon.isNull() ? 0 : myIcon.pixmap().width() + s );
+  int h = QMAX( ( myIcon.isNull() ? 0 : myIcon.pixmap().height() ), fM.height() ) + 2 * m;
+
+  return QSize( w, h );
+}
+
+/*!
+    Class: QtxPopupMenu [Public]
+    Descr: Popup menu item with title.
+*/
+
+QtxPopupMenu::QtxPopupMenu( QWidget* parent, const char* name )
+: QPopupMenu( parent, name ),
+myId( -1 ),
+myPolicy( TitleAuto ),
+myAlign( AlignCenter )
+{
+}
+
+QtxPopupMenu::~QtxPopupMenu()
+{
+}
+
+QString QtxPopupMenu::titleText() const
+{
+  return myText;
+}
+
+QIconSet QtxPopupMenu::titleIcon() const
+{
+  return myIcon;
+}
+
+int QtxPopupMenu::titlePolicy() const
+{
+  return myPolicy;
+}
+
+int QtxPopupMenu::titleAlignment() const
+{
+  return myAlign;
+}
+
+void QtxPopupMenu::setTitleText( const QString& txt )
+{
+  if ( myText == txt )
+    return;
+
+  myText = txt;
+
+  updateTitle();
+}
+
+void QtxPopupMenu::setTitleIcon( const QIconSet& ico )
+{
+  myIcon = ico;
+
+  updateTitle();
+}
+
+void QtxPopupMenu::setTitlePolicy( const int p )
+{
+  if ( myPolicy == p )
+    return;
+
+  myPolicy = p;
+
+  updateTitle();
+}
+
+void QtxPopupMenu::setTitleAlignment( const int a )
+{
+  if ( myAlign == a )
+    return;
+
+  myAlign = a;
+
+  updateTitle();
+}
+
+void QtxPopupMenu::show()
+{
+  insertTitle();
+
+  QPopupMenu::show();
+}
+
+void QtxPopupMenu::hide()
+{
+  QPopupMenu::hide();
+
+  removeTitle();
+}
+
+QtxPopupMenu::TitleMenuItem* QtxPopupMenu::createTitleItem( const QString& txt, const QIconSet& ico,
+                                                            const int align ) const
+{
+  return new TitleMenuItem( txt, ico, align );
+}
+
+void QtxPopupMenu::insertTitle()
+{
+  if ( myId != -1 || titlePolicy() == TitleOff ||
+       ( titlePolicy() == TitleAuto && titleText().stripWhiteSpace().isEmpty() ) )
+    return;
+
+  TitleMenuItem* item = createTitleItem( titleText(), titleIcon(), titleAlignment() );
+
+  myId = insertItem( item, -1, 0 );
+}
+
+void QtxPopupMenu::removeTitle()
+{
+  if ( myId == -1 )
+    return;
+
+  removeItem( myId );
+  myId = -1;
+}
+
+void QtxPopupMenu::updateTitle()
+{
+  if ( myId != -1 )
+  {
+    removeTitle();
+    insertTitle();
+  }
+}
diff --git a/src/Qtx/QtxPopupMenu.h b/src/Qtx/QtxPopupMenu.h
new file mode 100644 (file)
index 0000000..2ddb1b3
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef QTXPOPUPMENU_H
+#define QTXPOPUPMENU_H
+
+#include "Qtx.h"
+
+#include <qstring.h>
+#include <qiconset.h>
+#include <qpopupmenu.h>
+
+class QTX_EXPORT QtxPopupMenu : public QPopupMenu
+{
+  Q_OBJECT
+
+protected:
+  class TitleMenuItem;
+
+public:
+  enum { TitleAuto, TitleOn, TitleOff };
+
+public:
+  QtxPopupMenu( QWidget* = 0, const char* = 0 );
+  virtual ~QtxPopupMenu();
+
+  QString                titleText() const;
+  QIconSet               titleIcon() const;
+
+  int                    titlePolicy() const;
+  int                    titleAlignment() const;
+
+  virtual void           setTitleText( const QString& );
+  virtual void           setTitleIcon( const QIconSet& );
+
+  virtual void           setTitlePolicy( const int );
+  virtual void           setTitleAlignment( const int );
+
+public slots:
+  virtual void           show();
+  virtual void           hide();
+
+protected:
+  virtual TitleMenuItem* createTitleItem( const QString&, const QIconSet&, const int ) const;
+
+private:
+  void                   updateTitle();
+  void                   insertTitle();
+  void                   removeTitle();
+
+private:
+  int                    myId;
+  QString                myText;
+  QIconSet               myIcon;
+  int                    myAlign;
+  int                    myPolicy;
+};
+
+#endif
index b132fe9b0510648b2b973dfefc81ed9816eefb7c..094923942b4516f467fd561f86c689a77c89f990 100644 (file)
@@ -143,10 +143,8 @@ void QtxToolBar::Watcher::updateVisibility()
     }
   }
 
-  if ( vis )
-    myCont->show();
-  else
-    myCont->hide();
+  if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
+    vis ? myCont->show() : myCont->hide();
 }
 
 void QtxToolBar::Watcher::updateIcon()
index eccdfc90d0d801780b6e62d658785e013f199ec1..41392ffa9e4b60ca23d6fe84721d21e71d5fdb07 100755 (executable)
@@ -68,10 +68,15 @@ void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e )
   }
 
   SUIT_Study* study = activeStudy();
+
+  if ( study )
+    study->closeDocument();
+
   setActiveStudy( 0 );
   delete study;
 
   setDesktop( 0 );
+
   closeApplication();
 }
 
@@ -303,13 +308,9 @@ void STD_Application::onCloseDoc()
   }
 
   afterCloseDoc();
-  closeApplication();
-}
 
-void STD_Application::closeApplication()
-{
   if ( !desktop() )
-    emit applicationClosed( this );
+    closeApplication();
 }
 
 bool STD_Application::isPossibleToClose()
index 77349a09827447f202809a1cd9f2a9861b9b3fd8..1e2427e5770348422d9c536bf6d26b06e74ffc65 100755 (executable)
@@ -35,7 +35,6 @@ public:
   virtual QString       applicationName() const;
 
   virtual bool          isPossibleToClose();
-  virtual void          closeApplication();
   virtual void          useFile( const QString& );
 
   virtual void          createEmptyStudy();
index f14f1947ecfbac6428dcdfb67a9eacbb3136c588..22e16df1d4f9341b070aeb784808093bff75e75f 100755 (executable)
@@ -33,6 +33,11 @@ bool SUIT_Application::isPossibleToClose()
   return true;
 }
 
+void SUIT_Application::closeApplication()
+{
+  emit applicationClosed( this );
+}
+
 SUIT_Study* SUIT_Application::activeStudy() const
 {
   return myStudy;
index 52e5451163176ff3d0b50b0c7727151924988f00..bcf33bae3e4f55f4ac7290d76cff451dc717b933 100755 (executable)
@@ -37,6 +37,8 @@ public:
       This method called by SUIT_Session whin closing of application was requested. */
   virtual bool          isPossibleToClose();
 
+  virtual void          closeApplication();
+
   //! Returns active Study. If Application supports wirking with several studies this method should be redefined
   virtual SUIT_Study*   activeStudy() const;
 
index d2c547c1dbe4ecf1714e9a230560ac5e60b4c5fd..08d85b0f404b1ef28191155d0c96bddf54d25a50 100755 (executable)
@@ -191,12 +191,14 @@ void SUIT_Session::onApplicationClosed( SUIT_Application* theApp )
 */
 void SUIT_Session::closeSession()
 {
-  for ( AppListIterator it( myAppList ); it.current(); ++it )
+  while ( !myAppList.isEmpty() )
   {
-    if ( !it.current()->isPossibleToClose() )
+    SUIT_Application* app = myAppList.getFirst();
+    if ( !app->isPossibleToClose() )
       return;
+
+    app->closeApplication();
   }
-  qApp->quit();
 }
 
 SUIT_ExceptionHandler* SUIT_Session::handler() const
index 25b884d53786866e31766138fc9ecc2601f12ae3..08cf540f2d7ef4caeeae8f28f1f2ff51ebf01284 100755 (executable)
@@ -29,6 +29,8 @@
 #ifndef ToolsGUI_HeaderFile
 #define ToolsGUI_HeaderFile
 
+#include "utilities.h"
+
 #ifndef _Standard_HeaderFile
 #include <Standard.hxx>
 #endif
index 58a755f5b9155625545b940606459fa6a6420609..5d0736baa7df4941338088bd8b315d6303323236 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <set>
 #include <algorithm>
-#include <iterator>
 
 static float FACE_TOLERANCE = 0;
 
index baac7e1637edfe0c09e8cd7418dd42b3b93d62bd..f305140b01173d93fc5ad54e63115b69c932e9f7 100644 (file)
 // 
 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
 //
-//
-//
-//  File   : VTKViewer_ConvexTool.h
-//  Author : Eugeny Nikolaev
-//  Module : SALOME
-//  $Header$
-
 
 #ifndef _VTKViewer_ConvexTool_H
 #define _VTKViewer_ConvexTool_H
 typedef std::vector<vtkIdType> TCell; // ptsIds
 typedef std::map<vtkIdType,TCell> TCellArray; // CellId, TCell
 
-namespace CONVEX_TOOL{
-
+namespace CONVEX_TOOL
+{
   void GetPolygonalFaces(vtkUnstructuredGrid* theCell,int cellId,TCellArray &outputCellArray);
 }
 
 #endif // _VTKViewer_ConvexTool_H
-