]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
sinusX p.4
authorisn <isn@opencascade.com>
Wed, 17 Jun 2015 11:19:48 +0000 (14:19 +0300)
committerisn <isn@opencascade.com>
Wed, 17 Jun 2015 11:19:48 +0000 (14:19 +0300)
src/HYDROData/HYDROData_SinusX.cxx
src/HYDROData/HYDROData_SinusX.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 5c0c6f5a9fbecd8fd4359515325d64a7fc2a3699..da8e48b1fdf9366ce1d0e08fcff78b5e6b34afd9 100644 (file)
@@ -27,6 +27,7 @@
 #include <HYDROData_Entity.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Profile.h>
+#include <HYDROData_Iterator.h>
 
 #include <gp_XYZ.hxx>
 #include <gp_XY.hxx>
@@ -44,6 +45,50 @@ HYDROData_SinusX::~HYDROData_SinusX()
 {
 }
 
+void HYDROData_SinusX::CollectExistingNames(Handle_HYDROData_Document theDocument)
+{
+  HYDROData_Iterator anIter( theDocument );
+  int anInd = 0;
+  myExistingNames.clear();
+  std::vector<int> anAllowedIndexes;
+  for( ; anIter.More(); anIter.Next() )
+    myExistingNames.push_back(anIter.Current()->GetName());
+}
+
+QString HYDROData_SinusX::GetName(const QString& theName)
+{
+  if (myExistingNames.contains(theName))
+  { 
+    QString aName = theName; 
+    while (myExistingNames.contains(aName)) 
+    {
+      QStringList aList = aName.split("_");
+      int aLastInd = aName.lastIndexOf("_");
+      bool IsNum = false; 
+      int anInd = -1;
+      anInd = aList.last().toInt(&IsNum);
+      if (IsNum)
+      {
+        aName = aName.left(aLastInd) + "_";
+        /*for (int i = 0; i < aList.size() - 1; i++ )
+          aName += aList[i];*/
+        aName+= QString::number(++anInd);
+      }
+      else
+        aName = theName + "_0";
+    }
+
+    myExistingNames.push_back(aName);
+    return aName;
+  }
+  else
+  {
+    myExistingNames.push_back(theName);
+    return theName;
+  }
+
+}
+
 
 bool HYDROData_SinusX::Import(const QString& theFilePath, Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
 {
@@ -62,6 +107,7 @@ bool HYDROData_SinusX::Import(const QString& theFilePath, Handle(HYDROData_Docum
 
     Parse(aFile);
    
+    CollectExistingNames(theDocument);
     SXToHydro(theDocument, theEntities);
     
     aFile.close();
@@ -85,7 +131,7 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
         aAPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
 
       aBath->SetAltitudePoints(aAPoints);
-      aBath->SetName(myCurveBlocks[i].myName);
+      aBath->SetName(GetName(myCurveBlocks[i].myName + "_bath"));
       theEntities.Append(aBath);
     }
     if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3)
@@ -101,9 +147,9 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
       aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY);
       Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
       aProfile->SetParametricPoints(aProfileUZ->GetPoints());
-      aPolyXY->SetName(myCurveBlocks[i].myName + "_polyXY");
-      aProfileUZ->SetName(myCurveBlocks[i].myName + "_profileUZ");
-      aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+      aPolyXY->SetName(GetName(myCurveBlocks[i].myName + "_polyXY"));
+      aProfileUZ->SetName(GetName(myCurveBlocks[i].myName + "_profileUZ"));
+      aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
       theEntities.Append(aPolyXY);
       theEntities.Append(aProfileUZ);
       theEntities.Append(aProfile);
@@ -127,7 +173,7 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
             aProfile->SetRightPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[2], myCurveBlocks[i].myAdditionalCurveInfo[3]));
             aProfile->Update();
           }
-          aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+          aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
           theEntities.Append(aProfile);
         }
       }
@@ -138,7 +184,7 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
         for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
           aPointList.Append(myCurveBlocks[i].myXYZPoints[j]);
         aProfile->SetProfilePoints(aPointList);
-        aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+        aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
         theEntities.Append(aProfile);
       }
     }
@@ -147,8 +193,6 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec
 }
  
 
-
-
 bool HYDROData_SinusX::Parse(QFile& theFile)
 {
   if ( !theFile.isOpen() )
index 0d8e9e15803792a3df16015d06f978d8934a8efe..cc743d71cfafd6f2eba2254cd0aecc71ab84d73f 100644 (file)
 #include <HYDROData.h>
 #include <NCollection_Sequence.hxx>
 #include <QString>
+#include <QStringList>
 
 class QFile;
 class gp_XYZ;
-//class QString;
 class Handle_HYDROData_Entity;
 class Handle_HYDROData_Document;
 
@@ -59,9 +59,12 @@ public:
 private:
   void SXToHydro(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
   bool Parse( QFile& theFile );
+  void CollectExistingNames(Handle_HYDROData_Document theDocument);
+  QString GetName(const QString& theName);
 private:
 
   std::vector<HYDROGUI_CurveBlock> myCurveBlocks;
+  QStringList myExistingNames;
 };
 
 #endif
index a91b6064cea949169c903b77f421c2398a428cec..f251d775d75e1a873ee8b218526fa4f3479de596 100644 (file)
@@ -908,7 +908,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>DSK_IMPORT_SINUSX</source>
-      <translation>Import entities from SinusX file</translation>
+      <translation>Import from SinusX</translation>
     </message>
     <message>
       <source>DSK_LOAD_VISUAL_STATE</source>
@@ -1200,7 +1200,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>MEN_IMPORT_SINUSX</source>
-      <translation>Import entities from SinusX file</translation>
+      <translation>Import from SinusX</translation>
     </message>
     <message>
       <source>MEN_LOAD_VISUAL_STATE</source>
@@ -1469,7 +1469,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>STB_IMPORT_SINUSX</source>
-      <translation>Import entities from SinusX file</translation>
+      <translation>Import from SinusX</translation>
     </message>
     <message>
       <source>STB_LOAD_VISUAL_STATE</source>
@@ -2122,7 +2122,7 @@ file cannot be correctly imported for an Obstacle definition.</translation>
     <name>HYDROGUI_ImportSinusXOp</name>
     <message>
       <source>IMPORT_SINUSX</source>
-      <translation>Import entities from SinusX file</translation>
+      <translation>Import from SinusX</translation>
     </message>
     <message>
       <source>SINUSX_FILTER</source>