]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Delition of objects (Feature #90).
authoradv <adv@opencascade.com>
Wed, 4 Dec 2013 05:42:26 +0000 (05:42 +0000)
committeradv <adv@opencascade.com>
Wed, 4 Dec 2013 05:42:26 +0000 (05:42 +0000)
24 files changed:
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Image.cxx
src/HYDROData/HYDROData_Image.h
src/HYDROData/HYDROData_ImmersibleZone.cxx
src/HYDROData/HYDROData_ImmersibleZone.h
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Polyline3D.cxx
src/HYDROData/HYDROData_Polyline3D.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROData/HYDROData_Zone.cxx
src/HYDROData/HYDROData_Zone.h
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 3441d309b83d1d5a41c56415ee27cff13b20274c..9d556eca30d79ac37b94d87906e76dcfd85d7ef8 100644 (file)
@@ -129,6 +129,13 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre
   return aResList;
 }
 
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+  aResSeq.Append( GetRegions() );
+  return aResSeq;
+}
+
 void HYDROData_CalculationCase::SplitGeometryObjects()
 {
   // At first we remove previously created regions
index 12e0704a341a73ac3c28d4574549d903f92ba4d0..83d75bbeab969b72f10f63a9f6982b7d3d580b40 100644 (file)
@@ -56,6 +56,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
 public:      
   // Public methods to work with Calculation
 
index 40c496aa61520c5b4b15dc4c608f8ebef14a4bec..3aab98b5ac6ea61db8394bc8904aa6fbefc5ddab 100644 (file)
@@ -47,6 +47,21 @@ QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObje
   return aResList;
 }
 
+HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
+
+  Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
+  if ( !aGuideLine.IsNull() )
+    aResSeq.Append( aGuideLine );
+
+  Handle(HYDROData_Profile) aProfile = GetProfile();
+  if ( !aProfile.IsNull() )
+    aResSeq.Append( aProfile );
+
+  return aResSeq;
+}
+
 TopoDS_Shape HYDROData_Channel::GetTopShape() const
 {
   return getTopShape();
index c1aea49c7c416158b74a188f9f2c78dc2b454ea4..8ffa76a7bcab1184692394120b3575a922691905 100644 (file)
@@ -39,6 +39,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
   /**
    * Returns the top shape of the object.
    */
index f8238ec656dbde367949cbcb1104f7ec09497f40..015cb0f7e17d73c4782107a1c3d8e6fa943e272a 100644 (file)
@@ -89,6 +89,11 @@ void HYDROData_Entity::Remove()
   return myLab.ForgetAllAttributes( true );
 }
 
+bool HYDROData_Entity::CanRemove()
+{
+  return true;
+}
+
 HYDROData_Entity::HYDROData_Entity()
 {
 }
@@ -121,6 +126,11 @@ Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
   return aFather;
 }
 
