]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Join modifications from V3_2_0_maintainance (V3_2_6pre4 - T32x_16Aug2007_16h00m)
authorjfa <jfa@opencascade.com>
Fri, 17 Aug 2007 10:15:40 +0000 (10:15 +0000)
committerjfa <jfa@opencascade.com>
Fri, 17 Aug 2007 10:15:40 +0000 (10:15 +0000)
14 files changed:
src/LightApp/LightApp_Selection.cxx
src/PythonConsole/PythonConsole_PyEditor.cxx
src/PythonConsole/PythonConsole_PyEditor.h
src/SUIT/SUIT_Application.cxx
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_Session.cxx
src/SUIT/SUIT_Study.cxx
src/SUIT/SUIT_Study.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_Study.cxx
src/SalomeApp/SalomeApp_Study.h
src/VTKViewer/VTKViewer_ConvexTool.cxx
src/VTKViewer/VTKViewer_ConvexTool.h

index fe0a15207ca64bd90a601988deb7125cde04e4fd..4b7e58ae5b76ff40fe25c1edce183fdf147137ea 100644 (file)
@@ -67,9 +67,10 @@ void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr
     for( SUIT_Selector* selector = aSelectors.first(); selector; selector = aSelectors.next() )
     {
       qDebug( selector->type() );
-      if( selector->type()!=client )
+      if( selector->type() != client && selector->isEnabled() )
       {
-       mgr->selected( cur_sel, selector->type() );
+       //mgr->selected( cur_sel, selector->type() );
+        selector->selected( cur_sel );
        SUIT_DataOwnerPtrList::const_iterator aLIt = cur_sel.begin(), aLLast = cur_sel.end();
        for( ; aLIt!=aLLast; aLIt++ )
          sel.append( *aLIt ); //check entry and don't append if such entry is in list already
index 30291e0c43a4eae034f44532de87e0b4bca4bb3f..21e2566f44a09b0fcd40736e90849003c9d27fb2 100755 (executable)
@@ -37,6 +37,7 @@
 #include <qdragobject.h>
 #include <qapplication.h>
 #include <qpopupmenu.h>
+#include <qfontmetrics.h>
 
 using namespace std;
 
@@ -138,7 +139,43 @@ void PythonConsole_PyEditor::setText(QString s)
 {
   int para=paragraphs()-1;
   int col=paragraphLength(para);
-  insertAt(s,para,col);
+
+  // Limit length of the string because exception may occur if string too long (NPAL16033)
+  // Exception occurs if  one of paragraphs of the input string "s" is too long.  Now long 
+  // paragraph is limited with threshold numbers of characters and finished by " ..." string. 
+  // Note that first paragraph of the string is checked only because it is enough for bug fixing. 
+  // If it will be insufficient for other cases then more complicated check should be implemented.
+  // At present it is not done because of possible performance problem.
+
+  static int threshold = 50000;
+  long strLength = s.length();
+  if ( col + strLength <= threshold || s.find( '\n' ) < threshold )
+    insertAt(s,para,col);
+  else
+  {
+    if ( col >= threshold )
+    {
+      if ( text( para ).right( 5 )  != QString( " ...\n" ) )
+        insertAt(" ...\n",para,col);
+    }
+    else
+    {
+      long n = threshold - col; 
+      s.truncate( n );
+      if ( n >= 5 )
+      {
+        s.at( n - 5 ) = QChar( ' ' );
+        s.at( n - 4 ) = QChar( '.' );
+        s.at( n - 3 ) = QChar( '.' );
+        s.at( n - 2 ) = QChar( '.' );
+        s.at( n - 1 ) = QChar( '\n' );
+      }
+      else 
+        s = " ...\n";
+      insertAt(s,para,col);
+    }
+  }
+
   int n = paragraphs()-1;  
   setCursorPosition( n, paragraphLength(n)); 
 }
@@ -159,9 +196,12 @@ void PythonConsole_PyEditor::exec( const QString& command )
   _currentPrompt = READY_PROMPT;
   _buf.truncate(0);
   _isInHistory = false;
-  setText( "\n" + _currentPrompt); 
-  setText( command + "\n" ); 
-  handleReturn();
+  setText( "\n" + _currentPrompt);
+  // PAL15963 (Problem with option -u (--execute) of runSalome).
+  // Let events creating a study end before script execution starts
+  setText( command /*+ "\n"*/ );
+  //handleReturn();
+  qApp->postEvent( this, new QKeyEvent(QEvent::KeyPress,Key_Return,13,Qt::NoButton ));
 }
 
 void PythonConsole_PyEditor::execAndWait( const QString& command )
@@ -377,21 +417,22 @@ void PythonConsole_PyEditor::keyPressEvent( QKeyEvent* e )
       else if ( ctrlPressed ) {
        moveCursor( QTextEdit::MoveUp, false );
       }
-      else { 
-       QString histLine = _currentPrompt;
-       if ( ! _isInHistory ) {
-         _isInHistory = true;
-         _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
-         _currentCommand.truncate( _currentCommand.length() - 1 );
-       }
-       QString previousCommand = myInterp->getPrevious();
-       if ( previousCommand.compare( BEGIN_HISTORY_PY ) != 0 )
-  {
-    removeParagraph( endLine );
-         histLine.append( previousCommand );
-    append( histLine );
-       }
-       moveCursor( QTextEdit::MoveEnd, false );
+      else {
+        QString histLine = _currentPrompt;
+        if ( ! _isInHistory ) {
+          _isInHistory = true;
+          _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
+          _currentCommand.truncate( _currentCommand.length() - 1 );
+        }
+        QString previousCommand = myInterp->getPrevious();
+        if ( previousCommand.compare( BEGIN_HISTORY_PY ) != 0 )
+        {
+          removeParagraph( endLine );
+          histLine.append( previousCommand );
+          append( histLine );
+        }
+        moveCursor( QTextEdit::MoveEnd, false );
+        scrollViewAfterHistoryUsing( previousCommand ); // NPAL16035
       }
       break;
     }
@@ -429,6 +470,7 @@ void PythonConsole_PyEditor::keyPressEvent( QKeyEvent* e )
          }
        }
        moveCursor( QTextEdit::MoveEnd, false );
