]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PAL13473 (Build repetitive mesh):
authoreap <eap@opencascade.com>
Thu, 7 Dec 2006 08:29:52 +0000 (08:29 +0000)
committereap <eap@opencascade.com>
Thu, 7 Dec 2006 08:29:52 +0000 (08:29 +0000)
an arg added to constructor of SMESH_subMeshEventListener

src/SMESH/SMESH_subMesh.cxx
src/SMESH/SMESH_subMeshEventListener.hxx
src/StdMeshers/StdMeshers_Projection_1D.cxx
src/StdMeshers/StdMeshers_Projection_2D.cxx
src/StdMeshers/StdMeshers_Projection_3D.cxx

index d47ab027c4118b938f50ac8d9aff9e875b809cfc..1701da6004a47fcf9e387284de9445bea1e4eb65 100644 (file)
@@ -1491,12 +1491,12 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
     break;
   }
 
-  if ( _algoState != oldAlgoState )
+  if ( _algoState != oldAlgoState || event == MODIF_HYP )
   {
-    if (_algoState == HYP_OK && algo )
-      algo->SetEventListener( this );
     if ( oldAlgoState == HYP_OK )
       DeleteOwnListeners();
+    if (_algoState == HYP_OK && algo )
+      algo->SetEventListener( this );
   }
   NotifyListenersOnEvent( event, COMPUTE_EVENT );
 
@@ -1883,8 +1883,8 @@ void SMESH_subMesh::DeleteEventListener(EventListener* listener)
   map< EventListener*, EventListenerData* >::iterator l_d =
     myEventListeners.find( listener );
   if ( l_d != myEventListeners.end() ) {
-    delete l_d->first;
-    delete l_d->second;
+    if ( l_d->first->IsDeletable() ) delete l_d->first;
+    if ( l_d->second->IsDeletable() ) delete l_d->second;
     myEventListeners.erase( l_d );
   }
 }
index 66543cf7d9912f6316aa81a2e2ecd186e8ccb5ab..f8a5fc4be834ec68ef57077f1aa2b5c6469fa978 100644 (file)
@@ -42,7 +42,10 @@ struct SMESH_subMeshEventListenerData;
 // ------------------------------------------------------------------
 
 class SMESH_subMeshEventListener {
+  bool myIsDeletable; //!< if true, it will be deleted by SMESH_subMesh
 public:
+  SMESH_subMeshEventListener(bool isDeletable):myIsDeletable(isDeletable) {}
+  bool IsDeletable() const { return myIsDeletable; }
   /*!
    * \brief Do something on a certain event
    * \param event - algo_event or compute_event itself (of SMESH_subMesh)
@@ -69,11 +72,13 @@ public:
 
 struct SMESH_subMeshEventListenerData
 {
-  //!< to recognize data type
-  int myType;
-  //!< generally: submeshes depending on the one storing this data
-  std::list<SMESH_subMesh*> mySubMeshes;
- //!< subMesh where data
+  bool myIsDeletable; //!< if true, it will be deleted by SMESH_subMesh
+  int myType;         //!< to recognize data type
+  std::list<SMESH_subMesh*> mySubMeshes; //!< generally: submeshes depending
+                                         // on the one storing this data
+public:
+  SMESH_subMeshEventListenerData(bool isDeletable):myIsDeletable(isDeletable) {}
+  bool IsDeletable() const { return myIsDeletable; }
 
   /*!
    * \brief Create a default listener data.
@@ -82,12 +87,12 @@ struct SMESH_subMeshEventListenerData
    * \retval SMESH_subMeshEventListenerData* - a new listener data
    *
    * See SMESH_subMeshEventListener::ProcessEvent() to know how the default
-   * listener uses it
+   * listener uses it (implementation is in SMESH_subMesh.cxx)
    */
   static SMESH_subMeshEventListenerData* MakeData(SMESH_subMesh* dependentSM,
                                                   const int      type = 0)
   {
-    SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData;
+    SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData(true);
     data->mySubMeshes.push_back( dependentSM );
     data->myType = type;
     return data;
index acf89664b1a2b2bcc3a3d913c48cfa0291385d32..bde70d3950a11fb030a22225e968db9cc7a327b6 100644 (file)
@@ -354,7 +354,7 @@ void StdMeshers_Projection_1D::SetEventListener(SMESH_subMesh* subMesh)
       srcMesh->GetSubMesh( _sourceHypo->GetSourceEdge() );
 
     if ( srcEdgeSM != subMesh )
-      subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+      subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
                                  SMESH_subMeshEventListenerData::MakeData( subMesh ),
                                  srcEdgeSM );
   }
index 5e10f6d0779d5e92c1f41544d2913b594e0275c1..36f4a3b5448da2131cb68cadb8826ef968a5e7e7 100644 (file)
@@ -631,7 +631,7 @@ void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh)
     SMESH_subMesh* srcFaceSM =
       srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() );
 
-    subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+    subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
                                SMESH_subMeshEventListenerData::MakeData( subMesh ),
                                srcFaceSM );
   }
index 44b4395f4c7f773d86b9ad0e488014f049c5f20d..241ff7670c79096f8431f5eb7d30106e923cf793 100644 (file)
@@ -430,7 +430,7 @@ void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh)
       srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
 
     if ( srcShapeSM != subMesh )
-      subMesh->SetEventListener( new SMESH_subMeshEventListener(),
+      subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
                                  SMESH_subMeshEventListenerData::MakeData( subMesh ),
                                  srcShapeSM );
   }