+HYDROData_SequenceOfObjects HYDROData_Entity::GetAllReferenceObjects() const
+{
+  return HYDROData_SequenceOfObjects();
+}
+
 void HYDROData_Entity::SetLabel(TDF_Label theLabel)
 {
   myLab = theLabel;
index 02c191160873fe31ca2403e308454bd86f5987f6..dd067a187fa9de588ed177378ccdcf5b38248052 100644 (file)
@@ -131,6 +131,14 @@ public:
    */
   HYDRODATA_EXPORT virtual void Remove();
 
+  /**
+   * Returns flag indicating that object can be removed or not.
+   * Reimplement this method in class which can't be removed 
+   * separately with it parent object.
+   * Base implementaiton returns always TRUE.
+   */
+  HYDRODATA_EXPORT virtual bool CanRemove();
+
   /**
    * Returns unique integer identifier of the object (may be used for ordering of objects)
    */
@@ -148,12 +156,21 @@ public:
    */
   HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
 
+
   /**
    * Returns father object. For object created under root document label
    * this method always return NULL object.
    */
   HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
 
+
+  /**
+   * Returns the list of all reference objects of this object.
+   * Base implementation always return empty list.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+
 protected:
 
   friend class HYDROData_Iterator;
index 58d86ccc99f736aab8d14d547af3d90f8ae8f3de..082f160ced1d4eaade67c4c5015cb664f1091b6f 100644 (file)
@@ -218,6 +218,19 @@ QVariant HYDROData_Image::GetDataVariant()
   return aVarData;
 }
 
+HYDROData_SequenceOfObjects HYDROData_Image::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+  Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
+  if ( !aRefImage.IsNull() )
+    aResSeq.Append( aRefImage );
+
+  aResSeq.Append( GetReferenceObjects( 0 ) );
+
+  return aResSeq;
+}
+
 void HYDROData_Image::SetImage(const QImage& theImage)
 {
   if (theImage.isNull()) {
index 633edbe8cc879a3ed5476cee61d3391f9534f00d..66193e016b8e545f9a9d6e11986f841862584711 100644 (file)
@@ -69,6 +69,12 @@ public:
    */
   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+
   /**
    * Stores the image
    * \param theImage new image
index 4ebe9772405b0e9b7857901949f26649a94dcc52..cf4375de071ad75da5cab1d645d7a8bd9077c740 100644 (file)
@@ -75,6 +75,17 @@ QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTrea
   return aResList;
 }
 
+HYDROData_SequenceOfObjects HYDROData_ImmersibleZone::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_NaturalObject::GetAllReferenceObjects();
+
+  Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
+  if ( !aRefPolyline.IsNull() )
+    aResSeq.Append( aRefPolyline );
+
+  return aResSeq;
+}
+
 TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const
 {
   TopoDS_Shape aResShape = TopoDS_Face();
index 04616f48f923d6a430f395fba570b89b7a72262a..f7111a37960632d1aaa5c48fd07e4a20a275a1d6 100644 (file)
@@ -37,6 +37,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
   /**
    * Returns the top shape of the object.
    */
index f8c514b3a86f9a7690bb0896154d0347e0ebe6f9..e8477db6e038bdba58fe79b27ce1f76fb496d972 100644 (file)
@@ -22,6 +22,17 @@ HYDROData_Object::~HYDROData_Object()
 {
 }
 
+HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+  Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
+  if ( !aRefBathymetry.IsNull() )
+    aResSeq.Append( aRefBathymetry );
+
+  return aResSeq;
+}
+
 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
 {
   TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
index 0fcd138480fb330c2a545fc40b2b0465bc273732..053a39e4a808f65c234cc946e45fa929def83499 100644 (file)
@@ -33,6 +33,18 @@ protected:
 public:
   DEFINE_STANDARD_RTTI(HYDROData_Object);
 
+  /**
+   * Update the geometry object.
+   * Call this method whenever you made changes for object data.
+   */
+  HYDRODATA_EXPORT virtual void Update();
+
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+
   /**
    * Sets the top(2d projection) shape of the object.
    */
@@ -54,13 +66,6 @@ public:
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const = 0;
 
   
-  /**
-   * Update the geometry object.
-   * Call this method whenever you made changes for object data.
-   */
-  HYDRODATA_EXPORT virtual void Update();
-
-
   /**
    * Set reference bathymetry object for geometry object.
    */
index 89f3be36c6299af77a9da7d67116c378df7be401..cf41020e6ef39a5d0b8907b33b069cdd4049ee8d 100644 (file)
@@ -50,6 +50,21 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO
   return aResList;
 }
 
+HYDROData_SequenceOfObjects HYDROData_Polyline3D::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
+
+  Handle(HYDROData_PolylineXY) aPolylineXY = GetPolylineXY();
+  if ( !aPolylineXY.IsNull() )
+    aResSeq.Append( aPolylineXY );
+
+  Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
+  if ( !aProfileUZ.IsNull() )
+    aResSeq.Append( aProfileUZ );
+
+  return aResSeq;
+}
+
 TopoDS_Shape HYDROData_Polyline3D::GetTopShape() const
 {
   return getTopShape();
index 73f21cbb8edc2ffced754e977156fdb7e432d881..67e93e20f9e147e76d6898174466f722fdbc8dfc 100644 (file)
@@ -45,6 +45,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
   /**
    * Returns the top shape of the object.
    */
index 090171f9e8b09619801de27ad7976baa15c1c306..d86d64c1f52c1e80c0f97e2b669a1c8103bfcb54 100644 (file)
@@ -77,6 +77,18 @@ void HYDROData_Region::Remove()
     aFatherCalc->UpdateRegionsOrder();
 }
 