+        scrollViewAfterHistoryUsing( nextCommand ); // NPAL16035
       }
       break;
     }
@@ -762,3 +804,36 @@ QPopupMenu* PythonConsole_PyEditor::createPopupMenu( const QPoint& pos )
 
   return popup;
 }
+
+/*!
+  Scrolls view after use of history (Up/Down keys)to the left position if length
+  of command less than visible width of the view
+*/
+void PythonConsole_PyEditor::scrollViewAfterHistoryUsing( const QString& command )
+{
+  if ( !command.isEmpty() )
+  {
+    if ( command == QString( BEGIN_HISTORY_PY ) )
+    {
+      ensureCursorVisible();
+      return;
+    }
+
+    QFontMetrics aFM( currentFont() );
+    int aCommandLength = aFM.width( command ) + aFM.width( READY_PROMPT ) + 5;
+    int aVisibleWidth = visibleWidth();
+    QScrollBar* aBar = horizontalScrollBar();
+    if ( aBar )
+    {
+      if ( aCommandLength <= aVisibleWidth )
+        aBar->setValue( aBar->minValue() );
+      else  if ( aVisibleWidth > 0 )
+      {
+        double aRatio = aCommandLength / contentsWidth();
+        double aPos = ( aBar->maxValue() - aBar->minValue() ) * aRatio;
+        aBar->setValue( (int)aPos );
+        ensureCursorVisible();
+      }
+    }
+  }
+}
index b353ee4dadf5b08d83d2ef7db338aca02d0d073b..d8a2acb30ba223cedc819acc4303949d0d04bb51 100755 (executable)
@@ -55,13 +55,17 @@ protected:
   virtual void keyPressEvent (QKeyEvent* event);
   virtual void mousePressEvent (QMouseEvent* event);
   virtual void customEvent (QCustomEvent* event);
-  
+
 public slots:
   void handleReturn();
   void onPyInterpChanged( PyInterp_base* );
 
   virtual QPopupMenu* createPopupMenu( const QPoint& );
-  
+
+private:
+
+  void scrollViewAfterHistoryUsing( const QString& command );
+
 private:
   QString        _buf;
   QString        _currentCommand;
index bbe68030d2b757c51ddd1624e2802656960ba6fd..13821608c7856142e07de28048080b9ecc021ad2 100755 (executable)
   Default constructor
 */
 SUIT_Application::SUIT_Application()
