From: isn Date: Wed, 17 Jun 2015 11:19:48 +0000 (+0300) Subject: small corrections X-Git-Tag: v1.4.2~54^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=973a3c11ac0584373fcb01410140954b553ebd8b;p=modules%2Fhydro.git small corrections --- diff --git a/src/HYDROData/HYDROData_SinusX.cxx b/src/HYDROData/HYDROData_SinusX.cxx index 5c0c6f5a..bca60482 100644 --- a/src/HYDROData/HYDROData_SinusX.cxx +++ b/src/HYDROData/HYDROData_SinusX.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,48 @@ HYDROData_SinusX::~HYDROData_SinusX() { } +void HYDROData_SinusX::CollectExistingNames(Handle_HYDROData_Document theDocument) +{ + HYDROData_Iterator anIter( theDocument ); + int anInd = 0; + myExistingNames.clear(); + std::vector 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) + "_"; + 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& theEntities) { @@ -62,6 +105,7 @@ bool HYDROData_SinusX::Import(const QString& theFilePath, Handle(HYDROData_Docum Parse(aFile); + CollectExistingNames(theDocument); SXToHydro(theDocument, theEntities); aFile.close(); @@ -85,7 +129,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) @@ -93,17 +137,19 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec NCollection_Sequence aPoints; for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++) aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j])); - if (myCurveBlocks[i].myIsClosed) - aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[0])); + /*if (myCurveBlocks[i].myIsClosed) + aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[0]));*/ Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( theDocument->CreateObject( KIND_PROFILEUZ ) ); Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) ); - aPolyXY->AddSection( "", myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, false ); + aPolyXY->AddSection( "", + myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, + myCurveBlocks[i].myIsClosed ? true : false); 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); @@ -118,7 +164,8 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec HYDROData_ProfileUZ::PointsList aPointList; for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++) aPointList.Append(gp_XY (myCurveBlocks[i].myXYZPoints[j].X(), myCurveBlocks[i].myXYZPoints[j].Z())); - + aProfile->GetProfileUZ()->SetSectionType(0, myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE); + aProfile->GetProfileUZ()->SetSectionClosed(0, myCurveBlocks[i].myIsClosed ? true : false); aProfile->SetParametricPoints(aPointList); if ( ! (myCurveBlocks[i].myAdditionalCurveInfo[0] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[1] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[2] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[3] == 0) ) @@ -127,7 +174,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); } } @@ -137,8 +184,10 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec HYDROData_Profile::ProfilePoints aPointList; for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++) aPointList.Append(myCurveBlocks[i].myXYZPoints[j]); + aProfile->GetProfileUZ()->SetSectionType(0, myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE); + aProfile->GetProfileUZ()->SetSectionClosed(0, myCurveBlocks[i].myIsClosed ? true : false); aProfile->SetProfilePoints(aPointList); - aProfile->SetName(myCurveBlocks[i].myName + "_profile"); + aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile")); theEntities.Append(aProfile); } } @@ -147,8 +196,6 @@ void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollec } - - bool HYDROData_SinusX::Parse(QFile& theFile) { if ( !theFile.isOpen() ) diff --git a/src/HYDROData/HYDROData_SinusX.h b/src/HYDROData/HYDROData_SinusX.h index 0d8e9e15..cc743d71 100644 --- a/src/HYDROData/HYDROData_SinusX.h +++ b/src/HYDROData/HYDROData_SinusX.h @@ -27,10 +27,10 @@ #include #include #include +#include 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& theEntities); bool Parse( QFile& theFile ); + void CollectExistingNames(Handle_HYDROData_Document theDocument); + QString GetName(const QString& theName); private: std::vector myCurveBlocks; + QStringList myExistingNames; }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index a91b6064..f251d775 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -908,7 +908,7 @@ Would you like to remove all references from the image? DSK_IMPORT_SINUSX - Import entities from SinusX file + Import from SinusX DSK_LOAD_VISUAL_STATE @@ -1200,7 +1200,7 @@ Would you like to remove all references from the image? MEN_IMPORT_SINUSX - Import entities from SinusX file + Import from SinusX MEN_LOAD_VISUAL_STATE @@ -1469,7 +1469,7 @@ Would you like to remove all references from the image? STB_IMPORT_SINUSX - Import entities from SinusX file + Import from SinusX STB_LOAD_VISUAL_STATE @@ -2122,7 +2122,7 @@ file cannot be correctly imported for an Obstacle definition. HYDROGUI_ImportSinusXOp IMPORT_SINUSX - Import entities from SinusX file + Import from SinusX SINUSX_FILTER