+bool HYDROData_Region::CanRemove()
+{
+  return false;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Region::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+  aResSeq.Append( GetZones() );
+  return aResSeq;
+}
+
 bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
 {
   if ( theZone.IsNull() )
index cfaf931f7d6a494814d26c2ef361d7c007f93b11..e6769ebe9188dbff6302931f34633ee447cdf4db 100644 (file)
@@ -49,6 +49,16 @@ public:
    */
   HYDRODATA_EXPORT virtual void Remove();
 
+  /**
+   * Returns flag indicating that object can be removed or not.
+   */
+  HYDRODATA_EXPORT virtual bool CanRemove();
+
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
 
   /**
    * Add new one reference zone for region.
index 19c9900abfbbaa0302b98c833ccf8b73a28ec008..19362261adbc3963ffc363fb64861f4b99a13a2d 100644 (file)
@@ -54,6 +54,19 @@ QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjec
   return aResList;
 }
 
+HYDROData_SequenceOfObjects HYDROData_Stream::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
+
+  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+  if ( !aHydAxis.IsNull() )
+    aResSeq.Append( aHydAxis );
+
+  aResSeq.Append( GetProfiles() );
+
+  return aResSeq;
+}
+
 TopoDS_Shape HYDROData_Stream::GetTopShape() const
 {
   return getTopShape();
index c65e319360abf23e2ccc34a5666efdf3041b106e..ce9eb426555f1d6c6e3f7a704019d767fedc8cbe 100644 (file)
@@ -39,6 +39,11 @@ public:
    */
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
   /**
    * Returns the top shape of the object.
    */
index fdbf91b082aad2b50bae545cf3cd9c9190f895c8..a33c0ab46ecf576c8aaa1caa64fbc02bd2bc45f3 100644 (file)
@@ -63,6 +63,18 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects
   return aResList;
 }
 
+bool HYDROData_Zone::CanRemove()
+{
+  return false;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+  aResSeq.Append( GetGeometryObjects() );
+  return aResSeq;
+}
+
 void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
 {
   TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
index c0472ea79906d6789cf1a9f6a1d658129750fd57..610b3e1881d4f6a1b9c8cfecc9d38af1694a2718 100644 (file)
@@ -55,6 +55,17 @@ public:
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
 
+  /**
+   * Returns flag indicating that object can be removed or not.
+   */
+  HYDRODATA_EXPORT virtual bool CanRemove();
+
+  /**
+   * Returns the list of all reference objects of this object.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+
   /**
    * Sets the shape of the zone.
    */
index deb1542d37a5bac138f982ac19b3bdc2bd436395..f7534146b158ff6574618747c28d9b8718efc00e 100644 (file)
@@ -47,56 +47,75 @@ void HYDROGUI_DeleteOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  HYDROData_SequenceOfObjects aFullSeq; // selected objects with their back-references
-  QStringList aFullNames;
-
   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
-  if( !aSeq.IsEmpty() )
+  if( aSeq.IsEmpty() )
   {
-    for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
-    {
-      Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
-      if( !anObject.IsNull() )
-      {
-        aFullSeq.Append( anObject );
-        aFullNames.append( anObject->GetName() );
-
-        // collect the back-references
-        ObjectKind aKind = anObject->GetKind();
-        if( aKind == KIND_IMAGE || aKind == KIND_POLYLINEXY )
-        {
-          HYDROData_SequenceOfObjects anObjects;
-          QStringList aNames;
-          HYDROGUI_Tool::GetObjectBackReferences( module(), anObject, anObjects, aNames );
-          aFullSeq.Append( anObjects );
-          aFullNames.append( aNames );
-        }
-      }
-    }
+    abort();
+    return;
+  }
+
+  bool anIsCanRemove = true;
 
-    aFullNames.removeDuplicates();
-    aFullNames.sort();
+  QStringList anObjNames;
+  for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+  {
+    Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+    if( anObject.IsNull() )
+      continue;
 
-    QString aList = aFullNames.join( "\n" );
-    int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
-                                              tr( "DELETE_OBJECTS" ),
-                                              tr( "CONFIRM_DELETION" ).arg( aList ),
-                                              QMessageBox::Yes | QMessageBox::No,
-                                              QMessageBox::No );
-    if( anAnswer == QMessageBox::No )
+    if ( !anObject->CanRemove() )
     {
-      abort();
-      return;
+      anIsCanRemove = false;
+      break;
     }
+
+    anObjNames.append( anObject->GetName() );
+  }
+
+  if ( !anIsCanRemove )
+  {
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "DELETE_OBJECTS" ), tr( "DELETE_OBJECTS_IMPOSIBLE" ) );
+    abort();
+    return;
+  }
+
+  anObjNames.removeDuplicates();
+  anObjNames.sort();
+
+  // check the back-references
+  QMap<QString,HYDROData_SequenceOfObjects> aBackObjects =
+    HYDROGUI_Tool::GetObjectsBackReferences( module(), anObjNames );
+
+  if ( !aBackObjects.isEmpty() )
+  {
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "DELETE_OBJECTS" ), tr( "DELETED_OBJECTS_HAS_BACKREFERENCES" ) );
+    abort();
+    return;
+  }
+
+  QString aNamesList = anObjNames.join( "\n" );
+  int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
+                                            tr( "DELETE_OBJECTS" ),
+                                            tr( "CONFIRM_DELETION" ).arg( aNamesList ),
+                                            QMessageBox::Yes | QMessageBox::No,
+                                            QMessageBox::No );
+  if( anAnswer == QMessageBox::No )
+  {
+    abort();
+    return;
   }
 
   startDocOperation();