-: QObject( 0 ),
-myStudy( 0 ),
-myDesktop( 0 ),
-myStatusLabel( 0 )
-{ 
+  : QObject( 0 ),
+    myStudy( 0 ),
+    myDesktop( 0 ),
+    myStatusLabel( 0 ),
+    myIsInitiallyRegistered( false )
+{
 }
 
 /*!
index 0bf48847e47efb99ae3aaaa7a08de43aabc794b7..2bf9da35547eb6364d7e7b5e04e45b345b525895 100755 (executable)
@@ -109,6 +109,9 @@ public:
   //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
   virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
 
+  //! Perform required actions on the application, just registed in the session
+  virtual void Registered() { myIsInitiallyRegistered = true; };
+
 signals:
   void                  applicationClosed( SUIT_Application* );
   void                  activated( SUIT_Application* );
@@ -163,6 +166,9 @@ protected:
 protected slots:
   virtual void          onDesktopActivated();
 
+protected:
+  bool        myIsInitiallyRegistered; //<! false before the first application registration in the session
+
 private:
   SUIT_Study*           myStudy;
   SUIT_Desktop*         myDesktop;
index 7d2ac383912cb8488928028e7721f233ac8dc9ce..66e84e4b3e07e19abbefbc72f97dc26f1332d1db 100755 (executable)
@@ -326,9 +326,11 @@ SUIT_ResourceMgr* SUIT_Session::createResourceMgr( const QString& appName ) cons
 /*!
   Slot, called on activation of some application's desktop
 */
-void SUIT_Session::onApplicationActivated( SUIT_Application* app ) 
+void SUIT_Session::onApplicationActivated( SUIT_Application* app )
 {
   myActiveApp = app;
+  if (app)
+    app->Registered();
 }
 
 /*!
index a3baef3ce8bc7dfa153cea62db34b2e91c3cd4a4..19dabb03be905e1f7af958e840b0e305adfad8e0 100755 (executable)
@@ -511,18 +511,12 @@ bool SUIT_Study::hasTransaction() const
 {
   return false;
 }
-
-/*!
- * \brief Stores the study state
-*/
-int SUIT_Study::storeState()
-{
-  return -1;
-}
  
 /*!
- * \brief Restores the study state
-*/
+ * \brief Restores the study state.
+ */
 void SUIT_Study::restoreState(int savePoint)
 {
+  // Redefined in SalomeApp_Study.
+  // Called from SALOME_Session_i::restoreVisualState(CORBA::Long theSavePoint)
 }
index 156c6bc74df61f24a70f95fe04b46b75bd69e98a..fc6c35f0c26a746643baf4dd6e457021a1ec31b1 100755 (executable)
@@ -75,7 +75,6 @@ public:
   bool              suspend( SUIT_Operation* );
   bool              resume( SUIT_Operation* );
 
-  virtual int       storeState();
   virtual void      restoreState(int savePoint);
 
 signals:
index 93f1e10aad65c69d88fa12d79caced34cc12dfa3..4df0a4fab88e7162ea626d011ccc741c735f3938 100644 (file)
@@ -154,11 +154,16 @@ void SalomeApp_Application::start()
   LightApp_Application::start();
 
   SalomeApp_EventFilter::Init();
+}
 
