Salome HOME
0021343: EDF 1930 SMESH: Huge memory occupation when assigning an hypothesis to...
authorvsr <vsr@opencascade.com>
Tue, 9 Aug 2011 08:39:43 +0000 (08:39 +0000)
committervsr <vsr@opencascade.com>
Tue, 9 Aug 2011 08:39:43 +0000 (08:39 +0000)
resources/SalomeApp.xml
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx
src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.h

index 6035cdc67d62b65f7cf90229d8e6940522022cc9..a0958857e9649bdfd9197e945300cf3b2bf8c5ef 100644 (file)
@@ -80,6 +80,7 @@
     <parameter name="quadratic_mode"               value="0"/>
     <parameter name="max_angle"                    value="2"/>
     <parameter name="documentation"                value="smesh_help"/>
+    <parameter name="preview_actor_chunk_size"     value="100" />
     <!-- Input field precisions -->
     <parameter name="def_precision"                value="3"  />
     <parameter name="length_precision"             value="-6"  />
index 7d608fae577e7905c59391cad7b1b3c7ebb5c473..dba7560384b1ae783e15e78314bf656c857badca 100644 (file)
@@ -4396,6 +4396,13 @@ void SMESHGUI::createPreferences()
     setPreferenceProperty( precs[ii], "precision", 2 );
   }
 
+  int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
+  setPreferenceProperty( previewGroup, "columns", 2 );
+  int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
+  setPreferenceProperty( chunkSize, "min",  0 );
+  setPreferenceProperty( chunkSize, "max",  1000 );
+  setPreferenceProperty( chunkSize, "step", 50 );
+  
   // Mesh tab ------------------------------------------------------------------------
   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
index 5bbd260f57baf52bcb1bcc8d0f5b6b3987c72a06..d0805425a57607f185effec8f245a1faf24ddf8e 100644 (file)
@@ -3612,6 +3612,10 @@ Please, create VTK viewer and try again</translation>
         <source>SMESH_PREF_GROUP_PRECISION</source>
         <translation>Input fields precision</translation>
     </message>
+    <message>
+        <source>SMESH_PREF_GROUP_PREVIEW</source>
+        <translation>Preview</translation>
+    </message>
     <message>
         <source>PREF_GROUP_ELEMENTS</source>
         <translation>Elements</translation>
@@ -3736,6 +3740,10 @@ Please, create VTK viewer and try again</translation>
         <source>PREF_WIDTH</source>
         <translation>Width</translation>
     </message>
+    <message>
+        <source>PREF_PREVIEW_CHUNK_SIZE</source>
+        <translation>Sub-shapes preview chunk size</translation>
+    </message>
 </context>
 <context>
     <name>SMESHGUI_AddQuadraticElementDlg</name>
@@ -6058,4 +6066,11 @@ as they are of improper type:
         <translation>elements</translation>
     </message>
 </context>
+<context>
+    <name>StdMeshersGUI_SubShapeSelectorWdg</name>
+    <message>
+        <source>X_FROM_Y_ITEMS_SHOWN</source>
+        <translation>%1-%2 from %3 items shown</translation>
+    </message>
+</context>
 </TS>
index 09ba1f2f0850425d5c21128c2d23db99409e660c..80259747bf3876b0b240a01bc1beb36308892124 100644 (file)
@@ -93,20 +93,28 @@ StdMeshersGUI_SubShapeSelectorWdg
   edgesLayout->setMargin( MARGIN );
   edgesLayout->setSpacing( SPACING );
   
-  myListWidget    = new QListWidget( this );
+  myListWidget   = new QListWidget( this );
   myAddButton    = new QPushButton( tr( "SMESH_BUT_ADD" ),    this );
   myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this );      
+  myInfoLabel    = new QLabel( this );
+  myPrevButton   = new QPushButton( "<<", this );
+  myNextButton   = new QPushButton( ">>", this );
   myListWidget->setSelectionMode( QListWidget::ExtendedSelection );
 
   edgesLayout->addWidget(myListWidget,   0, 0, 3, 3);
-  edgesLayout->addWidget(myAddButton,    0, 4);
-  edgesLayout->addWidget(myRemoveButton, 1, 4);
+  edgesLayout->addWidget(myAddButton,    0, 3);
+  edgesLayout->addWidget(myRemoveButton, 1, 3);
+  edgesLayout->addWidget(myInfoLabel,    3, 0, 1, 3);
+  edgesLayout->addWidget(myPrevButton,   4, 0);
+  edgesLayout->addWidget(myNextButton,   4, 2);
 
-  //edgesLayout->setRowStretch(2, 5);
-  edgesLayout->setColumnStretch(2, 5);
+  edgesLayout->setRowStretch(2, 5);
+  edgesLayout->setColumnStretch(1, 5);
 