-  for( Standard_Integer anIndex = 1, aLength = aFullSeq.Length(); anIndex <= aLength; anIndex++ )
+
+  for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Entity) anObject = aFullSeq.Value( anIndex );
-    if( !anObject.IsNull() && !anObject->IsRemoved() )
+    Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+    if ( !anObject.IsNull() && !anObject->IsRemoved() )
       anObject->Remove();
   }
+
   commitDocOperation();
 
   module()->update( UF_Model | UF_Viewer | UF_OCCViewer );
index 007e855f6bbab0b7276915c588995065ece06b44..ce0d25b3dd6a7363bd1b8b2dec0061f283aa7995 100644 (file)
@@ -501,66 +501,88 @@ void HYDROGUI_Tool::setOCCActionShown( HYDROGUI_Module* theModule,
   }
 }
 
-void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
+void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Entity)& theObj,
                                          HYDROData_SequenceOfObjects& theRefObjects,
                                          QStringList& theRefNames )
 {
-  if( theImage.IsNull() )
+  if( theObj.IsNull() )
     return;
 
-  for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
+  HYDROData_SequenceOfObjects anAllRefObjects = theObj->GetAllReferenceObjects();
+  theRefObjects.Append( anAllRefObjects );
+
+  for( int i = 1, n = anAllRefObjects.Length(); i <= n; ++i )
   {
-    Handle(HYDROData_Entity) aRefObj = theImage->Reference( anIndex );
-    if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
-    {
-      QString aName = aRefObj->GetName();
-      if( !theRefNames.contains( aName ) )
-      {
-        theRefObjects.Append( aRefObj );
-        theRefNames.append( aRefObj->GetName() );
-        if( aRefObj->GetKind() == KIND_IMAGE )
-        {
-          Handle(HYDROData_Image) aRefImage = Handle(HYDROData_Image)::DownCast( aRefObj );
-          if( !aRefImage.IsNull() )
-            GetObjectReferences( aRefImage, theRefObjects, theRefNames );
-        }
-      }
-    }
+    Handle(HYDROData_Entity) aRefObj = theRefObjects.Value( i );
+    if( aRefObj.IsNull() || aRefObj->IsRemoved() )
+      continue;
+
+    QString aRefObjectName = aRefObj->GetName();
+    if( theRefNames.contains( aRefObjectName ) )
+      continue;
+
+    theRefObjects.Append( aRefObj );
+    theRefNames.append( aRefObjectName );
+
+    GetObjectReferences( aRefObj, theRefObjects, theRefNames );
   }
 }
 