-  static bool isFirst = true;
-  if ( isFirst ) {
-    isFirst = false;
+/*!Just registered in the session*/
+void SalomeApp_Application::Registered()
+{
+  if (!myIsInitiallyRegistered)
+  {
+    myIsInitiallyRegistered = true;
 
+    // execute python scripts
     QString hdffile;
     QStringList pyfiles;
 
index 09ece677d64a0f4906e35435e86f622d0e87ed3c..893d53c1dd884bbeba8782bc1619a508a76de918 100644 (file)
@@ -94,6 +94,8 @@ public:
   SUIT_ViewManager*                   newViewManager(const QString&);
   void                                updateSavePointDataObjects( SalomeApp_Study* );
 
+  virtual void Registered();
+
 public slots:
   virtual bool                        onOpenDoc( const QString& );
   virtual void                        onLoadDoc();
index 1fb4d0bdd078ab109a1dcf03c6f4ee78f753adc1..503438d4ab7eee7c4e2c591710fd0cbb300f1e94 100644 (file)
@@ -727,6 +727,15 @@ std::string SalomeApp_Study::getVisualComponentName()
   return "Interface Applicative";
 }
 
+/*!
+ * \brief Restores the study state
+ */
+void SalomeApp_Study::restoreState(int savePoint)
+{
+  SalomeApp_VisualState((SalomeApp_Application*)application()).restoreState(savePoint);
+}
+
+
 /*!
   Slot: called on change of a root of a data model. Redefined from CAM_Study
 */
index ef5c127fd11caa68c3007ae77ed3723351d8ab8f..707518a378180e41bf2860cf96b935ae33012591 100644 (file)
@@ -73,6 +73,8 @@ public:
   void                setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint);
   virtual std::string getVisualComponentName();
 
+  virtual void        restoreState(int savePoint);
+
 protected:
   virtual void        saveModuleData ( QString theModuleName, QStringList theListOfFiles );
   virtual void        openModuleData ( QString theModuleName, QStringList& theListOfFiles );
index 1ecabea6ed99454386b95b648e9fe43445969339..3a8680a40a4c7f4fad4738eb20db2dd1fc8f95de 100644 (file)
@@ -47,6 +47,9 @@
 #include <vtkCell.h>
 #include <vtkPlane.h>
 #include <vtkMath.h>
+#include <vtkCellArray.h>
+#include <vtkTriangle.h>
+#include <vtkOrderedTriangulator.h>
 
 #ifdef _DEBUG_
 static int DEBUG_TRIA_EXECUTE = 0;
@@ -517,8 +520,15 @@ VTKViewer_Triangulator
 */
 VTKViewer_OrderedTriangulator
 ::VTKViewer_OrderedTriangulator():
-  myCell(vtkGenericCell::New())
-{}
+  myCell(vtkGenericCell::New()),
+  myBoundaryTris(vtkCellArray::New()),
+  myTriangle(vtkTriangle::New()),
+  myTriangulator(vtkOrderedTriangulator::New())
+{
+  myBoundaryTris->Allocate(100);
+  myTriangulator->PreSortedOff();
+  //myTriangulator->UseTemplatesOn();
+}
 
 /*!
   Destructor
@@ -527,6 +537,9 @@ VTKViewer_OrderedTriangulator
 ::~VTKViewer_OrderedTriangulator()
 {
   myCell->Delete();
+  myBoundaryTris->Delete();
+  myTriangle->Delete();
+  myTriangulator->Delete();
 }
 
 vtkPoints*
@@ -534,6 +547,39 @@ VTKViewer_OrderedTriangulator
 ::InitPoints()
 {
   myInput->GetCell(myCellId,myCell);
+
+  int numPts = myCell->GetNumberOfPoints();
+  if ( numPts > 0 )
+  {
+    myTriangulator->InitTriangulation(0.0,1.0, 0.0,1.0, 0.0,1.0, numPts);
+
+    vtkFloatingPointType x[3], p[3];
+    vtkIdType ptId;
+    vtkFloatingPointType *bounds = myCell->GetBounds();
+
+    // Inject cell points into triangulation
+    for (int i=0; i<numPts; i++)
+    {
+      myCell->Points->GetPoint(i, x);
+      for (int j=0; j<3; j++)
+        p[j] = (x[j] - bounds[2*j]) / (bounds[2*j+1] - bounds[2*j]);
+      ptId = myCell->PointIds->GetId(i);
+      //    myTriangulator->InsertPoint(ptId, x, x, 0);
+      myTriangulator->InsertPoint(ptId, x, p, 0);
+    }//for all points
+
+
+//     if ( myCell->IsPrimaryCell() ) //use templates if topology is fixed
+//     {
+//       int numEdges=myCell->GetNumberOfEdges();
+//       myTriangulator->TemplateTriangulate(myCell->GetCellType(),
+//                                           numPts,numEdges);
+//     }
+//     else //use ordered triangulator
+    {
+      myTriangulator->Triangulate();
+    }
+  }
   return myInput->GetPoints();
 }
 
@@ -562,14 +608,31 @@ vtkIdType
 VTKViewer_OrderedTriangulator
 ::GetNumFaces()
 {
-  return myCell->GetNumberOfFaces();
+  myBoundaryTris->Reset();
+  myTriangulator->AddTriangles(myBoundaryTris);
+  return myBoundaryTris->GetNumberOfCells();
+  //return myCell->GetNumberOfFaces();
 }
 
 vtkCell*
 VTKViewer_OrderedTriangulator
 ::GetFace(vtkIdType theFaceId)
 {
-  return myCell->GetFace(theFaceId);
+  int numCells = myBoundaryTris->GetNumberOfCells();
+  if ( theFaceId < 0 || theFaceId >=numCells ) {return NULL;}
+
+  vtkIdType *cells = myBoundaryTris->GetPointer();
+
+  // Each triangle has three points plus number of points
+  vtkIdType *cptr = cells + 4*theFaceId;
+  for (int i=0; i<3; i++)
+  {
+    myTriangle->PointIds->SetId(i,cptr[i+1]);
+    myTriangle->Points->SetPoint(i,myCell->Points->GetPoint(cptr[i+1]));
+  }
+
+  return myTriangle;
+  //return myCell->GetFace(theFaceId);
 }
 
 void 
index 2bf024d5e0fc1d1a7bd86b948ab215259e59e2dd..46f5cdf6e59e412cb5006e5e3eee64cc15e5da01 100644 (file)
@@ -36,6 +36,9 @@ class vtkCellData;
 class vtkPoints;
 class vtkIdList;
 class vtkCell;
+class vtkCellArray;
+class vtkTriangle;
+class vtkOrderedTriangulator;
 
 class VTKVIEWER_EXPORT VTKViewer_Triangulator
 {
@@ -111,7 +114,10 @@ class VTKVIEWER_EXPORT VTKViewer_OrderedTriangulator : public VTKViewer_Triangul
   ~VTKViewer_OrderedTriangulator();
 
  protected:
-  vtkGenericCell *myCell;
+  vtkGenericCell         *myCell;
+  vtkCellArray           *myBoundaryTris;
+  vtkTriangle            *myTriangle;
+  vtkOrderedTriangulator *myTriangulator;
 
   virtual
   vtkPoints*