-  setLayout( edgesLayout );
-  setMinimumWidth( 300 );
+  myListWidget->setMinimumWidth(300);
+  myInfoLabel->setMinimumWidth(300);
+  myInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+  myInfoLabel->setAlignment(Qt::AlignCenter);
 
   mySubShType = aSubShType;
 
@@ -171,6 +179,8 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
 
   connect( myAddButton,    SIGNAL(clicked()), SLOT(onAdd()));
   connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
+  connect( myPrevButton,   SIGNAL(clicked()), SLOT(onPrevious()));
+  connect( myNextButton,   SIGNAL(clicked()), SLOT(onNext()));
   
   connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   connect( myListWidget,   SIGNAL(itemSelectionChanged()),    this, SLOT(onListSelectionChanged()));
@@ -296,6 +306,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
   myAddButton->setEnabled( ( myListWidget->count() < myMaxSize || myMaxSize == -1 ) && mySelectedIDs.size() > 0 && ( mySelectedIDs.size() <= myMaxSize || myMaxSize == -1 ) );
 
   //Connect Selected Ids in viewer and dialog's Ids list
+  bool signalsBlocked = myListWidget->blockSignals( true );
   myListWidget->clearSelection();
   if ( mySelectedIDs.size() > 0 ) {
     for (int i = 0; i < mySelectedIDs.size(); i++) {
@@ -306,6 +317,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
         item->setSelected(true);
     }
   }
+  myListWidget->blockSignals( signalsBlocked );
 }
 
 //=================================================================================
@@ -360,6 +372,28 @@ void StdMeshersGUI_SubShapeSelectorWdg::onRemove()
   myAddButton->setEnabled( true );
 }
 
+void StdMeshersGUI_SubShapeSelectorWdg::onPrevious()
+{
+  if ( myPreviewActor ) {
+    myPreviewActor->previous();
+    myListWidget->clearSelection();
+    updateButtons();
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->Repaint();
+  }
+}
+
+void StdMeshersGUI_SubShapeSelectorWdg::onNext()
+{
+  if ( myPreviewActor ) {
+    myPreviewActor->next();
+    myListWidget->clearSelection();
+    updateButtons();
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->Repaint();
+  }
+}
+
 //=================================================================================
 // function : onListSelectionChanged()
 // purpose  : Called when selection in element list is changed
@@ -404,6 +438,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
   bool state = false;
   if ( !myGeomShape.IsNull() )
     state = true;
+  myInfoLabel->setVisible( false );
+  myPrevButton->setVisible( false );
+  myNextButton->setVisible( false );
   
   myListWidget->setEnabled( state );
   myAddButton->setEnabled( mySelectedIDs.size() > 0 );
@@ -419,6 +456,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
       myPreviewActor->AddToRender( myRenderer );
       aViewWindow->Repaint();
     }
+    updateButtons();
   }
 }
 
@@ -552,3 +590,21 @@ QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSu
 
   return aList;
 }
+
+void StdMeshersGUI_SubShapeSelectorWdg::updateButtons()
+{
+  if ( myPreviewActor ) {
+    int total = myPreviewActor->count();
+    int chunk = myPreviewActor->currentChunk();
+    int chunkSize = myPreviewActor->chunkSize();
+    int imin = chunk*chunkSize+1;
+    int imax = std::min((chunk+1)*chunkSize, total);
+    bool vis = imax > 0 && total > chunkSize;
+    myInfoLabel->setVisible( vis );
+    myPrevButton->setVisible( vis );
+    myNextButton->setVisible( vis );
+    myInfoLabel->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg(imin).arg(imax).arg(total) );
+    myPrevButton->setEnabled( myPreviewActor->hasPrevious() );
+    myNextButton->setEnabled( myPreviewActor->hasNext() );
+  }
+}
index 2cc304ff207b6139559b4f8f9e35614e573fbf4e..897b873fd57fa59941374a0d133821f008475fe0 100644 (file)
@@ -39,6 +39,7 @@ class SMESHGUI;
 class LightApp_SelectionMgr;
 class SVTK_Selector;
 class QPushButton;
+class QLabel;
 class QLineEdit;
 class QCheckBox;
 class QListWidget;
@@ -85,10 +86,13 @@ public:
 private:
   void                           updateState();
   void                           setFilter();
+  void                           updateButtons();
 
 private slots:
   void                           onAdd(); 
   void                           onRemove(); 
+  void                           onPrevious(); 
+  void                           onNext(); 
   void                           SelectionIntoArgument();
   void                           onListSelectionChanged();
 
@@ -109,6 +113,9 @@ private:
   QListWidget*                   myListWidget;
   QPushButton*                   myAddButton;
   QPushButton*                   myRemoveButton;
+  QLabel*                        myInfoLabel;
+  QPushButton*                   myPrevButton;
+  QPushButton*                   myNextButton;
   QList<int>                     mySelectedIDs;
   QList<int>                     myListOfIDs;