-void HYDROGUI_Tool::GetObjectBackReferences( HYDROGUI_Module* theModule,
-                                             const Handle(HYDROData_Entity)& theObj,
-                                             HYDROData_SequenceOfObjects& theBackRefObjects,
-                                             QStringList& theBackRefNames )
+HYDROData_SequenceOfObjects HYDROGUI_Tool::GetObjectBackReferences( 
+  HYDROGUI_Module*                theModule,
+  const Handle(HYDROData_Entity)& theObj )
 {
   if( theObj.IsNull() )
-    return;
+    return HYDROData_SequenceOfObjects();
+
+  QString anObjName = theObj->GetName();
+
+  QMap<QString,HYDROData_SequenceOfObjects> aMapOfBackRefs =
+    GetObjectsBackReferences( theModule, QStringList() << anObjName );
+
+  return aMapOfBackRefs[ anObjName ];
+}
+
+QMap<QString,HYDROData_SequenceOfObjects> HYDROGUI_Tool::GetObjectsBackReferences(
+  HYDROGUI_Module*   theModule, const QStringList& theObjectNames )
+{
+  QMap<QString,HYDROData_SequenceOfObjects> aResMap;
+
+  if( theObjectNames.isEmpty() )
+    return aResMap;
 
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
   if( aDocument.IsNull() )
-    return;
-
-  QString aName = theObj->GetName();
+    return aResMap;
 
-  HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
+  HYDROData_Iterator anIterator( aDocument );
   for( ; anIterator.More(); anIterator.Next() )
   {
-    Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
-    if( !anImage.IsNull() )
+    Handle(HYDROData_Entity) anObject = anIterator.Current();
+    if( anObject.IsNull() || anObject->IsRemoved() )
+      continue;
+
+    QString anObjectName = anObject->GetName();
+    if ( theObjectNames.contains( anObjectName ) )
+      continue;
+
+    HYDROData_SequenceOfObjects aRefObjects = anObject->GetAllReferenceObjects();
+    for ( int i = 1, n = aRefObjects.Length(); i <= n; ++i )
     {
-      HYDROData_SequenceOfObjects aRefObjects;
-      QStringList aRefNames;
-      GetObjectReferences( anImage, aRefObjects, aRefNames );
-      if( aRefNames.contains( aName ) )
-      {
-        theBackRefObjects.Append( anImage );
-        theBackRefNames.append( anImage->GetName() );
-      }
+      Handle(HYDROData_Entity) aRefObject = aRefObjects.Value( i );
+      if( aRefObject.IsNull() || aRefObject->IsRemoved() )
+        continue;
+
+      QString aRefObjectName = aRefObject->GetName();
+      if ( !theObjectNames.contains( aRefObjectName ) )
+        continue;
+
+      aResMap[ aRefObjectName ].Append( anObject );
     }
   }
-}
 
+  return aResMap;
+}
 
 QDockWidget* HYDROGUI_Tool::WindowDock( QWidget* wid )
 {
index 18a3d587e4df9c2034c03cffbc23543d192cf73b..48c8e246dcc0903ae4a20fc2613475074777760b 100644 (file)
@@ -262,12 +262,12 @@ public:
                                                      const bool isShown );
 
   /**
-   * \brief Get the list of references (recursively) for the specified image object
-   * \param theImage image data object
+   * \brief Get the list of references (recursively) for the specified data object
+   * \param theObj data object
    * \param theRefObjects list of reference objects
    * \param theRefNames list of reference object names
    */
-  static void                     GetObjectReferences( const Handle(HYDROData_Image)& theImage,
+  static void                     GetObjectReferences( const Handle(HYDROData_Entity)& theObj,
                                                        HYDROData_SequenceOfObjects& theRefObjects,
                                                        QStringList& theRefNames );
 
@@ -275,13 +275,19 @@ public:
    * \brief Get the list of back-references for the specified object
    * \param theModule module
    * \param theObj data object
-   * \param theBackRefObjects list of back-reference objects
-   * \param theBackRefNames list of back-reference object names
+   * \return list of back-reference objects
+   */
+  static HYDROData_SequenceOfObjects GetObjectBackReferences( HYDROGUI_Module*                theModule,
+                                                              const Handle(HYDROData_Entity)& theObj );
+
+  /**
+   * \brief Get the map of back-references for the specified list of objects
+   * \param theModule module
+   * \param theObjectNames names of objects
+   * \return map of back-reference objects
    */
-  static void                     GetObjectBackReferences( HYDROGUI_Module* theModule,
-                                                           const Handle(HYDROData_Entity)& theObj,
-                                                           HYDROData_SequenceOfObjects& theBackRefObjects,
-                                                           QStringList& theBackRefNames );
+  static QMap<QString,HYDROData_SequenceOfObjects> GetObjectsBackReferences( HYDROGUI_Module*   theModule,
+                                                                             const QStringList& theObjectNames );
 
   /**
    * \brief Get father dock window for widget 
index ab30bf095c1a96ccde0294f4bd78de9a73bc4052..0f4dd7e08276070fe3c10efe97c93218b48984cf 100644 (file)
@@ -271,9 +271,17 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
     </message>
     <message>
       <source>CONFIRM_DELETION</source>
-      <translation>The following objects (including the dependencies) will be deleted:
-%1
-Do you want to continue?</translation>
+      <translation>Do you really want to delete following objects:
+%1 ?</translation>
+    </message>
+    <message>
+      <source>DELETE_OBJECTS_IMPOSIBLE</source>
+      <translation>One or more selected objects can not be deleted separately from parent object.</translation>
+    </message>
+    <message>
+      <source>DELETED_OBJECTS_HAS_BACKREFERENCES</source>
+      <translation>One or more selected objects are used to create another ones.
+First remove objects which are created on their basis.</translation>
     </message>
   </context>